]> granicus.if.org Git - clang/commitdiff
Introduce optional labels to dumpStmt
authorStephen Kelly <steveire@gmail.com>
Sun, 9 Dec 2018 13:23:07 +0000 (13:23 +0000)
committerStephen Kelly <steveire@gmail.com>
Sun, 9 Dec 2018 13:23:07 +0000 (13:23 +0000)
If the label is present, it is added as a child, with the statement a
child of the label.  This preserves behavior of the InitListExpr dump
output.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348717 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTDumper.cpp

index b95813ed7c1f0e0b157fe964e0ad673a79939314..d1d7097a64e090b4a09d738e7c7ceecd8d315328 100644 (file)
@@ -83,7 +83,8 @@ namespace  {
     void setDeserialize(bool D) { Deserialize = D; }
 
     void dumpDecl(const Decl *D);
-    void dumpStmt(const Stmt *S);
+    void dumpStmt(const Stmt *S, const char *label = nullptr);
+    void dumpStmtImpl(const Stmt *S);
 
     // Utilities
     void dumpType(QualType T) { NodeDumper.dumpType(T); }
@@ -1711,7 +1712,18 @@ void ASTDumper::VisitBlockDecl(const BlockDecl *D) {
 //  Stmt dumping methods.
 //===----------------------------------------------------------------------===//
 
-void ASTDumper::dumpStmt(const Stmt *S) {
+void ASTDumper::dumpStmt(const Stmt *S, const char *label) {
+  if (label) {
+    dumpChild([=] {
+      OS << label;
+      dumpStmtImpl(S);
+    });
+  } else {
+    dumpStmtImpl(S);
+  }
+}
+
+void ASTDumper::dumpStmtImpl(const Stmt *S) {
   dumpChild([=] {
     if (!S) {
       ColorScope Color(OS, ShowColors, NullColor);
@@ -1978,10 +1990,7 @@ void ASTDumper::VisitInitListExpr(const InitListExpr *ILE) {
     NodeDumper.dumpBareDeclRef(Field);
   }
   if (auto *Filler = ILE->getArrayFiller()) {
-    dumpChild([=] {
-      OS << "array filler";
-      dumpStmt(Filler);
-    });
+    dumpStmt(Filler, "array filler");
   }
 }