Commit 5a68ed6f authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Split kIsSanitizeAddress and kIsLibrarySanitizeAddress

Summary: [Folly] Split `kIsSanitizeAddress` and `kIsLibrarySanitizeAddress`, letting them follow the corresponding preprocessor symbols.

Reviewed By: simpkins

Differential Revision: D15773943

fbshipit-source-id: 938ae9d4106a18c3115df5bdbf8560531da3ccbe
parent 03ef648d
......@@ -117,12 +117,18 @@ constexpr bool kIsArchPPC64 = FOLLY_PPC64 == 1;
namespace folly {
/**
* folly::kIsSanitizeAddress reports if folly was compiled with ASAN
* folly::kIsLibrarySanitizeAddress reports if folly was compiled with ASAN
* enabled. Note that for compilation units outside of folly that include
* folly/Portability.h, the value of kIsSanitizeAddress may be different
* folly/Portability.h, the value of kIsLibrarySanitizeAddress may be different
* from whether or not the current compilation unit is being compiled with ASAN.
*/
#if FOLLY_LIBRARY_SANITIZE_ADDRESS
constexpr bool kIsLibrarySanitizeAddress = true;
#else
constexpr bool kIsLibrarySanitizeAddress = false;
#endif
#if FOLLY_SANITIZE_ADDRESS
constexpr bool kIsSanitizeAddress = true;
#else
constexpr bool kIsSanitizeAddress = false;
......
......@@ -381,7 +381,7 @@ struct BasePolicy
}
void afterDestroyWithoutDeallocate(Value* addr, std::size_t n) {
if (kIsSanitizeAddress) {
if (kIsLibrarySanitizeAddress) {
memset(static_cast<void*>(addr), 0x66, sizeof(Value) * n);
}
}
......
......@@ -1954,7 +1954,7 @@ class F14Table : public Policy {
// sanitizer builds
FOLLY_ALWAYS_INLINE void debugModeOnReserve(std::size_t capacity) {
if (kIsSanitizeAddress || kIsDebug) {
if (kIsLibrarySanitizeAddress || kIsDebug) {
if (capacity > size()) {
tlsPendingSafeInserts(static_cast<std::ptrdiff_t>(capacity - size()));
}
......@@ -1978,14 +1978,14 @@ class F14Table : public Policy {
// One way to fix this is to call map.reserve(N) before such a
// sequence, where N is the number of keys that might be inserted
// within the section that retains references plus the existing size.
if (kIsSanitizeAddress && !tlsPendingSafeInserts() && size() > 0 &&
if (kIsLibrarySanitizeAddress && !tlsPendingSafeInserts() && size() > 0 &&
tlsMinstdRand(size()) == 0) {
debugModeSpuriousRehash();
}
}
FOLLY_ALWAYS_INLINE void debugModeAfterInsert() {
if (kIsSanitizeAddress || kIsDebug) {
if (kIsLibrarySanitizeAddress || kIsDebug) {
tlsPendingSafeInserts(-1);
}
}
......@@ -2192,7 +2192,7 @@ class F14Table : public Policy {
}
void clear() noexcept {
if (kIsSanitizeAddress) {
if (kIsLibrarySanitizeAddress) {
// force recycling of heap memory
auto bc = bucket_count();
reset();
......@@ -2393,7 +2393,7 @@ class F14Table : public Policy {
namespace f14 {
namespace test {
inline void disableInsertOrderRandomization() {
if (kIsSanitizeAddress || kIsDebug) {
if (kIsLibrarySanitizeAddress || kIsDebug) {
detail::tlsPendingSafeInserts(static_cast<std::ptrdiff_t>(
(std::numeric_limits<std::size_t>::max)() / 2));
}
......
......@@ -71,7 +71,7 @@ void repeat(F const& func) {
template <typename F>
void expectAsanFailure(F const& func) {
if (kIsSanitizeAddress) {
if (kIsLibrarySanitizeAddress) {
EXPECT_EXIT(
repeat(func), testing::ExitedWithCode(1), ".*heap-use-after-free.*");
}
......@@ -131,7 +131,7 @@ TEST(F14AsanSupportTest, F14VectorErase) {
auto& v = *set.begin();
EXPECT_EQ(v, 3);
set.erase(2);
if (kIsSanitizeAddress) {
if (kIsLibrarySanitizeAddress) {
EXPECT_NE(v, 3);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment