From: Jordan DeLong Date: Wed, 4 Sep 2013 01:52:52 +0000 (-0700) Subject: Some fixes for building stuff with clang X-Git-Tag: v0.22.0~883 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ec0da6900c92e487781763dd1ca75a72e47dca7f;p=folly.git 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 --- diff --git a/folly/Conv.h b/folly/Conv.h index f5cc23c5..28ad844b 100644 --- a/folly/Conv.h +++ b/folly/Conv.h @@ -861,10 +861,10 @@ to(StringPiece * src) { auto t = detail::digits_to::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()); diff --git a/folly/FBVector.h b/folly/FBVector.h index 7a0cc0f5..e1319587 100644 --- a/folly/FBVector.h +++ b/folly/FBVector.h @@ -1653,7 +1653,6 @@ void fbvector::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; diff --git a/folly/Traits.h b/folly/Traits.h index 37bd58d3..47092973 100644 --- a/folly/Traits.h +++ b/folly/Traits.h @@ -402,6 +402,16 @@ constexpr bool is_negative(T x) { template constexpr bool is_non_positive(T x) { return !x || folly::is_negative(x); } +// same as `x > 0` +template +constexpr bool is_positive(T x) { return !is_non_positive(x); } + +// same as `x >= 0` +template +constexpr bool is_non_negative(T x) { + return !x || is_positive(x); +} + template bool less_than(LHS const lhs) { return detail::less_than_impl<