svn commit: r319529 - in vendor/libc++/dist: include test/libcxx/containers/unord test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion test/std/exp...
Dimitry Andric
dim at FreeBSD.org
Sat Jun 3 15:21:13 UTC 2017
Author: dim
Date: Sat Jun 3 15:21:10 2017
New Revision: 319529
URL: https://svnweb.freebsd.org/changeset/base/319529
Log:
Vendor import of libc++ trunk r304659:
https://llvm.org/svn/llvm-project/libcxx/trunk@304659
Added:
vendor/libc++/dist/test/libcxx/containers/unord/next_pow2.pass.cpp (contents, props changed)
Modified:
vendor/libc++/dist/include/__hash_table
vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp
vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp
vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp
Modified: vendor/libc++/dist/include/__hash_table
==============================================================================
--- vendor/libc++/dist/include/__hash_table Sat Jun 3 15:21:07 2017 (r319528)
+++ vendor/libc++/dist/include/__hash_table Sat Jun 3 15:21:10 2017 (r319529)
@@ -137,7 +137,7 @@ inline _LIBCPP_INLINE_VISIBILITY
size_t
__next_hash_pow2(size_t __n)
{
- return size_t(1) << (std::numeric_limits<size_t>::digits - __clz(__n-1));
+ return __n < 2 ? __n : (size_t(1) << (std::numeric_limits<size_t>::digits - __clz(__n-1)));
}
Added: vendor/libc++/dist/test/libcxx/containers/unord/next_pow2.pass.cpp
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ vendor/libc++/dist/test/libcxx/containers/unord/next_pow2.pass.cpp Sat Jun 3 15:21:10 2017 (r319529)
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+// UNSUPPORTED: c++98, c++03
+
+// Not a portable test
+
+// <__hash_table>
+
+// size_t __next_hash_pow2(size_t n);
+
+// If n <= 1, return n. If n is a power of 2, return n.
+// Otherwise, return the next power of 2.
+
+#include <__hash_table>
+#include <unordered_map>
+#include <cassert>
+
+#include <iostream>
+
+bool
+is_power_of_two(unsigned long n)
+{
+ return __builtin_popcount(n) == 1;
+}
+
+void test_next_pow2_val(size_t n)
+{
+ std::size_t npow2 = std::__next_hash_pow2(n);
+ assert(is_power_of_two(npow2) && npow2 > n);
+}
+
+void
+test_next_pow2()
+{
+ assert(!is_power_of_two(0));
+ assert(is_power_of_two(1));
+ assert(is_power_of_two(2));
+ assert(!is_power_of_two(3));
+
+ assert(std::__next_hash_pow2(0) == 0);
+ assert(std::__next_hash_pow2(1) == 1);
+
+ for (std::size_t n = 2; n < (sizeof(std::size_t) * 8 - 1); ++n)
+ {
+ std::size_t pow2 = 1ULL << n;
+ assert(std::__next_hash_pow2(pow2) == pow2);
+ }
+
+ test_next_pow2_val(3);
+ test_next_pow2_val(7);
+ test_next_pow2_val(9);
+ test_next_pow2_val(15);
+ test_next_pow2_val(127);
+ test_next_pow2_val(129);
+}
+
+// Note: this is only really useful when run with -fsanitize=undefined.
+void
+fuzz_unordered_map_reserve(unsigned num_inserts,
+ unsigned num_reserve1,
+ unsigned num_reserve2)
+{
+ std::unordered_map<uint64_t, unsigned long> m;
+ m.reserve(num_reserve1);
+ for (unsigned I = 0; I < num_inserts; ++I) m[I] = 0;
+ m.reserve(num_reserve2);
+ assert(m.bucket_count() >= num_reserve2);
+}
+
+int main()
+{
+ test_next_pow2();
+
+ for (unsigned num_inserts = 0; num_inserts <= 64; ++num_inserts)
+ for (unsigned num_reserve1 = 1; num_reserve1 <= 64; ++num_reserve1)
+ for (unsigned num_reserve2 = 1; num_reserve2 <= 64; ++num_reserve2)
+ fuzz_unordered_map_reserve(num_inserts, num_reserve1, num_reserve2);
+
+ return 0;
+}
Modified: vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp
==============================================================================
--- vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp Sat Jun 3 15:21:07 2017 (r319528)
+++ vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.completion/done.pass.cpp Sat Jun 3 15:21:10 2017 (r319529)
@@ -33,7 +33,7 @@ void do_test(coro::coroutine_handle<Promise> const& H)
// FIXME Add a runtime test
{
ASSERT_SAME_TYPE(decltype(H.done()), bool);
- ASSERT_NOT_NOEXCEPT(H.done());
+ LIBCPP_ASSERT_NOT_NOEXCEPT(H.done());
}
}
Modified: vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp
==============================================================================
--- vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp Sat Jun 3 15:21:07 2017 (r319528)
+++ vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/await_result.pass.cpp Sat Jun 3 15:21:10 2017 (r319529)
@@ -23,7 +23,7 @@ struct coro_t {
}
suspend_never initial_suspend() { return {}; }
suspend_never final_suspend() { return {}; }
- void return_void(){}
+ void return_void() {}
static void unhandled_exception() {}
};
};
@@ -37,7 +37,7 @@ struct B {
struct A {
- ~A(){}
+ ~A() {}
bool await_ready() { return true; }
int await_resume() { return 42; }
template <typename F> void await_suspend(F) {}
Modified: vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp
==============================================================================
--- vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp Sat Jun 3 15:21:07 2017 (r319528)
+++ vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/bool_await_suspend.pass.cpp Sat Jun 3 15:21:10 2017 (r319529)
@@ -10,6 +10,9 @@
// UNSUPPORTED: c++98, c++03, c++11
+// See https://bugs.llvm.org/show_bug.cgi?id=33271
+// UNSUPPORTED: ubsan
+
#include <experimental/coroutine>
#include <cassert>
@@ -22,7 +25,7 @@ struct coro_t {
}
suspend_never initial_suspend() { return {}; }
suspend_never final_suspend() { return {}; }
- void return_void(){}
+ void return_void() {}
void unhandled_exception() {}
};
coro_t(coroutine_handle<promise_type> hh) : h(hh) {}
Modified: vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp
==============================================================================
--- vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp Sat Jun 3 15:21:07 2017 (r319528)
+++ vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/generator.pass.cpp Sat Jun 3 15:21:10 2017 (r319529)
@@ -10,6 +10,9 @@
// UNSUPPORTED: c++98, c++03, c++11
+// See https://bugs.llvm.org/show_bug.cgi?id=33271
+// UNSUPPORTED: ubsan
+
#include <experimental/coroutine>
#include <vector>
#include <cassert>
Modified: vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp
==============================================================================
--- vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp Sat Jun 3 15:21:07 2017 (r319528)
+++ vendor/libc++/dist/test/std/experimental/language.support/support.coroutines/end.to.end/oneshot_func.pass.cpp Sat Jun 3 15:21:10 2017 (r319529)
@@ -68,10 +68,10 @@ template <typename R> struct func { (private)
std::vector<int> yielded_values = {};
int yield(int x) { yielded_values.push_back(x); return x + 1; }
-float fyield(int x) { yielded_values.push_back(x); return x + 2; }
+float fyield(int x) { yielded_values.push_back(x); return static_cast<float>(x + 2); }
void Do1(func<int> f) { yield(f()); }
-void Do2(func<double> f) { yield(f()); }
+void Do2(func<double> f) { yield(static_cast<int>(f())); }
int main() {
Do1([] { return yield(43); });
More information about the svn-src-vendor
mailing list