[PATCH] D31343: Add an attribute plugin example
John Brawn via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 2 10:21:02 PST 2020
john.brawn marked 2 inline comments as done.
john.brawn added inline comments.
================
Comment at: clang/examples/Attribute/Attribute.cpp:35
+ Spellings.push_back({ParsedAttr::AS_GNU, "example"});
+ Spellings.push_back({ParsedAttr::AS_CXX11, "::example"});
+ Spellings.push_back({ParsedAttr::AS_CXX11, "plugin::example"});
----------------
aaron.ballman wrote:
> This is not a valid spelling for an attribute (we should probably assert that an attribute-scoped-token does not have an empty scope).
"::example" is actually how an unscoped spelling is specified - normalizeName in Basic/Attributes.cpp adds a "::" to the start if there's no scope, and the tablegen-generated getAttrKind expects it as well.
================
Comment at: clang/examples/Attribute/Attribute.cpp:42
+ // This attribute appertains to functions only.
+ if (!D || !isa<FunctionDecl>(D)) {
+ S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type_str)
----------------
aaron.ballman wrote:
> I don't think `D` can ever be null, can it?
I don't know, but this is how the auto-generated diagAppertainsToDecl functions do it.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D31343/new/
https://reviews.llvm.org/D31343
More information about the cfe-commits
mailing list