diff options
author | Stephen Kelly <steveire@gmail.com> | 2019-12-18 22:35:46 +0000 |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2019-12-21 11:02:11 +0000 |
commit | 5a79cfa32d62f018607438a30b7acb49c2ab97f3 (patch) | |
tree | 0968857245022ac33971450dbea8fa42bd02d7ec /clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp | |
parent | 1805d1f87d7835b237f85bfb0595d1f411ebf1bf (diff) | |
download | bcm5719-llvm-5a79cfa32d62f018607438a30b7acb49c2ab97f3.tar.gz bcm5719-llvm-5a79cfa32d62f018607438a30b7acb49c2ab97f3.zip |
Customize simplified dumping and matching of LambdaExpr
Reviewers: aaron.ballman
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D71680
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp | 28 |
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) { |