fix incorrect usage of FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER in folly::Histogram
authorTianjiao Yin <ytj@fb.com>
Tue, 18 Apr 2017 04:28:57 +0000 (21:28 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 18 Apr 2017 04:36:04 +0000 (21:36 -0700)
Summary: According to [clang documentation](http://clang.llvm.org/docs/AttributeReference.html#no-sanitize-clang-no-sanitize), the format is incorrect. This results unit-test failure with ubsan.

Reviewed By: yfeldblum

Differential Revision: D4901777

fbshipit-source-id: e9d012366c5e1911632e47fa4fb690820b761fc3

folly/CPortability.h
folly/stats/Histogram.h

index 50984477a9f0d8a31b359d5ded315a6c92be818a..1a47d2518ad6d447260da0a4c6e4ef69cd2c1f34 100644 (file)
  * used as folly whitelists some functions.
  */
 #if UNDEFINED_SANITIZER
-# define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(x) \
-    __attribute__((no_sanitize(x)))
+#define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(...) \
+  __attribute__((no_sanitize(__VA_ARGS__)))
 #else
-# define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(x)
+#define FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(...)
 #endif // UNDEFINED_SANITIZER
 
 /**
index a6daa374b0f41948388f878be94a28728990c1e1..e8e8c97c18de786d6f905fefc9e2b590c8ceda87 100644 (file)
@@ -245,9 +245,9 @@ class Histogram {
     : buckets_(bucketSize, min, max, Bucket()) {}
 
   /* Add a data point to the histogram */
-  void addValue(ValueType value)
-      FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("signed-integer-overflow")
-      FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("unsigned-integer-overflow") {
+  void addValue(ValueType value) FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(
+      "signed-integer-overflow",
+      "unsigned-integer-overflow") {
     Bucket& bucket = buckets_.getByValue(value);
     // NOTE: Overflow is handled elsewhere and tests check this
     // behavior (see HistogramTest.cpp TestOverflow* tests).
@@ -258,8 +258,9 @@ class Histogram {
 
   /* Add multiple same data points to the histogram */
   void addRepeatedValue(ValueType value, uint64_t nSamples)
-      FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("signed-integer-overflow")
-      FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("unsigned-integer-overflow") {
+      FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(
+          "signed-integer-overflow",
+          "unsigned-integer-overflow") {
     Bucket& bucket = buckets_.getByValue(value);
     // NOTE: Overflow is handled elsewhere and tests check this
     // behavior (see HistogramTest.cpp TestOverflow* tests).
@@ -276,8 +277,8 @@ class Histogram {
    * requested value from the appropriate bucket's sum.
    */
   void removeValue(ValueType value) FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER(
-      "signed-integer-overflow")
-      FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER("unsigned-integer-overflow") {
+      "signed-integer-overflow",
+      "unsigned-integer-overflow") {
     Bucket& bucket = buckets_.getByValue(value);
     // NOTE: Overflow is handled elsewhere and tests check this
     // behavior (see HistogramTest.cpp TestOverflow* tests).