Fix CI: unused parameter without exceptions, cpplint, BUILD.bazel

- json_sax_error_reporter::parse_error: mark the exception unused, as
  JSON_THROW does not use it with JSON_NOEXCEPTION
- unit-contiguous_parser.cpp: compare the exceptions of both paths only
  when exceptions are enabled (invalid input aborted the test otherwise)
- silence cpplint's readability/braces false positives on the if
  statements inside the parser's macros
- add contiguous_parser.hpp to BUILD.bazel

Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
Niels Lohmann committed 2026-11-06 12:09:24 +01:00
1 parent 933952e095
commit 2eb9aae537
4 files changed
+18 -14

No files matched your search

+6 -5
View File
@@ -23962,7 +23962,7 @@ class contiguous_parser
#define JSON_CONTIGUOUS_OPEN(is_object) \
do \
{ \
if (JSON_HEDLEY_UNLIKELY(depth != 0 && (depth % 64) == 0)) \
if (JSON_HEDLEY_UNLIKELY(depth != 0 && (depth % 64) == 0)) /* NOLINT(readability/braces) */ \
{ \
outer.push_back(kinds); \
kinds = 0; \
@@ -24068,13 +24068,13 @@ class contiguous_parser
// what may follow a value in an array: a comma and the next value, or the end
#define JSON_CONTIGUOUS_AFTER_ELEMENT \
JSON_CONTIGUOUS_WS(); \
if (JSON_HEDLEY_LIKELY(JSON_CONTIGUOUS_CUR() == ',')) \
if (JSON_HEDLEY_LIKELY(JSON_CONTIGUOUS_CUR() == ',')) /* NOLINT(readability/braces) */ \
{ \
++p; \
JSON_CONTIGUOUS_WS(); \
goto array_value; \
} \
if (JSON_HEDLEY_LIKELY(JSON_CONTIGUOUS_CUR() == ']')) \
if (JSON_HEDLEY_LIKELY(JSON_CONTIGUOUS_CUR() == ']')) /* NOLINT(readability/braces) */ \
{ \
++p; \
if (JSON_HEDLEY_UNLIKELY(!report(sax->end_array()))) \
@@ -24088,13 +24088,13 @@ class contiguous_parser
// what may follow a value in an object: a comma and the next member, or the end
#define JSON_CONTIGUOUS_AFTER_MEMBER \
JSON_CONTIGUOUS_WS(); \
if (JSON_HEDLEY_LIKELY(JSON_CONTIGUOUS_CUR() == ',')) \
if (JSON_HEDLEY_LIKELY(JSON_CONTIGUOUS_CUR() == ',')) /* NOLINT(readability/braces) */ \
{ \
++p; \
JSON_CONTIGUOUS_WS(); \
goto object_key; \
} \
if (JSON_HEDLEY_LIKELY(JSON_CONTIGUOUS_CUR() == '}')) \
if (JSON_HEDLEY_LIKELY(JSON_CONTIGUOUS_CUR() == '}')) /* NOLINT(readability/braces) */ \
{ \
++p; \
if (JSON_HEDLEY_UNLIKELY(!report(sax->end_object()))) \
@@ -24678,6 +24678,7 @@ class json_sax_error_reporter : public json_sax_acceptor<BasicJsonType>
template<class Exception>
bool parse_error(std::size_t /*unused*/, const std::string& /*unused*/, const Exception& ex)
{
static_cast<void>(ex); // (unused without exceptions)
if (allow_exceptions)
{
JSON_THROW(ex);