<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Sep 19, 2014 at 11:09 AM, Kostya Serebryany <span dir="ltr"><<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</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">Richard, <div>When using <span style="font-size:13px;font-family:arial,sans-serif">expr->getOperatorNew()-></span><span style="font-size:13px;font-family:arial,sans-serif">isReplaceableGlobalAllocationF</span><span style="font-size:13px;font-family:arial,sans-serif">unction() we don't handle operator new defined inside a class (see below). </span></div><div><span style="font-size:13px;font-family:arial,sans-serif">Using </span><span style="font-size:13px;font-family:arial,sans-serif"> </span><span style="font-size:13px;font-family:arial,sans-serif">expr->getNumPlacementArgs() == 0 fixes that but breaks </span><span style="font-size:13px;font-family:arial,sans-serif">new (std::nothrow) X[n]. </span><br></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div><span style="font-family:arial,sans-serif;font-size:13px">Would you suggest another check that will include all non-placement operator new cases? </span></div></div></blockquote><div><br></div><div>(Discussed offline. For posterity:)</div><div><br></div><div>Applying this check to class-specific operator new[] doesn't seem correct in general; the class might in principle track values it has returned from ::operator new[] and provide access to / recycle them by some mechanism other than calling ::operator delete[].</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><font face="arial, sans-serif">#include <new></font></div><div><font face="arial, sans-serif">#include <stdlib.h></font></div><div><font face="arial, sans-serif">class Foo {</font></div><div><font face="arial, sans-serif"> public:</font></div><div><font face="arial, sans-serif">#ifdef OPN</font></div><div><font face="arial, sans-serif"> void *operator new(size_t s);</font></div><div><font face="arial, sans-serif"> void *operator new[] (size_t s);</font></div><div><font face="arial, sans-serif">#endif</font></div><div><font face="arial, sans-serif"> ~Foo();</font></div><div><font face="arial, sans-serif">};</font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">Foo *getFoo(size_t s) {</font></div><div><font face="arial, sans-serif"> return new Foo[s];</font></div><div><font face="arial, sans-serif">}</font></div><div style="font-family:arial,sans-serif;font-size:13px"><br></div></div><div><span style="font-family:arial,sans-serif;font-size:13px"> </span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 25, 2014 at 6:33 PM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">LGTM<br>
<br>
<a href="http://reviews.llvm.org/D4774" target="_blank">http://reviews.llvm.org/D4774</a><br>
<br>
<br>
</blockquote></div><br></div>
</blockquote></div><br></div></div>