aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/AST/CMakeLists.txt1
-rw-r--r--lib/Frontend/ASTConsumers.cpp20
-rw-r--r--lib/Frontend/CompilerInvocation.cpp3
-rw-r--r--lib/Frontend/FrontendActions.cpp11
-rw-r--r--lib/FrontendTool/ExecuteCompilerInvocation.cpp1
5 files changed, 36 insertions, 0 deletions
diff --git a/lib/AST/CMakeLists.txt b/lib/AST/CMakeLists.txt
index f56e6c41b0..6fca4d7e73 100644
--- a/lib/AST/CMakeLists.txt
+++ b/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/lib/Frontend/ASTConsumers.cpp b/lib/Frontend/ASTConsumers.cpp
index eb7f270ae8..5c7c02da9b 100644
--- a/lib/Frontend/ASTConsumers.cpp
+++ b/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/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index a0280e52c7..80643b2d4b 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/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/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp
index d18baaa7e1..0ffc06a477 100644
--- a/lib/Frontend/FrontendActions.cpp
+++ b/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/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/lib/FrontendTool/ExecuteCompilerInvocation.cpp
index 861117fb30..711cbb6400 100644
--- a/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ b/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();