[libcxx-commits] [libcxx] mark std::make_format_args with clang::lifetimebound attribute (PR #78997)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jan 22 07:59:51 PST 2024


https://github.com/kelbon created https://github.com/llvm/llvm-project/pull/78997

Inspired by:

https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2905r2.html

[[clang::lifetimebound]] is great, it may be very useful in many places of standard library

how it will work:

https://godbolt.org/z/dqj5eazMn



>From 1638b0d3d8c16473b1d51d69b4b01756f2e7d760 Mon Sep 17 00:00:00 2001
From: Kelbon Nik <kelbonage at gmail.com>
Date: Mon, 22 Jan 2024 19:46:13 +0400
Subject: [PATCH] add lifetime bound on make_format_args

---
 libcxx/include/__format/format_functions.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/include/__format/format_functions.h b/libcxx/include/__format/format_functions.h
index 015bff70f51d97..0de1c5dc7c5e32 100644
--- a/libcxx/include/__format/format_functions.h
+++ b/libcxx/include/__format/format_functions.h
@@ -63,7 +63,7 @@ using wformat_args = basic_format_args<wformat_context>;
 #  endif
 
 template <class _Context = format_context, class... _Args>
-_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&... __args) {
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&... __args [[clang::lifetimebound]]) {
   return _VSTD::__format_arg_store<_Context, _Args...>(__args...);
 }
 



More information about the libcxx-commits mailing list