r348717 - Introduce optional labels to dumpStmt

Stephen Kelly via cfe-commits cfe-commits at lists.llvm.org
Sun Dec 9 05:23:07 PST 2018


Author: steveire
Date: Sun Dec  9 05:23:07 2018
New Revision: 348717

URL: http://llvm.org/viewvc/llvm-project?rev=348717&view=rev
Log:
Introduce optional labels to dumpStmt

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.

Modified:
    cfe/trunk/lib/AST/ASTDumper.cpp

Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=348717&r1=348716&r2=348717&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Sun Dec  9 05:23:07 2018
@@ -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 Blo
 //  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
     NodeDumper.dumpBareDeclRef(Field);
   }
   if (auto *Filler = ILE->getArrayFiller()) {
-    dumpChild([=] {
-      OS << "array filler";
-      dumpStmt(Filler);
-    });
+    dumpStmt(Filler, "array filler");
   }
 }
 




More information about the cfe-commits mailing list