[PATCH] D96017: [clang-check] Add tokens-dump in clang-check.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 11 00:41:04 PST 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf1a17c219c0: [clang-check] Add tokens-dump in clang-check. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D96017/new/

https://reviews.llvm.org/D96017

Files:
  clang/tools/clang-check/ClangCheck.cpp


Index: clang/tools/clang-check/ClangCheck.cpp
===================================================================
--- clang/tools/clang-check/ClangCheck.cpp
+++ clang/tools/clang-check/ClangCheck.cpp
@@ -88,6 +88,9 @@
 static cl::opt<bool> SyntaxTreeDump("syntax-tree-dump",
                                     cl::desc("dump the syntax tree"),
                                     cl::cat(ClangCheckCategory));
+static cl::opt<bool> TokensDump("tokens-dump",
+                                cl::desc("dump the preprocessed tokens"),
+                                cl::cat(ClangCheckCategory));
 
 namespace {
 
@@ -148,6 +151,8 @@
 
       void HandleTranslationUnit(clang::ASTContext &AST) override {
         clang::syntax::TokenBuffer TB = std::move(Collector).consume();
+        if (TokensDump)
+          llvm::outs() << TB.dumpForTests();
         clang::syntax::Arena A(AST.getSourceManager(), AST.getLangOpts(), TB);
         llvm::outs() << clang::syntax::buildSyntaxTree(A, AST)->dump(
             AST.getSourceManager());
@@ -217,7 +222,7 @@
     FrontendFactory = newFrontendActionFactory<clang::ento::AnalysisAction>();
   else if (Fixit)
     FrontendFactory = newFrontendActionFactory<ClangCheckFixItAction>();
-  else if (SyntaxTreeDump)
+  else if (SyntaxTreeDump || TokensDump)
     FrontendFactory = newFrontendActionFactory<DumpSyntaxTree>();
   else
     FrontendFactory = newFrontendActionFactory(&CheckFactory);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96017.322911.patch
Type: text/x-patch
Size: 1442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210211/cc3b3315/attachment.bin>


More information about the cfe-commits mailing list