Skip to content

Commit e6debec

Browse files
committed
Dump various nodes’ semanticExprs
Previously, only DictionaryExpr dumped its semanticExpr, and it replaced the direct contents. With this change, all nodes with a semanticExpr dump it, and they all handle it in the same way: they append it to the end of the list of children, in a separate S-expression marked by “semantic_expr”.
1 parent 531109c commit e6debec

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

lib/AST/ASTDumper.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
16621662
Indent += 2;
16631663
OS.indent(Indent);
16641664
PrintWithColorRAII(OS, ParenthesisColor) << '(';
1665+
PrintWithColorRAII(OS, ExprColor) << label;
16651666
OS << '\n';
16661667
printRec(E);
16671668
PrintWithColorRAII(OS, ParenthesisColor) << ')';
@@ -1720,6 +1721,15 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
17201721

17211722
return OS;
17221723
}
1724+
1725+
void printSemanticExpr(Expr * semanticExpr) {
1726+
if (semanticExpr == nullptr) {
1727+
return;
1728+
}
1729+
1730+
OS << '\n';
1731+
printRecLabeled(semanticExpr, "semantic_expr");
1732+
}
17231733

17241734
void visitErrorExpr(ErrorExpr *E) {
17251735
printCommon(E, "error_expr");
@@ -1780,6 +1790,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
17801790
OS << '\n';
17811791
printRec(Segment);
17821792
}
1793+
printSemanticExpr(E->getSemanticExpr());
17831794
PrintWithColorRAII(OS, ParenthesisColor) << ')';
17841795
}
17851796
void visitMagicIdentifierLiteralExpr(MagicIdentifierLiteralExpr *E) {
@@ -1803,6 +1814,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
18031814
printArgumentLabels(E->getArgumentLabels());
18041815
OS << "\n";
18051816
printRec(E->getArg());
1817+
printSemanticExpr(E->getSemanticExpr());
18061818
PrintWithColorRAII(OS, ParenthesisColor) << ')';
18071819
}
18081820

@@ -1955,20 +1967,16 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
19551967
OS << '\n';
19561968
printRec(elt);
19571969
}
1970+
printSemanticExpr(E->getSemanticExpr());
19581971
PrintWithColorRAII(OS, ParenthesisColor) << ')';
19591972
}
19601973
void visitDictionaryExpr(DictionaryExpr *E) {
19611974
printCommon(E, "dictionary_expr");
1962-
if (auto semaE = E->getSemanticExpr()) {
1963-
OS << '\n';
1964-
printRec(semaE);
1965-
PrintWithColorRAII(OS, ParenthesisColor) << ')';
1966-
return;
1967-
}
19681975
for (auto elt : E->getElements()) {
19691976
OS << '\n';
19701977
printRec(elt);
19711978
}
1979+
printSemanticExpr(E->getSemanticExpr());
19721980
PrintWithColorRAII(OS, ParenthesisColor) << ')';
19731981
}
19741982
void visitSubscriptExpr(SubscriptExpr *E) {
@@ -2468,6 +2476,7 @@ class PrintExpr : public ExprVisitor<PrintExpr> {
24682476
OS << '\n';
24692477
printRec(ExpTyR);
24702478
}
2479+
printSemanticExpr(E->getSemanticExpr());
24712480
PrintWithColorRAII(OS, ParenthesisColor) << ')';
24722481
}
24732482
void visitObjCSelectorExpr(ObjCSelectorExpr *E) {

0 commit comments

Comments
 (0)