From c4d14fcc01fc9fc5c2073a851ea5c1de81291831 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 27 Feb 2023 10:31:43 -0800 Subject: [PATCH 1/9] Add braces to an if-statement in ppltasks.cpp. --- stl/src/ppltasks.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stl/src/ppltasks.cpp b/stl/src/ppltasks.cpp index de405dd6cfb..e1d4375f473 100644 --- a/stl/src/ppltasks.cpp +++ b/stl/src/ppltasks.cpp @@ -39,7 +39,9 @@ namespace Concurrency { #if (defined(_M_IX86) || defined(_M_X64)) && !defined(_CRT_APP) if (IsProcessorFeaturePresent(PF_FASTFAIL_AVAILABLE)) #endif + { __fastfail(FAST_FAIL_INVALID_ARG); + } std::terminate(); } From 7f9a33336c7225712f976336fb6ed97592642cdc Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 27 Feb 2023 10:50:40 -0800 Subject: [PATCH 2/9] Drop `this->` when calling `Base::meow()`. --- stl/inc/memory_resource | 6 +++--- stl/inc/regex | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stl/inc/memory_resource b/stl/inc/memory_resource index 62b0f428dbf..b0527b5ec90 100644 --- a/stl/inc/memory_resource +++ b/stl/inc/memory_resource @@ -572,18 +572,18 @@ namespace pmr { void release() noexcept /* strengthened */ { lock_guard _Guard{_Mtx}; - this->unsynchronized_pool_resource::release(); + unsynchronized_pool_resource::release(); } protected: void* do_allocate(const size_t _Bytes, const size_t _Align) override { lock_guard _Guard{_Mtx}; - return this->unsynchronized_pool_resource::do_allocate(_Bytes, _Align); + return unsynchronized_pool_resource::do_allocate(_Bytes, _Align); } void do_deallocate(void* const _Ptr, const size_t _Bytes, const size_t _Align) override { lock_guard _Guard{_Mtx}; - this->unsynchronized_pool_resource::do_deallocate(_Ptr, _Bytes, _Align); + unsynchronized_pool_resource::do_deallocate(_Ptr, _Bytes, _Align); } private: diff --git a/stl/inc/regex b/stl/inc/regex index dc5c484cf54..ac0515c387e 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -628,7 +628,7 @@ public: } void swap(sub_match& _Other) noexcept(_Is_nothrow_swappable<_BidIt>::value) { - this->_Mybase::swap(_Other); + _Mybase::swap(_Other); _STD swap(matched, _Other.matched); } From ca2848dbaceaa3a7613627934af25ebd74501717 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 27 Feb 2023 12:20:24 -0800 Subject: [PATCH 3/9] Use _STL_INTERNAL_STATIC_ASSERT in invoke. --- stl/inc/type_traits | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/type_traits b/stl/inc/type_traits index 463db6fd760..ea33e6f20fa 100644 --- a/stl/inc/type_traits +++ b/stl/inc/type_traits @@ -1597,7 +1597,7 @@ _CONSTEXPR17 auto invoke(_Callable&& _Obj, _Ty1&& _Arg1, _Types2&&... _Args2) no } else if constexpr (_Invoker1<_Callable, _Ty1>::_Strategy == _Invoker_strategy::_Pmd_refwrap) { return _Arg1.get().*_Obj; } else { - static_assert(_Invoker1<_Callable, _Ty1>::_Strategy == _Invoker_strategy::_Pmd_pointer, "bug in invoke"); + _STL_INTERNAL_STATIC_ASSERT(_Invoker1<_Callable, _Ty1>::_Strategy == _Invoker_strategy::_Pmd_pointer); return (*static_cast<_Ty1&&>(_Arg1)).*_Obj; } } From a992318adb8b3ca0196e4a6efd4f05459225b22d Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Mon, 27 Feb 2023 13:17:08 -0800 Subject: [PATCH 4/9] Move `#include _STL_INTRIN_HEADER` to the end so it doesn't interrupt sorting. --- stl/inc/__msvc_int128.hpp | 3 ++- stl/inc/bit | 3 ++- stl/inc/charconv | 3 ++- stl/inc/limits | 3 ++- stl/inc/xatomic.h | 3 ++- stl/inc/xbit_ops.h | 1 + 6 files changed, 11 insertions(+), 5 deletions(-) diff --git a/stl/inc/__msvc_int128.hpp b/stl/inc/__msvc_int128.hpp index 56b0b4371e6..0018edbf674 100644 --- a/stl/inc/__msvc_int128.hpp +++ b/stl/inc/__msvc_int128.hpp @@ -10,10 +10,11 @@ #include #if _STL_COMPILER_PREPROCESSOR #include -#include _STL_INTRIN_HEADER #include #include +#include _STL_INTRIN_HEADER + #if _HAS_CXX20 #include #include diff --git a/stl/inc/bit b/stl/inc/bit index b4ecd911d05..cf2e52705b8 100644 --- a/stl/inc/bit +++ b/stl/inc/bit @@ -12,11 +12,12 @@ _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++20 or later."); #else // ^^^ !_HAS_CXX20 / _HAS_CXX20 vvv -#include _STL_INTRIN_HEADER #include #include #include +#include _STL_INTRIN_HEADER + #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) diff --git a/stl/inc/charconv b/stl/inc/charconv index c26313fb9b3..4393c7dd217 100644 --- a/stl/inc/charconv +++ b/stl/inc/charconv @@ -13,13 +13,14 @@ _EMIT_STL_WARNING(STL4038, "The contents of are available only with C++17 or later."); #else // ^^^ !_HAS_CXX17 / _HAS_CXX17 vvv #include -#include _STL_INTRIN_HEADER #include #include #include #include #include +#include _STL_INTRIN_HEADER + #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) diff --git a/stl/inc/limits b/stl/inc/limits index 01e0f119c50..3617866926e 100644 --- a/stl/inc/limits +++ b/stl/inc/limits @@ -11,10 +11,11 @@ #include #include #include -#include _STL_INTRIN_HEADER #include #include +#include _STL_INTRIN_HEADER + // TRANSITION, GH-2129, move down to _Arm64_popcount #if (defined(_M_ARM64) || defined(_M_ARM64EC)) && !defined(_M_CEE_PURE) && !defined(__CUDACC__) \ && !defined(__INTEL_COMPILER) && !defined(__clang__) // TRANSITION, LLVM-51488 diff --git a/stl/inc/xatomic.h b/stl/inc/xatomic.h index d6924b29ff5..83ca9def6f8 100644 --- a/stl/inc/xatomic.h +++ b/stl/inc/xatomic.h @@ -9,9 +9,10 @@ #include #if _STL_COMPILER_PREPROCESSOR -#include _STL_INTRIN_HEADER #include +#include _STL_INTRIN_HEADER + #pragma pack(push, _CRT_PACKING) #pragma warning(push, _STL_WARNING_LEVEL) #pragma warning(disable : _STL_DISABLED_WARNINGS) diff --git a/stl/inc/xbit_ops.h b/stl/inc/xbit_ops.h index d7075cc2980..a46e3cdfb9c 100644 --- a/stl/inc/xbit_ops.h +++ b/stl/inc/xbit_ops.h @@ -10,6 +10,7 @@ #if _STL_COMPILER_PREPROCESSOR #include + #include _STL_INTRIN_HEADER #pragma pack(push, _CRT_PACKING) From 89ba2ef9665450bcafd54a1c3ffa6542cc26a951 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 2 Mar 2023 07:26:08 -0800 Subject: [PATCH 5/9] stl/src/xmtx.hpp doesn't need push-pop defenses. --- stl/src/xmtx.hpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/stl/src/xmtx.hpp b/stl/src/xmtx.hpp index 9380716a3c0..2c0525cfd25 100644 --- a/stl/src/xmtx.hpp +++ b/stl/src/xmtx.hpp @@ -10,11 +10,6 @@ #include -#pragma pack(push, _CRT_PACKING) -#pragma warning(push, 3) -#pragma push_macro("new") -#undef new - _EXTERN_C_UNLESS_PURE using _Rmtx = CRITICAL_SECTION; @@ -34,7 +29,4 @@ _MRTIMP2 void __cdecl _Mtxunlock(_Rmtx*) noexcept; _END_EXTERN_C_UNLESS_PURE -#pragma pop_macro("new") -#pragma warning(pop) -#pragma pack(pop) #endif // _XMTX From 62f893461c13eeaf8c6abeefa4d3aa802eea5120 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 2 Mar 2023 07:30:02 -0800 Subject: [PATCH 6/9] Rely on `#pragma once` in xmath.hpp and xmtx.hpp, like all other stl/src headers. --- stl/src/xmath.hpp | 6 ++---- stl/src/xmtx.hpp | 5 +---- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/stl/src/xmath.hpp b/stl/src/xmath.hpp index 67528bdd35f..eafcb9cef1e 100644 --- a/stl/src/xmath.hpp +++ b/stl/src/xmath.hpp @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#ifndef _XMATH -#define _XMATH +#pragma once + #include #include #include @@ -205,5 +205,3 @@ template #ifndef _M_CEE_PURE #pragma float_control(pop) #endif - -#endif // _XMATH diff --git a/stl/src/xmtx.hpp b/stl/src/xmtx.hpp index 2c0525cfd25..44eb904eba5 100644 --- a/stl/src/xmtx.hpp +++ b/stl/src/xmtx.hpp @@ -2,8 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #pragma once -#ifndef _XMTX -#define _XMTX + #include #include @@ -28,5 +27,3 @@ _MRTIMP2 void __cdecl _Mtxunlock(_Rmtx*) noexcept; #endif // _M_CEE_PURE _END_EXTERN_C_UNLESS_PURE - -#endif // _XMTX From 5868438a24a28c6ee53d6f105f12bea9d5c50c4f Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 2 Mar 2023 08:16:54 -0800 Subject: [PATCH 7/9] Mark _Pass_fn() as _NODISCARD. --- stl/inc/xutility | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stl/inc/xutility b/stl/inc/xutility index 74782010400..13b78725526 100644 --- a/stl/inc/xutility +++ b/stl/inc/xutility @@ -375,7 +375,7 @@ struct _Ref_fn { // pass function object by value as a reference }; template -constexpr auto _Pass_fn(_Fn& _Func) noexcept { +_NODISCARD constexpr auto _Pass_fn(_Fn& _Func) noexcept { constexpr bool _Pass_by_value = conjunction_v, is_trivially_copy_constructible<_Fn>, is_trivially_destructible<_Fn>>; if constexpr (_Pass_by_value) { From 05932bdadb6bdf272fc0e3643900982d970440ef Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 2 Mar 2023 08:25:47 -0800 Subject: [PATCH 8/9] _Ryu_exponent can be const. --- stl/inc/xcharconv_ryu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stl/inc/xcharconv_ryu.h b/stl/inc/xcharconv_ryu.h index 70ab5338355..8a7d22910fb 100644 --- a/stl/inc/xcharconv_ryu.h +++ b/stl/inc/xcharconv_ryu.h @@ -1318,7 +1318,7 @@ _NODISCARD pair<_CharT*, errc> __to_chars(_CharT* const _First, _CharT* const _L chars_format _Fmt, const uint32_t __ieeeMantissa, const uint32_t __ieeeExponent) { // Step 5: Print the decimal representation. uint32_t _Output = __v.__mantissa; - int32_t _Ryu_exponent = __v.__exponent; + const int32_t _Ryu_exponent = __v.__exponent; const uint32_t __olength = __decimalLength9(_Output); int32_t _Scientific_exponent = _Ryu_exponent + static_cast(__olength) - 1; @@ -1926,7 +1926,7 @@ _NODISCARD pair<_CharT*, errc> __to_chars(_CharT* const _First, _CharT* const _L chars_format _Fmt, const double __f) { // Step 5: Print the decimal representation. uint64_t _Output = __v.__mantissa; - int32_t _Ryu_exponent = __v.__exponent; + const int32_t _Ryu_exponent = __v.__exponent; const uint32_t __olength = __decimalLength17(_Output); int32_t _Scientific_exponent = _Ryu_exponent + static_cast(__olength) - 1; From 9a0454cb721d322b4b495a80edd5d88d4c853571 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Fri, 3 Mar 2023 16:13:24 -0800 Subject: [PATCH 9/9] Move `_Can_const_join` and `_As_lvalue` up. This avoids separating `join_view`'s primary and specialization. --- stl/inc/ranges | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/stl/inc/ranges b/stl/inc/ranges index 66e94c498ad..5469647071b 100644 --- a/stl/inc/ranges +++ b/stl/inc/ranges @@ -3549,6 +3549,17 @@ namespace ranges { _EXPORT_STD inline constexpr _Drop_while_fn drop_while; } // namespace views +#ifdef __clang__ + template // TRANSITION, LLVM-47414 + concept _Can_const_join = forward_range && is_reference_v> + && input_range>; +#endif // ^^^ workaround ^^^ + + template + _NODISCARD constexpr _Ty& _As_lvalue(_Ty&& _Val) noexcept { + return static_cast<_Ty&>(_Val); + } + _EXPORT_STD template requires view<_Vw> && input_range> class join_view; @@ -3569,17 +3580,6 @@ namespace ranges { /* [[no_unique_address]] */ _Non_propagating_cache<_Cache_wrapper, false> _Inner{}; }; -#ifdef __clang__ - template // TRANSITION, LLVM-47414 - concept _Can_const_join = forward_range && is_reference_v> - && input_range>; -#endif // ^^^ workaround ^^^ - - template - _NODISCARD constexpr _Ty& _As_lvalue(_Ty&& _Val) noexcept { - return static_cast<_Ty&>(_Val); - } - template requires is_reference_v> class _Join_view_base<_Vw> : public view_interface> {};