diff --git a/compiler-rt/test/asan/TestCases/debug_double_free.cpp b/compiler-rt/test/asan/TestCases/debug_double_free.cpp --- a/compiler-rt/test/asan/TestCases/debug_double_free.cpp +++ b/compiler-rt/test/asan/TestCases/debug_double_free.cpp @@ -10,16 +10,16 @@ // If we use %p with MSVC, it comes out all upper case. Use %08x to get // lowercase hex. #ifdef _MSC_VER -# ifdef _WIN64 -# define PTR_FMT "0x%08llx" -# else -# define PTR_FMT "0x%08x" -# endif +# ifdef _WIN64 +# define PTR_FMT "0x%08llx" +# else +# define PTR_FMT "0x%08x" +# endif // Solaris libc omits the leading 0x. #elif defined(__sun__) && defined(__svr4__) -# define PTR_FMT "0x%p" +# define PTR_FMT "0x%p" #else -# define PTR_FMT "%p" +# define PTR_FMT "%p" #endif char *heap_ptr; @@ -33,11 +33,15 @@ // CHECK: heap_ptr: 0x[[ADDR:[0-9a-f]+]] free(heap_ptr); - free(heap_ptr); // BOOM + free(heap_ptr); // BOOM return 0; } -void __asan_on_error() { +#if (__APPLE__) +__attribute__((weak)) +#endif +extern "C" void +__asan_on_error() { int present = __asan_report_present(); void *addr = __asan_get_report_address(); const char *description = __asan_get_report_description(); diff --git a/compiler-rt/test/asan/TestCases/debug_report.cpp b/compiler-rt/test/asan/TestCases/debug_report.cpp --- a/compiler-rt/test/asan/TestCases/debug_report.cpp +++ b/compiler-rt/test/asan/TestCases/debug_report.cpp @@ -37,7 +37,11 @@ # define PTR_FMT "%p" #endif -void __asan_on_error() { +#if (__APPLE__) +__attribute__((weak)) +#endif +extern "C" void +__asan_on_error() { int present = __asan_report_present(); void *pc = __asan_get_report_pc(); void *bp = __asan_get_report_bp(); diff --git a/compiler-rt/test/asan/TestCases/default_options.cpp b/compiler-rt/test/asan/TestCases/default_options.cpp --- a/compiler-rt/test/asan/TestCases/default_options.cpp +++ b/compiler-rt/test/asan/TestCases/default_options.cpp @@ -6,13 +6,14 @@ const char *kAsanDefaultOptions = "verbosity=1 help=1"; -extern "C" -__attribute__((no_sanitize_address)) -const char *__asan_default_options() { +#if (__APPLE__) +__attribute__((weak)) +#endif +__attribute__((no_sanitize_address)) // TBD: Explain why +extern "C" const char * +__asan_default_options() { // CHECK: Available flags for AddressSanitizer: return kAsanDefaultOptions; } -int main() { - return 0; -} +int main() { return 0; } diff --git a/compiler-rt/test/asan/TestCases/on_error_callback.cpp b/compiler-rt/test/asan/TestCases/on_error_callback.cpp --- a/compiler-rt/test/asan/TestCases/on_error_callback.cpp +++ b/compiler-rt/test/asan/TestCases/on_error_callback.cpp @@ -6,14 +6,17 @@ #include #include -extern "C" -void __asan_on_error() { +#if (__APPLE__) +__attribute__((weak)) +#endif +extern "C" void +__asan_on_error() { fprintf(stderr, "__asan_on_error called\n"); fflush(stderr); } int main() { - char *x = (char*)malloc(10 * sizeof(char)); + char *x = (char *)malloc(10 * sizeof(char)); free(x); return x[5]; // CHECK: __asan_on_error called diff --git a/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp b/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp --- a/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp +++ b/compiler-rt/test/ubsan/TestCases/Misc/monitor.cpp @@ -10,19 +10,20 @@ #include -extern "C" { -void __ubsan_get_current_report_data(const char **OutIssueKind, - const char **OutMessage, - const char **OutFilename, - unsigned *OutLine, unsigned *OutCol, - char **OutMemoryAddr); - -// Override the definition of __ubsan_on_report from the runtime, just for -// testing purposes. -void __ubsan_on_report(void) { +// Override __ubsan_on_report() from the runtime, just for testing purposes. +#if (__APPLE__) +__attribute__((weak)) +#endif +extern "C" void +__ubsan_on_report(void) { + void __ubsan_get_current_report_data( + const char **OutIssueKind, const char **OutMessage, + const char **OutFilename, unsigned *OutLine, unsigned *OutCol, + char **OutMemoryAddr); const char *IssueKind, *Message, *Filename; unsigned Line, Col; char *Addr; + __ubsan_get_current_report_data(&IssueKind, &Message, &Filename, &Line, &Col, &Addr); @@ -33,7 +34,6 @@ (void)Addr; } -} int main() { char C = 3;