Fix the develop CI failures hidden behind cancelled jobs

- ci_test_noexceptions: the JSON Patch section of unit-throw_messages
  and the strict dumps in unit-serialization catch exceptions, which
  JSON_NOEXCEPTION turns into std::abort(); skip them there.
- ci_cppcheck: insert() and iter_impl::key() ended with a call to a
  noreturn throw helper, which Cppcheck reports as missingReturn; check
  the error case first and end with the return, like the other functions.
- ci_single_binaries: ordered_map.hpp uses the Hedley macros since #5838,
  so include hedley.hpp (IWYU).
- MSVC: also wrap the second vector<json> comparison in unit-constructor2
  in parentheses.

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-10-16 07:54:13 +02:00
1 parent 94d77f8d8d
commit ac17aad589
7 files changed
+82 -71

No files matched your search

@@ -680,12 +680,12 @@ class iter_impl // NOLINT(cppcoreguidelines-special-member-functions,hicpp-speci
{
JSON_ASSERT(m_object != nullptr);
if (JSON_HEDLEY_LIKELY(m_object->is_object()))
if (JSON_HEDLEY_UNLIKELY(!m_object->is_object()))
{
return m_it.object_iterator->first;
throw_literal<invalid_iterator>(exception_id::iterator_key_not_object, "cannot use key() for non-object iterators", m_object);
}
throw_literal<invalid_iterator>(exception_id::iterator_key_not_object, "cannot use key() for non-object iterators", m_object);
return m_it.object_iterator->first;
}
/*!
+32 -32
View File
@@ -4895,19 +4895,19 @@ public:
iterator insert(const_iterator pos, const basic_json& val) // NOLINT(performance-unnecessary-value-param)
{
// insert only works for arrays
if (JSON_HEDLEY_LIKELY(is_array()))
if (JSON_HEDLEY_UNLIKELY(!is_array()))
{
// check if iterator pos fits to this JSON value
if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
detail::throw_literal<invalid_iterator>(detail::exception_id::iterator_from_other_value, "iterator does not fit current value", this);
}
// insert to array and return iterator
return insert_iterator(pos, val);
detail::throw_cannot_use_with(detail::exception_id::insert_wrong_type, "insert()", *this);
}
detail::throw_cannot_use_with(detail::exception_id::insert_wrong_type, "insert()", *this);
// check if iterator pos fits to this JSON value
if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
detail::throw_literal<invalid_iterator>(detail::exception_id::iterator_from_other_value, "iterator does not fit current value", this);
}
// insert to array and return iterator
return insert_iterator(pos, val);
}
/// @brief inserts element into array
@@ -4915,21 +4915,21 @@ public:
iterator insert(const_iterator pos, basic_json&& val) // NOLINT(performance-unnecessary-value-param)
{
// insert only works for arrays
if (JSON_HEDLEY_LIKELY(is_array()))
if (JSON_HEDLEY_UNLIKELY(!is_array()))
{
// check if iterator pos fits to this JSON value
if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
detail::throw_literal<invalid_iterator>(detail::exception_id::iterator_from_other_value, "iterator does not fit current value", this);
}
// moving into a local first keeps this safe even if val aliases
// an element of this array
basic_json tmp(std::move(val));
return insert_iterator(pos, std::move(tmp));
detail::throw_cannot_use_with(detail::exception_id::insert_wrong_type, "insert()", *this);
}
detail::throw_cannot_use_with(detail::exception_id::insert_wrong_type, "insert()", *this);
// check if iterator pos fits to this JSON value
if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
detail::throw_literal<invalid_iterator>(detail::exception_id::iterator_from_other_value, "iterator does not fit current value", this);
}
// moving into a local first keeps this safe even if val aliases
// an element of this array
basic_json tmp(std::move(val));
return insert_iterator(pos, std::move(tmp));
}
/// @brief inserts copies of element into array
@@ -4937,19 +4937,19 @@ public:
iterator insert(const_iterator pos, size_type cnt, const basic_json& val) // NOLINT(performance-unnecessary-value-param)
{
// insert only works for arrays
if (JSON_HEDLEY_LIKELY(is_array()))
if (JSON_HEDLEY_UNLIKELY(!is_array()))
{
// check if iterator pos fits to this JSON value
if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
detail::throw_literal<invalid_iterator>(detail::exception_id::iterator_from_other_value, "iterator does not fit current value", this);
}
// insert to array and return iterator
return insert_iterator(pos, cnt, val);
detail::throw_cannot_use_with(detail::exception_id::insert_wrong_type, "insert()", *this);
}
detail::throw_cannot_use_with(detail::exception_id::insert_wrong_type, "insert()", *this);
// check if iterator pos fits to this JSON value
if (JSON_HEDLEY_UNLIKELY(pos.m_object != this))
{
detail::throw_literal<invalid_iterator>(detail::exception_id::iterator_from_other_value, "iterator does not fit current value", this);
}
// insert to array and return iterator
return insert_iterator(pos, cnt, val);
}
/// @brief inserts range of elements into array
+1
View File
@@ -23,6 +23,7 @@
#include <nlohmann/detail/abi_macros.hpp>
#include <nlohmann/detail/macro_scope.hpp>
#include <nlohmann/detail/meta/type_traits.hpp>
#include <nlohmann/thirdparty/hedley/hedley.hpp>
NLOHMANN_JSON_NAMESPACE_BEGIN