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 11
11
#include < string>
12
12
#include < vector>
13
13
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
-
22
14
namespace {
23
15
template <typename T>
24
16
void TestAdditionOverflow (FuzzedDataProvider& fuzzed_data_provider)
@@ -32,14 +24,12 @@ void TestAdditionOverflow(FuzzedDataProvider& fuzzed_data_provider)
32
24
assert (is_addition_overflow_custom == AdditionOverflow (j, i));
33
25
assert (maybe_add == CheckedAdd (j, i));
34
26
assert (sat_add == SaturatingAdd (j, i));
35
- #if defined(HAVE_BUILTIN_ADD_OVERFLOW)
36
27
T result_builtin;
37
28
const bool is_addition_overflow_builtin = __builtin_add_overflow (i, j, &result_builtin);
38
29
assert (is_addition_overflow_custom == is_addition_overflow_builtin);
39
30
if (!is_addition_overflow_custom) {
40
31
assert (i + j == result_builtin);
41
32
}
42
- #endif
43
33
if (is_addition_overflow_custom) {
44
34
assert (sat_add == std::numeric_limits<T>::min () || sat_add == std::numeric_limits<T>::max ());
45
35
} else {
Original file line number Diff line number Diff line change 10
10
#include < string>
11
11
#include < vector>
12
12
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
-
21
13
namespace {
22
14
template <typename T>
23
15
void TestMultiplicationOverflow (FuzzedDataProvider& fuzzed_data_provider)
24
16
{
25
17
const T i = fuzzed_data_provider.ConsumeIntegral <T>();
26
18
const T j = fuzzed_data_provider.ConsumeIntegral <T>();
27
19
const bool is_multiplication_overflow_custom = MultiplicationOverflow (i, j);
28
- #if defined(HAVE_BUILTIN_MUL_OVERFLOW)
29
20
T result_builtin;
30
21
const bool is_multiplication_overflow_builtin = __builtin_mul_overflow (i, j, &result_builtin);
31
22
assert (is_multiplication_overflow_custom == is_multiplication_overflow_builtin);
32
23
if (!is_multiplication_overflow_custom) {
33
24
assert (i * j == result_builtin);
34
25
}
35
- #else
36
- if (!is_multiplication_overflow_custom) {
37
- (void )(i * j);
38
- }
39
- #endif
40
26
}
41
27
} // namespace
42
28
You can’t perform that action at this time.
0 commit comments