[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:32 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))
+    // The whole struct is specificed in the __bdos. The calculation of the
+    // whole size of the structure can be done in two ways:
+    //
+    //     1) sizeof(struct S) + count * sizeof(typeof(fam))
+    //     2) offsetof(struct S, fam) + count * sizeof(typeof(fam))
+    //
+    // The first will add any remaining whitespace that might exist after
----------------
efriedma-quic wrote:

```suggestion
    // The first will add additional padding after the end of the array,
```

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


More information about the cfe-commits mailing list