Skip to content

Commit 68fdc1c

Browse files
authored
[lldb] Fix Dlang symbol test breakage (#94046)
Follow up to #93881. Updates missed tests and handles `_Dmain`.
1 parent 2db190f commit 68fdc1c

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
@@ -50,11 +50,12 @@ Mangled::ManglingScheme Mangled::GetManglingScheme(llvm::StringRef const name) {
5050
return Mangled::eManglingSchemeRustV0;
5151

5252
if (name.starts_with("_D")) {
53-
// A dlang mangled name begins with `_D`, followed by a numeric length.
53+
// A dlang mangled name begins with `_D`, followed by a numeric length. One
54+
// known exception is the symbol `_Dmain`.
5455
// See `SymbolName` and `LName` in
5556
// https://dlang.org/spec/abi.html#name_mangling
5657
llvm::StringRef buf = name.drop_front(2);
57-
if (!buf.empty() && llvm::isDigit(buf.front()))
58+
if (!buf.empty() && (llvm::isDigit(buf.front()) || name == "_Dmain"))
5859
return Mangled::eManglingSchemeD;
5960
}
6061

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, RecognizeSwiftMangledNames) {

0 commit comments

Comments
 (0)