diff options
| author | Sam McCall <sam.mccall@gmail.com> | 2020-10-19 23:36:50 +0200 |
|---|---|---|
| committer | Sam McCall <sam.mccall@gmail.com> | 2021-08-06 22:06:04 +0200 |
| commit | a4bdcdadc6ffab250b218bbdae9a0ced05bebfc9 (patch) | |
| tree | 8796291f7d95dde6c57a389655007cd36fa806b2 /clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp | |
| parent | 9ed7416aaf257b13079b48f856df9b45d783fab2 (diff) | |
| download | llvm-a4bdcdadc6ffab250b218bbdae9a0ced05bebfc9.zip llvm-a4bdcdadc6ffab250b218bbdae9a0ced05bebfc9.tar.gz llvm-a4bdcdadc6ffab250b218bbdae9a0ced05bebfc9.tar.bz2 | |
Support Attr in DynTypedNode and ASTMatchers.
Differential Revision: https://reviews.llvm.org/D89743
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp')
| -rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp | 23 |
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())); |
