Fix ci issues

This commit is contained in:
barcode 2022-12-23 21:12:27 +01:00 committed by Raphael Grimm
parent bda3e4b7bc
commit a416868818
6 changed files with 42 additions and 43 deletions

View File

@ -636,7 +636,7 @@ add_custom_target(ci_test_valgrind
-DJSON_BuildTests=ON -DJSON_Valgrind=ON -DJSON_BuildTests=ON -DJSON_Valgrind=ON
-S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_valgrind -S${PROJECT_SOURCE_DIR} -B${PROJECT_BINARY_DIR}/build_valgrind
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_valgrind COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR}/build_valgrind
COMMAND cd ${PROJECT_BINARY_DIR}/build_valgrind && ${CMAKE_CTEST_COMMAND} -L valgrind --parallel ${N} --output-on-failure COMMAND cd ${PROJECT_BINARY_DIR}/build_valgrind && ${CMAKE_CTEST_COMMAND} -L valgrind --parallel ${N} --output-on-failure --timeout 10000
COMMENT "Compile and test with Valgrind" COMMENT "Compile and test with Valgrind"
) )

View File

@ -187,7 +187,7 @@ class sax_with_token_start_stop_metadata
return false; return false;
} }
constexpr bool is_errored() const bool is_errored() const
{ {
return errored; return errored;
} }

View File

@ -15,6 +15,7 @@
#include <nlohmann/detail/abi_macros.hpp> #include <nlohmann/detail/abi_macros.hpp>
#include <nlohmann/detail/meta/detected.hpp> #include <nlohmann/detail/meta/detected.hpp>
#include <nlohmann/detail/meta/type_traits.hpp> #include <nlohmann/detail/meta/type_traits.hpp>
#include <nlohmann/detail/input/position_t.hpp>
NLOHMANN_JSON_NAMESPACE_BEGIN NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail namespace detail
@ -63,7 +64,7 @@ struct sax_call_function
//the sax parser supports calls with a lexer //the sax parser supports calls with a lexer
static constexpr bool detected_call_with_lex_pos = static constexpr bool detected_call_with_lex_pos =
!called_with_byte_pos && !called_with_byte_pos &&
is_detected_exact<void, call_t, SAX, const position_t >::value; is_detected_exact<void, call_t, SAX, position_t >::value;
//there either has to be a version accepting a lexer or a position //there either has to be a version accepting a lexer or a position
static constexpr bool valid = detected_call_with_byte_pos || detected_call_with_lex_pos; static constexpr bool valid = detected_call_with_byte_pos || detected_call_with_lex_pos;

View File

@ -8962,6 +8962,8 @@ NLOHMANN_JSON_NAMESPACE_END
// #include <nlohmann/detail/meta/type_traits.hpp> // #include <nlohmann/detail/meta/type_traits.hpp>
// #include <nlohmann/detail/input/position_t.hpp>
NLOHMANN_JSON_NAMESPACE_BEGIN NLOHMANN_JSON_NAMESPACE_BEGIN
namespace detail namespace detail
@ -9010,7 +9012,7 @@ struct sax_call_function
//the sax parser supports calls with a lexer //the sax parser supports calls with a lexer
static constexpr bool detected_call_with_lex_pos = static constexpr bool detected_call_with_lex_pos =
!called_with_byte_pos && !called_with_byte_pos &&
is_detected_exact<void, call_t, SAX, const position_t >::value; is_detected_exact<void, call_t, SAX, position_t >::value;
//there either has to be a version accepting a lexer or a position //there either has to be a version accepting a lexer or a position
static constexpr bool valid = detected_call_with_byte_pos || detected_call_with_lex_pos; static constexpr bool valid = detected_call_with_byte_pos || detected_call_with_lex_pos;

View File

@ -521,7 +521,7 @@ void fill_expected_sax_pos_json(SAX& sax,
case nlohmann::json::value_t::object: case nlohmann::json::value_t::object:
{ {
sax.pos_start_object.emplace(element(1)); // { sax.pos_start_object.emplace(element(1)); // {
for (auto& el : part.items()) for (const auto& el : part.items())
{ {
sax.pos_key.emplace(element(el.key().size() + 2)); //'"' + str + '"' sax.pos_key.emplace(element(el.key().size() + 2)); //'"' + str + '"'
offset += 1; // separator ':' between key and value offset += 1; // separator ':' between key and value
@ -538,7 +538,7 @@ void fill_expected_sax_pos_json(SAX& sax,
case nlohmann::json::value_t::array: case nlohmann::json::value_t::array:
{ {
sax.pos_start_array.emplace(element(1)); // [ sax.pos_start_array.emplace(element(1)); // [
for (auto& el : part.items()) for (const auto& el : part.items())
{ {
fill_expected_sax_pos_json(sax, element, el.value(), offset); fill_expected_sax_pos_json(sax, element, el.value(), offset);
offset += 1; // add , offset += 1; // add ,
@ -553,7 +553,7 @@ void fill_expected_sax_pos_json(SAX& sax,
case nlohmann::json::value_t::string: case nlohmann::json::value_t::string:
{ {
const auto val = part.get<std::string>(); const auto val = part.get<std::string>();
std::size_t nbytes = val.size() + 2; //'"' + value + '"' const std::size_t nbytes = val.size() + 2; //'"' + value + '"'
sax.pos_string.emplace(element(nbytes)); sax.pos_string.emplace(element(nbytes));
} }
break; break;
@ -573,21 +573,21 @@ void fill_expected_sax_pos_json(SAX& sax,
case nlohmann::json::value_t::number_integer: case nlohmann::json::value_t::number_integer:
{ {
const auto val = part.get<std::int64_t>(); const auto val = part.get<std::int64_t>();
std::size_t nbytes = std::to_string(val).size(); const std::size_t nbytes = std::to_string(val).size();
sax.pos_number_integer.emplace(element(nbytes)); sax.pos_number_integer.emplace(element(nbytes));
} }
break; break;
case nlohmann::json::value_t::number_unsigned: case nlohmann::json::value_t::number_unsigned:
{ {
const auto val = part.get<std::uint64_t>(); const auto val = part.get<std::uint64_t>();
std::size_t nbytes = std::to_string(val).size(); const std::size_t nbytes = std::to_string(val).size();
sax.pos_number_unsigned.emplace(element(nbytes)); sax.pos_number_unsigned.emplace(element(nbytes));
} }
break; break;
case nlohmann::json::value_t::number_float: case nlohmann::json::value_t::number_float:
{ {
const auto val = part.get<double>(); const auto val = part.get<double>();
std::size_t nbytes = std::to_string(val).size(); const std::size_t nbytes = std::to_string(val).size();
sax.pos_number_float.emplace(element(nbytes)); sax.pos_number_float.emplace(element(nbytes));
} }
break; break;
@ -632,7 +632,7 @@ void fill_expected_sax_pos_bson(SAX& sax,
case nlohmann::json::value_t::object: case nlohmann::json::value_t::object:
{ {
sax.pos_start_object.emplace(element(4)); //32 bit size sax.pos_start_object.emplace(element(4)); //32 bit size
for (auto& el : part.items()) for (const auto& el : part.items())
{ {
offset += 1; // type of item offset += 1; // type of item
sax.pos_key.emplace(element(el.key().size() + 1)); // str + terminator sax.pos_key.emplace(element(el.key().size() + 1)); // str + terminator
@ -645,7 +645,7 @@ void fill_expected_sax_pos_bson(SAX& sax,
{ {
sax.pos_start_array.emplace(element(4)); //32 bit size sax.pos_start_array.emplace(element(4)); //32 bit size
std::size_t i = 0; std::size_t i = 0;
for (auto& el : part.items()) for (const auto& el : part.items())
{ {
offset += 1; // type of item offset += 1; // type of item
offset += 1 + std::to_string(i).size(); // dummy key + terminator offset += 1 + std::to_string(i).size(); // dummy key + terminator
@ -667,8 +667,7 @@ void fill_expected_sax_pos_bson(SAX& sax,
case nlohmann::json::value_t::boolean: case nlohmann::json::value_t::boolean:
{ {
//type is before the key -> not included //type is before the key -> not included
std::size_t nbytes = 1; //value sax.pos_boolean.emplace(element(1)); //value
sax.pos_boolean.emplace(element(nbytes));
} }
break; break;
case nlohmann::json::value_t::number_integer: case nlohmann::json::value_t::number_integer:
@ -741,8 +740,7 @@ void fill_expected_sax_pos_cbor(SAX& sax, const FN& element, const nlohmann::jso
{ {
case nlohmann::json::value_t::null: case nlohmann::json::value_t::null:
{ {
std::size_t nbytes = 1; //type sax.pos_null.emplace(element(1)); //type
sax.pos_null.emplace(element(nbytes));
} }
break; break;
case nlohmann::json::value_t::object: case nlohmann::json::value_t::object:
@ -770,7 +768,7 @@ void fill_expected_sax_pos_cbor(SAX& sax, const FN& element, const nlohmann::jso
} }
sax.pos_start_object.emplace(element(nbytes)); sax.pos_start_object.emplace(element(nbytes));
//key follows same rules as string //key follows same rules as string
for (auto& el : part.items()) for (const auto& el : part.items())
{ {
std::size_t nbyteskey = 1; //type std::size_t nbyteskey = 1; //type
nbyteskey += el.key().size(); nbyteskey += el.key().size();
@ -862,8 +860,7 @@ void fill_expected_sax_pos_cbor(SAX& sax, const FN& element, const nlohmann::jso
break; break;
case nlohmann::json::value_t::boolean: case nlohmann::json::value_t::boolean:
{ {
std::size_t nbytes = 1; //type sax.pos_boolean.emplace(element(1)); //type
sax.pos_boolean.emplace(element(nbytes));
} }
break; break;
case nlohmann::json::value_t::number_integer: case nlohmann::json::value_t::number_integer:
@ -880,15 +877,15 @@ void fill_expected_sax_pos_cbor(SAX& sax, const FN& element, const nlohmann::jso
{ {
//value implicit in type //value implicit in type
} }
else if (-val - 1 <= static_cast<std::int64_t>(std::numeric_limits<std::uint8_t>::max())) else if (-(val + 1) <= static_cast<std::int64_t>(std::numeric_limits<std::uint8_t>::max()))
{ {
nbytes += 1; nbytes += 1;
} }
else if (-val - 1 <= static_cast<std::int64_t>(std::numeric_limits<std::uint16_t>::max())) else if (-(val + 1) <= static_cast<std::int64_t>(std::numeric_limits<std::uint16_t>::max()))
{ {
nbytes += 2; nbytes += 2;
} }
else if (-val - 1 <= static_cast<std::int64_t>(std::numeric_limits<std::uint32_t>::max())) else if (-(val + 1) <= static_cast<std::int64_t>(std::numeric_limits<std::uint32_t>::max()))
{ {
nbytes += 4; nbytes += 4;
} }
@ -993,8 +990,7 @@ void fill_expected_sax_pos_msgpack(SAX& sax, const FN& element, const nlohmann::
{ {
case nlohmann::json::value_t::null: case nlohmann::json::value_t::null:
{ {
std::size_t nbytes = 1; //type sax.pos_null.emplace(element(1)); //type
sax.pos_null.emplace(element(nbytes));
} }
break; break;
case nlohmann::json::value_t::object: case nlohmann::json::value_t::object:
@ -1018,7 +1014,7 @@ void fill_expected_sax_pos_msgpack(SAX& sax, const FN& element, const nlohmann::
} }
sax.pos_start_object.emplace(element(nbytes)); sax.pos_start_object.emplace(element(nbytes));
//key follows same rules as string //key follows same rules as string
for (auto& el : part.items()) for (const auto& el : part.items())
{ {
std::size_t nbyteskey = 1; //type std::size_t nbyteskey = 1; //type
nbyteskey += el.key().size(); nbyteskey += el.key().size();
@ -1106,8 +1102,7 @@ void fill_expected_sax_pos_msgpack(SAX& sax, const FN& element, const nlohmann::
break; break;
case nlohmann::json::value_t::boolean: case nlohmann::json::value_t::boolean:
{ {
std::size_t nbytes = 1; //type sax.pos_boolean.emplace(element(1)); //type
sax.pos_boolean.emplace(element(nbytes));
} }
break; break;
case nlohmann::json::value_t::number_integer: case nlohmann::json::value_t::number_integer:
@ -1233,15 +1228,14 @@ void fill_expected_sax_pos_ubjson(SAX& sax, const FN& element, const nlohmann::j
{ {
case nlohmann::json::value_t::null: case nlohmann::json::value_t::null:
{ {
std::size_t nbytes = 1; //type sax.pos_null.emplace(element(1)); //type
sax.pos_null.emplace(element(nbytes));
} }
break; break;
case nlohmann::json::value_t::object: case nlohmann::json::value_t::object:
{ {
sax.pos_start_object.emplace(element(1)); sax.pos_start_object.emplace(element(1));
//key follows same rules as string //key follows same rules as string
for (auto& el : part.items()) for (const auto& el : part.items())
{ {
std::size_t nbyteskey = 1; //type of len std::size_t nbyteskey = 1; //type of len
nbyteskey += el.key().size(); nbyteskey += el.key().size();
@ -1305,8 +1299,7 @@ void fill_expected_sax_pos_ubjson(SAX& sax, const FN& element, const nlohmann::j
break; break;
case nlohmann::json::value_t::boolean: case nlohmann::json::value_t::boolean:
{ {
std::size_t nbytes = 1; //type sax.pos_boolean.emplace(element(1)); //type
sax.pos_boolean.emplace(element(nbytes));
} }
break; break;
case nlohmann::json::value_t::number_integer: case nlohmann::json::value_t::number_integer:
@ -1442,15 +1435,14 @@ void fill_expected_sax_pos_bjdata(SAX& sax, const FN& element, const nlohmann::j
{ {
case nlohmann::json::value_t::null: case nlohmann::json::value_t::null:
{ {
std::size_t nbytes = 1; //type sax.pos_null.emplace(element(1)); //type
sax.pos_null.emplace(element(nbytes));
} }
break; break;
case nlohmann::json::value_t::object: case nlohmann::json::value_t::object:
{ {
sax.pos_start_object.emplace(element(1)); sax.pos_start_object.emplace(element(1));
//key follows same rules as string //key follows same rules as string
for (auto& el : part.items()) for (const auto& el : part.items())
{ {
std::size_t nbyteskey = 1; //type of len std::size_t nbyteskey = 1; //type of len
nbyteskey += el.key().size(); nbyteskey += el.key().size();
@ -1514,8 +1506,7 @@ void fill_expected_sax_pos_bjdata(SAX& sax, const FN& element, const nlohmann::j
break; break;
case nlohmann::json::value_t::boolean: case nlohmann::json::value_t::boolean:
{ {
std::size_t nbytes = 1; //type sax.pos_boolean.emplace(element(1)); //type
sax.pos_boolean.emplace(element(nbytes));
} }
break; break;
case nlohmann::json::value_t::number_integer: case nlohmann::json::value_t::number_integer:

View File

@ -83,13 +83,18 @@ class sax_with_token_start_stop_metadata
*/ */
explicit sax_with_token_start_stop_metadata(json& r, const bool allow_exceptions_ = true) explicit sax_with_token_start_stop_metadata(json& r, const bool allow_exceptions_ = true)
: root(r) : root(r)
, ref_stack{} , object_element{nullptr} // NOLINT(modernize-use-default-member-init)
, object_element{nullptr} , errored{false} // NOLINT(modernize-use-default-member-init)
, errored{false}
, allow_exceptions(allow_exceptions_) , allow_exceptions(allow_exceptions_)
, start_stop{}
{} {}
sax_with_token_start_stop_metadata(sax_with_token_start_stop_metadata&&) = delete;
sax_with_token_start_stop_metadata(const sax_with_token_start_stop_metadata&) = delete;
sax_with_token_start_stop_metadata& operator=(sax_with_token_start_stop_metadata&&) = delete;
sax_with_token_start_stop_metadata& operator=(const sax_with_token_start_stop_metadata&) = delete;
~sax_with_token_start_stop_metadata() = default;
void next_token_start(const nlohmann::position_t& p) void next_token_start(const nlohmann::position_t& p)
{ {
start_stop.start = p; start_stop.start = p;
@ -210,7 +215,7 @@ class sax_with_token_start_stop_metadata
return false; return false;
} }
constexpr bool is_errored() const bool is_errored() const
{ {
return errored; return errored;
} }