diff options
author | Anders Waldenborg <anders@0x63.nu> | 2023-02-12 22:12:08 +0100 |
---|---|---|
committer | Anders Waldenborg <anders@0x63.nu> | 2023-03-13 16:47:51 +0100 |
commit | 1285a495d5886b99f8d193c90b258a56f89c8937 (patch) | |
tree | 23297183a3354501a372ced5f63169e24eb502f6 /clang/examples | |
parent | 8629343a8b6c26f15f02de2fdd8db440eba71937 (diff) | |
download | llvm-1285a495d5886b99f8d193c90b258a56f89c8937.zip llvm-1285a495d5886b99f8d193c90b258a56f89c8937.tar.gz llvm-1285a495d5886b99f8d193c90b258a56f89c8937.tar.bz2 |
[clang][pp] Handle attributes defined by plugin in __has_attribute
When using attributes by plugins (both in clang and clang-tidy) the
preprocessor functions `__has_attribute`, `__has_c_attribute`,
`__has_cpp_attribute` still returned 0.
That problem is fixed by having the "hasAttribute" function also check
if any of the plugins provide that attribute.
This also adds C2x spelling to the example plugin for attributes so that
`__has_c_attribute` can be tested.
Differential Revision: https://reviews.llvm.org/D144405
Diffstat (limited to 'clang/examples')
-rw-r--r-- | clang/examples/Attribute/Attribute.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/examples/Attribute/Attribute.cpp b/clang/examples/Attribute/Attribute.cpp index 159b09e..24b95dd 100644 --- a/clang/examples/Attribute/Attribute.cpp +++ b/clang/examples/Attribute/Attribute.cpp @@ -9,6 +9,8 @@ // Example clang plugin which adds an an annotation to file-scope declarations // with the 'example' attribute. // +// This plugin is used by clang/test/Frontend/plugin-attribute tests. +// //===----------------------------------------------------------------------===// #include "clang/AST/ASTContext.h" @@ -27,9 +29,10 @@ struct ExampleAttrInfo : public ParsedAttrInfo { // number of arguments. This just illustrates how many arguments a // `ParsedAttrInfo` can hold, we will not use that much in this example. OptArgs = 15; - // GNU-style __attribute__(("example")) and C++-style [[example]] and + // GNU-style __attribute__(("example")) and C++/C2x-style [[example]] and // [[plugin::example]] supported. static constexpr Spelling S[] = {{ParsedAttr::AS_GNU, "example"}, + {ParsedAttr::AS_C2x, "example"}, {ParsedAttr::AS_CXX11, "example"}, {ParsedAttr::AS_CXX11, "plugin::example"}}; Spellings = S; |