summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index a21ed04b32d..b9075927d74 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1751,6 +1751,17 @@ B func12() {
return c;
}
+void func13() {
+ int a = 0;
+ int c = 0;
+
+ [a, b = c](int d) { int e = d; };
+}
+
+void func14() {
+ [] <typename TemplateType> (TemplateType t, TemplateType u) { int e = t + u; };
+}
+
)cpp";
EXPECT_TRUE(matches(
@@ -1821,6 +1832,23 @@ B func12() {
returnStmt(forFunction(functionDecl(hasName("func12"))),
hasReturnValue(
declRefExpr(to(varDecl(hasName("c")))))))));
+
+ EXPECT_TRUE(matches(
+ Code,
+ traverse(
+ ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ lambdaExpr(forFunction(functionDecl(hasName("func13"))),
+ has(compoundStmt(hasDescendant(varDecl(hasName("e"))))),
+ has(declRefExpr(to(varDecl(hasName("a"))))),
+ has(varDecl(hasName("b"), hasInitializer(declRefExpr(to(
+ varDecl(hasName("c"))))))),
+ has(parmVarDecl(hasName("d")))))));
+
+ EXPECT_TRUE(matches(
+ Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+ lambdaExpr(
+ forFunction(functionDecl(hasName("func14"))),
+ has(templateTypeParmDecl(hasName("TemplateType")))))));
}
TEST(IgnoringImpCasts, MatchesImpCasts) {
OpenPOWER on IntegriCloud