Skip to content

Commit f9bcd02

Browse files
Apply libcxxabi/src/demangle/cp-to-llvm.sh
1 parent 58ab150 commit f9bcd02

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

llvm/include/llvm/Demangle/ItaniumDemangle.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,17 +2077,25 @@ class SizeofParamPackExpr : public Node {
20772077
class CallExpr : public Node {
20782078
const Node *Callee;
20792079
NodeArray Args;
2080+
bool IsParen; // (func)(args ...) ?
20802081

20812082
public:
2082-
CallExpr(const Node *Callee_, NodeArray Args_, Prec Prec_)
2083-
: Node(KCallExpr, Prec_), Callee(Callee_), Args(Args_) {}
2083+
CallExpr(const Node *Callee_, NodeArray Args_, bool IsParen_, Prec Prec_)
2084+
: Node(KCallExpr, Prec_), Callee(Callee_), Args(Args_),
2085+
IsParen(IsParen_) {}
20842086

20852087
template <typename Fn> void match(Fn F) const {
20862088
F(Callee, Args, getPrecedence());
20872089
}
20882090

20892091
void printLeft(OutputBuffer &OB) const override {
2090-
Callee->print(OB);
2092+
if (IsParen) {
2093+
OB.printOpen();
2094+
Callee->print(OB);
2095+
OB.printClose();
2096+
} else {
2097+
Callee->print(OB);
2098+
}
20912099
OB.printOpen();
20922100
Args.printWithComma(OB);
20932101
OB.printClose();
@@ -3354,10 +3362,10 @@ const typename AbstractManglingParser<
33543362
"operator co_await"},
33553363
{"az", OperatorInfo::OfIdOp, /*Type*/ false, Node::Prec::Unary, "alignof "},
33563364
{"cc", OperatorInfo::NamedCast, false, Node::Prec::Postfix, "const_cast"},
3357-
{"cl", OperatorInfo::Call, false, Node::Prec::Postfix, "operator()"},
3365+
{"cl", OperatorInfo::Call, /*Paren*/ false, Node::Prec::Postfix, "operator()"},
33583366
{"cm", OperatorInfo::Binary, false, Node::Prec::Comma, "operator,"},
33593367
{"co", OperatorInfo::Prefix, false, Node::Prec::Unary, "operator~"},
3360-
{"cp", OperatorInfo::Call, false, Node::Prec::Postfix, "operator()"},
3368+
{"cp", OperatorInfo::Call, /*Paren*/ true, Node::Prec::Postfix, "operator()"},
33613369
{"cv", OperatorInfo::CCast, false, Node::Prec::Cast, "operator"}, // C Cast
33623370
{"dV", OperatorInfo::Binary, false, Node::Prec::Assign, "operator/="},
33633371
{"da", OperatorInfo::Del, /*Ary*/ true, Node::Prec::Unary,
@@ -5005,6 +5013,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseRequiresExpr() {
50055013
// ::= <binary operator-name> <expression> <expression>
50065014
// ::= <ternary operator-name> <expression> <expression> <expression>
50075015
// ::= cl <expression>+ E # call
5016+
// ::= cp <base-unresolved-name> <expression>* E # (name) (expr-list), call that would use argument-dependent lookup but for the parentheses
50085017
// ::= cv <type> <expression> # conversion with one argument
50095018
// ::= cv <type> _ <expression>* E # conversion with a different number of arguments
50105019
// ::= [gs] nw <expression>* _ <type> E # new (expr-list) type
@@ -5140,7 +5149,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
51405149
Names.push_back(E);
51415150
}
51425151
return make<CallExpr>(Callee, popTrailingNodeArray(ExprsBegin),
5143-
Op->getPrecedence());
5152+
/*IsParen=*/Op->getFlag(), Op->getPrecedence());
51445153
}
51455154
case OperatorInfo::CCast: {
51465155
// C Cast: (type)expr
@@ -5327,7 +5336,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
53275336
}
53285337
}
53295338
return make<CallExpr>(Name, popTrailingNodeArray(ExprsBegin),
5330-
Node::Prec::Postfix);
5339+
/*IsParen=*/false, Node::Prec::Postfix);
53315340
}
53325341

53335342
// Only unresolved names remain.

0 commit comments

Comments
 (0)