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
This commit is contained in:
Taewook Oh 2018-06-27 21:59:09 -07:00 committed by Facebook Github Bot
parent 7f850b889d
commit b557499eee

7
cache/lru_cache.cc vendored
View File

@ -505,10 +505,17 @@ uint32_t LRUCache::GetHash(Handle* handle) const {
void LRUCache::DisownData() { void LRUCache::DisownData() {
// Do not drop data if compile with ASAN to suppress leak warning. // 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__ #ifndef __SANITIZE_ADDRESS__
shards_ = nullptr; shards_ = nullptr;
num_shards_ = 0; num_shards_ = 0;
#endif // !__SANITIZE_ADDRESS__ #endif // !__SANITIZE_ADDRESS__
#endif // __clang__
} }
size_t LRUCache::TEST_GetLRUSize() { size_t LRUCache::TEST_GetLRUSize() {