From b557499eeeb37c5e5ec741d5b152a838b97b630a Mon Sep 17 00:00:00 2001 From: Taewook Oh Date: Wed, 27 Jun 2018 21:59:09 -0700 Subject: [PATCH] Suppress leak warning for clang(LLVM) asan (#4066) Summary: Instead of __SANITIZE_ADDRESS__ macro, LLVM uses __has_feature(address_sanitzer) to check if ASAN is enabled for the build. I tested it with MySQL sanitizer build that uses RocksDB as a submodule. Closes https://github.com/facebook/rocksdb/pull/4066 Reviewed By: riversand963 Differential Revision: D8668941 Pulled By: taewookoh fbshipit-source-id: af4d1da180c1470d257a228f431eebc61490bc36 --- cache/lru_cache.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cache/lru_cache.cc b/cache/lru_cache.cc index 432fee66d..efc423493 100644 --- a/cache/lru_cache.cc +++ b/cache/lru_cache.cc @@ -505,10 +505,17 @@ uint32_t LRUCache::GetHash(Handle* handle) const { void LRUCache::DisownData() { // Do not drop data if compile with ASAN to suppress leak warning. +#if defined(__clang__) +#if !defined(__has_feature) || !__has_feature(address_sanitizer) + shards_ = nullptr; + num_shards_ = 0; +#endif +#else // __clang__ #ifndef __SANITIZE_ADDRESS__ shards_ = nullptr; num_shards_ = 0; #endif // !__SANITIZE_ADDRESS__ +#endif // __clang__ } size_t LRUCache::TEST_GetLRUSize() {