[Lldb-commits] [lldb] 68fdc1c - [lldb] Fix Dlang symbol test breakage (#94046)
via lldb-commits
lldb-commits at lists.llvm.org
Fri May 31 14:04:44 PDT 2024
Author: Dave Lee
Date: 2024-05-31T14:04:40-07:00
New Revision: 68fdc1cf87eb04686e079af27eaeec0f1c41f8cc
URL: https://github.com/llvm/llvm-project/commit/68fdc1cf87eb04686e079af27eaeec0f1c41f8cc
DIFF: https://github.com/llvm/llvm-project/commit/68fdc1cf87eb04686e079af27eaeec0f1c41f8cc.diff
LOG: [lldb] Fix Dlang symbol test breakage (#94046)
Follow up to #93881. Updates missed tests and handles `_Dmain`.
Added:
Modified:
lldb/source/Core/Mangled.cpp
lldb/unittests/Core/MangledTest.cpp
Removed:
################################################################################
diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 3142c81d12ed9..387c4fac6b0f8 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -50,11 +50,12 @@ Mangled::ManglingScheme Mangled::GetManglingScheme(llvm::StringRef const name) {
return Mangled::eManglingSchemeRustV0;
if (name.starts_with("_D")) {
- // A dlang mangled name begins with `_D`, followed by a numeric length.
+ // A dlang mangled name begins with `_D`, followed by a numeric length. One
+ // known exception is the symbol `_Dmain`.
// See `SymbolName` and `LName` in
// https://dlang.org/spec/abi.html#name_mangling
llvm::StringRef buf = name.drop_front(2);
- if (!buf.empty() && llvm::isDigit(buf.front()))
+ if (!buf.empty() && (llvm::isDigit(buf.front()) || name == "_Dmain"))
return Mangled::eManglingSchemeD;
}
diff --git a/lldb/unittests/Core/MangledTest.cpp b/lldb/unittests/Core/MangledTest.cpp
index 4efc961d371d3..a3760ba43b3c9 100644
--- a/lldb/unittests/Core/MangledTest.cpp
+++ b/lldb/unittests/Core/MangledTest.cpp
@@ -81,12 +81,12 @@ TEST(MangledTest, ResultForValidDLangName) {
EXPECT_STREQ(expected_result.GetCString(), the_demangled.GetCString());
}
-TEST(MangledTest, EmptyForInvalidDLangName) {
+TEST(MangledTest, SameForInvalidDLangPrefixedName) {
ConstString mangled_name("_DDD");
Mangled the_mangled(mangled_name);
ConstString the_demangled = the_mangled.GetDemangledName();
- EXPECT_STREQ("", the_demangled.GetCString());
+ EXPECT_STREQ("_DDD", the_demangled.GetCString());
}
TEST(MangledTest, RecognizeSwiftMangledNames) {
More information about the lldb-commits
mailing list