[compiler-rt] Enable build and testing of asan on AIX (PR #137186)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 24 07:41:54 PDT 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions c,cpp -- compiler-rt/test/asan/TestCases/Posix/asan-symbolize-bad-path.cpp compiler-rt/test/asan/TestCases/Posix/asan-symbolize-sanity-test.cpp compiler-rt/test/asan/TestCases/Posix/asan_symbolize_script/plugin_wrong_frame_number_bug.cpp compiler-rt/test/asan/TestCases/Posix/asprintf.cpp compiler-rt/test/asan/TestCases/Posix/closed-fds.cpp compiler-rt/test/asan/TestCases/Posix/coverage-fork.cpp compiler-rt/test/asan/TestCases/Posix/coverage-module-unloaded.cpp compiler-rt/test/asan/TestCases/Posix/coverage-reset.cpp compiler-rt/test/asan/TestCases/Posix/coverage.cpp compiler-rt/test/asan/TestCases/Posix/deep_call_stack.cpp compiler-rt/test/asan/TestCases/Posix/fake_stack_gc.cpp compiler-rt/test/asan/TestCases/Posix/fgets_fputs.cpp compiler-rt/test/asan/TestCases/Posix/fread_fwrite.cpp compiler-rt/test/asan/TestCases/Posix/interception-in-shared-lib-test.cpp compiler-rt/test/asan/TestCases/Posix/invalid-pointer-pairs-threads.cpp compiler-rt/test/asan/TestCases/Posix/ioctl.cpp compiler-rt/test/asan/TestCases/Posix/new_array_cookie_test.cpp compiler-rt/test/asan/TestCases/Posix/no_asan_gen_globals.c compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cpp compiler-rt/test/asan/TestCases/Posix/stack-overflow.cpp compiler-rt/test/asan/TestCases/Posix/start-deactivated.cpp compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp compiler-rt/test/asan/TestCases/Posix/wait.cpp compiler-rt/test/asan/TestCases/Posix/wait3.cpp compiler-rt/test/asan/TestCases/Posix/wait4.cpp compiler-rt/test/asan/TestCases/Posix/waitid.cpp compiler-rt/test/asan/TestCases/calloc-overflow.cpp compiler-rt/test/asan/TestCases/coverage-disabled.cpp compiler-rt/test/asan/TestCases/debug_double_free.cpp compiler-rt/test/asan/TestCases/debug_locate.cpp compiler-rt/test/asan/TestCases/debug_ppc64_mapping.cpp compiler-rt/test/asan/TestCases/debug_report.cpp compiler-rt/test/asan/TestCases/double-free.cpp compiler-rt/test/asan/TestCases/frexp_interceptor.cpp compiler-rt/test/asan/TestCases/frexpf_interceptor.cpp compiler-rt/test/asan/TestCases/frexpl_interceptor.cpp compiler-rt/test/asan/TestCases/global-location-nodebug.cpp compiler-rt/test/asan/TestCases/global-overflow.cpp compiler-rt/test/asan/TestCases/global-underflow.cpp compiler-rt/test/asan/TestCases/heap-overflow.cpp compiler-rt/test/asan/TestCases/heavy_uar_test.cpp compiler-rt/test/asan/TestCases/initialization-bug.cpp compiler-rt/test/asan/TestCases/intercept-rethrow-exception.cpp compiler-rt/test/asan/TestCases/invalid-free.cpp compiler-rt/test/asan/TestCases/invalid-pointer-pairs-compare-errors.cpp compiler-rt/test/asan/TestCases/invalid-pointer-pairs-subtract-errors.cpp compiler-rt/test/asan/TestCases/invalid-pointer-pairs.cpp compiler-rt/test/asan/TestCases/large_func_test.cpp compiler-rt/test/asan/TestCases/malloc-size-too-big.cpp compiler-rt/test/asan/TestCases/malloc_context_size.cpp compiler-rt/test/asan/TestCases/memset_test.cpp compiler-rt/test/asan/TestCases/null_deref.cpp compiler-rt/test/asan/TestCases/print_summary.cpp compiler-rt/test/asan/TestCases/replaceable_new_delete_shared.cpp compiler-rt/test/asan/TestCases/set_shadow_test.c compiler-rt/test/asan/TestCases/stack-buffer-overflow.cpp compiler-rt/test/asan/TestCases/strcasestr-1.c compiler-rt/test/asan/TestCases/strcasestr-2.c compiler-rt/test/asan/TestCases/strcasestr_strict.c compiler-rt/test/asan/TestCases/strcat_strict.c compiler-rt/test/asan/TestCases/strcmp.c compiler-rt/test/asan/TestCases/strcmp_strict.c compiler-rt/test/asan/TestCases/strcpy-overlap.cpp compiler-rt/test/asan/TestCases/strip_path_prefix.c compiler-rt/test/asan/TestCases/strncat-overlap.cpp compiler-rt/test/asan/TestCases/strncat_strict.c compiler-rt/test/asan/TestCases/strncmp_strict.c compiler-rt/test/asan/TestCases/strncpy-overflow.cpp compiler-rt/test/asan/TestCases/strncpy-overlap.cpp compiler-rt/test/asan/TestCases/suppressions-library.cpp compiler-rt/test/asan/TestCases/use-after-delete.cpp compiler-rt/test/asan/TestCases/use-after-free-right.cpp compiler-rt/test/asan/TestCases/use-after-free.cpp compiler-rt/test/asan/TestCases/use-after-scope-dtor-order.cpp compiler-rt/test/asan/TestCases/use-after-scope-if.cpp compiler-rt/test/asan/TestCases/use-after-scope-inlined.cpp compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.cpp compiler-rt/test/asan/TestCases/use-after-scope-loop-removed.cpp compiler-rt/test/asan/TestCases/use-after-scope-loop.cpp compiler-rt/test/asan/TestCases/use-after-scope-temp.cpp compiler-rt/test/asan/TestCases/use-after-scope-temp2.cpp compiler-rt/test/asan/TestCases/use-after-scope-types.cpp compiler-rt/test/asan/TestCases/use-after-scope.cpp compiler-rt/test/asan/TestCases/zero_page_pc.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/arc4random.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/create_thread_fail.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/dedup_token_length_test.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/devname.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/devname_r.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/fgetln.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/fseek.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/fts.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/funopen.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/getcpuclockid.c compiler-rt/test/sanitizer_common/TestCases/Posix/getfsent.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/getmntinfo.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/getpass.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/huge_malloc.c compiler-rt/test/sanitizer_common/TestCases/Posix/illegal_read_test.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/illegal_write_test.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/posix_spawn.c compiler-rt/test/sanitizer_common/TestCases/Posix/setvbuf.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/signal.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/sl_add.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/strlcat.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/strlcpy.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/strtonum.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/sysctl.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/vis.cpp compiler-rt/test/sanitizer_common/TestCases/Posix/wcsdup.c compiler-rt/test/sanitizer_common/TestCases/Posix/weak_hook_test.cpp compiler-rt/test/sanitizer_common/TestCases/allocator_returns_null.cpp compiler-rt/test/sanitizer_common/TestCases/hard_rss_limit_mb_test.cpp compiler-rt/test/sanitizer_common/TestCases/max_allocation_size.cpp compiler-rt/test/sanitizer_common/TestCases/print-stack-trace.cpp compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-dso.cpp compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard.cpp compiler-rt/test/sanitizer_common/TestCases/strcasestr.c compiler-rt/test/sanitizer_common/TestCases/suffix-log-path_test.c compiler-rt/test/sanitizer_common/TestCases/symbolize_pc.cpp compiler-rt/test/sanitizer_common/TestCases/symbolize_pc_demangle.cpp compiler-rt/test/sanitizer_common/TestCases/symbolize_pc_inline.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/compiler-rt/test/asan/TestCases/Posix/new_array_cookie_test.cpp b/compiler-rt/test/asan/TestCases/Posix/new_array_cookie_test.cpp
index 614569b00..c4dacc4ef 100644
--- a/compiler-rt/test/asan/TestCases/Posix/new_array_cookie_test.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/new_array_cookie_test.cpp
@@ -19,9 +19,9 @@ struct C {
 int main(int argc, char **argv) {
   C *buffer = new C[argc];
   buffer[-2].x = 10;
-// CHECK: AddressSanitizer: heap-buffer-overflow
-// CHECK: in {{main|.main}} {{.*}}new_array_cookie_test.cpp:[[@LINE-2]]
-// CHECK: is located 0 bytes inside of 12-byte region
-// NO_COOKIE: ZZZZZZZZ
+  // CHECK: AddressSanitizer: heap-buffer-overflow
+  // CHECK: in {{main|.main}} {{.*}}new_array_cookie_test.cpp:[[@LINE-2]]
+  // CHECK: is located 0 bytes inside of 12-byte region
+  // NO_COOKIE: ZZZZZZZZ
   delete [] buffer;
 }
diff --git a/compiler-rt/test/asan/TestCases/Posix/no_asan_gen_globals.c b/compiler-rt/test/asan/TestCases/Posix/no_asan_gen_globals.c
index 136f150c9..b1f24bb29 100644
--- a/compiler-rt/test/asan/TestCases/Posix/no_asan_gen_globals.c
+++ b/compiler-rt/test/asan/TestCases/Posix/no_asan_gen_globals.c
@@ -7,7 +7,6 @@
 
 // UNSUPPORTED: target={{.*aix.*}}
 
-
 int x, y, z;
 int main() { return 0; }
 // CHECK-NOT: ___asan_gen_
diff --git a/compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cpp b/compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cpp
index b68d20bbb..cf711caf8 100644
--- a/compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/shared-lib-test.cpp
@@ -30,7 +30,7 @@ int main(int argc, char *argv[]) {
   if (!inc) return 1;
   printf("ok\n");
   inc(1);
-  inc(11);  // BOOM, 11 is more robust than -1 as -1 requires the GLOB and pad are stored adjacent.
+  inc(11); // BOOM, 11 is more robust than -1 as -1 requires the GLOB and pad are stored adjacent.
   // CHECK: {{.*ERROR: AddressSanitizer: global-buffer-overflow}}
   // CHECK: {{READ of size 4 at 0x.* thread T0}}
   // CHECK: {{    #0 0x.*}}
diff --git a/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cpp b/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cpp
index f9bdb5cc8..a1cc1cacc 100644
--- a/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cpp
+++ b/compiler-rt/test/asan/TestCases/Posix/start-deactivated.cpp
@@ -87,27 +87,27 @@ int main(int argc, char *argv[]) {
   // After this line ASan is activated and starts detecting errors.
   void *fn = dlsym(dso, "do_another_bad_thing");
   if (!fn) {
-	  fprintf(stderr, "dlsym failed: %s\n", dlerror());
-	  return 1;
+    fprintf(stderr, "dlsym failed: %s\n", dlerror());
+    return 1;
   }
 
   // After activation: redzones.
   for (int i = 1; i < HoneyPotSize; ++i) {
-	  honeyPot[i] = (char *)malloc(HoneyPotBlockSize);
-	  test_malloc_shadow(honeyPot[i], HoneyPotBlockSize, true);
+    honeyPot[i] = (char *)malloc(HoneyPotBlockSize);
+    test_malloc_shadow(honeyPot[i], HoneyPotBlockSize, true);
   }
   {
-	  char *p = (char *)malloc(HoneyPotBlockSize);
-	  test_malloc_shadow(p, HoneyPotBlockSize, true);
-	  free(p);
+    char *p = (char *)malloc(HoneyPotBlockSize);
+    test_malloc_shadow(p, HoneyPotBlockSize, true);
+    free(p);
   }
   for (int i = 1; i < HoneyPotSize; ++i)
-	  free(honeyPot[i]);
+    free(honeyPot[i]);
 
   // Pre-existing allocations got redzones, too.
   for (size_t sz = 1; sz < nPtrs; ++sz) {
-	  test_malloc_shadow(ptrs[sz], sz, true);
-	  free(ptrs[sz]);
+    test_malloc_shadow(ptrs[sz], sz, true);
+    free(ptrs[sz]);
   }
 
   // Test that ASAN_ACTIVATION_OPTIONS=allocator_may_return_null=1 has effect.
diff --git a/compiler-rt/test/asan/TestCases/debug_double_free.cpp b/compiler-rt/test/asan/TestCases/debug_double_free.cpp
index e4afaf0cf..981fc2eaf 100644
--- a/compiler-rt/test/asan/TestCases/debug_double_free.cpp
+++ b/compiler-rt/test/asan/TestCases/debug_double_free.cpp
@@ -14,7 +14,7 @@
 # endif
 // Solaris libc omits the leading 0x.
 #elif (defined(__sun__) && defined(__svr4__)) || defined(_AIX)
-# define PTR_FMT "0x%p"
+#  define PTR_FMT "0x%p"
 #else
 # define PTR_FMT "%p"
 #endif
diff --git a/compiler-rt/test/asan/TestCases/debug_report.cpp b/compiler-rt/test/asan/TestCases/debug_report.cpp
index 80cd96245..733d95e4f 100644
--- a/compiler-rt/test/asan/TestCases/debug_report.cpp
+++ b/compiler-rt/test/asan/TestCases/debug_report.cpp
@@ -29,7 +29,7 @@ int main() {
 # endif
 // Solaris libc omits the leading 0x.
 #elif (defined(__sun__) && defined(__svr4__)) || defined(_AIX)
-# define PTR_FMT "0x%p"
+#  define PTR_FMT "0x%p"
 #else
 # define PTR_FMT "%p"
 #endif
diff --git a/compiler-rt/test/asan/TestCases/suppressions-library.cpp b/compiler-rt/test/asan/TestCases/suppressions-library.cpp
index 78a1235c8..d8fa0f6fc 100644
--- a/compiler-rt/test/asan/TestCases/suppressions-library.cpp
+++ b/compiler-rt/test/asan/TestCases/suppressions-library.cpp
@@ -17,7 +17,6 @@
 
 // UNSUPPORTED: target={{.*aix.*}}
 
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/compiler-rt/test/asan/TestCases/zero_page_pc.cpp b/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
index 0233b5839..e2789ba18 100644
--- a/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
+++ b/compiler-rt/test/asan/TestCases/zero_page_pc.cpp
@@ -9,10 +9,10 @@
 #  include <ptrauth.h>
 #endif
 
-+// AIX reports illegal instruction error instead of SEGV while accesses address 0x4.
-+// UNSUPPORTED: aix
++ // AIX reports illegal instruction error instead of SEGV while accesses address 0x4.
+    + // UNSUPPORTED: aix
 
-typedef void void_f();
+    typedef void void_f();
 int main() {
   void_f *func = (void_f *)0x4;
 #if __has_feature(ptrauth_calls)
diff --git a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp
index 7d614e748..6244f7825 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Posix/getpw_getgr.cpp
@@ -81,7 +81,8 @@ int main(int argc, const char *argv[]) {
   setgrent();
   test<group>(&getgrent);
 
-#if !defined(__APPLE__) && !(defined(__sun__) && defined(__svr4__)) && !defined(_AIX)
+#  if !defined(__APPLE__) && !(defined(__sun__) && defined(__svr4__)) &&       \
+      !defined(_AIX)
   setpwent();
   test_r<passwd>(&getpwent_r);
   setgrent();

``````````

</details>


https://github.com/llvm/llvm-project/pull/137186


More information about the llvm-commits mailing list