[compiler-rt] Add aligned_alloc to macOS tsan interceptors (PR #79198)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 23 12:01:17 PST 2024


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 8ed1291d96eaf230ce289c9e62d28df3851d4372 f4e1f4149d3a4b3babcd15ee2d326c195fed7888 -- compiler-rt/test/tsan/free_race_aligned_alloc.c compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h compiler-rt/lib/tsan/rtl/tsan_dispatch_defs.h compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
``````````

</details>

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

``````````diff
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
index 75fda42a48..a1815aef1a 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h
@@ -33,22 +33,22 @@
 # define SANITIZER_INTERFACE_ATTRIBUTE __declspec(dllimport)
 #else
 # define SANITIZER_INTERFACE_ATTRIBUTE __declspec(dllexport)
-#endif // SANITIZER_IMPORT_INTERFACE
-# define SANITIZER_WEAK_ATTRIBUTE
-# define  SANITIZER_WEAK_IMPORT
+#  endif  // SANITIZER_IMPORT_INTERFACE
+#  define SANITIZER_WEAK_ATTRIBUTE
+#  define SANITIZER_WEAK_IMPORT
 #elif SANITIZER_GO
 # define SANITIZER_INTERFACE_ATTRIBUTE
 # define SANITIZER_WEAK_ATTRIBUTE
-# define SANITIZER_WEAK_IMPORT
-#else // NOT SANITIZER_WINDOWS
-# define SANITIZER_INTERFACE_ATTRIBUTE __attribute__((visibility("default")))
-# define SANITIZER_WEAK_ATTRIBUTE  __attribute__((weak))
-#if SANITIZER_APPLE
-# define SANITIZER_WEAK_IMPORT extern "C" __attribute((weak_import))
-#else // NOT SANITIZER_APPLE
-# define SANITIZER_WEAK_IMPORT extern "C" SANITIZER_WEAK_ATTRIBUTE
-#endif // SANITIZER_APPLE
-#endif // SANITIZER_WINDOWS
+#  define SANITIZER_WEAK_IMPORT
+#else  // NOT SANITIZER_WINDOWS
+#  define SANITIZER_INTERFACE_ATTRIBUTE __attribute__((visibility("default")))
+#  define SANITIZER_WEAK_ATTRIBUTE __attribute__((weak))
+#  if SANITIZER_APPLE
+#    define SANITIZER_WEAK_IMPORT extern "C" __attribute((weak_import))
+#  else  // NOT SANITIZER_APPLE
+#    define SANITIZER_WEAK_IMPORT extern "C" SANITIZER_WEAK_ATTRIBUTE
+#  endif  // SANITIZER_APPLE
+#endif    // SANITIZER_WINDOWS
 
 //--------------------------- WEAK FUNCTIONS ---------------------------------//
 // When working with weak functions, to simplify the code and make it more
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index 1e27807e26..d75c25f380 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -12,27 +12,27 @@
 // sanitizer_common/sanitizer_common_interceptors.inc
 //===----------------------------------------------------------------------===//
 
+#include <stdarg.h>
+
+#include "interception/interception.h"
 #include "sanitizer_common/sanitizer_atomic.h"
 #include "sanitizer_common/sanitizer_errno.h"
 #include "sanitizer_common/sanitizer_internal_defs.h"
 #include "sanitizer_common/sanitizer_libc.h"
 #include "sanitizer_common/sanitizer_linux.h"
+#include "sanitizer_common/sanitizer_placement_new.h"
 #include "sanitizer_common/sanitizer_platform_limits_netbsd.h"
 #include "sanitizer_common/sanitizer_platform_limits_posix.h"
-#include "sanitizer_common/sanitizer_placement_new.h"
 #include "sanitizer_common/sanitizer_posix.h"
 #include "sanitizer_common/sanitizer_stacktrace.h"
 #include "sanitizer_common/sanitizer_tls_get_addr.h"
-#include "interception/interception.h"
+#include "tsan_fd.h"
 #include "tsan_interceptors.h"
 #include "tsan_interface.h"
+#include "tsan_mman.h"
 #include "tsan_platform.h"
-#include "tsan_suppressions.h"
 #include "tsan_rtl.h"
-#include "tsan_mman.h"
-#include "tsan_fd.h"
-
-#include <stdarg.h>
+#include "tsan_suppressions.h"
 
 using namespace __tsan;
 
@@ -822,7 +822,7 @@ TSAN_INTERCEPTOR(void*, memalign, uptr align, uptr sz) {
 // macOS 10.15 is greater than our minimal deployment target.  To ensure we
 // generate a weak reference so the TSan dylib continues to work on older
 // systems, we need to forward declare the intercepted function as "weak
-// imports".   
+// imports".
 SANITIZER_WEAK_IMPORT void *aligned_alloc(SIZE_T __alignment, SIZE_T __size);
 TSAN_INTERCEPTOR(void*, aligned_alloc, uptr align, uptr sz) {
   if (in_symbolizer())
diff --git a/compiler-rt/test/tsan/free_race_aligned_alloc.c b/compiler-rt/test/tsan/free_race_aligned_alloc.c
index 5e9c496925..a85ab96db2 100644
--- a/compiler-rt/test/tsan/free_race_aligned_alloc.c
+++ b/compiler-rt/test/tsan/free_race_aligned_alloc.c
@@ -1,21 +1,20 @@
 // RUN: %clang_tsan -O1 %s -o %t -undefined dynamic_lookup
-// RUN: %deflake %run %t | FileCheck %s 
+// RUN: %deflake %run %t | FileCheck %s
 
 #include "test.h"
 
 #include <stdlib.h>
 
 #if defined(__cplusplus) && (__cplusplus >= 201703L)
-#define HAVE_ALIGNED_ALLOC 1
+#  define HAVE_ALIGNED_ALLOC 1
 #endif
 
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&                  \
     __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101500
-#define HAVE_ALIGNED_ALLOC 0 
+#  define HAVE_ALIGNED_ALLOC 0
 #else
 #endif
 
-
 int *mem;
 pthread_mutex_t mtx;
 
@@ -39,9 +38,9 @@ int main() {
 
   barrier_init(&barrier, 2);
 #if HAVE_ALIGNED_ALLOC
-  mem = (int*)aligned_alloc(8, 8);
+  mem = (int *)aligned_alloc(8, 8);
 #else
-  mem = (int*)malloc(8);
+  mem = (int *)malloc(8);
 #endif
   pthread_mutex_init(&mtx, 0);
   pthread_t t;

``````````

</details>


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


More information about the llvm-commits mailing list