Commit Graph

3735 Commits

Author SHA1 Message Date
Justin Bogner 603715c66b Adorn __call_once_proxy with `inline` and `_LIBCPP_INLINE_VISIBILITY`
As per discussion with mclow and EricWF on irc, this is small and
simple enough to deserve being inlined.

llvm-svn: 291497
2017-01-09 23:07:12 +00:00
Marshall Clow 04b9853a97 Swap two lines in __mutex_base. On systems with high clock rates, we could mistakenly return no_timeout when a mutex had timed out if we got a tick between these two lines. Thanks to Brian Cain for the bug report.
llvm-svn: 291492
2017-01-09 22:32:11 +00:00
Dimitry Andric 082fa545cc Move _PairT declaration out of __hash_combine to avoid warning under C++98
Summary:
Some parts of the FreeBSD tree are still compiled with C++98, and until
rL288554 this has always worked fine.  After that, a complaint about the
newly introduced local _PairT is produced:

    /usr/include/c++/v1/memory:3354:27: error: template argument uses local type '_PairT' [-Werror,-Wlocal-type-template-args]
        typedef __scalar_hash<_PairT> _HashT;
                              ^~~~~~
    /usr/include/c++/v1/memory:3284:29: error: template argument uses local type '_PairT' [-Werror,-Wlocal-type-template-args]
        : public unary_function<_Tp, size_t>
                                ^~~
    /usr/include/c++/v1/memory:3356:12: note: in instantiation of template class 'std::__1::__scalar_hash<_PairT, 2>' requested here
        return _HashT()(__p);
               ^

As far as I can see, there should be no problem moving the _PairT
struct to just before the __hash_combine() function, which fixes this
particular warning.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits, emaste

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

llvm-svn: 291476
2017-01-09 20:29:35 +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
Bruno Cardoso Lopes e542373920 [Chrono][Darwin] Make steady_clock use CLOCK_UPTIME_RAW
Use CLOCK_UPTIME_RAW in case clock_gettime is available on Darwin.

On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able
to time functions in the nanosecond range. Thus, they are the only
acceptable implementations of steady_clock.

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

rdar://problem/29449467

llvm-svn: 291466
2017-01-09 19:21:48 +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
Asiri Rathnayake b71c89913c [libcxx] Fix externally-threaded shared library builds after r291275.
Need to allow unresolved symbols in the dylib. This was previously done for
LIBCXX_HAS_EXTERNAL_THREAD_API, but we have since split that into two with
LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY being the externally-threaded variant.

Also a minor CMakeLists.txt cleanup.

llvm-svn: 291433
2017-01-09 10:38:56 +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
Michael Park f62eb6b29a Added "Michael Park" to `CREDITS.TXT`.
Summary: Test commit + give myself credit.

Reviewers: EricWF

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

llvm-svn: 291344
2017-01-07 10:19:24 +00:00
Eric Fiselier 956604fed5 [libc++] Implement terminate(), unexpected() and uncaught_exceptions() on Windows
Summary:
This patch implements the following functions on Windows by forwarding to the MSVCRT:

* `get_terminate()`
* `set_terminate()`
* `terminate()`
* `set_unexpected()`
* `get_unexpected()`
* `unexpected()`
* `uncaught_exception()`

* `uncaught_exceptions()`

Reviewers: compnerd, rnk, majnemer, smeenai

Subscribers: cfe-commits

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

llvm-svn: 291343
2017-01-07 10:04:40 +00:00
Eric Fiselier 72771139f1 Ensure Sleep(...) isn't passed the value 0 on Windows
llvm-svn: 291342
2017-01-07 09:53:28 +00:00
Eric Fiselier a7234f1a60 Explicitly specify MSVC mangling of iostream globals. Patch from Dave Lee
llvm-svn: 291337
2017-01-07 06:09:12 +00:00
Saleem Abdulrasool 49a10e1c07 system_error: correct ELAST emulation on Windows
ELAST should point to the last valid error string value.  However,
`_sys_nerr` provides the number of elements in the errlist array.  Since
the index is 0-based, this is off-by-one.  Adjust it accordingly.

Thanks to David Majnemer for catching this!

llvm-svn: 291336
2017-01-07 05:13:32 +00:00
Saleem Abdulrasool 6d7d0bec10 provide Win32 native threading
Add an implementation for the Win32 threading model as a backing API for
the internal c++ threading interfaces.  This uses the Fls* family for
the TLS (which has the support for adding termination callbacks),
CRITICAL_SECTIONs for the recursive mutex, and Slim Reader/Writer locks
(SRW locks) for non-recursive mutexes.  These APIs should all be
available on Vista or newer.

llvm-svn: 291333
2017-01-07 03:07:45 +00:00
Eric Fiselier cd71f447b7 [libc++] Tolerate presence of __deallocate macro
Summary:
On Windows the identifier `__deallocate` is defined as a macro by one of the Windows system headers. Previously libc++ worked around this by `#undef __deallocate` and generating a warning. However this causes the WIN32 version of `__threading_support` to always generate a warning on Windows. This is not OK.

This patch renames all usages of `__deallocate` internally as to not conflict with the macro.

Reviewers: mclow.lists, majnemer, rnk, rsmith, smeenai, compnerd

Subscribers: cfe-commits

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

llvm-svn: 291332
2017-01-07 03:01:24 +00:00
Saleem Abdulrasool deaceefc4b thread: implement sleep_for on Windows
Windows does not provide an implementation of `nanosleep`.  Round up the
time duration to the nearest ms and use `Sleep`.  Although this may
over-sleep, there is no hard real-time guarantee on the wake, so
sleeping a bit more is better than under-sleeping as it within the
specification.

llvm-svn: 291331
2017-01-07 02:48:30 +00:00
Shoaib Meenai 1b0bda3310 [libc++] Correct macro name in documenation
The macro is named `_LIBCPP_TEMPLATE_VIS`, not `_LIBCPP_TEMPLATE_ONLY`.
No functional change.

llvm-svn: 291330
2017-01-07 02:45:35 +00:00
Eric Fiselier 330fe0170f Add _LIBCPP_ABI_[ITANIUM|MICROSOFT] macros.
This patch adds a libc++ configuration macro for the ABI we
are targeting, either Itanium or Microsoft. For now we configure
for the Microsoft ABI when on Windows with a compiler that defines
_MSC_VER. However this is only temporary until Clang implements
builtin macros we can use.

llvm-svn: 291329
2017-01-07 02:43:58 +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 937c74cdab Configure default ABI library as NONE on Windows
llvm-svn: 291306
2017-01-06 23:59:52 +00:00
Eric Fiselier 72cffa5583 Fix breakage caused when _LIBCPP_HAS_THREAD_API_PTHREAD is manually defined
llvm-svn: 291298
2017-01-06 23:15:16 +00:00
Eric Fiselier 541f9e2830 Add _LIBCPP_COMPILER_[CLANG|GCC|MSVC|IBM] macros.
This patch refactors the compiler detection done in `__config` by creating a
set of `_LIBCPP_COMPILER_<TYPE>` macros. The goal of this patch is to make
it easier to detect what compiler is being used outside of `__config`.

Additionally this patch removes workarounds for GCC in `__bit_reference`. I
tested GCC 4.8 and 4.9 without the workaround and neither seemed to need it
anymore.

llvm-svn: 291286
2017-01-06 21:42:58 +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
Saleem Abdulrasool caabc1be3b config_elast: fix typo (NFC)
Missed the original typo which was duplicated.  NFC.

llvm-svn: 291192
2017-01-05 23:25:44 +00:00
Saleem Abdulrasool 9075622d58 typeinfo: style adjustments for adding MS ABI RTTI
This is motivated by adding a third RTTI scheme to libc++.  Split out
the two forms of the itanium RTTI representation.  This is based on
suggestions from Eric Fiselier.  NFC

llvm-svn: 291174
2017-01-05 21:22:22 +00:00
Saleem Abdulrasool 58a0dcee80 thread_support: split out {,non-}recursive mutex
Split out the recursive and non-recursive mutex.  This split is needed
for platforms which may use differing types for the two mutex (e.g.
Win32 threads).

llvm-svn: 291145
2017-01-05 17:54:45 +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 cb5cbc8b66 [libcxx] Fix PR31402: map::__find_equal_key has undefined behavior.
Summary:
This patch fixes llvm.org/PR31402 by replacing `map::__find_equal_key` with `__tree::__find_equal`, which has already addressed the same undefined behavior.

Unfortunately I haven't been able to write a test case which causes the UBSAN diagnostic mentioned in the bug report. I can write tests which exercise the UB but for some reason they do not cause UBSAN to fail. Any help writing a test case would be appreciated.


Reviewers: mclow.lists, vsk, EricWF

Subscribers: cfe-commits

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

llvm-svn: 291087
2017-01-05 06:06:18 +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
Richard Smith 564cba9bc3 PR31540: install libc++abi headers into include/c++/v1 in build area.
This allows an in-build-area clang binary to find <cxxabi.h>.

llvm-svn: 291065
2017-01-05 02:55:10 +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 011508d529 Fix Sphinx build error caused by bad indentation
llvm-svn: 291039
2017-01-05 00:04:37 +00:00
Eric Fiselier e2f2d1edef [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS
The name _LIBCPP_TYPE_VIS_ONLY is no longer accurate because both
_LIBCPP_TYPE_VIS and _LIBCPP_TYPE_VIS_ONLY expand to
__attribute__((__type_visibility__)) with Clang. The only remaining difference
is that _LIBCPP_TYPE_VIS_ONLY can be applied to templates whereas
_LIBCPP_TYPE_VIS cannot (due to dllimport/dllexport not being allowed on
templates).

This patch renames _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS.

llvm-svn: 291035
2017-01-04 23:56:00 +00:00
Eric Fiselier e5b41f7ccf Fix private inheritance in C++03 tuple_size
llvm-svn: 291032
2017-01-04 23:35:51 +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
Saleem Abdulrasool 6039656441 fix elast configuration on Windows targets
A typo and missing header inclusion was obscured by the litany of user
defined literal warnings.  This fixes the detection of ELAST on windows.

llvm-svn: 290941
2017-01-04 05:50:01 +00:00
Saleem Abdulrasool 07b65ed040 config: MSVC 19+ has unicode chars
MSVC 19+ and clang-cl with emulation version >= 19.00 will provide
char{16,32}_t as builtin types.  Adjust the configuration accordingly.

llvm-svn: 290940
2017-01-04 05:49:59 +00:00
Saleem Abdulrasool f1ae11a4f0 build: use the platform dependent library prefix/suffix
Use the cmake variables to get the platform dependent values for the
static library prefix and suffix, which can be different from the Unix
preference for "lib", ".a" (e.g. Windows uses "", ".lib" respectively).

llvm-svn: 290939
2017-01-04 05:49:57 +00:00
Saleem Abdulrasool 99c19ada66 build: use more portable spelling for flag
Use `CMAKE_LIBRARY_PATH_FLAG` instead of hard-coding it to -L.  This
silences a warning with cl which expects `/LIBPATH` instead.

llvm-svn: 290938
2017-01-04 05:49:55 +00:00
Saleem Abdulrasool 86eebc5b65 Refactor bitscan64 check
Introduce a `_LIBCPP_HAS_BITSCAN64` macro to specify if the 64-bit
variant of the bitscan family of APIs is available.  This avoids
duplicating the check in the support header.

llvm-svn: 290924
2017-01-04 01:53:24 +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
Saleem Abdulrasool b2826a1ddc clean up use of _WIN32
Replace the use of _WIN32 in libc++. Replace most use with a C runtime
check _LIBCPP_MSVCRT or the new _LIBCPP_WIN32 to indicate that we are
using the Win32 API. Use a new _LIBCPP_WCHAR_IS_UCS2 to indicate that we
are on an environment that has a short wchar_t.

llvm-svn: 290910
2017-01-03 21:53:51 +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
Eric Fiselier 649dcec527 Update year to 2017
llvm-svn: 290876
2017-01-03 11:20:43 +00:00
Eric Fiselier a0a61faad1 Simplify CMake target for the __generated_config header
llvm-svn: 290875
2017-01-03 11:18:17 +00:00
Saleem Abdulrasool 720fb14cdd clang-format: tweak configuration
Update the configuration to reflect the style more accurately.  Pointers
are tied to the left.  Braces are split on classes/structs and
functions.

llvm-svn: 290857
2017-01-03 04:23:52 +00:00
Saleem Abdulrasool 833094463c build: remove now unused UNIX_CAT
THe previous change replaced the use of `cat` or `type` with a custom
python script.  Remove the now unused command determining.

llvm-svn: 290856
2017-01-03 04:23:50 +00:00
Eric Fiselier 887894aaef Fix creating __generated_config on Windows
llvm-svn: 290853
2017-01-03 03:55:29 +00:00
Saleem Abdulrasool edd09b3db2 system_error: provide a thread safe stringification for Windows
Provide a strerror_r replacement for Windows.  This is needed to build
libc++ for Windows with threading.

llvm-svn: 290851
2017-01-03 02:00:33 +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
Eric Fiselier 9877c1e713 Fix use of throw(...) spec with GCC in C++17
llvm-svn: 290845
2017-01-02 23:27:42 +00:00
Eric Fiselier 221596df33 Revert r290839 - Fix configuring and building libc++ w/o an ABI library
llvm-svn: 290841
2017-01-02 22:27:45 +00:00
Eric Fiselier 9aca97d6f9 Introduce _LIBCPP_DEPRECATED_ABI_EXTERNAL_ERROR_CATEGORY_CONSTRUCTOR ABI option.
Currently libc++ compiles a special version of error_category()
into the dylib. This definition is no longer needed, and doesn't
work on Windows due to dllimport/dllexport semantics.

For those reasons this patch introduces an option to
disable/enable this definition. By default the definition
is provided in ABI v1 except on windows. This patch
also addresses D28210.

llvm-svn: 290840
2017-01-02 22:17:51 +00:00
Eric Fiselier 5d25843f66 Fix configuring and building libc++ w/o an ABI library.
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: 290839
2017-01-02 21:58:06 +00:00
Saleem Abdulrasool 58729cd53e build: tweak macros for Windows build
Move the windows specific macro definitions for compiling c++ into the
target.  Add a number of newer options that are necessary to properly
build libc++ for windows.  This ensures that we do not accidentally
autolink msvcprt (Microsoft's C++ runtime library), do not define linker
pragmas which are msvcprt specific, and do not accidentally encode the
incorrect version of the msvc compatibility version.

llvm-svn: 290837
2017-01-02 21:40:17 +00:00
Saleem Abdulrasool 2d2ed1cc47 build: make cross-compiling to Windows work on Linux
Disable the manifest bundling on Windows when cross-compiling on
not-Windows.  With this, it is possible to execute the link command from
CMake which will use cmake to invoke the manifest tool to generate a
manifest and pass that to the linker.

llvm-svn: 290836
2017-01-02 21:09:19 +00:00
Saleem Abdulrasool 11c0c53367 win32: temporarily disable setting locale on 14+
The locale structures have been made opaque in CRT 14+.  This currently
prevents building libc++ for Windows.  We can re-enable this in the
future when we have replicated the structure to access the private field
for the name (unless there exists a better supported mechanism to query
the name of a locale given the locale_t).

llvm-svn: 290835
2017-01-02 21:09:16 +00:00
Eric Fiselier e9735f17e0 Rework fix for PR19460 - Use explicit bool as an extension instead.
In the previous fix I used a PMF type as a semi-safe bool type in C++03.
However immediately after committing I realized clang offered explicit
conversion operators as an extension. This patch removes the old fix and
enables _LIBCPP_EXPLICIT using __has_extension instead.

This change also affects the following other classes, which have
'_LIBCPP_EXPLICIT operator bool()'.

* shared_ptr
* unique_ptr
* error_condition
* basic_ios
* function (already C++11 only)
* istream::sentry
* experimental::string_view.

In all of the above cases I believe it is safe to enable the extension, except
in the experimental::string_view case. There seem to be some Clang bugs
affecting the experimental::string_view conversion to std::basic_string. To
work around that I manually disabled _LIBCPP_EXPLICIT in that case.

llvm-svn: 290831
2017-01-02 20:15:33 +00:00
Saleem Abdulrasool d1c346a43b chrono: correct the units for the epoch bias
As pointed out by Howard, this is actually 134774 days (* 24 * 3600),
and therefore seconds, not 100ns units.  Adjust the units to reflect
reality.

llvm-svn: 290824
2017-01-02 18:41:50 +00:00
Saleem Abdulrasool 8bcade547a locale: update ctype access for MSVC CRT 14+
Visual C++ 14 and newer split msvcrt into msvcrt and ucrt with flavours
of the ucrt for different environments.  This changed the access to the
ctype table by introducing the `__pctype_func` and `__pwctype_func`
accessors.  Use this rather than directly accessing `_ctype` which
allows us to be safer in threaded situations by going through the libc
locking.

llvm-svn: 290823
2017-01-02 18:41:48 +00:00
Saleem Abdulrasool e91473c3c0 chrono: address post commit comments from Howard
Drawing some inspiration from code from Bill O'Neal as pointed out by
Howard, rework the code to avoid an overflow in the duration.  Adjust
the style to match libc++ style as well.

Create a local typedef for the FILETIME duration (100-ns units).  Use
this to define the difference between the NT and the UNIX epochs (which
previously overflowed due to the representation limits due to the
bouncing to ns).  Return the FILETIME duration biased by the NT-to-UNIX
epoch conversion.

Use of the custom duration makes it easier to read and reason about the
code.

llvm-svn: 290806
2017-01-01 22:04:38 +00:00
Saleem Abdulrasool cfc01154c3 chrono: address post-commit comments from majnemer
Correct style to match libc++ style as pointed out by David Majnemer on
IRC.  NFC.

llvm-svn: 290805
2017-01-01 22:04:36 +00:00
Saleem Abdulrasool 78f51f95a4 chrono: give Windows a steady_clock
Provide a definition for a steady monotonic clock by wrapping
QueryPerformanceCounter.

llvm-svn: 290804
2017-01-01 20:20:43 +00:00
Saleem Abdulrasool 6e3a0cc404 chrono: implement a Windows version of system_clock::now
system_clock::now is not entirely straight forward on Windows, which
does not have a clock_gettime function.

GetSystemTimeAsFileTime gives us the value relative to the NT epoch (Jan
1 1601) rather than the Unix epoch (Jan 1 1970).  However, this function
has a low resolution (~10ms).  Newer versions of Windows provide
GetSystemTimePreciseAsFileTime which gives us a much more accurate time
(<1us).  Unfortunately, the latter is only available on Windows 8+ when
targeting desktop apps.

llvm-svn: 290803
2017-01-01 20:20:41 +00:00
Saleem Abdulrasool 581bb5b9dd build: further improve flags handling for cl
This allows us to build with cl (or rather clang-cl) by using the
correct spelling for `-include` (`/FI` for cl).  clang-cl and cl default
to C++11/C++14 as they support it rather than permitting an explicit
language standard.

llvm-svn: 290802
2017-01-01 20:20:40 +00:00
Saleem Abdulrasool 9dde949199 build: dont detect libraries for Windows
Hard code the defaults for Windows for the time being.  The checks
really are always going to return the same value.  Technically, the
pthread linkage is possible, however, it seems better to use the Win32
threading along with the external threading support that we have added.

llvm-svn: 290801
2017-01-01 20:20:38 +00:00
Saleem Abdulrasool 61bce47e3b build: differentiate between building for and on Windows
This is necessary to support cross-compiling a Windows libc++ from
Linux.  The CMAKE_SYSTEM_HOST_NAME tells you what, in autotools
parlance, is known as the build as opposed to WIN32 which maps to, in
autotools parlance, host.

llvm-svn: 290800
2017-01-01 20:20:36 +00:00
Saleem Abdulrasool c8bf96182d system_error: use strerror_r only for threaded code
When building libc++ without threading, strerror_r is not used.  Define
the code only when threading is enabled.  This allows us to build
system_error for Windows, which ATM doesn't build with threading.

llvm-svn: 290791
2016-12-31 21:24:04 +00:00
Saleem Abdulrasool 2177f3ce5f clean up some qualifier casting
This cleans up the `-Wqual-cast` warnings from gcc 6 when building
libc++.  NFC.

llvm-svn: 290789
2016-12-31 18:13:34 +00:00
Saleem Abdulrasool 21711c451e remove some inherited attributes on exceptions
These exception types are marked with `_LIBCPP_EXCEPTION_ABI` which
expands to `__attribute__((__visibility__("default")))` or
`__declspec(dllexport)`.  When building for Windows, we would hit an
error:

    cannot apply 'dllexport' to a 'dllexport' class

Remove the duplicate annotations as they will be inherited from the
class.

llvm-svn: 290785
2016-12-31 17:34:26 +00:00
Saleem Abdulrasool 4a12eab828 random: include __config before building
We need to include __config to ensure that we know what random
implementation is being used.  Fixes compilation for Windows.

llvm-svn: 290775
2016-12-31 00:00:21 +00:00
Sebastian Pop 9070500633 improve performance of string::find
string::find used to call the generic algorithm ::find.  The patch special
case string::find such that it ultimately gets converted to calls to memchr
and memcmp.

The patch improves the performance of the string::find routine by about 20x.

Without the patch, the performance on an x86_64-linux 3400 MHz machine is:

Benchmark                           Time           CPU Iterations
-----------------------------------------------------------------
BM_StringFindNoMatch/10             4 ns          4 ns  166421326
BM_StringFindNoMatch/64            37 ns         37 ns   18754392
BM_StringFindNoMatch/512          268 ns        268 ns    2586060
BM_StringFindNoMatch/4k          2143 ns       2144 ns     328342
BM_StringFindNoMatch/32k        16910 ns      16917 ns      40623
BM_StringFindNoMatch/128k       67577 ns      67602 ns      10138
BM_StringFindAllMatch/1             3 ns          3 ns  265163471
BM_StringFindAllMatch/8             6 ns          6 ns  112582467
BM_StringFindAllMatch/64           36 ns         36 ns   19566457
BM_StringFindAllMatch/512         209 ns        209 ns    3318893
BM_StringFindAllMatch/4k         1618 ns       1618 ns     432963
BM_StringFindAllMatch/32k       12909 ns      12914 ns      54317
BM_StringFindAllMatch/128k      48342 ns      48361 ns      13922
BM_StringFindMatch1/1           33777 ns      33790 ns      20698
BM_StringFindMatch1/8           33940 ns      33953 ns      20619
BM_StringFindMatch1/64          34038 ns      34051 ns      20571
BM_StringFindMatch1/512         34217 ns      34230 ns      20480
BM_StringFindMatch1/4k          35510 ns      35524 ns      19752
BM_StringFindMatch1/32k         46438 ns      46456 ns      15030
BM_StringFindMatch2/1           33839 ns      33852 ns      20648
BM_StringFindMatch2/8           33950 ns      33963 ns      20594
BM_StringFindMatch2/64          33846 ns      33859 ns      20668
BM_StringFindMatch2/512         34023 ns      34036 ns      20279
BM_StringFindMatch2/4k          35422 ns      35436 ns      19716
BM_StringFindMatch2/32k         46570 ns      46588 ns      15027

With the patch applied

Benchmark                           Time           CPU Iterations
-----------------------------------------------------------------
BM_StringFindNoMatch/10             5 ns          5 ns  133724346
BM_StringFindNoMatch/64             6 ns          6 ns  119312184
BM_StringFindNoMatch/512           13 ns         13 ns   51539628
BM_StringFindNoMatch/4k            77 ns         77 ns    8935934
BM_StringFindNoMatch/32k          551 ns        551 ns    1222808
BM_StringFindNoMatch/128k        2684 ns       2685 ns     259957
BM_StringFindAllMatch/1             7 ns          7 ns   98017959
BM_StringFindAllMatch/8             7 ns          7 ns   91466911
BM_StringFindAllMatch/64            8 ns          8 ns   85707392
BM_StringFindAllMatch/512          20 ns         20 ns   34490895
BM_StringFindAllMatch/4k           93 ns         93 ns    7360375
BM_StringFindAllMatch/32k         827 ns        828 ns     829944
BM_StringFindAllMatch/128k       3593 ns       3594 ns     195815
BM_StringFindMatch1/1            1332 ns       1332 ns     516354
BM_StringFindMatch1/8            1336 ns       1336 ns     495876
BM_StringFindMatch1/64           1338 ns       1339 ns     516656
BM_StringFindMatch1/512          1357 ns       1357 ns     510717
BM_StringFindMatch1/4k           1485 ns       1486 ns     461228
BM_StringFindMatch1/32k          2235 ns       2236 ns     318253
BM_StringFindMatch2/1            1335 ns       1335 ns     517105
BM_StringFindMatch2/8            1336 ns       1337 ns     518004
BM_StringFindMatch2/64           1344 ns       1345 ns     511751
BM_StringFindMatch2/512          1361 ns       1361 ns     508150
BM_StringFindMatch2/4k           1611 ns       1611 ns     463388
BM_StringFindMatch2/32k          2187 ns       2187 ns     317532

Patch written by Aditya Kumar and Sebastian Pop.

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

llvm-svn: 290761
2016-12-30 18:01:36 +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 28727b81ef Update "Making Optional Greater Equal Again" paper status
llvm-svn: 290742
2016-12-30 04:16:30 +00:00
Eric Fiselier 8604783a3f Fix build using the buildit script
llvm-svn: 290727
2016-12-29 22:42:45 +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 99940720c8 Fix typo in comment
llvm-svn: 290666
2016-12-28 11:09:18 +00:00
Eric Fiselier b9565705bd Fix ABI incompatible C++03 nullptr_t
In C++03 libc++ emulates nullptr_t using a class, and #define's nullptr.
However this makes nullptr_t mangle differently between C++03 and C++11.
This breaks any function ABI which takes nullptr_t.

Thanfully Clang provides __nullptr in all dialects. This patch adds
an ABI option to switch to using __nullptr in C++03. In a perfect world
I would like to turn this on by default, since it's just ABI breaking fix
to an ABI breaking bug.

llvm-svn: 290662
2016-12-28 09:50:23 +00:00
Eric Fiselier 873c275caa Remove dead debug_mode doc link
llvm-svn: 290659
2016-12-28 06:21:09 +00:00
Eric Fiselier d5ae0257f2 Ensure <__debug> gets the nullptr definition in C++03
llvm-svn: 290658
2016-12-28 06:15:01 +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 8dd73d8e06 Fix stupid build error caused by a stupid person
llvm-svn: 290656
2016-12-28 05:56:16 +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 14bd0bf008 Fix __wrap_iter in debug mode and apply _NOEXCEPT_DEBUG to it
llvm-svn: 290654
2016-12-28 05:35:32 +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 ab768a85f6 Fix debug mode build w/o exceptions
llvm-svn: 290652
2016-12-28 05:20:27 +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
Shoaib Meenai fe1aacd014 [libc++] Make __num_get_float hidden
It's an internal function and shouldn't be exported. It's also a source
of discrepancy in the published ABI list; these symbols aren't exported
for me on CentOS 7 or Ubuntu 16.04, leading to spurious check-cxx-abilist
failures.

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

llvm-svn: 290503
2016-12-24 18:05:32 +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
Eric Fiselier e161f97b81 Fix -Wsign-compare warnings in re tests that only run on OS X
llvm-svn: 290481
2016-12-24 03:20:53 +00:00
Eric Fiselier b0bbd8aaaa Fix sign-compare warnings on ARM platforms caused by wchar_t being unsigned
llvm-svn: 290480
2016-12-24 03:09:00 +00:00
Eric Fiselier 82ad195ad5 Avoid unused warning in __throw_future_error w/o exceptions enabled
llvm-svn: 290479
2016-12-24 01:56:25 +00:00
Eric Fiselier 059b08a6b9 Fix warning caused by platforms providing a signed wint_t
llvm-svn: 290477
2016-12-24 01:43:54 +00:00
Eric Fiselier 2bc3471d40 Fix yet another missed -Wunused warning. Hopefully this is the last one
llvm-svn: 290476
2016-12-24 01:29:27 +00:00
Eric Fiselier a3f141113e Fix unused warning which only triggers in C++11
llvm-svn: 290475
2016-12-24 01:12:28 +00:00
Eric Fiselier 6a74f44873 fix warnings only produced by apple-clang
llvm-svn: 290474
2016-12-24 01:07:54 +00:00
Eric Fiselier 9eb96d5b08 Fix missed sign-compare warning
llvm-svn: 290473
2016-12-24 00:44:20 +00:00
Eric Fiselier 3777a33d71 fix newly failing c++03 tests
llvm-svn: 290472
2016-12-24 00:40:45 +00:00
Eric Fiselier 9e317127ad Fix another unused warning
llvm-svn: 290470
2016-12-24 00:28:19 +00:00
Eric Fiselier aec0878403 fix sign comparison warnings
llvm-svn: 290469
2016-12-24 00:24:44 +00:00
Eric Fiselier fd83822741 Fix unused parameters and variables
llvm-svn: 290459
2016-12-23 23:37:52 +00:00
Eric Fiselier 3e8353724b Don't use posix_memalign on Windows platforms
llvm-svn: 290448
2016-12-23 20:17:23 +00:00
Eric Fiselier 3f9b557ddd Fix PR31440: Make __sanitizer_annotate_contigious_container always visible. Fix from Jan Beich
llvm-svn: 290447
2016-12-23 20:03:52 +00:00
Eric Fiselier b778b51854 Update doc and various cleanup
llvm-svn: 290446
2016-12-23 20:00:13 +00:00
Eric Fiselier e4c941b57e Add test that _LIBCPP_VERSION matches __libcpp_version
llvm-svn: 290445
2016-12-23 19:38:43 +00:00
Eric Fiselier d8cb65611c Add release update instructions for libc++
llvm-svn: 290444
2016-12-23 19:30:24 +00:00
Eric Fiselier aaec00aed5 Update TestingLibcxx doc to reflect the use_system_cxx_lib flag. Patch from Michael Park
llvm-svn: 290441
2016-12-23 19:09:14 +00:00
Eric Fiselier 277799a2e9 Add apple-clang-8 to list of XFAILS for some variant tests. Patch from Michael Park
llvm-svn: 290440
2016-12-23 19:07:54 +00:00
Chris Bieneman ca7d19e595 [CMake] Fix issue reported on sanitizer bots
This should resolve an issue reported on the commit thread that impacted sanitizer bots.

llvm-svn: 290052
2016-12-17 21:28:24 +00:00
Chris Bieneman 6c29367330 [CMake] Put headers relative to clang
When libcxx isn't building with an installed LLVM we copy the libcxx headers into the LLVM build directory so that a clang in that build tree can find the headers relative to itself.

This is only important in situations where you don't have headers installed under /, which is common these days on Darwin.

llvm-svn: 289963
2016-12-16 17:30:51 +00:00
Eric Fiselier f34964bdd7 Fix XFAILS for is_trivially_destructible trait
llvm-svn: 289802
2016-12-15 11:00:07 +00:00
Eric Fiselier 7dfa62687c Fix typo
llvm-svn: 289781
2016-12-15 07:23:44 +00:00
Eric Fiselier f4d7c18628 Add tests for LWG 2796
llvm-svn: 289780
2016-12-15 07:15:39 +00:00
Eric Fiselier 3fede1c9c0 Add more test cases for PR31384
llvm-svn: 289778
2016-12-15 07:05:19 +00:00
Eric Fiselier 9ce1745464 Add test case for PR31384
llvm-svn: 289774
2016-12-15 06:38:07 +00:00
Eric Fiselier 347a1cc221 Revert r289727 due to PR31384
This patch reverts the changes to tuple which fixed construction from
types derived from tuple. It breaks the code mentioned in llvm.org/PR31384.
I'll follow this commit up with a test case.

llvm-svn: 289773
2016-12-15 06:34:54 +00:00
Eric Fiselier a0620a1c45 XFAIL test for more apple-clang versions
llvm-svn: 289767
2016-12-15 05:41:07 +00:00
Eric Fiselier 7cd166cdcc Work around bug in initialization of std::array base class with older clangs
llvm-svn: 289741
2016-12-14 23:24:12 +00:00
Eric Fiselier 5cac7755ab Fix PR31378 - std::list::remove should not require a default constructible allocator.
In list::remove we collect the nodes we're removing in a seperate
list instance. However we construct this list using the default
constructor which default constructs the allocator. However allocators
are not required to be default constructible. This patch fixes the
construction of the second list.

llvm-svn: 289735
2016-12-14 22:48:38 +00:00
Stephan T. Lavavej 286adee501 [libcxx] [test] Fix MSVC x64 truncation warnings with 32-bit allocator size_type/difference_type.
test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
Iterate with C::size_type because that's what operator[] takes.

test/std/containers/sequences/vector/contiguous.pass.cpp
test/std/strings/basic.string/string.require/contiguous.pass.cpp
Add static_cast<typename C::difference_type> because that's what the iterator's operator+ takes.

Fixes D27777.

llvm-svn: 289734
2016-12-14 22:46:46 +00:00
Eric Fiselier f8136d08c6 [libcxx] Fix tuple construction/assignment from types derived from tuple/pair/array.
Summary:
The standard requires tuple have the following constructors:
```
tuple(tuple<OtherTypes...> const&);
tuple(tuple<OtherTypes...> &&);
tuple(pair<T1, T2> const&);
tuple(pair<T1, T2> &&);
tuple(array<T, N> const&);
tuple(array<T, N> &&);
```
However libc++ implements these as a single constructor with the signature:
```
template <class TupleLike, enable_if_t<__is_tuple_like<TupleLike>::value>>
tuple(TupleLike&&);
```

This causes the constructor to reject types derived from tuple-like types; Unlike if we had all of the concrete overloads, because they cause the derived->base conversion in the signature.

This patch fixes this issue by detecting derived types and the tuple-like base they are derived from. It does this by creating an overloaded function with signatures for each of tuple/pair/array and checking if the possibly derived type can convert to any of them.

This patch fixes [PR17550]( https://llvm.org/bugs/show_bug.cgi?id=17550)

This patch 

Reviewers: mclow.lists, K-ballo, mpark, EricWF

Subscribers: cfe-commits

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

llvm-svn: 289727
2016-12-14 22:22:38 +00:00
Eric Fiselier a361aa3cc9 XFAIL test on apple-clang-7.0
llvm-svn: 289716
2016-12-14 21:44:08 +00:00
Eric Fiselier 4ffd08cae9 [libcxx] Fix PR24075, PR23841 - Add scoped_allocator_adaptor::construct(pair<T, U>*, ...) overloads.
Summary:
For more information see:

* https://llvm.org/bugs/show_bug.cgi?id=23841
* https://llvm.org/bugs/show_bug.cgi?id=24075

I hope you have as much fun reviewing as I did writing these insane tests!

Reviewers: mclow.lists, AlisdairM, EricWF

Subscribers: AlisdairM, Potatoswatter, cfe-commits

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

llvm-svn: 289710
2016-12-14 21:29:29 +00:00
Eric Fiselier fec6be9c81 Recommit r286884: P0503R0, adopted in Issaquah, rewords some requirements on nullptr_t and istream_iterator.
No code changes were needed, but I updated a few tests.
Also resolved P0509 and P0521, which required no changes to the library or tests.

This patch was reverted due to llvm.org/PR31016. There is a bug in Clang 3.7
which causes default.pass.cpp to fails. That test is now marked as XFAIL for that
clang version.

This patch was originally authored by Marshall Clow.

llvm-svn: 289708
2016-12-14 21:22:48 +00:00
Stephan T. Lavavej 105a3061f7 [libcxx] [test] Fix size_t-to-int truncation warnings in syserr.hash.
After r289363, these tests were triggering MSVC x64 warning C4267
"conversion from 'size_t' to 'int', possible loss of data" by taking 0, 2, and 10
as std::size_t, then constructing error_code(int, const error_category&) or
error_condition(int, const error_category&) from that (N4618 19.5.3.2
[syserr.errcode.constructors]/3, 19.5.4.2 [syserr.errcondition.constructors]/3).

The fix is simple: take these ints as int, pass them to the int-taking
constructor, and perform a value-preserving static_cast<std::size_t>
when comparing them to `std::size_t result`.

Fixes D27691.

llvm-svn: 289512
2016-12-13 01:54:58 +00:00
Stephan T. Lavavej 1738e9d649 [libcxx] [test] Change ifstream constructor tests to handle read-only files.
Certain source control systems like to set the read-only bit on their files,
which interferes with opening "test.dat" for both input and output.
Fortunately, we can work around this without losing test coverage.
Now, the ifstream.cons tests have comments referring to the ofstream.cons tests.
There, we're creating writable files (not checked into source control),
where the ifstream constructor tests will succeed.

Fixes D26814.

llvm-svn: 289463
2016-12-12 19:50:22 +00:00
Stephan T. Lavavej 14530fcb93 [libcxx] [test] Fix an improper assumption about Null Forward Iterators.
Value-initialized iterators still can't be compared to those with parents.

Fixes D26626.

llvm-svn: 289462
2016-12-12 19:50:14 +00:00
Petr Hosek 2a452ebf76 [libcxx][CMake] Move the warning to HandleOutOfTreeLLVM
This currently gives a warning when building libcxx under runtimes.

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

llvm-svn: 289418
2016-12-12 05:05:46 +00:00
Eric Fiselier bd3ad9ffb6 Actually re-disable -Wsign-compare
llvm-svn: 289367
2016-12-11 05:54:43 +00:00
Eric Fiselier 1eb8f253ae Re-disable -Wsign-compare for now. I didn't catch all occurrences
llvm-svn: 289366
2016-12-11 05:45:55 +00:00
Eric Fiselier c71bd55b5d Enable the -Wsign-compare warning to better support MSVC
llvm-svn: 289363
2016-12-11 05:31:00 +00:00
Eric Fiselier dc43d75ac0 Fix copy/paste errors introduced in r289358
llvm-svn: 289359
2016-12-11 04:00:26 +00:00
Eric Fiselier 1286bc577f Fix undefined behavior in container swap tests.
These swap tests were swapping non-POCS non-equal allocators which
is undefined behavior. This patch changes the tests to use allocators
which compare equal. In order to test that the allocators were not
swapped I added an "id" field to test_allocator which does not
participate in equality but does propagate across copies/swaps.

This patch is based off of D26623 which was submitted by STL.

llvm-svn: 289358
2016-12-11 03:41:12 +00:00
Eric Fiselier b639881878 Fix yet another dynamic exception spec
llvm-svn: 289357
2016-12-11 02:49:37 +00:00
Eric Fiselier 3ca4566452 Fix more uses of dynamic exception specifications in C++17
llvm-svn: 289356
2016-12-11 02:47:36 +00:00
Eric Fiselier e297b527a1 Fix count_new.hpp to work w/o dynamic exception specifications
llvm-svn: 289355
2016-12-11 02:20:17 +00:00
Eric Fiselier 0d542d350d [libc++] Fix support for multibyte thousands_sep and decimal_point in moneypunct_byname and numpunct_byname.
Summary:
The underlying C locales provide the `thousands_sep` and `decimal_point` as strings, possible with more than one character. We currently don't handle this case even for `wchar_t`.

This patch properly converts the mbs -> wide character for `moneypunct_byname<wchar_t>`. For the `moneypunct_byname<char>` case we attempt to narrow the WC and if that fails we also attempt to translate it to some reasonable value. For example we translate U00A0 (non-breaking space) into U0020 (regular space). If none of these conversions succeed then we simply allow the base class to provide a fallback value.


Reviewers: mclow.lists, EricWF

Subscribers: vangyzen, george.burgess.iv, cfe-commits

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

llvm-svn: 289347
2016-12-11 00:20:59 +00:00
Stephan T. Lavavej aec1876601 [libcxx] [test] Fix string_view tests.
test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp
Passing -1 to size_t triggers signed/unsigned mismatch warnings because it's
a value-modifying conversion. Add static_cast<size_t> to soothe the compiler.
(This file refers to size_t unqualified.)

test/std/strings/string.view/string.view.ops/substr.pass.cpp
Add <algorithm> for std::min() and <stdexcept> for std::out_of_range.

N4618 21.4.2.4 [string.view.access]/1: "Requires: pos < size()."
/4: "[ Note: Unlike basic_string::operator[], basic_string_view::operator[](size())
has undefined behavior instead of returning charT(). -end note ]"

Fixes D27633.

llvm-svn: 289283
2016-12-09 22:35:53 +00:00
Stephan T. Lavavej 8a597d653a [libcxx] [test] Add LIBCPP_ASSERT_NOEXCEPT/LIBCPP_ASSERT_NOT_NOEXCEPT, remove an unused variable.
test/support/test_macros.h
For convenience/greppability, add macros for libcxx-specific static_asserts about noexceptness.

(Moving the definitions of ASSERT_NOEXCEPT/ASSERT_NOT_NOEXCEPT isn't technically necessary
because they're macros, but I think it's better style to define stuff before using it.)

test/std/utilities/tuple/tuple.tuple/tuple.apply/apply.pass.cpp
There was a completely unused `TrackedCallable obj;`.

apply() isn't depicted with conditional noexcept in C++17.

test/std/utilities/tuple/tuple.tuple/tuple.apply/make_from_tuple.pass.cpp
Now that we have LIBCPP_ASSERT_NOEXCEPT, use it.

Fixes D27622.

llvm-svn: 289264
2016-12-09 19:53:08 +00:00
Eric Fiselier fb1fb81406 Update doc version to 4.0
llvm-svn: 289206
2016-12-09 12:33:49 +00:00
Eric Fiselier 642d9a1e48 [NFC] Change whitespace to force docs rebuild
llvm-svn: 289205
2016-12-09 12:32:02 +00:00
Eric Fiselier 41b4d6c8ff Fix missing const on set::count. Patch from Andrey Khalyavin
llvm-svn: 289204
2016-12-09 12:17:31 +00:00
Eric Fiselier 43a7f2c53b Refactor uses_allocator test types for upcoming fixes
llvm-svn: 289197
2016-12-09 09:51:09 +00:00
Eric Fiselier 0ef3b1b10a Put C++ ABI headers in a special build directory instead of the top level.
This patch changes where the C++ ABI headers are put during the build. Previously
    they were put in the top level include directory (not the libc++ header directory).
    However that just polutes the top level directory. Instead this patch creates a special
    directory to put them in. The reason they can't be put under c++/v1 until after the build
    is because libc++ uses the in-source headers, so we can't add the include path of the libc++
    headers in the object dir.

    Additionally this patch teaches the test suite how to find the ABI headers,
    and adds a demangling utility to help debug tests with.

llvm-svn: 289195
2016-12-09 09:31:01 +00:00
Eric Fiselier 217c5d36bb fix misspelling in .clang-format
llvm-svn: 289178
2016-12-09 03:18:45 +00:00
Eric Fiselier 949e47daed Turn off header sorting and comment formatting
llvm-svn: 289177
2016-12-09 03:17:25 +00:00
Eric Fiselier bd688258ba Fix PR27374 - Remove the implicit reduced-arity-extension in tuple.
This patch removes libc++'s tuple extension which allowed it to be
constructed from fewer initializers than elements; with the remaining
elements being default constructed. However the implicit version of
this extension breaks conforming code. For example:

    int fun(std::string);
    int fun(std::tuple<std::string, int>);
    int x = fun("hello"); // ambigious

Because existing code may already depend on this extension it can be re-enabled
by defining _LIBCPP_ENABLE_TUPLE_IMPLICIT_REDUCED_ARITY_EXTENSION.

Note that the explicit version of this extension is still supported,
although it's somewhat less useful than the implicit one.

llvm-svn: 289158
2016-12-08 23:57:08 +00:00
Stephan T. Lavavej f2e24f568b [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 7/7.
test/std/input.output/iostream.format/input.streams/istream.unformatted/get.pass.cpp
Add static_cast<char> because basic_istream::get() returns int_type (N4606 27.7.2.3 [istream.unformatted]/4).

test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp
Add static_cast<char> because toupper() returns int (C11 7.4.2.2/1).

test/std/iterators/stream.iterators/ostream.iterator/ostream.iterator.ops/assign_t.pass.cpp
This test is intentionally writing doubles to ostream_iterator<int>.
It's silencing -Wliteral-conversion for Clang, so I'm adding C4244 silencing for MSVC.

test/std/language.support/support.limits/limits/numeric.limits.members/infinity.pass.cpp
Given `extern float zero;`, the expression `1./zero` has type double, which emits a truncation warning
when being passed to test<float>() taking float. The fix is to say `1.f/zero` which has type float.

test/std/numerics/complex.number/cmplx.over/arg.pass.cpp
test/std/numerics/complex.number/cmplx.over/norm.pass.cpp
These tests were constructing std::complex<double>(x, 0), emitting truncation warnings when x is long long.
Saying static_cast<double>(x) avoids this.

test/std/numerics/rand/rand.eng/rand.eng.lcong/seed_result_type.pass.cpp
This was using `int s` to construct and seed a linear_congruential_engine<T, stuff>, where T is
unsigned short/unsigned int/unsigned long/unsigned long long. That emits a truncation warning in the
unsigned short case. Because the range [0, 20) is tiny and we aren't doing anything else with the index,
we can just iterate with `T s`.

test/std/re/re.traits/value.pass.cpp
regex_traits<wchar_t>::value()'s first parameter is wchar_t (N4606 28.7 [re.traits]/13). This loop is
using int to iterate through ['g', 0xFFFF), emitting a truncation warning from int to wchar_t
(which is 16-bit for some of us). Because the bound is exclusive, we can just iterate with wchar_t.

test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
This test is a little strange. It's trying to verify that basic_string's (InIt, InIt) range constructor
isn't confused by "N copies of C" when N and C have the same integral type. To do this, it was
testing (100, 65), but that eventually emits truncation warnings from int to char. There's a simple way
to avoid this - passing (static_cast<char>(100), static_cast<char>(65)) also exercises the disambiguation.
(And 100 is representable even when char has a signed range.)

test/std/strings/string.view/string.view.hash/string_view.pass.cpp
Add static_cast<char_type> because `'0' + i` has type int.

test/std/utilities/function.objects/bind/func.bind/func.bind.bind/nested.pass.cpp
What's more horrible than nested bind()? pow() overloads! This operator()(T a, T b) was assuming that
std::pow(a, b) can be returned as T. (In this case, T is int.) However, N4606 26.9.1 [cmath.syn]/2
says that pow(int, int) returns double, so this was truncating double to int.
Adding static_cast<T> silences this.

test/std/utilities/function.objects/unord.hash/integral.pass.cpp
This was iterating `for (int i = 0; i <= 5; ++i)` and constructing `T t(i);` but that's truncating
when T is short. (And super truncating when T is bool.) Adding static_cast<T> silences this.

test/std/utilities/utility/exchange/exchange.pass.cpp
First, this was exchanging 67.2 into an int, but that's inherently truncating.
Changing this to static_cast<short>(67) avoids the truncation while preserving the
"what if T and U are different" test coverage.
Second, this was exchanging {} with the explicit type float into an int, and that's also
inherently truncating. Specifying short is just as good.

test/std/utilities/utility/pairs/pairs.spec/make_pair.pass.cpp
Add static_cast<short>. Note that this affects template argument deduction for make_pair(),
better fulfilling the test's intent. For example, this was saying
`typedef std::pair<int, short> P1; P1 p1 = std::make_pair(3, 4);` but that was asking
make_pair() to return pair<int, int>, which was then being converted to pair<int, short>.
(pair's converting constructors are tested elsewhere.)
Now, std::make_pair(3, static_cast<short>(4)) actually returns pair<int, short>.
(There's still a conversion from pair<nullptr_t, short> to pair<unique_ptr<int>, short>.)

Fixes D27544.

llvm-svn: 289111
2016-12-08 21:38:57 +00:00
Stephan T. Lavavej 4e19c47556 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 6/7.
test/std/algorithms/alg.modifying.operations/alg.random.shuffle/random_shuffle_rand.pass.cpp
(Affects 64-bit architectures.) Include <cstddef> so we can take/return std::ptrdiff_t
(instead of int) in random_shuffle()'s RNG. (C++14 D.12 [depr.alg.random.shuffle]/2 says that
difference_type is used, and we're shuffling a plain array.)

test/std/algorithms/alg.sorting/alg.sort/sort/sort.pass.cpp
test/std/algorithms/alg.sorting/alg.sort/stable.sort/stable_sort.pass.cpp
(Affects 64-bit architectures.) Include <iterator> because we're already using iterator_traits.
Then, store the result of subtracting two RanIts as difference_type instead of long
(which truncates on LLP64 architectures like MSVC x64).

test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
(Affects 64-bit architectures.) Include <cstddef> so we can store the result of
subtracting two pointers as std::ptrdiff_t (instead of int).

test/std/input.output/iostream.format/input.streams/istream.unformatted/ignore_0xff.pass.cpp
(Affects 32-bit architectures.) Sometimes, size_t is too small. That's the case here,
where tellg() returns pos_type (N4606 27.7.2.3 [istream.unformatted]/39). Implementations can
have 64-bit pos_type (to handle large files) even when they have 32-bit size_t.

Fixes D27543.

llvm-svn: 289110
2016-12-08 21:38:44 +00:00
Stephan T. Lavavej a0d87857e0 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 5/7.
Instead of storing double in double and then truncating to int, store int in long
and then widen to long long. This preserves test coverage (as these tests are
interested in various tuple conversions) while avoiding truncation warnings.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
Since we aren't physically truncating anymore, t1 is equal to p0.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
One edit is different from the usual pattern. Previously, we were storing
double in double and then converting to A, which has an implicitly converting
constructor from int. Now, we're storing int in int and then converting to A,
avoiding the truncation.

Fixes D27542.

llvm-svn: 289109
2016-12-08 21:38:32 +00:00
Stephan T. Lavavej 84ade982a2 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 4/7.
Change char to long and remove some char casts. This preserves test coverage for tuple's
heterogeneous comparisons, while avoiding int-to-char truncation warnings.

Fixes D27541.

llvm-svn: 289108
2016-12-08 21:38:23 +00:00
Stephan T. Lavavej 7abade3769 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 3/7.
Add static_cast<short> when constructing pair<Whatever, short> from (Something, int).

Fixes D27540.

llvm-svn: 289107
2016-12-08 21:38:14 +00:00
Stephan T. Lavavej c255fa5e93 [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 2/7.
These tests for some guy's transparent operator functors were needlessly truncating their
double results to int. Preserving the doubleness makes compilers happier. I'm following
existing practice by adding an "// exact in binary" comment when the result isn't a whole number.
(The changes from 6 to 6.0 and so forth are stylistic, not critical.)

Fixes D27539.

llvm-svn: 289106
2016-12-08 21:38:01 +00:00
Stephan T. Lavavej d7dc18e26d [libcxx] [test] Fix MSVC warning C4244 "conversion from 'X' to 'Y', possible loss of data", part 1/7.
Given `std::basic_streambuf<CharT>::int_type __c`, `std::basic_string<CharT> str_`,
and having checked `__c != std::basic_streambuf<CharT>::traits_type::eof()` (substituting typedefs
for clarity), the line `str_.push_back(__c);` is safe according to humans, but truncates according
to compilers. `str_.push_back(static_cast<CharT>(__c));` avoids that problem.

Fixes D27538.

llvm-svn: 289105
2016-12-08 21:37:47 +00:00
Eric Fiselier 4262748e0f Add more test cases to packaged_task copyability test
llvm-svn: 289034
2016-12-08 10:02:04 +00:00
Eric Fiselier 009259da8a Avoid C++17 guaranteed copy elision when testing for non-copyability
llvm-svn: 289033
2016-12-08 09:57:00 +00:00
Eric Fiselier 4879815600 Fix PR30323: numeric_limits<T>::max_digits10 when using 16 bit ints.
Summary: Also see https://llvm.org/bugs/show_bug.cgi?id=30323

Reviewers: mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 289029
2016-12-08 07:30:01 +00:00
Eric Fiselier 900efb2f1a Fix _LIBCPP_VERSION tests with modules on Darwin
llvm-svn: 289028
2016-12-08 06:37:41 +00:00
Eric Fiselier 2c482d3f01 Revert r288787: Add missing stdbool.h module.
Reverting because I didn't properly test this patch. Although it's probably
correct to add a stdbool_h module I thought the change fixed more than it did.
I'll re-commit after more investigation.

llvm-svn: 288789
2016-12-06 09:48:32 +00:00
Eric Fiselier d9cbffb0df Add missing stdbool.h module. The test suite now passes on OS X with modules
llvm-svn: 288787
2016-12-06 09:41:50 +00:00
Eric Fiselier 4facc13108 Fix stdio module build on OS X
llvm-svn: 288778
2016-12-06 07:40:46 +00:00
Casey Carter 6da13b6b79 std::get<0>([std::variant constant expression]) *is* noexcept.
Differential review: http://reviews.llvm.org/D27436

llvm-svn: 288760
2016-12-06 02:28:19 +00:00
Eric Fiselier 25af0418da Fix C++03 modules build
llvm-svn: 288755
2016-12-06 01:34:24 +00:00
Stephan T. Lavavej d4b83e6dfd [libcxx] [test] D27269: Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 3/4.
test/std/containers/sequences/vector.bool/copy.pass.cpp
test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
Change "unsigned s = x.size();" to "typename C::size_type s = x.size();"
because that's what it returns.

test/std/strings/basic.string/string.cons/pointer_alloc.pass.cpp
Include <cstddef>, then change "unsigned n = T::length(s);"
to "std::size_t n = T::length(s);" because that's what char_traits returns.

test/std/strings/basic.string/string.cons/substr.pass.cpp
Change unsigned to typename S::size_type because that's what str.size() returns.

test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
This was needlessly truncating std::size_t to unsigned.
It's being used to compare and initialize std::size_t.

llvm-svn: 288753
2016-12-06 01:14:51 +00:00
Stephan T. Lavavej f41847c401 [libcxx] [test] D27268: Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 2/4.
Use static_cast<int> when storing size_t in int (or passing size_t to int).

Also, remove a spurious semicolon in test/support/archetypes.hpp.

test/support/count_new.hpp
Additionally, change data members (and parameters) to size_t.

llvm-svn: 288752
2016-12-06 01:14:43 +00:00
Stephan T. Lavavej baa547b996 [libcxx] [test] D27267: Fix MSVC x64 warning C4267 "conversion from 'size_t' to 'int' [or 'unsigned int'], possible loss of data", part 1/4.
Replace "int n = str_.size();" with "int n = static_cast<int>(str_.size());".

int is the correct type to use, because we're eventually calling
"base::pbump(n+1);" where base is std::basic_streambuf.
N4606 27.6.3.3.3 [streambuf.put.area]/4 declares: "void pbump(int n);"

llvm-svn: 288751
2016-12-06 01:14:29 +00:00
Stephan T. Lavavej fe4ca8c539 [libcxx] [test] D27266: Remove spurious semicolons.
llvm-svn: 288750
2016-12-06 01:14:06 +00:00
Stephan T. Lavavej e9c728899f [libcxx] [test] D27025: Fix MSVC warning C4389 "signed/unsigned mismatch", part 12/12.
Various changes:

test/std/algorithms/alg.sorting/alg.merge/inplace_merge.pass.cpp
This is comparing value_type to unsigned. value_type is sometimes int and sometimes struct S (implicitly constructible from int).
static_cast<value_type>(unsigned) silences the warning and doesn't do anything bad (as the values in question are small).

test/std/algorithms/alg.sorting/alg.nth.element/nth_element_comp.pass.cpp
This is comparing an int remote-element to size_t. The values in question are small and non-negative,
so either type is fine. I think that converting int to size_t is marginally better here than the reverse.

test/std/containers/sequences/deque/deque.cons/size.pass.cpp
DefaultOnly::count is int (and non-negative). When comparing to unsigned, use static_cast<unsigned>.

test/std/strings/basic.string/string.access/index.pass.cpp
We're comparing char to '0' through '9', but formed with the type size_t. Add static_cast<char>.

test/std/utilities/template.bitset/bitset.cons/ull_ctor.pass.cpp
Include <cstddef> for pedantic correctness (this test was already mentioning std::size_t).

"v[i] == (i & 1)" was comparing bool to size_t. Saying "v[i] == ((i & 1) != 0)" smashes the RHS to bool.

llvm-svn: 288749
2016-12-06 01:13:51 +00:00
Stephan T. Lavavej 6859c20ac9 [libcxx] [test] D27024: Fix MSVC warning C4389 "signed/unsigned mismatch", part 11/12.
Change "unsigned n = 0;" to "int n = 0;". It's being compared to int elements and ptrdiff_t distances.

test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
This one's a little special, but not really. "*i == n" is comparing MoveOnly to n.
MoveOnly is implicitly constructible from int, so int is the correct type to use here.

llvm-svn: 288748
2016-12-06 01:13:40 +00:00
Stephan T. Lavavej e17a155c61 [libcxx] [test] D27023: Fix MSVC warning C4389 "signed/unsigned mismatch", part 10/12.
Add static_cast<int>. In these cases, the values are guaranteed to be small-ish,
and they're being compared to int elements.

test/std/containers/sequences/deque/deque.capacity/access.pass.cpp
Use int instead of unsigned to iterate from 0 to 10.

llvm-svn: 288747
2016-12-06 01:13:29 +00:00
Stephan T. Lavavej 68a694b800 [libcxx] [test] D27022: Fix MSVC warning C4389 "signed/unsigned mismatch", part 9/12.
Add static_cast<std::size_t> to more comparisons. (Performed manually, unlike part 8/12.)

Also, include <cstddef> when it wasn't already being included.

llvm-svn: 288746
2016-12-06 01:13:14 +00:00
Stephan T. Lavavej fbfb2ab63e [libcxx] [test] D27021: Fix MSVC warning C4389 "signed/unsigned mismatch", part 8/12.
Add static_cast<std::size_t> when comparing distance() to size().

These replacements were performed programmatically with regex_replace():

const vector<pair<regex, string>> reg_fmt = {
    { regex(R"(assert\((\w+)\.size\(\) == std::distance\((\w+, \w+)\)\))"),
        "assert($1.size() == static_cast<std::size_t>(std::distance($2)))" },
    { regex(R"(assert\(distance\((\w+\.begin\(\), \w+\.end\(\))\) == (\w+)\.size\(\)\))"),
        "assert(static_cast<std::size_t>(distance($1)) == $2.size())" },
    { regex(R"(assert\(std::distance\((\w+\.\w*begin\(\), \w+\.\w*end\(\))\) == (\w+)\.size\(\)\))"),
        "assert(static_cast<std::size_t>(std::distance($1)) == $2.size())" },
};

Also, include <cstddef> when it wasn't already being included.

llvm-svn: 288745
2016-12-06 01:12:34 +00:00
Eric Fiselier 9642b36e91 Add support for writing -verify shell tests
llvm-svn: 288743
2016-12-06 01:02:15 +00:00
Eric Fiselier 8e27c2b970 Allow enabling/disabling testing with module using env LIBCXX_USE_MODULES=1
The Clang modules implementation breaks enough that libc++ needs an easy way
to enable/disable using modules on the Zorg builders. Editing Zorg itself
requires a buildmaster restart which only happens weekly. This patch
allows LIBCXX_USE_MODULES to be used to enable/disable the feature,
allowing the buildslave to disable it as need be.

llvm-svn: 288736
2016-12-06 00:01:04 +00:00
Eric Fiselier e1f72557c2 Add module definitions for <experimental/foo> headers
llvm-svn: 288735
2016-12-05 23:55:34 +00:00
Eric Fiselier ca648c9787 Add module definitions for string_view
llvm-svn: 288733
2016-12-05 23:53:23 +00:00
Eric Fiselier 392aa10811 Add modules for any/optional/variant
llvm-svn: 288730
2016-12-05 23:33:19 +00:00
Eric Fiselier daf21c3f69 Adjust libc++ test infastructure to fully support modules
This patch overhalls the libc++ test format/configuration in order to fully support modules. By "fully support" I mean get almost all of the tests passing. The main hurdle for doing this is handling tests that `#define _LIBCPP_FOO` macros to test a different configuration. This patch deals with these tests in the following ways:

1. For tests that define single `_LIBCPP_ABI_FOO` macros have been annotated with `// MODULES_DEFINES: _LIBCPP_ABI_FOO`. This allows the test suite to define the macro on the command line so it uses a different set of modules.
2. Tests for libc++'s debug mode (which define custom `_LIBCPP_ASSERT`) are automatically detected by the test suite and are compiled and run with modules disabled.

This patch also cleans up how the `CXXCompiler` helper class handles enabling/disabling language features.

NOTE: This patch uses `LIT` features which were only committed to LLVM today. If this patch breaks running the libc++ tests you probably need to update LLVM.
llvm-svn: 288728
2016-12-05 23:16:07 +00:00
Shoaib Meenai fc6100c195 [libc++] Add _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
It's useful to be able to disable visibility annotations entirely; for
example, if we're building libc++ static to include in another library,
and we don't want any libc++ functions getting exported out of that
library. This is a generalization of _LIBCPP_DISABLE_DLL_IMPORT_EXPORT.

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

llvm-svn: 288690
2016-12-05 19:40:12 +00:00
Roger Ferrer Ibanez 4cb4b36aa2 Handle tests for noexcept that expect a false value
Under libcpp-no-exceptions, noexcept is trivially true. Some tests expect in
the usual setting to return false, so adjust them to expect true under
libcpp-no-exceptions.

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

llvm-svn: 288660
2016-12-05 11:05:09 +00:00
Eric Fiselier 11b932b0d9 Update status page for variant implementation
llvm-svn: 288625
2016-12-04 22:14:53 +00:00
Eric Fiselier 02460bac8b Choose better hash values for std::monostate and valueless variants.
Previously these hashes were 0 and -1 respectively. These seem like common
sentinel values and should be avoided to prevent needless collisions.

This patch changes those values to different arbitrary numbers, which should
hopefully cause less collisions. Because I couldn't help myself I choose the
fundamental constants for gravity and the speed of light.

llvm-svn: 288623
2016-12-04 21:37:37 +00:00
Eric Fiselier 0c6d89d614 Turn off testsuite warnings by default with GCC
llvm-svn: 288576
2016-12-03 03:29:45 +00:00
Eric Fiselier 613dc646d3 Make make_exception_ptr abort with -fno-exceptions
llvm-svn: 288575
2016-12-03 03:22:11 +00:00
Eric Fiselier 9a0b4abbba Mark various <variant> items as complete
llvm-svn: 288574
2016-12-03 02:47:40 +00:00
Eric Fiselier 46fcbb4da4 Work around more -Wshadow warnings
llvm-svn: 288573
2016-12-03 02:26:28 +00:00
Eric Fiselier 63322af698 Fix <variant> w/o exception support
llvm-svn: 288571
2016-12-03 01:58:07 +00:00
Eric Fiselier f9353d89be Revert workaround for Clang bug. Thanks to Richard for the quick fix
llvm-svn: 288566
2016-12-03 01:28:01 +00:00
Eric Fiselier 572e6deeb7 Fix -Wshadow warnings and enable warnings by default for C++ >= 11
llvm-svn: 288564
2016-12-03 01:21:40 +00:00
Eric Fiselier 33f947057d XFAIL variant tests for apple-clang
llvm-svn: 288559
2016-12-03 00:33:03 +00:00
Eric Fiselier 465bd0fc00 Enable warnings by default for C++ >= 11 and fix -Wshadow occurances
llvm-svn: 288557
2016-12-03 00:27:13 +00:00
Eric Fiselier d7a50d1d6b Work around Clang 3.8 bugs
llvm-svn: 288556
2016-12-03 00:13:33 +00:00
Eric Fiselier 5877920183 Fix C++03 build
llvm-svn: 288555
2016-12-02 23:41:18 +00:00
Eric Fiselier 918f32fc7b Make variant's index part of the hash value
llvm-svn: 288554
2016-12-02 23:38:31 +00:00
Eric Fiselier cb3ef1561d Fix generated warnings in <variant>
llvm-svn: 288552
2016-12-02 23:17:33 +00:00
Eric Fiselier c7a28dee10 Update darwin ABI list for <variant>
llvm-svn: 288551
2016-12-02 23:14:18 +00:00
Eric Fiselier aa97dee358 Update ABI lists for <variant>
llvm-svn: 288550
2016-12-02 23:11:28 +00:00
Eric Fiselier 0d3d8de014 Implement C++17 <variant>. Patch from Michael Park!
This patch was reviewed as https://reviews.llvm.org/D23263.

llvm-svn: 288547
2016-12-02 23:00:05 +00:00
Eric Fiselier 13b6cc4b08 Work around a bug in Clang's implementation of noexcept function types
llvm-svn: 288544
2016-12-02 22:30:52 +00:00
Eric Fiselier ffd5732170 Fix copy/paste errors in new variant tests
llvm-svn: 288538
2016-12-02 21:32:35 +00:00
Eric Fiselier 96be8df23e Add tests for libc++'s constexpr variant copy/move extension
llvm-svn: 288536
2016-12-02 21:17:51 +00:00
Roger Ferrer Ibanez de344ac83b Protect sequences test under libcpp-no-exceptions
Replace throw with TEST_THROW and protect tests that do throw. Also add missing assert(false).

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

llvm-svn: 288383
2016-12-01 17:36:41 +00:00
Roger Ferrer Ibanez f3fce920ff Protect futures test under libcpp-no-exceptions
Skip tests that expect an exception be thrown.

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

llvm-svn: 288382
2016-12-01 17:34:57 +00:00
Roger Ferrer Ibanez c9a8a5596f Protect optional test under libcpp-no-exceptions
Replace throw with TEST_THROW and skip tests that throw exceptions

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

llvm-svn: 288379
2016-12-01 17:33:36 +00:00
Roger Ferrer Ibanez 9f1bcb65aa Protect std::ostream::sentry test under libcpp-no-exceptions
Skip test that throws an exception.

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

llvm-svn: 288378
2016-12-01 17:31:38 +00:00
Roger Ferrer Ibanez 86663cd0ef Protect std::array tests under noexceptions
Skip tests that expect exceptions be thrown. Also add missing asserts.

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

llvm-svn: 288165
2016-11-29 17:10:29 +00:00
Roger Ferrer Ibanez 9d03c03858 Protect std::string tests under libcpp-no-exceptions
Skip tests that expect an exception be thrown and/or disable
unreachable catch handlers.

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

llvm-svn: 288158
2016-11-29 16:40:19 +00:00
Roger Ferrer Ibanez f2e50651f6 Protect std::{,unordered_}map tests under noexceptions
Skip tests that use exceptions

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

llvm-svn: 288157
2016-11-29 16:37:48 +00:00
Roger Ferrer Ibanez d7306fb85a Protect locale tests under noexceptions
Skip tests that expect exceptions be thrown.

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

llvm-svn: 288156
2016-11-29 16:31:40 +00:00
Roger Ferrer Ibanez 21ad28cfb4 Protect test for dynarray under libcpp-no-exceptions
This test expects an exception be thrown.

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

llvm-svn: 288155
2016-11-29 16:27:45 +00:00
Aditya Kumar b9775795a8 [libcxx] remove unused code
The macro _LIBCPP_UNROLL_LOOPS isn't used anywhere
so the code was dead.

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

llvm-svn: 288143
2016-11-29 14:43:42 +00:00
Marshall Clow 13320a50e5 Implement conjuntion/disjuntion/negation for LFTS v2. Same code and tests for the ones in std::
llvm-svn: 287988
2016-11-26 18:45:03 +00:00
Marshall Clow 3b3352dead Implement the 'detection idiom' from LFTS v2
llvm-svn: 287981
2016-11-26 15:49:40 +00:00
Roger Ferrer Ibanez d056b5be51 Reverting wrong diff
I managed to confuse me with two reviews of the same thing and ended commiting the wrong one.

llvm-svn: 287868
2016-11-24 11:28:02 +00:00
Roger Ferrer Ibanez 929282836a Protect tests for std::uninitialized_{copy,fill} under libcpp-no-exceptions
Skip tests that expect an exception be thrown.

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

llvm-svn: 287866
2016-11-24 11:17:09 +00:00
Roger Ferrer Ibanez c65daf3e4a Protect std::string tests under libcpp-no-exceptions
Skip tests that expect an exception be thrown and/or disable
unreachable catch handlers.

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

llvm-svn: 287865
2016-11-24 11:15:09 +00:00
Stephan T. Lavavej d72ece6462 [libcxx] [test] D27027: Strip trailing whitespace.
llvm-svn: 287829
2016-11-23 22:03:28 +00:00
Stephan T. Lavavej 640660aa3f [libcxx] [test] D27026: Fix copy-paste silliness; ULL can't ever be 32-bit.
llvm-svn: 287828
2016-11-23 22:02:59 +00:00
Stephan T. Lavavej 8eb5ce8652 [libcxx] [test] D27020: Fix MSVC warning C4245 "conversion from 'X' to 'Y', signed/unsigned mismatch", part 7/12.
When initializing unsigned integers to their maximum values, change "const T M(~0);" to "const T M(static_cast<T>(-1));".

~0 and -1 are equivalent, but I consider the -1 form to be significantly clearer (and more consistent with other tests).

llvm-svn: 287827
2016-11-23 22:02:53 +00:00
Stephan T. Lavavej bbdf9b7d2b [libcxx] [test] D27019: Fix MSVC warning C4245 "conversion from 'X' to 'Y', signed/unsigned mismatch", part 6/12.
Add static_cast when initializing unsigned integers with negative numbers (in order to obtain big values).

llvm-svn: 287826
2016-11-23 22:02:44 +00:00
Stephan T. Lavavej 562f28a6ed [libcxx] [test] D27018: Fix MSVC warning C4018 "signed/unsigned mismatch", part 5/12.
Various changes:

test/std/algorithms/alg.sorting/alg.binary.search/binary.search/binary_search.pass.cpp
Change M from unsigned to int. It's compared against "int x",
and we binary_search() for it within a vector<int>.

test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval.pass.cpp
test/std/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.f/eval_param.pass.cpp
Add static_cast<unsigned> when comparing int to unsigned.

test/std/strings/basic.string/string.cons/size_char_alloc.pass.cpp
Change unsigned indices to int when we're being given int as a bound.

llvm-svn: 287825
2016-11-23 22:02:35 +00:00
Stephan T. Lavavej 73876facd5 [libcxx] [test] D27016: Fix MSVC warning C4018 "signed/unsigned mismatch", part 4/12.
Change "int j;" indices to "std::size_t j;".

Also, include <cstddef> when it wasn't already being included.

llvm-svn: 287824
2016-11-23 22:02:27 +00:00
Stephan T. Lavavej afe99ae092 [libcxx] [test] D27015: Fix MSVC warning C4018 "signed/unsigned mismatch", part 3/12.
Change unsigned to int in parameters.

llvm-svn: 287823
2016-11-23 22:02:16 +00:00
Stephan T. Lavavej a11d322f0d [libcxx] [test] D27014: Fix MSVC warning C4018 "signed/unsigned mismatch", part 2/12.
Add static_cast<std::size_t> when comparing int to std::size_t.

Also, include <cstddef> when it wasn't already being included.

llvm-svn: 287822
2016-11-23 22:01:58 +00:00