mirror of
https://github.com/nlohmann/json.git
synced 2024-11-27 16:49:02 +08:00
🚨 adding targets for static analyzers
This commit is contained in:
parent
baf8b4be7c
commit
d6c4cd3b6d
205
Makefile
205
Makefile
@ -49,6 +49,9 @@ all:
|
|||||||
@echo "clean - remove built files"
|
@echo "clean - remove built files"
|
||||||
@echo "coverage - create coverage information with lcov"
|
@echo "coverage - create coverage information with lcov"
|
||||||
@echo "cppcheck - analyze code with cppcheck"
|
@echo "cppcheck - analyze code with cppcheck"
|
||||||
|
@echo "cpplint - analyze code with cpplint"
|
||||||
|
@echo "clang_tidy - analyze code with Clang-Tidy"
|
||||||
|
@echo "clang_analyze - analyze code with Clang-Analyzer"
|
||||||
@echo "doctest - compile example files and check their output"
|
@echo "doctest - compile example files and check their output"
|
||||||
@echo "fuzz_testing - prepare fuzz testing of the JSON parser"
|
@echo "fuzz_testing - prepare fuzz testing of the JSON parser"
|
||||||
@echo "fuzz_testing_bson - prepare fuzz testing of the BSON parser"
|
@echo "fuzz_testing_bson - prepare fuzz testing of the BSON parser"
|
||||||
@ -123,7 +126,7 @@ doctest:
|
|||||||
# -Wno-c++2a-compat: u8 literals will behave differently in C++20...
|
# -Wno-c++2a-compat: u8 literals will behave differently in C++20...
|
||||||
# -Wno-padded: padding is nothing to warn about
|
# -Wno-padded: padding is nothing to warn about
|
||||||
pedantic_clang:
|
pedantic_clang:
|
||||||
$(MAKE) json_unit CXX=$(COMPILER_DIR)/clang++ CXXFLAGS="\
|
$(MAKE) json_unit CXX=$(COMPILER_DIR)/clang++ CXXFLAGS=" \
|
||||||
-std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \
|
-std=c++11 -Wno-c++98-compat -Wno-c++98-compat-pedantic \
|
||||||
-Werror \
|
-Werror \
|
||||||
-Weverything \
|
-Weverything \
|
||||||
@ -141,68 +144,229 @@ pedantic_clang:
|
|||||||
|
|
||||||
# calling GCC with most warnings
|
# calling GCC with most warnings
|
||||||
pedantic_gcc:
|
pedantic_gcc:
|
||||||
$(MAKE) json_unit CXX=$(COMPILER_DIR)/g++ CXXFLAGS="\
|
$(MAKE) json_unit CXX=$(COMPILER_DIR)/g++ CXXFLAGS=" \
|
||||||
-std=c++11 \
|
-std=c++11 \
|
||||||
-Wno-deprecated-declarations \
|
-Waddress \
|
||||||
-Werror \
|
-Waddress-of-packed-member \
|
||||||
-Wall -Wpedantic -Wextra \
|
-Waggressive-loop-optimizations \
|
||||||
|
-Waligned-new=all \
|
||||||
|
-Wall \
|
||||||
|
-Walloc-zero \
|
||||||
-Walloca \
|
-Walloca \
|
||||||
|
-Warray-bounds \
|
||||||
-Warray-bounds=2 \
|
-Warray-bounds=2 \
|
||||||
-Wcast-qual -Wcast-align \
|
-Wattribute-alias=2 \
|
||||||
|
-Wattribute-warning \
|
||||||
|
-Wattributes \
|
||||||
|
-Wbool-compare \
|
||||||
|
-Wbool-operation \
|
||||||
|
-Wbuiltin-declaration-mismatch \
|
||||||
|
-Wbuiltin-macro-redefined \
|
||||||
|
-Wcannot-profile \
|
||||||
|
-Wcast-align \
|
||||||
|
-Wcast-function-type \
|
||||||
|
-Wcast-qual \
|
||||||
|
-Wcatch-value=3 \
|
||||||
-Wchar-subscripts \
|
-Wchar-subscripts \
|
||||||
|
-Wclass-conversion \
|
||||||
|
-Wclass-memaccess \
|
||||||
|
-Wclobbered \
|
||||||
|
-Wcomment \
|
||||||
|
-Wcomments \
|
||||||
-Wconditionally-supported \
|
-Wconditionally-supported \
|
||||||
-Wconversion \
|
-Wconversion \
|
||||||
|
-Wconversion-null \
|
||||||
|
-Wcoverage-mismatch \
|
||||||
|
-Wcpp \
|
||||||
|
-Wctor-dtor-privacy \
|
||||||
|
-Wdangling-else \
|
||||||
-Wdate-time \
|
-Wdate-time \
|
||||||
|
-Wdelete-incomplete \
|
||||||
|
-Wdelete-non-virtual-dtor \
|
||||||
-Wdeprecated \
|
-Wdeprecated \
|
||||||
|
-Wdeprecated-copy \
|
||||||
|
-Wdeprecated-copy-dtor \
|
||||||
|
-Wdeprecated-declarations \
|
||||||
-Wdisabled-optimization \
|
-Wdisabled-optimization \
|
||||||
|
-Wdiv-by-zero \
|
||||||
-Wdouble-promotion \
|
-Wdouble-promotion \
|
||||||
-Wduplicated-branches \
|
-Wduplicated-branches \
|
||||||
-Wduplicated-cond \
|
-Wduplicated-cond \
|
||||||
|
-Wempty-body \
|
||||||
|
-Wendif-labels \
|
||||||
|
-Wenum-compare \
|
||||||
|
-Werror \
|
||||||
|
-Wextra \
|
||||||
|
-Wextra-semi \
|
||||||
|
-Wfloat-conversion \
|
||||||
|
-Wfloat-equal \
|
||||||
|
-Wformat \
|
||||||
|
-Wformat-contains-nul \
|
||||||
|
-Wformat-extra-args \
|
||||||
|
-Wformat-nonliteral \
|
||||||
-Wformat-overflow=2 \
|
-Wformat-overflow=2 \
|
||||||
|
-Wformat-security \
|
||||||
-Wformat-signedness \
|
-Wformat-signedness \
|
||||||
-Wformat-truncation=2 \
|
-Wformat-truncation=2 \
|
||||||
|
-Wformat-y2k \
|
||||||
|
-Wformat-zero-length \
|
||||||
-Wformat=2 \
|
-Wformat=2 \
|
||||||
-Wno-ignored-qualifiers \
|
-Wframe-address \
|
||||||
|
-Wfree-nonheap-object \
|
||||||
|
-Whsa \
|
||||||
|
-Wif-not-aligned \
|
||||||
|
-Wignored-attributes \
|
||||||
|
-Wignored-qualifiers \
|
||||||
-Wimplicit-fallthrough=5 \
|
-Wimplicit-fallthrough=5 \
|
||||||
|
-Winherited-variadic-ctor \
|
||||||
|
-Winit-list-lifetime \
|
||||||
|
-Winit-self \
|
||||||
|
-Winline \
|
||||||
|
-Wint-in-bool-context \
|
||||||
|
-Wint-to-pointer-cast \
|
||||||
|
-Winvalid-memory-model \
|
||||||
|
-Winvalid-offsetof \
|
||||||
|
-Winvalid-pch \
|
||||||
|
-Wliteral-suffix \
|
||||||
|
-Wlogical-not-parentheses \
|
||||||
-Wlogical-op \
|
-Wlogical-op \
|
||||||
|
-Wlto-type-mismatch \
|
||||||
|
-Wmain \
|
||||||
|
-Wmaybe-uninitialized \
|
||||||
|
-Wmemset-elt-size \
|
||||||
|
-Wmemset-transposed-args \
|
||||||
|
-Wmisleading-indentation \
|
||||||
|
-Wmissing-attributes \
|
||||||
|
-Wmissing-braces \
|
||||||
-Wmissing-declarations \
|
-Wmissing-declarations \
|
||||||
|
-Wmissing-field-initializers \
|
||||||
-Wmissing-format-attribute \
|
-Wmissing-format-attribute \
|
||||||
-Wmissing-include-dirs \
|
-Wmissing-include-dirs \
|
||||||
|
-Wmissing-noreturn \
|
||||||
|
-Wmissing-profile \
|
||||||
|
-Wmultichar \
|
||||||
|
-Wmultiple-inheritance \
|
||||||
|
-Wmultistatement-macros \
|
||||||
|
-Wnarrowing \
|
||||||
|
-Wno-deprecated-declarations \
|
||||||
|
-Wno-effc++ \
|
||||||
|
-Wno-expansion-to-defined \
|
||||||
|
-Wno-ignored-qualifiers \
|
||||||
|
-Wno-long-long \
|
||||||
|
-Wno-namespaces \
|
||||||
|
-Wno-padded \
|
||||||
|
-Wno-switch-default \
|
||||||
|
-Wno-switch-enum \
|
||||||
|
-Wno-system-headers \
|
||||||
|
-Wno-templates \
|
||||||
|
-Wno-undef \
|
||||||
-Wnoexcept \
|
-Wnoexcept \
|
||||||
|
-Wnoexcept-type \
|
||||||
|
-Wnon-template-friend \
|
||||||
|
-Wnon-virtual-dtor \
|
||||||
-Wnonnull \
|
-Wnonnull \
|
||||||
|
-Wnonnull-compare \
|
||||||
|
-Wnonportable-cfstrings \
|
||||||
|
-Wnormalized \
|
||||||
-Wnull-dereference \
|
-Wnull-dereference \
|
||||||
|
-Wodr \
|
||||||
-Wold-style-cast \
|
-Wold-style-cast \
|
||||||
|
-Wopenmp-simd \
|
||||||
|
-Woverflow \
|
||||||
|
-Woverlength-strings \
|
||||||
-Woverloaded-virtual \
|
-Woverloaded-virtual \
|
||||||
|
-Wpacked \
|
||||||
|
-Wpacked-bitfield-compat \
|
||||||
|
-Wpacked-not-aligned \
|
||||||
-Wparentheses \
|
-Wparentheses \
|
||||||
|
-Wpedantic \
|
||||||
|
-Wpessimizing-move \
|
||||||
-Wplacement-new=2 \
|
-Wplacement-new=2 \
|
||||||
|
-Wpmf-conversions \
|
||||||
|
-Wpointer-arith \
|
||||||
|
-Wpointer-compare \
|
||||||
|
-Wpragmas \
|
||||||
|
-Wprio-ctor-dtor \
|
||||||
|
-Wpsabi \
|
||||||
-Wredundant-decls \
|
-Wredundant-decls \
|
||||||
|
-Wredundant-move \
|
||||||
|
-Wregister \
|
||||||
-Wreorder \
|
-Wreorder \
|
||||||
-Wrestrict \
|
-Wrestrict \
|
||||||
|
-Wreturn-local-addr \
|
||||||
|
-Wreturn-type \
|
||||||
|
-Wscalar-storage-order \
|
||||||
|
-Wsequence-point \
|
||||||
|
-Wshadow \
|
||||||
|
-Wshadow-compatible-local \
|
||||||
|
-Wshadow-local \
|
||||||
|
-Wshadow=compatible-local \
|
||||||
-Wshadow=global \
|
-Wshadow=global \
|
||||||
|
-Wshadow=local \
|
||||||
|
-Wshift-count-negative \
|
||||||
|
-Wshift-count-overflow \
|
||||||
|
-Wshift-negative-value \
|
||||||
-Wshift-overflow=2 \
|
-Wshift-overflow=2 \
|
||||||
|
-Wsign-compare \
|
||||||
-Wsign-conversion \
|
-Wsign-conversion \
|
||||||
-Wsign-promo \
|
-Wsign-promo \
|
||||||
-Wsized-deallocation \
|
-Wsized-deallocation \
|
||||||
|
-Wsizeof-array-argument \
|
||||||
|
-Wsizeof-pointer-div \
|
||||||
|
-Wsizeof-pointer-memaccess \
|
||||||
|
-Wstack-protector \
|
||||||
|
-Wstrict-aliasing=3 \
|
||||||
|
-Wstrict-null-sentinel \
|
||||||
-Wstrict-overflow=5 \
|
-Wstrict-overflow=5 \
|
||||||
|
-Wstringop-overflow=4 \
|
||||||
|
-Wstringop-truncation \
|
||||||
|
-Wsubobject-linkage \
|
||||||
|
-Wsuggest-attribute=cold \
|
||||||
-Wsuggest-attribute=const \
|
-Wsuggest-attribute=const \
|
||||||
-Wsuggest-attribute=format \
|
-Wsuggest-attribute=format \
|
||||||
|
-Wsuggest-attribute=malloc \
|
||||||
-Wsuggest-attribute=noreturn \
|
-Wsuggest-attribute=noreturn \
|
||||||
-Wsuggest-attribute=pure \
|
-Wsuggest-attribute=pure \
|
||||||
-Wsuggest-final-methods \
|
-Wsuggest-final-methods \
|
||||||
-Wsuggest-final-types \
|
-Wsuggest-final-types \
|
||||||
-Wsuggest-override \
|
-Wsuggest-override \
|
||||||
|
-Wswitch \
|
||||||
|
-Wswitch-bool \
|
||||||
|
-Wswitch-unreachable \
|
||||||
|
-Wsync-nand \
|
||||||
|
-Wsynth \
|
||||||
|
-Wtautological-compare \
|
||||||
|
-Wterminate \
|
||||||
|
-Wtrampolines \
|
||||||
-Wtrigraphs \
|
-Wtrigraphs \
|
||||||
-Wundef \
|
-Wtype-limits \
|
||||||
-Wuninitialized -Wunknown-pragmas \
|
-Wuninitialized \
|
||||||
|
-Wunknown-pragmas \
|
||||||
|
-Wunreachable-code \
|
||||||
|
-Wunsafe-loop-optimizations \
|
||||||
-Wunused \
|
-Wunused \
|
||||||
|
-Wunused-but-set-parameter \
|
||||||
|
-Wunused-but-set-variable \
|
||||||
-Wunused-const-variable=2 \
|
-Wunused-const-variable=2 \
|
||||||
|
-Wunused-function \
|
||||||
|
-Wunused-label \
|
||||||
|
-Wunused-local-typedefs \
|
||||||
-Wunused-macros \
|
-Wunused-macros \
|
||||||
-Wunused-parameter \
|
-Wunused-parameter \
|
||||||
|
-Wunused-result \
|
||||||
|
-Wunused-value \
|
||||||
|
-Wunused-variable \
|
||||||
-Wuseless-cast \
|
-Wuseless-cast \
|
||||||
|
-Wvarargs \
|
||||||
-Wvariadic-macros \
|
-Wvariadic-macros \
|
||||||
-Wctor-dtor-privacy \
|
-Wvector-operation-performance \
|
||||||
-Winit-self \
|
-Wvirtual-inheritance \
|
||||||
-Wstrict-null-sentinel"
|
-Wvirtual-move-assign \
|
||||||
|
-Wvla \
|
||||||
|
-Wvolatile-register-var \
|
||||||
|
-Wwrite-strings \
|
||||||
|
-Wzero-as-null-pointer-constant \
|
||||||
|
"
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# benchmarks
|
# benchmarks
|
||||||
@ -279,7 +443,7 @@ fuzzing-stop:
|
|||||||
|
|
||||||
# call cppcheck on the main header file
|
# call cppcheck on the main header file
|
||||||
cppcheck:
|
cppcheck:
|
||||||
cppcheck --enable=warning --inconclusive --force --std=c++11 $(AMALGAMATED_FILE) --error-exitcode=1
|
cppcheck --enable=warning --inconclusive --force --std=c++11 $(SRCS) --error-exitcode=1
|
||||||
|
|
||||||
# compile and check with Clang Static Analyzer
|
# compile and check with Clang Static Analyzer
|
||||||
clang_analyze:
|
clang_analyze:
|
||||||
@ -288,6 +452,21 @@ clang_analyze:
|
|||||||
cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja
|
cd clang_analyze_build ; CCC_CXX=$(COMPILER_DIR)/clang++ CXX=$(COMPILER_DIR)/clang++ $(COMPILER_DIR)/scan-build cmake .. -GNinja
|
||||||
cd clang_analyze_build ; $(COMPILER_DIR)/scan-build -enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull --use-c++=$(COMPILER_DIR)/clang++ --view -analyze-headers -o clang_analyze_build/report.html ninja
|
cd clang_analyze_build ; $(COMPILER_DIR)/scan-build -enable-checker alpha.core.BoolAssignment,alpha.core.CallAndMessageUnInitRefArg,alpha.core.CastSize,alpha.core.CastToStruct,alpha.core.Conversion,alpha.core.DynamicTypeChecker,alpha.core.FixedAddr,alpha.core.PointerArithm,alpha.core.PointerSub,alpha.core.SizeofPtr,alpha.core.StackAddressAsyncEscape,alpha.core.TestAfterDivZero,alpha.deadcode.UnreachableCode,core.builtin.BuiltinFunctions,core.builtin.NoReturnFunctions,core.CallAndMessage,core.DivideZero,core.DynamicTypePropagation,core.NonnilStringConstants,core.NonNullParamChecker,core.NullDereference,core.StackAddressEscape,core.UndefinedBinaryOperatorResult,core.uninitialized.ArraySubscript,core.uninitialized.Assign,core.uninitialized.Branch,core.uninitialized.CapturedBlockVariable,core.uninitialized.UndefReturn,core.VLASize,cplusplus.InnerPointer,cplusplus.Move,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,cplusplus.SelfAssignment,deadcode.DeadStores,nullability.NullableDereferenced,nullability.NullablePassedToNonnull,nullability.NullableReturnedFromNonnull,nullability.NullPassedToNonnull,nullability.NullReturnedFromNonnull --use-c++=$(COMPILER_DIR)/clang++ --view -analyze-headers -o clang_analyze_build/report.html ninja
|
||||||
|
|
||||||
|
# call cpplint (some errors expected due to false positives)
|
||||||
|
cpplint:
|
||||||
|
third_party/cpplint/cpplint.py --filter=-whitespace,-legal,-readability/alt_tokens,-runtime/references,-runtime/explicit --quiet --recursive include
|
||||||
|
|
||||||
|
clang_tidy:
|
||||||
|
$(COMPILER_DIR)/clang-tidy -checks='-*, readability-*, -readability-magic-numbers, -readability-uppercase-literal-suffix, modernize-*, bugprone-*, performance-*, clang-analyzer-*, portability-*, cert-*, hicpp-*, -hicpp-no-array-decay, -hicpp-uppercase-literal-suffix, google-*, -google-runtime-references' $(SRCS) -- -Iinclude -std=c++11
|
||||||
|
|
||||||
|
pvs_studio:
|
||||||
|
rm -fr pvs_studio_build
|
||||||
|
mkdir pvs_studio_build
|
||||||
|
cd pvs_studio_build ; cmake .. -DCMAKE_EXPORT_COMPILE_COMMANDS=On
|
||||||
|
cd pvs_studio_build ; pvs-studio-analyzer analyze -j 10
|
||||||
|
cd pvs_studio_build ; plog-converter -a'GA:1,2;64:1;CS' -t fullhtml PVS-Studio.log -o pvs
|
||||||
|
open pvs_studio_build/pvs/index.html
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# maintainer targets
|
# maintainer targets
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
Loading…
Reference in New Issue
Block a user