[libcxx-commits] [libcxxabi] c204cee - [demangler] Update node match calls

Nathan Sidwell via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 29 05:32:48 PDT 2022


Author: Nathan Sidwell
Date: 2022-03-29T05:32:36-07:00
New Revision: c204cee642ee794901d2e8a9819b52ac12f92bc9

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

LOG: [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.

Added: 
    

Modified: 
    libcxxabi/src/cxa_demangle.cpp
    libcxxabi/src/demangle/ItaniumDemangle.h
    llvm/include/llvm/Demangle/ItaniumDemangle.h

Removed: 
    


################################################################################
diff  --git a/libcxxabi/src/cxa_demangle.cpp b/libcxxabi/src/cxa_demangle.cpp
index bee4cfd5a119c..794cd770d4844 100644
--- a/libcxxabi/src/cxa_demangle.cpp
+++ b/libcxxabi/src/cxa_demangle.cpp
@@ -173,6 +173,9 @@ struct DumpVisitor {
       return printStr("TemplateParamKind::Template");
     }
   }
+  void print(Node::Prec) {
+    // FIXME: Print Prec enumerator
+  }
 
   void newLine() {
     printStr("\n");

diff  --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index 85b4923a21016..be2cf882bfc22 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 @@ class BinaryExpr : public Node {
       : 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 @@ class ArraySubscriptExpr : public Node {
   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 @@ class PostfixExpr : public Node {
   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 @@ class ConditionalExpr : public Node {
                   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 @@ class MemberExpr : public Node {
   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 @@ class EnclosingExpr : public Node {
   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 @@ class CastExpr : public Node {
   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 @@ class CallExpr : public Node {
   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 @@ class NewExpr : public Node {
         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 @@ class DeleteExpr : public Node {
       : 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 @@ class PrefixExpr : public Node {
   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 @@ class ConversionExpr : public Node {
   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 @@ class PointerToMemberConversionExpr : public Node {
       : 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();

diff  --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 037e94818d287..778342e7fd594 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/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)
@@ -1812,7 +1814,9 @@ class ArraySubscriptExpr : public Node {
   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());
@@ -1830,7 +1834,9 @@ class PostfixExpr : public Node {
   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);
@@ -1848,7 +1854,9 @@ class ConditionalExpr : public Node {
                   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());
@@ -1868,7 +1876,9 @@ class MemberExpr : public Node {
   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);
@@ -1920,7 +1930,9 @@ class EnclosingExpr : public Node {
   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;
@@ -1941,7 +1953,9 @@ class CastExpr : public Node {
   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;
@@ -1985,7 +1999,9 @@ class CallExpr : public Node {
   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);
@@ -2009,7 +2025,7 @@ class NewExpr : public Node {
         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 {
@@ -2043,7 +2059,9 @@ class DeleteExpr : public Node {
       : 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)
@@ -2064,7 +2082,9 @@ class PrefixExpr : public Node {
   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;
@@ -2094,7 +2114,9 @@ class ConversionExpr : public Node {
   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();
@@ -2117,7 +2139,9 @@ class PointerToMemberConversionExpr : public Node {
       : 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();


        


More information about the libcxx-commits mailing list