[PATCH] D21453: Add support for attribute "overallocated"

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 17 18:49:10 PDT 2016


ahatanak added inline comments.

================
Comment at: include/clang/Basic/AttrDocs.td:2073-2079
@@ +2072,9 @@
+  let Content = [{
+Use ``overallocated`` to indicate a struct or union is over-allocated. For example,
+
+.. code-block:: c++
+
+struct S {
+  char a[4], char b[4];
+} __attribute__((overallocated));
+
----------------
I intended overallocated to mean there might be extra memory at the end of a struct or union regardless of whether or not the last member is an array. This seemed more useful than restricting it to structs with array members as was discussed in the cfe-dev thread. For example, Hal mentioned that we might have caught the bugs you fixed in r262891 had we used this attribute on over-allocated classes.

Does this sound reasonable to you or do you see any problem with this approach? Alternatively, we can use an attribute (variable_length_array or gcc's bnd_variable_size) that will be attached to the array, which is good enough for the use case we care about (we want __builtin_object_size to return an exact or a conservative value for struct sockaddr_un that was mentioned in the thread).


http://reviews.llvm.org/D21453





More information about the cfe-commits mailing list