summaryrefslogtreecommitdiffstats
path: root/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
diff options
context:
space:
mode:
authorHaojian Wu <hokein@google.com>2016-09-26 16:01:52 +0000
committerHaojian Wu <hokein@google.com>2016-09-26 16:01:52 +0000
commitb2c1023a57dfe16e64e14fcd207a82f1571345a1 (patch)
treef949a8813714a27ff99640a4b6ed881d2936ad6a /unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
parent1f6e70072ee98bce99c82e8bfa6c251666b37b97 (diff)
[ASTMatcher] Add isStaticStorageClass matcher for varDecl and functionDecl.
Reviewers: klimek Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D24821 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282415 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp')
-rw-r--r--unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp b/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
index 1527eacb6a..5834211bdb 100644
--- a/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -848,6 +848,14 @@ TEST(IsExternC, MatchesExternCVariableDeclarations) {
EXPECT_TRUE(notMatches("int i;", varDecl(isExternC())));
}
+TEST(IsStaticStorageClass, MatchesStaticDeclarations) {
+ EXPECT_TRUE(
+ matches("static void f() {}", functionDecl(isStaticStorageClass())));
+ EXPECT_TRUE(matches("static int i = 1;", varDecl(isStaticStorageClass())));
+ EXPECT_TRUE(notMatches("int i = 1;", varDecl(isStaticStorageClass())));
+ EXPECT_TRUE(notMatches("void f() {}", functionDecl(isStaticStorageClass())));
+}
+
TEST(IsDefaulted, MatchesDefaultedFunctionDeclarations) {
EXPECT_TRUE(notMatches("class A { ~A(); };",
functionDecl(hasName("~A"), isDefaulted())));