[cfe-commits] r70108 - in /cfe/trunk/tools/clang-cc: ASTConsumers.cpp ASTConsumers.h clang-cc.cpp
Douglas Gregor
dgregor at apple.com
Sat Apr 25 19:02:08 PDT 2009
Author: dgregor
Date: Sat Apr 25 21:02:08 2009
New Revision: 70108
URL: http://llvm.org/viewvc/llvm-project?rev=70108&view=rev
Log:
Add a new -ast-dump-full option that traverses the translation unit
declaration rather than printing through the HandleTopLevelDecl
action. Using this, one can deserialize an entire PCH file and dump
it.
Modified:
cfe/trunk/tools/clang-cc/ASTConsumers.cpp
cfe/trunk/tools/clang-cc/ASTConsumers.h
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/tools/clang-cc/ASTConsumers.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/ASTConsumers.cpp?rev=70108&r1=70107&r2=70108&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/ASTConsumers.cpp (original)
+++ cfe/trunk/tools/clang-cc/ASTConsumers.cpp Sat Apr 25 21:02:08 2009
@@ -591,18 +591,34 @@
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
@@ -652,7 +668,9 @@
}
}
-ASTConsumer *clang::CreateASTDumper() { return new ASTDumper(); }
+ASTConsumer *clang::CreateASTDumper(bool FullDump) {
+ return new ASTDumper(FullDump);
+}
//===----------------------------------------------------------------------===//
/// ASTViewer - AST Visualization
Modified: cfe/trunk/tools/clang-cc/ASTConsumers.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/ASTConsumers.h?rev=70108&r1=70107&r2=70108&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/ASTConsumers.h (original)
+++ cfe/trunk/tools/clang-cc/ASTConsumers.h Sat Apr 25 21:02:08 2009
@@ -34,7 +34,7 @@
ASTConsumer *CreateASTPrinter(llvm::raw_ostream* OS = NULL);
-ASTConsumer *CreateASTDumper();
+ASTConsumer *CreateASTDumper(bool FullDump);
ASTConsumer *CreateASTViewer();
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=70108&r1=70107&r2=70108&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Sat Apr 25 21:02:08 2009
@@ -183,6 +183,8 @@
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.
@@ -224,6 +226,8 @@
"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",
@@ -1539,7 +1543,10 @@
return CreateASTPrinter();
case ASTDump:
- return CreateASTDumper();
+ return CreateASTDumper(false);
+
+ case ASTDumpFull:
+ return CreateASTDumper(true);
case ASTView:
return CreateASTViewer();
More information about the cfe-commits
mailing list