functions to protect against duration and time_point overflow. Since
we're about to wait anyway, we can afford to spend a few more cycles on
this checking. I purposefully did not treat the timed try_locks with
overflow checking. This fixes
http://llvm.org/bugs/show_bug.cgi?id=13721 . I'm unsure if the standard
needs clarification in this area, or if this is simply QOI. The
<chrono> facilities were never intended to overflow check, but just to
not overflow if durations stayed within +/- 292 years.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162925 91177308-0d34-0410-b5e6-96231b3b80d8
It does not consider user-defined conversions that convert an rvalue
into an lvalue and works incorrectly for types with such a conversion
operator.
For example,
struct foo
{
operator int&();
};
returns false_type.
Attached a patch that fixes this problem.
http://llvm.org/bugs/show_bug.cgi?id=13601
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162644 91177308-0d34-0410-b5e6-96231b3b80d8
Remaining characters should be discarded once sync() called. If don’t, garbage
characters can be inserted to the front of external buffer in underflow().
Because underflow() copies remaining characters in external buffer to it’s
front. This results wrong characters insertion when seekpos() or seekoff() is
called.
this line should be inserted in sync() just before return:
__extbufnext_ = __extbufend_ = __extbuf_;
2. sync() should use length() rather than out() to calculate offset.
Reversing iterators and calling out() to calculate offset from behind is
working fine in stateless character encoding. However, in stateful encoding,
escape sequences could differ in length. As a result, out() could return wrong
length.
For example, if we have internal buffer converted from this external sequence:
(capital letters mean escape sequence)
… a a a a B b b b b
out() produces this sequence.
b b b b A a a a a
Because out() inserts escape sequence A rather than B, result sequence doesn't
match to external sequence. A and B could have different lengths, result offset
could be wrong value too.
length() method in codecvt is right for calculating offset, but it counts
offset from the beginning of buffer. So it requires another state member
variable to hold state before conversion.
Fixes http://llvm.org/bugs/show_bug.cgi?id=13667
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@162601 91177308-0d34-0410-b5e6-96231b3b80d8
LLVM_ENABLE_ASSERTIONS instead of LIBCXX_ENABLE_ASSERTIONS when
figuring out what _DEBUG/NDEBUG defines to set. It also tries to test
the non-existent variable 'uppercase_CMAKE_BUILD_TYPE', which the top
level LLVM CMakeLists.txt sets up, but which the top level libc++
CMakeLists.txt currently does not. Changing the variable name tested
and creating the uppercase release name variable allows libc++ to
honor the LIBCXX_ENABLE_ASSERTIONS option correctly.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161308 91177308-0d34-0410-b5e6-96231b3b80d8
rotate is a critical algorithm because it is often used by other algorithms,
both std and non-std. The main thrust of this optimization is a specialized
algorithm when the 'distance' to be shifted is 1 (either left or right). To my
surprise, this 'optimization' was not effective for types like std::string.
std::string favors rotate algorithms which only use swap. But for types like
scalars, and especially when the sequence is random access, these new
specializations are a big win. If it is a vector<size_t> for example, the
rotate is done via a memmove and can be several times faster than the gcd
algorithm.
I'm using is_trivially_move_assignable to distinguish between types like int and
types like string. This is obviously an ad-hoc approximation, but I haven't
found a case where it doesn't give good results.
I've used a 'static if' (with is_trivially_move_assignable) in three places.
Testing with both -Os and -O3 showed that clang eliminated all code not be
executed by the 'static if' (including the 'static if' itself).
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161247 91177308-0d34-0410-b5e6-96231b3b80d8
__time_get_storage<char> to match the initialization behavior in
__time_get_storage<wchar>. Without the initialization, valgrind
reports errors in the subsequent calls to strftime_l.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@161196 91177308-0d34-0410-b5e6-96231b3b80d8