From 9b66c4bbbe23accc8c3b3b8cbacf7f093870f68f Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 24 Nov 2010 11:21:45 +0000 Subject: 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 --- clang/lib/Frontend/ASTConsumers.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'clang/lib/Frontend/ASTConsumers.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); +} -- cgit v1.2.3