Commit Graph

9393 Commits

Author SHA1 Message Date
Muhammad Usman Shahid 6542cb55a3 Rewording the "static_assert" to static assertion
This patch is basically the rewording of the static assert statement's
output(error) on screen after failing. Failing a _Static_assert in C
should not report that static_assert failed. It’d probably be better to
reword the diagnostic to be more like GCC and say “static assertion”
failed in both C and C++.

consider a c file having code

_Static_assert(0, "oh no!");

In clang the output is like:

<source>:1:1: error: static_assert failed: oh no!
_Static_assert(0, "oh no!");
^              ~
1 error generated.
Compiler returned: 1

Thus here the "static_assert" is not much good, it will be better to
reword it to the "static assertion failed" to more generic. as the gcc
prints as:

<source>:1:1: error: static assertion failed: "oh no!"
    1 | _Static_assert(0, "oh no!");
          | ^~~~~~~~~~~~~~
          Compiler returned: 1

The above can also be seen here. This patch is about rewording
the static_assert to static assertion.

Differential Revision: https://reviews.llvm.org/D129048
2022-07-21 06:34:14 -07:00
Hui Xie 7abbd6224b [libc++] Fix proxy iterator issues that trigger an assertion in Chromium.
Crash report:
https://bugs.chromium.org/p/chromium/issues/detail?id=1346012

The triggered assertion is related sorting with `v8::internal::AtomicSlot`.
`AtomicSlot` is a proxy iterator with a proxy type `AtomicSlot::Reference`
(see 9bcb5eb590/src/objects/slots-atomic-inl.h).

https://reviews.llvm.org/D130197 correctly spotted the issue in
`__iter_move` but doesn't actually fix the issue. The reason is that
`AtomicSlot::operator*` returns a prvalue `Reference`. After the fix in
D130197, the return type of `__iter_move` is `Reference&&`. But the
rvalue reference is bound to the temporary value returned by
`operator*`, which will be dangling after `__iter_move` returns.

The idea of the fix in this change is borrowed from C++17's move_iterator
https://timsong-cpp.github.io/cppwp/n4659/move.iterators#move.iterator-1
When the underlying reference is a prvalue, we just return it by value.

Differential Revision: https://reviews.llvm.org/D130212
2022-07-20 18:05:49 -07:00
Konstantin Varlamov bc4d2e7051 [libc++] Fix `_IterOps::__iter_move` to support proxy iterators.
The return type was specified incorrectly for proxy iterators that
define `reference` to be a class that implicitly converts to
`value_type`. `__iter_move` would end up returning an object of type
`reference` which would then implicitly convert to `value_type`; thus,
the function will return a `value_type&&` rvalue reference to the local
temporary.

Differential Revision: https://reviews.llvm.org/D130197
2022-07-20 13:19:00 -07:00
Nikolas Klauser 23cf42e706 [libc++] Use uninitialized algorithms for vector
Reviewed By: ldionne, #libc

Spies: libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D128146
2022-07-20 22:02:14 +02:00
Konstantin Varlamov 065202f3ca [libc++][ranges] Implement `std::ranges::partition_{point,copy}`.
Reviewed By: #libc, huixie90, ldionne

Differential Revision: https://reviews.llvm.org/D130070
2022-07-20 11:39:07 -07:00
Mark de Wever b32e600edd [libc++][format] Updates the status page. 2022-07-20 19:26:28 +02:00
Mark de Wever 857a78c04d [libc++] Implements Unicode grapheme clustering
This implements the Grapheme clustering as required by
P1868R2 width: clarifying units of width and precision in std::format

This was omitted in the initial patch, but the paper was marked as completed. This really completes the paper.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D126971
2022-07-20 18:38:32 +02:00
Mark de Wever 29a66ab766 [libc++][doc] Updates the release notes.
This is a preparation for the upcoming LLVM 16 release.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D130031
2022-07-20 18:20:18 +02:00
Nikolas Klauser 309aed3068 [libc++] Implement P1423R3 (char8_t backward compatibility remediation)
Reviewed By: Mordante, #libc

Spies: h-vetinari, libcxx-commits, arichardson

Differential Revision: https://reviews.llvm.org/D129195
2022-07-20 11:27:51 +02:00
Nikolas Klauser 20d30f709b [libc++] Add clang-tidy for the tests
Reviewed By: Mordante, huixie90, #libc

Spies: aheejin, libcxx-commits

Differential Revision: https://reviews.llvm.org/D129976
2022-07-20 11:26:49 +02:00
Konstantin Varlamov 25aa29f38a [libc++][ranges][NFC] Consolidate range algorithm checks for returning `dangling`.
Also simplify the `robust` test files for non-boolean predicates and
omitting `std::invoke`.

Differential Revision: https://reviews.llvm.org/D129741
2022-07-19 20:46:22 -07:00
varconst 5dd19ada57 [libc++][ranges] Implement `ranges::partial_sort`.
Differential Revision: https://reviews.llvm.org/D128744
2022-07-19 20:10:34 -07:00
Konstantin Varlamov 18f46f3ab0 [libc++][ranges] Fix broken CI. 2022-07-19 18:14:44 -07:00
Hui Xie 9c0564a3a7 [libc++][ranges] fix `std::search_n` incorrect `static_assert`
[libc++][ranges] fix `std::search_n` incorrect `static_assert`
see more detail in https://reviews.llvm.org/D124079?#3661721

Differential Revision: https://reviews.llvm.org/D130124
2022-07-19 17:24:47 -07:00
Konstantin Varlamov b8d54d1d6a [libc++][ranges][NFC] Test that range algorithms support iterators requiring `iter_move`.
Differential Revision: https://reviews.llvm.org/D130057
2022-07-19 17:21:08 -07:00
Joe Loser 50cfb76e02
[libc++] Define ostream nullptr inserter for >= C++17 only
The `ostream` `nullptr` inserter implemented in 3c125fe is missing a C++ version
guard. Normally, `libc++` takes the stance of backporting LWG issues to older
standards modes as was done in 3c125fe. However, backporting to older standards
modes breaks existing code in popular libraries such as `Boost.Test` and
`Google Test` who define their own overload for `nullptr_t`.

Instead, only apply this `operator<<` overload in C++17 or later.

Fixes https://github.com/llvm/llvm-project/issues/55861.

Differential Revision: https://reviews.llvm.org/D127033
2022-07-19 18:16:45 -06:00
Louis Dionne 91941f0142 [libc++][NFC] Add commit SHA for ABI change 2022-07-19 17:16:53 -04:00
Louis Dionne f1c3013541 [libc++] Drop the legacy debug mode symbols by default
Leave the escape hatch in place with a note, but don't include the
debug mode symbols by default since we don't support the debug mode
in the normal library anymore.

This is technically an ABI break for users who were depending on
those debug mode symbols in the dylib, however those users will
already be broken at compile-time because they must have been using
_LIBCPP_DEBUG=2, which is now an error.

Differential Revision: https://reviews.llvm.org/D127360
2022-07-19 17:16:06 -04:00
Louis Dionne 8711fcae27 [libc++] Treat incomplete features just like other experimental features
In particular remove the ability to expel incomplete features from the
library at configure-time, since this can now be done through the
_LIBCPP_ENABLE_EXPERIMENTAL macro.

Also, never provide symbols related to incomplete features inside the
dylib, instead provide them in c++experimental.a (this changes the
symbols list, but not for any configuration that should have shipped).

Differential Revision: https://reviews.llvm.org/D128928
2022-07-19 10:50:20 -04:00
Louis Dionne 7300a651f5 [libc++] Re-apply "Always build c++experimental.a""
This re-applies bb939931a1, which had been reverted by 09cebfb978
because it broke Chromium. The issues seen by Chromium should be
addressed by 1d0f79558c.

Differential Revision: https://reviews.llvm.org/D128927
2022-07-19 10:44:19 -04:00
Louis Dionne 1d0f79558c [libc++] Make sure cxx_experimental links against libc++ headers
This should fix builds where we build neither the static nor the shared
library.
2022-07-19 10:41:36 -04:00
Konstantin Varlamov 8ed702b83f [libc++][ranges] Implement `ranges::{,stable_}partition`.
Differential Revision: https://reviews.llvm.org/D129624
2022-07-18 21:06:17 -07:00
Hans Wennborg 09cebfb978 Revert "[libc++] Always build c++experimental.a"
This caused build failures when building Clang and libc++ together on Mac:

  fatal error: 'experimental/memory_resource' file not found

See the code review for details. Reverting until the problem and how to
solve it is better understood.

(Updates to some test files were not reverted, since they seemed
unrelated and were later updated by 340b48b267b96.)

> This is the first part of a plan to ship experimental features
> by default while guarding them behind a compiler flag to avoid
> users accidentally depending on them. Subsequent patches will
> also encompass incomplete features (such as <format> and <ranges>)
> in that categorization. Basically, the idea is that we always
> build and ship the c++experimental library, however users can't
> use what's in it unless they pass the `-funstable` flag to Clang.
>
> Note that this patch intentionally does not start guarding
> existing <experimental/FOO> content behind the flag, because
> that would merely break users that might be relying on such
> content being in the headers unconditionally. Instead, we
> should start guarding new TSes behind the flag, and get rid
> of the existing TSes we have by shipping their Standard
> counterpart.
>
> Also, this patch must jump through a few hoops like defining
> _LIBCPP_ENABLE_EXPERIMENTAL because we still support compilers
> that do not implement -funstable yet.
>
> Differential Revision: https://reviews.llvm.org/D128927

This reverts commit bb939931a1.
2022-07-18 16:57:15 +02:00
Brad Smith da11b775b1 [libcxx] Fix copy and pasto that broke the build on Android/Fuchsia
Reviewed by: Mordante, phosek

Differential Revision: https://reviews.llvm.org/D129978
2022-07-18 09:16:49 -04:00
David Spickett 22a8671fd6 Revert "[libcxx] Temporarily skip Arm configs"
This reverts commit 81bffdf6a5,
the machine is back online.

Differential Revision: https://reviews.llvm.org/D129987
2022-07-18 10:13:12 +00:00
Konstantin Varlamov a7c3379cf9 [libc++][ranges] Make range algorithms support proxy iterators
Also test all the range algorithms to verify the support.

Differential Revision: https://reviews.llvm.org/D129823
2022-07-17 18:12:06 -07:00
Nikolas Klauser 6f0f2f9a1a [libc++] Enable test for already written ranges algorithms
Reviewed By: Mordante, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D129970
2022-07-18 00:58:07 +02:00
Igor Zhukov d2f21f98a9 Conversion from '__int64' to 'long', possible loss of data
llvm-project\libcxx\test\std\time\time.hms\time.hms.members\seconds.pass.cpp(38): note: see reference to function template instantiation 'long check_seconds<std::chrono::seconds>(Duration)' being compiled
        with
        [
            Duration=std::chrono::seconds
        ]
llvm-project\libcxx\test\std\time\time.hms\time.hms.members\seconds.pass.cpp(31): warning C4244: 'return': conversion from '_Rep' to 'long', possible loss of data
        with
        [
            _Rep=__int64
        ]

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D129928
2022-07-17 16:43:41 +02:00
Brad Smith 21ef59a55e [libcxx] Replace remaining _LIBCPP_INLINE_VISIBILITY in __support
Replace remaining _LIBCPP_INLINE_VISIBILITY in __support with _LIBCPP_HIDE_FROM_ABI.

Reviewed by: Mordante

Differential Revision: https://reviews.llvm.org/D129922
2022-07-16 19:08:34 -04:00
Xing Xue d29c947732 [libc++][AIX] Correct the definition of __regex_word for AIX
Summary:
The patch changes the definition of __regex_word to 0x8000 for AIX because the current definition 0x80 clashes with ctype_base::print (_ISPRINT is defined as 0x80 in AIX ctype.h).

Reviewed by: Mordante, hubert.reinterpretcast, libc++

Differential Revision: https://reviews.llvm.org/D129862
2022-07-16 18:11:04 -04:00
Igor Zhukov 9aea9ab83d Visual C++ doesn't support C99 compound literal
Fix test libcxx/test/std/containers/sequences/array/array.creation/to_array.pass.cpp

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D129923
2022-07-16 19:47:45 +02:00
Igor Zhukov 844a320ccd Tests ignore the return value of sto{meow}, triggering nodiscard warnings in MS STL
Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D129925
2022-07-16 19:46:34 +02:00
Adhemerval Zanella 81bffdf6a5 [libcxx] Temporarily skip Arm configs
The machine hosting these agents will be down for maintenance July 15th.

Differential Revision: https://reviews.llvm.org/D129847
2022-07-15 09:11:26 -03:00
Nikolas Klauser 5492b71db3 [libc++] Update RangesAlgorithms.csv 2022-07-15 00:18:31 +02:00
Hui Xie 3151b95dad [libc++][ranges] implement `std::ranges::set_union`
[libc++][ranges] implement `std::ranges::set_union`

Differential Revision: https://reviews.llvm.org/D129657
2022-07-14 21:05:30 +01:00
David Tenty a83004f4ff [libcxx][AIX][z/OS] Remove headers included via `_IBMCPP__`
D127650 removed support for non-clang-based XL compilers, but left some
of the headers used only by this compiler and included under the
__IBMCPP__ macro. This change cleans this up by deleting these headers.

Reviewed By: hubert.reinterpretcast, fanbo-meng

Differential Revision: https://reviews.llvm.org/D129491
2022-07-14 15:41:46 -04:00
Louis Dionne 340b48b267 [libc++] Add missing UNSUPPORTED annotations to experimental tests that use RTTI 2022-07-14 15:12:20 -04:00
Nikolas Klauser 0a92e0728c [libc++] Use __unwrap_iter_impl for both unwrapping and rewrapping
Reviewed By: ldionne, #libc

Spies: arichardson, sstefan1, libcxx-commits

Differential Revision: https://reviews.llvm.org/D129039
2022-07-14 20:01:19 +02:00
Nikolas Klauser 64d63f4823 [libc++] Error if someone tries to use MSVC and tell them to contact the libc++ developers
Nobody knows if there are users of libc++ with MSVC. Let's try to find that out and encourage them to upstream their changes to make that configuration work.

Reviewed By: ldionne, #libc

Spies: libcxx-commits

Differential Revision: https://reviews.llvm.org/D129055
2022-07-14 19:35:12 +02:00
Nikolas Klauser 2619ce8b7e [libc++] Test the size of basic_string
Reviewed By: ldionne, #libc

Spies: hubert.reinterpretcast, arichardson, mstorsjo, libcxx-commits

Differential Revision: https://reviews.llvm.org/D127672
2022-07-14 16:57:51 +02:00
Nikolas Klauser 0f050528fd [libc++] Allow setting _LIBCPP_OVERRIDABLE_FUNC_VIS
Chromium changes this flag to be able to use a custom new/delete from a
dylib.
2022-07-14 15:09:38 +02:00
Hui Xie a5c0638dec [libc++][ranges] implement `std::ranges::set_symmetric_difference`
[libc++][ranges] implement `std::ranges::set_symmetric_difference`

Differential Revision: https://reviews.llvm.org/D129520
2022-07-13 21:24:32 +01:00
Nikolas Klauser 101d1e9b3c [libc++] Implement ranges::find_end, ranges::search{, _n}
Reviewed By: var-const, #libc, huixie90

Spies: thakis, h-vetinari, huixie90, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D124079
2022-07-13 20:30:55 +02:00
Mark de Wever 6589729206 [libc++][format] Improves parsing speed.
A format string like "{}" is quite common. In this case avoid parsing
the format-spec when it's not present. Before the parsing was always
called, therefore some refactoring is done to make sure the formatters
work properly when their parse member isn't called.

From the wording it's not entirely clear whether this optimization is
allowed

[tab:formatter]
```
  and the range [pc.begin(), pc.end()) from the last call to f.parse(pc).
```
Implies there's always a call to `f.parse` even when the format-spec
isn't present. Therefore this optimization isn't done for handle
classes; it's unclear whether that would break user defined formatters.

The improvements give a small reduciton is code size:
 719408	  12472	    488	 732368	  b2cd0	before
 718824	  12472	    488	 731784	  b2a88	after

The performance benefits when not using a format-spec are:

```
Comparing ./formatter_int.libcxx.out-baseline to ./formatter_int.libcxx.out
Benchmark                                                               Time             CPU      Time Old      Time New       CPU Old       CPU New
----------------------------------------------------------------------------------------------------------------------------------------------------
BM_Basic<uint32_t>                                                   -0.0688         -0.0687            67            62            67            62
BM_Basic<int32_t>                                                    -0.1105         -0.1107            73            65            73            65
BM_Basic<uint64_t>                                                   -0.1053         -0.1049            95            85            95            85
BM_Basic<int64_t>                                                    -0.0889         -0.0888            93            85            93            85
BM_BasicLow<__uint128_t>                                             -0.0655         -0.0655            96            90            96            90
BM_BasicLow<__int128_t>                                              -0.0693         -0.0694            97            90            97            90
BM_Basic<__uint128_t>                                                -0.0359         -0.0359           256           247           256           247
BM_Basic<__int128_t>                                                 -0.0414         -0.0414           239           229           239           229
```

For the cases where a format-spec is used the results remain similar,
some are faster some are slower, differing per run.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D129426
2022-07-13 17:39:09 +02:00
Mark de Wever fd36a3d48d [libc++][chrono] Adds operator<=> for day.
Since the calendar classes were introduced in C++20 there's no need to
keep the old comparison operators.

This commit does the day calender class, the other calendar classes will
be in a followup commit.

Implements parts of:
- P1614R2 The mothership has landed

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D128603
2022-07-13 17:20:31 +02:00
Nikolas Klauser 1f04759316 Revert "[libc++] Implement ranges::find_end, ranges::search{, _n}"
This reverts commit 76a7651850.
2022-07-13 13:41:25 +02:00
Nikolas Klauser 76a7651850 [libc++] Implement ranges::find_end, ranges::search{, _n}
Reviewed By: var-const, #libc, huixie90

Spies: h-vetinari, huixie90, libcxx-commits, mgorny

Differential Revision: https://reviews.llvm.org/D124079
2022-07-13 13:11:26 +02:00
Konstantin Varlamov 295b951ebc [lib++][ranges][NFC] Refactor `iterator_operations.h` to use tags.
Change the mechanism in `iterator_operations.h` to pass around a generic
policy tag indicating whether an internal function is being invoked from
a "classic" STL algorithm or a ranges algorithm. `IterOps` is now
a template class specialized on the policy tag.

The advantage is that this mechanism is more generic and allows defining
arbitrary conditions in a clean manner.

Also add a few more iterator functions to `IterOps`.

Differential Revision: https://reviews.llvm.org/D129390
2022-07-12 17:53:58 -07:00
Mark de Wever 984f5f3f62 [libc++][test] Adds spaceship support to macros.
This was already reviewed as D128603. This contains only the updates to
the test script.

Differential Revision: https://reviews.llvm.org/D129578
2022-07-12 21:10:23 +02:00
David Tenty 4a009797ec [libc++][NFC] Add MVS guard for locale_mgmt_zos.h
This header need not be included on non-z/OS IBM platforms (and indeed
will add nothing when it is), so add a guard. This let's us remove the
header without things breaking when shipping libc++ for AIX.

Reviewed By: hubert.reinterpretcast, fanbo-meng

Differential Revision: https://reviews.llvm.org/D129493
2022-07-12 14:15:42 -04:00