[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 4 04:46:43 PST 2021
hokein created this revision.
hokein added a reviewer: kbobyrev.
hokein requested review of this revision.
Herald added a project: clang.
It is useful for syntax-tree developement.
Repository:
rG LLVM Github Monorepo
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.321386.patch
Type: text/x-patch
Size: 1442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210204/dc530c4e/attachment.bin>
More information about the cfe-commits
mailing list