[libcxx-commits] [libcxx] 2750294 - [libc++][C++03] Cherry-pick #106832 (#205547)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 24 09:01:48 PDT 2026
Author: Nikolas Klauser
Date: 2026-06-24T18:01:43+02:00
New Revision: 2750294d90d6e76f49583eead7c9db2e8075149b
URL: https://github.com/llvm/llvm-project/commit/2750294d90d6e76f49583eead7c9db2e8075149b
DIFF: https://github.com/llvm/llvm-project/commit/2750294d90d6e76f49583eead7c9db2e8075149b.diff
LOG: [libc++][C++03] Cherry-pick #106832 (#205547)
Added:
Modified:
libcxx/include/__cxx03/__config
libcxx/include/__cxx03/__type_traits/datasizeof.h
libcxx/test/libcxx-03/type_traits/datasizeof.compile.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/include/__cxx03/__config b/libcxx/include/__cxx03/__config
index 27c26084da4b10..c7b2d2b1a7c6d8 100644
--- a/libcxx/include/__cxx03/__config
+++ b/libcxx/include/__cxx03/__config
@@ -842,21 +842,9 @@ typedef __char32_t char32_t;
// (If/when MSVC breaks its C++ ABI, it will be changed to work as intended.)
// However, MSVC implements [[msvc::no_unique_address]] which does what
// [[no_unique_address]] is supposed to do, in general.
-
-// Clang-cl does not yet (14.0) implement either [[no_unique_address]] or
-// [[msvc::no_unique_address]] though. If/when it does implement
-// [[msvc::no_unique_address]], this should be preferred though.
# define _LIBCPP_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
-# elif __has_cpp_attribute(no_unique_address)
-# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
# else
-# define _LIBCPP_NO_UNIQUE_ADDRESS /* nothing */
-// Note that this can be replaced by #error as soon as clang-cl
-// implements msvc::no_unique_address, since there should be no C++20
-// compiler that doesn't support one of the two attributes at that point.
-// We generally don't want to use this macro outside of C++20-only code,
-// because using it conditionally in one language version only would make
-// the ABI inconsistent.
+# define _LIBCPP_NO_UNIQUE_ADDRESS [[__no_unique_address__]]
# endif
// c8rtomb() and mbrtoc8() were added in C++20 and C23. Support for these
diff --git a/libcxx/include/__cxx03/__type_traits/datasizeof.h b/libcxx/include/__cxx03/__type_traits/datasizeof.h
index d428856d13a664..c207f59ac2cc0a 100644
--- a/libcxx/include/__cxx03/__type_traits/datasizeof.h
+++ b/libcxx/include/__cxx03/__type_traits/datasizeof.h
@@ -26,29 +26,16 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-#if __has_keyword(__datasizeof) || __has_extension(datasizeof)
+// TODO: Enable this again once #94816 is fixed.
+#if (__has_keyword(__datasizeof) || __has_extension(datasizeof)) && 0
template <class _Tp>
inline const size_t __datasizeof_v = __datasizeof(_Tp);
#else
-// NOLINTNEXTLINE(readability-redundant-preprocessor) This is https://llvm.org/PR64825
-# if __has_cpp_attribute(__no_unique_address__)
template <class _Tp>
struct _FirstPaddingByte {
- [[__no_unique_address__]] _Tp __v_;
+ _LIBCPP_NO_UNIQUE_ADDRESS _Tp __v_;
char __first_padding_byte_;
};
-# else
-template <class _Tp, bool = __libcpp_is_final<_Tp>::value || !is_class<_Tp>::value>
-struct _FirstPaddingByte : _Tp {
- char __first_padding_byte_;
-};
-
-template <class _Tp>
-struct _FirstPaddingByte<_Tp, true> {
- _Tp __v_;
- char __first_padding_byte_;
-};
-# endif // __has_cpp_attribute(__no_unique_address__)
// _FirstPaddingByte<> is sometimes non-standard layout. Using `offsetof` is UB in that case, but GCC and Clang allow
// the use as an extension.
diff --git a/libcxx/test/libcxx-03/type_traits/datasizeof.compile.pass.cpp b/libcxx/test/libcxx-03/type_traits/datasizeof.compile.pass.cpp
index 67a4dccb0f5fef..699c5101bb7fec 100644
--- a/libcxx/test/libcxx-03/type_traits/datasizeof.compile.pass.cpp
+++ b/libcxx/test/libcxx-03/type_traits/datasizeof.compile.pass.cpp
@@ -6,9 +6,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: FROZEN-CXX03-HEADERS-FIXME
-
-#include <__type_traits/datasizeof.h>
+#include <__cxx03/__type_traits/datasizeof.h>
#include <cstdint>
#include <type_traits>
More information about the libcxx-commits
mailing list