<div dir="ltr">Relanded in r326872. Thanks!</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 6, 2018 at 7:03 PM, Nico Weber <span dir="ltr"><<a href="mailto:thakis@chromium.org" target="_blank">thakis@chromium.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">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.</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 6, 2018 at 2:42 AM, George Burgess IV via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: gbiv<br>
Date: Mon Mar  5 23:42:36 2018<br>
New Revision: 326766<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=326766&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=326766&view=rev</a><br>
Log:<br>
[ExprConstant] Look through ExprWithCleanups for `allocsize`<br>
<br>
Modified:<br>
    cfe/trunk/lib/AST/ExprConstant<wbr>.cpp<br>
    cfe/trunk/test/CodeGenCXX/allo<wbr>c-size.cpp<br>
<br>
Modified: cfe/trunk/lib/AST/ExprConstant<wbr>.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=326766&r1=326765&r2=326766&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/AST/ExprCo<wbr>nstant.cpp?rev=326766&r1=<wbr>326765&r2=326766&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/AST/ExprConstant<wbr>.cpp (original)<br>
+++ cfe/trunk/lib/AST/ExprConstant<wbr>.cpp Mon Mar  5 23:42:36 2018<br>
@@ -133,7 +133,11 @@ namespace {<br>
<br>
     E = E->IgnoreParens();<br>
     // If we're doing a variable assignment from e.g. malloc(N), there will<br>
-    // probably be a cast of some kind. Ignore it.<br>
+    // probably be a cast of some kind. In exotic cases, we might also see a<br>
+    // top-level ExprWithCleanups. Ignore them either way.<br>
+    if (const auto *EC = dyn_cast<ExprWithCleanups>(E))<br>
+      E = EC->getSubExpr()->IgnoreParens<wbr>();<br>
+<br>
     if (const auto *Cast = dyn_cast<CastExpr>(E))<br>
       E = Cast->getSubExpr()->IgnorePare<wbr>ns();<br>
<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/allo<wbr>c-size.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/alloc-size.cpp?rev=326766&r1=326765&r2=326766&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/CodeGenCX<wbr>X/alloc-size.cpp?rev=326766&<wbr>r1=326765&r2=326766&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/CodeGenCXX/allo<wbr>c-size.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/allo<wbr>c-size.cpp Mon Mar  5 23:42:36 2018<br>
@@ -88,3 +88,15 @@ int callMemberCalloc() {<br>
   // CHECK: ret i32 32<br>
   return __builtin_object_size(C().my_c<wbr>alloc(16, 2), 0);<br>
 }<br>
+<br>
+struct D {<br>
+  ~D();<br>
+  void *my_malloc(int N) __attribute__((alloc_size(2)))<wbr>;<br>
+};<br>
+<br>
+// CHECK-LABEL: define i32 @_Z20callExprWithCleanupsv<br>
+int callExprWithCleanups() {<br>
+  int *const p = (int *)D().my_malloc(3);<br>
+  // CHECK: ret i32 3<br>
+  return __builtin_object_size(p, 0);<br>
+}<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>