diff options
author | Stephen Kelly <steveire@gmail.com> | 2018-10-20 09:13:59 +0000 |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2018-10-20 09:13:59 +0000 |
commit | 5b664c48414e6e269bf80e5ddfe84e777bb494cf (patch) | |
tree | 413bba2e5833050d06ccf82ef252e54bc81a7d55 /clang-query/Query.cpp | |
parent | 52465410c851466db4f302a7f9b5dc25c74d3412 (diff) |
[clang-query] Add option to print matcher expression
Summary:
This is useful if using clang-query -f with a file containing multiple
matchers.
Reviewers: aaron.ballman
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D52859
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344840 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-query/Query.cpp')
-rw-r--r-- | clang-query/Query.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang-query/Query.cpp b/clang-query/Query.cpp index 63b4f357..463e52c5 100644 --- a/clang-query/Query.cpp +++ b/clang-query/Query.cpp @@ -41,6 +41,8 @@ bool HelpQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const { "as part of other expressions.\n" " set bind-root (true|false) " "Set whether to bind the root matcher to \"root\".\n" + " set print-matcher (true|false) " + "Set whether to print the current matcher,\n" " set output (diag|print|dump) " "Set whether to print bindings as diagnostics,\n" " " @@ -86,6 +88,12 @@ bool MatchQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const { } Finder.matchAST(AST->getASTContext()); + if (QS.PrintMatcher) { + std::string prefixText = "Matcher: "; + OS << "\n " << prefixText << Source << "\n"; + OS << " " << std::string(prefixText.size() + Source.size(), '=') << '\n'; + } + for (auto MI = Matches.begin(), ME = Matches.end(); MI != ME; ++MI) { OS << "\nMatch #" << ++MatchCount << ":\n\n"; |