summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2014-08-25 11:23:50 +0000
committerManuel Klimek <klimek@google.com>2014-08-25 11:23:50 +0000
commit3fe8a38110ee54efe04c3a66c677c67fb619f645 (patch)
treecbac75bd4d175a295a59863852e9d3c451d686a9 /clang/unittests/ASTMatchers/ASTMatchersTest.cpp
parent4b3ba214d06d5681894d1f481a7bb1f5cc6a597e (diff)
downloadbcm5719-llvm-3fe8a38110ee54efe04c3a66c677c67fb619f645.tar.gz
bcm5719-llvm-3fe8a38110ee54efe04c3a66c677c67fb619f645.zip
Add hasAttr matcher for declarations.
Delete special-case CUDA attribute matchers. Patch by Jacques Pienaar. llvm-svn: 216379
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index 7a639aac81c..9263736fef8 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -649,22 +649,23 @@ TEST(DeclarationMatcher, HasDescendantMemoization) {
EXPECT_TRUE(matches("void f() { int i; }", CannotMemoize));
}
+TEST(DeclarationMatcher, HasAttr) {
+ EXPECT_TRUE(matches("struct __attribute__((warn_unused)) X {};",
+ decl(hasAttr(clang::attr::WarnUnused))));
+ EXPECT_FALSE(matches("struct X {};",
+ decl(hasAttr(clang::attr::WarnUnused))));
+}
+
TEST(DeclarationMatcher, MatchCudaDecl) {
EXPECT_TRUE(matchesWithCuda("__global__ void f() { }"
"void g() { f<<<1, 2>>>(); }",
CUDAKernelCallExpr()));
EXPECT_TRUE(matchesWithCuda("__attribute__((device)) void f() {}",
- hasCudaDeviceAttr()));
- EXPECT_TRUE(matchesWithCuda("__attribute__((host)) void f() {}",
- hasCudaHostAttr()));
- EXPECT_TRUE(matchesWithCuda("__attribute__((global)) void f() {}",
- hasCudaGlobalAttr()));
- EXPECT_FALSE(matchesWithCuda("void f() {}",
- hasCudaGlobalAttr()));
+ hasAttr(clang::attr::CUDADevice)));
EXPECT_TRUE(notMatchesWithCuda("void f() {}",
- hasCudaGlobalAttr()));
+ CUDAKernelCallExpr()));
EXPECT_FALSE(notMatchesWithCuda("__attribute__((global)) void f() {}",
- hasCudaGlobalAttr()));
+ hasAttr(clang::attr::CUDAGlobal)));
}
// Implements a run method that returns whether BoundNodes contains a
OpenPOWER on IntegriCloud