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

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 3 11:13:35 PDT 2024


================
@@ -177,6 +177,26 @@ static bool isLanguageDefinedBuiltin(const SourceManager &SourceMgr,
   return false;
 }
 
+static bool isReservedAttrName(Preprocessor &PP, IdentifierInfo *II) {
----------------
AaronBallman 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`)?

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


More information about the cfe-commits mailing list