Skip to content

Commit

Permalink
Run clang-format 11; no manual changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanTLavavej committed Dec 10, 2020
1 parent 58160d5 commit 68b344c
Show file tree
Hide file tree
Showing 57 changed files with 617 additions and 586 deletions.
4 changes: 2 additions & 2 deletions stl/inc/any
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ inline constexpr size_t _Any_trivial_space_size = (_Small_object_num_ptrs - 1) *

template <class _Ty>
inline constexpr bool _Any_is_trivial = alignof(_Ty) <= alignof(max_align_t)
&& is_trivially_copyable_v<_Ty> && sizeof(_Ty) <= _Any_trivial_space_size;
&& is_trivially_copyable_v<_Ty> && sizeof(_Ty) <= _Any_trivial_space_size;

inline constexpr size_t _Any_small_space_size = (_Small_object_num_ptrs - 2) * sizeof(void*);

template <class _Ty>
inline constexpr bool _Any_is_small = alignof(_Ty) <= alignof(max_align_t)
&& is_nothrow_move_constructible_v<_Ty> && sizeof(_Ty) <= _Any_small_space_size;
&& is_nothrow_move_constructible_v<_Ty> && sizeof(_Ty) <= _Any_small_space_size;

enum class _Any_representation : uintptr_t { _Trivial, _Big, _Small };

Expand Down
13 changes: 6 additions & 7 deletions stl/inc/atomic
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,14 @@ struct _Atomic_padded {
// STRUCT TEMPLATE _Atomic_storage_traits
template <class _Ty>
struct _Atomic_storage_traits { // properties for how _Ty is stored in an atomic
static constexpr size_t _Storage_size =
sizeof(_Ty) == 1 ? 1
: sizeof(_Ty) == 2 ? 2
: sizeof(_Ty) <= 4 ? 4
: sizeof(_Ty) <= 8 ? 8
static constexpr size_t _Storage_size = sizeof(_Ty) == 1 ? 1
: sizeof(_Ty) == 2 ? 2
: sizeof(_Ty) <= 4 ? 4
: sizeof(_Ty) <= 8 ? 8
#if defined(_M_X64) || defined(_M_ARM64) || defined(_M_ARM64EC)
: sizeof(_Ty) <= 16 ? 16
: sizeof(_Ty) <= 16 ? 16
#endif // 64 bits
: sizeof(_Ty);
: sizeof(_Ty);
static constexpr size_t _Padding_size = _Storage_size - sizeof(_Ty);
static constexpr bool _Uses_padding = _Padding_size != 0;
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/bit
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ _NODISCARD int _Checked_x86_x64_countl_zero(const _Ty _Val) noexcept {

template <class _Ty>
_NODISCARD int _Checked_x86_x64_popcount(const _Ty _Val) noexcept {
constexpr int _Digits = numeric_limits<_Ty>::digits;
constexpr int _Digits = numeric_limits<_Ty>::digits;
#ifndef __AVX__
const bool _Definitely_have_popcnt = __isa_available >= __ISA_AVAILABLE_SSE42;
if (!_Definitely_have_popcnt) {
Expand Down
71 changes: 36 additions & 35 deletions stl/inc/charconv
Original file line number Diff line number Diff line change
Expand Up @@ -62,34 +62,35 @@ _NODISCARD to_chars_result _Integer_to_chars(
char* _RNext = _Buff_end;

switch (_Base) {
case 10: { // Derived from _UIntegral_to_buff()
// Performance note: Ryu's digit table should be faster here.
constexpr bool _Use_chunks = sizeof(_Unsigned) > sizeof(size_t);

if constexpr (_Use_chunks) { // For 64-bit numbers on 32-bit platforms, work in chunks to avoid 64-bit
// divisions.
while (_Value > 0xFFFF'FFFFU) {
// Performance note: Ryu's division workaround would be faster here.
unsigned long _Chunk = static_cast<unsigned long>(_Value % 1'000'000'000);
_Value = static_cast<_Unsigned>(_Value / 1'000'000'000);

for (int _Idx = 0; _Idx != 9; ++_Idx) {
*--_RNext = static_cast<char>('0' + _Chunk % 10);
_Chunk /= 10;
case 10:
{ // Derived from _UIntegral_to_buff()
// Performance note: Ryu's digit table should be faster here.
constexpr bool _Use_chunks = sizeof(_Unsigned) > sizeof(size_t);

if constexpr (_Use_chunks) { // For 64-bit numbers on 32-bit platforms, work in chunks to avoid 64-bit
// divisions.
while (_Value > 0xFFFF'FFFFU) {
// Performance note: Ryu's division workaround would be faster here.
unsigned long _Chunk = static_cast<unsigned long>(_Value % 1'000'000'000);
_Value = static_cast<_Unsigned>(_Value / 1'000'000'000);

for (int _Idx = 0; _Idx != 9; ++_Idx) {
*--_RNext = static_cast<char>('0' + _Chunk % 10);
_Chunk /= 10;
}
}
}
}

using _Truncated = conditional_t<_Use_chunks, unsigned long, _Unsigned>;
using _Truncated = conditional_t<_Use_chunks, unsigned long, _Unsigned>;

_Truncated _Trunc = static_cast<_Truncated>(_Value);
_Truncated _Trunc = static_cast<_Truncated>(_Value);

do {
*--_RNext = static_cast<char>('0' + _Trunc % 10);
_Trunc /= 10;
} while (_Trunc != 0);
break;
}
do {
*--_RNext = static_cast<char>('0' + _Trunc % 10);
_Trunc /= 10;
} while (_Trunc != 0);
break;
}

case 2:
do {
Expand Down Expand Up @@ -406,8 +407,8 @@ struct _Big_integer_flt {
}

static constexpr uint32_t _Maximum_bits = 1074 // 1074 bits required to represent 2^1074
+ 2552 // ceil(log2(10^768))
+ 54; // shift space
+ 2552 // ceil(log2(10^768))
+ 54; // shift space

static constexpr uint32_t _Element_bits = 32;

Expand Down Expand Up @@ -1022,7 +1023,7 @@ _NODISCARD inline uint64_t _Divide(_Big_integer_flt& _Numerator, const _Big_inte
uint32_t _U_carry = 0;
for (uint32_t _Iu2 = 0; _Iu2 < _Cu_den; ++_Iu2) {
const uint64_t _Sum = static_cast<uint64_t>(_Numerator._Mydata[_Iu + _Iu2])
+ static_cast<uint64_t>(_Denominator._Mydata[_Iu2]) + _U_carry;
+ static_cast<uint64_t>(_Denominator._Mydata[_Iu2]) + _U_carry;

_Numerator._Mydata[_Iu + _Iu2] = static_cast<uint32_t>(_Sum);
_U_carry = static_cast<uint32_t>(_Sum >> 32);
Expand Down Expand Up @@ -1376,7 +1377,7 @@ _NODISCARD errc _Assemble_floating_point_value_from_big_integer_flt(const _Big_i
const int32_t _Exponent = static_cast<int32_t>(_Base_exponent + _Bottom_element_index * 32);

const uint64_t _Mantissa = _Integer_value._Mydata[_Bottom_element_index]
+ (static_cast<uint64_t>(_Integer_value._Mydata[_Middle_element_index]) << 32);
+ (static_cast<uint64_t>(_Integer_value._Mydata[_Middle_element_index]) << 32);

bool _Has_zero_tail = !_Has_nonzero_fractional_part;
for (uint32_t _Ix = 0; _Has_zero_tail && _Ix != _Bottom_element_index; ++_Ix) {
Expand Down Expand Up @@ -1527,8 +1528,8 @@ _NODISCARD errc _Convert_decimal_string_to_floating_type(
const uint32_t _Fractional_denominator_bits = _Bit_scan_reverse(_Fractional_denominator);

const uint32_t _Fractional_shift = _Fractional_denominator_bits > _Fractional_numerator_bits
? _Fractional_denominator_bits - _Fractional_numerator_bits
: 0;
? _Fractional_denominator_bits - _Fractional_numerator_bits
: 0;

if (_Fractional_shift > 0) {
[[maybe_unused]] const bool _Shift_success1 =
Expand Down Expand Up @@ -1595,8 +1596,8 @@ _NODISCARD errc _Convert_decimal_string_to_floating_type(
// Then, in both cases, we subtract an additional one from the exponent,
// to account for the fact that we've generated an extra bit of precision, for use in rounding.
const int32_t _Final_exponent = _Integer_bits_of_precision > 0
? static_cast<int32_t>(_Integer_bits_of_precision - 2)
: -static_cast<int32_t>(_Fractional_exponent) - 1;
? static_cast<int32_t>(_Integer_bits_of_precision - 2)
: -static_cast<int32_t>(_Fractional_exponent) - 1;

return _Assemble_floating_point_value(
_Complete_mantissa, _Final_exponent, _Data._Myis_negative, _Has_zero_tail, _Result);
Expand Down Expand Up @@ -2143,10 +2144,10 @@ _NODISCARD to_chars_result _Floating_to_chars_hex_precision(
_Buffer_size -= _Precision;

const int32_t _Length_excluding_precision = 1 // leading hexit
+ static_cast<int32_t>(_Precision > 0) // possible decimal point
// excluding `+ _Precision`, hexits after decimal point
+ 2 // "p+" or "p-"
+ _Exponent_length; // exponent
+ static_cast<int32_t>(_Precision > 0) // possible decimal point
// excluding `+ _Precision`, hexits after decimal point
+ 2 // "p+" or "p-"
+ _Exponent_length; // exponent

if (_Buffer_size < _Length_excluding_precision) {
return {_Last, errc::value_too_large};
Expand Down
40 changes: 19 additions & 21 deletions stl/inc/compare
Original file line number Diff line number Diff line change
Expand Up @@ -666,10 +666,9 @@ namespace _Compare_strong_order_fallback {
return {_St::_Strong, noexcept(_STD strong_order(_STD declval<_Ty1&>(), _STD declval<_Ty2&>()))};
} else if constexpr (_Can_fallback_eq_lt<_Ty1, _Ty2>) {
return {_St::_Fallback,
noexcept(_STD declval<_Ty1&>() == _STD declval<_Ty2&>()
? strong_ordering::equal
: _STD declval<_Ty1&>() < _STD declval<_Ty2&>() ? strong_ordering::less
: strong_ordering::greater)};
noexcept(_STD declval<_Ty1&>() == _STD declval<_Ty2&>() ? strong_ordering::equal
: _STD declval<_Ty1&>() < _STD declval<_Ty2&>() ? strong_ordering::less
: strong_ordering::greater)};
} else {
return {_St::_None};
}
Expand All @@ -690,7 +689,8 @@ namespace _Compare_strong_order_fallback {
return _STD strong_order(_Left, _Right);
} else if constexpr (_Strat == _St::_Fallback) {
return _Left == _Right ? strong_ordering::equal
: _Left < _Right ? strong_ordering::less : strong_ordering::greater;
: _Left < _Right ? strong_ordering::less
: strong_ordering::greater;
} else {
static_assert(_Always_false<_Ty1>, "should be unreachable");
}
Expand Down Expand Up @@ -720,11 +720,10 @@ namespace _Compare_weak_order_fallback {
} else if constexpr (_Can_weak_order<_Ty1, _Ty2>) {
return {_St::_Weak, noexcept(_STD weak_order(_STD declval<_Ty1&>(), _STD declval<_Ty2&>()))};
} else if constexpr (_Can_fallback_eq_lt<_Ty1, _Ty2>) {
return {_St::_Fallback,
noexcept(_STD declval<_Ty1&>() == _STD declval<_Ty2&>()
? weak_ordering::equivalent
: _STD declval<_Ty1&>() < _STD declval<_Ty2&>() ? weak_ordering::less
: weak_ordering::greater)};
return {
_St::_Fallback, noexcept(_STD declval<_Ty1&>() == _STD declval<_Ty2&>() ? weak_ordering::equivalent
: _STD declval<_Ty1&>() < _STD declval<_Ty2&>() ? weak_ordering::less
: weak_ordering::greater)};
} else {
return {_St::_None};
}
Expand All @@ -745,7 +744,8 @@ namespace _Compare_weak_order_fallback {
return _STD weak_order(_Left, _Right);
} else if constexpr (_Strat == _St::_Fallback) {
return _Left == _Right ? weak_ordering::equivalent
: _Left < _Right ? weak_ordering::less : weak_ordering::greater;
: _Left < _Right ? weak_ordering::less
: weak_ordering::greater;
} else {
static_assert(_Always_false<_Ty1>, "should be unreachable");
}
Expand Down Expand Up @@ -785,12 +785,10 @@ namespace _Compare_partial_order_fallback {
return {_St::_Partial, noexcept(_STD partial_order(_STD declval<_Ty1&>(), _STD declval<_Ty2&>()))};
} else if constexpr (_Can_fallback_eq_lt_twice<_Ty1, _Ty2>) {
return {_St::_Fallback,
noexcept(_STD declval<_Ty1&>() == _STD declval<_Ty2&>()
? partial_ordering::equivalent
: _STD declval<_Ty1&>() < _STD declval<_Ty2&>()
? partial_ordering::less
: _STD declval<_Ty2&>() < _STD declval<_Ty1&>() ? partial_ordering::greater
: partial_ordering::unordered)};
noexcept(_STD declval<_Ty1&>() == _STD declval<_Ty2&>() ? partial_ordering::equivalent
: _STD declval<_Ty1&>() < _STD declval<_Ty2&>() ? partial_ordering::less
: _STD declval<_Ty2&>() < _STD declval<_Ty1&>() ? partial_ordering::greater
: partial_ordering::unordered)};
} else {
return {_St::_None};
}
Expand All @@ -810,10 +808,10 @@ namespace _Compare_partial_order_fallback {
if constexpr (_Strat == _St::_Partial) {
return _STD partial_order(_Left, _Right);
} else if constexpr (_Strat == _St::_Fallback) {
return _Left == _Right
? partial_ordering::equivalent
: _Left < _Right ? partial_ordering::less
: _Right < _Left ? partial_ordering::greater : partial_ordering::unordered;
return _Left == _Right ? partial_ordering::equivalent
: _Left < _Right ? partial_ordering::less
: _Right < _Left ? partial_ordering::greater
: partial_ordering::unordered;
} else {
static_assert(_Always_false<_Ty1>, "should be unreachable");
}
Expand Down
2 changes: 1 addition & 1 deletion stl/inc/complex
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ public:
_Ans = log1p(_Left + _Left * _Left / (1 + sqrt(_Left * _Left + 1)));
} else {
_Ans = log(_Left) // _Left big, compute log(_Left+_Left)
+ static_cast<_Ty>(0.69314718055994530941723212145817658L);
+ static_cast<_Ty>(0.69314718055994530941723212145817658L);
}

return _Copysign(_Ans, _Old_left);
Expand Down
Loading

0 comments on commit 68b344c

Please sign in to comment.