From: Tianjiao Yin Date: Tue, 18 Apr 2017 04:28:57 +0000 (-0700) Subject: fix incorrect usage of FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER in folly::Histogram X-Git-Tag: v2017.04.24.00~12 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=404a98c4a2917a649e19a81020ba3b1e492540d1;p=folly.git fix incorrect usage of FOLLY_DISABLE_UNDEFINED_BEHAVIOR_SANITIZER in folly::Histogram 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 --- diff --git a/folly/CPortability.h b/folly/CPortability.h index 50984477..1a47d251 100644 --- a/folly/CPortability.h +++ b/folly/CPortability.h @@ -90,10 +90,10 @@ * 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 /** diff --git a/folly/stats/Histogram.h b/folly/stats/Histogram.h index a6daa374..e8e8c97c 100644 --- a/folly/stats/Histogram.h +++ b/folly/stats/Histogram.h @@ -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).