Skip to content

[lldb] Fix Dlang symbol test breakage #94046

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

Merged

Conversation

kastiglione
Copy link
Contributor

@kastiglione kastiglione commented May 31, 2024

Follow up to #93881. Updates missed tests and handles _Dmain.

@kastiglione kastiglione requested a review from JDevlieghere as a code owner May 31, 2024 20:48
@llvmbot llvmbot added the lldb label May 31, 2024
@llvmbot
Copy link
Member

llvmbot commented May 31, 2024

@llvm/pr-subscribers-lldb

Author: Dave Lee (kastiglione)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/94046.diff

2 Files Affected:

  • (modified) lldb/source/Core/Mangled.cpp (+3-2)
  • (modified) lldb/unittests/Core/MangledTest.cpp (+2-2)
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) {

@kastiglione kastiglione requested a review from adrian-prantl May 31, 2024 20:49
@kastiglione kastiglione merged commit 68fdc1c into llvm:main May 31, 2024
@kastiglione kastiglione deleted the lldb-Fix-Dlang-symbol-test-breakage branch May 31, 2024 21:04
kastiglione added a commit to swiftlang/llvm-project that referenced this pull request Jun 3, 2024
Follow up to llvm#93881. Updates missed tests and handles `_Dmain`.

(cherry picked from commit 68fdc1c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants