[PATCH] D62056: Use ASTDumper to dump the AST from clang-query

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 17 01:40:31 PDT 2019


steveire created this revision.
steveire added a reviewer: aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D62056

Files:
  clang-query/Query.cpp


Index: clang-query/Query.cpp
===================================================================
--- clang-query/Query.cpp
+++ 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 @@
         }
         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";
         }
       }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62056.199989.patch
Type: text/x-patch
Size: 908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190517/87d2b8af/attachment.bin>


More information about the cfe-commits mailing list