Skip to content
Snippets Groups Projects
  • George Burgess IV's avatar
    aa365cb2
    Add the alloc_size attribute to clang, attempt 2. · aa365cb2
    George Burgess IV authored
    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
    aa365cb2
    History
    Add the alloc_size attribute to clang, attempt 2.
    George Burgess IV authored
    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
Code owners
Assign users and groups as approvers for specific file changes. Learn more.