From f83e80c885197148fd5df28cc9c04053dd66f361 Mon Sep 17 00:00:00 2001 From: Samuel Benzaquen Date: Thu, 5 Jun 2014 18:22:14 +0000 Subject: 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 --- unittests/ASTMatchers/ASTMatchersTest.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'unittests') 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) {}", -- cgit v1.2.3