Namespace the UBSAN_DISABLE symbol
authorYedidya Feldblum <yfeldblum@fb.com>
Thu, 5 Jan 2017 17:57:26 +0000 (09:57 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 5 Jan 2017 18:02:59 +0000 (10:02 -0800)
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

folly/CPortability.h
folly/stats/Histogram.h
folly/test/MemcpyTest.cpp

index 01e972e9ea03723c7d418de38cdc6b2879d290b6..0989cbc920fb745a07c6e4dee2afa7c72d85b911 100644 (file)
  * used as folly whitelists some functions.
  */
 #if UNDEFINED_SANITIZER
-# define UBSAN_DISABLE(x) __attribute__((no_sanitize(x)))
+# define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(x) \
+    __attribute__((no_sanitize(x)))
 #else
-# define UBSAN_DISABLE(x)
+# define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(x)
 #endif // UNDEFINED_SANITIZER
 
 /**
index 33fe5d094914486efa7240d1c95a925613b808c9..fbb259831d750268a25a30a6eefea1e784833769 100644 (file)
@@ -245,8 +245,9 @@ class Histogram {
     : buckets_(bucketSize, min, max, Bucket()) {}
 
   /* Add a data point to the histogram */
-  void addValue(ValueType value) UBSAN_DISABLE("signed-integer-overflow")
-      UBSAN_DISABLE("unsigned-integer-overflow") {
+  void addValue(ValueType value)
+      FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("signed-integer-overflow")
+      FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("unsigned-integer-overflow") {
     Bucket& bucket = buckets_.getByValue(value);
     // NOTE: Overflow is handled elsewhere and tests check this
     // behavior (see HistogramTest.cpp TestOverflow* tests).
@@ -257,8 +258,8 @@ class Histogram {
 
   /* Add multiple same data points to the histogram */
   void addRepeatedValue(ValueType value, uint64_t nSamples)
-      UBSAN_DISABLE("signed-integer-overflow")
-          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);
     // NOTE: Overflow is handled elsewhere and tests check this
     // behavior (see HistogramTest.cpp TestOverflow* tests).
@@ -274,8 +275,9 @@ class Histogram {
    * had previously been added to the histogram; it merely subtracts the
    * requested value from the appropriate bucket's sum.
    */
-  void removeValue(ValueType value) UBSAN_DISABLE("signed-integer-overflow")
-      UBSAN_DISABLE("unsigned-integer-overflow") {
+  void removeValue(ValueType value) FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(
+      "signed-integer-overflow")
+      FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("unsigned-integer-overflow") {
     Bucket& bucket = buckets_.getByValue(value);
     // NOTE: Overflow is handled elsewhere and tests check this
     // behavior (see HistogramTest.cpp TestOverflow* tests).
index e9f335852226304250c9fe37844329e0b518191d..f9f5a4336e8614cab2b0375438b69edc4c97ba3e 100644 (file)
@@ -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
   // not crash.
   char* srcNull = nullptr;