summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
diff options
context:
space:
mode:
authorYitzhak Mandelbaum <yitzhakm@google.com>2019-08-08 17:41:44 +0000
committerYitzhak Mandelbaum <yitzhakm@google.com>2019-08-08 17:41:44 +0000
commit57f471f4ff431cfc29ea0849a42829cc52e5f40a (patch)
tree8a457461e0d6b7f147a537ddac528be0cc23c3e6 /clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
parent8faf2f3c406329323d04513a53c91ea07be80ac2 (diff)
downloadbcm5719-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.cpp17
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("+"),
OpenPOWER on IntegriCloud