[clang] [Clang][Sema] Support 'counted_by' attribute on FAM/pointers in anonymous unions (PR #171996)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 9 12:16:10 PST 2026


================
@@ -207,10 +234,17 @@ bool Sema::CheckCountedByAttrOnField(FieldDecl *FD, Expr *E, bool CountInBytes,
     return true;
   }
 
+  // Reject if both FD and CountFD are in the same union - they share storage.
+  if (FD->getParent() == CountFD->getParent() && FD->getParent()->isUnion()) {
----------------
ojhunt wrote:

I was looking at this and thinking "this seems like a long line, is it correct" and I realised it would be nice if GH could be configured to show column rulers. Then I remembered just how absolutely atrocious GH performance is already :D

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


More information about the cfe-commits mailing list