[compiler-rt] r190139 - [ASan] make the check for NULL more portable.

Alexander Potapenko glider at google.com
Fri Sep 6 05:04:37 PDT 2013


Author: glider
Date: Fri Sep  6 07:04:37 2013
New Revision: 190139

URL: http://llvm.org/viewvc/llvm-project?rev=190139&view=rev
Log:
[ASan] make the check for NULL more portable.


Modified:
    compiler-rt/trunk/lib/asan/lit_tests/TestCases/allocator_returns_null.cc

Modified: compiler-rt/trunk/lib/asan/lit_tests/TestCases/allocator_returns_null.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/TestCases/allocator_returns_null.cc?rev=190139&r1=190138&r2=190139&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/TestCases/allocator_returns_null.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/TestCases/allocator_returns_null.cc Fri Sep  6 07:04:37 2013
@@ -53,7 +53,9 @@ int main(int argc, char **argv) {
     x = (char*)realloc(t, size);
     assert(*t == 42);
   }
-  fprintf(stderr, "x: %p\n", x);
+  // The NULL pointer is printed differently on different systems, while (long)0
+  // is always the same.
+  fprintf(stderr, "x: %lx\n", (long)x);
   return x != 0;
 }
 // CHECK-mCRASH: malloc:
@@ -68,12 +70,12 @@ int main(int argc, char **argv) {
 // CHECK-mrCRASH: AddressSanitizer's allocator is terminating the process
 
 // CHECK-mNULL: malloc:
-// CHECK-mNULL: x: (nil)
+// CHECK-mNULL: x: 0
 // CHECK-cNULL: calloc:
-// CHECK-cNULL: x: (nil)
+// CHECK-cNULL: x: 0
 // CHECK-coNULL: calloc-overflow:
-// CHECK-coNULL: x: (nil)
+// CHECK-coNULL: x: 0
 // CHECK-rNULL: realloc:
-// CHECK-rNULL: x: (nil)
+// CHECK-rNULL: x: 0
 // CHECK-mrNULL: realloc-after-malloc:
-// CHECK-mrNULL: x: (nil)
+// CHECK-mrNULL: x: 0





More information about the llvm-commits mailing list