Skip to content

Commit 813b7ba

Browse files
Merge pull request #6957 from apple/dl/lldb-Avoid-eager-loading-of-SwiftASTContext-from-TSSwiftTypeRef-SetTriple
[lldb] Avoid eager loading of SwiftASTContext from TSSwiftTypeRef::SetTriple
2 parents 5b25d9d + 9aa46a4 commit 813b7ba

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,8 @@ SwiftASTContext *TypeSystemSwiftTypeRef::GetSwiftASTContext() const {
14551455
*const_cast<TypeSystemSwiftTypeRef *>(this));
14561456
m_swift_ast_context =
14571457
llvm::dyn_cast_or_null<SwiftASTContext>(m_swift_ast_context_sp.get());
1458+
if (m_swift_ast_context && !m_swift_ast_context_triple.str().empty())
1459+
m_swift_ast_context->SetTriple(m_swift_ast_context_triple);
14581460
}
14591461
return m_swift_ast_context;
14601462
}
@@ -1522,8 +1524,10 @@ llvm::Triple TypeSystemSwiftTypeRef::GetTriple() const {
15221524
}
15231525

15241526
void TypeSystemSwiftTypeRef::SetTriple(const llvm::Triple triple) {
1525-
if (auto *swift_ast_context = GetSwiftASTContext())
1527+
if (auto *swift_ast_context = GetSwiftASTContextOrNull())
15261528
swift_ast_context->SetTriple(triple);
1529+
else
1530+
m_swift_ast_context_triple = triple;
15271531
}
15281532

15291533
void TypeSystemSwiftTypeRef::ClearModuleDependentCaches() {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ class TypeSystemSwiftTypeRef : public TypeSystemSwift {
427427
#endif
428428

429429
/// The sibling SwiftASTContext.
430+
llvm::Triple m_swift_ast_context_triple;
430431
mutable bool m_swift_ast_context_initialized = false;
431432
mutable lldb::TypeSystemSP m_swift_ast_context_sp;
432433
mutable SwiftASTContext *m_swift_ast_context = nullptr;

0 commit comments

Comments
 (0)