diff options
| author | Samuel Benzaquen <sbenza@google.com> | 2014-08-15 14:20:59 +0000 |
|---|---|---|
| committer | Samuel Benzaquen <sbenza@google.com> | 2014-08-15 14:20:59 +0000 |
| commit | 8e7f99647d2ebe94878fd956f193d3cab13163e9 (patch) | |
| tree | 410664b362d86f55d2674ed54e712bb38f9cecf5 | |
| parent | adbe02435db367785cbff52a89dda644e29b20c8 (diff) | |
| download | bcm5719-llvm-8e7f99647d2ebe94878fd956f193d3cab13163e9.tar.gz bcm5719-llvm-8e7f99647d2ebe94878fd956f193d3cab13163e9.zip | |
Add isDeleted() matcher for FunctionDecl nodes.
Reviewers: klimek
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D4911
llvm-svn: 215714
| -rw-r--r-- | clang/docs/LibASTMatchersReference.html | 13 | ||||
| -rw-r--r-- | clang/include/clang/ASTMatchers/ASTMatchers.h | 13 | ||||
| -rw-r--r-- | clang/lib/ASTMatchers/Dynamic/Registry.cpp | 1 | ||||
| -rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 7 |
4 files changed, 33 insertions, 1 deletions
diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html index 82c26a527d9..03910f0f665 100644 --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -368,7 +368,7 @@ nestedNameSpecifier() <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1Stmt.html">Stmt</a>></td><td class="name" onclick="toggle('CUDAKernelCallExpr0')"><a name="CUDAKernelCallExpr0Anchor">CUDAKernelCallExpr</a></td><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html">CUDAKernelCallExpr</a>>...</td></tr> <tr><td colspan="4" class="doc" id="CUDAKernelCallExpr0"><pre>Matches CUDA kernel call expression. -Example matches kernel<<<i,j>>>() +Example matches, kernel<<<i,j>>>(); </pre></td></tr> @@ -1733,6 +1733,17 @@ Usable as: Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1TagDec </pre></td></tr> +<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isDeleted0')"><a name="isDeleted0Anchor">isDeleted</a></td><td></td></tr> +<tr><td colspan="4" class="doc" id="isDeleted0"><pre>Matches deleted function declarations. + +Given: + void Func(); + void DeletedFunc() = delete; +functionDecl(isDeleted()) + matches the declaration of DeletedFunc, but not Func. +</pre></td></tr> + + <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html">FunctionDecl</a>></td><td class="name" onclick="toggle('isExplicitTemplateSpecialization0')"><a name="isExplicitTemplateSpecialization0Anchor">isExplicitTemplateSpecialization</a></td><td></td></tr> <tr><td colspan="4" class="doc" id="isExplicitTemplateSpecialization0"><pre>Matches explicit template specializations of function, class, or static member variable template instantiations. diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h index c2ee0b22773..1f3e6501603 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchers.h +++ b/clang/include/clang/ASTMatchers/ASTMatchers.h @@ -2373,6 +2373,19 @@ AST_MATCHER(FunctionDecl, isExternC) { return Node.isExternC(); } +/// \brief Matches deleted function declarations. +/// +/// Given: +/// \code +/// void Func(); +/// void DeletedFunc() = delete; +/// \endcode +/// functionDecl(isDeleted()) +/// matches the declaration of DeletedFunc, but not Func. +AST_MATCHER(FunctionDecl, isDeleted) { + return Node.isDeleted(); +} + /// \brief Matches the condition expression of an if statement, for loop, /// or conditional operator. /// diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp index 7e323a5198e..1214e6293e9 100644 --- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp @@ -230,6 +230,7 @@ RegistryMaps::RegistryMaps() { REGISTER_MATCHER(isConst); REGISTER_MATCHER(isConstQualified); REGISTER_MATCHER(isDefinition); + REGISTER_MATCHER(isDeleted); REGISTER_MATCHER(isExplicitTemplateSpecialization); REGISTER_MATCHER(isExpr); REGISTER_MATCHER(isExternC); diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index bf4dee82bda..7a639aac81c 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -1528,6 +1528,13 @@ TEST(IsExternC, MatchesExternCFunctionDeclarations) { EXPECT_TRUE(notMatches("void f() {}", functionDecl(isExternC()))); } +TEST(IsDeleted, MatchesDeletedFunctionDeclarations) { + EXPECT_TRUE( + notMatches("void Func();", functionDecl(hasName("Func"), isDeleted()))); + EXPECT_TRUE(matches("void Func() = delete;", + functionDecl(hasName("Func"), isDeleted()))); +} + TEST(HasAnyParameter, DoesntMatchIfInnerMatcherDoesntMatch) { EXPECT_TRUE(notMatches("class Y {}; class X { void x(int) {} };", methodDecl(hasAnyParameter(hasType(recordDecl(hasName("X"))))))); |

