Add the alloc_size attribute to clang, attempt 2.
This is a recommit of r290149, which was reverted in r290169 due to msan failures. msan was failing because we were calling `isMostDerivedAnUnsizedArray` on an invalid designator, which caused us to read uninitialized memory. To fix this, the logic of the caller of said function was simplified, and we now have a `!Invalid` assert in `isMostDerivedAnUnsizedArray`, so we can catch this particular bug more easily in the future. Fingers crossed that this patch sticks this time. :) Original commit message: This patch does three things: - Gives us the alloc_size attribute in clang, which lets us infer the number of bytes handed back to us by malloc/realloc/calloc/any user functions that act in a similar manner. - Teaches our constexpr evaluator that evaluating some `const` variables is OK sometimes. This is why we have a change in test/SemaCXX/constant-expression-cxx11.cpp and other seemingly unrelated tests. Richard Smith okay'ed this idea some time ago in person. - Uniques some Blocks in CodeGen, which was reviewed separately at D26410. Lack of uniquing only really shows up as a problem when combined with our new eagerness in the face of const. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290297 91177308-0d34-0410-b5e6-96231b3b80d8
Showing
- include/clang/Basic/Attr.td 9 additions, 0 deletionsinclude/clang/Basic/Attr.td
- include/clang/Basic/AttrDocs.td 38 additions, 0 deletionsinclude/clang/Basic/AttrDocs.td
- include/clang/Basic/DiagnosticSemaKinds.td 3 additions, 0 deletionsinclude/clang/Basic/DiagnosticSemaKinds.td
- lib/AST/ExprConstant.cpp 433 additions, 183 deletionslib/AST/ExprConstant.cpp
- lib/CodeGen/CGBlocks.cpp 22 additions, 2 deletionslib/CodeGen/CGBlocks.cpp
- lib/CodeGen/CGCall.cpp 8 additions, 0 deletionslib/CodeGen/CGCall.cpp
- lib/CodeGen/CodeGenFunction.h 3 additions, 1 deletionlib/CodeGen/CodeGenFunction.h
- lib/CodeGen/CodeGenModule.h 14 additions, 0 deletionslib/CodeGen/CodeGenModule.h
- lib/Sema/SemaDeclAttr.cpp 88 additions, 0 deletionslib/Sema/SemaDeclAttr.cpp
- test/CodeGen/alloc-size.c 352 additions, 0 deletionstest/CodeGen/alloc-size.c
- test/CodeGenCXX/alloc-size.cpp 72 additions, 0 deletionstest/CodeGenCXX/alloc-size.cpp
- test/CodeGenCXX/block-in-ctor-dtor.cpp 0 additions, 2 deletionstest/CodeGenCXX/block-in-ctor-dtor.cpp
- test/CodeGenCXX/global-init.cpp 0 additions, 3 deletionstest/CodeGenCXX/global-init.cpp
- test/CodeGenOpenCL/cl20-device-side-enqueue.cl 11 additions, 13 deletionstest/CodeGenOpenCL/cl20-device-side-enqueue.cl
- test/Sema/alloc-size.c 23 additions, 0 deletionstest/Sema/alloc-size.c
- test/SemaCXX/constant-expression-cxx11.cpp 2 additions, 2 deletionstest/SemaCXX/constant-expression-cxx11.cpp
Loading
Please register or sign in to comment