mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 14:20:17 +00:00
[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.
This commit is contained in:
parent
65b1b3b961
commit
c204cee642
@ -173,6 +173,9 @@ struct DumpVisitor {
|
||||
return printStr("TemplateParamKind::Template");
|
||||
}
|
||||
}
|
||||
void print(Node::Prec) {
|
||||
// FIXME: Print Prec enumerator
|
||||
}
|
||||
|
||||
void newLine() {
|
||||
printStr("\n");
|
||||
|
@ -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();
|
||||
|
@ -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 @@ 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());
|
||||
@ -1830,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);
|
||||
@ -1848,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());
|
||||
@ -1868,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);
|
||||
@ -1920,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;
|
||||
@ -1941,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;
|
||||
@ -1985,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);
|
||||
@ -2009,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 {
|
||||
@ -2043,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)
|
||||
@ -2064,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;
|
||||
@ -2094,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();
|
||||
@ -2117,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();
|
||||
|
Loading…
Reference in New Issue
Block a user