Skip to content

Commit 147e6e9

Browse files
authored
Merge pull request #16778 from brentdax/semantic-expr-dump
Dump semantic expressions in AST consistently
2 parents 28ff5d9 + e6debec commit 147e6e9

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1691,6 +1691,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
16911691
Indent += 2;
16921692
OS.indent(Indent);
16931693
PrintWithColorRAII(OS, ParenthesisColor) << '(';
1694+
PrintWithColorRAII(OS, ExprColor) << label;
16941695
OS << '\n';
16951696
printRec(E);
16961697
PrintWithColorRAII(OS, ParenthesisColor) << ')';
@@ -1749,6 +1750,15 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
17491750

17501751
return OS;
17511752
}
1753+
1754+
void printSemanticExpr(Expr * semanticExpr) {
1755+
if (semanticExpr == nullptr) {
1756+
return;
1757+
}
1758+
1759+
OS << '\n';
1760+
printRecLabeled(semanticExpr, "semantic_expr");
1761+
}
17521762

17531763
void visitErrorExpr(ErrorExpr *E) {
17541764
printCommon(E, "error_expr");
@@ -1809,6 +1819,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
18091819
OS << '\n';
18101820
printRec(Segment);
18111821
}
1822+
printSemanticExpr(E->getSemanticExpr());
18121823
PrintWithColorRAII(OS, ParenthesisColor) << ')';
18131824
}
18141825
void visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E) {
@@ -1832,6 +1843,8 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
18321843
printArgumentLabels(E->getArgumentLabels());
18331844
OS << "\n";
18341845
printRec(E->getArg());
1846+
printSemanticExpr(E->getSemanticExpr());
1847+
PrintWithColorRAII(OS, ParenthesisColor) << ')';
18351848
}
18361849

18371850
void visitDiscardAssignmentExpr(DiscardAssignmentExpr *E) {
@@ -1983,20 +1996,16 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
19831996
OS << '\n';
19841997
printRec(elt);
19851998
}
1999+
printSemanticExpr(E->getSemanticExpr());
19862000
PrintWithColorRAII(OS, ParenthesisColor) << ')';
19872001
}
19882002
void visitDictionaryExpr(DictionaryExpr *E) {
19892003
printCommon(E, "dictionary_expr");
1990-
if (auto semaE = E->getSemanticExpr()) {
1991-
OS << '\n';
1992-
printRec(semaE);
1993-
PrintWithColorRAII(OS, ParenthesisColor) << ')';
1994-
return;
1995-
}
19962004
for (auto elt : E->getElements()) {
19972005
OS << '\n';
19982006
printRec(elt);
19992007
}
2008+
printSemanticExpr(E->getSemanticExpr());
20002009
PrintWithColorRAII(OS, ParenthesisColor) << ')';
20012010
}
20022011
void visitSubscriptExpr(SubscriptExpr *E) {
@@ -2496,6 +2505,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
24962505
OS << '\n';
24972506
printRec(ExpTyR);
24982507
}
2508+
printSemanticExpr(E->getSemanticExpr());
24992509
PrintWithColorRAII(OS, ParenthesisColor) << ')';
25002510
}
25012511
void visitObjCSelectorExpr(ObjCSelectorExpr *E) {

0 commit comments

Comments
 (0)