[clang] [Clang] adjust caret placement for the suggested attribute location for enum class (PR #168092)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 14 11:38:48 PST 2025


================
@@ -1100,30 +1100,32 @@ Parser::DeclGroupPtrTy Parser::ParseDeclOrFunctionDefInternal(
   // C99 6.7.2.3p6: Handle "struct-or-union identifier;", "enum { X };"
   // declaration-specifiers init-declarator-list[opt] ';'
   if (Tok.is(tok::semi)) {
-    auto LengthOfTSTToken = [](DeclSpec::TST TKind) {
-      assert(DeclSpec::isDeclRep(TKind));
-      switch(TKind) {
-      case DeclSpec::TST_class:
-        return 5;
-      case DeclSpec::TST_struct:
-        return 6;
-      case DeclSpec::TST_union:
-        return 5;
-      case DeclSpec::TST_enum:
-        return 4;
-      case DeclSpec::TST_interface:
-        return 9;
-      default:
-        llvm_unreachable("we only expect to get the length of the class/struct/union/enum");
+    auto GetAdjustedAttrsLoc = [&]() {
----------------
erichkeane wrote:

the location + if has a little less mental load when reading this?  And I'd hope with the below suggestions this stays pretty small/gets smaller.

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


More information about the cfe-commits mailing list