summaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorAlex Converse <aconverse@google.com>2017-04-11 10:20:18 -0700
committerJames Zern <jzern@google.com>2017-08-01 23:26:03 +0000
commit2aeff089d32365e319ea278398b4c05c05841198 (patch)
tree426ab2b4db659b8fdbd15bf09ed24a23866ab904 /third_party
parentcd0b493546a4b304e1100a0f4973194dc4b6513c (diff)
googletest: suppress unsigned overflow in the LCG
Local application of: https://github.com/google/googletest/pull/1066 Suppress unsigned overflow instrumentation in the LCG The rest of the (covered) codebase is already integer overflow clean. TESTED=gtest_shuffle_test goes from fail to pass with -fsanitize=integer Change-Id: I8a6db02a7c274160adb08b7dfd528b87b5b53050
Diffstat (limited to 'third_party')
-rw-r--r--third_party/googletest/README.libaom2
-rw-r--r--third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h13
-rw-r--r--third_party/googletest/src/googletest/src/gtest.cc1
3 files changed, 16 insertions, 0 deletions
diff --git a/third_party/googletest/README.libaom b/third_party/googletest/README.libaom
index a53d7e008..9784dd51b 100644
--- a/third_party/googletest/README.libaom
+++ b/third_party/googletest/README.libaom
@@ -22,3 +22,5 @@ Local Modifications:
CONTRIBUTORS
LICENSE
README.md
+- Suppress unsigned overflow instrumentation in the LCG
+ https://github.com/google/googletest/pull/1066
diff --git a/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h b/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h
index 0094ed507..da57e65d3 100644
--- a/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h
+++ b/third_party/googletest/src/googletest/include/gtest/internal/gtest-port.h
@@ -985,6 +985,19 @@ using ::std::tuple_size;
# define GTEST_ATTRIBUTE_NO_SANITIZE_THREAD_
#endif // __clang__
+// A function level attribute to disable UndefinedBehaviorSanitizer's (defined)
+// unsigned integer overflow instrumentation.
+#if defined(__clang__)
+# if defined(__has_attribute) && __has_attribute(no_sanitize)
+# define GTEST_ATTRIBUTE_NO_SANITIZE_UNSIGNED_OVERFLOW_ \
+ __attribute__((no_sanitize("unsigned-integer-overflow")))
+# else
+# define GTEST_ATTRIBUTE_NO_SANITIZE_UNSIGNED_OVERFLOW_
+# endif // defined(__has_attribute) && __has_attribute(no_sanitize)
+#else
+# define GTEST_ATTRIBUTE_NO_SANITIZE_UNSIGNED_OVERFLOW_
+#endif // __clang__
+
namespace testing {
class Message;
diff --git a/third_party/googletest/src/googletest/src/gtest.cc b/third_party/googletest/src/googletest/src/gtest.cc
index d882ab2e3..5a8932c73 100644
--- a/third_party/googletest/src/googletest/src/gtest.cc
+++ b/third_party/googletest/src/googletest/src/gtest.cc
@@ -308,6 +308,7 @@ namespace internal {
// Generates a random number from [0, range), using a Linear
// Congruential Generator (LCG). Crashes if 'range' is 0 or greater
// than kMaxRange.
+GTEST_ATTRIBUTE_NO_SANITIZE_UNSIGNED_OVERFLOW_
UInt32 Random::Generate(UInt32 range) {
// These constants are the same as are used in glibc's rand(3).
state_ = (1103515245U*state_ + 12345U) % kMaxRange;