[libcxx-commits] [libcxx] [libc++][C++03] Cherry-pick #106832 (PR #205547)
via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jun 24 09:02:24 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Nikolas Klauser (philnik777)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/205547.diff
3 Files Affected:
- (modified) libcxx/include/__cxx03/__config (+1-13)
- (modified) libcxx/include/__cxx03/__type_traits/datasizeof.h (+3-16)
- (modified) libcxx/test/libcxx-03/type_traits/datasizeof.compile.pass.cpp (+1-3)
``````````diff
diff --git a/libcxx/include/__cxx03/__config b/libcxx/include/__cxx03/__config
index 27c26084da4b1..c7b2d2b1a7c6d 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 d428856d13a66..c207f59ac2cc0 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 67a4dccb0f5fe..699c5101bb7fe 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>
``````````
</details>
https://github.com/llvm/llvm-project/pull/205547
More information about the libcxx-commits
mailing list