]> granicus.if.org Git - libvpx/commitdiff
googletest: suppress unsigned overflow in the LCG
authorAlex Converse <aconverse@google.com>
Tue, 11 Apr 2017 17:20:18 +0000 (10:20 -0700)
committerJames Zern <jzern@google.com>
Sat, 1 Jul 2017 19:24:32 +0000 (12:24 -0700)
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

third_party/googletest/README.libvpx
third_party/googletest/src/include/gtest/internal/gtest-port.h
third_party/googletest/src/src/gtest.cc

index 3d9938096f0b87cf37f127b43f7ab31a3ce4bcdf..2cd6910b4100934c500fd6a5e04f81126ba08cd6 100644 (file)
@@ -20,3 +20,5 @@ Local Modifications:
    LICENSE
    README.md
    src
+- Suppress unsigned overflow instrumentation in the LCG
+  https://github.com/google/googletest/pull/1066
index 0094ed5077e69a59afc3f535c9dcfc403b31fbbc..da57e65d338b99bc0a75c6c167032accc3551c73 100644 (file)
@@ -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;
index d882ab2e36a1299528013fe585438baf6fe772ab..5a8932c73e3614ce8ed588883156143bbf67d314 100644 (file)
@@ -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;