[libcxx-commits] [libcxx] f6fc5e8 - [libc++][test] Guard non-guaranteed implicit-lifetime-ness cases with `_LIBCPP_VERSION` (#160627)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 26 03:08:02 PDT 2025


Author: A. Jiang
Date: 2025-09-26T18:07:59+08:00
New Revision: f6fc5e83d71e643518c63acb5e43847cd1813895

URL: https://github.com/llvm/llvm-project/commit/f6fc5e83d71e643518c63acb5e43847cd1813895
DIFF: https://github.com/llvm/llvm-project/commit/f6fc5e83d71e643518c63acb5e43847cd1813895.diff

LOG: [libc++][test] Guard non-guaranteed implicit-lifetime-ness cases with `_LIBCPP_VERSION` (#160627)

And add some guaranteed cases (namely, for `expected`, `optional`, and
`variant`) to `is_implicit_lifetime.pass.cpp`.

It's somehow unfortunate that `pair` and `tuple` are not guaranteed to
propagate triviality of copy/move constructors, and MSVC STL fails to do
so due to ABI compatibility. This affects the implicit-lifetime
property.

Added: 
    

Modified: 
    libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
index a68f3f40e3647..5264e7700e3d9 100644
--- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
+++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_implicit_lifetime.pass.cpp
@@ -17,9 +17,12 @@
 
 #include <cassert>
 #include <cstddef>
+#include <expected>
+#include <optional>
 #include <tuple>
 #include <type_traits>
 #include <utility>
+#include <variant>
 
 #include "test_macros.h"
 #include "type_algorithms.h"
@@ -216,8 +219,16 @@ constexpr bool test() {
 
   // C++ standard library types
 
+  // These types are guaranteed to be implicit-lifetime.
+  test_is_implicit_lifetime<std::expected<int, float>>();
+  test_is_implicit_lifetime<std::optional<float>>();
+  test_is_implicit_lifetime<std::variant<float, int>>();
+
+#ifdef _LIBCPP_VERSION
+  // These types should be implicit-lifetime, but they are not guaranteed to be so.
   test_is_implicit_lifetime<std::pair<int, float>>();
   test_is_implicit_lifetime<std::tuple<int, float>>();
+#endif
 
   // Standard C23 types
 


        


More information about the libcxx-commits mailing list