summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/clang-query/QueryEngineTest.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/unittests/clang-query/QueryEngineTest.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/unittests/clang-query/QueryEngineTest.cpp')
-rw-r--r--clang-tools-extra/unittests/clang-query/QueryEngineTest.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/clang-tools-extra/unittests/clang-query/QueryEngineTest.cpp b/clang-tools-extra/unittests/clang-query/QueryEngineTest.cpp
index f95d315c61b..74fd6d1a3f4 100644
--- a/clang-tools-extra/unittests/clang-query/QueryEngineTest.cpp
+++ b/clang-tools-extra/unittests/clang-query/QueryEngineTest.cpp
@@ -52,6 +52,8 @@ TEST_F(QueryEngineTest, Basic) {
DynTypedMatcher FnMatcher = functionDecl();
DynTypedMatcher FooMatcher = functionDecl(hasName("foo1"));
+ std::string FooMatcherString = "functionDecl(hasName(\"foo1\"))";
+
EXPECT_TRUE(NoOpQuery().run(OS, S));
EXPECT_EQ("", OS.str());
@@ -70,7 +72,7 @@ TEST_F(QueryEngineTest, Basic) {
Str.clear();
- EXPECT_TRUE(MatchQuery(FnMatcher).run(OS, S));
+ EXPECT_TRUE(MatchQuery("functionDecl()", FnMatcher).run(OS, S));
EXPECT_TRUE(OS.str().find("foo.cc:1:1: note: \"root\" binds here") !=
std::string::npos);
@@ -84,7 +86,7 @@ TEST_F(QueryEngineTest, Basic) {
Str.clear();
- EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
+ EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
EXPECT_TRUE(OS.str().find("foo.cc:1:1: note: \"root\" binds here") !=
std::string::npos);
@@ -94,7 +96,7 @@ TEST_F(QueryEngineTest, Basic) {
EXPECT_TRUE(
SetQuery<OutputKind>(&QuerySession::OutKind, OK_Print).run(OS, S));
- EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
+ EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
EXPECT_TRUE(OS.str().find("Binding for \"root\":\nvoid foo1()") !=
std::string::npos);
@@ -102,20 +104,20 @@ TEST_F(QueryEngineTest, Basic) {
Str.clear();
EXPECT_TRUE(SetQuery<OutputKind>(&QuerySession::OutKind, OK_Dump).run(OS, S));
- EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
+ EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
EXPECT_TRUE(OS.str().find("FunctionDecl") != std::string::npos);
Str.clear();
EXPECT_TRUE(SetQuery<bool>(&QuerySession::BindRoot, false).run(OS, S));
- EXPECT_TRUE(MatchQuery(FooMatcher).run(OS, S));
+ EXPECT_TRUE(MatchQuery(FooMatcherString, FooMatcher).run(OS, S));
EXPECT_TRUE(OS.str().find("No bindings.") != std::string::npos);
Str.clear();
- EXPECT_FALSE(MatchQuery(isMain()).run(OS, S));
+ EXPECT_FALSE(MatchQuery("isMain()", isMain()).run(OS, S));
EXPECT_EQ("Not a valid top-level matcher.\n", OS.str());
}
OpenPOWER on IntegriCloud