[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 3 11:26:40 PDT 2024


================
@@ -177,6 +177,26 @@ static bool isLanguageDefinedBuiltin(const SourceManager &SourceMgr,
   return false;
 }
 
+static bool isReservedAttrName(Preprocessor &PP, IdentifierInfo *II) {
----------------
erichkeane wrote:

> Because we don't support any non-standard attributes without a vendor namespace (e.g., we don't support `[[foo]]` as an extension, it needs to have some sort of prefix like `[[gnu::foo]]` or `[[clang::foo]]`), I was thinking we could rely on that.
> 
> However, it might also make sense to just add a bit to the `Spelling` in `Attr.td` to say "this is a standard spelling for the attribute" (which side-steps things like `nodiscard` vs `warn_unused_result`)?

Ah, yeah, we could just check if it has a non-namespaced standard spelling, thats probably more than enough.  An additional bit isn't really necessary at that point (since we effectively already have it).


https://github.com/llvm/llvm-project/pull/106036


More information about the cfe-commits mailing list