[asan] Turn LSan-related #if’s into regular if’s in ASan initializer

Removing some preprocessor #if’s in favor of regular if’s. However, we need to declare empty stub functions to avoid linker errors.

Differential Revision: http://reviews.llvm.org/D20911

llvm-svn: 272047
This commit is contained in:
Kuba Brecka 2016-06-07 19:13:38 +00:00
parent 3621857eac
commit 688c3d3bf1
2 changed files with 15 additions and 8 deletions

View File

@ -546,12 +546,12 @@ static void AsanInitInternal() {
force_interface_symbols(); // no-op. force_interface_symbols(); // no-op.
SanitizerInitializeUnwinder(); SanitizerInitializeUnwinder();
#if CAN_SANITIZE_LEAKS if (CAN_SANITIZE_LEAKS) {
__lsan::InitCommonLsan(); __lsan::InitCommonLsan();
if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) { if (common_flags()->detect_leaks && common_flags()->leak_check_at_exit) {
Atexit(__lsan::DoLeakCheck); Atexit(__lsan::DoLeakCheck);
} }
#endif // CAN_SANITIZE_LEAKS }
#if CAN_SANITIZE_UB #if CAN_SANITIZE_UB
__ubsan::InitAsPlugin(); __ubsan::InitAsPlugin();
@ -559,12 +559,12 @@ static void AsanInitInternal() {
InitializeSuppressions(); InitializeSuppressions();
{ if (CAN_SANITIZE_LEAKS) {
#if CAN_SANITIZE_LEAKS
// LateInitialize() calls dlsym, which can allocate an error string buffer // LateInitialize() calls dlsym, which can allocate an error string buffer
// in the TLS. Let's ignore the allocation to avoid reporting a leak. // in the TLS. Let's ignore the allocation to avoid reporting a leak.
__lsan::ScopedInterceptorDisabler disabler; __lsan::ScopedInterceptorDisabler disabler;
#endif Symbolizer::LateInitialize();
} else {
Symbolizer::LateInitialize(); Symbolizer::LateInitialize();
} }

View File

@ -650,6 +650,13 @@ uptr LeakReport::UnsuppressedLeakCount() {
} }
} // namespace __lsan } // namespace __lsan
#else // CAN_SANITIZE_LEAKS
namespace __lsan {
void InitCommonLsan() { }
void DoLeakCheck() { }
void DisableInThisThread() { }
void EnableInThisThread() { }
}
#endif // CAN_SANITIZE_LEAKS #endif // CAN_SANITIZE_LEAKS
using namespace __lsan; // NOLINT using namespace __lsan; // NOLINT