Commit 9b7138e4 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Namespace the UBSAN_DISABLE symbol

Summary:
[Folly] Namespace the `UBSAN_DISABLE` symbol.

Symbols defined by Folly should typically be namespaced to Folly.

Reviewed By: igorsugak

Differential Revision: D4378401

fbshipit-source-id: ff72f5f44e7c9d1bbf08efcec24bd3dc05d10ee7
parent cd578dbf
...@@ -90,9 +90,10 @@ ...@@ -90,9 +90,10 @@
* used as folly whitelists some functions. * used as folly whitelists some functions.
*/ */
#if UNDEFINED_SANITIZER #if UNDEFINED_SANITIZER
# define UBSAN_DISABLE(x) __attribute__((no_sanitize(x))) # define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(x) \
__attribute__((no_sanitize(x)))
#else #else
# define UBSAN_DISABLE(x) # define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(x)
#endif // UNDEFINED_SANITIZER #endif // UNDEFINED_SANITIZER
/** /**
......
...@@ -245,8 +245,9 @@ class Histogram { ...@@ -245,8 +245,9 @@ class Histogram {
: buckets_(bucketSize, min, max, Bucket()) {} : buckets_(bucketSize, min, max, Bucket()) {}
/* Add a data point to the histogram */ /* Add a data point to the histogram */
void addValue(ValueType value) UBSAN_DISABLE("signed-integer-overflow") void addValue(ValueType value)
UBSAN_DISABLE("unsigned-integer-overflow") { FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("signed-integer-overflow")
FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("unsigned-integer-overflow") {
Bucket& bucket = buckets_.getByValue(value); Bucket& bucket = buckets_.getByValue(value);
// NOTE: Overflow is handled elsewhere and tests check this // NOTE: Overflow is handled elsewhere and tests check this
// behavior (see HistogramTest.cpp TestOverflow* tests). // behavior (see HistogramTest.cpp TestOverflow* tests).
...@@ -257,8 +258,8 @@ class Histogram { ...@@ -257,8 +258,8 @@ class Histogram {
/* Add multiple same data points to the histogram */ /* Add multiple same data points to the histogram */
void addRepeatedValue(ValueType value, uint64_t nSamples) void addRepeatedValue(ValueType value, uint64_t nSamples)
UBSAN_DISABLE("signed-integer-overflow") FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("signed-integer-overflow")
UBSAN_DISABLE("unsigned-integer-overflow") { FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("unsigned-integer-overflow") {
Bucket& bucket = buckets_.getByValue(value); Bucket& bucket = buckets_.getByValue(value);
// NOTE: Overflow is handled elsewhere and tests check this // NOTE: Overflow is handled elsewhere and tests check this
// behavior (see HistogramTest.cpp TestOverflow* tests). // behavior (see HistogramTest.cpp TestOverflow* tests).
...@@ -274,8 +275,9 @@ class Histogram { ...@@ -274,8 +275,9 @@ class Histogram {
* had previously been added to the histogram; it merely subtracts the * had previously been added to the histogram; it merely subtracts the
* requested value from the appropriate bucket's sum. * requested value from the appropriate bucket's sum.
*/ */
void removeValue(ValueType value) UBSAN_DISABLE("signed-integer-overflow") void removeValue(ValueType value) FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(
UBSAN_DISABLE("unsigned-integer-overflow") { "signed-integer-overflow")
FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("unsigned-integer-overflow") {
Bucket& bucket = buckets_.getByValue(value); Bucket& bucket = buckets_.getByValue(value);
// NOTE: Overflow is handled elsewhere and tests check this // NOTE: Overflow is handled elsewhere and tests check this
// behavior (see HistogramTest.cpp TestOverflow* tests). // behavior (see HistogramTest.cpp TestOverflow* tests).
......
...@@ -32,7 +32,8 @@ void init() { ...@@ -32,7 +32,8 @@ void init() {
} }
} }
TEST(memcpy, zero_len) UBSAN_DISABLE("nonnull-attribute") { TEST(memcpy, zero_len)
FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("nonnull-attribute") {
// If length is 0, we shouldn't touch any memory. So this should // If length is 0, we shouldn't touch any memory. So this should
// not crash. // not crash.
char* srcNull = nullptr; char* srcNull = nullptr;
......
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