diff options
| author | Samuel Benzaquen <sbenza@google.com> | 2015-04-20 20:58:50 +0000 |
|---|---|---|
| committer | Samuel Benzaquen <sbenza@google.com> | 2015-04-20 20:58:50 +0000 |
| commit | 025f6b19815916e357a5a11d600cffde25d427e1 (patch) | |
| tree | c0470cbe53049e9648d71c69f3c3f6163cef6b33 /clang | |
| parent | dc4260db2a8df312268771fdfb8e9db5cd522508 (diff) | |
| download | bcm5719-llvm-025f6b19815916e357a5a11d600cffde25d427e1.tar.gz bcm5719-llvm-025f6b19815916e357a5a11d600cffde25d427e1.zip | |
Add conversionDecl matcher for node CXXConversionDecl.
llvm-svn: 235348
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/ASTMatchers/ASTMatchers.h | 9 | ||||
| -rw-r--r-- | clang/lib/ASTMatchers/Dynamic/Registry.cpp | 1 | ||||
| -rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 6 |
3 files changed, 16 insertions, 0 deletions
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index 6a7b5303604..3280083b2b8 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -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 diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp index e46e6dafadd..04d3a325631 100644 --- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -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); diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index 4b0580a8147..46ddb8d0fb6 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -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) { |

