Commit Graph

1883 Commits

Author SHA1 Message Date
Eric Fiselier faf2a81380 Diagnose invalid memory orderings in <atomic>
llvm-svn: 291976
2017-01-13 23:45:39 +00:00
Eric Fiselier 04333f9bda Diagnose non-const-callable hash functions and comparators
llvm-svn: 291969
2017-01-13 22:42:53 +00:00
Eric Fiselier b1e7a12ee8 Add _LIBCPP_DIAGNOSE_WARNING and _LIBCPP_DIAGNOSE_ERROR macros.
Clang recently added a `diagnose_if(cond, msg, type)` attribute
which can be used to generate diagnostics when `cond` is a constant
expression that evaluates to true. Otherwise no attribute has no
effect.

This patch adds _LIBCPP_DIAGNOSE_ERROR/WARNING macros which
use this new attribute. Additionally this patch implements
a diagnostic message when a non-const-callable comparator is
given to a container.

Note: For now the warning version of the diagnostic is useless
within libc++ since warning diagnostics are suppressed by the
system header pragma. I'm going to work on fixing this.

llvm-svn: 291961
2017-01-13 22:02:08 +00:00
Marshall Clow 05d57faa2e Implement P0426: Constexpr for std::char_traits
llvm-svn: 291741
2017-01-12 04:37:14 +00:00
Roger Ferrer Ibanez e8623b90ae Mark tests as unsupported under libcpp-no-exceptions
The destructor of std::promise needs to construct a std::future_error
exception so it calls std::make_exception_ptr. But under
libcpp-no-exceptions this will trigger an abort.

Differential Revision: https://reviews.llvm.org/D27614

llvm-svn: 291550
2017-01-10 08:48:48 +00:00
Marshall Clow 6f8e7e0853 Added XFAIL for the apple versions of clang as well
llvm-svn: 291475
2017-01-09 20:29:28 +00:00
Marshall Clow 8fd58a6be8 Implement P0403R1 - 'Literal suffixes for basic_string_view'. Requires clang 4.0 (specifically, r290744)
llvm-svn: 291457
2017-01-09 18:07:34 +00:00
Eric Fiselier 5741d86d11 Replace identifiers called `__out` because Windows.h #defines it.
Windows is greedy and it defines the identifier `__out` as a macro.
This patch renames all conflicting libc++ identifiers in order
to correctly work on Windows.

llvm-svn: 291345
2017-01-07 11:27:06 +00:00
Stephan T. Lavavej 12195f1f03 [libcxx] [test] Strip trailing whitespace. NFC, no code review.
llvm-svn: 291322
2017-01-07 01:12:15 +00:00
Eric Fiselier 4ecb6dd6ea Get all tuple tests passing on Windows
llvm-svn: 291311
2017-01-07 00:10:42 +00:00
Eric Fiselier 93619335df Fix linking of DLL's on Windows
On Windows the runtime search path for DLL's is the same as PATH.
This patch changes the test suite to add the libc++ build directory
to the runtime PATH.

llvm-svn: 291309
2017-01-07 00:01:55 +00:00
Eric Fiselier 8f56dedb5f Replace _LIBCPP_HAS_NO_DELETED_FUNCTIONS with _LIBCPP_CXX03_LANG
llvm-svn: 291278
2017-01-06 20:58:25 +00:00
Eric Fiselier 00f6beaed4 [libc++] Cleanup and document <__threading_support>
Summary:
This patch attempts to clean up the macro configuration mess in `<__threading_support>`, specifically the mess involving external threading variants. Additionally this patch adds design documentation for `<__threading_support>` and the configuration macros it uses.

The primary change in this patch is separating the idea of an "external API" provided by `<__external_threading>` and the idea of having an external threading library. Now `_LIBCPP_HAS_THREAD_API_EXTERNAL` means that libc++ should use `<__external_threading>` and that the header is expected to exist.  Additionally the new macro `_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL` is now used to configure for using an "external library"  with the default threading API.

Reviewers: compnerd, rmaprath

Subscribers: smeenai, cfe-commits, mgorny

Differential Revision: https://reviews.llvm.org/D28316

llvm-svn: 291275
2017-01-06 20:05:40 +00:00
Eric Fiselier 945d79ad8b Add gcc-[56] clang-3.[678] to list of XFAILS for variant tests. Patch from Michael Park
llvm-svn: 291094
2017-01-05 09:06:30 +00:00
Eric Fiselier fc9859b4ae Use C++11 static_assert in variant tests. Patch from Michael Park
llvm-svn: 291093
2017-01-05 09:03:43 +00:00
Eric Fiselier 72c5d90a05 Get tests linking on Windows.
This patch is a temporary hack to get the tests passing on
Windows.

llvm-svn: 291091
2017-01-05 08:07:17 +00:00
Eric Fiselier c1d5d110a1 Fix test suite configuration when no lit.site.cfg is available
llvm-svn: 291081
2017-01-05 05:18:37 +00:00
Eric Fiselier 4372f06d0f Get test-suite configuring on Windows with clang-cl
This patch gets the test suite "working" on Windows, although
none of the tests pass.

In order to reuse the existing configuration, which uses UNIX
style flags not accepted by clang-cl, this patch only works with clang++.
When clang-cl is specified the test harness secretly looks for
clang++ and then it configures it using the INCLUDE and LIB enviroment
variables.

This is very much a work in progress.

llvm-svn: 291072
2017-01-05 03:57:40 +00:00
Eric Fiselier 07aaf62a0f Fix XPASS buildbot failure related to structured bindings
The test was previously set to XFAIL if __cpp_structured_bindings
wasn't defined. However there are Clang 4.0 versions which do not
define this macro but do provide structured bindings, which causes
the test to pass unexpectedly.

This patch changes the XFAIL to an UNSUPPORTED.

llvm-svn: 291060
2017-01-05 01:34:14 +00:00
Eric Fiselier 76a01ea34d Fix PR26961 - Add default constructor to std::pointer_safety struct.
In ABI v1 libc++ implements std::pointer_safety as a class type instead
of an enumeration. However this class type does not provide
a default constructor as it should. This patch adds that default constructor.

llvm-svn: 291059
2017-01-05 01:28:40 +00:00
Eric Fiselier 528600c41f Fix std::pointer_safety type in ABI v2
In the C++ standard `std::pointer_safety` is defined
as a C++11 strongly typed enum. However libc++ currently defines
it as a class type which simulates a C++11 enumeration. This
can be detected in valid C++ code.

This patch introduces an the _LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE ABI option.
When defined `std::pointer_safety` is implemented as an enum type.
Unfortunatly this also means it can no longer be provided as an extension
in C++03.

Additionally this patch moves the definition for `get_pointer_safety()`
out of the dylib, and into the headers. New usages of `get_pointer_safety()`
will now use the inline version instead of the dylib version. However in
order to keep the dylib ABI compatible the old definition is explicitly
compiled into it.

llvm-svn: 291046
2017-01-05 01:15:42 +00:00
Eric Fiselier a00db36b86 Fix verify test on 32 bit systems
llvm-svn: 291031
2017-01-04 23:30:06 +00:00
Marshall Clow dbf7ca9ce6 Implement P0505: 'Wording for GB 50'
llvm-svn: 291028
2017-01-04 23:03:24 +00:00
Eric Fiselier 9e17df95d4 Use C++11 static_assert in variant tests. Patch from Michael Park
llvm-svn: 291021
2017-01-04 22:43:08 +00:00
Eric Fiselier cb0d4df974 [libcxx] Re-implement LWG 2770 again: Fix tuple_size to work with structured bindings
Summary:
This patch attempts to re-implement a fix for LWG 2770, but not the actual specified PR. 

The PR for 2770 specifies tuple_size<T const> as only conditionally providing a `::value` member. However C++17 structured bindings require `tuple_size<T const>` to be complete only if  `tuple_size<T>` is also complete. Therefore this patch implements only provides the specialization `tuple_size<T CV>` iff `tuple_size<T>` is a complete type.

This fixes http://llvm.org/PR31513.

Reviewers: mclow.lists, rsmith, mpark

Subscribers: mpark, cfe-commits

Differential Revision: https://reviews.llvm.org/D28222

llvm-svn: 291019
2017-01-04 22:38:46 +00:00
Marshall Clow 020b623a3b Implement the last bit of P0031: 'A Proposal to Add Constexpr Modifiers to reverse_iterator, move_iterator, array and Range Access' for C++17
llvm-svn: 290976
2017-01-04 17:58:17 +00:00
Stephan T. Lavavej e28ab799b2 [libcxx] [test] Strip trailing whitespace.
Fixes D27786.

llvm-svn: 290922
2017-01-04 00:53:41 +00:00
Stephan T. Lavavej e01b1eff59 [libcxx] [test] Fix recently introduced warnings emitted by MSVC.
These tests were using malloc()'s return value without checking for null,
which MSVC's /analyze rightly warns about. Asserting that the pointer is
non-null both expresses the test's intention and silences the warning.

Fixes D27785.

llvm-svn: 290921
2017-01-04 00:53:31 +00:00
Asiri Rathnayake 205d7d3f68 [libcxx] Add build/test support for the externally threaded libc++abi variant
Differential revision: https://reviews.llvm.org/D27576

Reviewers: EricWF
llvm-svn: 290889
2017-01-03 12:59:50 +00:00
Asiri Rathnayake 6cb0d41cc8 [libcxx] Fix testing of the externally-threaded library build
after r290850

Before r290850, building libcxx with -DLIBCXX_HAS_EXTERNAL_THREAD_API=ON had two
uses:
  - Allow platform vendors to plug-in an __external_threading header which
    should take care of the entire threading infrastructure of libcxx

  - Allow testing of an externally-threaded library build; where the thread API
    is declared using pthread data structures, and the implementation of this
    API is provided as a separate library (test/support/external_threads.cpp)
   and linked-in when running the test suite.

r290850 breaks the second use case (pthread data structures are no longer
available). This patch re-stores the ability to build+test an
externally-threaded library variant on a pthread based system.

llvm-svn: 290878
2017-01-03 11:32:31 +00:00
Saleem Abdulrasool 790e10f6df threading_support: refactor for Win32 threading
Refactor the header to allow us to implement alternate threading models
with alternate data structures.  Take the opportunity to clang-format
the area.  This will allow us to avoid re-declaring the interfaces for
Win32 threading.  NFC

llvm-svn: 290850
2017-01-03 02:00:31 +00:00
Eric Fiselier 1285e4d60e Recommit r290839 - Fix configuring and building libc++ w/o an ABI library.
This patch re-commits a previous attempt to support building libc++ w/o
an ABI library. That patch was originally reverted because:

1) It forgot to teach the test suite about "default" ABI libraries.

2) Some LLVM builders don't clear the CMake cache between builds. The previous
   patch caused those builders to fail since their old cache entry for
   LIBCXX_CXX_ABI="" is no longer valid.

The updated patch addresses both issues. It works around (2) by adding
a hack to force the builders to update their cache entries. The hack will
be removed shortly once all LLVM builders have run.

Original commit message
-----------------------

Typically libc++ uses libc++abi or libcxxrt to provide the ABI and runtime bits
of the C++ STL. However we also support building w/o an ABI library entirely.
This patch fixes building libc++ w/o an ABI library (and incorporates the
`~type_info()` fix in D28211).

The main changes in this patch are:

1) Add `-DLIBCXX_CXX_ABI=default` instead of using the empty string to mean "default".
2) Fix CMake bits which treated "none" as "default" on OS X.
3) Teach the source files to respect `-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY`.
4) Define ~type_info() when _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY is defined.

Unfortunately this patch doesn't help clean up the macro mess that we use to
configure for different ABI libraries.

llvm-svn: 290849
2017-01-03 01:18:48 +00:00
Eric Fiselier 1013fe3c0c Re-implement LWG 2770 - Fix tuple_size with structured bindings.
This patch implements the correct PR for LWG 2770. It also makes the primary
tuple_size template incomplete again which fixes part of llvm.org/PR31513.

llvm-svn: 290846
2017-01-02 23:54:13 +00:00
Marshall Clow 3c5a60329b Fix some 'FIXME's in the tests.
llvm-svn: 290758
2016-12-30 17:42:11 +00:00
Eric Fiselier 1b06dfe7b7 Recommit r290750: Fix PR19460 - std::ios is convertible to int.
There were two problems with the initial fix.

1. The added tests flushed out that we misconfigured _LIBCPP_EXPLICIT with GCC.

2. Because the boolean type was a member function template it caused weird link
   errors. I'm assuming due to the vague linkage rules. This time the bool type
   is a non-template member function pointer. That seems to have fixed the
   failing tests. Plus it will end up generating less symbols overall, since
   the bool type is no longer per instantiation.

original commit message below
-----------------------------

std::basic_ios has an operator bool(). In C++11 and later
it is explicit, and only allows contextual implicit conversions.

However explicit isn't available in C++03 which causes std::istream (et al)
to have an implicit conversion to int. This can easily cause ambiguities
when calling operator<< and operator>>.

This patch uses a "bool-like" type in C++03 to work around this. The
"bool-like" type is an arbitrary pointer to member function type. It
will not convert to either int or void*, but will convert to bool.

llvm-svn: 290754
2016-12-30 14:05:52 +00:00
Eric Fiselier 03226c5e06 Revert r290750 - Fix PR19460 - std::ios is convertible to int.
llvm-svn: 290752
2016-12-30 13:11:17 +00:00
Eric Fiselier 46d95400f4 Add missing include in test.
llvm-svn: 290751
2016-12-30 12:45:30 +00:00
Eric Fiselier 2131a71c05 Fix PR19460 - std::ios is convertible to int.
std::basic_ios has an operator bool(). In C++11 and later
it is explicit, and only allows contextual implicit conversions.

However explicit isn't available in C++03 which causes std::istream (et al)
to have an implicit conversion to int. This can easily cause ambiguities
when calling operator<< and operator>>.

This patch uses a "bool-like" type in C++03 to work around this. The
"bool-like" type is an arbitrary pointer to member function type. It
will not convert to either int or void*, but will convert to bool.

llvm-svn: 290750
2016-12-30 12:44:58 +00:00
Ed Schouten 0a92402436 Remove mblen(), mbtowc() and wctomb() from the thread-unsafe functions.
Back in r240527 I added a knob to prevent thread-unsafe functions from
being exposed. mblen(), mbtowc() and wctomb() were also added to this
list, as the latest issue of POSIX doesn't require these functions to be
thread-safe.

It turns out that the only circumstance in which these functions are not
thread-safe is in case they are used in combination with state-dependent
character sets (e.g., Shift-JIS). According to Austin Group Bug 708,
these character sets "[...] are mostly a relic of the past and which
were never supported on most POSIX systems".

Though in many cases the use of these functions can be prevented by
using the reentrant counterparts, they are the only functions that allow
you to query whether the locale's character set is state-dependent. This
means that omitting these functions removes actual functionality.

Let's be a bit less pedantic and drop the guards around these functions.

Links:
http://austingroupbugs.net/view.php?id=708
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2037.htm

Reviewed by:	ericwf
Differential Revision:	https://reviews.llvm.org/D21436

llvm-svn: 290748
2016-12-30 10:44:00 +00:00
Eric Fiselier abf424334d Get ctype_byname tests passing on Linux.
llvm-svn: 290746
2016-12-30 09:28:58 +00:00
Eric Fiselier d566c34526 Fix PR31489 - std::function self-swap segfaults
llvm-svn: 290721
2016-12-29 20:03:55 +00:00
Eric Fiselier 2e519579f7 Fix debug mode for vector/list and cleanup tests
llvm-svn: 290657
2016-12-28 06:06:09 +00:00
Eric Fiselier 780b51df1d Add tests for unordered container tests and std::string
llvm-svn: 290655
2016-12-28 05:53:01 +00:00
Eric Fiselier c842c8d88c Fix build errors in C++03 caused by recent debug changes
llvm-svn: 290653
2016-12-28 05:26:56 +00:00
Eric Fiselier 687d3213f0 Implement a throwing version of _LIBCPP_ASSERT.
This patch implements changes to allow _LIBCPP_ASSERT to throw on failure
instead of aborting. The main changes needed to do this are:

1. Change _LIBCPP_ASSERT to call a handler via a replacable function pointer
   instead of calling abort directly. Additionally this patch implements two
   handler functions, one which aborts and another that throws an exception.

2. Add _NOEXCEPT_DEBUG macro for disabling noexcept spec on function which
   contain _LIBCPP_ASSERT. This is required in order to prevent assertion
   failures throwing through a noexcept function. This macro has no effect
   unless _LIBCPP_DEBUG_USE_EXCEPTIONS is defined.

Having a non-aborting _LIBCPP_ASSERT is very important to allow sane testing of
debug mode. Currently we can only have one test case per file, since the test
case will cause the program to abort. Testing debug mode this way would require
thousands of test files, most of which would be 95% boiler plate. I don't think
this is a feasible strategy. Fortunately using a throwing debug handler solves
these issues.

Additionally this patch rewrites the documentation for debug mode.

llvm-svn: 290651
2016-12-28 04:58:52 +00:00
Eric Fiselier 14b1bcc14b Implement P0435R1 - Resolving LWG issues for common_type
llvm-svn: 290627
2016-12-27 21:16:48 +00:00
Eric Fiselier b6d0b83cd2 Fix PR31481 - 3+ parameter common_type isn't SFINAE friendly
llvm-svn: 290624
2016-12-27 19:59:50 +00:00
Marshall Clow da520dcbeb Fix bug #31387 - not checking end iterator when parsing decimal escape. Thanks to Karen for the report.
llvm-svn: 290500
2016-12-24 17:21:03 +00:00
Eric Fiselier dee07a6a9f Enable -Wunreachable-code and fix duplicate warning flags
llvm-svn: 290486
2016-12-24 04:34:33 +00:00
Eric Fiselier db0931880a Fix ASAN test failure
llvm-svn: 290482
2016-12-24 03:27:52 +00:00