Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/danmar/cppcheck into Suppre…
Browse files Browse the repository at this point in the history
…ssCommentTags
  • Loading branch information
JohanBertrand committed Sep 3, 2023
2 parents ee32ad6 + 6817113 commit 4e633e1
Show file tree
Hide file tree
Showing 65 changed files with 2,489 additions and 721 deletions.
3 changes: 1 addition & 2 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ Checks: >
-readability-magic-numbers,
-readability-redundant-access-specifiers,
-readability-suspicious-call-argument,
-readability-uppercase-literal-suffix,
-readability-use-anyofallof
-readability-uppercase-literal-suffix
WarningsAsErrors: '*'
HeaderFilterRegex: '(cli|gui|lib|oss-fuzz|test|triage)\/[a-z]+\.h'
CheckOptions:
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/CI-cygwin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

name: CI-cygwin

on: [push,pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/CI-mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

name: CI-mingw

on: [push,pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/CI-unixish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: CI-unixish-docker

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/CI-unixish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: CI-unixish

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down Expand Up @@ -334,6 +341,7 @@ jobs:
run: |
python3 -m pip install pip --upgrade
python3 -m pip install pytest
python3 -m pip install pytest-timeout
- name: Build cppcheck
run: |
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/CI-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

name: CI-windows

on: [push,pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down Expand Up @@ -70,6 +77,7 @@ jobs:
matrix:
os: [windows-2019, windows-2022]
arch: [x64, x86]
config: [debug, release]
fail-fast: false

runs-on: ${{ matrix.os }}
Expand All @@ -82,6 +90,7 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Python 3.11
if: matrix.config == 'release'
uses: actions/setup-python@v4
with:
python-version: '3.11'
Expand Down Expand Up @@ -124,10 +133,12 @@ jobs:
CL: /MP

- name: Install missing Python packages
if: matrix.config == 'release'
run: |
python -m pip install pip --upgrade || exit /b !errorlevel!
python -m pip install pytest || exit /b !errorlevel!
python -m pip install pytest-custom_exit_code || exit /b !errorlevel!
python -m pip install pytest-timeout || exit /b !errorlevel!
- name: Run CMake
if: false # TODO: enable
Expand All @@ -139,6 +150,7 @@ jobs:
cmake -S . -B build -DBUILD_TESTS=On || exit /b !errorlevel!
- name: Build CLI debug configuration using MSBuild
if: matrix.config == 'debug'
run: |
set ARCH=${{ matrix.arch }}
if "${{ matrix.arch }}" == "x86" (
Expand All @@ -148,9 +160,11 @@ jobs:
msbuild -m cppcheck.sln /p:Configuration=Debug-PCRE;Platform=%ARCH% -maxcpucount || exit /b !errorlevel!
- name: Run Debug test
if: matrix.config == 'debug'
run: .\bin\debug\testrunner.exe || exit /b !errorlevel!

- name: Build CLI release configuration using MSBuild
if: matrix.config == 'release'
run: |
set ARCH=${{ matrix.arch }}
if "${{ matrix.arch }}" == "x86" (
Expand All @@ -160,9 +174,11 @@ jobs:
msbuild -m cppcheck.sln /p:Configuration=Release-PCRE;Platform=%ARCH% -maxcpucount || exit /b !errorlevel!
- name: Run Release test
if: matrix.config == 'release'
run: .\bin\testrunner.exe || exit /b !errorlevel!

- name: Run test/cli
if: matrix.config == 'release'
run: |
:: since FILESDIR is not set copy the binary to the root so the addons are found
:: copy .\build\bin\Release\cppcheck.exe .\cppcheck.exe || exit /b !errorlevel!
Expand All @@ -178,6 +194,7 @@ jobs:
python -m pytest test-suppress-syntaxError.py || exit /b !errorlevel!
- name: Test addons
if: matrix.config == 'release'
run: |
.\cppcheck --addon=threadsafety addons\test\threadsafety || exit /b !errorlevel!
.\cppcheck --addon=threadsafety --std=c++03 addons\test\threadsafety || exit /b !errorlevel!
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: address sanitizer

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/buildman.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: Build manual

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: clang-tidy

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: "CodeQL"

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: Coverage

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: format

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/scriptcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: scriptcheck

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/selfcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: selfcheck

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: thread sanitizer

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/ubsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: undefined behaviour sanitizers

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/valgrind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
# Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners
name: valgrind

on: [push, pull_request]
on:
push:
branches:
- 'main'
- 'releases/**'
tags:
- '2.*'
pull_request:

permissions:
contents: read
Expand Down
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ Thomas Otto
Thomas P. K. Healy
Thomas Sondergaard
Thorsten Sick
Tim Blume
Tim Gerundt
tititiou36
Tobias Weibel
Expand Down
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ LIBOBJ = $(libcppdir)/analyzerinfo.o \
$(libcppdir)/checkbufferoverrun.o \
$(libcppdir)/checkclass.o \
$(libcppdir)/checkcondition.o \
$(libcppdir)/checkersreport.o \
$(libcppdir)/checkexceptionsafety.o \
$(libcppdir)/checkfunctions.o \
$(libcppdir)/checkinternal.o \
Expand Down Expand Up @@ -488,6 +489,9 @@ $(libcppdir)/checkclass.o: lib/checkclass.cpp externals/tinyxml2/tinyxml2.h lib/
$(libcppdir)/checkcondition.o: lib/checkcondition.cpp lib/astutils.h lib/check.h lib/checkcondition.h lib/checkother.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkcondition.cpp

$(libcppdir)/checkersreport.o: lib/checkersreport.cpp lib/checkers.h lib/checkersreport.h lib/config.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/utils.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkersreport.cpp

$(libcppdir)/checkexceptionsafety.o: lib/checkexceptionsafety.cpp lib/check.h lib/checkexceptionsafety.h lib/config.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/suppressions.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h
$(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkexceptionsafety.cpp

Expand Down Expand Up @@ -638,7 +642,7 @@ $(libcppdir)/vfvalue.o: lib/vfvalue.cpp lib/config.h lib/errortypes.h lib/mathli
cli/cmdlineparser.o: cli/cmdlineparser.cpp cli/cmdlineparser.h cli/cppcheckexecutor.h cli/filelister.h externals/tinyxml2/tinyxml2.h lib/check.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/utils.h
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/cmdlineparser.cpp

cli/cppcheckexecutor.o: cli/cppcheckexecutor.cpp cli/cmdlineparser.h cli/cppcheckexecutor.h cli/cppcheckexecutorseh.h cli/cppcheckexecutorsig.h cli/executor.h cli/filelister.h cli/processexecutor.h cli/singleexecutor.h cli/threadexecutor.h lib/analyzerinfo.h lib/check.h lib/checkers.h lib/checkunusedfunctions.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h
cli/cppcheckexecutor.o: cli/cppcheckexecutor.cpp cli/cmdlineparser.h cli/cppcheckexecutor.h cli/cppcheckexecutorseh.h cli/cppcheckexecutorsig.h cli/executor.h cli/filelister.h cli/processexecutor.h cli/singleexecutor.h cli/threadexecutor.h lib/analyzerinfo.h lib/check.h lib/checkers.h lib/checkersreport.h lib/checkunusedfunctions.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/importproject.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h
$(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/cppcheckexecutor.cpp

cli/cppcheckexecutorseh.o: cli/cppcheckexecutorseh.cpp cli/cppcheckexecutor.h cli/cppcheckexecutorseh.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/utils.h
Expand Down
10 changes: 10 additions & 0 deletions addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1457,6 +1457,15 @@ def _save_ctu_summary_usage(self, dumpfile, cfg):
cppcheckdata.reportSummary(dumpfile, 'MisraUsage', names)


def misra_1_2(self, cfg):
# gcc language extensions: https://gcc.gnu.org/onlinedocs/gcc/C-Extensions.html
for token in cfg.tokenlist:
if simpleMatch(token, '? :'):
self.reportError(token, 1, 2)
elif simpleMatch(token, '( {') and simpleMatch(token.next.link.previous, '; } )'):
self.reportError(token, 1, 2)


def misra_1_4(self, cfg):
for token in cfg.tokenlist:
if token.str in ('_Atomic', '_Noreturn', '_Generic', '_Thread_local', '_Alignas', '_Alignof'):
Expand Down Expand Up @@ -4311,6 +4320,7 @@ def fillVerifyExpected(verify_expected, tok):
if not self.settings.quiet:
self.printStatus('Checking %s, config %s...' % (dumpfile, cfg.name))

self.executeCheck(102, self.misra_1_2, cfg)
if not path_premium_addon:
self.executeCheck(104, self.misra_1_4, cfg)
self.executeCheck(202, self.misra_2_2, cfg)
Expand Down
Loading

0 comments on commit 4e633e1

Please sign in to comment.