Commit Graph

5379 Commits

Author SHA1 Message Date
Louis Dionne a470a13a70 [libc++] Enable deprecation warnings by default
Summary:
In r342843, I added deprecation warnings to some facilities that were
deprectated in C++14 and C++17. However, those deprecation warnings
were not enabled by default.

After discussing this on IRC, we had finally gotten consensus to enable
those warnings by default, and I'm getting around to doing that only
now.

Reviewers: mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, jdoerfert, libcxx-commits

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

llvm-svn: 355961
2019-03-12 20:10:06 +00:00
Eric Fiselier 86af6f5088 Allow optional to tolerate being used with a nested class.
When Clang tries to complete a type containing `std::optional` it
considers the `in_place_t` constructor with no arguments which checks
if the value type is default constructible. If the value type is a
nested class type, then this check occurs too early and poisons the
is_default_constructible trait.

This patch makes optional deduce `in_place_t` so we can prevent
this early SFINAE evaluation. Technically this could break people
doing weird things with the in_place_t tag, but that seems less
important than making the nested class case work.

llvm-svn: 355877
2019-03-11 22:55:21 +00:00
Louis Dionne 3836a49039 [libc++] Remove empty header xlocale/xlocale.h
Summary:
I can't think of a reason for shipping this empty header. If there is
a reason to do so, then hopefully this review can uncover it.

Reviewers: mclow.lists, EricWF

Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits

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

llvm-svn: 355829
2019-03-11 15:41:51 +00:00
Eric Fiselier 7ffcd984c4 LWG 2843 "Unclear behavior of std::pmr::memory_resource::do_allocate()"
Patch by Arthur O'Dwyer.
Reviewed as https://reviews.llvm.org/D47344

new_delete_resource().allocate(n, a) has basically two permissible results:

* Return an appropriately sized and aligned block.
* Throw bad_alloc.

Before this patch, libc++'s new_delete_resource would do a third and impermissible thing, which was
to return an appropriately sized but inappropriately under-aligned block. This is now fixed.

(This came up while I was stress-testing unsynchronized_pool_resource on my MacBook. If we can't
trust the default resource to return appropriately aligned blocks, pretty much everything breaks.
For similar reasons, I would strongly support just patching __libcpp_allocate directly, but I don't
care to die on that hill, so I made this patch as a <memory_resource>-specific workaround.)

llvm-svn: 355763
2019-03-09 00:38:19 +00:00
Eric Fiselier 411210838d Work around dllimport bug with exclude_from_explicit_instantiation.
When dllimport is specified on a class, and
exclude_from_explicit_instatiation is specified on a member, clang-cl
will still expect a definition to be available externally. But this is
not correct.

Surprisingly one one symbol seems to be consistently affected by this
bug. So this patch simply works around it there.

llvm-svn: 355760
2019-03-08 23:59:29 +00:00
Eric Fiselier 3e3d6c9038 Fix C++03 build failure
llvm-svn: 355758
2019-03-08 23:30:26 +00:00
Eric Fiselier 9dd9495a35 Revert "[libc++] Do not force building with -fPIC"
This reverts commit r355764.

CMake does not turn -fPIC on for us by default. so this patch breaks
standalone builds. The only reason it hasn't broken any bots is because
LLVM turns on and specifies '-fPIC' for us.

llvm-svn: 355756
2019-03-08 23:27:46 +00:00
Eric Fiselier 0e1586c4fb Unbork `std::memory_order` ABI.
Summary:
We need to pin the underlying type of C++20' `std::memory_order` to match the C++17 version. Anything less is an ABI break.

At the moment it's `unsigned` before C++20 and `int` after. Or if you're using `-fshort-enums` it's `unsigned char` before C++20 and `int` after.

This patch explicitly specifies the underlying type of the  C++20 `memory_order` to be w/e type the compiler would have chosen for the C++17 version.

Reviewers: mclow.lists, ldionne

Reviewed By: ldionne

Subscribers: jfb, jdoerfert, #libc, zoecarver

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

llvm-svn: 355755
2019-03-08 23:15:54 +00:00
Eric Fiselier 6e4ec6022f Fix PR41017 - Build failure with _LIBCPP_DEBUG=0 and non-const-ref
comparator for std::sort()

Our debug comparator assumed that the comparator it wraps would always
accepts the values by const ref. This isn't required by the standard.

This patch makes our __debug_less comparator forward the constness.

llvm-svn: 355752
2019-03-08 22:58:59 +00:00
Louis Dionne 2714d58901 [libc++] Do not force building with -fPIC
Summary:
Whether we build with -fPIC should be specified by the
CMAKE_POSITION_INDEPENDENT_CODE option at configure time.
Note that this patch doesn't change the behavior when building
by default, since -fPIC is used for shared libraries by default.

Reviewers: EricWF

Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits

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

llvm-svn: 355746
2019-03-08 22:24:12 +00:00
Louis Dionne 3d678b5336 [NFC] Add missing revision information to ABI Changelog
llvm-svn: 355732
2019-03-08 21:01:25 +00:00
Matthew Voss 1262e52e16 Revert "[runtimes] Move libunwind, libc++abi and libc++ to lib/ and include/"
This broke the windows bots.

This reverts commit 28302c66d2.

llvm-svn: 355725
2019-03-08 20:33:55 +00:00
Petr Hosek 28302c66d2 [runtimes] Move libunwind, libc++abi and libc++ to lib/ and include/
This change is a consequence of the discussion in "RFC: Place libs in
Clang-dedicated directories", specifically the suggestion that
libunwind, libc++abi and libc++ shouldn't be using Clang resource
directory.  Tools like clangd make this assumption, but this is
currently not true for the LLVM_ENABLE_PER_TARGET_RUNTIME_DIR build.
This change addresses that by moving the output of these libraries to
lib/<target> and include/ directories, leaving resource directory only
for compiler-rt runtimes and Clang builtin headers.

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

llvm-svn: 355665
2019-03-08 05:35:22 +00:00
Thomas Anderson 516d07de07 [libc++] Fix use-after-free when building with _LIBCPP_DEBUG=1
The issue is the following code:

    __cn1->__add(*__ip);
    (*__ip)->__c_ = __cn1;

`__ip` points into the array of iterators for container `__cn2`.  This code adds
the iterator to the array of iterators for `__cn1`, and updates the iterator to
point to the new container.

This code works fine, except when `__cn1` and `__cn2` are the same container.
`__cn1->__add()` might need to grow the array of iterators, and when it does,
`__ip` becomes invalid, so the second line becomes a use-after-free error.

Simply swapping the order of the above two lines is not sufficient, because of
the memmove() below.  The easiest and most performant solution is just to skip
touching any iterators if the containers are the same.

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

llvm-svn: 355550
2019-03-06 21:10:08 +00:00
Eric Fiselier 2710d8e105 Fix ABI compatibility of `<stdexcept>` with VCRuntime.
Summary:
Currently, libc++'s `<stdexcept>` doesn't play nice with `vcruntime`. Specifically:

* `logic_error` and `runtime_error` have a different layout.
* libc++'s `logic_error` and `runtime_error` override `what()` but `vcruntime` does not.
*  `vcruntime` uses weak vtables for `<stdexcept>` types.
* libc++'s `<stdexcept>` constructors and assignment operators may have different manglings than `vcruntimes`.

This patch makes libc++'s declarations in `<stdexcept>` match those provided by MSVC's STL as closely as possible.
If MSVC doesn't declare a special member, then neither do we. This ensures that the implicit definitions have the same linkage, visibility, triviality, and noexcept-ness.







Reviewers: thomasanderson, ldionne, smeenai

Reviewed By: thomasanderson

Subscribers: jdoerfert, libcxx-commits

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

llvm-svn: 355546
2019-03-06 20:31:57 +00:00
Louis Dionne 930007ba76 [libc++] Do not specify the underlying type of memory_order
Summary:
This breaks ABI for folks using -fshort-enums, and does not really buy
us anything.

http://llvm.org/PR40977

Reviewers: mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits, zoecarver

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

llvm-svn: 355521
2019-03-06 17:07:24 +00:00
Marshall Clow 8eda3ad29d Eradicate all the ptrdiff_ts in span left over from applying P1227. A couple of other minor cleanups. NFC
llvm-svn: 355481
2019-03-06 03:59:44 +00:00
Louis Dionne bbdddb7b0e [libc++] Only add dylib-related features when using the system's libc++
Otherwise, when testing trunk libc++ on an older system, lit will think
that the dylib features are disabled. Ideally, we'd have a notion of
running the tests with/without a deployment target (or, equivalently,
a deployment target representing trunk where everything is as recent
as can be). Since we always have a deployment target right now (which
defaults to the current system), we only enable those features when
we're going to also be testing with the system libc++.

We also need to disable the availability markup when we are not running
a system library flavor, because availability markup does not make sense
when building against the trunk libc++ (which has everything regardless
of what the current system is).

This is a re-application of r353319, which had been reverted due to
CI breakage. This time around, I made sure it didn't break our internal
CI before submitting.

This is also a partial undoing of r348296, in spirit at least. However,
with this patch, availability markup is enabled based on whether we're
using a system library or not, whereas previously one could enable
it or disable it arbitrarily. This was confusing as it led to testing
configurations that don't make sense (such as testing a system library
without availability markup, or trunk testing with availability markup).

llvm-svn: 355451
2019-03-05 22:42:45 +00:00
Davide Italiano 6de760ac4e Reinstate libc++ patches now that the lldb formatter has been updated.
"[libc++] Fix <atomic> failures on GCC"
"[libc++] Change memory_order to an enum class"
"[libc++] decoupling Freestanding atomic<T> from libatomic.a"

llvm-svn: 355427
2019-03-05 18:40:49 +00:00
Davide Italiano 1061cb6a93 [libcxx] Revert set of atomic patches that broke lldb.
Revert "[libc++] Fix <atomic> failures on GCC"
Revert "[libc++] Change memory_order to an enum class"
Revert "[libc++] decoupling Freestanding atomic<T> from libatomic.a"

The lldb formatter nededs to be updated. Shafik and Louis will
coordinate to do so.

llvm-svn: 355417
2019-03-05 17:38:33 +00:00
Louis Dionne 130322e7cc [libc++] Fix <atomic> failures on GCC
Summary:
In https://reviews.llvm.org/D58201, we turned memory_order into an enum
class in C++20 mode. However, we were not casting memory_order to its
underlying type correctly for the GCC implementation, which broke the
build bots. I also fixed a test that was failing in C++17 mode on GCC 5.

Reviewers: EricWF, jfb, mclow.lists

Subscribers: zoecarver

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

llvm-svn: 355409
2019-03-05 15:49:58 +00:00
Louis Dionne b55803283b [libc++] Change memory_order to an enum class
This implements P0439R0.

Thanks to Zoe Carver for the patch.
Differential Revision: https://reviews.llvm.org/D58201

llvm-svn: 355403
2019-03-05 14:50:25 +00:00
Eric Fiselier 1c014d75b4 Fix -fsanitize=vptr badness in <__debug>
Summary:

This patch fixes a lifetime bug when inserting a new container into the debug database. It is
diagnosed by UBSAN when debug mode is enabled. This patch corrects how nodes are constructed
during insertion.

The fix requires unconditionally breaking the debug mode ABI. Users should not expect ABI
stability from debug mode.

Reviewers: ldionne, serge-sans-paille, EricWF

Reviewed By: EricWF

Subscribers: mclow.lists, christof, libcxx-commits

Tags: #libc

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

llvm-svn: 355367
2019-03-05 02:10:31 +00:00
Eric Fiselier e69290dc7f Make VCRuntime ABI configuration a first-class option.
Summary:
On Windows we currently provide two separate ABI configurations. One which defers to `vcruntime` to provide the C++ runtime and another which doesn't.
Using `vcruntime` allows interoperability which programs compiled against the MSVC STL, and should be preferred whenever possible.

When deferring to `vcruntime` much of the ABI we provide changes. Including the layout of `<stdexcept>` types, their vtables, and how the linkage of their members.

This patch introduces the `_LIBCPP_ABI_VCRUNTIME` macro to denote this configuration. It also cleans up the existing configuration for using `vcruntime`.

This cleanup lays the groundwork for fixing a number of ABI and interoperability bugs in  `<stdexcept>`.


Reviewers: thomasanderson, ldionne, smeenai

Reviewed By: smeenai

Subscribers: jdoerfert, libcxx-commits, #libc

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

llvm-svn: 355366
2019-03-05 01:57:01 +00:00
Louis Dionne fc778fa2c5 [libc++] Remove old CMake workaround
We haven't had any complaints so far, and I don't think anybody builds
libc++ from source for that old platform anymore.

llvm-svn: 355336
2019-03-04 20:52:14 +00:00
Eric Fiselier 8b73ab29c3 Install GCC 5 on buildbots to replace GCC 4.9.
LLVM is dropping support for GCC 4.9. This patch adds
a GCC 5 installation to the buildbot image so we can upgrade
the 4.9 bot to GCC 5.

As a temporary workaround until zorg updates, we install GCC 5
as GCC 4.9.

llvm-svn: 355334
2019-03-04 20:49:18 +00:00
Louis Dionne 21450545d1 [libc++] decoupling Freestanding atomic<T> from libatomic.a
This patch introduces non-lockfree atomics that do not require using
an external libatomic. This work is done with the long-term goal of
allowing the use of <atomic> in freestanding environments.

Thanks to Olivier Giroux for the patch.
Differential Revision: https://reviews.llvm.org/D56913

llvm-svn: 355318
2019-03-04 15:26:27 +00:00
Louis Dionne afde07ce97 [libc++] Fix forgotten fclose() in unit test
Thanks to Andrey Maksimov for the patch.
Differential Revision: https://reviews.llvm.org/D58732

llvm-svn: 355162
2019-03-01 01:32:44 +00:00
Louis Dionne e90085029c [libc++] Increase portability of xalloc test
Do not assume that xalloc() starts at 0, which is not specified by the
Standard.

Thanks to Andrey Maksimov for the patch.
Differential Revision: https://reviews.llvm.org/D58299

llvm-svn: 355160
2019-03-01 00:51:54 +00:00
Louis Dionne 4fcdf21406 [NFC][libc++] Update comment about oldest supported macosx for back-deployment
llvm-svn: 355043
2019-02-27 23:36:22 +00:00
Louis Dionne ab19068b7f [libc++] Add is_nothrow_convertible from P0758R1
Reviewed as https://reviews.llvm.org/D58019.
Thanks to Zoe Carver for the patch.

llvm-svn: 355010
2019-02-27 17:57:38 +00:00
Louis Dionne 1be935f418 [libc++] Remove visibility-related warnings with Clang 8
The attributes were placed incorrectly -- they need to be after the
"struct" keyword, not before.

llvm-svn: 355006
2019-02-27 17:33:25 +00:00
Marshall Clow 5c814099c7 I changed a 'enable_if<...>::type to' 'enable_if_t<...>' but forgot to remove the preceding 'typename'
llvm-svn: 354995
2019-02-27 16:09:35 +00:00
Marshall Clow 02e1651c1f Implment the last part of P1024: tuple-like interface to span. Reviewed as https://reviews.llvm.org/D58706.
llvm-svn: 354988
2019-02-27 15:41:37 +00:00
Marshall Clow 2ffa170515 In the review of D58642, Louis asked: 'Is there a reason for making this inline? Templates are already inline by default'. I told him that I didn't want to change the one call (ssize) that I was adding, but would come back later and clean them all (data/empty/begin/end/cbegin/cend/rbegin/rend/crbegin/crend/size/ssize) up later. Now it is later. Remove the unnecessary 'inline' modifiers from all these calls.
llvm-svn: 354952
2019-02-27 03:25:43 +00:00
Marshall Clow 7d3986ea30 Implement the second part of P1227R2 - Signed ssize() functions. Reviewed as https://reviews.llvm.org/D58642
llvm-svn: 354950
2019-02-27 02:58:56 +00:00
Marshall Clow ded9f0efad Fix an ambiguity in the tests that gcc-tot complained about.
llvm-svn: 354944
2019-02-27 01:29:52 +00:00
Louis Dionne 62f3900715 [libc++] Add a test for PR14074
PR14074 was fixed in r165884, but no tests were added.

llvm-svn: 354943
2019-02-27 01:29:09 +00:00
Louis Dionne 25838c6dac [libc++] Mark several tests as XFAIL on macosx10.7
Those tests fail when linking against a new dylib but running against
macosx10.7. I believe this is caused by a duplicate definition of the
RTTI for exception classes in libc++.dylib and libc++abi.dylib, but
this matter still needs some investigation.

This issue was not caught previously because all the tests always linked
against the same dylib used for running (because LIT made it impossible
to do otherwise before r349171).

rdar://problem/46809586

llvm-svn: 354940
2019-02-27 00:57:57 +00:00
Marshall Clow 7ad06a9319 First part of P1227R2 - change span over to use 'size_t' instead of 'ptrdiff_t'. Reviewed as https://reviews.llvm.org/D58639.
llvm-svn: 354936
2019-02-27 00:32:16 +00:00
Louis Dionne 27f79151ec [libc++] Add <filesystem> to the min-mac macro header test
llvm-svn: 354932
2019-02-26 23:14:58 +00:00
Marshall Clow c0170de222 Remove P1272R1, it was not moved in Kona
llvm-svn: 354904
2019-02-26 18:17:30 +00:00
Marshall Clow a04143ee27 Put a 'first implemented' version into the entry for P1357
llvm-svn: 354901
2019-02-26 17:22:47 +00:00
Marshall Clow 7b4ab3b9e4 Mark several issues (and one paper) as complete. Reviewed as D58099; but I added LWG3101 and LWG3144 and P1357R1 as well.
llvm-svn: 354898
2019-02-26 17:01:00 +00:00
Marshall Clow 46c719ddcd Implement P1357: Traits for [Un]bounded Arrays; adopted in Kona
llvm-svn: 354891
2019-02-26 16:07:03 +00:00
Louis Dionne 5d79eaa82f [libc++] Rename _NOALIAS macro to _LIBCPP_NOALIAS
Summary:
For consistency, libc++ macros always start with _LIBCPP. This should
have no functionality change.

Reviewers: EricWF, mclow.lists

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

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

llvm-svn: 354848
2019-02-26 06:34:42 +00:00
Marshall Clow 310b75e519 LWG3101 - span's Container constructors need another constraint. Reviewed as https://reviews.llvm.org/D57058.
llvm-svn: 354805
2019-02-25 18:32:57 +00:00
Marshall Clow 4fd0395477 Commit LWG3144 - span does not have a const_pointer typedef. Reviewed as D57039.
llvm-svn: 354802
2019-02-25 17:58:03 +00:00
Marshall Clow 9ab85a69dc First part of P1024: Usability Enhancements for std::span. Remove operator() for indexing, and add 'front' and 'back' calls.
llvm-svn: 354801
2019-02-25 17:54:08 +00:00
Marshall Clow 8a7f4c9891 Update status page with papers/issues adopted in Kona
llvm-svn: 354796
2019-02-25 16:12:00 +00:00