[clang] [Clang] add typo correction for unknown attribute names (PR #140629)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Tue May 20 10:04:16 PDT 2025


================
@@ -203,10 +221,47 @@ unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex() const {
   // attribute spell list index matching code.
   auto Syntax = static_cast<AttributeCommonInfo::Syntax>(getSyntax());
   StringRef ScopeName = normalizeAttrScopeName(getScopeName(), Syntax);
-  StringRef Name = normalizeAttrName(getAttrName(), ScopeName, Syntax);
-
+  StringRef Name =
+      normalizeAttrName(getAttrName()->getName(), ScopeName, Syntax);
   AttributeCommonInfo::Scope ComputedScope =
       getScopeFromNormalizedScopeName(ScopeName);
 
 #include "clang/Sema/AttrSpellingListIndex.inc"
 }
+
+#include "clang/Basic/AttributeSpellingList.inc"
----------------
AaronBallman wrote:

It's hard to understand what's going on here because the tablegen hides the fact that this is introducing new declarations. I think a more general approach would be:
```
#define NAME(X) X
static constexpr const char *AttrSpellingList[] = {
#include "clang/Basic/AttributeSpellingList.inc"
};
#undef NAME

#define SCOPE(X) X
static constexpr const char *AttrScopeSpellingList[] = {
#include "clang/Basic/AttributeSpellingList.inc"
};
#undef SCOPE
```
WDYT?

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


More information about the cfe-commits mailing list