namespace {
class ASTDumper : public ASTConsumer, public DeclPrinter {
ASTContext *Ctx;
+ bool FullDump;
+
public:
- ASTDumper() : DeclPrinter() {}
+ explicit ASTDumper(bool FullDump) : DeclPrinter(), FullDump(FullDump) {}
void Initialize(ASTContext &Context) {
Ctx = &Context;
}
virtual void HandleTopLevelDecl(DeclGroupRef D) {
+ if (FullDump)
+ return;
for (DeclGroupRef::iterator I = D.begin(), E = D.end(); I != E; ++I)
HandleTopLevelSingleDecl(*I);
}
void HandleTopLevelSingleDecl(Decl *D);
+
+ virtual void HandleTranslationUnit(ASTContext &Ctx) {
+ if (!FullDump)
+ return;
+
+ for (DeclContext::decl_iterator
+ D = Ctx.getTranslationUnitDecl()->decls_begin(Ctx),
+ DEnd = Ctx.getTranslationUnitDecl()->decls_end(Ctx);
+ D != DEnd;
+ ++D)
+ HandleTopLevelSingleDecl(*D);
+ }
};
} // end anonymous namespace
}
}
-ASTConsumer *clang::CreateASTDumper() { return new ASTDumper(); }
+ASTConsumer *clang::CreateASTDumper(bool FullDump) {
+ return new ASTDumper(FullDump);
+}
//===----------------------------------------------------------------------===//
/// ASTViewer - AST Visualization
EmitHTML, // Translate input source into HTML.
ASTPrint, // Parse ASTs and print them.
ASTDump, // Parse ASTs and dump them.
+ ASTDumpFull, // Parse ASTs and dump them, including the
+ // contents of a PCH file.
ASTView, // Parse ASTs and view them in Graphviz.
PrintDeclContext, // Print DeclContext and their Decls.
ParsePrintCallbacks, // Parse and print each callback.
"Build ASTs and then pretty-print them"),
clEnumValN(ASTDump, "ast-dump",
"Build ASTs and then debug dump them"),
+ clEnumValN(ASTDumpFull, "ast-dump-full",
+ "Build ASTs and then debug dump them, including PCH"),
clEnumValN(ASTView, "ast-view",
"Build ASTs and view them with GraphViz"),
clEnumValN(PrintDeclContext, "print-decl-contexts",
return CreateASTPrinter();
case ASTDump:
- return CreateASTDumper();
+ return CreateASTDumper(false);
+
+ case ASTDumpFull:
+ return CreateASTDumper(true);
case ASTView:
return CreateASTViewer();