Skip to content

Commit a650687

Browse files
committed
[ItaniumDemangle] Add getter for constructor/destructor variants
This patch adds a way to retrieve the constructor/destructor variant from the Itanium demangle tree. This will be used by LLDB.
1 parent 3ddc4d4 commit a650687

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

libcxxabi/src/demangle/ItaniumDemangle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,8 @@ class CtorDtorName final : public Node {
17661766

17671767
template<typename Fn> void match(Fn F) const { F(Basename, IsDtor, Variant); }
17681768

1769+
int getVariant() const { return Variant; }
1770+
17691771
void printLeft(OutputBuffer &OB) const override {
17701772
if (IsDtor)
17711773
OB += "~";

llvm/include/llvm/Demangle/Demangle.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ struct ItaniumPartialDemangler {
127127
/// If this symbol describes a constructor or destructor.
128128
DEMANGLE_ABI bool isCtorOrDtor() const;
129129

130+
/// If this symbol describes a constructor or destructor.
131+
std::optional<int> getCtorOrDtorVariant() const;
132+
130133
/// If this symbol describes a function.
131134
DEMANGLE_ABI bool isFunction() const;
132135

llvm/include/llvm/Demangle/ItaniumDemangle.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,8 @@ class CtorDtorName final : public Node {
17661766

17671767
template<typename Fn> void match(Fn F) const { F(Basename, IsDtor, Variant); }
17681768

1769+
int getVariant() const { return Variant; }
1770+
17691771
void printLeft(OutputBuffer &OB) const override {
17701772
if (IsDtor)
17711773
OB += "~";

llvm/lib/Demangle/ItaniumDemangle.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,13 +560,17 @@ bool ItaniumPartialDemangler::hasFunctionQualifiers() const {
560560
}
561561

562562
bool ItaniumPartialDemangler::isCtorOrDtor() const {
563+
return getCtorOrDtorVariant().has_value();
564+
}
565+
566+
std::optional<int> ItaniumPartialDemangler::getCtorOrDtorVariant() const {
563567
const Node *N = static_cast<const Node *>(RootNode);
564568
while (N) {
565569
switch (N->getKind()) {
566570
default:
567-
return false;
571+
return std::nullopt;
568572
case Node::KCtorDtorName:
569-
return true;
573+
return static_cast<const CtorDtorName *>(N)->getVariant();
570574

571575
case Node::KAbiTagAttr:
572576
N = static_cast<const AbiTagAttr *>(N)->Base;
@@ -588,7 +592,7 @@ bool ItaniumPartialDemangler::isCtorOrDtor() const {
588592
break;
589593
}
590594
}
591-
return false;
595+
return std::nullopt;
592596
}
593597

594598
bool ItaniumPartialDemangler::isFunction() const {

0 commit comments

Comments
 (0)