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

Oleksandr T. via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 17 12:25:56 PST 2025


================
@@ -179,13 +179,15 @@ static bool isLanguageDefinedBuiltin(const SourceManager &SourceMgr,
 static bool isReservedCXXAttributeName(Preprocessor &PP, IdentifierInfo *II) {
   const LangOptions &Lang = PP.getLangOpts();
   if (Lang.CPlusPlus &&
-      hasAttribute(AttributeCommonInfo::Syntax::AS_CXX11, /*Scope*/ nullptr, II,
-                   PP.getTargetInfo(), Lang) > 0) {
-    AttributeCommonInfo::Kind AttrKind = AttributeCommonInfo::getParsedKind(
-        II, /*Scope*/ nullptr, AttributeCommonInfo::Syntax::AS_CXX11);
-    return !((AttrKind == AttributeCommonInfo::Kind::AT_Likely ||
-              AttrKind == AttributeCommonInfo::Kind::AT_Unlikely) &&
-             PP.isNextPPTokenLParen());
+      hasAttribute(AttributeCommonInfo::AS_CXX11, /* Scope*/ nullptr, II,
+                   PP.getTargetInfo(), Lang, /*CheckPlugins*/ false) > 0) {
+    AttributeCommonInfo::AttrArgsInfo AttrArgsInfo =
+        AttributeCommonInfo::getCXX11AttrArgsInfo(II);
+    if (AttrArgsInfo == AttributeCommonInfo::AttrArgsInfo::Required)
----------------
a-tarasyuk wrote:

Yes. I added attribute arg information to eliminate the need for additional logic to define how certain attributes should behave. For the new attributes, everything will work based on the TG information, with no additional logic needed.


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


More information about the llvm-commits mailing list