13 Commits

Author SHA1 Message Date
Louis Dionne
9783f28cbb
[libc++] Format the code base (#74334)
This patch runs clang-format on all of libcxx/include and libcxx/src, in
accordance with the RFC discussed at [1]. Follow-up patches will format
the benchmarks, the test suite and remaining parts of the code. I'm
splitting this one into its own patch so the diff is a bit easier to
review.

This patch was generated with:

   find libcxx/include libcxx/src -type f \
      | grep -v 'module.modulemap.in' \
      | grep -v 'CMakeLists.txt' \
      | grep -v 'README.txt' \
      | grep -v 'libcxx.imp' \
      | grep -v '__config_site.in' \
      | xargs clang-format -i

A Git merge driver is available in libcxx/utils/clang-format-merge-driver.sh
to help resolve merge and rebase issues across these formatting changes.

[1]: https://discourse.llvm.org/t/rfc-clang-formatting-all-of-libc-once-and-for-all
2023-12-18 14:01:33 -05:00
Mark de Wever
3c28ce6bec [libc++] Adds __throw_system_error overload.
This was mention in D150044 and D154995 that this would be useful.
This addresses the last review coment of D150044.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D156019
2023-08-29 19:08:18 +02:00
Nikolas Klauser
4da76ea70a [libc++][NFC] Refactor enable_ifs in defaulted arguments to defaulted template arguments
This brings most of the enable_ifs in libc++ to the same style. It also has the nice side-effect of reducing the size of names of these symbols, since the arguments don't get mangled anymore.

Reviewed By: #libc, Mordante

Spies: Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157748
2023-08-18 13:08:18 -07:00
Nikolas Klauser
475bd19ee8 [libc++][NFC] Refactor return type enable_ifs to defaulted template arguments
This brings most of the enable_ifs in libc++ to the same style. It also has the nice side-effect of reducing the size of names of these symbols, since the depedent return type is shorter.

Reviewed By: #libc, ldionne

Spies: ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D157736
2023-08-15 12:19:21 -07:00
Edoardo Sanguineti
66bb6b4fda [libc++] Optimize internal function in <system_error>
In the event the internal function __init is called with an empty string the code will take unnecessary extra steps, in addition, the code generated might be overall greater because, to my understanding, when initializing a string with an empty `const char*` "" (like in this case), the compiler might be unable to deduce the string is indeed empty at compile time and more code is generated.

The goal of this patch is to make a new internal function that will accept just an error code skipping the empty string argument. It should skip the unnecessary steps and in the event `if (ec)` is `false`, it will return an empty string using the correct ctor, avoiding any extra code generation issues.

After the conversation about this patch matured in the libcxx channel on the LLVM Discord server, the patch was analyzed quickly with "Compiler Explorer" and other tools and it was discovered that it does indeed reduce the amount of code generated when using the latest stable clang version (16) which in turn produces faster code.

This patch targets LLVM 18 as it will break the ABI by addressing https://github.com/llvm/llvm-project/issues/63985

Benchmark tests run on other machines as well show in the best case, that the new version without the extra string as an argument performs 10 times faster.
On the buildkite CI run it shows the new code takes less CPU time as well.
In conclusion, the new code should also just appear cleaner because there are fewer checks to do when there is no message.

Reviewed By: #libc, philnik

Spies: emaste, nemanjai, philnik, libcxx-commits

Differential Revision: https://reviews.llvm.org/D155820
2023-08-11 13:08:45 -07:00
Ian Anderson
40cdb220f5 [libc++][Modules] Make module exports consistent with header includes
Some modules export modules that they don't import (i.e. that their header doesn't directly include). That sometimes works when the exported submodule is in the same module, but when the `std` mega module is broken up (D144322), some of the exports stop working. Make the exports and includes consistent, either by adding includes for the exports, or by removing exports for missing includes.

The `concepts.equality_comparable` export in `std.iterator.__iterator.concepts` isn't doing anything because 1) it's resolved as `std.iterator.__iterator.concepts.equality_comparable` and 2) there's a `__concepts` submodule in between `std.concepts` and `equality_comparable`. Fix it to be `std.concepts.__concepts.equality_comparable`.

<span> is listed in both `std.span` and `std.experimental.span`. Delete the latter module.
There is no `__errc` module or header, so remove that export from `std.system_error`.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D153211
2023-06-29 15:37:03 -07:00
Nikolas Klauser
f1ea0b11ca [libc++] Merge _LIBCPP_FUNC_VIS, _LIBCPP_TYPE_VIS and _LIBCPP_EXCEPTION_ABI into _LIBCPP_EXPORTED_FROM_ABI
These macros are always defined identically, so we can simplify the code a bit by merging them.

Reviewed By: ldionne, #libc

Spies: libcxx-commits, krytarowski, smeenai

Differential Revision: https://reviews.llvm.org/D152652
2023-06-15 08:56:45 -07:00
Nikolas Klauser
18c4695ded [libc++][NFC] Fix whitespace problems in the files added to ignore_format.txt in D151115
Reviewed By: ldionne, #libc, Mordante

Spies: arichardson, Mordante, libcxx-commits

Differential Revision: https://reviews.llvm.org/D151119
2023-05-23 08:44:10 -07:00
Nikolas Klauser
83ce139721 [libc++] Add hide_from_abi check for classes
We already have a clang-tidy check for making sure that `_LIBCPP_HIDE_FROM_ABI` is on free functions. This patch extends this to class members. The places where we don't check for `_LIBCPP_HIDE_FROM_ABI` are classes for which we have an instantiation in the library.

Reviewed By: ldionne, Mordante, #libc

Spies: jplehr, mikhail.ramalho, sstefan1, libcxx-commits, krytarowski, miyuki, smeenai

Differential Revision: https://reviews.llvm.org/D142332
2023-04-16 15:23:23 +02:00
Mark de Wever
943d225713 [NFC][libc++] Use _LIBCPP_HIDE_FROM_ABI.
This updates the new __system_error directory.

Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D148028
2023-04-12 17:34:58 +02:00
Mark de Wever
51f0b809ca [libc++] Formats the sytem_error headers.
Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D147886
2023-04-11 18:40:29 +02:00
Nikolas Klauser
eb65912e41 [libc++] Move __errc to __system_error/errc.h
This file was added before we started granularizing the headers, but is essentially just a granularized header. This moves the header to the correct place.

Reviewed By: #libc, EricWF

Spies: libcxx-commits, arichardson, mikhail.ramalho

Differential Revision: https://reviews.llvm.org/D146395
2023-04-10 19:23:42 +02:00
Mark de Wever
e8cfbfd05a [libc++] Granularize system_error.
Reviewed By: #libc, philnik

Differential Revision: https://reviews.llvm.org/D147853
2023-04-09 17:57:14 +02:00