diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2015-11-18 17:56:55 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2015-11-18 17:56:55 +0000 |
commit | 64ba2ebce065a39c210102dad5ee7d972499be94 (patch) | |
tree | 9d8d1930b770b01ad90bee0f76c8afa6d39848a9 /unittests/ASTMatchers/ASTMatchersTest.cpp | |
parent | ce63f1d374b8ec9f687f346879053940d2374f68 (diff) | |
download | clang-64ba2ebce065a39c210102dad5ee7d972499be94.tar.gz |
Re-committing r253473 after hopefully fixing the bot breakage. There was a copy-pasta issue that my local testing did not catch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@253481 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r-- | unittests/ASTMatchers/ASTMatchersTest.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp index 476a0be290..6d81bd88b9 100644 --- a/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -1355,6 +1355,29 @@ TEST(Matcher, VarDecl_Storage) { EXPECT_TRUE(matches("void f() { static int X; }", M)); } +TEST(Matcher, VarDecl_StorageDuration) { + std::string T = + "void f() { int x; static int y; thread_local int z; } int a;"; + + EXPECT_TRUE(matches(T, varDecl(hasName("x"), hasAutomaticStorageDuration()))); + EXPECT_TRUE( + notMatches(T, varDecl(hasName("y"), hasAutomaticStorageDuration()))); + EXPECT_TRUE( + notMatches(T, varDecl(hasName("z"), hasAutomaticStorageDuration()))); + EXPECT_TRUE( + notMatches(T, varDecl(hasName("a"), hasAutomaticStorageDuration()))); + + EXPECT_TRUE(matches(T, varDecl(hasName("y"), hasStaticStorageDuration()))); + EXPECT_TRUE(matches(T, varDecl(hasName("a"), hasStaticStorageDuration()))); + EXPECT_TRUE(notMatches(T, varDecl(hasName("x"), hasStaticStorageDuration()))); + EXPECT_TRUE(notMatches(T, varDecl(hasName("z"), hasStaticStorageDuration()))); + + EXPECT_TRUE(matches(T, varDecl(hasName("z"), hasThreadStorageDuration()))); + EXPECT_TRUE(notMatches(T, varDecl(hasName("x"), hasThreadStorageDuration()))); + EXPECT_TRUE(notMatches(T, varDecl(hasName("y"), hasThreadStorageDuration()))); + EXPECT_TRUE(notMatches(T, varDecl(hasName("a"), hasThreadStorageDuration()))); +} + TEST(Matcher, FindsVarDeclInFunctionParameter) { EXPECT_TRUE(matches( "void f(int i) {}", |