Skip to content

Commit

Permalink
Cleanup compiler bug workarounds and their comments (#4362)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej authored Feb 6, 2024
1 parent 3688df0 commit f49ffd2
Show file tree
Hide file tree
Showing 71 changed files with 149 additions and 146 deletions.
2 changes: 1 addition & 1 deletion stl/inc/__msvc_bit_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ _NODISCARD int _Checked_arm_arm64_countl_zero(const _Ty _Val) noexcept {
} else {
return static_cast<int>(_CountLeadingZeros64(_Val));
}
#endif // TRANSITION, GH-1586
#endif // ^^^ no workaround ^^^
}
#endif // defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC) || defined(_M_HYBRID_X86_ARM64)
#endif // _HAS_COUNTL_ZERO_INTRINSICS
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/__msvc_iter_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ concept weakly_incrementable = movable<_Ty>
}
#ifdef __clang__ // TRANSITION, LLVM-48173
&& !same_as<_Ty, bool>
#endif // TRANSITION, LLVM-48173
#endif // ^^^ workaround ^^^
;

_EXPORT_STD template <class _It>
Expand Down
8 changes: 4 additions & 4 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -2756,7 +2756,7 @@ namespace chrono {
_EXPORT_STD template <class _Duration>
using file_time = time_point<file_clock, _Duration>;
} // namespace chrono
#endif // ^^^ _HAS_CXX20
#endif // ^^^ _HAS_CXX20 ^^^

#if _HAS_CXX17
namespace filesystem {
Expand Down Expand Up @@ -2810,10 +2810,10 @@ namespace filesystem {

return _File_time;
}
#endif // ^^^ _HAS_CXX20
#endif // ^^^ _HAS_CXX20 ^^^
};
} // namespace filesystem
#endif // ^^^ _HAS_CXX17
#endif // ^^^ _HAS_CXX17 ^^^

#if _HAS_CXX20
namespace chrono {
Expand Down Expand Up @@ -5438,7 +5438,7 @@ namespace chrono {
continue;
}
}
#endif // defined(_MSVC_EXECUTION_CHARACTER_SET) && _MSVC_EXECUTION_CHARACTER_SET == 65001
#endif // ^^^ no workaround ^^^

_CharT _Fmt_str[4];
_Stream << _STD put_time<_CharT>(&_Time, _Fmt_string(_Spec, _Fmt_str));
Expand Down
4 changes: 2 additions & 2 deletions stl/inc/expected
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ public:
constexpr ~expected()
#ifndef __clang__ // TRANSITION, LLVM-59854
noexcept
#endif // !defined(__clang__)
#endif // ^^^ no workaround ^^^
{
if (_Has_value) {
if constexpr (!is_trivially_destructible_v<_Ty>) {
Expand Down Expand Up @@ -1300,7 +1300,7 @@ public:
constexpr ~expected()
#ifndef __clang__ // TRANSITION, LLVM-59854
noexcept
#endif // !defined(__clang__)
#endif // ^^^ no workaround ^^^
{
if (!_Has_value) {
_Unexpected.~_Err();
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/filesystem
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,7 @@ namespace filesystem {
_EXPORT_STD using file_time_type = _CHRONO time_point<_CHRONO file_clock>;
#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
using file_time_type = _CHRONO time_point<filesystem::_File_time_clock>;
#endif // ^^^ !_HAS_CXX20
#endif // ^^^ !_HAS_CXX20 ^^^

struct _Dir_enum_impl;
struct _Recursive_dir_enum_impl;
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/format
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ public:
__std_fs_convert_narrow_to_wide(__std_code_page{_MSVC_EXECUTION_CHARACTER_SET}, _First, 1, &_Wide, 1);
_Val = _Wide;
return {_First + 1, _Res._Len != 0};
#endif // defined(_MSVC_EXECUTION_CHARACTER_SET)
#endif // ^^^ no workaround ^^^
} else {
if (*_First == '\0') {
_Val = U'\0';
Expand Down
6 changes: 3 additions & 3 deletions stl/inc/ranges
Original file line number Diff line number Diff line change
Expand Up @@ -1167,14 +1167,14 @@ namespace ranges {
static constexpr bool _Nothrow_minus_equal<_Left, _Right> = true;

public:
#endif // TRANSITION, DevCom-1347136
#endif // ^^^ workaround ^^^

constexpr _Ioterator& operator+=(const difference_type _Off)
#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-1347136
noexcept(noexcept(_Current += _Off)) /* strengthened */
#else // ^^^ no workaround / workaround vvv
noexcept(_Nothrow_plus_equal<_Wi, difference_type>) /* strengthened */
#endif // TRANSITION, DevCom-1347136
#endif // ^^^ workaround ^^^
requires _Advanceable<_Wi>
{
if constexpr (_Integer_like<_Wi>) {
Expand All @@ -1198,7 +1198,7 @@ namespace ranges {
noexcept(noexcept(_Current -= _Off)) /* strengthened */
#else // ^^^ no workaround / workaround vvv
noexcept(_Nothrow_minus_equal<_Wi, difference_type>) /* strengthened */
#endif // TRANSITION, DevCom-1347136
#endif // ^^^ workaround ^^^
requires _Advanceable<_Wi>
{
if constexpr (_Integer_like<_Wi>) {
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ concept _Can_construct_from_tuple_like =
&& (tuple_size_v<_Tuple> != 1
|| (!is_convertible_v<_TupleLike, tuple_element_t<0, _Tuple>>
&& !is_constructible_v<tuple_element_t<0, _Tuple>, _TupleLike>) );
#endif // defined(__clang__) || defined(__EDG__)
#endif // ^^^ workaround ^^^

template <class _TTuple, class _UTuple, class _Indices = make_index_sequence<tuple_size_v<_UTuple>>>
struct _Three_way_comparison_result_with_tuple_like {};
Expand Down
12 changes: 6 additions & 6 deletions stl/inc/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ struct is_convertible : bool_constant<__is_convertible_to(_From, _To)> {
_EXPORT_STD template <class _From, class _To>
_INLINE_VAR constexpr bool is_convertible_v = __is_convertible_to(_From, _To);

#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-1627396
#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-1627396
template <class _Ty>
struct is_convertible<_Ty&, volatile _Ty&> : true_type {};

Expand All @@ -351,7 +351,7 @@ _INLINE_VAR constexpr bool is_convertible_v<_Ty&, const volatile _Ty&> = true;

template <class _Ty>
_INLINE_VAR constexpr bool is_convertible_v<volatile _Ty&, const volatile _Ty&> = true;
#endif // ^^^ workaround
#endif // ^^^ workaround ^^^

_EXPORT_STD template <class _Ty>
struct is_enum : bool_constant<__is_enum(_Ty)> {}; // determine whether _Ty is an enumerated type
Expand Down Expand Up @@ -700,7 +700,7 @@ struct is_trivial : bool_constant<__is_trivial(_Ty)> {}; // determine whether _T

_EXPORT_STD template <class _Ty>
_INLINE_VAR constexpr bool is_trivial_v = __is_trivial(_Ty);
#endif // TRANSITION
#endif // ^^^ no workaround ^^^

_EXPORT_STD template <class _Ty>
struct is_trivially_copyable : bool_constant<__is_trivially_copyable(_Ty)> {
Expand Down Expand Up @@ -1409,7 +1409,7 @@ struct _Add_qualifiers<_Ty1&&> {
using _Apply = add_rvalue_reference_t<_Copy_cv<_Ty1, _Ty2>>;
};

#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-10095944
#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-10095944
template <class _Ty1, class _Ty2>
using _Cond_res_if_right = // N4950 [meta.trans.other]/2.4
decltype(false ? _Returns_exactly<_Ty1>() : _Returns_exactly<_Ty2>());
Expand Down Expand Up @@ -1953,7 +1953,7 @@ _EXPORT_STD template <class _ClassTy1, class _ClassTy2, class _MemberTy1, class
_NODISCARD constexpr bool is_corresponding_member(_MemberTy1 _ClassTy1::*_Pm1, _MemberTy2 _ClassTy2::*_Pm2) noexcept {
return __is_corresponding_member(_ClassTy1, _ClassTy2, _Pm1, _Pm2);
}
#endif // !defined(__clang__)
#endif // ^^^ no workaround ^^^
#endif // _HAS_CXX20

template <class _Ty>
Expand Down Expand Up @@ -2239,7 +2239,7 @@ struct _Is_trivially_swappable : bool_constant<_Is_trivially_swappable_v<_Ty>> {
#if _HAS_CXX20
_EXPORT_STD template <class _From, class _To>
concept convertible_to =
#if !defined(__EDG__) && !defined(__clang__) // TRANSITION, DevCom-1627396
#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-1627396
is_convertible_v<_From, _To>
#else // ^^^ workaround / no workaround vvv
__is_convertible_to(_From, _To)
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/utility
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ template <class _PairLike, class _Ty1, class _Ty2>
concept _Can_construct_from_pair_like = _Pair_like<_PairLike> && !_Is_subrange_v<remove_cvref_t<_PairLike>>
&& is_constructible_v<_Ty1, decltype(_STD get<0>(_STD declval<_PairLike>()))>
&& is_constructible_v<_Ty2, decltype(_STD get<1>(_STD declval<_PairLike>()))>;
#endif // defined(__clang__) || defined(__EDG__)
#endif // ^^^ workaround ^^^
#endif // _HAS_CXX23
#endif // _HAS_CXX20

Expand Down
10 changes: 6 additions & 4 deletions stl/inc/variant
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ public:
return _STD move(_Head)._Item;
}
};
#endif // defined(__cplusplus_winrt)
#endif // ^^^ workaround ^^^

template <size_t _Idx, class _Storage>
_NODISCARD constexpr decltype(auto) _Variant_raw_get(_Storage&& _Obj) noexcept {
Expand Down Expand Up @@ -1088,7 +1088,7 @@ public:
#ifdef __clang__ // TRANSITION, LLVM-45398
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-lambda-capture"
#endif // TRANSITION, LLVM-45398
#endif // ^^^ workaround ^^^
_CONSTEXPR20 void swap(variant& _That) noexcept(
conjunction_v<is_nothrow_move_constructible<_Types>..., is_nothrow_swappable<_Types>...>) {
// exchange the contained values if *this and _That hold the same alternative, otherwise exchange the values of
Expand Down Expand Up @@ -1149,7 +1149,7 @@ public:
}
#ifdef __clang__ // TRANSITION, LLVM-45398
#pragma clang diagnostic pop
#endif // TRANSITION, LLVM-45398
#endif // ^^^ workaround ^^^

private:
template <size_t _Idx, class... _ArgTypes>
Expand Down Expand Up @@ -1425,7 +1425,9 @@ struct _Variant_dispatcher<index_sequence<_Is...>> {
template <class _Ret, class _Callable, class... _Types, bool _Any_valueless = ((_Is == 0) || ...)>
_NODISCARD static constexpr _Ret _Dispatch2(_Callable&& _Obj, _Types&&... _Args) {
if constexpr (_Any_valueless) {
((void) _Args, ...); // TRANSITION, VSO-1513409
#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, VSO-1513409
((void) _Args, ...);
#endif // ^^^ workaround ^^^
_STD _Throw_bad_variant_access();
}
#if _HAS_CXX20
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/xstring
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ template <>
struct char_traits<unsigned short> : _WChar_traits<unsigned short> {};
#endif // defined(_CRTBLD)

#if defined(__cpp_char8_t) && !defined(__EDG__) && !defined(__clang__)
#if defined(__cpp_char8_t) && !defined(__clang__) && !defined(__EDG__)
#define _HAS_U8_INTRINSICS 1
#else // ^^^ Use intrinsics for char8_t / don't use said intrinsics vvv
#define _HAS_U8_INTRINSICS 0
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/xutility
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ _EXPORT_STD template <class _Ty, class... _Types,
// per LWG-3888
_EXPORT_STD template <class _Ty, class... _Types,
void_t<decltype(::new(static_cast<void*>(_STD declval<_Ty*>())) _Ty(_STD declval<_Types>()...))>* = nullptr>
#endif // TRANSITION, DevCom-1691516
#endif // ^^^ workaround ^^^
constexpr _Ty* construct_at(_Ty* const _Location, _Types&&... _Args) noexcept(
noexcept(::new(static_cast<void*>(_Location)) _Ty(_STD forward<_Types>(_Args)...))) /* strengthened */ {
_MSVC_CONSTEXPR return ::new (static_cast<void*>(_Location)) _Ty(_STD forward<_Types>(_Args)...);
Expand Down
6 changes: 3 additions & 3 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1758,13 +1758,13 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect

#ifndef __clang__ // TRANSITION, LLVM-48860
#define __cpp_lib_is_layout_compatible 201907L
#endif // !defined(__clang__)
#endif // ^^^ no workaround ^^^

#define __cpp_lib_is_nothrow_convertible 201806L

#ifndef __clang__ // TRANSITION, LLVM-48860
#define __cpp_lib_is_pointer_interconvertible 201907L
#endif // !defined(__clang__)
#endif // ^^^ no workaround ^^^

#define __cpp_lib_jthread 201911L
#define __cpp_lib_latch 201907L
Expand All @@ -1773,7 +1773,7 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect

#if !defined(__clang__) && !defined(__EDG__) // TRANSITION, Clang and EDG support for modules
#define __cpp_lib_modules 202207L
#endif // !defined(__clang__) && !defined(__EDG__)
#endif // ^^^ no workaround ^^^

#define __cpp_lib_move_iterator_concept 202207L
#define __cpp_lib_polymorphic_allocator 201902L
Expand Down
4 changes: 2 additions & 2 deletions stl/src/atomic_wait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ _Smtx_t* __stdcall __std_atomic_get_mutex(const void* const _Key) noexcept {
}

return __std_atomic_compare_exchange_128_fallback(_Destination, _ExchangeHigh, _ExchangeLow, _ComparandResult);
#endif // ^^^ _STD_ATOMIC_ALWAYS_USE_CMPXCHG16B == 0
#endif // ^^^ _STD_ATOMIC_ALWAYS_USE_CMPXCHG16B == 0 ^^^
}

[[nodiscard]] char __stdcall __std_atomic_has_cmpxchg16b() noexcept {
Expand All @@ -432,6 +432,6 @@ _Smtx_t* __stdcall __std_atomic_get_mutex(const void* const _Key) noexcept {
}

return _Value;
#endif // ^^^ _STD_ATOMIC_ALWAYS_USE_CMPXCHG16B == 0
#endif // ^^^ _STD_ATOMIC_ALWAYS_USE_CMPXCHG16B == 0 ^^^
}
} // extern "C"
2 changes: 1 addition & 1 deletion tests/std/include/test_atomic_wait.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,5 @@ inline void test_atomic_wait() {
test_pad_bits<with_padding_bits<16>>(waiting_duration);
test_pad_bits<with_padding_bits<32>>(waiting_duration);
#endif // ^^^ !ARM ^^^
#endif // __clang__, TRANSITION, LLVM-46685
#endif // ^^^ no workaround ^^^
}
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ struct use_async_in_a_global_tester {
};

use_async_in_a_global_tester use_async_in_a_global_instance;
#endif // _M_CEE
#endif // ^^^ no workaround ^^^

int main() {
test_DevDiv_235721();
Expand Down
2 changes: 1 addition & 1 deletion tests/std/tests/Dev11_0535636_functional_overhaul/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ _CONSTEXPR20 bool test_mem_fn() {
assert(mem_fn(&Widget::unary_lv)(&w, 6) == 1061);

assert(mem_fn(&Widget::unary_rv)(move(w), 7) == 1404);
#endif // _M_CEE
#endif // ^^^ no workaround ^^^

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,4 @@ void test_adl_proof_basic_const_iterator_comparison() {
}
#endif // _HAS_CXX23

#endif // _M_CEE
#endif // ^^^ no workaround ^^^
2 changes: 1 addition & 1 deletion tests/std/tests/GH_000431_equal_family/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ void test_algorithms(EqualFn equal_fn) {
assert(!equal_fn(begin(arr6), end(arr6), begin(arr7), end(arr7), equal_to<>{}));
assert(!equal_fn(begin(arr6), end(arr6), begin(arr7), end(arr7), equal_to<mfn_ptr2>{}));
}
#endif // _M_CEE_PURE
#endif // ^^^ no workaround ^^^

{ // Test vector
vector<int> arr1 = {3, 6, 4, 7, 3};
Expand Down
2 changes: 1 addition & 1 deletion tests/std/tests/GH_000940_missing_valarray_copy/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ int main() {

#if defined(__clang__) || defined(__EDG__) // TRANSITION, DevCom-10416247
STATIC_ASSERT(std::is_nothrow_default_constructible_v<std::gslice>); // strengthened
#endif // defined(__clang__) || defined(__EDG__)
#endif // ^^^ no workaround ^^^
std::gslice gs{};
STATIC_ASSERT(noexcept(gs.start())); // strengthened
}
Original file line number Diff line number Diff line change
Expand Up @@ -731,4 +731,4 @@ void test_ranges_non_projected_algorithms() {
#endif // _HAS_CXX23
}
#endif // _HAS_CXX20
#endif // _M_CEE
#endif // ^^^ no workaround ^^^
2 changes: 1 addition & 1 deletion tests/std/tests/GH_002030_asan_annotate_string/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,7 @@ void run_tests() {
test_sstream<Alloc>();
#if !(defined(__clang__) && defined(_M_IX86)) // TRANSITION, LLVM-54804
test_exceptions<Alloc>();
#endif // !(defined(__clang__) && defined(_M_IX86))
#endif // ^^^ no workaround ^^^
}

template <class CharType, template <class, class, class> class Alloc>
Expand Down
5 changes: 2 additions & 3 deletions tests/std/tests/GH_002030_asan_annotate_vector/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,15 +1019,14 @@ int main() {
run_allocator_matrix<non_trivial_can_throw>();
run_allocator_matrix<non_trivial_cannot_throw>();

// TRANSITION, LLVM-35365
#ifndef __clang__
#ifndef __clang__ // TRANSITION, LLVM-35365
test_push_back_throw();
test_emplace_back_throw();
test_insert_range_throw();
test_insert_throw();
test_emplace_throw();
test_resize_throw();
test_insert_n_throw();
#endif // !__clang__
#endif // ^^^ no workaround ^^^
#endif // ASan instrumentation enabled
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ void run_tests() {
assert(failures == 7);
assert(succeeded != -1 && f.get().x == succeeded);
}
#endif // _M_CEE
#endif // ^^^ no workaround ^^^

{
(void) std::async(std::launch::async, [] { return T(16); });
Expand Down
2 changes: 1 addition & 1 deletion tests/std/tests/GH_002620_construct_at_workaround/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ int main() {
// GH-2620: <xutility>: SFINAE constraint on construct_at prevents emplacing immovable objects with copy elision
#ifndef __EDG__ // TRANSITION, DevCom-10000388
construct_at(&u.s, copy_elider{});
#endif // TRANSITION, DevCom-10000388
#endif // ^^^ no workaround ^^^
}
8 changes: 5 additions & 3 deletions tests/std/tests/GH_003022_substr_allocator/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,13 @@ CONSTEXPR20 bool test_substr_allocator() {
}
};

#if _HAS_CXX23 && !defined(__EDG__) // TRANSITION, VSO-1601179
#if _HAS_CXX23
#ifndef __EDG__ // TRANSITION, VSO-1601179
static_assert(!is_constructible_v<string_type, ambiguator&, size_t, size_t>, "This should be ambiguous");
#else // _HAS_CXX23 && !defined(__EDG__)
#endif // ^^^ no workaround ^^^
#else // ^^^ _HAS_CXX23 / !_HAS_CXX23 vvv
static_assert(is_constructible_v<string_type, ambiguator&, size_t, size_t>, "This should be unambiguous");
#endif // _HAS_CXX23 && !defined(__EDG__)
#endif // ^^^ !_HAS_CXX23 ^^^

return true;
}
Expand Down
Loading

0 comments on commit f49ffd2

Please sign in to comment.