[all-commits] [llvm/llvm-project] 2a74b2: [Basic] Fix crash computing the spelling index of ...

Vassil Vassilev via All-commits all-commits at lists.llvm.org
Mon Jul 13 08:32:12 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2a74b20bb612c3f6695f30eb3648da33bfcf10a3
      https://github.com/llvm/llvm-project/commit/2a74b20bb612c3f6695f30eb3648da33bfcf10a3
  Author: Vassil Vassilev <v.g.vassilev at gmail.com>
  Date:   2026-07-13 (Mon, 13 Jul 2026)

  Changed paths:
    M clang/lib/Basic/Attributes.cpp
    M clang/unittests/AST/AttrTest.cpp

  Log Message:
  -----------
  [Basic] Fix crash computing the spelling index of an unknown scoped attribute (#208909)

AttributeCommonInfo::getAttributeSpellingListIndex() aborts for an
unknown attribute that has a scope, such as [[ns::foo]]. It calls
calculateAttributeSpellingListIndex(), which runs name/scope
string-switches generated for the known attributes. Those switches
intentionally have no default: getScopeFromNormalizedScopeName() falls
off the end and hits llvm_unreachable ("Fell off the end of a
string-switch") for the unknown scope.

Any caller that asks a scoped unknown attribute for its spelling index
therefore crashes. An unrecognized attribute has no entry in those
tables and carries a single no-spelling, so short-circuit
calculateAttributeSpellingListIndex() for UnknownAttribute and return
index 0 before the switches run.

Add a unit test that constructs an unknown scoped AttributeCommonInfo
and asks for its spelling index; it aborts without the fix.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list