[compiler-rt] 1eb78a6 - [NFC][scudo] Clang-format tests

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon May 17 12:31:18 PDT 2021


Author: Vitaly Buka
Date: 2021-05-17T12:31:09-07:00
New Revision: 1eb78a64c4a5d3febd1799643e0d0aa7151d52bf

URL: https://github.com/llvm/llvm-project/commit/1eb78a64c4a5d3febd1799643e0d0aa7151d52bf
DIFF: https://github.com/llvm/llvm-project/commit/1eb78a64c4a5d3febd1799643e0d0aa7151d52bf.diff

LOG: [NFC][scudo] Clang-format tests

Added: 
    

Modified: 
    compiler-rt/test/scudo/aligned-new.cpp
    compiler-rt/test/scudo/alignment.c
    compiler-rt/test/scudo/dealloc-race.c
    compiler-rt/test/scudo/double-free.cpp
    compiler-rt/test/scudo/interface.cpp
    compiler-rt/test/scudo/malloc.cpp
    compiler-rt/test/scudo/memalign.c
    compiler-rt/test/scudo/mismatch.cpp
    compiler-rt/test/scudo/options.cpp
    compiler-rt/test/scudo/overflow.c
    compiler-rt/test/scudo/preinit.c
    compiler-rt/test/scudo/quarantine.c
    compiler-rt/test/scudo/random_shuffle.cpp
    compiler-rt/test/scudo/realloc.cpp
    compiler-rt/test/scudo/rss.c
    compiler-rt/test/scudo/secondary.c
    compiler-rt/test/scudo/sized-delete.cpp
    compiler-rt/test/scudo/stats.c
    compiler-rt/test/scudo/threads.c
    compiler-rt/test/scudo/tsd_destruction.c
    compiler-rt/test/scudo/valloc.c

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/scudo/aligned-new.cpp b/compiler-rt/test/scudo/aligned-new.cpp
index 0a10ae188c922..771dd3b828971 100644
--- a/compiler-rt/test/scudo/aligned-new.cpp
+++ b/compiler-rt/test/scudo/aligned-new.cpp
@@ -8,8 +8,8 @@
 // so this just tests that the APIs work.
 
 #include <assert.h>
-#include <stdio.h>
 #include <stdint.h>
+#include <stdio.h>
 #include <string.h>
 
 // Define all new/delete to not depend on the version provided by the platform.
@@ -18,41 +18,54 @@ namespace std {
 struct nothrow_t {};
 static const nothrow_t nothrow;
 enum class align_val_t : size_t {};
-}  // namespace std
+} // namespace std
 
 void *operator new(size_t);
 void *operator new[](size_t);
-void *operator new(size_t, std::nothrow_t const&);
-void *operator new[](size_t, std::nothrow_t const&);
+void *operator new(size_t, std::nothrow_t const &);
+void *operator new[](size_t, std::nothrow_t const &);
 void *operator new(size_t, std::align_val_t);
 void *operator new[](size_t, std::align_val_t);
-void *operator new(size_t, std::align_val_t, std::nothrow_t const&);
-void *operator new[](size_t, std::align_val_t, std::nothrow_t const&);
+void *operator new(size_t, std::align_val_t, std::nothrow_t const &);
+void *operator new[](size_t, std::align_val_t, std::nothrow_t const &);
 
-void operator delete(void*) throw();
-void operator delete[](void*) throw();
-void operator delete(void*, std::nothrow_t const&);
-void operator delete[](void*, std::nothrow_t const&);
-void operator delete(void*, size_t) throw();
-void operator delete[](void*, size_t) throw();
-void operator delete(void*, std::align_val_t) throw();
-void operator delete[](void*, std::align_val_t) throw();
-void operator delete(void*, std::align_val_t, std::nothrow_t const&);
-void operator delete[](void*, std::align_val_t, std::nothrow_t const&);
-void operator delete(void*, size_t, std::align_val_t) throw();
-void operator delete[](void*, size_t, std::align_val_t) throw();
+void operator delete(void *) throw();
+void operator delete[](void *) throw();
+void operator delete(void *, std::nothrow_t const &);
+void operator delete[](void *, std::nothrow_t const &);
+void operator delete(void *, size_t) throw();
+void operator delete[](void *, size_t) throw();
+void operator delete(void *, std::align_val_t) throw();
+void operator delete[](void *, std::align_val_t) throw();
+void operator delete(void *, std::align_val_t, std::nothrow_t const &);
+void operator delete[](void *, std::align_val_t, std::nothrow_t const &);
+void operator delete(void *, size_t, std::align_val_t) throw();
+void operator delete[](void *, size_t, std::align_val_t) throw();
 
-template<typename T>
-inline T* break_optimization(T *arg) {
-  __asm__ __volatile__("" : : "r" (arg) : "memory");
+template <typename T>
+inline T *break_optimization(T *arg) {
+  __asm__ __volatile__(""
+                       :
+                       : "r"(arg)
+                       : "memory");
   return arg;
 }
 
-struct S12 { int a, b, c; };
-struct alignas(128) S12_128 { int a, b, c; };
-struct alignas(256) S12_256 { int a, b, c; };
-struct alignas(512) S1024_512 { char a[1024]; };
-struct alignas(1024) S1024_1024 { char a[1024]; };
+struct S12 {
+  int a, b, c;
+};
+struct alignas(128) S12_128 {
+  int a, b, c;
+};
+struct alignas(256) S12_256 {
+  int a, b, c;
+};
+struct alignas(512) S1024_512 {
+  char a[1024];
+};
+struct alignas(1024) S1024_1024 {
+  char a[1024];
+};
 
 int main(int argc, char **argv) {
   assert(argc == 2);

diff  --git a/compiler-rt/test/scudo/alignment.c b/compiler-rt/test/scudo/alignment.c
index 4e2dc1af03b14..f5cc4f0299e48 100644
--- a/compiler-rt/test/scudo/alignment.c
+++ b/compiler-rt/test/scudo/alignment.c
@@ -9,8 +9,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   assert(argc == 2);
   if (!strcmp(argv[1], "pointers")) {
     void *p = malloc(1U << 16);

diff  --git a/compiler-rt/test/scudo/dealloc-race.c b/compiler-rt/test/scudo/dealloc-race.c
index 326e22f27373a..cfac8f912692e 100644
--- a/compiler-rt/test/scudo/dealloc-race.c
+++ b/compiler-rt/test/scudo/dealloc-race.c
@@ -13,9 +13,9 @@
 
 #include <pthread.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
+#include <unistd.h>
 
 const int kNumThreads = 2;
 pthread_t tid[kNumThreads];
@@ -47,7 +47,7 @@ void child(void) {
     pthread_join(tid[i], 0);
 }
 
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
   const int kChildren = 40;
   pid_t pid;
   for (int i = 0; i < kChildren; ++i) {

diff  --git a/compiler-rt/test/scudo/double-free.cpp b/compiler-rt/test/scudo/double-free.cpp
index de6c90f1cced1..ce6ef5119ec47 100644
--- a/compiler-rt/test/scudo/double-free.cpp
+++ b/compiler-rt/test/scudo/double-free.cpp
@@ -10,8 +10,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   assert(argc == 2);
   if (!strcmp(argv[1], "malloc")) {
     void *p = malloc(sizeof(int));

diff  --git a/compiler-rt/test/scudo/interface.cpp b/compiler-rt/test/scudo/interface.cpp
index ec7375193e12b..a1e9f7d31243c 100644
--- a/compiler-rt/test/scudo/interface.cpp
+++ b/compiler-rt/test/scudo/interface.cpp
@@ -7,8 +7,8 @@
 
 // Tests that the sanitizer interface functions behave appropriately.
 
-#include <stdlib.h>
 #include <assert.h>
+#include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
@@ -17,8 +17,7 @@
 #include <sanitizer/allocator_interface.h>
 #include <sanitizer/scudo_interface.h>
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   assert(argc == 2);
 
   if (!strcmp(argv[1], "ownership")) {
@@ -32,7 +31,7 @@ int main(int argc, char **argv)
     // behave properly on chunks allocated by the Primary and Secondary.
     void *p;
     std::vector<ssize_t> sizes{1, 8, 16, 32, 1024, 32768,
-      1 << 16, 1 << 17, 1 << 20, 1 << 24};
+                               1 << 16, 1 << 17, 1 << 20, 1 << 24};
     for (size_t size : sizes) {
       p = malloc(size);
       assert(p);
@@ -49,7 +48,7 @@ int main(int argc, char **argv)
   if (!strcmp(argv[1], "soft-limit")) {
     // Verifies that setting the soft RSS limit at runtime works as expected.
     std::vector<void *> pointers;
-    size_t size = 1 << 19;  // 512Kb
+    size_t size = 1 << 19; // 512Kb
     for (int i = 0; i < 5; i++) {
       void *p = malloc(size);
       memset(p, 0, size);
@@ -75,7 +74,7 @@ int main(int argc, char **argv)
   if (!strcmp(argv[1], "hard-limit")) {
     // Verifies that setting the hard RSS limit at runtime works as expected.
     std::vector<void *> pointers;
-    size_t size = 1 << 19;  // 512Kb
+    size_t size = 1 << 19; // 512Kb
     for (int i = 0; i < 5; i++) {
       void *p = malloc(size);
       memset(p, 0, size);

diff  --git a/compiler-rt/test/scudo/malloc.cpp b/compiler-rt/test/scudo/malloc.cpp
index 6c6a6c464f29a..afa7ee47c03b3 100644
--- a/compiler-rt/test/scudo/malloc.cpp
+++ b/compiler-rt/test/scudo/malloc.cpp
@@ -11,18 +11,17 @@
 
 #include <vector>
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   void *p;
   std::vector<ssize_t> sizes{1, 8, 16, 32, 1024, 32768,
-    1 << 16, 1 << 17, 1 << 20, 1 << 24};
+                             1 << 16, 1 << 17, 1 << 20, 1 << 24};
   std::vector<int> offsets{1, 0, -1, -7, -8, -15, -16, -31, -32};
 
   p = malloc(0);
   assert(p);
   free(p);
   for (ssize_t size : sizes) {
-    for (int offset: offsets) {
+    for (int offset : offsets) {
       ssize_t actual_size = size + offset;
       if (actual_size <= 0)
         continue;

diff  --git a/compiler-rt/test/scudo/memalign.c b/compiler-rt/test/scudo/memalign.c
index 675f534151938..8c6cdf612c23c 100644
--- a/compiler-rt/test/scudo/memalign.c
+++ b/compiler-rt/test/scudo/memalign.c
@@ -20,8 +20,7 @@
 // Sometimes the headers may not have this...
 void *aligned_alloc(size_t alignment, size_t size);
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   void *p = NULL;
   size_t alignment = 1U << 12;
   size_t size = 1U << 12;

diff  --git a/compiler-rt/test/scudo/mismatch.cpp b/compiler-rt/test/scudo/mismatch.cpp
index b794f66d8a4ea..73da76c5b43e1 100644
--- a/compiler-rt/test/scudo/mismatch.cpp
+++ b/compiler-rt/test/scudo/mismatch.cpp
@@ -11,8 +11,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   assert(argc == 2);
   if (!strcmp(argv[1], "mallocdel")) {
     int *p = (int *)malloc(16);

diff  --git a/compiler-rt/test/scudo/options.cpp b/compiler-rt/test/scudo/options.cpp
index 605b632413372..5fba18258e098 100644
--- a/compiler-rt/test/scudo/options.cpp
+++ b/compiler-rt/test/scudo/options.cpp
@@ -10,12 +10,11 @@
 #include <malloc.h>
 #include <stdlib.h>
 
-extern "C" const char* __scudo_default_options() {
-  return "DeallocationTypeMismatch=0";  // Defaults to true in scudo_flags.inc.
+extern "C" const char *__scudo_default_options() {
+  return "DeallocationTypeMismatch=0"; // Defaults to true in scudo_flags.inc.
 }
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   int *p = (int *)malloc(16);
   assert(p);
   delete p;

diff  --git a/compiler-rt/test/scudo/overflow.c b/compiler-rt/test/scudo/overflow.c
index c5a58f87f3058..7df9f8ba3534b 100644
--- a/compiler-rt/test/scudo/overflow.c
+++ b/compiler-rt/test/scudo/overflow.c
@@ -8,8 +8,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   ssize_t offset = sizeof(void *) == 8 ? 8 : 0;
 
   assert(argc == 2);

diff  --git a/compiler-rt/test/scudo/preinit.c b/compiler-rt/test/scudo/preinit.c
index 792b2368e37d0..f3aaf42e1d605 100644
--- a/compiler-rt/test/scudo/preinit.c
+++ b/compiler-rt/test/scudo/preinit.c
@@ -25,8 +25,7 @@ void __fini(void) {
     free(global_p);
 }
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   void *p = malloc(1);
   assert(p);
   free(p);
@@ -34,7 +33,5 @@ int main(int argc, char **argv)
   return 0;
 }
 
-__attribute__((section(".preinit_array"), used))
-  void (*__local_preinit)(void) = __init;
-__attribute__((section(".fini_array"), used))
-  void (*__local_fini)(void) = __fini;
+__attribute__((section(".preinit_array"), used)) void (*__local_preinit)(void) = __init;
+__attribute__((section(".fini_array"), used)) void (*__local_fini)(void) = __fini;

diff  --git a/compiler-rt/test/scudo/quarantine.c b/compiler-rt/test/scudo/quarantine.c
index ddbb92005b841..0a59f5256480e 100644
--- a/compiler-rt/test/scudo/quarantine.c
+++ b/compiler-rt/test/scudo/quarantine.c
@@ -18,8 +18,7 @@
 
 #include <sanitizer/allocator_interface.h>
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   void *p, *old_p;
   size_t allocated_bytes, size = 1U << 8, alignment = 1U << 8;
 

diff  --git a/compiler-rt/test/scudo/random_shuffle.cpp b/compiler-rt/test/scudo/random_shuffle.cpp
index b493a292944c3..d48f2c960a16f 100644
--- a/compiler-rt/test/scudo/random_shuffle.cpp
+++ b/compiler-rt/test/scudo/random_shuffle.cpp
@@ -10,8 +10,8 @@
 
 // Tests that the allocator shuffles the chunks before returning to the user.
 
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 int main(int argc, char **argv) {
   int alloc_size = argc == 2 ? atoi(argv[1]) : 100;

diff  --git a/compiler-rt/test/scudo/realloc.cpp b/compiler-rt/test/scudo/realloc.cpp
index 26f6373b918e8..9c4d459df9b0c 100644
--- a/compiler-rt/test/scudo/realloc.cpp
+++ b/compiler-rt/test/scudo/realloc.cpp
@@ -17,8 +17,7 @@
 
 #include <sanitizer/allocator_interface.h>
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   void *p, *old_p;
   // Those sizes will exercise both allocators (Primary & Secondary).
   std::vector<size_t> sizes{1, 16, 1024, 32768, 1 << 16, 1 << 17, 1 << 20};
@@ -34,7 +33,8 @@ int main(int argc, char **argv)
     p = nullptr;
     // Make sure we get a chunk with a usable size actually larger than size.
     do {
-      if (p) free(p);
+      if (p)
+        free(p);
       size += 16;
       p = malloc(size);
       usable_size = __sanitizer_get_allocated_size(p);

diff  --git a/compiler-rt/test/scudo/rss.c b/compiler-rt/test/scudo/rss.c
index 0b76857b9a4d7..7f182b6dd6e5e 100644
--- a/compiler-rt/test/scudo/rss.c
+++ b/compiler-rt/test/scudo/rss.c
@@ -23,7 +23,7 @@
 #include <unistd.h>
 
 static const size_t kNumAllocs = 64;
-static const size_t kAllocSize = 1 << 20;  // 1MB.
+static const size_t kAllocSize = 1 << 20; // 1MB.
 
 static void *allocs[kNumAllocs];
 
@@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
       usleep(100000);
     allocs[i] = malloc(kAllocSize);
     if (allocs[i])
-      memset(allocs[i], 0xff, kAllocSize);  // Dirty the pages.
+      memset(allocs[i], 0xff, kAllocSize); // Dirty the pages.
     else
       returned_null++;
   }

diff  --git a/compiler-rt/test/scudo/secondary.c b/compiler-rt/test/scudo/secondary.c
index b770ca076b707..32bb93b9d5182 100644
--- a/compiler-rt/test/scudo/secondary.c
+++ b/compiler-rt/test/scudo/secondary.c
@@ -20,8 +20,7 @@ void handler(int signo, siginfo_t *info, void *uctx) {
   exit(1);
 }
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   // The size must be large enough to be serviced by the secondary allocator.
   long page_size = sysconf(_SC_PAGESIZE);
   size_t size = (1U << 17) + page_size;

diff  --git a/compiler-rt/test/scudo/sized-delete.cpp b/compiler-rt/test/scudo/sized-delete.cpp
index 81151b0974813..3b2945bea9c42 100644
--- a/compiler-rt/test/scudo/sized-delete.cpp
+++ b/compiler-rt/test/scudo/sized-delete.cpp
@@ -16,8 +16,7 @@
 
 #include <new>
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   assert(argc == 2);
   if (!strcmp(argv[1], "gooddel")) {
     long long *p = new long long;

diff  --git a/compiler-rt/test/scudo/stats.c b/compiler-rt/test/scudo/stats.c
index e7cc78ff0d492..f782754d92705 100644
--- a/compiler-rt/test/scudo/stats.c
+++ b/compiler-rt/test/scudo/stats.c
@@ -11,8 +11,7 @@
 
 #include <sanitizer/scudo_interface.h>
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   free(malloc(1U));
   __scudo_print_stats();
   return 0;

diff  --git a/compiler-rt/test/scudo/threads.c b/compiler-rt/test/scudo/threads.c
index b34e6f0f79a2d..f4637a77baad6 100644
--- a/compiler-rt/test/scudo/threads.c
+++ b/compiler-rt/test/scudo/threads.c
@@ -8,8 +8,8 @@
 
 #include <assert.h>
 #include <pthread.h>
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 
 #include <sanitizer/allocator_interface.h>
 
@@ -24,17 +24,21 @@ char go = 0;
 
 void *thread_fun(void *arg) {
   pthread_mutex_lock(&mutex);
-  while (!go) pthread_cond_wait(&cond, &mutex);
+  while (!go)
+    pthread_cond_wait(&cond, &mutex);
   pthread_mutex_unlock(&mutex);
   for (int i = 0; i < total_num_alloc / num_threads; i++) {
     void *p = malloc(10);
-    __asm__ __volatile__("" : : "r"(p) : "memory");
+    __asm__ __volatile__(""
+                         :
+                         : "r"(p)
+                         : "memory");
     free(p);
   }
   return 0;
 }
 
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
   assert(argc == 3);
   num_threads = atoi(argv[1]);
   assert(num_threads > 0);

diff  --git a/compiler-rt/test/scudo/tsd_destruction.c b/compiler-rt/test/scudo/tsd_destruction.c
index 1b0d0eff9f11b..2964df99745b3 100644
--- a/compiler-rt/test/scudo/tsd_destruction.c
+++ b/compiler-rt/test/scudo/tsd_destruction.c
@@ -10,7 +10,7 @@
 // Some of glibc's own thread local data is destroyed after a user's thread
 // local destructors are called, via __libc_thread_freeres. This might involve
 // calling free, as is the case for strerror_thread_freeres.
-// If there is no prior heap operation in the thread, this free would end up 
+// If there is no prior heap operation in the thread, this free would end up
 // initializing some thread specific data that would never be destroyed
 // properly, while still being deallocated when the TLS goes away. As a result,
 // a program could SEGV, usually in
@@ -25,13 +25,14 @@ pthread_t tid[kNumThreads];
 
 void *thread_func(void *arg) {
   uintptr_t i = (uintptr_t)arg;
-  if ((i & 1) == 0) free(malloc(16));
+  if ((i & 1) == 0)
+    free(malloc(16));
   // Calling strerror_l allows for strerror_thread_freeres to be called.
   strerror_l(0, LC_GLOBAL_LOCALE);
   return 0;
 }
 
-int main(int argc, char** argv) {
+int main(int argc, char **argv) {
   for (uintptr_t j = 0; j < 8; j++) {
     for (uintptr_t i = 0; i < kNumThreads; i++)
       pthread_create(&tid[i], 0, thread_func, (void *)i);

diff  --git a/compiler-rt/test/scudo/valloc.c b/compiler-rt/test/scudo/valloc.c
index 605b9c4d4b9d9..7f3a38ec50073 100644
--- a/compiler-rt/test/scudo/valloc.c
+++ b/compiler-rt/test/scudo/valloc.c
@@ -17,8 +17,7 @@ size_t round_up_to(size_t size, size_t alignment) {
   return (size + alignment - 1) & ~(alignment - 1);
 }
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
   void *p = NULL;
   size_t size, page_size;
 


        


More information about the llvm-commits mailing list