Refactor and clean up the AST printer, so that it uses a DeclVisitor,
walks through DeclContexts properly, and prints more of the
information available in the AST. The functionality is still available
via -ast-print, -ast-dump, etc., and also via the new member functions
Decl::dump() and Decl::print().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72597 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp
index e6a2bad..fc9fdf9 100644
--- a/lib/AST/StmtPrinter.cpp
+++ b/lib/AST/StmtPrinter.cpp
@@ -816,7 +816,7 @@
PrintExpr(Node->getLHS());
OS << " : ";
}
- else { // Handle GCC extention where LHS can be NULL.
+ else { // Handle GCC extension where LHS can be NULL.
OS << " ?: ";
}
@@ -903,7 +903,15 @@
}
void StmtPrinter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *Node) {
- OS << "/*implicit*/" << Node->getType().getAsString() << "()";
+ if (Policy.CPlusPlus)
+ OS << "/*implicit*/" << Node->getType().getAsString(Policy) << "()";
+ else {
+ OS << "/*implicit*/(" << Node->getType().getAsString(Policy) << ")";
+ if (Node->getType()->isRecordType())
+ OS << "{}";
+ else
+ OS << 0;
+ }
}
void StmtPrinter::VisitVAArgExpr(VAArgExpr *Node) {
@@ -1257,6 +1265,11 @@
return;
}
+ if (Policy.Dump) {
+ dump();
+ return;
+ }
+
StmtPrinter P(OS, Helper, Policy, Indentation);
P.Visit(const_cast<Stmt*>(this));
}