Skip to content

Commit 2e31fa3

Browse files
authored
[lldb] Try GetTargetWP before GetSwiftASTContext (#6656)
`LookupClangType` needs the `Target` instance, and it has used `GetSwiftASTContext` to get to the target. It does not need anything directly from the ASTContext. To avoid unnecessarily loading Swift ASTContexts from `TypeSystemSwiftTypeRef`, this change tries `GetTargetWP` first, and if that succeeds, then the call to `GetSwiftASTContext` can be avoided entirely.
1 parent 97f6808 commit 2e31fa3

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,13 @@ TypeSP TypeSystemSwiftTypeRef::LookupClangType(
229229
return result;
230230
}
231231

232-
SwiftASTContext *target_holder = GetSwiftASTContext();
233-
if (!target_holder)
234-
return {};
235-
TargetSP target_sp = target_holder->GetTargetWP().lock();
232+
TargetSP target_sp = GetTargetWP().lock();
233+
if (!target_sp) {
234+
SwiftASTContext *target_holder = GetSwiftASTContext();
235+
if (!target_holder)
236+
return {};
237+
target_sp = target_holder->GetTargetWP().lock();
238+
}
236239
if (!target_sp)
237240
return {};
238241
target_sp->GetImages().ForEach([&](const ModuleSP &module) -> bool {

0 commit comments

Comments
 (0)