Commit ec0da690 authored by Jordan DeLong's avatar Jordan DeLong

Some fixes for building stuff with clang

@override-unit-failures

Summary: Not that much.

Test Plan:
Compiled hphp with clang.

Reviewed By: oyamauchi@fb.com

FB internal diff: D954663
parent 91199bbe
......@@ -861,10 +861,10 @@ to(StringPiece * src) {
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());
......
......@@ -1653,7 +1653,6 @@ void fbvector<T, Allocator>::emplace_back_aux(Args&&... args) {
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;
......
......@@ -402,6 +402,16 @@ constexpr bool is_negative(T x) {
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<
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment