[Lldb-commits] [lldb] [lldb][test] Remove libc++ dependency in common libcxx-simulators header (PR #190922)

Michael Buch via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 8 00:48:53 PDT 2026


https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/190922

>From 88a798425c066a68e5dab35304b6336dce6ab1a6 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Wed, 8 Apr 2026 08:12:01 +0100
Subject: [PATCH 1/3] [lldb][test] Remove libc++ dependency in common
 libcxx-simulators header

After we made the test-suite mostly compile against system libc++ (in https://github.com/llvm/llvm-project/pull/190034), the `invalid-vector` test started failing on the macOS bots with:
```
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/include/c++/v1 -std=c++20 --driver-mode=g++ -MT main.o -MD -MP -MF main.d -c -o main.o /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp
[2026-04-07T00:09:44.764Z] /Users/ec2-user/jenkins/workspace/llvm.org/lldb-cmake/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx-simulators/invalid-vector/main.cpp:6:1: error: too few template parameters in template redeclaration
[2026-04-07T00:09:44.764Z]     6 | template <typename T> struct vector {
[2026-04-07T00:09:44.764Z]       | ^~~~~~~~~~~~~~~~~~~~~
[2026-04-07T00:09:44.764Z] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk/usr/include/c++/v1/iosfwd:167:1: note: previous template declaration is here
[2026-04-07T00:09:44.764Z]   167 | template <class _Tp, class _Alloc = allocator<_Tp> >
[2026-04-07T00:09:44.764Z]       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

This patch fixes the error by removing the STL header includes from the `compressed_pair.h` header. Presumably the `vector` forward declaration somehow gets pulled in via one of those headers (via `iosfwd`).

The `libcxx-simulators` tests are supposed to be STL-independent, so removing this dependency works towards that goal.

There's some `type_traits` that we use in this header that I haven't defined manually and we somehow pull those in. I'm not sure how (possibly through some headers the clang driver adds to a default command line invocation?). I'll fix those up as errors come up.
---
 .../make/libcxx-simulators-common/compressed_pair.h    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
index a1aa7e1a69f3e..e969d6317fc61 100644
--- a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
+++ b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
@@ -1,9 +1,6 @@
 #ifndef STD_LLDB_COMPRESSED_PAIR_H
 #define STD_LLDB_COMPRESSED_PAIR_H
 
-#include <type_traits>
-#include <utility> // for std::forward
-
 // COMPRESSED_PAIR_REV versions:
 // 0 -> Post-c88580c layout
 // 1 -> Post-27c83382d83dc layout
@@ -15,6 +12,13 @@
 namespace std {
 namespace __lldb {
 
+using size_t = decltype(sizeof(0));
+
+// Stripped down version of std::integral_constant
+template <class _Tp, _Tp __v> struct integral_constant {
+  static inline constexpr const _Tp value = __v;
+};
+
 #if __has_cpp_attribute(msvc::no_unique_address)
 #define _LLDB_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
 #elif __has_cpp_attribute(no_unique_address)

>From 9be73543dcf75119c807fdd5ec4feb6ca93e4aa5 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Wed, 8 Apr 2026 08:39:42 +0100
Subject: [PATCH 2/3] fixup! provide other type-traits

---
 .../compressed_pair.h                         | 25 ++++++++++++-------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
index e969d6317fc61..38387a1ba731e 100644
--- a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
+++ b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
@@ -12,6 +12,8 @@
 namespace std {
 namespace __lldb {
 
+// Type-traits definitions without pulling in STL headers.
+
 using size_t = decltype(sizeof(0));
 
 // Stripped down version of std::integral_constant
@@ -19,6 +21,16 @@ template <class _Tp, _Tp __v> struct integral_constant {
   static inline constexpr const _Tp value = __v;
 };
 
+template <class _Tp> constexpr _Tp &&forward(_Tp &&__t) noexcept {
+  return static_cast<_Tp &&>(__t);
+}
+
+template <class _Tp>
+struct is_empty : integral_constant<bool, __is_empty(_Tp)> {};
+
+template <class _Tp>
+struct is_final : public integral_constant<bool, __is_final(_Tp)> {};
+
 #if __has_cpp_attribute(msvc::no_unique_address)
 #define _LLDB_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
 #elif __has_cpp_attribute(no_unique_address)
@@ -35,15 +47,11 @@ template <class _Tp>
 inline const size_t __datasizeof_v =
     __builtin_offsetof(_FirstPaddingByte<_Tp>, __first_padding_byte_);
 
-template <class _Tp>
-struct __lldb_is_final : public integral_constant<bool, __is_final(_Tp)> {};
-
 // The legacy layout has been patched, see
 // https://github.com/llvm/llvm-project/pull/142516.
 #if COMPRESSED_PAIR_REV == 1
 template <class _ToPad> class __compressed_pair_padding {
-  char __padding_[((is_empty<_ToPad>::value &&
-                    !__lldb_is_final<_ToPad>::value) ||
+  char __padding_[((is_empty<_ToPad>::value && !is_final<_ToPad>::value) ||
                    is_reference<_ToPad>::value)
                       ? 0
                       : sizeof(_ToPad) - __datasizeof_v<_ToPad>];
@@ -51,7 +59,7 @@ template <class _ToPad> class __compressed_pair_padding {
 #elif COMPRESSED_PAIR_REV > 1 && COMPRESSED_PAIR_REV < 4
 template <class _ToPad>
 inline const bool __is_reference_or_unpadded_object =
-    (std::is_empty<_ToPad>::value && !__lldb_is_final<_ToPad>::value) ||
+    (is_empty<_ToPad>::value && !is_final<_ToPad>::value) ||
     sizeof(_ToPad) == __datasizeof_v<_ToPad>;
 
 template <class _Tp>
@@ -73,8 +81,7 @@ struct __value_init_tag {};
 struct __default_init_tag {};
 
 template <class _Tp, int _Idx,
-          bool _CanBeEmptyBase =
-              std::is_empty<_Tp>::value && !std::is_final<_Tp>::value>
+          bool _CanBeEmptyBase = is_empty<_Tp>::value && !is_final<_Tp>::value>
 struct __compressed_pair_elem {
   explicit __compressed_pair_elem(__default_init_tag) {}
   explicit __compressed_pair_elem(__value_init_tag) : __value_() {}
@@ -109,7 +116,7 @@ class __compressed_pair : private __compressed_pair_elem<_T1, 0>,
 
   template <class _U1, class _U2>
   explicit __compressed_pair(_U1 &&__t1, _U2 &&__t2)
-      : _Base1(std::forward<_U1>(__t1)), _Base2(std::forward<_U2>(__t2)) {}
+      : _Base1(forward<_U1>(__t1)), _Base2(forward<_U2>(__t2)) {}
 
   _T1 &first() { return static_cast<_Base1 &>(*this).__get(); }
 };

>From 32eb085453ea53b6e38579e47aa58a0bd8e4a97c Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Wed, 8 Apr 2026 08:48:40 +0100
Subject: [PATCH 3/3] fixup! fix std::forward

---
 .../make/libcxx-simulators-common/compressed_pair.h   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
index 38387a1ba731e..96a329a0b5460 100644
--- a/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
+++ b/lldb/packages/Python/lldbsuite/test/make/libcxx-simulators-common/compressed_pair.h
@@ -21,7 +21,16 @@ template <class _Tp, _Tp __v> struct integral_constant {
   static inline constexpr const _Tp value = __v;
 };
 
-template <class _Tp> constexpr _Tp &&forward(_Tp &&__t) noexcept {
+template <class _Tp>
+using remove_reference_t [[gnu::nodebug]] = __remove_reference_t(_Tp);
+
+template <class _Tp>
+constexpr _Tp &&forward(remove_reference_t<_Tp> &&__t) noexcept {
+  return static_cast<_Tp &&>(__t);
+}
+
+template <class _Tp>
+constexpr _Tp &&forward(remove_reference_t<_Tp> &__t) noexcept {
   return static_cast<_Tp &&>(__t);
 }
 



More information about the lldb-commits mailing list