Changeset View
Changeset View
Standalone View
Standalone View
unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
Show First 20 Lines • Show All 661 Lines • ▼ Show 20 Lines | TEST(Matcher, VarDecl_Storage) { | ||||
EXPECT_TRUE(notMatches("void f() { static int X; }", M)); | EXPECT_TRUE(notMatches("void f() { static int X; }", M)); | ||||
M = varDecl(hasName("X"), hasGlobalStorage()); | M = varDecl(hasName("X"), hasGlobalStorage()); | ||||
EXPECT_TRUE(notMatches("void f() { int X; }", M)); | EXPECT_TRUE(notMatches("void f() { int X; }", M)); | ||||
EXPECT_TRUE(matches("int X;", M)); | EXPECT_TRUE(matches("int X;", M)); | ||||
EXPECT_TRUE(matches("void f() { static int X; }", M)); | EXPECT_TRUE(matches("void f() { static int X; }", M)); | ||||
} | } | ||||
TEST(Matcher, VarDecl_IsStaticLocal) { | |||||
auto M = varDecl(isStaticLocal()); | |||||
EXPECT_TRUE(matches("void f() { static int X; }", M)); | |||||
EXPECT_TRUE(notMatches("static int X;", M)); | |||||
EXPECT_TRUE(notMatches("void f() { int X; }", M)); | |||||
EXPECT_TRUE(notMatches("int X;", M)); | |||||
} | |||||
TEST(Matcher, VarDecl_StorageDuration) { | TEST(Matcher, VarDecl_StorageDuration) { | ||||
std::string T = | std::string T = | ||||
"void f() { int x; static int y; } int a;static int b;extern int c;"; | "void f() { int x; static int y; } int a;static int b;extern int c;"; | ||||
EXPECT_TRUE(matches(T, varDecl(hasName("x"), hasAutomaticStorageDuration()))); | EXPECT_TRUE(matches(T, varDecl(hasName("x"), hasAutomaticStorageDuration()))); | ||||
EXPECT_TRUE( | EXPECT_TRUE( | ||||
notMatches(T, varDecl(hasName("y"), hasAutomaticStorageDuration()))); | notMatches(T, varDecl(hasName("y"), hasAutomaticStorageDuration()))); | ||||
EXPECT_TRUE( | EXPECT_TRUE( | ||||
▲ Show 20 Lines • Show All 1,578 Lines • Show Last 20 Lines |