[PATCH] D55212: Handle alloc_size attribute on function pointers
Alexander Richardson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 3 04:49:32 PST 2018
arichardson created this revision.
arichardson added reviewers: george.burgess.iv, aaron.ballman, jdenny.
Herald added a subscriber: cfe-commits.
I have been trying to statically find and analyze all calls to heap
allocation functions to determine how many of them use sizes known at
compile time vs only at runtime. While doing so I saw that quite a few
projects use replaceable function pointers for heap allocation and noticed
that clang was not able to annotate functions pointers with alloc_size.
I have changed the Sema checks to allow alloc_size on all function pointers
and typedefs for function pointers now and added checks that these
attributes are propagated to the LLVM IR correctly.
With this patch we can also compute __builtin_object_size() for calls to
allocation function pointers with the alloc_size attribute.
Repository:
rC Clang
https://reviews.llvm.org/D55212
Files:
include/clang/Basic/Attr.td
lib/AST/ExprConstant.cpp
lib/Sema/SemaDecl.cpp
lib/Sema/SemaDeclAttr.cpp
test/CodeGen/alloc-size-fnptr.c
test/CodeGen/alloc-size.c
test/Sema/alloc-size.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55212.176366.patch
Type: text/x-patch
Size: 16802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181203/29a3be77/attachment-0001.bin>
More information about the cfe-commits
mailing list