hintonda created this revision. hintonda added a reviewer: aaron.ballman. hintonda added a subscriber: cfe-commits. Herald added a subscriber: klimek.
Update hasDynamicExceptionSpec to use functionType instead of functionDecl. http://reviews.llvm.org/D20687 Files: docs/LibASTMatchersReference.html include/clang/ASTMatchers/ASTMatchers.h unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp =================================================================== --- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp +++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp @@ -1383,19 +1383,19 @@ } TEST(hasDynamicExceptionSpec, MatchesDynamicExceptionSpecifications) { - EXPECT_TRUE(notMatches("void f();", functionDecl(hasDynamicExceptionSpec()))); + EXPECT_TRUE(notMatches("void f();", functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE(notMatches("void g() noexcept;", - functionDecl(hasDynamicExceptionSpec()))); + functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE(notMatches("void h() noexcept(true);", - functionDecl(hasDynamicExceptionSpec()))); + functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE(notMatches("void i() noexcept(false);", - functionDecl(hasDynamicExceptionSpec()))); + functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE( - matches("void j() throw();", functionDecl(hasDynamicExceptionSpec()))); + matches("void j() throw();", functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE( - matches("void k() throw(int);", functionDecl(hasDynamicExceptionSpec()))); + matches("void k() throw(int);", functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE( - matches("void l() throw(...);", functionDecl(hasDynamicExceptionSpec()))); + matches("void l() throw(...);", functionType(hasDynamicExceptionSpec()))); } TEST(HasObjectExpression, DoesNotMatchMember) { Index: include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -3245,10 +3245,10 @@ /// void k() throw(int); /// void l() throw(...); /// \endcode -/// functionDecl(hasDynamicExceptionSpec()) +/// functionType(hasDynamicExceptionSpec()) /// matches the declarations of j, k, and l, but not f, g, h, or i. -AST_MATCHER(FunctionDecl, hasDynamicExceptionSpec) { - if (const auto *FnTy = Node.getType()->getAs<FunctionProtoType>()) +AST_MATCHER(FunctionType, hasDynamicExceptionSpec) { + if (const auto *FnTy = dyn_cast<FunctionProtoType>(&Node)) return FnTy->hasDynamicExceptionSpec(); return false; } Index: docs/LibASTMatchersReference.html =================================================================== --- docs/LibASTMatchersReference.html +++ docs/LibASTMatchersReference.html @@ -2403,22 +2403,6 @@ </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('hasDynamicExceptionSpec0')"><a name="hasDynamicExceptionSpec0Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> -<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. - -Given: - void f(); - void g() noexcept; - void h() noexcept(true); - void i() noexcept(false); - void j() throw(); - void k() throw(int); - void l() throw(...); -functionDecl(hasDynamicExceptionSpec()) - matches the declarations of j, k, and l, but not f, g, h, or i. -</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('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. @@ -2616,6 +2600,22 @@ </pre></td></tr> +<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType</a>></td><td class="name" onclick="toggle('hasDynamicExceptionSpec0')"><a name="hasDynamicExceptionSpec0Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> +<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. + +Given: + void f(); + void g() noexcept; + void h() noexcept(true); + void i() noexcept(false); + void j() throw(); + void k() throw(int); + void l() throw(...); +functionType(hasDynamicExceptionSpec()) + matches the declarations of j, k, and l, but not f, g, h, or i. +</pre></td></tr> + + <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals0')"><a name="equals0Anchor">equals</a></td><td>ValueT Value</td></tr> <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value.
Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp =================================================================== --- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp +++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp @@ -1383,19 +1383,19 @@ } TEST(hasDynamicExceptionSpec, MatchesDynamicExceptionSpecifications) { - EXPECT_TRUE(notMatches("void f();", functionDecl(hasDynamicExceptionSpec()))); + EXPECT_TRUE(notMatches("void f();", functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE(notMatches("void g() noexcept;", - functionDecl(hasDynamicExceptionSpec()))); + functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE(notMatches("void h() noexcept(true);", - functionDecl(hasDynamicExceptionSpec()))); + functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE(notMatches("void i() noexcept(false);", - functionDecl(hasDynamicExceptionSpec()))); + functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE( - matches("void j() throw();", functionDecl(hasDynamicExceptionSpec()))); + matches("void j() throw();", functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE( - matches("void k() throw(int);", functionDecl(hasDynamicExceptionSpec()))); + matches("void k() throw(int);", functionType(hasDynamicExceptionSpec()))); EXPECT_TRUE( - matches("void l() throw(...);", functionDecl(hasDynamicExceptionSpec()))); + matches("void l() throw(...);", functionType(hasDynamicExceptionSpec()))); } TEST(HasObjectExpression, DoesNotMatchMember) { Index: include/clang/ASTMatchers/ASTMatchers.h =================================================================== --- include/clang/ASTMatchers/ASTMatchers.h +++ include/clang/ASTMatchers/ASTMatchers.h @@ -3245,10 +3245,10 @@ /// void k() throw(int); /// void l() throw(...); /// \endcode -/// functionDecl(hasDynamicExceptionSpec()) +/// functionType(hasDynamicExceptionSpec()) /// matches the declarations of j, k, and l, but not f, g, h, or i. -AST_MATCHER(FunctionDecl, hasDynamicExceptionSpec) { - if (const auto *FnTy = Node.getType()->getAs<FunctionProtoType>()) +AST_MATCHER(FunctionType, hasDynamicExceptionSpec) { + if (const auto *FnTy = dyn_cast<FunctionProtoType>(&Node)) return FnTy->hasDynamicExceptionSpec(); return false; } Index: docs/LibASTMatchersReference.html =================================================================== --- docs/LibASTMatchersReference.html +++ docs/LibASTMatchersReference.html @@ -2403,22 +2403,6 @@ </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('hasDynamicExceptionSpec0')"><a name="hasDynamicExceptionSpec0Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> -<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. - -Given: - void f(); - void g() noexcept; - void h() noexcept(true); - void i() noexcept(false); - void j() throw(); - void k() throw(int); - void l() throw(...); -functionDecl(hasDynamicExceptionSpec()) - matches the declarations of j, k, and l, but not f, g, h, or i. -</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('hasOverloadedOperatorName0')"><a name="hasOverloadedOperatorName0Anchor">hasOverloadedOperatorName</a></td><td>StringRef Name</td></tr> <tr><td colspan="4" class="doc" id="hasOverloadedOperatorName0"><pre>Matches overloaded operator names. @@ -2616,6 +2600,22 @@ </pre></td></tr> +<tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1FunctionType.html">FunctionType</a>></td><td class="name" onclick="toggle('hasDynamicExceptionSpec0')"><a name="hasDynamicExceptionSpec0Anchor">hasDynamicExceptionSpec</a></td><td></td></tr> +<tr><td colspan="4" class="doc" id="hasDynamicExceptionSpec0"><pre>Matches functions that have a dynamic exception specification. + +Given: + void f(); + void g() noexcept; + void h() noexcept(true); + void i() noexcept(false); + void j() throw(); + void k() throw(int); + void l() throw(...); +functionType(hasDynamicExceptionSpec()) + matches the declarations of j, k, and l, but not f, g, h, or i. +</pre></td></tr> + + <tr><td>Matcher<<a href="http://clang.llvm.org/doxygen/classclang_1_1IntegerLiteral.html">IntegerLiteral</a>></td><td class="name" onclick="toggle('equals0')"><a name="equals0Anchor">equals</a></td><td>ValueT Value</td></tr> <tr><td colspan="4" class="doc" id="equals0"><pre>Matches literals that are equal to the given value.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits