File tree Expand file tree Collapse file tree 2 files changed +0
-24
lines changed Expand file tree Collapse file tree 2 files changed +0
-24
lines changed Original file line number Diff line number Diff line change 1111#include < string>
1212#include < vector>
1313
14- #if defined(__has_builtin)
15- #if __has_builtin(__builtin_add_overflow)
16- #define HAVE_BUILTIN_ADD_OVERFLOW
17- #endif
18- #elif defined(__GNUC__)
19- #define HAVE_BUILTIN_ADD_OVERFLOW
20- #endif
21-
2214namespace {
2315template <typename T>
2416void TestAdditionOverflow (FuzzedDataProvider& fuzzed_data_provider)
@@ -32,14 +24,12 @@ void TestAdditionOverflow(FuzzedDataProvider& fuzzed_data_provider)
3224 assert (is_addition_overflow_custom == AdditionOverflow (j, i));
3325 assert (maybe_add == CheckedAdd (j, i));
3426 assert (sat_add == SaturatingAdd (j, i));
35- #if defined(HAVE_BUILTIN_ADD_OVERFLOW)
3627 T result_builtin;
3728 const bool is_addition_overflow_builtin = __builtin_add_overflow (i, j, &result_builtin);
3829 assert (is_addition_overflow_custom == is_addition_overflow_builtin);
3930 if (!is_addition_overflow_custom) {
4031 assert (i + j == result_builtin);
4132 }
42- #endif
4333 if (is_addition_overflow_custom) {
4434 assert (sat_add == std::numeric_limits<T>::min () || sat_add == std::numeric_limits<T>::max ());
4535 } else {
Original file line number Diff line number Diff line change 1010#include < string>
1111#include < vector>
1212
13- #if defined(__has_builtin)
14- #if __has_builtin(__builtin_mul_overflow)
15- #define HAVE_BUILTIN_MUL_OVERFLOW
16- #endif
17- #elif defined(__GNUC__)
18- #define HAVE_BUILTIN_MUL_OVERFLOW
19- #endif
20-
2113namespace {
2214template <typename T>
2315void TestMultiplicationOverflow (FuzzedDataProvider& fuzzed_data_provider)
2416{
2517 const T i = fuzzed_data_provider.ConsumeIntegral <T>();
2618 const T j = fuzzed_data_provider.ConsumeIntegral <T>();
2719 const bool is_multiplication_overflow_custom = MultiplicationOverflow (i, j);
28- #if defined(HAVE_BUILTIN_MUL_OVERFLOW)
2920 T result_builtin;
3021 const bool is_multiplication_overflow_builtin = __builtin_mul_overflow (i, j, &result_builtin);
3122 assert (is_multiplication_overflow_custom == is_multiplication_overflow_builtin);
3223 if (!is_multiplication_overflow_custom) {
3324 assert (i * j == result_builtin);
3425 }
35- #else
36- if (!is_multiplication_overflow_custom) {
37- (void )(i * j);
38- }
39- #endif
4026}
4127} // namespace
4228
You can’t perform that action at this time.
0 commit comments