llvm-capstone/libcxx
Richard Smith 72315d02c4 Treat std::move, forward, etc. as builtins.
This is extended to all `std::` functions that take a reference to a
value and return a reference (or pointer) to that same value: `move`,
`forward`, `move_if_noexcept`, `as_const`, `addressof`, and the
libstdc++-specific function `__addressof`.

We still require these functions to be declared before they can be used,
but don't instantiate their definitions unless their addresses are
taken. Instead, code generation, constant evaluation, and static
analysis are given direct knowledge of their effect.

This change aims to reduce various costs associated with these functions
-- per-instantiation memory costs, compile time and memory costs due to
creating out-of-line copies and inlining them, code size at -O0, and so
on -- so that they are not substantially more expensive than a cast.
Most of these improvements are very small, but I measured a 3% decrease
in -O0 object file size for a simple C++ source file using the standard
library after this change.

We now automatically infer the `const` and `nothrow` attributes on these
now-builtin functions, in particular meaning that we get a warning for
an unused call to one of these functions.

In C++20 onwards, we disallow taking the addresses of these functions,
per the C++20 "addressable function" rule. In earlier language modes, a
compatibility warning is produced but the address can still be taken.

The same infrastructure is extended to the existing MSVC builtin
`__GetExceptionInfo`, which is now only recognized in namespace `std`
like it always should have been.

This is a re-commit of
  fc30901096,
  a571f82a50,
  64c045e25b, and
  de6ddaeef3,
and reverts aa643f455a.
This change also includes a workaround for users using libc++ 3.1 and
earlier (!!), as apparently happens on AIX, where std::move sometimes
returns by value.

Reviewed By: aaron.ballman

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

Revert "Fixup D123950 to address revert of D123345"

This reverts commit aa643f455a.
2022-04-20 17:58:31 -07:00
..
benchmarks [libc++][ranges] Implement ranges::minmax and ranges::minmax_element 2022-04-14 15:37:22 +02:00
cmake [libcxx] Stop recommending setting LIBCXX_HAS_WIN32_THREAD_API in the MinGW builds 2022-04-04 23:07:40 +03:00
docs [libc++] Implement ranges::copy{, _n, _if, _backward} 2022-04-15 13:44:11 +02:00
include [libc++] Granularize <functional> includes 2022-04-20 22:49:18 +02:00
lib [libc++][NFC] Refactor the ABI changelog 2022-03-24 10:24:43 -04:00
src [libc++] Define legacy symbols for inline functions at a finer-grained level 2022-04-12 13:44:30 -04:00
test Treat std::move, forward, etc. as builtins. 2022-04-20 17:58:31 -07:00
utils Fix libcxx build after cd0a5889d7 2022-04-12 15:42:56 -07:00
.clang-format [libc++] Update clang-format to C++20. 2021-10-30 12:50:57 +02:00
.clang-tidy [libc++] Enable modernize-loop-convert 2022-03-18 20:34:19 +01:00
.gitignore
appveyor-reqs-install.cmd
appveyor.yml
CMakeLists.txt [libc++] Add a lightweight overridable assertion handler 2022-03-23 15:35:46 -04:00
CREDITS.TXT Microsoft's floating-point to_chars powered by Ryu and Ryu Printf 2021-12-12 16:34:50 +01:00
LICENSE.TXT
TODO.TXT [libc++] Disallow volatile types in std::allocator 2021-09-22 11:47:38 -04:00