Skip to content

Commit 9a9c311

Browse files
committed
Reject Objective-C types in SwiftLanguage::GetPossibleFormattersMatches()
This mostly NFC commit avoids redundant work when formatting Objective-C(++) types, especially in Objective-C contexts. LLDB tries to format all Objective-C and Swift types in both languages. However the formatting of Objective-C types in Swift effectively just wraps the Objective-C type and the end result is the same as if we just formatted the type as Objective-C to begin with. Due to the incomplete ClangImporter implementation for C++ this this could also lead to crashes that can be avoided by just formatting ObjC types as Objective-C. rdar://75030678
1 parent bd2e42c commit 9a9c311

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,15 @@ std::vector<ConstString> SwiftLanguage::GetPossibleFormattersMatches(
884884
if (use_dynamic == lldb::eNoDynamicValues)
885885
return result;
886886

887+
// There is no point in attempting to format Clang types here, since
888+
// FormatManager will try to format all Swift types also as
889+
// Objective-C types and vice versa. Due to the incomplete
890+
// ClangImporter implementation for C++, continuing here for
891+
// Objective-C++ types can actually lead to crashes that can be
892+
// avoided by just formatting those types as Objective-C types.
893+
if (valobj.GetObjectRuntimeLanguage() == eLanguageTypeObjC)
894+
return result;
895+
887896
SwiftASTContextLock scratch_ctx_lock(&valobj.GetExecutionContextRef());
888897
CompilerType compiler_type(valobj.GetCompilerType());
889898

0 commit comments

Comments
 (0)