MCPcopy Create free account
hub / github.com/cel-expr/cel-cpp / CheckedSub

Function CheckedSub

internal/overflow.cc:90–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90absl::StatusOr<int64_t> CheckedSub(int64_t x, int64_t y) {
91#if ABSL_HAVE_BUILTIN(__builtin_sub_overflow)
92 int64_t diff;
93 if (!__builtin_sub_overflow(x, y, &diff)) {
94 return diff;
95 }
96 return absl::OutOfRangeError("integer overflow");
97#else
98 CEL_RETURN_IF_ERROR(CheckRange(
99 y < 0 ? x <= kInt64Max + y : x >= kInt64Min + y, "integer overflow"));
100 return x - y;
101#endif
102}
103
104absl::StatusOr<int64_t> CheckedNegation(int64_t v) {
105#if ABSL_HAVE_BUILTIN(__builtin_mul_overflow)

Callers 4

overflow_test.ccFile · 0.85
Sub<int64_t>Function · 0.85
Sub<uint64_t>Function · 0.85

Calls 3

CheckRangeFunction · 0.85
IsFiniteFunction · 0.85
CheckedAddFunction · 0.85

Tested by

no test coverage detected