summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-query/Query.cpp
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2018-10-20 09:13:59 +0000
committerStephen Kelly <steveire@gmail.com>2018-10-20 09:13:59 +0000
commit4a5b01ddd7dd12f9a5826741e57104e8bf54748b (patch)
tree2f0ca8c7ec49a337b095c90827577c0ee9ec26d1 /clang-tools-extra/clang-query/Query.cpp
parentd0e5eca0fdd54ca9dc896843781abb46656c17be (diff)
downloadbcm5719-llvm-4a5b01ddd7dd12f9a5826741e57104e8bf54748b.tar.gz
bcm5719-llvm-4a5b01ddd7dd12f9a5826741e57104e8bf54748b.zip
[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 llvm-svn: 344840
Diffstat (limited to 'clang-tools-extra/clang-query/Query.cpp')
-rw-r--r--clang-tools-extra/clang-query/Query.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/clang-tools-extra/clang-query/Query.cpp b/clang-tools-extra/clang-query/Query.cpp
index 63b4f3579b9..463e52c5806 100644
--- a/clang-tools-extra/clang-query/Query.cpp
+++ b/clang-tools-extra/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";
OpenPOWER on IntegriCloud