-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[lldb] Fix CXX's SymbolNameFitsToLanguage matching other languages #153685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The current implementation of CPlusPlusLanguage::SymbolNameFitsToLanguage will return true if there is any mangling scheme for the symbol, not just C++. rdar://158352104
|
@llvm/pr-subscribers-lldb Author: Augusto Noronha (augusto2112) ChangesThe current implementation of Full diff: https://github.com/llvm/llvm-project/pull/153685.diff 2 Files Affected:
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 3118ff151d1cf..e329cf231db82 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -105,7 +105,8 @@ CPlusPlusLanguage::GetFunctionNameInfo(ConstString name) const {
bool CPlusPlusLanguage::SymbolNameFitsToLanguage(Mangled mangled) const {
const char *mangled_name = mangled.GetMangledName().GetCString();
- return mangled_name && Mangled::IsMangledName(mangled_name);
+ return mangled_name && Mangled::GetManglingScheme(mangled_name) ==
+ Mangled::eManglingSchemeItanium;
}
ConstString CPlusPlusLanguage::GetDemangledFunctionNameWithoutArguments(
diff --git a/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp b/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
index 6eeb4f54952b9..af01303cc4689 100644
--- a/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
+++ b/lldb/unittests/Language/CPlusPlus/CPlusPlusLanguageTest.cpp
@@ -397,3 +397,16 @@ TEST(CPlusPlusLanguage, CPlusPlusNameParser) {
// Don't crash.
CPlusPlusNameParser((const char *)nullptr);
}
+
+TEST(CPlusPlusLanguage, DoesNotMatchCxx) {
+ // Test that a symbol name that is NOT C++ does not match C++.
+
+ SubsystemRAII<CPlusPlusLanguage> lang;
+ Language *CPlusPlusLang =
+ Language::FindPlugin(lldb::eLanguageTypeC_plus_plus);
+
+ EXPECT_TRUE(CPlusPlusLang != nullptr);
+
+ Mangled swiftSymbol("$sS");
+ EXPECT_FALSE(CPlusPlusLang->SymbolNameFitsToLanguage(swiftSymbol));
+}
|
| bool CPlusPlusLanguage::SymbolNameFitsToLanguage(Mangled mangled) const { | ||
| const char *mangled_name = mangled.GetMangledName().GetCString(); | ||
| return mangled_name && Mangled::IsMangledName(mangled_name); | ||
| return mangled_name && Mangled::GetManglingScheme(mangled_name) == |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm what about MS ABI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I could check if it's Itanium of MSVC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea I suppose that should work. It's all best effort I guess, cause non-C++ languages may choose to mangle with the Itanium ABI. But yea your changes make sense
| CPlusPlusNameParser((const char *)nullptr); | ||
| } | ||
|
|
||
| TEST(CPlusPlusLanguage, DoesNotMatchCxx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're adding this here, can you add a case where we do match C++? Using Itanium and MS ABI examples?
bulbazord
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to Michael's comments. :)
|
|
||
| EXPECT_TRUE(CPlusPlusLang != nullptr); | ||
|
|
||
| Mangled itaniumSymbol("_ZFoo"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that it matters much, but should we make these actually demangle-able symbols?
Some minimal ones are:
_Z3Foo
___Z3Bar_block_invoke
?x@@3AH
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah only saw your comment after merging. I'll make them real symbols.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here #153857
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/59/builds/22691 Here is the relevant piece of the build log for the reference |
…lvm#153685) The current implementation of CPlusPlusLanguage::SymbolNameFitsToLanguage will return true if the symbol is mangled for any language that lldb knows about. (cherry picked from commit c6ea7d7)
The current implementation of
CPlusPlusLanguage::SymbolNameFitsToLanguage will return true if the symbol is mangled for any language that lldb knows about.