aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index c24598d..6fb4372 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -1885,6 +1885,29 @@ TEST_P(ASTMatchersTest, NestedNameSpecifier) {
nestedNameSpecifier()));
}
+TEST_P(ASTMatchersTest, Attr) {
+ // Windows adds some implicit attributes.
+ bool AutomaticAttributes = StringRef(GetParam().Target).contains("win32");
+ if (GetParam().isCXX11OrLater()) {
+ EXPECT_TRUE(matches("struct [[clang::warn_unused_result]] F{};", attr()));
+
+ // Unknown attributes are not parsed into an AST node.
+ if (!AutomaticAttributes)
+ EXPECT_TRUE(notMatches("int x [[unknownattr]];", attr()));
+ }
+ }
+ if (GetParam().isCXX17OrLater()) {
+ EXPECT_TRUE(matches("struct [[nodiscard]] F{};", attr()));
+ }
+ EXPECT_TRUE(matches("int x(int * __attribute__((nonnull)) );", attr()));
+ if (!AutomaticAttributes) {
+ EXPECT_TRUE(notMatches("struct F{}; int x(int *);", attr()));
+ // Some known attributes are not parsed into an AST node.
+ EXPECT_TRUE(notMatches("typedef int x __attribute__((ext_vector_type(1)));",
+ attr()));
+ }
+}
+
TEST_P(ASTMatchersTest, NullStmt) {
EXPECT_TRUE(matches("void f() {int i;;}", nullStmt()));
EXPECT_TRUE(notMatches("void f() {int i;}", nullStmt()));