Skip to content

Commit 888e246

Browse files
committed
[libc++] Fix LLVM 22 TODOs
1 parent d30bd27 commit 888e246

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+237
-473
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ set(files
316316
__concepts/invocable.h
317317
__concepts/movable.h
318318
__concepts/predicate.h
319+
__concepts/referenceable.h
319320
__concepts/regular.h
320321
__concepts/relation.h
321322
__concepts/same_as.h
@@ -855,7 +856,6 @@ set(files
855856
__type_traits/is_primary_template.h
856857
__type_traits/is_reference.h
857858
__type_traits/is_reference_wrapper.h
858-
__type_traits/is_referenceable.h
859859
__type_traits/is_replaceable.h
860860
__type_traits/is_same.h
861861
__type_traits/is_scalar.h

libcxx/include/__type_traits/is_referenceable.h renamed to libcxx/include/__concepts/referenceable.h

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,27 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
#ifndef _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
10-
#define _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
9+
#ifndef _LIBCPP___CONCEPTS_REFERENCEABLE_H
10+
#define _LIBCPP___CONCEPTS_REFERENCEABLE_H
1111

1212
#include <__config>
13-
#include <__type_traits/void_t.h>
1413

1514
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1615
# pragma GCC system_header
1716
#endif
1817

19-
_LIBCPP_BEGIN_NAMESPACE_STD
18+
#if _LIBCPP_STD_VER >= 20
2019

21-
template <class _Tp, class = void>
22-
inline const bool __is_referenceable_v = false;
20+
_LIBCPP_BEGIN_NAMESPACE_STD
2321

2422
template <class _Tp>
25-
inline const bool __is_referenceable_v<_Tp, __void_t<_Tp&> > = true;
23+
using __referenceable_impl _LIBCPP_NODEBUG = _Tp&;
2624

27-
#if _LIBCPP_STD_VER >= 20
2825
template <class _Tp>
29-
concept __referenceable = __is_referenceable_v<_Tp>;
30-
#endif
26+
concept __referenceable = requires { typename __referenceable_impl<_Tp>; };
3127

3228
_LIBCPP_END_NAMESPACE_STD
3329

34-
#endif // _LIBCPP___TYPE_TRAITS_IS_REFERENCEABLE_H
30+
#endif
31+
32+
#endif // _LIBCPP___CONCEPTS_REFERENCEABLE_H

libcxx/include/__config

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,11 +1050,6 @@ typedef __char32_t char32_t;
10501050
# define _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(_ClassName) static_assert(true, "")
10511051
# endif
10521052

1053-
// TODO(LLVM 22): Remove the workaround
1054-
# if defined(__OBJC__) && (!defined(_LIBCPP_CLANG_VER) || _LIBCPP_CLANG_VER < 2001)
1055-
# define _LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS
1056-
# endif
1057-
10581053
# define _PSTL_PRAGMA(x) _Pragma(#x)
10591054

10601055
// Enable SIMD for compilers that support OpenMP 4.0
@@ -1255,14 +1250,6 @@ typedef __char32_t char32_t;
12551250
# define _LIBCPP_DIAGNOSE_NULLPTR
12561251
# endif
12571252

1258-
// TODO(LLVM 22): Remove this macro once LLVM19 support ends. __cpp_explicit_this_parameter has been set in LLVM20.
1259-
// Clang-18 has support for deducing this, but it does not set the FTM.
1260-
# if defined(__cpp_explicit_this_parameter) || (defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1800)
1261-
# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 1
1262-
# else
1263-
# define _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER 0
1264-
# endif
1265-
12661253
#endif // __cplusplus
12671254

12681255
#endif // _LIBCPP___CONFIG

libcxx/include/__configuration/abi.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,6 @@
6161
// According to the Standard, `bitset::operator[] const` returns bool
6262
# define _LIBCPP_ABI_BITSET_VECTOR_BOOL_CONST_SUBSCRIPT_RETURN_BOOL
6363

64-
// In LLVM 20, we've changed to take these ABI breaks unconditionally. These flags only exist in case someone is running
65-
// into the static_asserts we added to catch the ABI break and don't care that it is one.
66-
// TODO(LLVM 22): Remove these flags
67-
# define _LIBCPP_ABI_LIST_REMOVE_NODE_POINTER_UB
68-
# define _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
69-
# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
70-
# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
71-
7264
// These flags are documented in ABIGuarantees.rst
7365
# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
7466
# define _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON

libcxx/include/__format/format_arg.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ _LIBCPP_HIDE_FROM_ABI decltype(auto) __visit_format_arg(_Visitor&& __vis, basic_
149149
__libcpp_unreachable();
150150
}
151151

152-
# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
152+
# if _LIBCPP_STD_VER >= 26
153153

154154
template <class _Rp, class _Visitor, class _Context>
155155
_LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
@@ -200,7 +200,7 @@ _LIBCPP_HIDE_FROM_ABI _Rp __visit_format_arg(_Visitor&& __vis, basic_format_arg<
200200
__libcpp_unreachable();
201201
}
202202

203-
# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
203+
# endif // _LIBCPP_STD_VER >= 26
204204

205205
/// Contains the values used in basic_format_arg.
206206
///
@@ -285,7 +285,7 @@ class _LIBCPP_NO_SPECIALIZATIONS basic_format_arg {
285285

286286
_LIBCPP_HIDE_FROM_ABI explicit operator bool() const noexcept { return __type_ != __format::__arg_t::__none; }
287287

288-
# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
288+
# if _LIBCPP_STD_VER >= 26
289289

290290
// This function is user facing, so it must wrap the non-standard types of
291291
// the "variant" in a handle to stay conforming. See __arg_t for more details.
@@ -329,7 +329,7 @@ class _LIBCPP_NO_SPECIALIZATIONS basic_format_arg {
329329
}
330330
}
331331

332-
# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
332+
# endif // _LIBCPP_STD_VER >= 26
333333

334334
private:
335335
using char_type = typename _Context::char_type;
@@ -371,11 +371,8 @@ class basic_format_arg<_Context>::handle {
371371
// This function is user facing, so it must wrap the non-standard types of
372372
// the "variant" in a handle to stay conforming. See __arg_t for more details.
373373
template <class _Visitor, class _Context>
374-
# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
375-
_LIBCPP_DEPRECATED_IN_CXX26
376-
# endif
377-
_LIBCPP_HIDE_FROM_ABI decltype(auto)
378-
visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
374+
_LIBCPP_DEPRECATED_IN_CXX26 _LIBCPP_HIDE_FROM_ABI decltype(auto)
375+
visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg) {
379376
switch (__arg.__type_) {
380377
# if _LIBCPP_HAS_INT128
381378
case __format::__arg_t::__i128: {
@@ -387,7 +384,7 @@ _LIBCPP_DEPRECATED_IN_CXX26
387384
typename __basic_format_arg_value<_Context>::__handle __h{__arg.__value_.__u128_};
388385
return std::invoke(std::forward<_Visitor>(__vis), typename basic_format_arg<_Context>::handle{__h});
389386
}
390-
# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
387+
# endif // _LIBCPP_HAS_INT128
391388
default:
392389
return std::__visit_format_arg(std::forward<_Visitor>(__vis), __arg);
393390
}

libcxx/include/__format/format_context.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,13 @@ class basic_format_context<typename __format::__retarget_buffer<_CharT>::__itera
175175
__format::__determine_arg_t<basic_format_context, decltype(__arg)>(),
176176
__basic_format_arg_value<basic_format_context>(__arg)};
177177
};
178-
# if _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
178+
# if _LIBCPP_STD_VER >= 26
179179
return static_cast<_Context*>(__c)->arg(__id).visit(std::move(__visitor));
180180
# else
181181
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
182182
return std::visit_format_arg(std::move(__visitor), static_cast<_Context*>(__c)->arg(__id));
183183
_LIBCPP_SUPPRESS_DEPRECATED_POP
184-
# endif // _LIBCPP_STD_VER >= 26 && _LIBCPP_HAS_EXPLICIT_THIS_PARAMETER
184+
# endif // _LIBCPP_STD_VER >= 26
185185
}) {
186186
}
187187

libcxx/include/__hash_table

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,6 @@ struct __hash_node_base {
8383
typedef _NodePtr __node_pointer;
8484
typedef __node_base_pointer __next_pointer;
8585

86-
// TODO(LLVM 22): Remove this check
87-
#ifndef _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
88-
static_assert(sizeof(__node_base_pointer) == sizeof(__node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) ==
89-
_LIBCPP_ALIGNOF(__node_pointer),
90-
"It looks like you are using std::__hash_table (an implementation detail for the unordered containers) "
91-
"with a fancy pointer type that thas a different representation depending on whether it points to a "
92-
"__hash_table base pointer or a __hash_table node pointer (both of which are implementation details of "
93-
"the standard library). This means that your ABI is being broken between LLVM 19 and LLVM 20. If you "
94-
"don't care about your ABI being broken, define the _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB macro to "
95-
"silence this diagnostic.");
96-
#endif
97-
9886
__next_pointer __next_;
9987

10088
_LIBCPP_HIDE_FROM_ABI __next_pointer __ptr() _NOEXCEPT {

libcxx/include/__iterator/common_iterator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <__concepts/copyable.h>
1818
#include <__concepts/derived_from.h>
1919
#include <__concepts/equality_comparable.h>
20+
#include <__concepts/referenceable.h>
2021
#include <__concepts/same_as.h>
2122
#include <__config>
2223
#include <__iterator/concepts.h>
@@ -28,7 +29,6 @@
2829
#include <__memory/addressof.h>
2930
#include <__type_traits/conditional.h>
3031
#include <__type_traits/is_pointer.h>
31-
#include <__type_traits/is_referenceable.h>
3232
#include <__utility/declval.h>
3333
#include <variant>
3434

libcxx/include/__iterator/concepts.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <__concepts/invocable.h>
2121
#include <__concepts/movable.h>
2222
#include <__concepts/predicate.h>
23+
#include <__concepts/referenceable.h>
2324
#include <__concepts/regular.h>
2425
#include <__concepts/relation.h>
2526
#include <__concepts/same_as.h>
@@ -40,7 +41,6 @@
4041
#include <__type_traits/is_pointer.h>
4142
#include <__type_traits/is_primary_template.h>
4243
#include <__type_traits/is_reference.h>
43-
#include <__type_traits/is_referenceable.h>
4444
#include <__type_traits/is_valid_expansion.h>
4545
#include <__type_traits/remove_cv.h>
4646
#include <__type_traits/remove_cvref.h>
@@ -117,15 +117,12 @@ template <class _Tp>
117117
concept __signed_integer_like = signed_integral<_Tp>;
118118

119119
template <class _Ip>
120-
concept weakly_incrementable =
121-
// TODO: remove this once the clang bug is fixed (https://llvm.org/PR48173).
122-
!same_as<_Ip, bool> && // Currently, clang does not handle bool correctly.
123-
movable<_Ip> && requires(_Ip __i) {
124-
typename iter_difference_t<_Ip>;
125-
requires __signed_integer_like<iter_difference_t<_Ip>>;
126-
{ ++__i } -> same_as<_Ip&>; // not required to be equality-preserving
127-
__i++; // not required to be equality-preserving
128-
};
120+
concept weakly_incrementable = movable<_Ip> && requires(_Ip __i) {
121+
typename iter_difference_t<_Ip>;
122+
requires __signed_integer_like<iter_difference_t<_Ip>>;
123+
{ ++__i } -> same_as<_Ip&>; // not required to be equality-preserving
124+
__i++; // not required to be equality-preserving
125+
};
129126

130127
// [iterator.concept.inc]
131128
template <class _Ip>

libcxx/include/__iterator/iter_move.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
#define _LIBCPP___ITERATOR_ITER_MOVE_H
1212

1313
#include <__concepts/class_or_enum.h>
14+
#include <__concepts/referenceable.h>
1415
#include <__config>
1516
#include <__iterator/iterator_traits.h>
1617
#include <__type_traits/is_reference.h>
17-
#include <__type_traits/is_referenceable.h>
1818
#include <__type_traits/remove_cvref.h>
1919
#include <__utility/declval.h>
2020
#include <__utility/forward.h>

0 commit comments

Comments
 (0)