From 6266a5548572b9729fad06c5e8fd8c671bd5a75d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 17 Oct 2021 14:09:05 +0200 Subject: [PATCH] :mute: suppress more Clang-Tidy warnings --- .clang-tidy | 1 + include/nlohmann/detail/exceptions.hpp | 2 +- include/nlohmann/detail/iterators/iter_impl.hpp | 2 +- include/nlohmann/detail/output/serializer.hpp | 4 ++-- single_include/nlohmann/json.hpp | 8 ++++---- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 9aab53081..b526aa82f 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -14,6 +14,7 @@ Checks: '*, -cppcoreguidelines-pro-bounds-pointer-arithmetic, -cppcoreguidelines-pro-type-reinterpret-cast, -cppcoreguidelines-pro-type-union-access, + -cppcoreguidelines-virtual-class-destructor, -fuchsia-default-arguments-calls, -fuchsia-default-arguments-declarations, -fuchsia-overloaded-operator, diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index bd0979524..0fca6a357 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -60,7 +60,7 @@ class exception : public std::exception protected: JSON_HEDLEY_NON_NULL(3) - exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} + exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} // NOLINT(bugprone-throw-keyword-missing) static std::string name(const std::string& ename, int id_) { diff --git a/include/nlohmann/detail/iterators/iter_impl.hpp b/include/nlohmann/detail/iterators/iter_impl.hpp index aaff2b64c..434a62d3e 100644 --- a/include/nlohmann/detail/iterators/iter_impl.hpp +++ b/include/nlohmann/detail/iterators/iter_impl.hpp @@ -36,7 +36,7 @@ This class implements a both iterators (iterator and const_iterator) for the iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593) */ template -class iter_impl +class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) { /// the iterator with BasicJsonType of different const-ness using other_iter_impl = iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; diff --git a/include/nlohmann/detail/output/serializer.hpp b/include/nlohmann/detail/output/serializer.hpp index 786507c41..07fa3e968 100644 --- a/include/nlohmann/detail/output/serializer.hpp +++ b/include/nlohmann/detail/output/serializer.hpp @@ -502,7 +502,7 @@ class serializer case error_handler_t::strict: { std::stringstream ss; - ss << std::uppercase << std::setfill('0') << std::setw(4) << std::hex << byte; + ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (byte | 0); JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + ss.str(), BasicJsonType())); } @@ -596,7 +596,7 @@ class serializer case error_handler_t::strict: { std::stringstream ss; - ss << std::uppercase << std::setfill('0') << std::setw(4) << std::hex << s.back(); + ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (static_cast(s.back()) | 0); JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + ss.str(), BasicJsonType())); } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 52a1c85c6..f071e2433 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -2776,7 +2776,7 @@ class exception : public std::exception protected: JSON_HEDLEY_NON_NULL(3) - exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} + exception(int id_, const char* what_arg) : id(id_), m(what_arg) {} // NOLINT(bugprone-throw-keyword-missing) static std::string name(const std::string& ename, int id_) { @@ -11621,7 +11621,7 @@ This class implements a both iterators (iterator and const_iterator) for the iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593) */ template -class iter_impl +class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions) { /// the iterator with BasicJsonType of different const-ness using other_iter_impl = iter_impl::value, typename std::remove_const::type, const BasicJsonType>::type>; @@ -16926,7 +16926,7 @@ class serializer case error_handler_t::strict: { std::stringstream ss; - ss << std::uppercase << std::setfill('0') << std::setw(4) << std::hex << byte; + ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (byte | 0); JSON_THROW(type_error::create(316, "invalid UTF-8 byte at index " + std::to_string(i) + ": 0x" + ss.str(), BasicJsonType())); } @@ -17020,7 +17020,7 @@ class serializer case error_handler_t::strict: { std::stringstream ss; - ss << std::uppercase << std::setfill('0') << std::setw(4) << std::hex << s.back(); + ss << std::uppercase << std::setfill('0') << std::setw(2) << std::hex << (static_cast(s.back()) | 0); JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + ss.str(), BasicJsonType())); }