summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/Dynamic
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2018-08-30 23:11:09 +0000
committerStephen Kelly <steveire@gmail.com>2018-08-30 23:11:09 +0000
commitfc934cd916fa44fb439dae50c1dbcef1c58588cd (patch)
treee4145af2160400d0891d515ac291e3a359d5bafb /clang/unittests/ASTMatchers/Dynamic
parent5fb9dc51dc80602c806b5e45f47081966cd331db (diff)
downloadbcm5719-llvm-fc934cd916fa44fb439dae50c1dbcef1c58588cd.tar.gz
bcm5719-llvm-fc934cd916fa44fb439dae50c1dbcef1c58588cd.zip
Allow binding to NamedValue resulting from let expression
Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51259 llvm-svn: 341142
Diffstat (limited to 'clang/unittests/ASTMatchers/Dynamic')
-rw-r--r--clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
index d670e3129b8..fd7bbdde4a1 100644
--- a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -359,6 +359,44 @@ TEST(ParserTest, CompletionNamedValues) {
Comps[2].MatcherDecl);
}
+TEST(ParserTest, ParseBindOnLet) {
+
+ auto NamedValues = getTestNamedValues();
+
+ Diagnostics Error;
+
+ {
+ llvm::Optional<DynTypedMatcher> TopLevelLetBinding(
+ Parser::parseMatcherExpression("hasParamA.bind(\"parmABinding\")",
+ nullptr, &NamedValues, &Error));
+ EXPECT_EQ("", Error.toStringFull());
+ auto M = TopLevelLetBinding->unconditionalConvertTo<Decl>();
+
+ EXPECT_TRUE(matchAndVerifyResultTrue(
+ "void foo(int a);", M,
+ llvm::make_unique<VerifyIdIsBoundTo<FunctionDecl>>("parmABinding")));
+ EXPECT_TRUE(matchAndVerifyResultFalse(
+ "void foo(int b);", M,
+ llvm::make_unique<VerifyIdIsBoundTo<FunctionDecl>>("parmABinding")));
+ }
+
+ {
+ llvm::Optional<DynTypedMatcher> NestedLetBinding(
+ Parser::parseMatcherExpression(
+ "functionDecl(hasParamA.bind(\"parmABinding\"))", nullptr,
+ &NamedValues, &Error));
+ EXPECT_EQ("", Error.toStringFull());
+ auto M = NestedLetBinding->unconditionalConvertTo<Decl>();
+
+ EXPECT_TRUE(matchAndVerifyResultTrue(
+ "void foo(int a);", M,
+ llvm::make_unique<VerifyIdIsBoundTo<FunctionDecl>>("parmABinding")));
+ EXPECT_TRUE(matchAndVerifyResultFalse(
+ "void foo(int b);", M,
+ llvm::make_unique<VerifyIdIsBoundTo<FunctionDecl>>("parmABinding")));
+ }
+}
+
} // end anonymous namespace
} // end namespace dynamic
} // end namespace ast_matchers
OpenPOWER on IntegriCloud