Skip to content

Commit e90f48a

Browse files
Merge pull request #3752 from adrian-prantl/lookupinfo
Add back Swift-specific LookupInfo code.
2 parents 9142d4a + 1515594 commit e90f48a

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

lldb/source/Core/Module.cpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -648,23 +648,17 @@ Module::LookupInfo::LookupInfo(ConstString name,
648648
llvm::StringRef basename;
649649
llvm::StringRef context;
650650

651-
// FIXME: The commit that introduced GetFunctionNameInfo
652-
// will require us to implement that function in the SwiftLanguage
653-
// plugin. However, there's a revert commit following on to
654-
// this one, which would force us to remove this again. Instead,
655-
// I'm going to accept the llvm side of the change w/o implementing
656-
// the SwiftLanguage functions for now. But when the revert is
657-
// again reverted, we'll have to implement this function, or if
658-
// the patch gets abandoned, we'll have to put the code back the
659-
// way it was before this commit.
660-
661651
if (name_type_mask & eFunctionNameTypeAuto) {
662652
if (CPlusPlusLanguage::IsCPPMangledName(name_cstr))
663653
m_name_type_mask = eFunctionNameTypeFull;
664654
else if ((language == eLanguageTypeUnknown ||
665655
Language::LanguageIsObjC(language)) &&
666656
ObjCLanguage::IsPossibleObjCMethodName(name_cstr))
667657
m_name_type_mask = eFunctionNameTypeFull;
658+
#ifdef LLDB_ENABLE_SWIFT
659+
else if (SwiftLanguageRuntime::IsSwiftMangledName(name.GetStringRef()))
660+
m_name_type_mask = eFunctionNameTypeFull;
661+
#endif // LLDB_ENABLE_SWIFT
668662
else if (Language::LanguageIsC(language)) {
669663
m_name_type_mask = eFunctionNameTypeFull;
670664
} else {
@@ -674,7 +668,20 @@ Module::LookupInfo::LookupInfo(ConstString name,
674668
m_name_type_mask |= eFunctionNameTypeSelector;
675669

676670
CPlusPlusLanguage::MethodName cpp_method(name);
677-
basename = cpp_method.GetBasename();
671+
672+
#ifdef LLDB_ENABLE_SWIFT
673+
SwiftLanguageRuntime::MethodName swift_method(name, true);
674+
675+
if ((language == eLanguageTypeUnknown ||
676+
language == eLanguageTypeSwift) &&
677+
swift_method.IsValid())
678+
basename = swift_method.GetBasename();
679+
#endif // LLDB_ENABLE_SWIFT
680+
if ((language == eLanguageTypeUnknown ||
681+
Language::LanguageIsCFamily(language)) &&
682+
cpp_method.IsValid())
683+
basename = cpp_method.GetBasename();
684+
678685
if (basename.empty()) {
679686
if (CPlusPlusLanguage::ExtractContextAndIdentifier(name_cstr, context,
680687
basename))
@@ -692,6 +699,13 @@ Module::LookupInfo::LookupInfo(ConstString name,
692699
// If they've asked for a CPP method or function name and it can't be
693700
// that, we don't even need to search for CPP methods or names.
694701
CPlusPlusLanguage::MethodName cpp_method(name);
702+
703+
#ifdef LLDB_ENABLE_SWIFT
704+
SwiftLanguageRuntime::MethodName swift_method(name, true);
705+
if (swift_method.IsValid())
706+
basename = swift_method.GetBasename();
707+
#endif // LLDB_ENABLE_SWIFT
708+
695709
if (cpp_method.IsValid()) {
696710
basename = cpp_method.GetBasename();
697711

0 commit comments

Comments
 (0)