diff options
author | Nathan Sidwell <nathan@acm.org> | 2022-03-29 14:43:16 +0300 |
---|---|---|
committer | Nathan Sidwell <nathan@acm.org> | 2022-03-29 15:32:36 +0300 |
commit | c204cee642ee794901d2e8a9819b52ac12f92bc9 (patch) | |
tree | d67b7599dcbea9e302e729140b0e720d63062341 /libcxxabi/src/demangle | |
parent | 65b1b3b961cf0337a007e5646431abf2b7aff334 (diff) |
[demangler] Update node match calls
Each demangler node's match function needs to call the provided
functor with constructor arguments. That was omitted from D120905.
This adds the new Precedence argument where necessary (and a missing
boolean for a module node).
The two visitors need updating with a printer for that type, and this
adds a stub to cxa_demangle's version. blaikie added one to llvm's.
I'll fill out those printers in a followup, rather than wait, so that
downstream consumers are unbroken.
Diffstat (limited to 'libcxxabi/src/demangle')
-rw-r--r-- | libcxxabi/src/demangle/ItaniumDemangle.h | 54 |
1 files changed, 40 insertions, 14 deletions
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h index 85b4923a2101..be2cf882bfc2 100644 --- a/libcxxabi/src/demangle/ItaniumDemangle.h +++ b/libcxxabi/src/demangle/ItaniumDemangle.h @@ -1056,7 +1056,9 @@ struct ModuleName : Node { : Node(KModuleName), Parent(Parent_), Name(Name_), IsPartition(IsPartition_) {} - template <typename Fn> void match(Fn F) const { F(Parent, Name); } + template <typename Fn> void match(Fn F) const { + F(Parent, Name, IsPartition); + } void printLeft(OutputBuffer &OB) const override { if (Parent) @@ -1782,7 +1784,9 @@ public: : Node(KBinaryExpr, Prec_), LHS(LHS_), InfixOperator(InfixOperator_), RHS(RHS_) {} - template<typename Fn> void match(Fn F) const { F(LHS, InfixOperator, RHS); } + template <typename Fn> void match(Fn F) const { + F(LHS, InfixOperator, RHS, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { bool ParenAll = OB.isGtInsideTemplateArgs() && InfixOperator == ">"; @@ -1810,7 +1814,9 @@ public: ArraySubscriptExpr(const Node *Op1_, const Node *Op2_, Prec Prec_) : Node(KArraySubscriptExpr, Prec_), Op1(Op1_), Op2(Op2_) {} - template<typename Fn> void match(Fn F) const { F(Op1, Op2); } + template <typename Fn> void match(Fn F) const { + F(Op1, Op2, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { Op1->printAsOperand(OB, getPrecedence()); @@ -1828,7 +1834,9 @@ public: PostfixExpr(const Node *Child_, StringView Operator_, Prec Prec_) : Node(KPostfixExpr, Prec_), Child(Child_), Operator(Operator_) {} - template<typename Fn> void match(Fn F) const { F(Child, Operator); } + template <typename Fn> void match(Fn F) const { + F(Child, Operator, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { Child->printAsOperand(OB, getPrecedence(), true); @@ -1846,7 +1854,9 @@ public: Prec Prec_) : Node(KConditionalExpr, Prec_), Cond(Cond_), Then(Then_), Else(Else_) {} - template<typename Fn> void match(Fn F) const { F(Cond, Then, Else); } + template <typename Fn> void match(Fn F) const { + F(Cond, Then, Else, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { Cond->printAsOperand(OB, getPrecedence()); @@ -1866,7 +1876,9 @@ public: MemberExpr(const Node *LHS_, StringView Kind_, const Node *RHS_, Prec Prec_) : Node(KMemberExpr, Prec_), LHS(LHS_), Kind(Kind_), RHS(RHS_) {} - template<typename Fn> void match(Fn F) const { F(LHS, Kind, RHS); } + template <typename Fn> void match(Fn F) const { + F(LHS, Kind, RHS, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { LHS->printAsOperand(OB, getPrecedence(), true); @@ -1918,7 +1930,9 @@ public: EnclosingExpr(StringView Prefix_, Node *Infix_, Prec Prec_ = Prec::Primary) : Node(KEnclosingExpr, Prec_), Prefix(Prefix_), Infix(Infix_) {} - template <typename Fn> void match(Fn F) const { F(Prefix, Infix); } + template <typename Fn> void match(Fn F) const { + F(Prefix, Infix, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { OB += Prefix; @@ -1939,7 +1953,9 @@ public: CastExpr(StringView CastKind_, const Node *To_, const Node *From_, Prec Prec_) : Node(KCastExpr, Prec_), CastKind(CastKind_), To(To_), From(From_) {} - template<typename Fn> void match(Fn F) const { F(CastKind, To, From); } + template <typename Fn> void match(Fn F) const { + F(CastKind, To, From, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { OB += CastKind; @@ -1983,7 +1999,9 @@ public: CallExpr(const Node *Callee_, NodeArray Args_, Prec Prec_) : Node(KCallExpr, Prec_), Callee(Callee_), Args(Args_) {} - template<typename Fn> void match(Fn F) const { F(Callee, Args); } + template <typename Fn> void match(Fn F) const { + F(Callee, Args, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { Callee->print(OB); @@ -2007,7 +2025,7 @@ public: InitList(InitList_), IsGlobal(IsGlobal_), IsArray(IsArray_) {} template<typename Fn> void match(Fn F) const { - F(ExprList, Type, InitList, IsGlobal, IsArray); + F(ExprList, Type, InitList, IsGlobal, IsArray, getPrecedence()); } void printLeft(OutputBuffer &OB) const override { @@ -2041,7 +2059,9 @@ public: : Node(KDeleteExpr, Prec_), Op(Op_), IsGlobal(IsGlobal_), IsArray(IsArray_) {} - template<typename Fn> void match(Fn F) const { F(Op, IsGlobal, IsArray); } + template <typename Fn> void match(Fn F) const { + F(Op, IsGlobal, IsArray, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { if (IsGlobal) @@ -2062,7 +2082,9 @@ public: PrefixExpr(StringView Prefix_, Node *Child_, Prec Prec_) : Node(KPrefixExpr, Prec_), Prefix(Prefix_), Child(Child_) {} - template<typename Fn> void match(Fn F) const { F(Prefix, Child); } + template <typename Fn> void match(Fn F) const { + F(Prefix, Child, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { OB += Prefix; @@ -2092,7 +2114,9 @@ public: ConversionExpr(const Node *Type_, NodeArray Expressions_, Prec Prec_) : Node(KConversionExpr, Prec_), Type(Type_), Expressions(Expressions_) {} - template<typename Fn> void match(Fn F) const { F(Type, Expressions); } + template <typename Fn> void match(Fn F) const { + F(Type, Expressions, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { OB.printOpen(); @@ -2115,7 +2139,9 @@ public: : Node(KPointerToMemberConversionExpr, Prec_), Type(Type_), SubExpr(SubExpr_), Offset(Offset_) {} - template<typename Fn> void match(Fn F) const { F(Type, SubExpr, Offset); } + template <typename Fn> void match(Fn F) const { + F(Type, SubExpr, Offset, getPrecedence()); + } void printLeft(OutputBuffer &OB) const override { OB.printOpen(); |