Commit Graph

1676 Commits

Author SHA1 Message Date
JF Bastien b1ba015b9f libc++: support NaCl when building thread.cpp
Summary: NaCl shouldn't include sysctl.h when trying to determine std:🧵:hardware_concurrency, it should instead use sysconf(_SC_NPROCESSORS_ONLN) through unistd.h. No test needs to be changed, since hardware_concurrency.pass.cpp already tests that std:🧵:hardware_concurrency > 0.

Test Plan: make check-libcxx

Reviewers: dschuff, danalbert

Subscribers: jfb, cfe-commits

Differential Revision: http://reviews.llvm.org/D6470

llvm-svn: 223128
2014-12-02 17:30:19 +00:00
JF Bastien 57148cbcbd libc++: add NaCl and PNaCl support for std::random_device
Summary:
The NaCl sandbox doesn't allow opening files under /dev, but it offers an API which provides the same capabilities. This is the same random device emulation that nacl_io performs for POSIX support, but nacl_io is an optional library so libc++ can't assume that device emulation will be performed. Note that NaCl only supports /dev/urandom, not /dev/random.

This patch also cleans up some of the preprocessor #endif, and fixes the test for Win32 (it accepts any token, and would therefore never throw regardless of the token provided).

Test Plan: ninja check-libcxx

Reviewers: dschuff, mclow.lists, danalbert

Subscribers: jfb, cfe-commits

Differential Revision: http://reviews.llvm.org/D6442

llvm-svn: 223068
2014-12-01 19:19:55 +00:00
JF Bastien adec3407b8 libc++: integral types trap on PNaCl
Reviewers: dschuff, danalbert

    Subscribers: jfb, cfe-commits

    Differential Revision: http://reviews.llvm.org/D6411

llvm-svn: 222842
2014-11-26 17:51:58 +00:00
Eric Fiselier 53deb607d9 Fixes to get libc++ building on sun solaris. Patch from C Bergstrom.
llvm-svn: 222794
2014-11-25 21:57:41 +00:00
Eric Fiselier e620b5eaa6 Use lit.util.executeCommand instead of our own version
llvm-svn: 222717
2014-11-25 03:03:32 +00:00
Eric Fiselier cf82c1e904 Print lit configuration information after all configuration is done.
llvm-svn: 222711
2014-11-24 23:46:42 +00:00
Dan Albert 86b75a4057 Add better support for custom test runners.
Summary:
I finally got around to merging the many, many changes to lit.cfg into
Android's libc++. This patch makes it simpler to actually use a custom
configuration and test format.

First, I've factored out _build, _run, and _clean methods from
_execute_test, since these are the likely parts that will need to be
overridden. This is likely a first step in the work jroelofs has been
doing with improving cross-compiling test execution.

Second, I've added a `configuration_variant` to the config. This
entry, if present, is a string that forms the prefix of the class that
is to be used to configure the test runner. For example, Android sets
`config.configuration_variant = 'Android'`, and this causes an object
of type `AndroidConfiguration` to be constructed.

As an example of how this will be used, see:
https://android-review.googlesource.com/#/c/116022/

Reviewers: jroelofs, mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D6373

llvm-svn: 222698
2014-11-24 22:24:06 +00:00
Eric Fiselier a77ccfec24 Handle extra whitespace in linux distribution name.
llvm-svn: 222514
2014-11-21 08:54:35 +00:00
Eric Fiselier 5484151754 Mark some locale tests as XFAIL on debian and opensuse.
llvm-svn: 222513
2014-11-21 08:02:38 +00:00
Dan Albert 9ce6beaf07 Add more REQUIRES: LOCALE.* to tests.
llvm-svn: 222492
2014-11-21 01:23:04 +00:00
Eric Fiselier d50a62e9e8 Remove xfail tag for darwin from quick_exit test
llvm-svn: 222406
2014-11-20 03:40:32 +00:00
Eric Fiselier 3b0a6ce96c Remove tests that va_copy is not defined when C++ < 11.
llvm-svn: 222405
2014-11-20 03:39:25 +00:00
Eric Fiselier 4fb4ab50fc Change contradictory wording in va_copy test error message.
llvm-svn: 222383
2014-11-19 20:01:26 +00:00
Marshall Clow ad75510453 Implement N4280 - 'Non-member size() and more'
llvm-svn: 222378
2014-11-19 19:43:23 +00:00
Marshall Clow e8584ca3ad Added entries for bugs 2118 and 2306, which were closed in Urbana
llvm-svn: 222361
2014-11-19 15:59:16 +00:00
Eric Fiselier 1eb8220aff Overhaul and separate nullptr_t tests to pass with C++03.
The standard requires that nullptr_t can be reinterpret_cast to an integral type
at least the size of nullptr_t. There is no way to emulate this conversion in
the C++03 nullptr_t implementation. The test for this conversion has been moved
to a new test and marked XFAIL with c++03.

This recommits what was originally r222296.

llvm-svn: 222318
2014-11-19 05:49:03 +00:00
Eric Fiselier 77c1ae8364 Revert r222296 to fix bad commit message
llvm-svn: 222316
2014-11-19 05:41:29 +00:00
Eric Fiselier 13d123ccf7 Cleanup quick_exit tests and get them passing in C++03.
Wrap the original test in _LIBCPP_HAS_QUICK_EXIT so it only runs when we have
quick_exit and add two new tests that check that when _LIBCPP_HAS_QUICK_EXIT
is not defined then no definition of std::at_quick_exit or std::quick_exit are
available.

llvm-svn: 222298
2014-11-19 01:45:12 +00:00
Eric Fiselier a3857d336e diff --git a/test/language.support/support.types/nullptr_t.pass.cpp b/test/language.support/support.types/nullptr_t.pass.cpp
index 6c15fef..4d7c8b0 100644
--- a/test/language.support/support.types/nullptr_t.pass.cpp
+++ b/test/language.support/support.types/nullptr_t.pass.cpp
@@ -18,42 +18,62 @@ struct A
     A(std::nullptr_t) {}
 };
 
+template <class T>
+void test_conversions()
+{
+    {
+        T p = 0;
+        assert(p == nullptr);
+    }
+    {
+        T p = nullptr;
+        assert(p == nullptr);
+        assert(nullptr == p);
+        assert(!(p != nullptr));
+        assert(!(nullptr != p));
+    }
+}
+
+template <class T>
+void test_comparisons()
+{
+    T p = nullptr;
+    assert(p == nullptr);
+    assert(p <= nullptr);
+    assert(p >= nullptr);
+    assert(!(p != nullptr));
+    assert(!(p < nullptr));
+    assert(!(p > nullptr));
+    assert(nullptr == p);
+    assert(nullptr <= p);
+    assert(nullptr >= p);
+    assert(!(nullptr != p));
+    assert(!(nullptr < p));
+    assert(!(nullptr > p));
+}
+
+
 int main()
 {
     static_assert(sizeof(std::nullptr_t) == sizeof(void*),
                   "sizeof(std::nullptr_t) == sizeof(void*)");
-    A* p = 0;
-    assert(p == nullptr);
-    void (A::*pmf)() = 0;
-#ifdef __clang__
-    // GCC 4.2 can't handle this
-    assert(pmf == nullptr);
-#endif
-    int A::*pmd = 0;
-    assert(pmd == nullptr);
-    A a1(nullptr);
-    A a2(0);
-    bool b = nullptr;
-    assert(!b);
-    assert(nullptr == nullptr);
-    assert(nullptr <= nullptr);
-    assert(nullptr >= nullptr);
-    assert(!(nullptr != nullptr));
-    assert(!(nullptr < nullptr));
-    assert(!(nullptr > nullptr));
-    A* a = nullptr;
-    assert(a == nullptr);
-    assert(a <= nullptr);
-    assert(a >= nullptr);
-    assert(!(a != nullptr));
-    assert(!(a < nullptr));
-    assert(!(a > nullptr));
-    assert(nullptr == a);
-    assert(nullptr <= a);
-    assert(nullptr >= a);
-    assert(!(nullptr != a));
-    assert(!(nullptr < a));
-    assert(!(nullptr > a));
-    std::ptrdiff_t i = reinterpret_cast<std::ptrdiff_t>(nullptr);
-    assert(i == 0);
+
+    {
+        test_conversions<std::nullptr_t>();
+        test_conversions<void*>();
+        test_conversions<A*>();
+        test_conversions<void(*)()>();
+        test_conversions<void(A::*)()>();
+        test_conversions<int A::*>();
+    }
+    {
+        test_comparisons<std::nullptr_t>();
+        test_comparisons<void*>();
+        test_comparisons<A*>();
+        test_comparisons<void(*)()>();
+    }
+    {
+        bool b = nullptr;
+        assert(!b);
+    }
 }
diff --git a/test/language.support/support.types/nullptr_t_integral_cast.fail.cpp b/test/language.support/support.types/nullptr_t_integral_cast.fail.cpp
new file mode 100644
index 0000000..92bd879
--- /dev/null
+++ b/test/language.support/support.types/nullptr_t_integral_cast.fail.cpp
@@ -0,0 +1,17 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// typedef decltype(nullptr) nullptr_t;
+
+#include <cstddef>
+
+int main()
+{
+    std::ptrdiff_t i = static_cast<std::ptrdiff_t>(nullptr);
+}
diff --git a/test/language.support/support.types/nullptr_t_integral_cast.pass.cpp b/test/language.support/support.types/nullptr_t_integral_cast.pass.cpp
new file mode 100644
index 0000000..34c7a93
--- /dev/null
+++ b/test/language.support/support.types/nullptr_t_integral_cast.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+//                     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.
+//
+//===----------------------------------------------------------------------===//
+
+// NOTE: nullptr_t emulation cannot handle a reinterpret_cast to an
+// integral type
+// XFAIL: c++98, c++03
+
+// typedef decltype(nullptr) nullptr_t;
+
+
+#include <cstddef>
+#include <cassert>
+
+int main()
+{
+    std::ptrdiff_t i = reinterpret_cast<std::ptrdiff_t>(nullptr);
+    assert(i == 0);
+}

llvm-svn: 222296
2014-11-19 01:31:56 +00:00
Eric Fiselier e15f86cb12 Modify tests to check that va_copy is only defined in C++11 and beyond.
llvm-svn: 222282
2014-11-18 23:46:18 +00:00
Eric Fiselier a4884fdefd Flush out test cases for tuples constructor SFINAE
llvm-svn: 222278
2014-11-18 23:01:57 +00:00
Eric Fiselier 9b681f61b6 Add support for LLVM_USE_SANITIZER=Thread
llvm-svn: 222259
2014-11-18 21:26:45 +00:00
Marshall Clow 90ba6230a3 Marked LWG 2399 as complete. I committed a test for this earlier today.
llvm-svn: 222251
2014-11-18 20:37:47 +00:00
Marshall Clow e1a075d5ce Add a test for LWG issue #2399. We already implement this, but now we have a test as well.
llvm-svn: 222242
2014-11-18 18:14:53 +00:00
Marshall Clow f127a2d77f Update status of LWG issues 2340, 2396 and 2401. In all three cases, these are things that we already do.
llvm-svn: 222240
2014-11-18 17:35:16 +00:00
Marshall Clow e9ad58a76e Since Eric poisoned the comma operator on all our test iterators, we no longer need 'comma_iterator'. Remove it from the test suite.
llvm-svn: 222238
2014-11-18 16:15:00 +00:00
Marshall Clow e2c1750a2f Fix the tests I broke with the last commit. Sorry for the noise
llvm-svn: 222165
2014-11-17 19:16:57 +00:00
Marshall Clow 278ddec22c Implement LWG2400 - 'shared_ptr's get_deleter() should use addressof()', and add tests. Mark LWG2400 and LWG2404 as complete
llvm-svn: 222161
2014-11-17 19:05:50 +00:00
Marshall Clow 85a429a67a Reworked mismatch tests to count the number of comparisons, and make sure we are conforming with LWG2404. We are
llvm-svn: 222159
2014-11-17 18:52:25 +00:00
Marshall Clow 4bc58540c9 Fix a warning in the test; no functionality change
llvm-svn: 222143
2014-11-17 16:34:44 +00:00
Marshall Clow 3687d3c2e9 Implement void_t from N3911. Add a private version for use in the library before C++1z. Update the 1z status page, marking a bunch of issues that don't require library changes as complete (2129, 2212, 2230, 2233, 2325, 2365, 2376)
llvm-svn: 222138
2014-11-17 15:50:08 +00:00
Marshall Clow 5a8c46653f Add tests to ensure that reference_wrapper<T> is trivially copyable. This was added to C++1z with the adoption of N4277, but libc++ already implemented it as a conforming extension. No code changes were needed, just more tests.
llvm-svn: 222132
2014-11-17 15:04:46 +00:00
Eric Fiselier 382338d988 Fix build regression caused by not defining ABI library macros
llvm-svn: 222085
2014-11-15 17:25:23 +00:00
Eric Fiselier 5aedca96d5 [libcxx] Refactor CMakeLists.txt handling of compile and link flags to suppress warnings.
Summary:
Currently we have 5 variables that are used to specify options for building libcxx
1. `LIBCXX_CXX_FEATURE_FLAGS`
2. `LIBCXX_CXX_WARNING_FLAGS`
3. `LIBCXX_CXX_REQUIRED_FLAGS`
4. `compile_flags` (in libcxx/lib)
5. `link_flags` (in libcxx/lib)

The first three all get put into `CMAKE_CXX_FLAGS`. 
This changes the way flags are handled by only using 3 different options:

1. `LIBCXX_CXX_FLAGS` - general compile and link flags.
2. `LIBCXX_COMPILE_FLAGS` - compile only flags.
3. `LIBCXX_LINK_FLAGS` - link only flags.

This patch also removes the warning about `-nostdinc++` being unused during linking.



Reviewers: mclow.lists, danalbert

Reviewed By: danalbert

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D6277

llvm-svn: 222080
2014-11-15 06:26:30 +00:00
Eric Fiselier 3fe611e508 Split thread test into two parts. Mark one as XFAIL with ASAN.
The second part of the test checks that std::terminate is called when a running
thread is move assigned to. Calling std::terminate prevents some of the destructors
to be called and ASAN fires on this.

llvm-svn: 222076
2014-11-15 01:58:45 +00:00
Eric Fiselier d6bd7bf6ba Initialize pointer in string conversion helpers to prevent MSAN diagnostic.
Since the initialization of the pointer happens across the libc library boundry
MSAN will not know the pointer was initialized. This fixes MSAN failures in
test/strings/string.conversions.

llvm-svn: 222052
2014-11-14 22:23:57 +00:00
Eric Fiselier 0425c7c726 add debug info when compiling sanitizer tests
llvm-svn: 222051
2014-11-14 22:18:03 +00:00
Eric Fiselier 71380b8391 Add -gline-tables-only when compiling w/ sanitizers in RELEASE
llvm-svn: 222035
2014-11-14 20:38:07 +00:00
Eric Fiselier 93f65c4d08 [libcxx] Fix memory leak in strstream tests.
Summary: The strstream function `str()` sets `freeze(true)`. When `freeze` is true the destructor is not allowed to free any dynamically allocated memory. The memory leak causes ASAN to fail on these tests. To ensure memory is deallocated `strstream.freeze(false)` is called at the end of the tests.

Reviewers: danalbert, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D6261

llvm-svn: 222025
2014-11-14 19:10:43 +00:00
Eric Fiselier b9987293e6 [libcxx] Fix vector annotator size increase in `vector::insert(pos, count, value)`
Summary:
The size of the vector is being increased by `__n` during the call to `__move_range` and not by 1.
This fixes a test failure in `containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp` when using ASAN.

Reviewers: danalbert, kcc, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D6264

llvm-svn: 222014
2014-11-14 18:28:36 +00:00
Eric Fiselier 950a166710 Split string capacity test into two parts and mark one part as UNSUPPORTED when using sanitizers.
The test is split such that:
- max_size.pass.cpp tests that string::resize() fails to allocator for max_size
  and max_size -1
- over_max_size.pass.cpp tests that string::resize() throws a length error for
  max_size + 1

The test was split into two because max_size.pass.cpp cannot pass with 
sanitizers but over_max_size.pass.cpp can.

llvm-svn: 221969
2014-11-14 03:16:12 +00:00
Eric Fiselier eb2378b70c Mark more tests as UNSUPPORTED with ASAN and MSAN.
These tests fail for 2 reasons when using ASAN and MSAN.
1. If allocator_may_return_null=0 they will fail because null is returned
   or an exception is thrown.
2. When allocator_may_return_null=1 the new_handler is still not called. This
   results in an assertion failures.

llvm-svn: 221967
2014-11-14 02:55:16 +00:00
Eric Fiselier b941b50b16 Setup llvm-symbolizer when running the tests with sanitizers
llvm-svn: 221966
2014-11-14 02:47:08 +00:00
Eric Fiselier bc2d632964 Add -O3 when testing with UBSAN. This triggers far undefined behaviour
llvm-svn: 221964
2014-11-14 02:07:52 +00:00
Eric Fiselier a0c1b09c6a Mark more locale tests as unsupported with ASAN and MSAN
llvm-svn: 221937
2014-11-13 22:45:23 +00:00
Marshall Clow eb63c5e28c Replaced checking in string_view::remove_suffix/remove_prefix by _LIBCPP_ASSERT, since this is technically undefined behavior. Fixes PR#21496
llvm-svn: 221717
2014-11-11 22:07:10 +00:00
Marshall Clow 981f31ac51 Fix typo in allocator_traits::construct. This fixes PR14175, which shows up if an allocator has a no-args construct method
llvm-svn: 221697
2014-11-11 19:22:33 +00:00
Marshall Clow f1ce9c177f Fixed a typo in a paper name: 4190 --> N4190
llvm-svn: 221690
2014-11-11 16:45:50 +00:00
Marshall Clow 862af58793 Added vector<T>::insert tests suggested by code coverage results
llvm-svn: 221689
2014-11-11 16:44:05 +00:00
Marshall Clow a773ab1d8d EricQWF's code coverage work showed that none of the libc++ tests were exercising some code in vector<bool>. Add more tests in an attempt to get better coverage
llvm-svn: 221644
2014-11-11 00:16:30 +00:00