diff --git a/.clang-tidy b/.clang-tidy index 5a2e68e28..c4609d2d1 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -3,6 +3,7 @@ Checks: '*, -altera-struct-pack-align, -altera-unroll-loops, -android-cloexec-fopen, + -boost-use-ranges, -bugprone-easily-swappable-parameters, -cert-err58-cpp, -concurrency-mt-unsafe, diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp index ba2fecf00..2bc7f4ad8 100644 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ b/include/nlohmann/detail/conversions/to_chars.hpp @@ -241,8 +241,8 @@ boundaries compute_boundaries(FloatType value) const bool lower_boundary_is_closer = F == 0 && E > 1; const diyfp m_plus = diyfp((2 * v.f) + 1, v.e - 1); const diyfp m_minus = lower_boundary_is_closer - ? diyfp(4 * v.f - 1, v.e - 2) // (B) - : diyfp(2 * v.f - 1, v.e - 1); // (A) + ? diyfp((4 * v.f) - 1, v.e - 2) // (B) + : diyfp((2 * v.f) - 1, v.e - 1); // (A) // Determine the normalized w+ = m+. const diyfp w_plus = diyfp::normalize(m_plus); @@ -472,7 +472,7 @@ inline cached_power get_cached_power_for_binary_exponent(int e) JSON_ASSERT(e >= -1500); JSON_ASSERT(e <= 1500); const int f = kAlpha - e - 1; - const int k = (f * 78913) / (1 << 18) + static_cast(f > 0); + const int k = ((f * 78913) / (1 << 18)) + static_cast(f > 0); const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep; JSON_ASSERT(index >= 0); @@ -950,15 +950,15 @@ inline char* append_exponent(char* buf, int e) } else if (k < 100) { - *buf++ = static_cast('0' + k / 10); + *buf++ = static_cast('0' + (k / 10)); k %= 10; *buf++ = static_cast('0' + k); } else { - *buf++ = static_cast('0' + k / 100); + *buf++ = static_cast('0' + (k / 100)); k %= 100; - *buf++ = static_cast('0' + k / 10); + *buf++ = static_cast('0' + (k / 10)); k %= 10; *buf++ = static_cast('0' + k); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a9360f475..693125edf 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -41,6 +41,7 @@ // SPDX-License-Identifier: MIT + #include // #include @@ -53,6 +54,7 @@ // SPDX-License-Identifier: MIT + // This file contains all macro definitions affecting or depending on the ABI #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK @@ -154,6 +156,7 @@ // SPDX-License-Identifier: MIT + #include // transform #include // array #include // forward_list @@ -176,6 +179,7 @@ // SPDX-License-Identifier: MIT + #include // nullptr_t #include // exception #if JSON_DIAGNOSTICS @@ -195,6 +199,7 @@ // SPDX-License-Identifier: MIT + #include // array #include // size_t #include // uint8_t @@ -210,6 +215,7 @@ // SPDX-License-Identifier: MIT + #include // declval, pair // #include // __ _____ _____ _____ @@ -221,6 +227,7 @@ // SPDX-License-Identifier: MIT + #include // #include @@ -233,6 +240,7 @@ // SPDX-License-Identifier: MIT + // #include @@ -2964,6 +2972,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -3038,6 +3047,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // size_t // #include @@ -3080,6 +3090,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // size_t #include // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type @@ -3252,6 +3263,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // numeric_limits #include // false_type, is_constructible, is_integral, is_same, true_type #include // declval @@ -3268,6 +3280,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // random_access_iterator_tag // #include @@ -3335,6 +3348,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -3354,6 +3368,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -4228,6 +4243,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // strlen #include // string #include // forward @@ -4613,6 +4629,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -4636,6 +4653,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include @@ -5160,6 +5178,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // copy #include // begin, end #include // string @@ -5179,6 +5198,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // size_t #include // input_iterator_tag #include // string, to_string @@ -5900,6 +5920,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // uint8_t, uint64_t #include // tie #include // move @@ -6011,6 +6032,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // uint8_t #include // size_t #include // hash @@ -6143,6 +6165,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // generate_n #include // array #include // ldexp @@ -6168,6 +6191,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // size_t #include // strlen @@ -6664,6 +6688,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include #include // string #include // move @@ -7395,6 +7420,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // localeconv #include // size_t @@ -9035,6 +9061,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // size_t #include // declval #include // string @@ -12186,6 +12213,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // isfinite #include // uint8_t #include // function @@ -12714,6 +12742,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + // #include // #include @@ -12726,6 +12755,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // ptrdiff_t #include // numeric_limits @@ -12884,6 +12914,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next #include // conditional, is_const, remove_const @@ -13645,6 +13676,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // ptrdiff_t #include // reverse_iterator #include // declval @@ -13821,6 +13853,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // all_of #include // isdigit #include // errno, ERANGE @@ -14815,6 +14848,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include #include @@ -14906,6 +14940,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // reverse #include // array #include // map @@ -14931,6 +14966,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // copy #include // size_t #include // back_inserter @@ -16899,6 +16935,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // reverse, remove, fill, find, none_of #include // array #include // localeconv, lconv @@ -16923,6 +16960,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // array #include // signbit, isfinite #include // intN_t, uintN_t @@ -17156,8 +17194,8 @@ boundaries compute_boundaries(FloatType value) const bool lower_boundary_is_closer = F == 0 && E > 1; const diyfp m_plus = diyfp((2 * v.f) + 1, v.e - 1); const diyfp m_minus = lower_boundary_is_closer - ? diyfp(4 * v.f - 1, v.e - 2) // (B) - : diyfp(2 * v.f - 1, v.e - 1); // (A) + ? diyfp((4 * v.f) - 1, v.e - 2) // (B) + : diyfp((2 * v.f) - 1, v.e - 1); // (A) // Determine the normalized w+ = m+. const diyfp w_plus = diyfp::normalize(m_plus); @@ -17387,7 +17425,7 @@ inline cached_power get_cached_power_for_binary_exponent(int e) JSON_ASSERT(e >= -1500); JSON_ASSERT(e <= 1500); const int f = kAlpha - e - 1; - const int k = (f * 78913) / (1 << 18) + static_cast(f > 0); + const int k = ((f * 78913) / (1 << 18)) + static_cast(f > 0); const int index = (-kCachedPowersMinDecExp + k + (kCachedPowersDecStep - 1)) / kCachedPowersDecStep; JSON_ASSERT(index >= 0); @@ -17865,15 +17903,15 @@ inline char* append_exponent(char* buf, int e) } else if (k < 100) { - *buf++ = static_cast('0' + k / 10); + *buf++ = static_cast('0' + (k / 10)); k %= 10; *buf++ = static_cast('0' + k); } else { - *buf++ = static_cast('0' + k / 100); + *buf++ = static_cast('0' + (k / 100)); k %= 100; - *buf++ = static_cast('0' + k / 10); + *buf++ = static_cast('0' + (k / 10)); k %= 10; *buf++ = static_cast('0' + k); } @@ -19017,6 +19055,7 @@ NLOHMANN_JSON_NAMESPACE_END // SPDX-License-Identifier: MIT + #include // equal_to, less #include // initializer_list #include // input_iterator_tag, iterator_traits @@ -24570,6 +24609,7 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC // SPDX-License-Identifier: MIT + // restore clang diagnostic settings #if defined(__clang__) #pragma clang diagnostic pop @@ -24614,6 +24654,7 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC // SPDX-License-Identifier: MIT + #undef JSON_HEDLEY_ALWAYS_INLINE #undef JSON_HEDLEY_ARM_VERSION #undef JSON_HEDLEY_ARM_VERSION_CHECK @@ -24764,4 +24805,5 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC #undef JSON_HEDLEY_FALL_THROUGH + #endif // INCLUDE_NLOHMANN_JSON_HPP_ diff --git a/single_include/nlohmann/json_fwd.hpp b/single_include/nlohmann/json_fwd.hpp index f219db3be..29a6036d7 100644 --- a/single_include/nlohmann/json_fwd.hpp +++ b/single_include/nlohmann/json_fwd.hpp @@ -25,6 +25,7 @@ // SPDX-License-Identifier: MIT + // This file contains all macro definitions affecting or depending on the ABI #ifndef JSON_SKIP_LIBRARY_VERSION_CHECK