aboutsummaryrefslogtreecommitdiff
path: root/llvm
diff options
context:
space:
mode:
authorHubert Tong <hubert.reinterpretcast@gmail.com>2024-12-10 20:24:15 -0400
committerGitHub <noreply@github.com>2024-12-10 20:24:15 -0400
commit918d4558b0bad366ecadd411ed48cf64728c68d7 (patch)
tree768b345c871db01d015d0780c8641002591da6c6 /llvm
parent9b6bb8386001a1d308cda42fe273733e58b8e93e (diff)
downloadllvm-918d4558b0bad366ecadd411ed48cf64728c68d7.zip
llvm-918d4558b0bad366ecadd411ed48cf64728c68d7.tar.gz
llvm-918d4558b0bad366ecadd411ed48cf64728c68d7.tar.bz2
[libc++abi] Enable demangling of `cp` expression production (#114882)
See itanium-cxx-abi/cxx-abi#196
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/Demangle/ItaniumDemangle.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 3dfe838..7fba3fd 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -2077,17 +2077,23 @@ public:
class CallExpr : public Node {
const Node *Callee;
NodeArray Args;
+ bool IsParen; // (func)(args ...) ?
public:
- CallExpr(const Node *Callee_, NodeArray Args_, Prec Prec_)
- : Node(KCallExpr, Prec_), Callee(Callee_), Args(Args_) {}
+ CallExpr(const Node *Callee_, NodeArray Args_, bool IsParen_, Prec Prec_)
+ : Node(KCallExpr, Prec_), Callee(Callee_), Args(Args_),
+ IsParen(IsParen_) {}
template <typename Fn> void match(Fn F) const {
- F(Callee, Args, getPrecedence());
+ F(Callee, Args, IsParen, getPrecedence());
}
void printLeft(OutputBuffer &OB) const override {
+ if (IsParen)
+ OB.printOpen();
Callee->print(OB);
+ if (IsParen)
+ OB.printClose();
OB.printOpen();
Args.printWithComma(OB);
OB.printClose();
@@ -3354,9 +3360,12 @@ const typename AbstractManglingParser<
"operator co_await"},
{"az", OperatorInfo::OfIdOp, /*Type*/ false, Node::Prec::Unary, "alignof "},
{"cc", OperatorInfo::NamedCast, false, Node::Prec::Postfix, "const_cast"},
- {"cl", OperatorInfo::Call, false, Node::Prec::Postfix, "operator()"},
+ {"cl", OperatorInfo::Call, /*Paren*/ false, Node::Prec::Postfix,
+ "operator()"},
{"cm", OperatorInfo::Binary, false, Node::Prec::Comma, "operator,"},
{"co", OperatorInfo::Prefix, false, Node::Prec::Unary, "operator~"},
+ {"cp", OperatorInfo::Call, /*Paren*/ true, Node::Prec::Postfix,
+ "operator()"},
{"cv", OperatorInfo::CCast, false, Node::Prec::Cast, "operator"}, // C Cast
{"dV", OperatorInfo::Binary, false, Node::Prec::Assign, "operator/="},
{"da", OperatorInfo::Del, /*Ary*/ true, Node::Prec::Unary,
@@ -5099,6 +5108,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseRequiresExpr() {
// ::= <binary operator-name> <expression> <expression>
// ::= <ternary operator-name> <expression> <expression> <expression>
// ::= cl <expression>+ E # call
+// ::= cp <base-unresolved-name> <expression>* E # (name) (expr-list), call that would use argument-dependent lookup but for the parentheses
// ::= cv <type> <expression> # conversion with one argument
// ::= cv <type> _ <expression>* E # conversion with a different number of arguments
// ::= [gs] nw <expression>* _ <type> E # new (expr-list) type
@@ -5234,7 +5244,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
Names.push_back(E);
}
return make<CallExpr>(Callee, popTrailingNodeArray(ExprsBegin),
- Op->getPrecedence());
+ /*IsParen=*/Op->getFlag(), Op->getPrecedence());
}
case OperatorInfo::CCast: {
// C Cast: (type)expr
@@ -5421,7 +5431,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
}
}
return make<CallExpr>(Name, popTrailingNodeArray(ExprsBegin),
- Node::Prec::Postfix);
+ /*IsParen=*/false, Node::Prec::Postfix);
}
// Only unresolved names remain.