summaryrefslogtreecommitdiffstats
path: root/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2016-06-07 17:34:45 +0000
committerAaron Ballman <aaron@aaronballman.com>2016-06-07 17:34:45 +0000
commit61f7b355550c794c3590182733a63790788c9429 (patch)
treedfa72182b0da2ad7f1aea681a9c24d03ec1ffcba /unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
parent48e271ebb49eac1dd305a58d68c4d0d98a767aff (diff)
Make isNoThrow and hasDynamicExceptionSpec polymorphic so they can be used with both functionDecl and functionPrototype matchers.
Patch by Don Hinton. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272028 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp')
-rw-r--r--unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index dc266076d3..e304d0629c 100644
--- a/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -845,6 +845,13 @@ TEST(IsNoThrow, MatchesNoThrowFunctionDeclarations) {
notMatches("void f() noexcept(false);", functionDecl(isNoThrow())));
EXPECT_TRUE(matches("void f() throw();", functionDecl(isNoThrow())));
EXPECT_TRUE(matches("void f() noexcept;", functionDecl(isNoThrow())));
+
+ EXPECT_TRUE(notMatches("void f();", functionProtoType(isNoThrow())));
+ EXPECT_TRUE(notMatches("void f() throw(int);", functionProtoType(isNoThrow())));
+ EXPECT_TRUE(
+ notMatches("void f() noexcept(false);", functionProtoType(isNoThrow())));
+ EXPECT_TRUE(matches("void f() throw();", functionProtoType(isNoThrow())));
+ EXPECT_TRUE(matches("void f() noexcept;", functionProtoType(isNoThrow())));
}
TEST(isConstexpr, MatchesConstexprDeclarations) {
@@ -1396,6 +1403,20 @@ TEST(hasDynamicExceptionSpec, MatchesDynamicExceptionSpecifications) {
matches("void k() throw(int);", functionDecl(hasDynamicExceptionSpec())));
EXPECT_TRUE(
matches("void l() throw(...);", functionDecl(hasDynamicExceptionSpec())));
+
+ EXPECT_TRUE(notMatches("void f();", functionProtoType(hasDynamicExceptionSpec())));
+ EXPECT_TRUE(notMatches("void g() noexcept;",
+ functionProtoType(hasDynamicExceptionSpec())));
+ EXPECT_TRUE(notMatches("void h() noexcept(true);",
+ functionProtoType(hasDynamicExceptionSpec())));
+ EXPECT_TRUE(notMatches("void i() noexcept(false);",
+ functionProtoType(hasDynamicExceptionSpec())));
+ EXPECT_TRUE(
+ matches("void j() throw();", functionProtoType(hasDynamicExceptionSpec())));
+ EXPECT_TRUE(
+ matches("void k() throw(int);", functionProtoType(hasDynamicExceptionSpec())));
+ EXPECT_TRUE(
+ matches("void l() throw(...);", functionProtoType(hasDynamicExceptionSpec())));
}
TEST(HasObjectExpression, DoesNotMatchMember) {