summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2014-08-05 09:45:53 +0000
committerManuel Klimek <klimek@google.com>2014-08-05 09:45:53 +0000
commitd52a3b8897fe9084b1fc1ff7c273743db47d5072 (patch)
tree617f633691acbc7f169aca8b2c632f8bb207afd8 /clang/unittests/ASTMatchers/ASTMatchersTest.cpp
parent6b41a9900aba8b010daf10ec68d14f7a005f0c82 (diff)
downloadbcm5719-llvm-d52a3b8897fe9084b1fc1ff7c273743db47d5072.tar.gz
bcm5719-llvm-d52a3b8897fe9084b1fc1ff7c273743db47d5072.zip
Adds AST matchers for matching CUDA declarations.
Patch by Jacques Pienaar. llvm-svn: 214852
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersTest.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
index e769e887bd1..bf4dee82bda 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -649,6 +649,24 @@ TEST(DeclarationMatcher, HasDescendantMemoization) {
EXPECT_TRUE(matches("void f() { int i; }", CannotMemoize));
}
+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()));
+ EXPECT_TRUE(notMatchesWithCuda("void f() {}",
+ hasCudaGlobalAttr()));
+ EXPECT_FALSE(notMatchesWithCuda("__attribute__((global)) void f() {}",
+ hasCudaGlobalAttr()));
+}
+
// Implements a run method that returns whether BoundNodes contains a
// Decl bound to Id that can be dynamically cast to T.
// Optionally checks that the check succeeded a specific number of times.
OpenPOWER on IntegriCloud