summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorSamuel Benzaquen <sbenza@google.com>2014-06-05 18:22:14 +0000
committerSamuel Benzaquen <sbenza@google.com>2014-06-05 18:22:14 +0000
commitf83e80c885197148fd5df28cc9c04053dd66f361 (patch)
tree2f2383b67dd32ba4c3d5921cf4ac1276279c51bc /unittests
parent3bfddd4fdbb35e2d60f9233296d0b4f1fff75997 (diff)
downloadclang-f83e80c885197148fd5df28cc9c04053dd66f361.tar.gz
clang-f83e80c885197148fd5df28cc9c04053dd66f361.tar.bz2
clang-f83e80c885197148fd5df28cc9c04053dd66f361.tar.xz
Add hasLocalStorage/hasGlobalStorage matchers.
Summary: Add hasLocalStorage/hasGlobalStorage matchers for VarDecl nodes. Update the doc. Also add them to the dynamic registry. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D4034 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210278 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/ASTMatchers/ASTMatchersTest.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp
index 691719c04e..bcdc10ab6c 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1165,6 +1165,18 @@ TEST(Matcher, VariableUsage) {
"}", Reference));
}
+TEST(Matcher, VarDecl_Storage) {
+ auto M = varDecl(hasName("X"), hasLocalStorage());
+ EXPECT_TRUE(matches("void f() { int X; }", M));
+ EXPECT_TRUE(notMatches("int X;", M));
+ EXPECT_TRUE(notMatches("void f() { static int X; }", M));
+
+ M = varDecl(hasName("X"), hasGlobalStorage());
+ EXPECT_TRUE(notMatches("void f() { int X; }", M));
+ EXPECT_TRUE(matches("int X;", M));
+ EXPECT_TRUE(matches("void f() { static int X; }", M));
+}
+
TEST(Matcher, FindsVarDeclInFunctionParameter) {
EXPECT_TRUE(matches(
"void f(int i) {}",