/// \endcode
const internal::VariadicDynCastAllOfMatcher<Decl, CXXMethodDecl> methodDecl;
+/// \brief Matches conversion operator declarations.
+///
+/// Example matches the operator.
+/// \code
+/// class X { operator int() const; };
+/// \endcode
+const internal::VariadicDynCastAllOfMatcher<Decl, CXXConversionDecl>
+ conversionDecl;
+
/// \brief Matches variable declarations.
///
/// Note: this does not match declarations of member variables, which are
REGISTER_MATCHER(constructorDecl);
REGISTER_MATCHER(containsDeclaration);
REGISTER_MATCHER(continueStmt);
+ REGISTER_MATCHER(conversionDecl);
REGISTER_MATCHER(cStyleCastExpr);
REGISTER_MATCHER(ctorInitializer);
REGISTER_MATCHER(CUDAKernelCallExpr);
EXPECT_TRUE(matches("class Y { void x() { x(); } };", CallMethodX));
EXPECT_TRUE(notMatches("class Y { void x() {} };", CallMethodX));
+
+ CallMethodX = callExpr(callee(conversionDecl()));
+ EXPECT_TRUE(
+ matches("struct Y { operator int() const; }; int i = Y();", CallMethodX));
+ EXPECT_TRUE(notMatches("struct Y { operator int() const; }; Y y = Y();",
+ CallMethodX));
}
TEST(Callee, MatchesMemberExpressions) {