forked from OSchip/llvm-project
Add conversionDecl matcher for node CXXConversionDecl.
llvm-svn: 235348
This commit is contained in:
parent
dc4260db2a
commit
025f6b1981
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue