[libcxx-commits] [PATCH] D141321: [libc++] Add [[clang::lifetimebound]] attribute to std::forward and friends

Nikolas Klauser via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 10 12:36:28 PST 2023


philnik added inline comments.


================
Comment at: libcxx/include/__config:1056
+#  if __has_cpp_attribute(_Clang::__lifetimebound__)
+#    define _LIBCPP_LIFETIMEBOUND [[_Clang::__lifetimebound__]]
+#  else
----------------
Mordante wrote:
> Why not `[[clang::lifetimebound]]` ?
For the same reason that we _Uglify all other names: macros. Attributes are not immune to them, so we have to _Uglify them too. https://godbolt.org/z/MqW68b9PY


================
Comment at: libcxx/include/__utility/forward_like.h:37
 template <class _Tp, class _Up>
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto forward_like(_Up&& __ux) noexcept -> _ForwardLike<_Tp, _Up> {
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto forward_like(_LIBCPP_LIFETIMEBOUND _Up&& __ux) noexcept
+    -> _ForwardLike<_Tp, _Up> {
----------------
Mordante wrote:
> Should this extension be documented, like we do with `[[nodiscard]]`?
I'm not convinced we should list the `[[nodiscard]]` decorated functions. As we extend the use of these kinds of macros the lists become long and I don't see why anybody who is actually interested in that list. Users are interested in getting warnings from the compiler, not which functions have some specific attribute. We also don't document which symbols are marked `[[clang::preferred_name]]`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141321/new/

https://reviews.llvm.org/D141321



More information about the libcxx-commits mailing list