Commit Graph

499 Commits

Author SHA1 Message Date
Eric Fiselier fcc1e6d978 Fix locale test data for GLIBC 2.27 and newer.
GLIBC 2.27 changed the locale data for fr_FR and ru_RU. In particular
they change the decimal and thousands separators used. This patch
makes the locale tests tolerate the updated locales.

llvm-svn: 329143
2018-04-04 04:00:14 +00:00
Eric Fiselier d7fae181c3 Implement filesystem NB comments, relative paths, and related issues.
This is a fairly large patch that implements all of the filesystem NB comments
and the relative paths changes (ex. adding weakly_canonical). These issues
and papers are all interrelated so their implementation couldn't be split up
nicely.

This patch upgrades <experimental/filesystem> to match the C++17 spec and not
the published experimental TS spec. Some of the changes in this patch are both
API and ABI breaking, however libc++ makes no guarantee about stability for
experimental implementations.

The major changes in this patch are:

* Implement NB comments for filesystem (P0492R2), including:
  * Implement `perm_options` enum as part of NB comments, and update the
    `permissions` function to match.
  * Implement changes to `remove_filename` and `replace_filename`
  * Implement changes to `path::stem()` and `path::extension()` which support
    splitting examples like `.profile`.
  * Change path iteration to return an empty path instead of '.' for trailing
    separators.
  * Change `operator/=` to handle absolute paths on the RHS.
  * Change `absolute` to no longer accept a current path argument.

* Implement relative paths according to NB comments (P0219r1)

* Combine `path.cpp` and `operations.cpp` since some path functions require
  access to the operations internals, and some fs operations require access
  to the path parser.

llvm-svn: 329028
2018-04-02 23:03:41 +00:00
Eric Fiselier 4d334c4cdd Implement filesystem::perm_options specified in NB comments.
The NB comments for filesystem changed permissions and added
a new enum `perm_options` which control how the permissions
are applied.

This implements than NB resolution

llvm-svn: 328476
2018-03-26 06:23:55 +00:00
Eric Fiselier f2918d1c24 Fix PR22634 - std::allocator doesn't respect over-aligned types.
This patch fixes std::allocator, and more specifically, all users
of __libcpp_allocate and __libcpp_deallocate, to support over-aligned
types.

__libcpp_allocate/deallocate now take an alignment parameter, and when
the specified alignment is greater than that supported by malloc/new,
the aligned version of operator new is called (assuming it's available).

When aligned new isn't available, the old behavior has been kept, and the
alignment parameter is ignored.

This patch depends on recent changes to __builtin_operator_new/delete which
allow them to be used to call any regular new/delete operator. By using
__builtin_operator_new/delete when possible, the new/delete erasure optimization
is maintained.

llvm-svn: 328180
2018-03-22 04:42:56 +00:00
Nico Weber 6ef990e9ce Fix building libc++ with the macOS 10.13 SDK with -mmacosx-version-min=10.12 or lower.
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
2018-02-06 19:17:41 +00:00
Eric Fiselier 0f8c8f59df Address LWG 2849 and fix missing failure condition in copy_file.
Previously copy_file didn't handle the case where the input and
output were the same file.

llvm-svn: 324187
2018-02-04 02:43:32 +00:00
Marshall Clow b87adec4bd Put the exception classes for experimental::optional and experimental::any back in the dylib for binary compatibility
llvm-svn: 323989
2018-02-01 18:45:57 +00:00
Marshall Clow 5d8babe30d Remove <experimental/any>; use <any> instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 323972
2018-02-01 15:21:14 +00:00
Marshall Clow 040533215a Remove <experimental/optional>; use <optional> instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 323971
2018-02-01 14:54:25 +00:00
Peter Collingbourne 1634c15e3c libcxx: Use vcruntime declarations for typeinfo on Windows.
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
2018-01-26 01:22:17 +00:00
Peter Collingbourne 2f97aab6ea libcxx: Rename vasprintf function to __libcpp_vasprintf.
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
2018-01-23 18:53:33 +00:00
Peter Collingbourne ac15ae6d6b libcxx: Move Windows threading support into a .cpp file.
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
2018-01-23 01:59:43 +00:00
Peter Collingbourne 5e27cce467 libcxx: Define set_unexpected, _get_unexpected and __uncaught_exceptions without dllimport.
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
2018-01-18 00:33:35 +00:00
Peter Collingbourne 4bdb80faf2 libcxx: Stop using private MSVC macros in the exception implementation.
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
2018-01-17 04:37:04 +00:00
Marshall Clow 31163f629b Fix some too-big local arrays. Thanks to dcdillon for the patch. Reviewed as D28217
llvm-svn: 322295
2018-01-11 17:16:52 +00:00
Ekaterina Vaartis e44cbaf704 Make std::experimental::filesystem::remove and remove_all return false or 0 if the file doesn't exist
Differential Revision: https://reviews.llvm.org/D41830

llvm-svn: 322293
2018-01-11 17:04:29 +00:00
Don Hinton 1ec1a9558a [libcxx] Suppress unused warning on apple.
Summary:
This warning is already suppressed on non-apple platforms, so
this change just suppresses it on apple as well.

Reviewers: EricWF, lichray

Reviewed By: lichray

Subscribers: cfe-commits

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

llvm-svn: 321435
2017-12-25 05:33:42 +00:00
Sam Clegg 5029d676f8 [libcxx] Add WebAssembly support
It turns out that this is the only change required in libcxx
for it to compile with the new `wasm32-unknown-unknown-wasm`
target recently added to Clang.

Patch by Nicholas Wilson!

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

llvm-svn: 320925
2017-12-16 18:59:50 +00:00
Petr Hosek 5c70428176 [libcxx] Support getentropy as a source of randomness for std::random_device
Use this source use on Fuchsia where this is the oficially way
to obtain randomness. This could be also used on other platforms
that already support getentropy such as *BSD or Linux.

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

llvm-svn: 319523
2017-12-01 06:34:33 +00:00
Martin Storsjo 771edc7949 Allow to set locale on Windows.
Fix the problem PR31516 with setting locale on Windows by wrapping
_locale_t with a pointer-like class.

Reduces 74 test failures in std/localization test suite to 47 test
failures (on llvm clang, Visual Studio 2015). Number of test failures
doesn't depend on the platform (x86 or x64).

Patch by Andrey Khalyavin.

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

llvm-svn: 318902
2017-11-23 10:38:18 +00:00
Eric Fiselier 98cdfe6bcd Fix PR35078 - recursive directory iterator's increment method throws incorrectly.
The guts of the increment method for recursive_directory_iterator
was failing to pass an error code object to calls to status/symlink_status,
which can throw under certain conditions.

This patch fixes the issues by correctly propagating the error codes.
However the noexcept still needs to be removed from the signature, as
mentioned in LWG 3014, but that change will be made in a separate commit.

llvm-svn: 316939
2017-10-30 18:43:21 +00:00
Shoaib Meenai 492d7134f3 [libc++] Support Microsoft ABI without vcruntime headers
The vcruntime headers are hairy and clash with both libc++ headers
themselves and other libraries. libc++ normally deals with the clashes
by deferring to the vcruntime headers and silencing its own definitions,
but for clients which don't want to depend on vcruntime headers, it's
desirable to support the opposite, i.e. have libc++ provide its own
definitions.

Certain operator new/delete replacement scenarios are not currently
supported in this mode, which requires some tests to be marked XFAIL.
The added documentation has more details.

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

llvm-svn: 315234
2017-10-09 19:25:17 +00:00
Weiming Zhao fbfaec7089 [libc++] Replace __sync_* functions with __libcpp_atomic_* functions
Summary:
This patch replaces __sync_* with __libcpp_atomic_* and adds a wrapper
function for __atomic_exchange to support _LIBCPP_HAS_NO_THREADS.

Reviewers: EricWF, jroelofs, mclow.lists, compnerd

Reviewed By: EricWF, compnerd

Subscribers: compnerd, efriedma, cfe-commits, joerg, llvm-commits

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

llvm-svn: 313694
2017-09-19 23:18:03 +00:00
Saleem Abdulrasool e7b38cdc00 typeinfo: provide a partial implementation for Win32
The RTTI structure is different on Windows when building under MS ABI.
Update the definition to reflect this. The structure itself contains an
area for caching the undecorated name (which is 0-initialized). The
decorated name has a bitfield followed by the linkage name. When
std::type_info::name is invoked for the first time, the runtime should
undecorate the name, cache it, and return the undecorated name. This
requires access to an implementation of __unDName. For now, return
the raw name.

This uses the fnv-1a hash to hash the name of the RTTI. We could use an
alternate hash (murmur? city?), but, this was the quickest to throw
together.

llvm-svn: 313344
2017-09-15 05:42:39 +00:00
Marshall Clow d90758e2ef Make pbump (internally) handle sizes bigger than MAX_INT. Fixes PR#33725 - thanks to Jonathan Wakely for the report
llvm-svn: 313031
2017-09-12 15:00:43 +00:00
Shoaib Meenai 9b8ef6e55a [libc++] Don't hardcode namespace in manual mangling
libc++'s inline namespace can change depending on the ABI version.
Instead of hardcoding __1 in the manual Microsoft ABI manglings for the
iostream globals, stringify _LIBCPP_NAMESPACE and use that instead, to
work across all ABI versions.

llvm-svn: 310290
2017-08-07 19:59:58 +00:00
Marshall Clow c9da8f0f64 Rename a couple variables to eliminate a shadow warning. No functionality change
llvm-svn: 309881
2017-08-02 20:29:26 +00:00
James Y Knight 929f159777 Rework libcxx strerror_r handling.
The set of #ifdefs used to handle the two incompatible variants of
strerror_r were not complete (they didn't handle newlib appropriately).

Rather than attempting to make the ifdefs more complex, make them
unnecessary by choosing which behavior to use dependent upon the
return type.

Reviewers: waltl

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

llvm-svn: 308528
2017-07-19 21:48:49 +00:00
Eric Fiselier e3e7c0fb37 Remove <__refstring> header; Move it into source directory.
The libc++ <__refstring> headers has no real reason why it should
be a public header that libc++ ships. The only reason it was in the include
directory was because libc++abi needed it to build the library.

However keeping <__refstring> a header had other problems, like requiring its
dependancies to also be in the headers. For that reason this patch
moves it into the source directory.

To work around libc++abi's need for this header a duplicated copy was added
to libc++abi in r307748. While duplicating the code is an unfortunate solution
it's the best solution that's currently possible.

In the future I would like to start a discussion on the mailing lists about
making libc++abi build as a sub-project of libc++, requiring the libc++ sources
always be present.

llvm-svn: 307749
2017-07-12 01:38:35 +00:00
Eric Fiselier e82f49849b Revert "[libc++] Refactoring __sync_* builtins; NFC (Reland)"
This reverts commit r307595. The commit had some issues that needed
to first be addressed in review.

llvm-svn: 307746
2017-07-12 01:16:33 +00:00
Weiming Zhao f7850fa8b6 [libc++] Refactoring __sync_* builtins; NFC (Reland)
Summary: Wrap __sync_* builtins with __libcpp_ functions to facility future customizations as atomic operations are unavailable on some targets.

Reviewers: danalbert, EricWF, jroelofs

Subscribers: joerg, llvm-commits

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

llvm-svn: 307595
2017-07-10 21:37:35 +00:00
Weiming Zhao ba5b8c8ee7 Revert "[libc++] Refactoring __sync_* builtins; NFC"
This reverts commit 72ff8866bca49ee7d24c87673293b4ce88a039ec.

llvm-svn: 307593
2017-07-10 21:23:32 +00:00
Weiming Zhao 07f6efddc0 [libc++] Refactoring __sync_* builtins; NFC
Summary: Wrap __sync_* builtins with __libcpp_ functions to facility future customizations as atomic operations are unavailable on some targets.

Reviewers: danalbert, EricWF, jroelofs

Subscribers: joerg, llvm-commits

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

llvm-svn: 307591
2017-07-10 21:02:54 +00:00
Eric Fiselier 433c2f0859 Fix filesystem build on platforms with weird time_t types.
32-bit powerpc provides a 64 bit time_t type and older ppc64 systems
provide time_t as a floating point type. This caused problems when building
operations.cpp since operations.cpp contained compile time tests for conversions
between time_t and filesystem time type.

When these tests failed they caused the libc++ build to fail as well. This is unfortunate.

This patch moves the tests out of the source file and into the test suite. It also
expands the tests to allow testing of the weird time_t configurations on all platforms.

llvm-svn: 307461
2017-07-08 04:18:41 +00:00
Eric Fiselier 459877388b Implement LWG 2937 - equivalent("dne", "exists") is not an error
This patch speculatively implements the PR for LWG 2937, which fixes
two issues with equivalent.

(1) It makes equivalent("dne", "exists") an error. Previously only
    equivalent("dne", "dne") was an error and the former case was not (it returned false).
    Now equivalent reports an error when either input doesn't exist.

(2) It makes equivalent(p1, p2) well-formed when `is_other(p1) && is_other(p2)`.
    Previously this was an error, but there is seemingly no reason why it should be on POSIX system.

llvm-svn: 307117
2017-07-05 03:37:05 +00:00
Duncan P. N. Exon Smith 8b1b1322f1 path: Use string_view_t consistently
Most of filesystem/path.cpp uses string_view_t. This fixes the two spots
that use string_view directly.

https://reviews.llvm.org/D34332

llvm-svn: 305661
2017-06-19 04:27:41 +00:00
Eric Fiselier 63cfb6872b Fix potential bug by casting to the POSIX specified type
llvm-svn: 305549
2017-06-16 06:17:52 +00:00
Eric Fiselier 6af1b7d95c Move external instantiation for __vector_base_common to vector.cpp
Previously the explicit instantiation for this was in locale.cpp,
but that didn't make much sense. This patch creates a new vector.cpp
source file to contain the explicit instantiation.

llvm-svn: 305442
2017-06-15 01:53:12 +00:00
Eric Fiselier 1ec026252b Fix Libc++ build with MinGW64
Summary: This patch corrects the build errors I encountered when building on MinGW64.

Reviewers: mati865, rnk, compnerd, smeenai, bcraig

Reviewed By: mati865, smeenai

Subscribers: martell, chapuni, cfe-commits

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

llvm-svn: 304360
2017-05-31 22:14:05 +00:00
Eric Fiselier a016efb1dc [Libc++] Use #pragma push_macro/pop_macro to better handle min/max on Windows
Summary:
This patch improves how libc++ handles min/max macros within the headers. Previously libc++ would undef them and emit a warning.
This patch changes libc++ to use `#pragma push_macro`  to save the macro before undefining it, and `#pragma pop_macro` to restore the macros and the end of the header.

Reviewers: mclow.lists, bcraig, compnerd, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits, krytarowski

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

llvm-svn: 304357
2017-05-31 22:07:49 +00:00
Eric Fiselier 0c6e7ae4cc Remove usages of _LIBCPP_MSVC which is never defined
llvm-svn: 302736
2017-05-10 21:40:58 +00:00
Eric Fiselier 5d50aa3204 [libc++] Refactor Windows support headers.
Summary:
This patch refactors and tries to remove as much of the Windows support headers as possible. This is needed because they currently introduce super weird include cycles and dependencies between STL and libc headers.

The changes in this patch are:

* remove `support/win32/support.h` completely. The required parts have either been moved into `support/win32/msvc_support.h` (for `MSVC` only helpers not needed by Clang), or directly into their respective `foo.h` headers.

* Combine `locale_win32.h` and `locale_mgmt_win32.h` into a single headers, this header should only be included within `__locale` or `locale` to avoid include cycles.

* Remove the unneeded parts of `limits_win32.h` and re-name it to `limits_msvc_win32.h` since it's only needed by Clang.

I've tested this patch using Clang on Windows, but I suspect it might technically regress our non-existent support for MSVC. Is somebody able to double check?

This refactor is needed to support upcoming fixes to `<locale>` on Windows.



Reviewers: bcraig, rmaprath, compnerd, EricWF

Reviewed By: EricWF

Subscribers: majnemer, cfe-commits

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

llvm-svn: 302727
2017-05-10 20:57:45 +00:00
Eric Fiselier b4ddab26bc Refactor <locale> RAII guards to aid upcoming Windows locale changes.
Previously <locale> used std::unique_ptr<remove_ptr<locale_t>, locale-mgmt-function>
as a scope guard for (A) creating new locales, and (B) setting the thread specific locale
in RAII safe manner.

However using unique_ptr has some problems, first it requires that locale_t is a pointer
type, which may not be the case (Windows will need a non-pointer locale_t type that emulates _locale_t).

The second problem is that users of the guards had to supply the locale management function to the custom
deleter at every call site. However these locale management functions don't exist natively Windows, making
a good Windows implementation of locale more difficult.

This patch creates distinct and simply RAII guards that replace unique_ptr. These guards handle calling
the correct locale management function so that callers don't have too. This simplification will
aid in upcoming Windows fixes.

llvm-svn: 302474
2017-05-08 22:02:43 +00:00
Eric Fiselier 3e254a6ece [libc++] Implement exception_ptr on Windows
Summary:
This patch implements exception_ptr on Windows using the `__ExceptionPtrFoo` functions provided by MSVC.

The `__ExceptionPtrFoo` functions are defined inside the C++ standard library, `msvcprt`, which is unfortunate because it requires libc++ to link to the MSVC STL. However this doesn't seem to cause any immediate problems. However to be safe I kept all usages within the libc++ dylib so that user programs wouldn't have to link to MSVCPRT as well.

Note there are still 2 outstanding exception_ptr/nested_exception test failures.

* `current_exception.pass.cpp` needs to be rewritten for the Windows exception_ptr semantics which copy the exception every time.
* `rethrow_if_nested.pass.cpp` need investigation. It hits a stack overflow, likely from recursion.

This patch also gets most of the `<future>` tests passing as well.

Reviewers: mclow.lists, compnerd, bcraig, rmaprath, majnemer, BillyONeal, STL_MSFT

Subscribers: mgorny, cfe-commits

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

llvm-svn: 302393
2017-05-08 01:17:50 +00:00
Eric Fiselier f7ae14dbb9 Fix remaining GCC 7 build warnings
llvm-svn: 302283
2017-05-05 20:39:03 +00:00
Eric Fiselier 807790a09b Fix new warnings emitted by GCC 7
llvm-svn: 302280
2017-05-05 20:32:26 +00:00
Eric Fiselier 61a241ef11 Fix incorrect usage of __libcpp_mutex_trylock. Patch from Andrey Khalyavin
llvm-svn: 302129
2017-05-04 07:45:09 +00:00
Eric Fiselier 9c973b9f62 Use nullptr instead of the literal 0
llvm-svn: 302100
2017-05-04 01:06:56 +00:00
Shoaib Meenai 3698889a7b [libc++] Use _LIBCPP_ABI_MICROSOFT instead of _MSC_VER
_LIBCPP_ABI_MICROSOFT is more appropriate to use here, since the
conditionals are controlling Microsoft mangling. It wasn't used
originally since it didn't exist at the time.

llvm-svn: 300743
2017-04-19 20:11:04 +00:00
Shoaib Meenai 17af695f2b [libc++] Drop support for CRTs older than VS 2015
LLVM dropped support for Visual Studio versions older than 2015 quite
some time ago, so I consider it safe to drop libc++'s support for older
CRTs. The CRT in Visual Studio 2015 provides a lot of previously missing
functions, so targeting it requires less special casing.

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

llvm-svn: 299743
2017-04-07 02:20:52 +00:00