mirror of
https://github.com/nlohmann/json.git
synced 2026-07-09 12:05:10 +00:00
4c5b2b0666
cmake/clang_flags.cmake claimed -Wno-unsafe-buffer-usage was needed only for Doctest and that -Wno-missing-noreturn had "no way to silence... otherwise" (PR #4871, which never actually attempted a source fix). Neither held up under investigation (todo 130): - -Wno-unsafe-buffer-usage is pervasive (208 distinct sites across 19 files measured with clang trunk in silkeh/clang:dev), spanning the library's own low-level numeric/buffer code (to_chars, serializer, lexer, binary reader/writer, input adapters, json_pointer) as well as vendored Doctest itself (96 of the 208 sites). A source-level fix is not feasible at this scale; the comment now says so instead of blaming Doctest alone. - -Wno-missing-noreturn had exactly two real trigger sites, both genuinely and unconditionally non-returning: a test-only throwing allocator (tests/src/unit-allocator.cpp) and, previously undiscovered, wide_string_input_adapter::get_elements<T>() in include/nlohmann/detail/input/input_adapters.hpp. Verified this isn't a wider pattern by checking all 160 JSON_THROW call sites in the library for functions whose entire body is an unconditional throw. Annotated both ([[noreturn]] in the test file, since JSON_HEDLEY_NO_RETURN is #undef'd by the time test code runs; JSON_HEDLEY_NO_RETURN in the library file, its first real use anywhere in the codebase) and dropped the suppression entirely. single_include/nlohmann/json.hpp regenerated via `make amalgamate`; `make check-amalgamation` passes. Verified in Docker (silkeh/clang:dev, matching the ci_static_analysis_clang CI job): baseline builds clean, and the full 194-target test suite builds with zero warnings under the corrected CLANG_CXXFLAGS (-Wno-missing-noreturn no longer in the list). Also sanity-compiled and ran unit-allocator.cpp and unit-wstring.cpp on host Apple Clang to confirm behavior is unchanged. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
25 lines
1.2 KiB
CMake
25 lines
1.2 KiB
CMake
# Ignored Clang warnings:
|
|
# -Wno-c++98-compat The library targets C++11.
|
|
# -Wno-c++98-compat-pedantic The library targets C++11.
|
|
# -Wno-deprecated-declarations The library contains annotations for deprecated functions.
|
|
# -Wno-extra-semi-stmt The library uses assert which triggers this warning.
|
|
# -Wno-padded We do not care about padding warnings.
|
|
# -Wno-covered-switch-default All switches list all cases and a default case.
|
|
# -Wno-unsafe-buffer-usage Pervasive: the library's own low-level numeric/buffer code
|
|
# (to_chars, serializer, lexer, binary reader/writer, input
|
|
# adapters, json_pointer) plus vendored Doctest itself (~208
|
|
# distinct sites measured 2026-07-08 on clang trunk) all use
|
|
# raw pointer arithmetic / libc string calls by necessity.
|
|
|
|
set(CLANG_CXXFLAGS
|
|
-Werror
|
|
-Weverything
|
|
-Wno-c++98-compat
|
|
-Wno-c++98-compat-pedantic
|
|
-Wno-deprecated-declarations
|
|
-Wno-extra-semi-stmt
|
|
-Wno-padded
|
|
-Wno-covered-switch-default
|
|
-Wno-unsafe-buffer-usage
|
|
)
|