[PATCH] D14274: Add alloc_size attribute to clang
George Burgess IV via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 2 18:25:02 PST 2015
george.burgess.iv created this revision.
george.burgess.iv added a reviewer: rsmith.
george.burgess.iv added a subscriber: cfe-commits.
This is the first in a two patch series aimed at adding the alloc_size attribute to clang. This patch adds the alloc_size attribute, docs, and all of the logic needed to handle it in ExprConstant. The only thing that's _really_ missing is our ability to handle non-const locals, because that's proving to be a moderately interesting challenge. (Spoiler alert: that's basically the only thing in patch #2)
There's also a restructuring of TryEvaluateBuiltinObjectSize thrown in, because I felt like it was getting overly subtle. Hopefully the new version is considerably easier to reason about. :)
— Implementation notes —
- With the restructuring of TryEvaluateBuiltinObjectSize, I was able to make EM_DesignatorFold (now EM_OffsetFold) the only EvalMode we use in evaluating __builtin_object_size.
- The InvalidBase functionality of LValues was further (ab)used to get information to TryEvaluateBuiltinObjectSize. We know an LValue has been initialized by an alloc_size function if the base is invalid and the base itself is a CallExpr. This won’t conflict with current behavior, because (prior to this patch) all invalid bases were MemberExprs.
- As said in the ExprConstant code, I’d love a less hand-wavy approach to writing tryEvaluateLValueAsAllocSize.
http://reviews.llvm.org/D14274
Files:
include/clang/Basic/Attr.td
include/clang/Basic/AttrDocs.td
include/clang/Basic/DiagnosticSemaKinds.td
lib/AST/ExprConstant.cpp
lib/Sema/SemaDeclAttr.cpp
test/CodeGen/alloc-size.c
test/Sema/alloc-size.c
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14274.39025.patch
Type: text/x-patch
Size: 36075 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151103/1c79ab18/attachment-0001.bin>
More information about the cfe-commits
mailing list