Summary: On Windows tests that use `_LIBCPP_ASSERT` fail to link because the assertion handler function isn't correctly exported from the libc++ dylib. This patch fixes the dll import/export issues by introducing a new visibility macro `_LIBCPP_EXTERN_VIS` for use on external variables.
Reviewers: compnerd, smeenai, EricWF
Reviewed By: EricWF
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D28728
llvm-svn: 292158
This patch contains multiple cleanups and fixes to better support building on
Windows.
* [Test] Fix handling of library runtime search paths by correctly adding them
to the PATH variable when running the tests.
* [Test] Don't explicitly force "--target=i686-pc-windows" when running the
test suite. Clang++ seems to deduce the correct target.
* [Test] Fix `.sh.cpp` tests on Windows by properly escaping flags used in
shell commands. Specifically windows style paths which included spaces
were causing these tests to fail.
* [CMake] Add "vcruntime" to the list of supported C++ ABI libraries in CMake, and
teach the test suite how to handle it. For now libc++ defaults to using
"vcruntime" on Windows except when libc++abi is in tree; That is probably
a bug and should be changed to always use vcruntime, at least for now.
* [Misc] Move the "c++-build" include directory to the libc++ binary dir
instead of the top level project dir and rename it "c++build". This is just
misc cleanup. Libc++ shouldn't be creating internal build files and directories
at the top-level projects root.
* [Misc] Build type_info's destructor when building for MSVC. This is a temporary
work around to prevent link errors until we have a proper type_info
implementation.
llvm-svn: 292157
We have already refactored the underlying platform thread type into
__libcpp_thread_t, but there are few places in the source where we
still assume it is an integral type.
This patch refactores those points back into the threading API.
Differential revision: https://reviews.llvm.org/D28608
Reviewers: EricWF
llvm-svn: 292107
Summary: This patch allows libc++ to be built against the debug MSVC runtimes instead of just the release ones.
Reviewers: rnk, majnemer, compnerd, smeenai
Subscribers: mgorny, cfe-commits
Differential Revision: https://reviews.llvm.org/D28725
llvm-svn: 292006
Summary:
This patch attempts to fix the libc++ build/link so that it doesn't use an default C++ libraries on Windows. This is needed to prevent linking to MSVC's STL library.
Additionally this patch changes libc++ so that it is always linked with the non-debug DLL's (e.g. `/MD`). This is needed so that the test suite can correctly link the same libraries without needing to know which configuration `c++.dll` was linked with.
Reviewers: compnerd, rnk, majnemer, kimgr, awson, halyavin, smeenai
Subscribers: cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D28441
llvm-svn: 292001
When -pedantic-errors is specified `__has_extension(<feature>)` is always
false when it would otherwise be true. This causes C++03 <atomic> to break
along with other issues.
This patch avoids the above problem by using __is_identifier(...) instead since
it is not affected by -pedantic-errors. For example instead of checking for
__has_extension(c_atomics) we now check `!__is_identifier(_Atomic)`, which
is only true when _Atomic is not a keyword provided by the compiler.
This patch applies similar changes to the detection logic for __decltype and
__nullptr as well.
Note that it does not apply this change to the C++03
`static_assert` macro since -Wc11-extensions warnings generated by expanding
that macro will appear in user code, and will not be suppressed as part of a
system header.
llvm-svn: 291995
This patch adjusts the out-of-tree CMake configuration so that
the stderr output is ignored when an old llvm-config is found
that doesn't support --cmakedir.
llvm-svn: 291991
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
This tells whether or not the builtin function __builtin_memcmp is constexpr.
Only defined for clang 4.0 and later, and not true for any shipping version of Apple's clang.
llvm-svn: 291773
Attempting to pair an `_aligned_malloc` with a regular free causes heap
corruption. Pairing with `_aligned_free` is required instead.
Makes the following libc++ tests pass on Windows:
```
std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t.pass.cpp
std/language.support/support.dynamic/new.delete/new.delete.array/new_align_val_t_nothrow.pass.cpp
std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t.pass.cpp
std/language.support/support.dynamic/new.delete/new.delete.single/new_align_val_t_nothrow.pass.cpp
```
Differential Revision: https://reviews.llvm.org/D28512
llvm-svn: 291743
When doing standalone build, check that we actually have libcxxabi
before attempting to use it.
Differential Revision: https://reviews.llvm.org/D28580
llvm-svn: 291723
There is no guaranteed order in which CMake files for individual
runtimes are invoked and therefore we cannot rely on existence of
targets defined in other runtimes. Use the new HAVE_<name> options
instead in those cases.
Differential Revision: https://reviews.llvm.org/D28391
llvm-svn: 291632
This is to make sure this check is called even when building as
part of LLVM runtimes when we are doing standalone but not out of
tree build.
Differential Revision: https://reviews.llvm.org/D28392
llvm-svn: 291592
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
Although the CriticalSection itself doesnt need to be destroyed, there
may be debug data associated with it. Plug a possible small leak.
llvm-svn: 291536
Use the new --cmakedir option to obtain LLVM_CMAKE_PATH straight from
llvm-config. Fallback to local reconstruction if llvm-config does not
support this option.
llvm-svn: 291508
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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=708http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2037.htm
Reviewed by: ericwf
Differential Revision: https://reviews.llvm.org/D21436
llvm-svn: 290748
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
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
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
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
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
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
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
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
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