The 10.13 SDK always defines utimensat() (with an availability(macosx=10.13) annotation)
and unconditionally defines UTIME_OMIT, so use the compile-time availability macros
on Apple platforms instead.
For people statically linking libc++, it might make sense to also provide an opt-in
option for using __builtin_available() to dynamically check for the OS version,
but for now let's do the smallest thing needed to unbreak the build.
Based on a patch by Eric Fiselier <eric@efcs.ca>: https://reviews.llvm.org/D34249
Fixes PR33469.
llvm-svn: 324385
Revert "Fix initialization of array<const T, 0> with GCC."
Revert "Make array<const T, 0> non-CopyAssignable and make swap and fill ill-formed."
This reverts commit r324182, r324185, and r324194 which were causing issues with zero-length std::arrays.
llvm-svn: 324309
Previously, when handling zero-sized array of const objects we
used a const version of aligned_storage_t, which is not an array type.
However, GCC complains about initialization of the form: array<const T, 0> arr = {};
This patch fixes that bug by making the dummy object used to represent
the zero-sized array an array itself. This avoids GCC's complaints
about the uninitialized const member.
llvm-svn: 324194
This patch removes the noexcept declaration from filesystem
operations which require creating temporary paths or
creating a directory iterator. Either of these operations
can throw.
llvm-svn: 324192
Because path can be constructed from a ton of different types, including string
and wide strings, this caused it's streaming operators to suck up all sorts
of silly types via silly conversions. For example:
using namespace std::experimental::filesystem::v1;
std::wstring w(L"wide");
std::cout << w; // converts to path.
This patch tentatively adopts the resolution to LWG2989 and fixes the issue
by making the streaming operators friends of path.
llvm-svn: 324189
The standard isn't exactly clear how std::array should handle zero-sized arrays
with const element types. In particular W.R.T. copy assignment, swap, and fill.
This patch takes the position that those operations should be ill-formed,
and makes changes to libc++ to make it so.
This follows up on commit r324182.
llvm-svn: 324185
Summary:
This patch fixes llvm.org/PR35491 and LWG2157 (https://cplusplus.github.io/LWG/issue2157)
The fix attempts to maintain ABI compatibility by replacing the array with a instance of `aligned_storage`.
Reviewers: mclow.lists, EricWF
Reviewed By: EricWF
Subscribers: lichray, cfe-commits
Differential Revision: https://reviews.llvm.org/D41223
llvm-svn: 324182
When Clang encounters an already invalid class declaration, it can
emit incorrect diagnostics about the exception specification on
some of its members. This patch temporarily works around that
incorrect diagnostic.
The clang bug was introduced in r324062.
llvm-svn: 324164
Clang previously reported an empty union as having a unique object
representation. This was incorrect and was fixed in a recent Clang commit.
This patch fixes the libc++ tests.
llvm-svn: 324153
According to [1], forms 2 and 4 of std::is_permutation should use the passed in
binary predicate to compare elements. operator== should only be used for forms
1 and 3 which do not take a binary predicate.
This CL fixes forms 2 and 4 which relied on operator== for some comparisons.
[1] http://en.cppreference.com/w/cpp/algorithm/is_permutation
Patch by Thomas Anderson!
Differential Revision: https://reviews.llvm.org/D42518
llvm-svn: 323563
Clang and llvm already use llvm_setup_rpath(), so this change will
help standarize rpath usage across all projects.
Differential Revision: https://reviews.llvm.org/D42459
llvm-svn: 323492
We need to use the vcruntime declarations on Windows to avoid an
ODR violation involving rtti.obj, which provides the definition of
the runtime function implementing dynamic_cast and depends on the
vcruntime implementations of bad_cast and bad_typeid.
Differential Revision: https://reviews.llvm.org/D42220
llvm-svn: 323491
Code on Windows expects to be able to do:
#define _USE_MATH_DEFINES
#include <math.h>
and receive the definitions of mathematical constants, even if <math.h>
has previously been included. To support this scenario, re-include
<math.h> every time the wrapper header is included.
Differential Revision: https://reviews.llvm.org/D42403
llvm-svn: 323490
Shoaib Meenai pointed out this will break standalone builds when built without llvm.
Differential Revision: https://reviews.llvm.org/D42459
llvm-svn: 323459
Clang and llvm already use llvm_setup_rpath(), so this change will
help standarize rpath usage across all projects.
Differential Revision: https://reviews.llvm.org/D42459
llvm-svn: 323453
There was a bug in the implementation of splice where the container
sizes were updated before decrementing one of the iterators. Afterwards,
the result of decrementing the iterator was flagged as UB by the debug
implementation because the container was reported to be empty.
This patch fixes that bug by delaying the updating of the container
sizes until after the iterators have been correctly constructed.
llvm-svn: 323390
Summary:
See https://bugs.llvm.org/show_bug.cgi?id=20855
Libc++ goes out of it's way to diagnose `std::tuple` constructions which are UB due to lifetime bugs caused by reference creation. For example:
```
// The 'const std::string&' is created *inside* the tuple constructor, and its lifetime is over before the end of the constructor call.
std::tuple<int, const std::string&> t(std::make_tuple(42, "abc"));
```
However, we are over-aggressive and we incorrectly diagnose cases such as:
```
void foo(std::tuple<int const&, int const&> const&);
foo(std::make_tuple(42, 42));
```
This patch fixes the incorrectly diagnosed cases, as well as converting the diagnostic to use the newly added Clang trait `__reference_binds_to_temporary`. The new trait allows us to diagnose cases we previously couldn't such as:
```
std::tuple<int, const std::string&> t(42, "abc");
```
Reviewers: rsmith, mclow.lists
Reviewed By: rsmith
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D41977
llvm-svn: 323380
Summary:
Currently when a regular expression contains an invalid character
class name std::regex constructors throw an std::regex_error with
std::regex_constants::error_brack code.
This patch changes the code to std::regex_constants::error_ctype and
adds a test.
Reviewers: EricWF, mclow.lists
Reviewed By: mclow.lists
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D42291
llvm-svn: 323322
Some users may have a custom build system which gives a different
name to the libc++ archive (or does not create an archive at all,
instead passing the object files directly to the linker). Give those
users a way to disable auto-linking.
Differential Revision: https://reviews.llvm.org/D42436
llvm-svn: 323300
The language standard does not define a function with this name,
so it is part of the user's namespace. This change fixes a duplicate
symbol error that occurs when a user attempts to define a function
with this name.
Differential Revision: https://reviews.llvm.org/D42405
llvm-svn: 323237
This is an MSVC standard library extension. It seems like a reasonable
enough extension to me because wchar_t* is the native format for
filenames on that platform.
Differential Revision: https://reviews.llvm.org/D42225
llvm-svn: 323170
This allows us to avoid polluting the namespace of users of <thread>
with the definitions in windows.h.
Differential Revision: https://reviews.llvm.org/D42214
llvm-svn: 323169
When CMAKE_SYSROOT or CMAKE_FIND_ROOT_PATH is set, cmake
recommends setting CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
globally which means find_path() always prepends CMAKE_SYSROOT or
CMAKE_FIND_ROOT_PATH to all paths used in the search.
However, this find_path() invocation is looking for a path in the
libcxxabi project on the host system, not the target system,
which can be done by passing NO_CMAKE_FIND_ROOT_PATH.
Differential Revision: https://reviews.llvm.org/D41622
llvm-svn: 323143
This patch fixes almost all currently failing tests when
using GCC ToT.
The specific changes are:
(A) Workaround gcc.gnu.org/PR83921 which rejects variables w/o initializers
in constexpr contexts -- even when the variable is an empty class. This
bug has been worked around at all callsites by adding an initializer.
Additionally a new test, constexpr_init.pass.cpp, has been added to
test that Clang doesn't suffer from these bugs.
(B) Fix streambuf.assign/swap.pass.cpp. This test was never actually
calling the swap method as intended. In fact, the swap function it
intended to call was ill-formed when instantiated. GCC diagnosed
this ill-formedness w/o needing an instantiation.
(C) size_delete11.pass.cpp was fixed by adding c++2a to the list of
unsupported dialects.
llvm-svn: 322810
It turns out that the MSVC headers define these functions without
dllimport even when compiling with /MD. This change fixes the resulting
compile-time error.
Differential Revision: https://reviews.llvm.org/D42207
llvm-svn: 322794
Previously .fail.cpp tests for nodiscard were run with -Wunused-result
being a warning, not an error, when the compiler didn't support -verify.
When -verify isn't enabled this change judiciously adds -Werror=unused-result
when to only the failure tests containing the // expected-error string for nodiscard.
As a drive-by change, this patch also adds a missing // UNSUPPORTED: c++2a to
a test which was only supposed to run in C++ <= 11.
llvm-svn: 322776
The specification of this function mandates a cast to uninitialized
T*, which is forbidden under CFI.
Differential Revision: https://reviews.llvm.org/D42146
llvm-svn: 322744
Inline the provided "fallback" definitions (which seem to always be
taken) that expand to __cdecl into users. The fallback definitions
for the *CRTIMP* macros were wrong in the case where the CRT is being
linked statically, so define our own macro as a replacement.
Differential Revision: https://reviews.llvm.org/D42158
llvm-svn: 322617
type 'result_type' to 'double'. The only thing that we ever do with
these numbers is to promote them to 'double' and use them in a division.
For small result_types, the values were getting truncated, skewing the
results. Thanks to James Nagurne for the suggestion.
llvm-svn: 322556
It covers the cases when the sentry object returns false and when an exception
was thrown. Corresponding standard paragraph is C++14 [istream.unformatted]p9:
[...] In any case, if n is greater than zero it then stores a null
character into the next successive location of the array.
rdar://problem/35566567
Reviewers: EricWF, mclow.lists
Reviewed By: mclow.lists
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D40677
llvm-svn: 322326
An application may determine whether the C standard library is glibc
by testing whether __GLIBC_PREREQ is defined. This breaks if libc++
provides its own definition. Instead, define our own macro in our
namespace with the desired semantics.
Differential Revision: https://reviews.llvm.org/D41892
llvm-svn: 322201
test/support/msvc_stdlib_force_include.hpp
When testing MSVC's STL with C1XX, simulate a couple more compiler feature-test macros.
When testing MSVC's STL, simulate a few library feature-test macros.
test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
The vector_size attribute is a non-Standard extension that's supported by Clang and GCC,
but not C1XX. Therefore, guard this with `__has_attribute(vector_size)`.
Additionally, while these tests pass when MSVC's STL is compiled with Clang,
I don't consider this to be a supported scenario for our library,
so also guard this with defined(_LIBCPP_VERSION).
test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
N4713 23.14.10 [func.not_fn]/1 depicts only `call_wrapper(call_wrapper&&) = default;`
and `call_wrapper(const call_wrapper&) = default;`. According to
15.8.2 [class.copy.assign]/2 and /4, this makes call_wrapper non-assignable.
Therefore, guard the assignability tests as libc++ specific.
Add a (void) cast to tolerate not_fn() being marked as nodiscard.
Fixes D41213.
llvm-svn: 322144
Seems to have broken some tests since I first wrote this a while
back. Will reland after checking what went wrong with the tests.
This reverts commit 7023194c8d11a081fd01ed25308b3d60193c6a06.
llvm-svn: 322039