[clang] [Clang] Disable use of the counted_by attribute for whole struct pointers (PR #112636)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 17 13:26:33 PDT 2024


================
@@ -1013,6 +1013,24 @@ CodeGenFunction::emitFlexibleArrayMemberSize(const Expr *E, unsigned Type,
     // Can't find the field referenced by the "counted_by" attribute.
     return nullptr;
 
+  if (isa<DeclRefExpr>(Base))
----------------
efriedma-quic wrote:

I'm not sure this reliably detects a "whole struct"?  It's not clear to me why we want to treat `int f(struct X*p) { return __builtin_dynamic_object_size(p, 0); }` differently from `int f2(struct X**p) { return __builtin_dynamic_object_size(*p, 0); }` here.

Maybe this is fine if other parts of the code detect "whole struct" the same way, though.

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


More information about the cfe-commits mailing list