@override-unit-failures
Summary: Not that much.
Test Plan:
Compiled hphp with clang.
Reviewed By: oyamauchi@fb.com
FB internal diff:
D954663
auto t = detail::digits_to<typename std::make_unsigned<Tgt>::type>(b, m);
if (negative) {
result = -t;
- FOLLY_RANGE_CHECK(result <= 0, "Negative overflow");
+ FOLLY_RANGE_CHECK(is_non_positive(result), "Negative overflow");
} else {
result = t;
- FOLLY_RANGE_CHECK(result >= 0, "Overflow");
+ FOLLY_RANGE_CHECK(is_non_negative(result), "Overflow");
}
}
src->advance(m - src->data());
size_type lower = folly::goodMallocSize(sizeof(T) + size() * sizeof(T));
size_type upper = byte_sz;
size_type extra = upper - lower;
- assert(extra >= 0);
void* p = impl_.b_;
size_t actual;
template <typename T>
constexpr bool is_non_positive(T x) { return !x || folly::is_negative(x); }
+// same as `x > 0`
+template <typename T>
+constexpr bool is_positive(T x) { return !is_non_positive(x); }
+
+// same as `x >= 0`
+template <typename T>
+constexpr bool is_non_negative(T x) {
+ return !x || is_positive(x);
+}
+
template <typename RHS, RHS rhs, typename LHS>
bool less_than(LHS const lhs) {
return detail::less_than_impl<