r368326 - [clang][NFC] Move matcher ignoringElidableConstructorCall's tests to appropriate file.
Yitzhak Mandelbaum via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 8 11:55:42 PDT 2019
Author: ymandel
Date: Thu Aug 8 11:55:42 2019
New Revision: 368326
URL: http://llvm.org/viewvc/llvm-project?rev=368326&view=rev
Log:
[clang][NFC] Move matcher ignoringElidableConstructorCall's tests to appropriate file.
Summary:
`ignoringElidableConstructorCall` is a traversal matcher, but its tests are
grouped with narrowing-matcher tests. This revision moves them to the correct
file.
Reviewers: gribozavr
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65963
Modified:
cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp?rev=368326&r1=368325&r2=368326&view=diff
==============================================================================
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Thu Aug 8 11:55:42 2019
@@ -603,91 +603,6 @@ TEST(Matcher, BindMatchedNodes) {
llvm::make_unique<VerifyIdIsBoundTo<CXXMemberCallExpr>>("x")));
}
-TEST(Matcher, IgnoresElidableConstructors) {
- EXPECT_TRUE(
- matches("struct H {};"
- "template<typename T> H B(T A);"
- "void f() {"
- " H D1;"
- " D1 = B(B(1));"
- "}",
- cxxOperatorCallExpr(hasArgument(
- 1, callExpr(hasArgument(
- 0, ignoringElidableConstructorCall(callExpr()))))),
- LanguageMode::Cxx11OrLater));
- EXPECT_TRUE(
- matches("struct H {};"
- "template<typename T> H B(T A);"
- "void f() {"
- " H D1;"
- " D1 = B(1);"
- "}",
- cxxOperatorCallExpr(hasArgument(
- 1, callExpr(hasArgument(0, ignoringElidableConstructorCall(
- integerLiteral()))))),
- LanguageMode::Cxx11OrLater));
- EXPECT_TRUE(matches(
- "struct H {};"
- "H G();"
- "void f() {"
- " H D = G();"
- "}",
- varDecl(hasInitializer(anyOf(
- ignoringElidableConstructorCall(callExpr()),
- exprWithCleanups(has(ignoringElidableConstructorCall(callExpr())))))),
- LanguageMode::Cxx11OrLater));
-}
-
-TEST(Matcher, IgnoresElidableInReturn) {
- auto matcher = expr(ignoringElidableConstructorCall(declRefExpr()));
- EXPECT_TRUE(matches("struct H {};"
- "H f() {"
- " H g;"
- " return g;"
- "}",
- matcher, LanguageMode::Cxx11OrLater));
- EXPECT_TRUE(notMatches("struct H {};"
- "H f() {"
- " return H();"
- "}",
- matcher, LanguageMode::Cxx11OrLater));
-}
-
-TEST(Matcher, IgnoreElidableConstructorDoesNotMatchConstructors) {
- EXPECT_TRUE(matches("struct H {};"
- "void f() {"
- " H D;"
- "}",
- varDecl(hasInitializer(
- ignoringElidableConstructorCall(cxxConstructExpr()))),
- LanguageMode::Cxx11OrLater));
-}
-
-TEST(Matcher, IgnoresElidableDoesNotPreventMatches) {
- EXPECT_TRUE(matches("void f() {"
- " int D = 10;"
- "}",
- expr(ignoringElidableConstructorCall(integerLiteral())),
- 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("+"),
Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=368326&r1=368325&r2=368326&view=diff
==============================================================================
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Thu Aug 8 11:55:42 2019
@@ -1461,6 +1461,91 @@ TEST(HasImplicitDestinationType, DoesNot
unless(anything())))));
}
+TEST(Matcher, IgnoresElidableConstructors) {
+ EXPECT_TRUE(
+ matches("struct H {};"
+ "template<typename T> H B(T A);"
+ "void f() {"
+ " H D1;"
+ " D1 = B(B(1));"
+ "}",
+ cxxOperatorCallExpr(hasArgument(
+ 1, callExpr(hasArgument(
+ 0, ignoringElidableConstructorCall(callExpr()))))),
+ LanguageMode::Cxx11OrLater));
+ EXPECT_TRUE(
+ matches("struct H {};"
+ "template<typename T> H B(T A);"
+ "void f() {"
+ " H D1;"
+ " D1 = B(1);"
+ "}",
+ cxxOperatorCallExpr(hasArgument(
+ 1, callExpr(hasArgument(0, ignoringElidableConstructorCall(
+ integerLiteral()))))),
+ LanguageMode::Cxx11OrLater));
+ EXPECT_TRUE(matches(
+ "struct H {};"
+ "H G();"
+ "void f() {"
+ " H D = G();"
+ "}",
+ varDecl(hasInitializer(anyOf(
+ ignoringElidableConstructorCall(callExpr()),
+ exprWithCleanups(has(ignoringElidableConstructorCall(callExpr())))))),
+ LanguageMode::Cxx11OrLater));
+}
+
+TEST(Matcher, IgnoresElidableInReturn) {
+ auto matcher = expr(ignoringElidableConstructorCall(declRefExpr()));
+ EXPECT_TRUE(matches("struct H {};"
+ "H f() {"
+ " H g;"
+ " return g;"
+ "}",
+ matcher, LanguageMode::Cxx11OrLater));
+ EXPECT_TRUE(notMatches("struct H {};"
+ "H f() {"
+ " return H();"
+ "}",
+ matcher, LanguageMode::Cxx11OrLater));
+}
+
+TEST(Matcher, IgnoreElidableConstructorDoesNotMatchConstructors) {
+ EXPECT_TRUE(matches("struct H {};"
+ "void f() {"
+ " H D;"
+ "}",
+ varDecl(hasInitializer(
+ ignoringElidableConstructorCall(cxxConstructExpr()))),
+ LanguageMode::Cxx11OrLater));
+}
+
+TEST(Matcher, IgnoresElidableDoesNotPreventMatches) {
+ EXPECT_TRUE(matches("void f() {"
+ " int D = 10;"
+ "}",
+ expr(ignoringElidableConstructorCall(integerLiteral())),
+ 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(IgnoringImplicit, MatchesImplicit) {
EXPECT_TRUE(matches("class C {}; C a = C();",
varDecl(has(ignoringImplicit(cxxConstructExpr())))));
More information about the cfe-commits
mailing list