[clang] 64356b6 - Add missing unit test
Stephen Kelly via cfe-commits
cfe-commits at lists.llvm.org
Fri May 22 17:38:55 PDT 2020
Author: Stephen Kelly
Date: 2020-05-23T01:29:39+01:00
New Revision: 64356b6d94eac13780cc36ea12053d61a027561e
URL: https://github.com/llvm/llvm-project/commit/64356b6d94eac13780cc36ea12053d61a027561e
DIFF: https://github.com/llvm/llvm-project/commit/64356b6d94eac13780cc36ea12053d61a027561e.diff
LOG: Add missing unit test
Added:
Modified:
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
Removed:
################################################################################
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index 8fcaeac9cb5e..e8b0a312d0a3 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1830,6 +1830,43 @@ void stringConstruct()
hasDescendant(cxxOperatorCallExpr(
isAssignmentOperator(),
hasArgument(1, stringLiteral())))))));
+
+ Code = R"cpp(
+
+struct C1 {};
+struct C2 { operator C1(); };
+
+void conversionOperator()
+{
+ C2* c2;
+ C1 c1 = (*c2);
+}
+
+)cpp";
+ EXPECT_TRUE(matches(
+ Code,
+ traverse(
+ TK_AsIs,
+ functionDecl(
+ hasName("conversionOperator"),
+ hasDescendant(
+ varDecl(
+ hasName("c1"),
+ hasInitializer(
+ ignoringImplicit(cxxConstructExpr(hasArgument(
+ 0, ignoringImplicit(
+ cxxMemberCallExpr(onImplicitObjectArgument(
+ ignoringParenImpCasts(unaryOperator(
+ hasOperatorName("*")))))))))))
+ .bind("c1"))))));
+
+ EXPECT_TRUE(matches(
+ Code,
+ traverse(TK_IgnoreUnlessSpelledInSource,
+ functionDecl(hasName("conversionOperator"),
+ hasDescendant(varDecl(
+ hasName("c1"), hasInitializer(unaryOperator(
+ hasOperatorName("*")))))))));
}
template <typename MatcherT>
More information about the cfe-commits
mailing list