[compiler-rt] c96d0cc - asan: Use `#if` to test CAN_SANITIZE_LEAKS
Roland McGrath via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 23 11:59:40 PDT 2020
Author: Roland McGrath
Date: 2020-09-23T11:59:31-07:00
New Revision: c96d0cceb684fa176b51d7df5f4f8370e2c983f4
URL: https://github.com/llvm/llvm-project/commit/c96d0cceb684fa176b51d7df5f4f8370e2c983f4
DIFF: https://github.com/llvm/llvm-project/commit/c96d0cceb684fa176b51d7df5f4f8370e2c983f4.diff
LOG: asan: Use `#if` to test CAN_SANITIZE_LEAKS
The `if (0)` isn't necessarily optimized out so as not to create
a link-time reference to LSan runtime functions that might not
exist. So use explicit conditional compilation instead.
Reviewed By: phosek
Differential Revision: https://reviews.llvm.org/D88173
Added:
Modified:
compiler-rt/lib/asan/asan_rtl.cpp
compiler-rt/lib/lsan/lsan_common_fuchsia.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/asan/asan_rtl.cpp b/compiler-rt/lib/asan/asan_rtl.cpp
index ccce92dbe1f2..09270e9b43b1 100644
--- a/compiler-rt/lib/asan/asan_rtl.cpp
+++ b/compiler-rt/lib/asan/asan_rtl.cpp
@@ -498,10 +498,10 @@ static void AsanInitInternal() {
force_interface_symbols(); // no-op.
SanitizerInitializeUnwinder();
- if (CAN_SANITIZE_LEAKS) {
- __lsan::InitCommonLsan();
- InstallAtExitCheckLeaks();
- }
+#if CAN_SANITIZE_LEAKS
+ __lsan::InitCommonLsan();
+ InstallAtExitCheckLeaks();
+#endif
#if CAN_SANITIZE_UB
__ubsan::InitAsPlugin();
diff --git a/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp b/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp
index 9b1a7ed49981..a245093728a3 100644
--- a/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp
+++ b/compiler-rt/lib/lsan/lsan_common_fuchsia.cpp
@@ -51,7 +51,7 @@ void ProcessPlatformSpecificAllocations(Frontier *frontier) {}
// behavior and causes rare race conditions.
void HandleLeaks() {}
-// This is defined
diff erently in asan_fuchsiap.cpp and lsan_fuchsia.cpp.
+// This is defined
diff erently in asan_fuchsia.cpp and lsan_fuchsia.cpp.
bool UseExitcodeOnLeak();
int ExitHook(int status) {
More information about the llvm-commits
mailing list