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
This commit is contained in:
parent
27e37e1a8a
commit
f7645138d4
2
third_party/googletest/README.libvpx
vendored
2
third_party/googletest/README.libvpx
vendored
@ -20,3 +20,5 @@ Local Modifications:
|
||||
LICENSE
|
||||
README.md
|
||||
src
|
||||
- Suppress unsigned overflow instrumentation in the LCG
|
||||
https://github.com/google/googletest/pull/1066
|
||||
|
@ -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;
|
||||
|
1
third_party/googletest/src/src/gtest.cc
vendored
1
third_party/googletest/src/src/gtest.cc
vendored
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user