Skip to content

Commit 4601bcd

Browse files
committed
[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 #61213 Differential Revision: https://reviews.llvm.org/D145492
1 parent 50b58e8 commit 4601bcd

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

libcxxabi/src/demangle/ItaniumDemangle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,8 @@ struct AbiTagAttr : Node {
544544

545545
template<typename Fn> void match(Fn F) const { F(Base, Tag); }
546546

547+
StringView getBaseName() const override { return Base->getBaseName(); }
548+
547549
void printLeft(OutputBuffer &OB) const override {
548550
Base->printLeft(OB);
549551
OB += "[abi:";

libcxxabi/test/test_demangle.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30112,6 +30112,8 @@ const char* cases[][2] =
3011230112
"::basic_ostream()"},
3011330113
{"_ZNSsC1Ev", "std::basic_string<char, std::char_traits<char>,"
3011430114
" std::allocator<char>>::basic_string()"},
30115+
{"_ZN1SB8ctor_tagC2Ev", "S[abi:ctor_tag]::S()"},
30116+
{"_ZN1SB8ctor_tagD2Ev", "S[abi:ctor_tag]::~S()"},
3011530117
};
3011630118

3011730119
const unsigned N = sizeof(cases) / sizeof(cases[0]);

llvm/include/llvm/Demangle/ItaniumDemangle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ struct AbiTagAttr : Node {
537537

538538
template<typename Fn> void match(Fn F) const { F(Base, Tag); }
539539

540+
StringView getBaseName() const override { return Base->getBaseName(); }
541+
540542
void printLeft(OutputBuffer &OB) const override {
541543
Base->printLeft(OB);
542544
OB += "[abi:";
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
RUN: llvm-cxxfilt -n _Z14returns_stringB5cxx11v _Z6globalB5cxx11 _Z6globalB12a_longer_tag | FileCheck %s
1+
RUN: llvm-cxxfilt -n _Z14returns_stringB5cxx11v _Z6globalB5cxx11 _Z6globalB12a_longer_tag _ZN6globalB3TagC2Ev _ZN6globalB3TagD2Ev | FileCheck %s
22

33
CHECK: returns_string[abi:cxx11]()
44
CHECK-NEXT: global[abi:cxx11]
55
CHECK-NEXT: global[abi:a_longer_tag]
6-
6+
CHECK-NEXT: global[abi:Tag]::global()
7+
CHECK-NEXT: global[abi:Tag]::~global()

0 commit comments

Comments
 (0)