diff options
author | Samuel Benzaquen <sbenza@google.com> | 2014-06-05 18:22:14 +0000 |
---|---|---|
committer | Samuel Benzaquen <sbenza@google.com> | 2014-06-05 18:22:14 +0000 |
commit | f56a29924f2f32a1d688e516302c44092c07f15d (patch) | |
tree | 66f6dbef4f0eb802f101cdf4ee7b1ac738a8d1ec /clang/unittests/ASTMatchers/ASTMatchersTest.cpp | |
parent | 0d2f580200dfb257af1691a355ed395c926a495d (diff) | |
download | bcm5719-llvm-f56a29924f2f32a1d688e516302c44092c07f15d.tar.gz bcm5719-llvm-f56a29924f2f32a1d688e516302c44092c07f15d.zip |
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
llvm-svn: 210278
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index 691719c04e4..bcdc10ab6c0 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/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) {}", |