diff options
| author | John McCall <rjmccall@apple.com> | 2010-11-24 11:21:45 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-11-24 11:21:45 +0000 |
| commit | 9b66c4bbbe23accc8c3b3b8cbacf7f093870f68f (patch) | |
| tree | b57f74dd7f5edfbff1e89f832d76a03a0f4ebee2 /clang/lib | |
| parent | cb29802198d0f0fc623c53b34af64f364f1ea45f (diff) | |
| download | bcm5719-llvm-9b66c4bbbe23accc8c3b3b8cbacf7f093870f68f.tar.gz bcm5719-llvm-9b66c4bbbe23accc8c3b3b8cbacf7f093870f68f.zip | |
Add -cc1 -ast-dump-xml, an excessively detailed XML dump of the internals
of the ASTs. Only available in assertions builds. No stability guarantee.
This is intended solely as a debugging tool. I'm not sure if the goals
are sufficiently aligned with the XML printer to allow a common
implementation.
Currently just falls back on the StmtDumper to display statements,
which means it doesn't produce valid XML in those cases.
llvm-svn: 120088
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | clang/lib/Frontend/ASTConsumers.cpp | 20 | ||||
| -rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Frontend/FrontendActions.cpp | 11 | ||||
| -rw-r--r-- | clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 1 |
5 files changed, 36 insertions, 0 deletions
diff --git a/clang/lib/AST/CMakeLists.txt b/clang/lib/AST/CMakeLists.txt index f56e6c41b09..6fca4d7e732 100644 --- a/clang/lib/AST/CMakeLists.txt +++ b/clang/lib/AST/CMakeLists.txt @@ -19,6 +19,7 @@ add_clang_library(clangAST DeclObjC.cpp DeclPrinter.cpp DeclTemplate.cpp + DumpXML.cpp Expr.cpp ExprClassification.cpp ExprConstant.cpp diff --git a/clang/lib/Frontend/ASTConsumers.cpp b/clang/lib/Frontend/ASTConsumers.cpp index eb7f270ae8f..5c7c02da9b0 100644 --- a/clang/lib/Frontend/ASTConsumers.cpp +++ b/clang/lib/Frontend/ASTConsumers.cpp @@ -449,3 +449,23 @@ public: ASTConsumer *clang::CreateInheritanceViewer(const std::string& clsname) { return new InheritanceViewer(clsname); } + +//===----------------------------------------------------------------------===// +/// ASTDumperXML - In-depth XML dumping. + +namespace { +class ASTDumpXML : public ASTConsumer { + llvm::raw_ostream &OS; + +public: + ASTDumpXML(llvm::raw_ostream &OS) : OS(OS) {} + + void HandleTranslationUnit(ASTContext &C) { + C.getTranslationUnitDecl()->dumpXML(OS); + } +}; +} + +ASTConsumer *clang::CreateASTDumperXML(llvm::raw_ostream &OS) { + return new ASTDumpXML(OS); +} diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index a0280e52c72..80643b2d4be 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -319,6 +319,7 @@ static const char *getActionName(frontend::ActionKind Kind) { llvm_unreachable("Invalid kind!"); case frontend::ASTDump: return "-ast-dump"; + case frontend::ASTDumpXML: return "-ast-dump-xml"; case frontend::ASTPrint: return "-ast-print"; case frontend::ASTPrintXML: return "-ast-print-xml"; case frontend::ASTView: return "-ast-view"; @@ -1003,6 +1004,8 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, assert(0 && "Invalid option in group!"); case OPT_ast_dump: Opts.ProgramAction = frontend::ASTDump; break; + case OPT_ast_dump_xml: + Opts.ProgramAction = frontend::ASTDumpXML; break; case OPT_ast_print: Opts.ProgramAction = frontend::ASTPrint; break; case OPT_ast_print_xml: diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp index d18baaa7e1e..0ffc06a4772 100644 --- a/clang/lib/Frontend/FrontendActions.cpp +++ b/clang/lib/Frontend/FrontendActions.cpp @@ -59,6 +59,17 @@ ASTConsumer *ASTDumpAction::CreateASTConsumer(CompilerInstance &CI, return CreateASTDumper(); } +ASTConsumer *ASTDumpXMLAction::CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile) { + llvm::raw_ostream *OS; + if (CI.getFrontendOpts().OutputFile.empty()) + OS = &llvm::outs(); + else + OS = CI.createDefaultOutputFile(false, InFile); + if (!OS) return 0; + return CreateASTDumperXML(*OS); +} + ASTConsumer *ASTViewAction::CreateASTConsumer(CompilerInstance &CI, llvm::StringRef InFile) { return CreateASTViewer(); diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 861117fb30a..711cbb64006 100644 --- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -35,6 +35,7 @@ static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) { llvm_unreachable("Invalid program action!"); case ASTDump: return new ASTDumpAction(); + case ASTDumpXML: return new ASTDumpXMLAction(); case ASTPrint: return new ASTPrintAction(); case ASTPrintXML: return new ASTPrintXMLAction(); case ASTView: return new ASTViewAction(); |

