Skip to content

Commit c264004

Browse files
committed
[lldb] Fix Dlang symbol test breakage (llvm#94046)
Follow up to llvm#93881. Updates missed tests and handles `_Dmain`. (cherry picked from commit 68fdc1c)
1 parent 85ceed5 commit c264004

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lldb/source/Core/Mangled.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,12 @@ Mangled::ManglingScheme Mangled::GetManglingScheme(llvm::StringRef const name) {
5959
return Mangled::eManglingSchemeRustV0;
6060

6161
if (name.startswith("_D")) {
62-
// A dlang mangled name begins with `_D`, followed by a numeric length.
62+
// A dlang mangled name begins with `_D`, followed by a numeric length. One
63+
// known exception is the symbol `_Dmain`.
6364
// See `SymbolName` and `LName` in
6465
// https://dlang.org/spec/abi.html#name_mangling
6566
llvm::StringRef buf = name.drop_front(2);
66-
if (!buf.empty() && llvm::isDigit(buf.front()))
67+
if (!buf.empty() && (llvm::isDigit(buf.front()) || name == "_Dmain"))
6768
return Mangled::eManglingSchemeD;
6869
}
6970

lldb/unittests/Core/MangledTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ TEST(MangledTest, ResultForValidDLangName) {
8181
EXPECT_STREQ(expected_result.GetCString(), the_demangled.GetCString());
8282
}
8383

84-
TEST(MangledTest, EmptyForInvalidDLangName) {
84+
TEST(MangledTest, SameForInvalidDLangPrefixedName) {
8585
ConstString mangled_name("_DDD");
8686
Mangled the_mangled(mangled_name);
8787
ConstString the_demangled = the_mangled.GetDemangledName();
8888

89-
EXPECT_STREQ("", the_demangled.GetCString());
89+
EXPECT_STREQ("_DDD", the_demangled.GetCString());
9090
}
9191

9292
TEST(MangledTest, BoolConversionOperator) {

0 commit comments

Comments
 (0)