diff --git a/.github/workflows/CI-unixish-docker.yml b/.github/workflows/CI-unixish-docker.yml index f23f4363b..2eac834c5 100644 --- a/.github/workflows/CI-unixish-docker.yml +++ b/.github/workflows/CI-unixish-docker.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: - image: ["centos:7", "ubuntu:14.04", "ubuntu:21.04"] + image: ["centos:7", "ubuntu:14.04", "ubuntu:16.04", "ubuntu:21.04"] fail-fast: false # Prefer quick result runs-on: ubuntu-20.04 @@ -30,7 +30,7 @@ jobs: if: matrix.image != 'centos:7' run: | apt-get update - apt-get install -y cmake g++ make + apt-get install -y cmake g++ make python libxml2-utils apt-get install -y libpcre3-dev # tests require CMake 3.4 @@ -65,6 +65,10 @@ jobs: run: | make -j$(nproc) check HAVE_RULES=yes + - name: Validate + run: | + make -j$(nproc) checkCWEEntries validateXML + - name: Test addons run: | ./cppcheck --addon=threadsafety addons/test/threadsafety diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml index f68af6b50..a0d4f7972 100644 --- a/.github/workflows/CI-unixish.yml +++ b/.github/workflows/CI-unixish.yml @@ -58,6 +58,10 @@ jobs: make -j$(nproc) CXXFLAGS=-funsigned-char testrunner ./testrunner TestSymbolDatabase + - name: Check syntax with NONNEG + run: | + ls lib/*.cpp | xargs -n 1 -P $(nproc) g++ -fsyntax-only -std=c++0x -Ilib -Iexternals -Iexternals/picojson -Iexternals/simplecpp -Iexternals/tinyxml2 -DNONNEG + - name: Build cppcheck run: | make clean @@ -73,8 +77,8 @@ jobs: - name: Validate run: | - make -j$(nproc) validateCFG validatePlatforms - + make -j$(nproc) checkCWEEntries validateXML + - name: Test addons run: | ./cppcheck --addon=threadsafety addons/test/threadsafety diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml index 52fdaa0d3..79ee2343c 100644 --- a/.github/workflows/asan.yml +++ b/.github/workflows/asan.yml @@ -19,7 +19,7 @@ jobs: - name: Build run: | - CC=clang CXX=clang++ CXXFLAGS="-fsanitize=address -O1 -g3 -DCPPCHK_GLIBCXX_DEBUG" CPPFLAGS="-DCHECK_INTERNAL" make cppcheck testrunner -j$(nproc) USE_Z3=yes HAVE_RULES=yes MATCHCOMPILER=yes VERIFY=1 + CC=clang CXX=clang++ CXXFLAGS="-fsanitize=address -O1 -g3 -DCPPCHK_GLIBCXX_DEBUG" CPPFLAGS="-DCHECK_INTERNAL" make -j$(nproc) cppcheck testrunner USE_Z3=yes HAVE_RULES=yes MATCHCOMPILER=yes VERIFY=1 - name: Run tests run: | diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 4d85940a8..309848822 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -24,7 +24,7 @@ jobs: - name: Compile instrumented run: | - make test CXXFLAGS="-g -fprofile-arcs -ftest-coverage" USE_Z3=yes HAVE_RULES=yes -j$(nproc) + make -j$(nproc) test CXXFLAGS="-g -fprofile-arcs -ftest-coverage" USE_Z3=yes HAVE_RULES=yes - name: Generate coverage report run: | diff --git a/.github/workflows/scriptcheck.yml b/.github/workflows/scriptcheck.yml index 624ac74bf..029a235e9 100644 --- a/.github/workflows/scriptcheck.yml +++ b/.github/workflows/scriptcheck.yml @@ -29,7 +29,7 @@ jobs: - name: Install missing software on ubuntu (Python 3) if: matrix.python-version != '2.7' run: | - sudo apt-get install shellcheck + sudo apt-get install shellcheck libxml2-utils python -m pip install pip --upgrade python -m pip install natsort python -m pip install pexpect @@ -57,6 +57,11 @@ jobs: run: | find . -name '*.json' | xargs -n 1 python -m json.tool > /dev/null + - name: Validate + if: matrix.python-version == '3.8' + run: | + make -j$(nproc) validateCFG validatePlatforms validateRules + - name: check python syntax if: matrix.python-version != '2.7' run: | @@ -71,3 +76,9 @@ jobs: run: | make -j$(nproc) -s PYTHONPATH=./addons python -m pytest addons/test/test-*.py + + - name: dmake + if: matrix.python-version == '3.8' + run: | + make -j$(nproc) run-dmake + git diff --exit-code diff --git a/.github/workflows/ubsan.yml b/.github/workflows/ubsan.yml index dae34f947..69d81607d 100644 --- a/.github/workflows/ubsan.yml +++ b/.github/workflows/ubsan.yml @@ -19,7 +19,7 @@ jobs: - name: Build run: | - CC=clang CXX=clang++ CXXFLAGS="-fsanitize=undefined -fsanitize=nullability -fno-sanitize=signed-integer-overflow -O1 -g3 -DCPPCHK_GLIBCXX_DEBUG" CPPFLAGS="-DCHECK_INTERNAL" make cppcheck testrunner -j$(nproc) USE_Z3=yes HAVE_RULES=yes MATCHCOMPILER=yes VERIFY=1 + CC=clang CXX=clang++ CXXFLAGS="-fsanitize=undefined -fsanitize=nullability -fno-sanitize=signed-integer-overflow -O1 -g3 -DCPPCHK_GLIBCXX_DEBUG" CPPFLAGS="-DCHECK_INTERNAL" make -j$(nproc) cppcheck testrunner USE_Z3=yes HAVE_RULES=yes MATCHCOMPILER=yes VERIFY=1 - name: Run tests run: | diff --git a/.travis.yml b/.travis.yml index 0d0eef52f..d66fbdf73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,12 +7,10 @@ compiler: env: global: - - ORIGINAL_CXXFLAGS="-pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -D_GLIBCXX_DEBUG -g " + - ORIGINAL_CXXFLAGS="-pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -D_GLIBCXX_DEBUG -g" # unfortunately we need this to stay within 50min timelimit given by travis. - CXXFLAGS="${ORIGINAL_CXXFLAGS} -O2 -march=native -Wstrict-aliasing=2 -Werror=strict-aliasing" - CPPCHECK=${TRAVIS_BUILD_DIR}/cppcheck - - ASAN_OPTIONS=detect_stack_use_after_return=1 - - UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 matrix: - CXXFLAGS="${CXXFLAGS} -DCHECK_INTERNAL" - CXXFLAGS="${CXXFLAGS} -DCHECK_INTERNAL" MAKEFLAGS="HAVE_RULES=yes" MATCHCOMPILER=yes VERIFY=1 @@ -39,9 +37,6 @@ before_install: matrix: # do notify immediately about it when a job of a build fails. fast_finish: true - allow_failures: - - name: "rerun dmake?" - compiler: clang # defined extra jobs that run besides what is configured in the build matrix include: @@ -56,12 +51,8 @@ matrix: - make checkCWEEntries # check cfg files - make checkcfg -# check platform files - - make validatePlatforms # Validate Result XML - make validateXML -# Validate rule files - - make validateRules # check htmlreport stuff - python2 htmlreport/test_htmlreport.py - python3 htmlreport/test_htmlreport.py @@ -147,18 +138,6 @@ matrix: - cd - - python3 test/bug-hunting/juliet.py -# check if dmake needs to be rerun (this job may fail) - - name: "rerun dmake?" - compiler: clang -# we don't need to install any deps for dmake so skip it explicitly - before_install: - - true - script: - - echo "If the following command fails, run 'make dmake; make run-dmake' and commit the resulting change." - - make -s dmake -j$(nproc) - - make -s run-dmake - - git diff --exit-code - script: # fail the entire job as soon as one of the subcommands exits non-zero to save time and resources - set -e @@ -169,8 +148,6 @@ script: - echo $CXXFLAGS - make -s check -j$(nproc) CPPFLAGS=-DTEST_MATHLIB_VALUE - touch lib/mathlib.cpp test/testmathlib.cpp -# syntax checking of cppcheck source code with -DNONNEG - - ls lib/*.cpp | xargs -n 1 -P 2 g++ -fsyntax-only -std=c++0x -Ilib -Iexternals -Iexternals/picojson -Iexternals/simplecpp -Iexternals/tinyxml2 -DNONNEG # compile cppcheck, default build - echo $CXXFLAGS - make -s check -j$(nproc) @@ -182,12 +159,3 @@ script: # Testing addons (disabled 2020-11-24 because Travis fails, TODO try to enable these) # - PYTHONPATH=./addons python -m pytest addons/test/test-*.py # - PYTHONPATH=./addons python3 -m pytest addons/test/test-*.py - -notifications: - irc: - channels: - - "irc.freenode.org#cppcheck" - template: - - "[%{commit} : %{author}] %{message}" - - "%{build_url}" - skip_join: true diff --git a/Makefile b/Makefile index a8c697dac..435779e8c 100644 --- a/Makefile +++ b/Makefile @@ -775,7 +775,7 @@ test/testunusedprivfunc.o: test/testunusedprivfunc.cpp externals/simplecpp/simpl test/testunusedvar.o: test/testunusedvar.cpp externals/simplecpp/simplecpp.h lib/check.h lib/checkunusedvar.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h test/testsuite.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testunusedvar.o test/testunusedvar.cpp -test/testutils.o: test/testutils.cpp lib/config.h lib/errorlogger.h lib/errortypes.h lib/suppressions.h lib/utils.h test/testsuite.h +test/testutils.o: test/testutils.cpp lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h test/testsuite.h test/testutils.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CPPFILESDIR) $(CXXFLAGS) $(UNDEF_STRICT_ANSI) -c -o test/testutils.o test/testutils.cpp test/testvaarg.o: test/testvaarg.cpp lib/check.h lib/checkvaarg.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h test/testsuite.h