<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 12, 2014 at 2:40 PM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.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"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Wed, Nov 12, 2014 at 2:18 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@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"><div class="gmail_extra"><div class="gmail_quote"><span>On Wed, Nov 12, 2014 at 10:58 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.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"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 11, 2014 at 8:19 PM, Richard Trieu <span dir="ltr"><<a href="mailto:rtrieu@google.com" target="_blank">rtrieu@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rtrieu<br>
Date: Tue Nov 11 22:19:57 2014<br>
New Revision: 221769<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221769&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=221769&view=rev</a><br>
Log:<br>
delete => delete[] for arrays.<br></blockquote><div><br></div><div>We could probably just replace all these news and deletes with unique_ptr<T> and unique_ptr<T[]>?</div><div> </div></div></div></div></blockquote></span><div>Possibly, but it also seems reasonable that tests for the sanitizers wanted to directly access memory as opposed to going through a unique_ptr.  For instance, the asan test is set up to get the line of the memory access, which would not work if the access happened in a unique_ptr method.  </div></div></div></div></blockquote></span><div><br>Fair - though I think the memory access would actually still be in the test, rather than in unique_ptr - even if you use unique_ptr's operator*, it'll return (at the machine level) a pointer, which will be dereferenced in the caller. (if not, and that particular memory access location is desired, it could still be written using unique_ptr::get) </div><div><br>Alexey - any ideas if these can reasonably moved to unique_ptr?<br></div></div></div></div></blockquote><div><br></div><div>Yeah, I agree that we'd still be able to get correct source code locations with std::unique_ptr, but I don't think we should add it here. Direct access to array elements (i.e. x[9]++; instead of (*x)[9]++; or x.get()[9]++) is more readable,</div><div>and we don't have any ownership passing involved or early-exits due to the nature of unit tests.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified:<br>
    compiler-rt/trunk/lib/asan/tests/asan_test.cc<br>
    compiler-rt/trunk/lib/msan/tests/msan_test.cc<br>
<br>
Modified: compiler-rt/trunk/lib/asan/tests/asan_test.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=221769&r1=221768&r2=221769&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/tests/asan_test.cc?rev=221769&r1=221768&r2=221769&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/asan/tests/asan_test.cc (original)<br>
+++ compiler-rt/trunk/lib/asan/tests/asan_test.cc Tue Nov 11 22:19:57 2014<br>
@@ -832,7 +832,7 @@ NOINLINE static int LargeFunction(bool d<br>
   x[18]++;<br>
   x[19]++;<br>
<br>
-  delete x;<br>
+  delete[] x;<br>
   return res;<br>
 }<br>
<br>
<br>
Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=221769&r1=221768&r2=221769&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=221769&r1=221768&r2=221769&view=diff</a><br>
==============================================================================<br>
--- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)<br>
+++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Tue Nov 11 22:19:57 2014<br>
@@ -570,7 +570,7 @@ TEST(MemorySanitizer, fread) {<br>
   EXPECT_NOT_POISONED(x[16]);<br>
   EXPECT_NOT_POISONED(x[31]);<br>
   fclose(f);<br>
-  delete x;<br>
+  delete[] x;<br>
 }<br>
<br>
 TEST(MemorySanitizer, read) {<br>
@@ -583,7 +583,7 @@ TEST(MemorySanitizer, read) {<br>
   EXPECT_NOT_POISONED(x[16]);<br>
   EXPECT_NOT_POISONED(x[31]);<br>
   close(fd);<br>
-  delete x;<br>
+  delete[] x;<br>
 }<br>
<br>
 TEST(MemorySanitizer, pread) {<br>
@@ -596,7 +596,7 @@ TEST(MemorySanitizer, pread) {<br>
   EXPECT_NOT_POISONED(x[16]);<br>
   EXPECT_NOT_POISONED(x[31]);<br>
   close(fd);<br>
-  delete x;<br>
+  delete[] x;<br>
 }<br>
<br>
 TEST(MemorySanitizer, readv) {<br>
@@ -2807,7 +2807,7 @@ TEST(MemorySanitizer, scanf) {<br>
   EXPECT_NOT_POISONED(s[4]);<br>
   EXPECT_NOT_POISONED(s[5]);<br>
   EXPECT_POISONED(s[6]);<br>
-  delete s;<br>
+  delete[] s;<br>
   delete d;<br>
 }<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div></div></div><br></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Alexey Samsonov<br><a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a></div></div>
</div></div>