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 | 8e7f00b0eb9aed3fd88ce2fc6a53ddf27efef93b (patch) | |
tree | a4f75060a62fef491cc7745317f2606b215acb1b /clang/unittests | |
parent | 763c4ab32df4b7c139e688c9c727fa9eb0d806a4 (diff) | |
download | bcm5719-llvm-8e7f00b0eb9aed3fd88ce2fc6a53ddf27efef93b.tar.gz bcm5719-llvm-8e7f00b0eb9aed3fd88ce2fc6a53ddf27efef93b.zip |
Re-committing r253473 after hopefully fixing the bot breakage. There was a copy-pasta issue that my local testing did not catch.
llvm-svn: 253481
Diffstat (limited to 'clang/unittests')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index 476a0be2904..6d81bd88b9e 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/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) {}", |