[Lldb-commits] [lldb] [lldb] Fix Dlang symbol test breakage (PR #94046)

Dave Lee via lldb-commits lldb-commits at lists.llvm.org
Fri May 31 13:48:06 PDT 2024


https://github.com/kastiglione created https://github.com/llvm/llvm-project/pull/94046

None

>From a783b4c189d3c5387418e58156667ecc8382b5ce Mon Sep 17 00:00:00 2001
From: Dave Lee <davelee.com at gmail.com>
Date: Fri, 31 May 2024 13:47:24 -0700
Subject: [PATCH] [lldb] Fix Dlang symbol test breakage

---
 lldb/source/Core/Mangled.cpp        | 5 +++--
 lldb/unittests/Core/MangledTest.cpp | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

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