[Lldb-commits] [lldb] [LLDB] Handle i686 mingw32 mangling prefix (PR #160930)
via lldb-commits
lldb-commits at lists.llvm.org
Fri Sep 26 11:37:23 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lldb
Author: nerix (Nerixyz)
<details>
<summary>Changes</summary>
On i686 mingw32, `__Z` is used instead of `_Z`. `Mangled` didn't handle this and assumed the given string is not mangled.
Found in https://github.com/llvm/llvm-project/pull/149701#issuecomment-3333291102.
---
Full diff: https://github.com/llvm/llvm-project/pull/160930.diff
2 Files Affected:
- (modified) lldb/source/Core/Mangled.cpp (+4)
- (modified) lldb/unittests/Core/MangledTest.cpp (+17)
``````````diff
diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp
index 91b9c0007617d..13788e2a4992c 100644
--- a/lldb/source/Core/Mangled.cpp
+++ b/lldb/source/Core/Mangled.cpp
@@ -63,6 +63,10 @@ Mangled::ManglingScheme Mangled::GetManglingScheme(llvm::StringRef const name) {
if (name.starts_with("_Z"))
return Mangled::eManglingSchemeItanium;
+ // __Z is used on i686 mingw32
+ if (name.starts_with("__Z"))
+ return Mangled::eManglingSchemeItanium;
+
// ___Z is a clang extension of block invocations
if (name.starts_with("___Z"))
return Mangled::eManglingSchemeItanium;
diff --git a/lldb/unittests/Core/MangledTest.cpp b/lldb/unittests/Core/MangledTest.cpp
index cbc0c5d951b99..437290947cb57 100644
--- a/lldb/unittests/Core/MangledTest.cpp
+++ b/lldb/unittests/Core/MangledTest.cpp
@@ -114,6 +114,23 @@ TEST(MangledTest, SameForInvalidDLangPrefixedName) {
EXPECT_STREQ("_DDD", the_demangled.GetCString());
}
+TEST(MangledTest, ResultForValidMingw32Name) {
+ ConstString mangled_name("__Z7recursei");
+ Mangled the_mangled(mangled_name);
+ ConstString the_demangled = the_mangled.GetDemangledName();
+
+ ConstString expected_result("recurse(int)");
+ EXPECT_STREQ(expected_result.GetCString(), the_demangled.GetCString());
+}
+
+TEST(MangledTest, EmptyForInvalidMingw32Name) {
+ ConstString mangled_name("__Zzrecursei");
+ Mangled the_mangled(mangled_name);
+ ConstString the_demangled = the_mangled.GetDemangledName();
+
+ EXPECT_STREQ("", the_demangled.GetCString());
+}
+
TEST(MangledTest, RecognizeSwiftMangledNames) {
llvm::StringRef valid_swift_mangled_names[] = {
"_TtC4main7MyClass", // Mangled objc class name
``````````
</details>
https://github.com/llvm/llvm-project/pull/160930
More information about the lldb-commits
mailing list