Commit Graph

5079 Commits

Author SHA1 Message Date
Eric Fiselier 0ef540bd51 Correct docs to reference the new libc++ lists.
We recently added libcxx-dev and libcxx-commits mailing lists.
This patch updates the libc++ documentation to correctly reference
the libc++ lists instead of the old Clang ones.

llvm-svn: 342816
2018-09-22 19:49:29 +00:00
Roman Lebedev 931d66cd22 [libcxx] Blind attempt to fix harmless leak in nodiscard_extensions.pass.cpp test
libcxx-libcxxabi-x86_64-linux-ubuntu-asan complains about a leak here.

llvm-svn: 342814
2018-09-22 19:09:57 +00:00
Louis Dionne 8a15c924ae [libcxx] Fix the definition of the check-cxx-abilist target on Darwin
Summary:
r342805 added support for the check-cxx-abilist target on FreeBSD, but broke
the target on macOS in doing so. The problem is that the GENERIC_TARGET_TRIPLE
gets overwritten after replacing the FreeBSD regular expression, which
nullifies the replacement done with the darwin regular expression.

Reviewers: dim, EricWF

Subscribers: emaste, mgorny, krytarowski, christof, dexonsmith, cfe-commits, libcxx-commits

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

llvm-svn: 342813
2018-09-22 18:39:38 +00:00
Zhihao Yuan dbbb4b104d Document new symbols for __u64toa and __u32toa
Summary:
They are introduced in r338479; their Linux ABI changes are recorded in r338486.

TODO: Record the Mac OS X ABI changes.

Reviewers: EricWF

Reviewed By: EricWF

Subscribers: christof, ldionne, libcxx-commits, cfe-commits

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

llvm-svn: 342810
2018-09-22 18:05:28 +00:00
Roman Lebedev c65d39a464 [libc++] Add _LIBCPP_ENABLE_NODISCARD and _LIBCPP_NODISCARD_EXT to allow pre-C++2a [[nodiscard]]
Summary:
The `[[nodiscard]]` attribute is intended to help users find bugs where
function return values are ignored when they shouldn't be. After C++17 the
C++ standard has started to declared such library functions as `[[nodiscard]]`.
However, this application is limited and applies only to dialects after C++17.
Users who want help diagnosing misuses of STL functions may desire a more
liberal application of `[[nodiscard]]`.

For this reason libc++ provides an extension that does just that! The
extension must be enabled by defining `_LIBCPP_ENABLE_NODISCARD`. The extended
applications of `[[nodiscard]]` takes two forms:

1. Backporting `[[nodiscard]]` to entities declared as such by the
   standard in newer dialects, but not in the present one.

2. Extended applications of `[[nodiscard]]`, at the libraries discretion,
   applied to entities never declared as such by the standard.

Users may also opt-out of additional applications `[[nodiscard]]` using
additional macros.

Applications of the first form, which backport `[[nodiscard]]` from a newer
dialect may be disabled using macros specific to the dialect it was added. For
example `_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17`.

Applications of the second form, which are pure extensions, may be disabled
by defining `_LIBCPP_DISABLE_NODISCARD_EXT`.

This patch was originally written by me (Roman Lebedev),
then but then reworked by Eric Fiselier.

Reviewers: mclow.lists, thakis, EricWF

Reviewed By: thakis, EricWF

Subscribers: llvm-commits, mclow.lists, lebedev.ri, EricWF, rjmccall, Quuxplusone, cfe-commits, christof

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

llvm-svn: 342808
2018-09-22 17:54:48 +00:00
Dimitry Andric f3b94728c7 Similar to the handling of darwin target triples, strip the version
numbers off of freebsd target triples, when generating the name of the
ABI list file for check-cxx-abilist target.

Also remove unnecessary parentheses in the regex for darwin, and
slightly reword the comment.

llvm-svn: 342805
2018-09-22 14:37:49 +00:00
Sylvestre Ledru 6616b4c9e9 fix some typos in the doc
llvm-svn: 342628
2018-09-20 08:05:01 +00:00
Sylvestre Ledru 8e5a0b1f7b add a quick link to libc++abi
llvm-svn: 342625
2018-09-20 07:58:43 +00:00
Sylvestre Ledru 0296eea49b refresh the libc++ homepage
llvm-svn: 342624
2018-09-20 07:57:31 +00:00
Eric Fiselier 2d79835ccb Fix diagnostic regex in variant tests to tolerate older clang versions
llvm-svn: 342609
2018-09-20 01:15:17 +00:00
Volodymyr Sapsai 8d6ac8f689 Revert "Implement LWG 2221 - No formatted output operator for nullptr."
This reverts r342566 as it causes on bots linker errors like

> Undefined symbols for architecture i386:
>   "std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(std::nullptr_t)", referenced from:

llvm-svn: 342599
2018-09-19 23:31:34 +00:00
Marshall Clow 4a71f9cfcc Implement LWG 2221 - No formatted output operator for nullptr. Reviewed as https://reviews.llvm.org/D44263
llvm-svn: 342566
2018-09-19 18:29:57 +00:00
Eric Fiselier 7dca3127c2 Don't require relops on variant alternatives to all return the same
type.

Libc++ correctly asserts that a set of visitors for a variant all
return the same type. However, we use the visitation machinary to
perform relational operations. This causes a static assertion when
some of the alternatives relops return a UDT which is implicitly
convertible to bool instead of 'bool' exactly.

llvm-svn: 342560
2018-09-19 17:53:21 +00:00
Marshall Clow 8ae45e0e59 Remove unused include of "verbose_assert.h"
llvm-svn: 342524
2018-09-19 02:27:44 +00:00
Fangrui Song cac6d21731 Fix typo
llvm-svn: 342361
2018-09-17 07:40:42 +00:00
Marshall Clow 08ebf19e52 Mark LWG#3102 as complete. No code changes, but I updated a test or two
llvm-svn: 342103
2018-09-13 02:23:52 +00:00
Marshall Clow f56972e224 Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955
llvm-svn: 342073
2018-09-12 19:41:40 +00:00
Marshall Clow a4ce437104 Actually mark LWG#2953, don't just say you've done so in r342070
llvm-svn: 342071
2018-09-12 18:53:02 +00:00
Marshall Clow 71f7d7b1c7 mark LWG#2953 as complete. No code changes required, but added a couple of extra tests.
llvm-svn: 342070
2018-09-12 18:51:12 +00:00
Marshall Clow 4d0509f61a Update the failure annotations for the uncaught_exceptions test. The underlying abi library on some Mac OS versions does not support the plural uncaught_exceptions, so libc++ emulates it from the singlar; this means it will only return 0 or 1.
llvm-svn: 342063
2018-09-12 16:59:09 +00:00
Marshall Clow ebff3123a2 Implement LWG #3017. list splice functions should use addressof
llvm-svn: 342057
2018-09-12 14:46:17 +00:00
Marshall Clow 48e5b8b1a4 Update the synopsis for <version>. NFC
llvm-svn: 341990
2018-09-11 20:51:54 +00:00
Marshall Clow e9cc545129 Fix PR# 38900 - don't call swap inside of random_shuffle when we'd be swapping an element with itself
llvm-svn: 341975
2018-09-11 18:33:45 +00:00
Hans Wennborg 462429c03d ReleaseNotes: update links to use https
llvm-svn: 341789
2018-09-10 08:57:12 +00:00
Marshall Clow 226c14a5fa [asan] Update a vector's storage annotation during destruction. Reviewed as https://reviews.llvm.org/D50101. Thanks to bobsayshilol (Ben) for the patch.
llvm-svn: 341671
2018-09-07 15:47:59 +00:00
Louis Dionne 38895a0d80 [libc++] Add a link to the Release notes from the main libc++ documentation
llvm-svn: 341551
2018-09-06 15:05:43 +00:00
Louis Dionne 0fb7c99001 [libcxx] Add ReleaseNotes.rst file for release notes
llvm-svn: 341550
2018-09-06 14:46:22 +00:00
Marshall Clow d0ab67f7d0 Last week, someone noted that a couple of the time_point member functions were not constexpr. I looked, and they were right. They were made constexpr in p0505, so I looked at all the other bits in that paper to make sure that I didn't miss anything else. There were a couple methods in the synopsis that should have been marked constexpr, but the code was correct.
llvm-svn: 340992
2018-08-29 23:02:15 +00:00
Marshall Clow fa8ce34534 Use addressof instead of operator& in make_shared. Fixes PR38729. As a drive-by, make the same change in raw_storage_iterator (twice).
llvm-svn: 340823
2018-08-28 13:29:30 +00:00
Richard Smith 67c364dd9b Fix ODR violation: namespace-scope helpers should not be declared 'static'.
llvm-svn: 340778
2018-08-27 21:41:50 +00:00
Marshall Clow 05ff3d3bf7 Mark P0556 as 'in progress'
llvm-svn: 340752
2018-08-27 16:07:01 +00:00
Louis Dionne 954d4a2235 [libc++] Fix handling of negated character classes in regex
Summary:
This commit fixes a regression introduced in r316095, where we don't match
inverted character classes when there's no negated characrers in the []'s.

rdar://problem/43060054

Reviewers: mclow.lists, timshen, EricWF

Subscribers: christof, dexonsmith, cfe-commits

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

llvm-svn: 340609
2018-08-24 14:10:28 +00:00
Louis Dionne 616ef1863f [libc++] Remove race condition in std::async
Summary:
The state associated to the future was set in one thread (with synchronization)
but read in another thread without synchronization, which led to a data race.

https://bugs.llvm.org/show_bug.cgi?id=38181
rdar://problem/42548261

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, cfe-commits

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

llvm-svn: 340608
2018-08-24 14:00:59 +00:00
Erik Pilkington cda06daf3f Comment out #define __cpp_lib_node_extract, we only support half of that functionality
Differential revision: https://reviews.llvm.org/D51172

llvm-svn: 340544
2018-08-23 17:08:02 +00:00
Reid Kleckner a65d943e33 Disable the aligned allocation test on old mac versions instead of XFAILing it
It looks like this test XPASSes when the deployment target is older than
the OS of the system the test is running on. It looks like we run the
tests with -mmacosx-version-min=10.12, and that makes the test expect to
fail, but it passes.

llvm-svn: 340427
2018-08-22 17:47:41 +00:00
Eric Fiselier a60d7fac09 Add diagnostics for min/max algorithms when a InputIterator is used.
These algorithms require a ForwardIterator or better. Ensure
we diagnose the contract violation at compile time instead of
of silently doing the wrong thing.

Further algorithms will be audited in upcoming patches.

llvm-svn: 340426
2018-08-22 17:47:13 +00:00
Eric Fiselier 0353308710 Attempt to unbreak filesystem tests on certain linux distros.
On some platforms clock_gettime is in librt, which we don't
link by default when building the tests. However it is required
by the filesystem tests.

This patch introduces a workaround which links librt whenever
the filesystem tests are enabled. The workaround should later
be replaced with a patch that selectively links both libc++fs
and librt only when building filesystem specific tests. However,
the way the test configuration is set up right now, this is
non-trivial.

llvm-svn: 340406
2018-08-22 13:29:52 +00:00
Marshall Clow 934e9a3976 Fix Bug 38644: multimap::clear() missing exception specifier. Add noexcept tests for all the containers that have clear().
llvm-svn: 340385
2018-08-22 04:28:43 +00:00
Kamil Rytarowski 22c9256a49 Teach libc++ to use native NetBSD's max_align_t
Summary:
The NetBSD headers ship with max_align_t, that is not
compatible with the fallback version in libc++.

There is no defined a compiler specific symbol in the headers like:
 - __CLANG_MAX_ALIGN_T_DEFINED
 - _GCC_MAX_ALIGN_T
 - __DEFINED_max_align_t

Sponsored by <The NetBSD Foundation>

Reviewers: chandlerc, dlj, EricWF, joerg

Reviewed By: joerg

Subscribers: bsdjhb, llvm-commits, cfe-commits

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

llvm-svn: 340224
2018-08-20 22:29:20 +00:00
Marshall Clow ecb7f4da68 Refactor the newly created <bit> header. Still (almost) NFC. Reviewed as https://reviews.llvm.org/D50876
llvm-svn: 340049
2018-08-17 17:27:25 +00:00
Marshall Clow e02ee4f013 Recommit r339943 - Establish the <bit> header. NFC yet. Reviewed as https://reviews.llvm.org/D50815 - with a fix for the sanitizer bots
llvm-svn: 340045
2018-08-17 16:07:48 +00:00
Vitaly Buka 0d52fce74d Revert "Establish the <bit> header. NFC yet. Reviewed as https://reviews.llvm.org/D50815"
Breaks build on sanitizer bots.

This reverts commit r339943.

llvm-svn: 339971
2018-08-16 23:57:16 +00:00
Hubert Tong 2c0fad59df [libc++] Use correct rand.eng.mers all-zeroes seed sequence fallback
Summary:
When a seed sequence would lead to having no non-zero significant bits
in the initial state of a `mersenne_twister_engine`, the fallback is to
flip the most significant bit of the first value that appears in the
textual representation of the initial state.

rand.eng.mers describes this as setting the value to be 2 to the power
of one less than w; the previous value encoded in the implementation,
namely one less than "2 to the power of w", is replaced by the correct
value in this patch.

Reviewers: mclow.lists, EricWF, jasonliu

Reviewed By: mclow.lists

Subscribers: mclow.lists, jasonliu, EricWF, christof, ldionne, cfe-commits

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

llvm-svn: 339969
2018-08-16 23:56:54 +00:00
Marshall Clow 496bb865c6 Establish the <bit> header. NFC yet. Reviewed as https://reviews.llvm.org/D50815
llvm-svn: 339943
2018-08-16 21:35:38 +00:00
Louis Dionne 61cd687009 [libcxx] By default, do not use internal_linkage to hide symbols from the ABI
Summary:
https://reviews.llvm.org/D49240 led to symbol size problems in Chromium, and
we expect this may be the case in other projects built in debug mode too.
Instead, unless users explicitly ask for internal_linkage, we use always_inline
like we used to.

In the future, when we have a solution that allows us to drop always_inline
without falling back on internal_linkage, we can replace always_inline by
that.

Note that this commit introduces a change in contract for existing libc++
users: by default, libc++ used to guarantee that TUs built with different
versions of libc++ could be linked together. With the introduction of the
_LIBCPP_HIDE_FROM_ABI_PER_TU macro, the default behavior is that TUs built
with different libc++ versions are not guaranteed to link. This is a change
in contract but not a change in behavior, since the current implementation
still allows linking TUs built with different libc++ versions together.

Reviewers: EricWF, mclow.lists, dexonsmith, hans, rnk

Subscribers: christof, cfe-commits

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

llvm-svn: 339874
2018-08-16 12:44:28 +00:00
Marshall Clow 171c77b7da Selectively import timespec_get into namespace std, since some C libraries don't have it. Reviewed as https://reviews.llvm.org/D50799
llvm-svn: 339816
2018-08-15 21:19:08 +00:00
Marshall Clow dfb4f61d97 Mark the at_exit and at_quick_exit tests as unsupported under C++98 an 03, since those calls were introduced in C++11. They're already guarded by an ifdef in the code, so this is a 'belt-and-suspenders' change.
llvm-svn: 339804
2018-08-15 19:27:53 +00:00
Peter Collingbourne f11c00d782 libcxx: Mark __temp_value::__temp_value as _LIBCPP_NO_CFI.
This constructor needs to cast a pointer to uninitialized
memory to a pointer to object type in order to call
allocator_traits::construct(). This cast is not allowed when CFI cast
checks are enabled.

I did this instead of marking __addr() as _LIBCPP_NO_CFI so that we
don't lose CFI checks on get() or the dtor.

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

llvm-svn: 339797
2018-08-15 17:49:30 +00:00
Dimitry Andric c7510aa2ac For FreeBSD, don't define _M in nasty_macros.hpp
Because FreeBSD uses _M in its <sys/types.h>, and it is hard to avoid
including that header, only define _M to NASTY_MACRO for other operating
systems.  This fixes almost 2000 unexpected test failures.

Discussed with Eric Fiselier.

llvm-svn: 339794
2018-08-15 17:30:32 +00:00
Louis Dionne 7c6baa2184 [libcxx] Fix XFAILs for aligned allocation tests on older OSX versions
Summary:
Since r338934, Clang emits an error when aligned allocation functions are
used in conjunction with a system libc++ dylib that does not support those
functions. This causes some tests to fail when testing against older libc++
dylibs. This commit marks those tests as UNSUPPORTED, and also documents the
various reasons for the tests being unsupported.

Reviewers: vsapsai, EricWF

Subscribers: christof, dexonsmith, cfe-commits, mclow.lists, EricWF

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

llvm-svn: 339743
2018-08-15 00:30:03 +00:00
Louis Dionne feb0427c91 [libc++] Disable failing C11 feature tests for <cfloat> and <float.h>
Summary:
Those tests are breaking the test bots. A Bugzilla has been filed to
make sure those tests are re-enabled: https://bugs.llvm.org/show_bug.cgi?id=38572

Reviewers: mclow.lists, EricWF

Subscribers: krytarowski, christof, dexonsmith, cfe-commits

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

llvm-svn: 339742
2018-08-15 00:18:01 +00:00
Louis Dionne 894ffdd82f [libc++] Detect C11 features on non-Clang compilers
Summary:
The macros were inside `#if defined(_LIBCPP_COMPILER_CLANG)`, which means
we would never detect C11 features on non-Clang compilers. According to
Marshall Clow, this is not the intended behavior.

Reviewers: mclow.lists, EricWF

Subscribers: krytarowski, christof, dexonsmith, cfe-commits

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

llvm-svn: 339741
2018-08-15 00:16:41 +00:00
Louis Dionne 6513f375b1 [libc++] Fix incorrect definition of TEST_HAS_C11_FEATURES
Summary:
The macro was not defined in C++11 mode when it should have been, at least
according to how _LIBCPP_HAS_C11_FEATURES is defined.

Reviewers: mclow.lists, EricWF, jfb, dexonsmith

Subscribers: christof, dexonsmith, cfe-commits

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

llvm-svn: 339702
2018-08-14 18:16:56 +00:00
Martin Storsjo 3d2e5432ae [CMake] Fix the LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY option
This option should be available if LIBCXX_ENABLE_SHARED is enabled,
not LIBCXX_ENABLE_STATIC.

This fixes a typo from SVN r337814.

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

llvm-svn: 339697
2018-08-14 17:33:10 +00:00
Louis Dionne 5bd88cf7dd [libc++] Add missing #include in C11 features tests
Summary:
These #includes are quite important, since otherwise any

    #if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)

checks are always false, and so we don't actually test for C11 support
in the standard library.

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, cfe-commits

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

llvm-svn: 339675
2018-08-14 13:29:17 +00:00
Volodymyr Sapsai 0b8efae6bc [libcxx] Mark charconv tests as failing for previous libcxx versions.
<charconv> was added in r338479. Previous libcxx versions don't have
this functionality and corresponding tests should be failing.

Reviewers: mclow.lists, ldionne, EricWF

Reviewed By: ldionne

Subscribers: christof, dexonsmith, lichray, EricWF, cfe-commits

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

llvm-svn: 339451
2018-08-10 17:03:47 +00:00
Louis Dionne 53ac1776f3 [libc++] Enable aligned allocation based on feature test macro, irrespective of standard
Summary:
The current code enables aligned allocation functions when compiling in C++17
and later. This is a problem because aligned allocation functions might not
be supported on the target platform, which leads to an error at link time.

Since r338934, Clang knows not to define __cpp_aligned_new when it's not
available on the target platform -- this commit takes advantage of that to
only use aligned allocation functions when they are available.

Reviewers: vsapsai, EricWF

Subscribers: christof, dexonsmith, cfe-commits, EricWF, mclow.lists

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

llvm-svn: 339431
2018-08-10 13:24:56 +00:00
Billy Robert O'Neal III 77e898cbd0 [libcxx] [test] Avoid -Wunused-local-typedef in node_handle.pass.cpp.
llvm-svn: 339218
2018-08-08 04:24:47 +00:00
Billy Robert O'Neal III 58e9f8a2fc [libcxx] [test] Allow a standard library that implements LWG 1203 in istream.rvalue/rvalue.pass.cpp
(Still pending review at https://reviews.llvm.org/D47400 which has been open since may; will ask for forgiveness rather than permission :) )

llvm-svn: 339214
2018-08-08 00:49:02 +00:00
Billy Robert O'Neal III f2c9a2fee6 [libcxx] [test] Remove nonportable locale assumption in basic.ios.members/narrow.pass.cpp
I'm not sure if libcxx is asserting UTF-8 here; but on Windows the full char value is always passed through in its entirety, since the default codepage is something like Windows-1252. The replacement character is only used for non-chars there; and that should be a more portable test everywhere.

(Still pending review at https://reviews.llvm.org/D47395 which has been open since may; will ask for forgiveness rather than permission :) )

llvm-svn: 339213
2018-08-08 00:47:29 +00:00
Billy Robert O'Neal III e94d16e223 [libcxx] [test] Remove asserts that <cstddef> and <stdexcept> are included by <bitset>
Reviewed as https://reviews.llvm.org/D50421

llvm-svn: 339212
2018-08-08 00:43:38 +00:00
Billy Robert O'Neal III ed2f9a6094 [libcxx] [test] Add missing <stdexcept> in several tests.
Reviewed as https://reviews.llvm.org/D50420

llvm-svn: 339209
2018-08-08 00:40:32 +00:00
Louis Dionne ba71bd7c55 [libc++] Add the _LIBCPP_HIDE_FROM_ABI_AFTER_V1 macro
Summary:
This macro allows hiding symbols from the ABI when the library is built
with an ABI version after ABI v1, which is currently the only stable ABI.
This commit defines `_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY` to be
`_LIBCPP_HIDE_FROM_ABI_AFTER_V1`, meaning that symbols that were only
exported by the library for historical reasons are not exported anymore
in the unstable ABI.

Because of that, this commit is an ABI break for ABI v2. This ABI version
is not stable, however, so this should not be a problem.

Reviewers: EricWF, mclow.lists

Subscribers: christof, dexonsmith, cfe-commits

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

llvm-svn: 339012
2018-08-06 14:11:50 +00:00
Marshall Clow 7986a5bdf8 Mark LWG#2260 as complete. We already did the right thing, so I just added tests to ensure that we continue to DTRT.
llvm-svn: 338936
2018-08-03 23:28:48 +00:00
Louis Dionne 7c3492b00d [NFC][libc++] Consistently use spaces to indent
rdar://problem/19988944

llvm-svn: 338933
2018-08-03 22:36:53 +00:00
Marshall Clow 2fd30b4c87 Make my new test harness work w/c++03
llvm-svn: 338803
2018-08-03 02:58:16 +00:00
Marshall Clow 7c84e38104 Update the changes to the array tests (that I committed yesterday) to use the test_comparison routines that I committed last week. NFC.
llvm-svn: 338797
2018-08-03 00:47:12 +00:00
Marshall Clow 07d8ac0ab5 Implement P1023: constexpr comparison operators for std::array
llvm-svn: 338668
2018-08-02 02:11:06 +00:00
Marshall Clow cf49ccd0e5 Implement P0887: The identity metafunction
llvm-svn: 338666
2018-08-02 01:56:02 +00:00
Hans Wennborg 25977548aa Update version to 8.0.0svn: cmake, includes files and docs
llvm-svn: 338555
2018-08-01 13:54:28 +00:00
Louis Dionne 306b73e35b [libc++] Fix GCC 7.2.0 macro redefinition warning
The warning happens when LIBCXX_ENABLE_EXCEPTIONS cmake option is not set,
and it fires every time __config is included, 33 in total.

Patch by Jason Lovett
Reviewed as https://reviews.llvm.org/D49997

llvm-svn: 338531
2018-08-01 13:13:14 +00:00
Zhihao Yuan 63ebd3bd24 [libc++] Fix build failures after merging <charconv>
Summary:
- fix a stupid unit test typo
- add <charconv> symbols to Linux abilist

Reviewers: EricWF

Subscribers: christof, ldionne, cfe-commits

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

llvm-svn: 338486
2018-08-01 05:21:26 +00:00
Zhihao Yuan d27489645b [libc++][C++17] Elementary string conversions for integral types
Summary:
Major QoI considerations:

- The facility is backported to C++14, same as libstdc++.
- Efforts have been made to minimize the header dependencies.
- The design is friendly to the uses of MSVC intrinsics (`__emulu`, `_umul128`, `_BitScanForward`, `_BitScanForward64`) but not implemented; future contributions are welcome.

Thanks to Milo Yip for contributing the implementation of `__u64toa` and `__u32toa`.

References:
 https://wg21.link/p0067r5
 https://wg21.link/p0682r1

Reviewers: mclow.lists, EricWF

Reviewed By: mclow.lists

Subscribers: ldionne, Quuxplusone, christof, mgorny, cfe-commits

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

llvm-svn: 338479
2018-08-01 02:38:30 +00:00
Louis Dionne c8e84ff251 [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since _LIBCPP_BUILDING_LIBRARY
Summary: As suggested by Marshall in https://reviews.llvm.org/D49914

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, cfe-commits

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

llvm-svn: 338475
2018-08-01 02:08:59 +00:00
Erik Pilkington b0386a515b First half of C++17's splicing maps and sets
This commit adds a node handle type, (located in __node_handle), and adds
extract() and insert() members to all map and set types, as well as their
implementations in __tree and __hash_table.

The second half of this feature is adding merge() members, which splice nodes
in bulk from one container into another. This will be committed in a follow-up.

Differential revision: https://reviews.llvm.org/D46845

llvm-svn: 338472
2018-08-01 01:33:38 +00:00
Marshall Clow 1f9e03f04d Final bit of P0063 - make sure that aligned_alloc is available when the underlying C library supports it
llvm-svn: 338457
2018-07-31 23:39:12 +00:00
Marshall Clow 5802ab265c Test for the presence of a bunch of new macros for c++17. These macros come from C11. Part of P0063
llvm-svn: 338454
2018-07-31 23:29:06 +00:00
Marshall Clow deb471fa15 import timespec and timespec_get into namespace std if we're under c++17 or later AND the underlying C library has them. Fixes PR#38220, but doesn't implement all of P0063 yet.
llvm-svn: 338419
2018-07-31 19:25:00 +00:00
Marshall Clow 119f0a56d2 Introduce a new test macro TEST_HAS_C11_FEATURES which is set when the underlying C library has C11 features. In C++17, we use those features. <__config> defines a similar macro, _LIBCPP_HAS_C11_FEATURES, but we don't want to use that in the library-independent parts of the tests, so define the new one. Also add a libc++-specific test to make sure the two stay in sync.
llvm-svn: 338411
2018-07-31 18:23:57 +00:00
Marshall Clow 934864bfa7 Code cleanup - change naked 'throw' expressions to call helpre function '__throw_future_error'. The behavior change is that if you build libc++ with exceptions disabled, and then use that in a program that sets the value of the future twice (for example), it will now abort instead of behaving unpredictably.
llvm-svn: 338332
2018-07-30 23:33:48 +00:00
Tim Shen f72252e679 [libcxx] fix `>> 42` UB in <experimental/simd>
llvm-svn: 338325
2018-07-30 23:05:40 +00:00
Tim Shen 38cd7de5ac Re-apply "[libcxx] implement <simd> ABI for Clang/GCC vector extension, constructors, copy_from and copy_to."
...with proper guarding #ifdefs for unsupported C++11.

llvm-svn: 338318
2018-07-30 22:27:38 +00:00
Tim Shen 6f33ea4ef6 Revert "[libcxx] implement <simd> ABI for Clang/GCC vector extension, constructors, copy_from and copy_to."
This reverts commit r338309.

llvm-svn: 338316
2018-07-30 22:21:22 +00:00
Tim Shen 47ad09b339 [libcxx] implement <simd> ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.
Summary:
This patch adds a new macro _LIBCPP_HAS_NO_VECTOR_EXTENSION for detecting
whether a vector extension (\_\_attribute\_\_((vector_size(num_bytes)))) is
available.

On the top of that, this patch implements the following API:
* all constructors
* operator[]
* copy_from
* copy_to

It also defines simd_abi::native to use vector extension, if available.
In GCC and Clang, certain values with vector extension are passed by registers,
instead of memory.

Based on D41148.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits, MaskRay, lichray, sanjoy

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

llvm-svn: 338309
2018-07-30 21:23:13 +00:00
Jordan Rupprecht 78b6374997 [libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4
Summary:
[libc++] Exclude posix_l/strtonum fallback inclusion for newlib > 2.4

r338122 changed the linkage of some methods which revealed an existing ODR violation, e.g.:
projects/libcxx/include/support/xlocale/__posix_l_fallback.h:83:38: error: 'internal_linkage' attribute does not appear on the first declaration of 'iswcntrl_l'
inline _LIBCPP_INLINE_VISIBILITY int iswcntrl_l(wint_t c, locale_t) {
                                     ^
lib/include/wctype.h:55:12: note: previous definition is here
extern int      iswcntrl_l (wint_t, locale_t);

These were added to newlib in 2.4 [1] [2], so move them to the already existing include guard.

[1] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=238455adfab4f8070ac65400aac22bb8a9e502fc
[2] https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commit;h=8493c1631643fada62384768408852bc0fa6ff44

Reviewers: ldionne, rsmith, EricWF

Subscribers: christof, cfe-commits

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

llvm-svn: 338157
2018-07-27 20:02:58 +00:00
Louis Dionne cb3eb30636 [libc++] Introduce _LIBCPP_HIDE_FROM_ABI to replace _LIBCPP_INLINE_VISIBILITY
Summary:
This commit introduces a new macro, _LIBCPP_HIDE_FROM_ABI, whose goal is to
mark functions that shouldn't be part of libc++'s ABI. It marks the functions
as being hidden for dylib visibility purposes, and as having internal linkage
using Clang's __attribute__((internal_linkage)) when available, and
__always_inline__ otherwise.

It replaces _LIBCPP_INLINE_VISIBILITY, which was always using __always_inline__
to achieve similar goals, but suffered from debuggability and code size problems.
The full proposal, along with more background information, can be found here:

    http://lists.llvm.org/pipermail/cfe-dev/2018-July/058419.html

This commit does not rename uses of _LIBCPP_INLINE_VISIBILITY to
_LIBCPP_HIDE_FROM_ABI: this wide reaching but mechanical change can
be done later when we've confirmed we're happy with the new macro.

In the future, it would be nice if we could optionally allow dropping
any internal_linkage or __always_inline__ attribute, which could result
in code size improvements. However, this is currently impossible for
reasons explained here: http://lists.llvm.org/pipermail/cfe-dev/2018-July/058450.html

Reviewers: EricWF, dexonsmith, mclow.lists

Subscribers: christof, dexonsmith, llvm-commits, mclow.lists

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

llvm-svn: 338122
2018-07-27 12:46:03 +00:00
Eric Fiselier 8e4a1690bf Move Filesystem namespace definition out of a clang specific ifdef block.
llvm-svn: 338103
2018-07-27 06:12:46 +00:00
Eric Fiselier 67ea02b8aa Add libc++fs to the test deps, and not to the target 'cxx'.
llvm-svn: 338096
2018-07-27 03:47:46 +00:00
Eric Fiselier ce65245899 Attempt to unbreak *all the bots*
The bots were failing to build the cxx_filesystem target, so the
tests were failing. Though this does lead me to wonder how it
was ever working with c++experimental.

llvm-svn: 338095
2018-07-27 03:42:58 +00:00
Eric Fiselier 5090559bd4 Correctly mark the Filesystem status as complete.
llvm-svn: 338094
2018-07-27 03:16:02 +00:00
Eric Fiselier 998a5c8831 Implement <filesystem>
This patch implements the <filesystem> header and uses that
to provide <experimental/filesystem>.

Unlike other standard headers, the symbols needed for <filesystem>
have not yet been placed in libc++.so. Instead they live in the
new libc++fs.a library. Users of filesystem are required to link this
library. (Also note that libc++experimental no longer contains the
definition of <experimental/filesystem>, which now requires linking libc++fs).

The reason for keeping <filesystem> out of the dylib for now is that
it's still somewhat experimental, and the possibility of requiring an
ABI breaking change is very real. In the future the symbols will likely
be moved into the dylib, or the dylib will be made to link libc++fs automagically).

Note that moving the symbols out of libc++experimental may break user builds
until they update to -lc++fs. This should be OK, because the experimental
library provides no stability guarantees. However, I plan on looking into
ways we can force libc++experimental to automagically link libc++fs.

In order to use a single implementation and set of tests for <filesystem>, it
has been placed in a special `__fs` namespace. This namespace is inline in
C++17 onward, but not before that. As such implementation is available
in C++11 onward, but no filesystem namespace is present "directly", and
as such name conflicts shouldn't occur in C++11 or C++14.

llvm-svn: 338093
2018-07-27 03:07:09 +00:00
Petr Hosek 4b59ed4001 [CMake] Don't generate linker script only when shared library isn't statically linked
Since r337668, we support statically linking dependencies only to shared
or static library. However, that change hasn't updated the check whether
to generate a linker script. We shouldn't generate linker script only in
the case when we aren't statically linked ABI into the shared library.

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

llvm-svn: 338006
2018-07-26 05:10:24 +00:00
Eric Fiselier 6a10864d44 Copy LLVM CMake configuration for CMake Policy CMP0068
llvm-svn: 338005
2018-07-26 05:08:30 +00:00
Eric Fiselier 5d96947591 Be more consistent about which bool value means an error occurred
llvm-svn: 338002
2018-07-26 04:02:06 +00:00
Eric Fiselier a0a7c1f552 Cleanup the last_write_time internals
llvm-svn: 338001
2018-07-26 03:57:26 +00:00
Eric Fiselier d8600e21b6 Correct comment about stat truncating st_mtimespec to seconds
llvm-svn: 338000
2018-07-26 03:42:25 +00:00
Eric Fiselier f74c5461d8 Fix attribute placement WRT extern C
llvm-svn: 337999
2018-07-26 03:36:37 +00:00
Eric Fiselier 982bb884ff Workaround OS X 10.11 behavior where stat truncates st_mtimespec to seconds.
llvm-svn: 337998
2018-07-26 03:28:48 +00:00
Eric Fiselier e11adcc269 Add print statements to help debugging
llvm-svn: 337991
2018-07-26 01:10:50 +00:00
Eric Fiselier 1e1f8ece3b [libc++] Add hack to allow ubsan to work w/o compiler-rt (__muloti4 is undefined)
Summary:
Using int128_t with UBSAN causes link errors unless compiler-rt is providing the runtime library.
Specifically ubsan generates calls to __muloti4 but libgcc doesn't provide a definition.

In order to avoid this, and allow users to continue using sanitized versions of libc++, this patch introduces a hack.
It adds a cribbed version of  the compiler-rt builtin to the libc++ filesystem sources.

I don't think this approach will work in the long run, but it seems OK for now.

Also see:

https://bugs.llvm.org/show_bug.cgi?id=30643
https://bugs.llvm.org/show_bug.cgi?id=16404


Reviewers: mclow.lists, ldionne, rsmith, jyknight, echristo

Reviewed By: echristo

Subscribers: dberris, cfe-commits

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

llvm-svn: 337990
2018-07-26 00:34:50 +00:00
Alex Lorenz 70cf5c4c62 [libc++] Follow-up to r337968: use an explicit cast as suggested by Eric
llvm-svn: 337984
2018-07-25 23:59:54 +00:00
Petr Hosek 9d1bcc2a88 [CMake] Don't install c++abi headers in standalone libc++ build
This is a refinement on r337833. Previously we were installing two
copies of c++abi headers in libc++ build directory, one in
include/c++build and another one in include/c++/v1. However, the
second copy is unnecessary when building libc++ standalone.

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

llvm-svn: 337979
2018-07-25 22:57:39 +00:00
Eric Fiselier 99ca3c0a61 Work around GCC bug in constexpr function
llvm-svn: 337976
2018-07-25 22:21:47 +00:00
Eric Fiselier b7e6c1d238 Fix GCC build in C++14 w/o c++14 constexpr
llvm-svn: 337974
2018-07-25 22:07:36 +00:00
Eric Fiselier ceb33cd519 Remove test which shouldn't have been committed
llvm-svn: 337971
2018-07-25 21:58:37 +00:00
Eric Fiselier ce34437cc8 Fix failing test under C++14
llvm-svn: 337970
2018-07-25 21:53:43 +00:00
Alex Lorenz 33b4c8a18f [libc++] Follow-up to r337960: specify lambda's return type to avoid
-Wc++11-narrowing warning on Darwin

The internal CI produced the following diagnostic:
error: non-constant-expression cannot be narrowed from type 'long long' to '__darwin_suseconds_t' (aka 'int') in initializer list [-Wc++11-narrowing]
  struct ::timeval ConvertedTS[2] = {{TS[0].tv_sec, Convert(TS[0].tv_nsec)},
                                                    ^~~~~~~~~~~~~~~~~~~~~~

llvm-svn: 337968
2018-07-25 21:50:44 +00:00
Eric Fiselier d77f3ef4a4 Make <experimental/filesystem> compile with gcc 4.8.5
Patch by Victor Zverovich.

This fixes an error when compiling `<experimental/filesystem>` with gcc 4.8.5:

```
.../libcxx/src/experimental/filesystem/filesystem_common.h:137:34:
error: redeclaration ‘T
std::experimental::filesystem::v1::detail::{anonymous}::error_value() [with T =
bool]’ d
iffers in ‘constexpr’
 constexpr bool error_value<bool>() {
                                  ^
.../libcxx/src/experimental/filesystem/filesystem_common.h:133:3:
error: from previous declaration ‘T
std::experimental::filesystem::v1::detail::{anonymous}::error_value() [with T
 = bool]’
 T error_value();
   ^
```

Reviewed as https://reviews.llvm.org/D49813

llvm-svn: 337962
2018-07-25 21:01:45 +00:00
Eric Fiselier c55ac1055a [libc++] Use __int128_t to represent file_time_type.
Summary:
The ``file_time_type`` time point is used to represent the write times for files.
Its job is to act as part of a C++ wrapper for less ideal system interfaces. The
underlying filesystem uses the ``timespec`` struct for the same purpose.

However, the initial implementation of ``file_time_type`` could not represent
either the range or resolution of ``timespec``, making it unsuitable. Fixing
this requires an implementation which uses more than 64 bits to store the
time point.

I primarily considered two solutions: Using ``__int128_t`` and using a
arithmetic emulation of ``timespec``. Each has its pros and cons, and both
come with more than one complication.

However, after a lot of consideration, I decided on using `__int128_t`. This patch implements that change.

Please see the [FileTimeType Design Document](http://libcxx.llvm.org/docs/DesignDocs/FileTimeType.html) for more information.

Reviewers: mclow.lists, ldionne, joerg, arthur.j.odwyer, EricWF

Reviewed By: EricWF

Subscribers: christof, K-ballo, cfe-commits, BillyONeal

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

llvm-svn: 337960
2018-07-25 20:51:49 +00:00
Louis Dionne 8b6a5bf916 [libc++] Factor duplicate code into function templates
Summary:
The exact same code was replicated 11 times for implementing the basic_istream
input operators (those that don't use numeric_limits). The same code was also
duplicated twice for implementing the basic_istream input operators that take
numeric_limits into account.

This commit factors the common code into function templates to avoid
the duplication.

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, cfe-commits

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

llvm-svn: 337955
2018-07-25 19:40:01 +00:00
Martin Storsjo c89c9c7b63 [windows] Fix warning about comparing ints of different signs
This fixes a warning like this:

warning: comparison of integers of different signs:
      'std::__1::__libcpp_tls_key' (aka 'long') and 'DWORD'
      (aka 'unsigned long') [-Wsign-compare]
  if (*__key == FLS_OUT_OF_INDEXES)
      ~~~~~~ ^  ~~~~~~~~~~~~~~~~~~

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

llvm-svn: 337946
2018-07-25 18:24:23 +00:00
Louis Dionne f636411a5e [NFC] Fix grammatical mistakes in libc++ FileTimeType design docs
llvm-svn: 337925
2018-07-25 13:40:49 +00:00
Eric Fiselier 1f174327d1 Fix diagnostic test to tolerate Clang diagnosing it as well.
Tuple has tests that ensure we diagnose non-lifetime extended
reference bindings inside tuples constructors. As of yesterday,
Clang now does this for us.

Adjust the test to tolerate the new diagnostics, while still
testing that we emit diagnostics of our own. Maybe after this
version of Clang has been adopted by most users we should
remove our diagnostics; but for now more error detection is
better!

llvm-svn: 337905
2018-07-25 11:16:39 +00:00
Eric Fiselier b54393e638 Fix another typo in the FileTimeType docs
llvm-svn: 337900
2018-07-25 10:22:07 +00:00
Eric Fiselier f0b379c959 Fix typos, spelling, and grammar in the FileTimeType design docs.
I'm sure I'll discover more mistakes as I go on...

llvm-svn: 337897
2018-07-25 10:17:04 +00:00
Eric Fiselier 84e48004cf Fix bugs in create_directory implementation.
Libc++ was incorrectly reporting an error when the target of create_directory
already exists, but was not a directory. This behavior is not specified
in the most recent standard, which says no error should be reported.

Additionally, libc++ failed to report an error when the attribute directory
path didn't exist or didn't name a directory. This has been fixed as well.

Although it's not clear if we should call status or symlink_status on the
attribute directory. This patch chooses to still call status.

llvm-svn: 337888
2018-07-25 04:46:32 +00:00
Eric Fiselier 3b3edcb0b7 Fix missing includes in format_string.hpp helper
llvm-svn: 337886
2018-07-25 04:21:59 +00:00
Marshall Clow c17628fb15 New test support for comparisons. Reviewed as https://reviews.llvm.org/D49773
llvm-svn: 337885
2018-07-25 04:21:21 +00:00
Eric Fiselier 5baf73c354 Make <experimental/filesystem> explicitly require C++11.
Previously the <experimental/filesystem> didn't guard its
contents in any dialect. However, the implementation implicitly
requires at least C++11, and the tests have always been marked
unsupported in C++03. This patch puts a header guard around the
contents to avoid exposing them before C++11.

Additionally, it replaces all of the usages of _NOEXCEPT or
_LIBCPP_CONSTEXPR with the keyword directly, since we can
expect the compiler to implement those by now.

llvm-svn: 337884
2018-07-25 03:41:31 +00:00
Eric Fiselier 52ec6a206f Ensure path::iterator and PathParser share the same enumeration values.
To avoid exposing implementation details, path::iterator and PathParser
both implicitly used the same set of values to represent the state,
but they were defined twice. This could have lead to a mismatch
occuring.

This patch moves all of the parser state values into the filesystem
header and changes PathParser to use those value to avoid this.

llvm-svn: 337883
2018-07-25 03:31:48 +00:00
Eric Fiselier d981977d5a Add design docs for upcoming file_time_type change.
In upcoming changes to filesystem I plan to change file_time_type
to use __int128_t as its underlying representation, in order
to allow it to have a range and resolution at least that of
the timespec struct.

There was some pushback against this decision, so I drafted
a document explaining the problems, potential solutions, and
the rational for the decision.

However, it's probably easier to let people read the generated
HTML rather than the raw restructured text. For this reason
I'm commiting the design documents before hand, so they can
be available during any subsequent discussion or code review.

llvm-svn: 337880
2018-07-25 02:53:53 +00:00
Marshall Clow 8f7da2458e Mark <span> as complete
llvm-svn: 337879
2018-07-25 01:55:25 +00:00
Petr Hosek 4a1e14ea78 [CMake] Option to control whether shared/static library is installed
Currently it's only possible to control whether shared or static library
build of libc++, libc++abi and libunwind is enabled or disabled and
whether to install everything we've built or not. However, it'd be
useful to have more fine grained control, e.g. when static libraries are
merged together into libc++.a we don't need to install libc++abi.a and
libunwind.a. This change adds this option.

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

llvm-svn: 337867
2018-07-24 23:27:51 +00:00
Petr Hosek f8f2a788f0 [CMake] Fix the setting of LIBCXX_HEADER_DIR in standalone build
This is an alternative approach to r337727 which broke the build
because libc++ headers were copied into the location outside of
directories used by Clang. This change sets LIBCXX_HEADER_DIR to
different values depending on whether libc++ is being built as
part of LLVM w/ per-target multiarch runtime, LLVM or standalone.

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

llvm-svn: 337833
2018-07-24 15:49:29 +00:00
Alexander Richardson 2a6a3fc4a3 Stop wrapping __has_include in another macro
Summary:
This is not guaranteed to work since the characters after '__has_include('
have special lexing rules that can't possibly be applied when
__has_include is generated by a macro. It also breaks the crash reproducers
generated by -frewrite-includes (see https://llvm.org/pr37990).

Reviewers: EricWF, rsmith, mclow.lists
Reviewed By: mclow.lists
Differential Revision: https://reviews.llvm.org/D49067

llvm-svn: 337824
2018-07-24 12:40:56 +00:00
Eric Fiselier e95f4bf31b Fix use of incorrect _LIBCXX macro (should be _LIBCPP).
llvm-svn: 337817
2018-07-24 09:15:03 +00:00
Petr Hosek 058c04c3dd Reland "[CMake] Support statically linking dependencies only to shared or static library"
This is a reland of commit r337668.

llvm-svn: 337814
2018-07-24 07:06:17 +00:00
Marshall Clow 35773f5517 fix nesting of namespace and standard-version check. Also include <__config>
llvm-svn: 337809
2018-07-24 03:56:38 +00:00
Marshall Clow 8bbf22ed72 Disable 'suggest braces' warnings for std::array in tests
llvm-svn: 337808
2018-07-24 03:41:36 +00:00
Marshall Clow 8a0794b722 Implement <span>. Reviewed as https://reviews.llvm.org/D49338
llvm-svn: 337804
2018-07-24 03:01:02 +00:00
Alex Lorenz 311322aabc Revert r337727 as it caused Darwin bot failures
llvm-svn: 337782
2018-07-24 00:27:31 +00:00
Eric Fiselier 54f10f8e68 Handle DT_UNKNOWN correctly during directory iteration.
Unlike stat and lstat, where unknown really means we know it's something weird,
during directory iteration DT_UNKNOWN simply means that the underlying FS doesn't
support the dirent::dt_type field.

This patch fixes libc++ to correctly set the cache to empty when DT_UNKNOWN is reported.

llvm-svn: 337768
2018-07-23 22:58:46 +00:00
Eric Fiselier f96de02960 Recommit "Use possibly cached directory entry values when performing recursive directory iteration."
The initial patch didn't correctly handle systems when the dirent struct
didn't provide the d_type member. Specifically it set the cache to the incorrect state,
and claimed it was partially populated.

The updated version of this change correctly handles setting up the
cache when the file type is not known (aka file_type::none).

llvm-svn: 337765
2018-07-23 22:40:41 +00:00
Eric Fiselier 82d975afa0 Fix accidentally removed test.
When adding the new tests for the filesystem_error::what method,
I incorrectly removed a test case and replaced it with something else.

This patch restores that test case

llvm-svn: 337764
2018-07-23 22:39:56 +00:00
Eric Fiselier 5a16f861e9 Revert "Use possibly cached directory entry values when performing recursive directory iteration."
This reverts commit 04ce4aef00d3ee508327f6cf7bf1b1d200ab6238.

llvm-svn: 337749
2018-07-23 21:52:29 +00:00
Heejin Ahn e559401159 [CMake] Fix the setting of LIBCXX_HEADER_DIR
Reviewers: phosek

Subscribers: mgorny, christof, ldionne, cfe-commits

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

llvm-svn: 337727
2018-07-23 18:58:12 +00:00
Eric Fiselier 39fa372721 Cleanup unnecessary conversions in filesystem.
llvm-svn: 337685
2018-07-23 11:55:13 +00:00
Eric Fiselier c48dba4c6d Cleanup name qualification in the filesystem internals.
In most cases there is no reason why the filesystem internals
use the qualifier std:: or _VSTD::. This patch removes the unneeded
qualifiers, making the sources files more consistent

llvm-svn: 337684
2018-07-23 11:46:47 +00:00
Petr Hosek 781ee0bc5a Revert "[CMake] Support statically linking dependencies only to shared or static library"
This reverts commit r337668: broke the cxxabi build when using Make.

llvm-svn: 337670
2018-07-23 05:07:44 +00:00
Eric Fiselier c50ef8560a Use possibly cached directory entry values when performing recursive directory iteration.
llvm-svn: 337669
2018-07-23 04:55:57 +00:00
Petr Hosek 7a0295cbc8 [CMake] Support statically linking dependencies only to shared or static library
Currently it's possible to select whether to statically link unwinder
or the C++ ABI library, but this option applies to both the shared
and static library. However, in some scenarios it may be desirable to
only statically link unwinder and C++ ABI library into static C++
library since for shared C++ library we can rely on dynamic linking
and linker scripts. This change enables selectively enabling or
disabling statically linking only to shared or static library.

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

llvm-svn: 337668
2018-07-23 04:19:55 +00:00
Eric Fiselier 8725bbdb1f Fix use of C++14 syntax in C++11 filesystem tests.
llvm-svn: 337666
2018-07-23 03:41:46 +00:00
Eric Fiselier e3081d5d96 Work around various GCC 4.9 build errors
llvm-svn: 337665
2018-07-23 03:06:57 +00:00
Eric Fiselier 9158bfd32e Implement filesystem_error::what() and improve reporting.
This patch implements the `what()` for filesystem errors. The message
includes the 'what_arg', any paths that were specified, and the
error code message.

Additionally this patch refactors how errors are created, making it easier
to report them correctly.

llvm-svn: 337664
2018-07-23 02:00:52 +00:00
Eric Fiselier 6d4be63ab1 Workaround bug in GCC trunk.
For some reason GCC ToT is failing to deduce the auto type for
a static data member from its initializer in some cases.

Though I'm sure the bug will be short lived, there is a trivial workaround for it.
So we might as well get the bot passing again.

llvm-svn: 337661
2018-07-22 21:56:40 +00:00
Eric Fiselier 37dd491d13 Harden copy_file even more.
This patch removes the O_CREAT open flag when we first
attempt to open the destination file but we expect it to
already exist.

This theoretically avoids the possibility that it was removed
between when we first stat'ed it, and when we attempt to open it.

llvm-svn: 337659
2018-07-22 21:15:15 +00:00
Eric Fiselier 0f3ce8e640 fix test failures with older clang versions
llvm-svn: 337658
2018-07-22 20:50:16 +00:00
Eric Fiselier 7c0ed44db0 Implement a better copy_file.
This patch improves both the performance, and the safety of the
copy_file implementation.

The performance improvements are achieved by using sendfile on
Linux and copyfile on OS X when available.

The TOCTOU hardening is achieved by opening the source and
destination files and then using fstat to check their attributes to
see if we can copy them.

Unfortunately for the destination file, there is no way to open
it without accidentally creating it, so we first have to use
stat to determine if it exists, and if we should copy to it.
Then, once we're sure we should try to copy, we open the dest
file and ensure it names the same entity we previously stat'ed.

llvm-svn: 337649
2018-07-22 02:00:53 +00:00
Petr Hosek 32f7fb5713 [CMake] Install C++ ABI headers into the right location
This is a follow-up to r335809 and r337118. While libc++ headers are now
installed into the right location in both standard as well as multiarch
runtimes layout, turned out C++ ABI headers are still installed into the
old location in the latter case. This change addresses that.

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

llvm-svn: 337630
2018-07-20 22:45:24 +00:00
Eric Fiselier dc3c62f3e4 adjust incorrect comment
llvm-svn: 337532
2018-07-20 08:36:45 +00:00
Eric Fiselier 3bf90e7811 Fix two test failures in <experimental/filesystem>
First, <experimental/filesystem> didn't correctly guard
against min/max macros. This adds the proper push/pop macro guards.

Second, an internal time helper had been renamed but the test for
it hadn't been updated. This patch updates those tests.

llvm-svn: 337520
2018-07-20 01:51:48 +00:00
Eric Fiselier 41cdcbeedd Use _LIBCPP_UNREACHABLE to convince GCC that non-void functions actually always return
llvm-svn: 337519
2018-07-20 01:44:33 +00:00
Eric Fiselier 4902bde560 cleanup test assertion inside library
llvm-svn: 337517
2018-07-20 01:25:06 +00:00
Eric Fiselier c16998649e [libc++] Implement Directory Entry Caching -- Sort of.
Summary:
This patch implements directory_entry caching *almost* as specified in P0317r1. However, I explicitly chose to deviate from the standard as I'll explain below.

The approach I decided to take is a fully caching one. When `refresh()` is called, the cache is populated by calls to `stat` and `lstat` as needed.
During directory iteration the cache is only populated with the `file_type` as reported by `readdir`.
The cache can be in the following states:

* `_Empty`: There is nothing in the cache (likely due to an error)
* `_IterSymlink`: Created by directory iteration when we walk onto a symlink only the symlink file type is known.
* `_IterNonSymlink`: Created by directory iteration when we walk onto a non-symlink. Both the regular file type and symlink file type are known.
* `_RefreshSymlink` and `_RefreshNonSymlink`: A full cache created by `refresh()`.  This case includes dead symlinks.
* `_RefreshSymlinkUnresolved`: A partial cache created by refresh when we fail to resolve the file pointed to by a symlink (likely due to permissions). Symlink attributes are cached, but attributes about the linked entity are not.

As mentioned, this implementation purposefully deviates from the standard. According to some readings of the specification, and the Windows filesystem implementation, the constructors and modifiers which don't pass an `error_code` must throw when the `directory_entry` points to a entity which doesn't exist. or when attribute resolution fails for another reason. 

@BillyONeal  has proposed a more reasonable set of requirements, where modifiers other than refresh ignore errors. This is the behavior libc++ currently implements, with the expectation some form of the new language will be accepted into the standard.

Some additional semantics which differ from the Windows implementation:

1. `refresh` will not throw when the entry doesn't exist. In this case we can still meet the functions specification, so we don't treat it as an error.
2. We don't clear the path name when a constructor fails via refresh (this will hopefully be changed in the standard as well).

It should be noted that libstdc++'s current implementation has the same behavior as libc++, except for point (2).

If the changes to the specification don't get accepted, we'll be able to make the changes later.

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0317r1.html

Reviewers: mclow.lists, gromer, ldionne, aaron.ballman

Subscribers: BillyONeal, christof, cfe-commits

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

llvm-svn: 337516
2018-07-20 01:22:32 +00:00
Louis Dionne e9b3f58290 [libc++] Allow running ABI list tests with different ABI versions
Summary:
Currently, the ABI list test only works for ABI version 1. This commit
allows running the ABI list test with ABI version 2. It also adds an
ABI list file for ABI v2 on Mac OS X.

Reviewers: EricWF

Subscribers: mgorny, christof, dexonsmith, llvm-commits, mclow.lists

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

llvm-svn: 337477
2018-07-19 18:02:50 +00:00
Marshall Clow da77fe4a77 Update the synopsis for <chrono> for C++20. No functional change.
llvm-svn: 337406
2018-07-18 17:37:51 +00:00
Eric Fiselier 81d0dbda79 Address "always inline function is not always inlinable" warning with GCC.
When an always_inline function is used prior to the functions definition,
the compiler may not be able to inline it as requested by the attribute.
GCC flags the `basic_string(CharT const*)` function as one such example.

This patch supresses the warning, and the problem, by moving the
definition of the string constructor to the inline declaration.
This ensures the body is available when it is first ODR used.

llvm-svn: 337235
2018-07-17 05:48:48 +00:00
Eric Fiselier 241d4ad761 Fix PR38160 - init_priority attribute not supported by GCC on Apple.
This patch guards the use of __attribute__((init_priority(101)))
within memory_resource.cpp when building with compilers that don't
support it. Specifically GCC on Apple platforms, and MSVC.

llvm-svn: 337205
2018-07-16 20:01:59 +00:00
Petr Hosek e32792d8bd [CMake] Use correct variable as header install prefix
This variable is already set in CMakeLists.txt but it wasn't used
which means that the headers get installed into a wrong location
when the per target runtime directory option is being used.

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

llvm-svn: 337118
2018-07-15 04:09:35 +00:00
Marshall Clow d8098f9799 Mark __equal_to 's operations as constexpr.
llvm-svn: 337087
2018-07-14 04:15:19 +00:00
Marshall Clow 4ce0a916f0 Mark one more __wrap_iter operation as constexpr.
llvm-svn: 337085
2018-07-14 03:06:11 +00:00
Marshall Clow 75c4f5552e wrap _LIBCPP_HAS_NO_CXX14_CONSTEXPR in defined(...)
llvm-svn: 337028
2018-07-13 17:31:36 +00:00
Marshall Clow 2d1d690863 Shot in the dark to fix gcc 4.9 / c++11 build
llvm-svn: 337027
2018-07-13 17:24:59 +00:00
Marshall Clow 9cad502555 Make internal class __wrap_iter constexpr when not using libc++'s debugging mode. Introduce a new macro _LIBCPP_CONSTEXPR_IF_NODEBUG to mark this.
llvm-svn: 337019
2018-07-13 16:35:26 +00:00
Marshall Clow 3f7d20904f Fix a couple of 'unused variable' warnings in a vector test. NFC.
llvm-svn: 337016
2018-07-13 16:26:16 +00:00
Marshall Clow 71f1ec7ea1 Turns out that wide literals U"xxx" and u"xxx" are c++11 and later.
llvm-svn: 336880
2018-07-12 02:55:01 +00:00
Louis Dionne dc7200b486 [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY
Summary:
We never actually mean to always inline a function -- all the uses of
the macro I could find are actually attempts to control the visibility
of symbols. This is better described by _LIBCPP_INLINE_VISIBILITY, which
is actually always defined the same.

This change is orthogonal to the decision of what we're actually going
to do with _LIBCPP_INLINE_VISIBILITY -- it just simplifies things by
having one canonical way of doing things.

Note that this commit had originally been applied in r336369 and then
reverted in r336382 because of unforeseen problems. Both of these problems
have now been fixed.

Reviewers: EricWF, mclow.lists

Subscribers: christof, dexonsmith, erikvanderpoel

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

llvm-svn: 336866
2018-07-11 23:14:33 +00:00
Marshall Clow b360cbcc4b Same reversed ifdef happened twice. Test fix only, NFC to the library.
llvm-svn: 336856
2018-07-11 21:22:13 +00:00
Marshall Clow 9c43521cd6 Fix a test #ifdef that was reversed. NFC to the library.
llvm-svn: 336855
2018-07-11 21:20:42 +00:00
Petr Hosek 6aae861e0e [CMake] Set per-runtime library directory suffix in runtimes build
Do not use LLVM_RUNTIMES_LIBDIR_SUFFIX variable which is an internal
variable used by the runtimes build from individual runtimes, instead
set per-runtime librarhy directory suffix variable which is necessary
for the sanitized runtimes build to install libraries into correct
location.

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

llvm-svn: 336713
2018-07-10 19:13:33 +00:00
Louis Dionne cf3ae38405 [libc++] Declare noop_coroutine() with _LIBCPP_INLINE_VISIBILITY
Summary:
It was defined with the right visibility, but declared without any visibility.
This function was left out of a prior revision that did the same to several
functions in <compare> (r336665) because the compiler I used didn't support
coroutines. This reinforces the need for automated checks -- there might
still be several cases of this throughout the library.

Reviewers: EricWF

Subscribers: modocache, christof, dexonsmith, llvm-commits

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

llvm-svn: 336709
2018-07-10 17:38:30 +00:00
Eric Fiselier 9cc6d3b305 Remove BUILD file from google-benchmark
llvm-svn: 336666
2018-07-10 13:25:26 +00:00
Louis Dionne be4d99dd21 [libc++] Declare <compare> operators with the proper visibility attribute
Summary:
Many operators in <compare> were _defined_ with the proper visibility attribute,
but they were _declared_ without any. This is not a problem until we change the
definition of _LIBCPP_INLINE_VISIBILITY to something that requires the
declaration to be decorated.

I also marked `strong_equality::operator weak_equality()` as
`_LIBCPP_INLINE_VISIBILITY`, since it seems like it had been forgotten.

This came up while trying to get rid of `__attribute__((__always_inline__))`
in favor of `__attribute__((internal_linkage))`.

Reviewers: EricWF, mclow.lists

Subscribers: christof, dexonsmith, llvm-commits

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

llvm-svn: 336665
2018-07-10 13:21:03 +00:00
Eric Fiselier 09701324a1 Add new string benchmarks
llvm-svn: 336636
2018-07-10 04:11:22 +00:00
Eric Fiselier fcafd3e600 Update google-benchark to trunk
llvm-svn: 336635
2018-07-10 04:02:00 +00:00
Casey Carter 6cd35e8194 [test] two small cleanups:
* Remove unused type from is_assignable.pass.cpp

* Don't specialize `common_type<::X<float>>` in common_type.pass.cpp, which violates the requirements of [meta.trans.other]/5

llvm-svn: 336618
2018-07-09 23:45:09 +00:00
Casey Carter ac89571d20 type_traits: aligned_union is NOT the same as __uncvref [NFC]
llvm-svn: 336502
2018-07-08 00:06:27 +00:00
Louis Dionne 195a499d63 Revert "[libc++] Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY"
This reverts commit r336369. The commit had two problems:
1. __pbump was marked as _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY instead of
   _LIBCPP_INLINE_VISIBILITY, which lead to two symbols being added in the
   dylib and the check-cxx-abilist failing.

2. The LLDB tests started failing because they undefine
   `_LIBCPP_INLINE_VISIBILITY`. I need to figure out why they do that and
   fix the tests before we can go forward with this change.

llvm-svn: 336382
2018-07-05 18:41:50 +00:00
Marshall Clow d8f5b2d612 Fix HTML blunder
llvm-svn: 336381
2018-07-05 17:44:12 +00:00
Louis Dionne 4a8f3f9948 [libc++] Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITY
Summary:
We never actually mean to always inline a function -- all the uses of
the macro I could find are actually attempts to control the visibility
of symbols. This is better described by _LIBCPP_INLINE_VISIBILITY, which
is actually always defined the same.

This change is orthogonal to the decision of what we're actually going
to do with _LIBCPP_INLINE_VISIBILITY -- it just simplifies things by
having one canonical way of doing things.

Reviewers: EricWF

Subscribers: christof, llvm-commits, dexonsmith, erikvanderpoel, mclow.lists

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

llvm-svn: 336369
2018-07-05 16:49:38 +00:00
Louis Dionne 14c922a240 [NFC] Add <initializer_list> to the synopsis of <utility>
Summary:
It is part of the synopsis in the Standard and <utility> does include it,
but it was left out of the synopsis comment.

Reviewers: EricWF, mclow.lists

Subscribers: christof, llvm-commits

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

llvm-svn: 336368
2018-07-05 16:16:03 +00:00
Eric Fiselier 0b68096acf Remove old workaround that is no longer needed
llvm-svn: 336297
2018-07-04 20:16:05 +00:00
Zhihao Yuan 4b50837b3b [libc++] Install the missing header __errc
Summary: Omitted from D41347.

Reviewers: EricWF

Subscribers: mgorny, christof, ldionne, cfe-commits

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

llvm-svn: 336165
2018-07-03 04:01:44 +00:00
Zhihao Yuan 4f4effd6ee [libc++] Lift std::errc into a separated header
Summary: This is needed to implement `<charconv>`, otherwise `<charconv>` would need to include `<system_error>`, which pulls in `<string>` -- a header which the `<charconv>` proposal intends to keep away from.

Reviewers: mclow.lists, EricWF

Reviewed By: mclow.lists

Subscribers: christof, cfe-commits

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

llvm-svn: 336164
2018-07-03 03:25:10 +00:00
Pirama Arumuga Nainar 7aea360924 [Win32] Overload ==, != for locale_t and long long
Summary:
_is_chartype_l (needed for isxdigit_l) in MinGW compares locale_t and NULL.
NULL is 'long long' for 64-bit, and this results in ambiguous overloads when
compiled with Clang.  Define a concrete overload for the operators to fix the
ambiguity.

Reviewers: mstorsjo, EricWF, srhines, danalbert

Subscribers: christof, cfe-commits, ldionne

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

llvm-svn: 336141
2018-07-02 20:11:15 +00:00
Marshall Clow 76b26852b6 Implement LWG 2946, 3075 and 3076. Reviewed as https://reviews.llvm.org/D48616
llvm-svn: 336132
2018-07-02 18:41:15 +00:00
Pirama Arumuga Nainar c83bbf55d7 Configure ELAST for MinGW
Summary:
Use _LIBCPP_MSVCRT_LIKE while configuring ELAST, so MinGW gets the same
configuration as MSVC.

Reviewers: compnerd, srhines, danalbert, mstorsjo

Subscribers: christof, ldionne, cfe-commits

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

llvm-svn: 335916
2018-06-28 20:16:45 +00:00
Ahmed Bougacha 21e7aab7e5 [CMake] Rename cxx_headers back to cxx-headers.
r334477 renamed the cxx-headers target to cxx_headers, but various
pieces sort-of expect the target names to match the component (e.g.,
LLVM_DISTRIBUTION_COMPONENTS in the various bootstrap caches, which, via
some magic foreign to me, seems to expect cxx-headers,
install-cxx-headers, and install-cxx-headers-stripped to exist.)

Revert back to cxx-headers.

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

llvm-svn: 335899
2018-06-28 18:35:35 +00:00
Petr Hosek 887f26d470 Support for multiarch runtimes layout
This change adds a support for multiarch style runtimes layout, so in
addition to the existing layout where runtimes get installed to:

lib/clang/$version/lib/$os

Clang now allows runtimes to be installed to:

lib/clang/$version/$target/lib

This also includes libc++, libc++abi and libunwind; today those are
assumed to be in Clang library directory built for host, with the
new layout it is possible to install libc++, libc++abi and libunwind
into the runtime directory built for different targets.

The use of new layout is enabled by setting the
LLVM_ENABLE_RUNTIME_TARGET_DIR CMake variable and is supported by both
projects and runtimes layouts. The runtimes CMake build has been further
modified to use the new layout when building runtimes for multiple
targets.

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

llvm-svn: 335809
2018-06-28 03:11:52 +00:00
Matt Morehouse b812847647 [CMake] Fix install-cxx target.
Was broken by r334477.

llvm-svn: 335507
2018-06-25 18:01:51 +00:00
Martin Storsjo 11b02759a3 [CMake] Convert paths to the right form in standalone builds on Windows
The paths output from llvm-config --cmakedir and from clang
--print-libgcc-file-name can contain backslashes, while CMake
can't handle the paths in this form.

This matches what compiler-rt already does (since SVN r203789
and r293195).

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

llvm-svn: 335172
2018-06-20 21:03:34 +00:00
Richard Smith 7ebd641fcf Fix libcxx tests after clang r334677.
Feature test macro versions may have a trailing L.

llvm-svn: 334917
2018-06-17 19:58:45 +00:00
Marshall Clow b6b7a3bb78 Remove P0771, which was not passed in Rapperswil
llvm-svn: 334894
2018-06-16 18:03:29 +00:00
Stephan T. Lavavej cb0d20519e [libcxx] [test] Strip trailing whitespace. NFC.
llvm-svn: 334676
2018-06-14 00:12:20 +00:00
Stephan T. Lavavej 896e499e38 [libcxx] [test] Update msvc_stdlib_force_include.hpp.
MSVC's STL removed _SCL_SECURE_NO_WARNINGS.

MSVC's STL implemented feature-test macros.

llvm-svn: 334675
2018-06-14 00:12:14 +00:00
Petr Hosek a9e7908e30 [CMake] Use common variable for all header targets NFC
This simplifies the handling of header targets.

llvm-svn: 334477
2018-06-12 06:58:06 +00:00
Petr Hosek 0aa70faf9b [CMake] Add a missing target dependency on C++ ABI headers
This resolves the breakage introduced in r334468 which results in
build error when using CMake Makefile generator.

llvm-svn: 334470
2018-06-12 03:31:03 +00:00
Petr Hosek c20c182df3 Reland "Use custom command and target to install libc++ headers"
Using file(COPY FILE...) has several downsides. Since the file command
is only executed at configuration time, any changes to headers made
after the initial CMake execution are ignored. This can lead to subtle
errors since the just built Clang will be using stale libc++ headers.
Furthermore, since the headers are copied prior to executing the build
system, this may hide missing dependencies on libc++ from other LLVM
components.

This changes replaces the use of file(COPY FILE...) command with a
custom command and target which addresses all aforementioned issues and
matches the implementation already used by other LLVM components that
also install headers like Clang builtin headers.

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

llvm-svn: 334468
2018-06-12 03:10:02 +00:00
Marshall Clow e044d1e504 Update the to-do list with motions from Rapperswil.
llvm-svn: 334467
2018-06-12 02:45:30 +00:00
Volodymyr Sapsai d1df7b7ee7 Mark the test using <experimental/memory_resource> to require c++experimental.
When built against the old libc++ version the test was causing linker error

Undefined symbols for architecture x86_64:
  "std::experimental::fundamentals_v1::pmr::new_delete_resource()", referenced from:
      void test_evil<WidgetV0, WidgetV0>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV0, WidgetV1>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV0, WidgetV2>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV0, WidgetV3>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV1, WidgetV0>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV1, WidgetV1>() in construct_piecewise_pair_evil.pass.cpp.o
      void test_evil<WidgetV1, WidgetV2>() in construct_piecewise_pair_evil.pass.cpp.o
      ...

llvm-svn: 334431
2018-06-11 19:42:27 +00:00