Skip to content

Commit 3b98a9b

Browse files
committed
[lldb] Fix CXX's SymbolNameFitsToLanguage matching other languages
The current implementation of CPlusPlusLanguage::SymbolNameFitsToLanguage will return true if there is any mangling scheme for the symbol, not just C++. rdar://158352104
1 parent 52c9489 commit 3b98a9b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ CPlusPlusLanguage::GetFunctionNameInfo(ConstString name) const {
105105

106106
bool CPlusPlusLanguage::SymbolNameFitsToLanguage(Mangled mangled) const {
107107
const char *mangled_name = mangled.GetMangledName().GetCString();
108-
return mangled_name && Mangled::IsMangledName(mangled_name);
108+
return mangled_name && Mangled::GetManglingScheme(mangled_name) ==
109+
Mangled::eManglingSchemeItanium;
109110
}
110111

111112
ConstString CPlusPlusLanguage::GetDemangledFunctionNameWithoutArguments(

lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,3 +397,16 @@ TEST(CPlusPlusLanguage, CPlusPlusNameParser) {
397397
// Don't crash.
398398
CPlusPlusNameParser((const char *)nullptr);
399399
}
400+
401+
TEST(CPlusPlusLanguage, DoesNotMatchCxx) {
402+
// Test that a symbol name that is NOT C++ does not match C++.
403+
404+
SubsystemRAII<CPlusPlusLanguage> lang;
405+
Language *CPlusPlusLang =
406+
Language::FindPlugin(lldb::eLanguageTypeC_plus_plus);
407+
408+
EXPECT_TRUE(CPlusPlusLang != nullptr);
409+
410+
Mangled swiftSymbol("$sS");
411+
EXPECT_FALSE(CPlusPlusLang->SymbolNameFitsToLanguage(swiftSymbol));
412+
}

0 commit comments

Comments
 (0)