[libcxx-commits] [libcxxabi] 4601bcd - [libcxxabi][Demangle] Don't drop ctor/dtor name for abi-tagged structures

Michael Buch via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 19 04:07:21 PDT 2023


Author: Michael Buch
Date: 2023-03-19T11:03:54Z
New Revision: 4601bcdb7ed3168053aa6d70abedb17c3fffa0d2

URL: https://github.com/llvm/llvm-project/commit/4601bcdb7ed3168053aa6d70abedb17c3fffa0d2
DIFF: https://github.com/llvm/llvm-project/commit/4601bcdb7ed3168053aa6d70abedb17c3fffa0d2.diff

LOG: [libcxxabi][Demangle] Don't drop ctor/dtor name for abi-tagged structures

Before this patch we would demangle abi-tagged structures as follows:
```
$ c++filt -n _ZN1SB5OuterC2Ev
S[abi:Outer]:()

$ c++filt -n _ZN1SB5OuterD2Ev
S[abi:Outer]::~()
```

This is because `Node::getBaseName` was unimplemented for the
`AbiTagAttr` node, which meant that when we tried printing `CtorDtorName`
where its `Basename` `Node` was an `AbiTagAttr`, we'd drop the
name.

Addresses https://github.com/llvm/llvm-project/issues/61213

Differential Revision: https://reviews.llvm.org/D145492

Added: 
    

Modified: 
    libcxxabi/src/demangle/ItaniumDemangle.h
    libcxxabi/test/test_demangle.pass.cpp
    llvm/include/llvm/Demangle/ItaniumDemangle.h
    llvm/test/tools/llvm-cxxfilt/abitag.test

Removed: 
    


################################################################################
diff  --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index 22a35a8152998..fd66e9570e7a9 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -544,6 +544,8 @@ struct AbiTagAttr : Node {
 
   template<typename Fn> void match(Fn F) const { F(Base, Tag); }
 
+  StringView getBaseName() const override { return Base->getBaseName(); }
+
   void printLeft(OutputBuffer &OB) const override {
     Base->printLeft(OB);
     OB += "[abi:";

diff  --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index 0607c4ef7efaa..00592eede9a12 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -30112,6 +30112,8 @@ const char* cases[][2] =
      "::basic_ostream()"},
     {"_ZNSsC1Ev", "std::basic_string<char, std::char_traits<char>,"
      " std::allocator<char>>::basic_string()"},
+    {"_ZN1SB8ctor_tagC2Ev", "S[abi:ctor_tag]::S()"},
+    {"_ZN1SB8ctor_tagD2Ev", "S[abi:ctor_tag]::~S()"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);

diff  --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 0dd49ea91455b..acdf570e1a6ba 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -537,6 +537,8 @@ struct AbiTagAttr : Node {
 
   template<typename Fn> void match(Fn F) const { F(Base, Tag); }
 
+  StringView getBaseName() const override { return Base->getBaseName(); }
+
   void printLeft(OutputBuffer &OB) const override {
     Base->printLeft(OB);
     OB += "[abi:";

diff  --git a/llvm/test/tools/llvm-cxxfilt/abitag.test b/llvm/test/tools/llvm-cxxfilt/abitag.test
index 172062b8d658b..a617f164320cc 100644
--- a/llvm/test/tools/llvm-cxxfilt/abitag.test
+++ b/llvm/test/tools/llvm-cxxfilt/abitag.test
@@ -1,6 +1,7 @@
-RUN: llvm-cxxfilt -n _Z14returns_stringB5cxx11v _Z6globalB5cxx11 _Z6globalB12a_longer_tag | FileCheck %s
+RUN: llvm-cxxfilt -n _Z14returns_stringB5cxx11v _Z6globalB5cxx11 _Z6globalB12a_longer_tag _ZN6globalB3TagC2Ev _ZN6globalB3TagD2Ev | FileCheck %s
 
 CHECK: returns_string[abi:cxx11]()
 CHECK-NEXT: global[abi:cxx11]
 CHECK-NEXT: global[abi:a_longer_tag]
-
+CHECK-NEXT: global[abi:Tag]::global()
+CHECK-NEXT: global[abi:Tag]::~global()


        


More information about the libcxx-commits mailing list