Skip to content

Commit d050a21

Browse files
committed
[ASTDumper] Dump argument labels.
1 parent abea719 commit d050a21

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,9 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
16741674

16751675
void visitObjectLiteralExpr(ObjectLiteralExpr *E) {
16761676
printCommon(E, "object_literal")
1677-
<< " kind='" << E->getLiteralKindPlainName() << "'\n";
1677+
<< " kind='" << E->getLiteralKindPlainName() << "'";
1678+
printArgumentLabels(E->getArgumentLabels());
1679+
OS << "\n";
16781680
printRec(E->getArg());
16791681
}
16801682

@@ -1779,6 +1781,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
17791781
void visitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
17801782
printCommon(E, "unresolved_member_expr")
17811783
<< " name='" << E->getName() << "'";
1784+
printArgumentLabels(E->getArgumentLabels());
17821785
if (E->getArgument()) {
17831786
OS << '\n';
17841787
printRec(E->getArgument());
@@ -1846,6 +1849,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
18461849
OS << " decl=";
18471850
E->getDecl().dump(OS);
18481851
}
1852+
printArgumentLabels(E->getArgumentLabels());
18491853
OS << '\n';
18501854
printRec(E->getBase());
18511855
OS << '\n';
@@ -1856,6 +1860,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
18561860
printCommon(E, "dynamic_subscript_expr")
18571861
<< " decl=";
18581862
E->getMember().dump(OS);
1863+
printArgumentLabels(E->getArgumentLabels());
18591864
OS << '\n';
18601865
printRec(E->getBase());
18611866
OS << '\n';
@@ -2124,17 +2129,20 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
21242129
OS << ')';
21252130
}
21262131

2132+
void printArgumentLabels(ArrayRef<Identifier> argLabels) {
2133+
OS << " arg_labels=";
2134+
for (auto label : argLabels)
2135+
OS << (label.empty() ? "_" : label.str()) << ":";
2136+
}
2137+
21272138
void printApplyExpr(ApplyExpr *E, const char *NodeName) {
21282139
printCommon(E, NodeName);
21292140
if (E->isSuper())
21302141
OS << " super";
21312142
if (E->isThrowsSet())
21322143
OS << (E->throws() ? " throws" : " nothrow");
2133-
if (auto call = dyn_cast<CallExpr>(E)) {
2134-
OS << " arg_labels=";
2135-
for (auto label : call->getArgumentLabels())
2136-
OS << (label.empty() ? "_" : label.str()) << ":";
2137-
}
2144+
if (auto call = dyn_cast<CallExpr>(E))
2145+
printArgumentLabels(call->getArgumentLabels());
21382146

21392147
OS << '\n';
21402148
printRec(E->getFn());

0 commit comments

Comments
 (0)