r326766 - [ExprConstant] Look through ExprWithCleanups for `allocsize`

George Burgess IV via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 6 20:55:22 PST 2018


Relanded in r326872. Thanks!

On Tue, Mar 6, 2018 at 7:03 PM, Nico Weber <thakis at chromium.org> wrote:

> Apologies, I had to revert the change that touched alloc-size.cpp before
> this change in r326862. After that revert, your new test here failed, and
> since I didn't understand how to make it passed, I reverted your change
> in 326869 too. It should hopefully be easy for you to reland it.
>
> On Tue, Mar 6, 2018 at 2:42 AM, George Burgess IV via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: gbiv
>> Date: Mon Mar  5 23:42:36 2018
>> New Revision: 326766
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=326766&view=rev
>> Log:
>> [ExprConstant] Look through ExprWithCleanups for `allocsize`
>>
>> Modified:
>>     cfe/trunk/lib/AST/ExprConstant.cpp
>>     cfe/trunk/test/CodeGenCXX/alloc-size.cpp
>>
>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCo
>> nstant.cpp?rev=326766&r1=326765&r2=326766&view=diff
>> ============================================================
>> ==================
>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Mar  5 23:42:36 2018
>> @@ -133,7 +133,11 @@ namespace {
>>
>>      E = E->IgnoreParens();
>>      // If we're doing a variable assignment from e.g. malloc(N), there
>> will
>> -    // probably be a cast of some kind. Ignore it.
>> +    // probably be a cast of some kind. In exotic cases, we might also
>> see a
>> +    // top-level ExprWithCleanups. Ignore them either way.
>> +    if (const auto *EC = dyn_cast<ExprWithCleanups>(E))
>> +      E = EC->getSubExpr()->IgnoreParens();
>> +
>>      if (const auto *Cast = dyn_cast<CastExpr>(E))
>>        E = Cast->getSubExpr()->IgnoreParens();
>>
>>
>> Modified: cfe/trunk/test/CodeGenCXX/alloc-size.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCX
>> X/alloc-size.cpp?rev=326766&r1=326765&r2=326766&view=diff
>> ============================================================
>> ==================
>> --- cfe/trunk/test/CodeGenCXX/alloc-size.cpp (original)
>> +++ cfe/trunk/test/CodeGenCXX/alloc-size.cpp Mon Mar  5 23:42:36 2018
>> @@ -88,3 +88,15 @@ int callMemberCalloc() {
>>    // CHECK: ret i32 32
>>    return __builtin_object_size(C().my_calloc(16, 2), 0);
>>  }
>> +
>> +struct D {
>> +  ~D();
>> +  void *my_malloc(int N) __attribute__((alloc_size(2)));
>> +};
>> +
>> +// CHECK-LABEL: define i32 @_Z20callExprWithCleanupsv
>> +int callExprWithCleanups() {
>> +  int *const p = (int *)D().my_malloc(3);
>> +  // CHECK: ret i32 3
>> +  return __builtin_object_size(p, 0);
>> +}
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180306/12e62465/attachment.html>


More information about the cfe-commits mailing list