[clang] [Sema] Don't crash filling TypeLoc for a reused AttributedType (PR #220139)

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 1 17:52:33 PDT 2026


================
@@ -343,7 +343,11 @@ namespace {
         }
       }
 
-      llvm_unreachable("no Attr* for AttributedType*");
+      // The AttributedType can be inherited from another declarator, for
+      // example when __typeof__ reuses a type built for a different
+      // declaration, in which case there is no entry for it in this
+      // TypeProcessingState. Return null in that case.
+      return nullptr;
----------------
ahatanak wrote:

To clarify: I read your second paragraph as suggesting we register an `Attr *` before `fillAttributedTypeLoc()` is called, so that lookup never comes up empty. But the question then becomes which `Attr *` to register. `__typeof__(s->f1)` doesn't create any new `Attr *` of its own, so the only one available is the one on `NullabilityAtomicTypeofS::f1`, which has the problem I described above.

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


More information about the cfe-commits mailing list