Skip to content

[lldb] Introduce precise Fallback SwiftASTContexts. #9382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lldb/source/Plugins/Language/Swift/SwiftUnsafeTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,11 @@ SwiftUnsafeRawBufferPointer::SwiftUnsafeRawBufferPointer(ValueObject &valobj)
}

lldb::ChildCacheState SwiftUnsafeRawBufferPointer::Update() {
if (!m_valobj.GetNumChildren())
auto num_or_error = m_valobj.GetNumChildren();
if (!num_or_error) {
llvm::consumeError(num_or_error.takeError());
return ChildCacheState::eRefetch;
}

// Here is the layout of Swift's UnsafeRaw[Mutable]BufferPointer.
// It's a view of the raw bytes of the pointee object. Each byte is viewed as
Expand Down
282 changes: 187 additions & 95 deletions lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class SwiftASTContext : public TypeSystemSwift {
/// context.
static lldb::TypeSystemSP
CreateInstance(const SymbolContext &sc,
TypeSystemSwiftTypeRefForExpressions &typeref_typesystem,
TypeSystemSwiftTypeRef &typeref_typesystem,
const char *extra_options = nullptr);

static void EnumerateSupportedLanguages(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1839,8 +1839,7 @@ TypeSystemSwiftTypeRef::GetSwiftASTContext(const SymbolContext &sc) const {

// Create a new SwiftASTContextForExpressions.
TypeSystemSP ts = SwiftASTContext::CreateInstance(
LanguageType::eLanguageTypeSwift, *m_module,
*const_cast<TypeSystemSwiftTypeRef *>(this));
sc, *const_cast<TypeSystemSwiftTypeRef *>(this));
m_swift_ast_context_map.insert({key, ts});

auto *swift_ast_context = llvm::dyn_cast_or_null<SwiftASTContext>(ts.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def testSwiftDebugMacros(self):
# CHECK: SwiftASTContextForExpressions{{.*}}-DSPACE
# CHECK-NOT: {{ SPACE}}
# CHECK: SwiftASTContextForExpressions{{.*}}-UNDEBUG
# CHECK: SwiftASTContextForModule("libDylib{{.*}}-DDEBUG=1
# CHECK: SwiftASTContextForModule("libDylib{{.*}}-DSPACE
# CHECK: SwiftASTContext(module: "Dylib{{.*}}-DDEBUG=1
# CHECK: SwiftASTContext(module: "Dylib{{.*}}-DSPACE
# CHECK-NOT: {{ SPACE}}
# CHECK: SwiftASTContextForModule("libDylib{{.*}}-UNDEBUG
# CHECK: SwiftASTContext(module: "Dylib{{.*}}-UNDEBUG
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ def test_swift_precise_compiler_invocation_triple(self):
self.filecheck(
f'platform shell cat "{log}"', __file__, "-check-prefix=CHECK-PRECISE"
)
# CHECK-PRECISE: SwiftASTContextForExpressions(module: "NewerTarget", cu: "NewerTarget.swift")::CreateInstance() -- Fully specified target triple {{.*}}-apple-macosx11.1.0
# CHECK-PRECISE: SwiftASTContextForExpressions(module: "NewerTarget", cu: "NewerTarget.swift")::CreateInstance() -- Fully specified triple {{.*}}-apple-macosx11.1.0
# CHECK-PRECISE: SwiftASTContextForExpressions(module: "NewerTarget", cu: "NewerTarget.swift")::SetTriple("{{.*}}-apple-macosx11.1.0")
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ def test(self):
process = target.LaunchSimple(None, None, self.get_process_working_directory())
self.expect("expression 1")
self.filecheck('platform shell cat "%s"' % types_log, __file__)
# CHECK: {{SwiftASTContextForExpressions.*Preferring module triple .*-apple-macos.[0-9.]+ over target triple .*-apple-macos-unknown.}}
# CHECK: {{SwiftASTContextForExpressions.*Module triple: ".*-apple-macos.[0-9.]+"}}
# CHECK: {{SwiftASTContextForExpressions.*Target triple: ".*-apple-macos-unknown"}}
# CHECK: {{SwiftASTContextForExpressions.*setting to ".*-apple-macos.[0-9.]+"}}