[PATCH] D21453: Add support for attribute "overallocated"
Akira Hatanaka via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 16 16:13:07 PDT 2016
ahatanak created this revision.
ahatanak added reviewers: rsmith, george.burgess.iv, aaron.ballman.
ahatanak added subscribers: cfe-commits, dexonsmith, hfinkel.
This patch adds support for attribute "overallocated", which will be used to indicate a union or struct is over-allocated. This is needed to have __builtin_object_size correctly compute the size of an object when malloc allocates extra space at the end of a struct or union. For example,
struct S {
int a;
char s[32];
};
void *p = malloc(sizeof(S) + 64);
unsigned s = builtin_object_size(((struct S*)p)->s, 1); // "s" should be 32+64=96, not 32.
The link to the relevant discussion on cfe-dev is here:
http://lists.llvm.org/pipermail/cfe-dev/2016-March/047782.html
http://reviews.llvm.org/D21453
Files:
include/clang/Basic/Attr.td
include/clang/Basic/AttrDocs.td
lib/AST/ExprConstant.cpp
lib/Sema/SemaDeclAttr.cpp
test/CodeGen/object-size.c
test/CodeGen/object-size.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21453.61047.patch
Type: text/x-patch
Size: 7052 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160616/ced63b9e/attachment.bin>
More information about the cfe-commits
mailing list