[lsan] [aarch64] Fix printing of pointers in make check tests

This patch replaces fprintf with print_address function
in LSAN tests. This is necessary because of different
printing of pointers in fprintf and sanitizer's print
function. Differential Revision: https://reviews.llvm.org/D25270.

llvm-svn: 284722
GitOrigin-RevId: 19610a33c1c95a8d440640e6f9986b08a2bc6869
diff --git a/test/lsan/TestCases/cleanup_in_tsd_destructor.c b/test/lsan/TestCases/cleanup_in_tsd_destructor.c
index debf05c..c43f696 100644
--- a/test/lsan/TestCases/cleanup_in_tsd_destructor.c
+++ b/test/lsan/TestCases/cleanup_in_tsd_destructor.c
@@ -14,6 +14,7 @@
 #include <stdlib.h>
 
 #include "sanitizer/lsan_interface.h"
+#include "../../tsan/test.h"
 
 pthread_key_t key;
 __thread void *p;
@@ -25,7 +26,7 @@
 
 void *thread_func(void *arg) {
   p = malloc(1337);
-  fprintf(stderr, "Test alloc: %p.\n", p);
+  print_address("Test alloc: ", 1, p);
   int res = pthread_setspecific(key, (void*)1);
   assert(res == 0);
   return 0;
@@ -41,5 +42,5 @@
   assert(res == 0);
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: [[ADDR]] (1337 bytes)
diff --git a/test/lsan/TestCases/large_allocation_leak.cc b/test/lsan/TestCases/large_allocation_leak.cc
index f41143a..70b36c9 100644
--- a/test/lsan/TestCases/large_allocation_leak.cc
+++ b/test/lsan/TestCases/large_allocation_leak.cc
@@ -5,14 +5,15 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 int main() {
   // maxsize in primary allocator is always less than this (1 << 25).
   void *large_alloc = malloc(33554432);
-  fprintf(stderr, "Test alloc: %p.\n", large_alloc);
+  print_address("Test alloc: ", 1, large_alloc);
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (33554432 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/pointer_to_self.cc b/test/lsan/TestCases/pointer_to_self.cc
index 63bde2c..5696a65 100644
--- a/test/lsan/TestCases/pointer_to_self.cc
+++ b/test/lsan/TestCases/pointer_to_self.cc
@@ -6,13 +6,14 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 int main() {
   void *p = malloc(1337);
   *reinterpret_cast<void **>(p) = p;
-  fprintf(stderr, "Test alloc: %p.\n", p);
+  print_address("Test alloc: ", 1, p);
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/stale_stack_leak.cc b/test/lsan/TestCases/stale_stack_leak.cc
index 4b8a54e..4bba1f7 100644
--- a/test/lsan/TestCases/stale_stack_leak.cc
+++ b/test/lsan/TestCases/stale_stack_leak.cc
@@ -6,6 +6,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 void **pp;
 
@@ -18,7 +19,7 @@
   void *locals[2048];
   locals[0] = p;
   pp = &locals[0];
-  fprintf(stderr, "Test alloc: %p.\n", locals[0]);
+  print_address("Test alloc: ", 1, locals[0]);
   return 0;
 }
 
@@ -33,11 +34,11 @@
 __attribute__((destructor))
 __attribute__((no_sanitize_address))
 void ConfirmPointerHasSurvived() {
-  fprintf(stderr, "Value after LSan: %p.\n", *pp);
+  print_address("Value after LSan: ", 1, *pp);
 }
-// CHECK: Test alloc: [[ADDR:.*]].
-// CHECK-sanity: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
+// CHECK-sanity: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
-// CHECK-sanity: Value after LSan: [[ADDR]].
+// CHECK-sanity: Value after LSan: [[ADDR]]
diff --git a/test/lsan/TestCases/use_after_return.cc b/test/lsan/TestCases/use_after_return.cc
index eb917c0..903e3e3 100644
--- a/test/lsan/TestCases/use_after_return.cc
+++ b/test/lsan/TestCases/use_after_return.cc
@@ -8,16 +8,17 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 int main() {
   void *stack_var = malloc(1337);
-  fprintf(stderr, "Test alloc: %p.\n", stack_var);
+  print_address("Test alloc: ", 1, stack_var);
   // Take pointer to variable, to ensure it's not optimized into a register.
-  fprintf(stderr, "Stack var at: %p.\n", &stack_var);
+  print_address("Stack var at: ", 1, &stack_var);
   // Do not return from main to prevent the pointer from going out of scope.
   exit(0);
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/use_globals_initialized.cc b/test/lsan/TestCases/use_globals_initialized.cc
index 172d22a..bb2b3f6 100644
--- a/test/lsan/TestCases/use_globals_initialized.cc
+++ b/test/lsan/TestCases/use_globals_initialized.cc
@@ -7,15 +7,16 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 void *data_var = (void *)1;
 
 int main() {
   data_var = malloc(1337);
-  fprintf(stderr, "Test alloc: %p.\n", data_var);
+  print_address("Test alloc: ", 1, data_var);
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/use_globals_uninitialized.cc b/test/lsan/TestCases/use_globals_uninitialized.cc
index 2daa661..46d9f65 100644
--- a/test/lsan/TestCases/use_globals_uninitialized.cc
+++ b/test/lsan/TestCases/use_globals_uninitialized.cc
@@ -7,15 +7,16 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 void *bss_var;
 
 int main() {
   bss_var = malloc(1337);
-  fprintf(stderr, "Test alloc: %p.\n", bss_var);
+  print_address("Test alloc: ", 1, bss_var);
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/use_poisoned_asan.cc b/test/lsan/TestCases/use_poisoned_asan.cc
index a1c544c..c2b7bbc 100644
--- a/test/lsan/TestCases/use_poisoned_asan.cc
+++ b/test/lsan/TestCases/use_poisoned_asan.cc
@@ -9,17 +9,18 @@
 #include <stdlib.h>
 #include <sanitizer/asan_interface.h>
 #include <assert.h>
+#include "../../tsan/test.h"
 
 void **p;
 
 int main() {
   p = new void *;
   *p = malloc(1337);
-  fprintf(stderr, "Test alloc: %p.\n", *p);
+  print_address("Test alloc: ", 1, *p);
   __asan_poison_memory_region(p, sizeof(*p));
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: AddressSanitizer:
diff --git a/test/lsan/TestCases/use_registers.cc b/test/lsan/TestCases/use_registers.cc
index 74301a2..49c3702 100644
--- a/test/lsan/TestCases/use_registers.cc
+++ b/test/lsan/TestCases/use_registers.cc
@@ -10,6 +10,7 @@
 #include <sched.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 extern "C"
 void *registers_thread_func(void *arg) {
@@ -35,7 +36,7 @@
 #else
 #error "Test is not supported on this architecture."
 #endif
-  fprintf(stderr, "Test alloc: %p.\n", p);
+  print_address("Test alloc: ", 1, p);
   fflush(stderr);
   __sync_fetch_and_xor(sync, 1);
   while (true)
@@ -51,7 +52,7 @@
     sched_yield();
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/use_stacks.cc b/test/lsan/TestCases/use_stacks.cc
index 7afcde1..708f352 100644
--- a/test/lsan/TestCases/use_stacks.cc
+++ b/test/lsan/TestCases/use_stacks.cc
@@ -7,14 +7,15 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 int main() {
   void *stack_var = malloc(1337);
-  fprintf(stderr, "Test alloc: %p.\n", stack_var);
+  print_address("Test alloc: ", 1, stack_var);
   // Do not return from main to prevent the pointer from going out of scope.
   exit(0);
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/use_stacks_threaded.cc b/test/lsan/TestCases/use_stacks_threaded.cc
index a1d4383..9effa32 100644
--- a/test/lsan/TestCases/use_stacks_threaded.cc
+++ b/test/lsan/TestCases/use_stacks_threaded.cc
@@ -10,12 +10,13 @@
 #include <sched.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 extern "C"
 void *stacks_thread_func(void *arg) {
   int *sync = reinterpret_cast<int *>(arg);
   void *p = malloc(1337);
-  fprintf(stderr, "Test alloc: %p.\n", p);
+  print_address("Test alloc: ", 1, p);
   fflush(stderr);
   __sync_fetch_and_xor(sync, 1);
   while (true)
@@ -31,7 +32,7 @@
     sched_yield();
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/use_tls_dynamic.cc b/test/lsan/TestCases/use_tls_dynamic.cc
index 207894b..208df11 100644
--- a/test/lsan/TestCases/use_tls_dynamic.cc
+++ b/test/lsan/TestCases/use_tls_dynamic.cc
@@ -12,6 +12,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string>
+#include "../../tsan/test.h"
 
 int main(int argc, char *argv[]) {
   std::string path = std::string(argv[0]) + "-so.so";
@@ -26,10 +27,10 @@
   // If we don't  know about dynamic TLS, we will return a false leak above.
   void **p_in_tls = StoreToTLS(p);
   assert(*p_in_tls == p);
-  fprintf(stderr, "Test alloc: %p.\n", p);
+  print_address("Test alloc: ", 1, p);
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc b/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc
index 1488371..b80c460 100644
--- a/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc
+++ b/test/lsan/TestCases/use_tls_pthread_specific_dynamic.cc
@@ -9,6 +9,7 @@
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 // From glibc: this many keys are stored in the thread descriptor directly.
 const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32;
@@ -28,10 +29,10 @@
   void *p  = malloc(1337);
   res = pthread_setspecific(key, p);
   assert(res == 0);
-  fprintf(stderr, "Test alloc: %p.\n", p);
+  print_address("Test alloc: ", 1, p);
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/use_tls_pthread_specific_static.cc b/test/lsan/TestCases/use_tls_pthread_specific_static.cc
index 1fd5681..2225bf1 100644
--- a/test/lsan/TestCases/use_tls_pthread_specific_static.cc
+++ b/test/lsan/TestCases/use_tls_pthread_specific_static.cc
@@ -9,6 +9,7 @@
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 // From glibc: this many keys are stored in the thread descriptor directly.
 const unsigned PTHREAD_KEY_2NDLEVEL_SIZE = 32;
@@ -22,10 +23,10 @@
   void *p = malloc(1337);
   res = pthread_setspecific(key, p);
   assert(res == 0);
-  fprintf(stderr, "Test alloc: %p.\n", p);
+  print_address("Test alloc: ", 1, p);
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/use_tls_static.cc b/test/lsan/TestCases/use_tls_static.cc
index 50db23a..6f04ba2 100644
--- a/test/lsan/TestCases/use_tls_static.cc
+++ b/test/lsan/TestCases/use_tls_static.cc
@@ -7,15 +7,16 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include "../../tsan/test.h"
 
 __thread void *tls_var;
 
 int main() {
   tls_var = malloc(1337);
-  fprintf(stderr, "Test alloc: %p.\n", tls_var);
+  print_address("Test alloc: ", 1, tls_var);
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer:
diff --git a/test/lsan/TestCases/use_unaligned.cc b/test/lsan/TestCases/use_unaligned.cc
index 3e43ed4..8ecfa9b 100644
--- a/test/lsan/TestCases/use_unaligned.cc
+++ b/test/lsan/TestCases/use_unaligned.cc
@@ -7,17 +7,18 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "../../tsan/test.h"
 
 void *arr[2];
 
 int main() {
   void *p = malloc(1337);
-  fprintf(stderr, "Test alloc: %p.\n", p);
+  print_address("Test alloc: ", 1, p);
   char *char_arr = (char *)arr;
   memcpy(char_arr + 1, &p, sizeof(p));
   return 0;
 }
-// CHECK: Test alloc: [[ADDR:.*]].
+// CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]]
 // CHECK: LeakSanitizer: detected memory leaks
 // CHECK: [[ADDR]] (1337 bytes)
 // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: