Skip to content

Commit bcd2817

Browse files
Merge pull request #9382 from adrian-prantl/137087616
[lldb] Introduce precise Fallback SwiftASTContexts.
2 parents c45216d + 96d93d4 commit bcd2817

File tree

7 files changed

+199
-104
lines changed

7 files changed

+199
-104
lines changed

lldb/source/Plugins/Language/Swift/SwiftUnsafeTypes.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,11 @@ SwiftUnsafeRawBufferPointer::SwiftUnsafeRawBufferPointer(ValueObject &valobj)
203203
}
204204

205205
lldb::ChildCacheState SwiftUnsafeRawBufferPointer::Update() {
206-
if (!m_valobj.GetNumChildren())
206+
auto num_or_error = m_valobj.GetNumChildren();
207+
if (!num_or_error) {
208+
llvm::consumeError(num_or_error.takeError());
207209
return ChildCacheState::eRefetch;
210+
}
208211

209212
// Here is the layout of Swift's UnsafeRaw[Mutable]BufferPointer.
210213
// It's a view of the raw bytes of the pointee object. Each byte is viewed as

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp

Lines changed: 187 additions & 95 deletions
Large diffs are not rendered by default.

lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ class SwiftASTContext : public TypeSystemSwift {
207207
/// context.
208208
static lldb::TypeSystemSP
209209
CreateInstance(const SymbolContext &sc,
210-
TypeSystemSwiftTypeRefForExpressions &typeref_typesystem,
210+
TypeSystemSwiftTypeRef &typeref_typesystem,
211211
const char *extra_options = nullptr);
212212

213213
static void EnumerateSupportedLanguages(

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1839,8 +1839,7 @@ TypeSystemSwiftTypeRef::GetSwiftASTContext(const SymbolContext &sc) const {
18391839

18401840
// Create a new SwiftASTContextForExpressions.
18411841
TypeSystemSP ts = SwiftASTContext::CreateInstance(
1842-
LanguageType::eLanguageTypeSwift, *m_module,
1843-
*const_cast<TypeSystemSwiftTypeRef *>(this));
1842+
sc, *const_cast<TypeSystemSwiftTypeRef *>(this));
18441843
m_swift_ast_context_map.insert({key, ts});
18451844

18461845
auto *swift_ast_context = llvm::dyn_cast_or_null<SwiftASTContext>(ts.get());

lldb/test/API/lang/swift/clangimporter/config_macros/TestSwiftDedupMacros.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def testSwiftDebugMacros(self):
4949
# CHECK: SwiftASTContextForExpressions{{.*}}-DSPACE
5050
# CHECK-NOT: {{ SPACE}}
5151
# CHECK: SwiftASTContextForExpressions{{.*}}-UNDEBUG
52-
# CHECK: SwiftASTContextForModule("libDylib{{.*}}-DDEBUG=1
53-
# CHECK: SwiftASTContextForModule("libDylib{{.*}}-DSPACE
52+
# CHECK: SwiftASTContext(module: "Dylib{{.*}}-DDEBUG=1
53+
# CHECK: SwiftASTContext(module: "Dylib{{.*}}-DSPACE
5454
# CHECK-NOT: {{ SPACE}}
55-
# CHECK: SwiftASTContextForModule("libDylib{{.*}}-UNDEBUG
55+
# CHECK: SwiftASTContext(module: "Dylib{{.*}}-UNDEBUG

lldb/test/API/lang/swift/deployment_target/TestSwiftDeploymentTarget.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,5 @@ def test_swift_precise_compiler_invocation_triple(self):
9191
self.filecheck(
9292
f'platform shell cat "{log}"', __file__, "-check-prefix=CHECK-PRECISE"
9393
)
94-
# CHECK-PRECISE: SwiftASTContextForExpressions(module: "NewerTarget", cu: "NewerTarget.swift")::CreateInstance() -- Fully specified target triple {{.*}}-apple-macosx11.1.0
94+
# CHECK-PRECISE: SwiftASTContextForExpressions(module: "NewerTarget", cu: "NewerTarget.swift")::CreateInstance() -- Fully specified triple {{.*}}-apple-macosx11.1.0
9595
# CHECK-PRECISE: SwiftASTContextForExpressions(module: "NewerTarget", cu: "NewerTarget.swift")::SetTriple("{{.*}}-apple-macosx11.1.0")

lldb/test/API/lang/swift/tripleDetection/TestSwiftTripleDetection.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,6 @@ def test(self):
2626
process = target.LaunchSimple(None, None, self.get_process_working_directory())
2727
self.expect("expression 1")
2828
self.filecheck('platform shell cat "%s"' % types_log, __file__)
29-
# CHECK: {{SwiftASTContextForExpressions.*Preferring module triple .*-apple-macos.[0-9.]+ over target triple .*-apple-macos-unknown.}}
29+
# CHECK: {{SwiftASTContextForExpressions.*Module triple: ".*-apple-macos.[0-9.]+"}}
30+
# CHECK: {{SwiftASTContextForExpressions.*Target triple: ".*-apple-macos-unknown"}}
3031
# CHECK: {{SwiftASTContextForExpressions.*setting to ".*-apple-macos.[0-9.]+"}}

0 commit comments

Comments
 (0)