Add conversionDecl matcher for node CXXConversionDecl.

llvm-svn: 235348
This commit is contained in:
Samuel Benzaquen 2015-04-20 20:58:50 +00:00
parent dc4260db2a
commit 025f6b1981
3 changed files with 16 additions and 0 deletions

View File

@ -757,6 +757,15 @@ const internal::VariadicDynCastAllOfMatcher<
/// \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

View File

@ -128,6 +128,7 @@ RegistryMaps::RegistryMaps() {
REGISTER_MATCHER(constructorDecl);
REGISTER_MATCHER(containsDeclaration);
REGISTER_MATCHER(continueStmt);
REGISTER_MATCHER(conversionDecl);
REGISTER_MATCHER(cStyleCastExpr);
REGISTER_MATCHER(ctorInitializer);
REGISTER_MATCHER(CUDAKernelCallExpr);

View File

@ -1398,6 +1398,12 @@ TEST(Callee, MatchesDeclarations) {
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) {