summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2019-12-06 23:26:59 +0000
committerStephen Kelly <steveire@gmail.com>2019-12-06 23:38:56 +0000
commitb22d8ae7f436bfe63b28ceddea743071a6601eb1 (patch)
treeb2bf15e4e590ee683f7d750b9317953ae6c5ba1c
parente1578fd2b79fe5af5f80c0c166a8abd0f816c022 (diff)
downloadbcm5719-llvm-b22d8ae7f436bfe63b28ceddea743071a6601eb1.tar.gz
bcm5719-llvm-b22d8ae7f436bfe63b28ceddea743071a6601eb1.zip
Use ASTDumper to dump the AST from clang-query
Summary: This way, the output is not limited by the various API differences between the dump() member functions. For example, all dumps are now in color, while that used to be the case only for Decls and Stmts, but not Types. Additionally, while DynTypedNode::dump (which was used up to now) was limited to dumping only Decls, Stmts and Types, this makes clang-query support everything ASTNodeTraverser supports. Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62056
-rw-r--r--clang-tools-extra/clang-query/Query.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-query/Query.cpp b/clang-tools-extra/clang-query/Query.cpp
index eea0e7766d3..675fd968f46 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/clang-query/Query.cpp
@@ -8,6 +8,7 @@
#include "Query.h"
#include "QuerySession.h"
+#include "clang/AST/ASTDumper.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Frontend/TextDiagnostic.h"
@@ -128,7 +129,11 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
}
if (QS.DetailedASTOutput) {
OS << "Binding for \"" << BI->first << "\":\n";
- BI->second.dump(OS, AST->getSourceManager());
+ const ASTContext &Ctx = AST->getASTContext();
+ const SourceManager &SM = Ctx.getSourceManager();
+ ASTDumper Dumper(OS, &Ctx.getCommentCommandTraits(), &SM,
+ SM.getDiagnostics().getShowColors(), Ctx.getPrintingPolicy());
+ Dumper.Visit(BI->second);
OS << "\n";
}
}
OpenPOWER on IntegriCloud