diff options
| author | Yitzhak Mandelbaum <yitzhakm@google.com> | 2019-08-08 17:41:44 +0000 |
|---|---|---|
| committer | Yitzhak Mandelbaum <yitzhakm@google.com> | 2019-08-08 17:41:44 +0000 |
| commit | 57f471f4ff431cfc29ea0849a42829cc52e5f40a (patch) | |
| tree | 8a457461e0d6b7f147a537ddac528be0cc23c3e6 /clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp | |
| parent | 8faf2f3c406329323d04513a53c91ea07be80ac2 (diff) | |
| download | bcm5719-llvm-57f471f4ff431cfc29ea0849a42829cc52e5f40a.tar.gz bcm5719-llvm-57f471f4ff431cfc29ea0849a42829cc52e5f40a.zip | |
[clang] Update `ignoringElidableConstructorCall` matcher to ignore `ExprWithCleanups`.
Summary:
The `ExprWithCleanups` node is added to the AST along with the elidable
CXXConstructExpr. If it is the outermost node of the node being matched, ignore
it as well.
Reviewers: gribozavr
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65944
llvm-svn: 368319
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp')
| -rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp index cb5cf9ebf52..1b95d3d54ee 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp @@ -671,6 +671,23 @@ TEST(Matcher, IgnoresElidableDoesNotPreventMatches) { LanguageMode::Cxx11OrLater)); } +TEST(Matcher, IgnoresElidableInVarInit) { + auto matcher = + varDecl(hasInitializer(ignoringElidableConstructorCall(callExpr()))); + EXPECT_TRUE(matches("struct H {};" + "H G();" + "void f(H D = G()) {" + " return;" + "}", + matcher, LanguageMode::Cxx11OrLater)); + EXPECT_TRUE(matches("struct H {};" + "H G();" + "void f() {" + " H D = G();" + "}", + matcher, LanguageMode::Cxx11OrLater)); +} + TEST(Matcher, BindTheSameNameInAlternatives) { StatementMatcher matcher = anyOf( binaryOperator(hasOperatorName("+"), |

