[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 26 07:07:10 PDT 2024
================
@@ -177,6 +177,26 @@ static bool isLanguageDefinedBuiltin(const SourceManager &SourceMgr,
return false;
}
+static bool isReservedAttrName(Preprocessor &PP, IdentifierInfo *II) {
+ const LangOptions &Lang = PP.getLangOpts();
+ const StringRef Name = II->getName();
+
+ if (Lang.CPlusPlus26)
+ return Name == "indeterminate";
+ if (Lang.CPlusPlus23)
+ return Name == "assume";
----------------
zwuis wrote:
> It seems that `#define assume` will not trigger diagnostic in C++26.
I mean, control flow will reach line 185 and check if the name is `"indeterminate"` only, not check `"assume"`.
I think it shoule be
```cpp
if (Lang.CPlusPlus26 && Name == "indeterminate")
return true;
```
https://github.com/llvm/llvm-project/pull/106036
More information about the cfe-commits
mailing list