pax_global_header00006660000000000000000000000064147576076110014530gustar00rootroot0000000000000052 comment=ac9db3069b9f90e81e126a090b99ad456e122cf8 cppcheck-2.17.1/000077500000000000000000000000001475760761100134005ustar00rootroot00000000000000cppcheck-2.17.1/.clang-tidy000066400000000000000000000053271475760761100154430ustar00rootroot00000000000000--- Checks: > *, -abseil-*, -altera-*, -android-*, -boost-*, -cert-*, -cppcoreguidelines-*, -darwin-*, -fuchsia-*, -google-*, -hicpp-*, -linuxkernel-*, -llvm-*, -llvmlibc-*, -mpi-*, -objc-*, -openmp-*, -zircon-*, cert-err34-c, cppcoreguidelines-pro-type-static-cast-downcast, cppcoreguidelines-rvalue-reference-param-not-moved, google-explicit-constructor, -bugprone-assignment-in-if-condition, -bugprone-branch-clone, -bugprone-easily-swappable-parameters, -bugprone-empty-catch, -bugprone-macro-parentheses, -bugprone-narrowing-conversions, -bugprone-signed-char-misuse, -bugprone-switch-missing-default-case, -bugprone-unchecked-optional-access, -clang-analyzer-*, -concurrency-mt-unsafe, -misc-const-correctness, -misc-no-recursion, -misc-non-private-member-variables-in-classes, -misc-throw-by-value-catch-by-reference, -misc-use-anonymous-namespace, -modernize-avoid-c-arrays, -modernize-deprecated-ios-base-aliases, -misc-include-cleaner, -misc-unused-using-decls, -modernize-loop-convert, -modernize-macro-to-enum, -modernize-raw-string-literal, -modernize-replace-auto-ptr, -modernize-return-braced-init-list, -modernize-type-traits, -modernize-use-designated-initializers, -modernize-use-nodiscard, -modernize-use-trailing-return-type, -performance-avoid-endl, -performance-inefficient-string-concatenation, -performance-no-automatic-move, -portability-simd-intrinsics, -portability-std-allocator-const, -readability-avoid-nested-conditional-operator, -readability-braces-around-statements, -readability-container-data-pointer, -readability-enum-initial-value, -readability-function-cognitive-complexity, -readability-function-size, -readability-identifier-length, -readability-identifier-naming, -readability-implicit-bool-conversion, -readability-isolate-declaration, -readability-magic-numbers, -readability-suspicious-call-argument, -readability-uppercase-literal-suffix WarningsAsErrors: '*' HeaderFilterRegex: '(cli|gui|lib|oss-fuzz|test|triage)\/[a-z]+\.h' CheckOptions: - key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic value: '1' - key: readability-simplify-boolean-expr.SimplifyDeMorgan value: '0' cppcheck-2.17.1/.codacy.yml000066400000000000000000000002461475760761100154450ustar00rootroot00000000000000exclude_paths: - addons/test/** - addons/y2038/test/*.c - htmlreport/example.cc - samples/**/bad.c - samples/**/bad.cpp - test/cfg/*.c - test/cfg/*.cpp cppcheck-2.17.1/.gitattributes000066400000000000000000000007041475760761100162740ustar00rootroot00000000000000## standard default enconding * text=auto ## UNIX specific files *.sh text eol=lf ## Windows specific files *.bat text eol=crlf *.cmd text eol=crlf *.ps1 text eol=crlf *.vcxproj text eol=crlf *.vcxproj.filters text eol=crlf *.sln text eol=crlf *.wixproj text eol=crlf *.wxi text eol=crlf *.wxs text eol=crlf ## Binary resources *.pdf binarycppcheck-2.17.1/.github/000077500000000000000000000000001475760761100147405ustar00rootroot00000000000000cppcheck-2.17.1/.github/workflows/000077500000000000000000000000001475760761100167755ustar00rootroot00000000000000cppcheck-2.17.1/.github/workflows/CI-cygwin.yml000066400000000000000000000033561475760761100213200ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: CI-cygwin on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read defaults: run: shell: cmd jobs: # TODO: add CMake build build_cygwin: strategy: matrix: os: [windows-2022] platform: [x86_64] include: - platform: 'x86_64' packages: | gcc-g++ python3 fail-fast: false runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Set up Cygwin uses: cygwin/cygwin-install-action@master with: platform: ${{ matrix.platform }} packages: ${{ matrix.packages }} # Cygwin will always link the binaries even if they already exist. The linking is also extremely slow. So just run the "check" target which includes all the binaries. - name: Build all and run test run: | C:\cygwin\bin\bash.exe -l -c cd %GITHUB_WORKSPACE% && make VERBOSE=1 -j%NUMBER_OF_PROCESSORS% check - name: Extra test for misra run: | cd %GITHUB_WORKSPACE%\addons\test ..\..\cppcheck.exe --dump -DDUMMY --suppress=uninitvar --inline-suppr misra\misra-test.c --std=c89 --platform=unix64 python3 ..\misra.py -verify misra\misra-test.c.dump ..\..\cppcheck.exe --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 misra\misra-ctu-1-test.c misra\misra-ctu-2-test.c cppcheck-2.17.1/.github/workflows/CI-mingw.yml000066400000000000000000000042501475760761100211330ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: CI-mingw on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read defaults: run: shell: msys2 {0} jobs: # TODO: add CMake build build_mingw: strategy: matrix: # the MinGW installation in windows-2019 is supposed to be 8.1 but it is 12.2 # the MinGW installation in windows-2022 is not including all necessary packages by default, so just use the older image instead - package versions are he same os: [windows-2019] fail-fast: false runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Set up MSYS2 uses: msys2/setup-msys2@v2 with: release: false # use pre-installed install: >- mingw-w64-x86_64-lld mingw-w64-x86_64-ccache - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} # TODO: bail out on warning - name: Build cppcheck run: | export PATH="/mingw64/lib/ccache/bin:$PATH" # set RDYNAMIC to work around broken MinGW detection make VERBOSE=1 RDYNAMIC=-lshlwapi -j$(nproc) cppcheck env: LDFLAGS: -fuse-ld=lld # use lld for faster linking - name: Build test run: | export PATH="/mingw64/lib/ccache/bin:$PATH" # set RDYNAMIC to work around broken MinGW detection make VERBOSE=1 RDYNAMIC=-lshlwapi -j$(nproc) testrunner env: LDFLAGS: -fuse-ld=lld # use lld for faster linking - name: Run test run: | export PATH="/mingw64/lib/ccache/bin:$PATH" # set RDYNAMIC to work around broken MinGW detection make VERBOSE=1 RDYNAMIC=-lshlwapi -j$(nproc) check env: LDFLAGS: -fuse-ld=lld # use lld for faster linking cppcheck-2.17.1/.github/workflows/CI-unixish-docker.yml000066400000000000000000000100561475760761100227470ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: CI-unixish-docker on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: build_cmake: strategy: matrix: image: ["ubuntu:24.04", "ubuntu:24.10"] include: - build_gui: false - image: "ubuntu:24.04" build_gui: true - image: "ubuntu:24.10" build_gui: true fail-fast: false # Prefer quick result runs-on: ubuntu-22.04 # TODO: is this actually applied to the guest? env: # TODO: figure out why there are cache misses with PCH enabled CCACHE_SLOPPINESS: pch_defines,time_macros container: image: ${{ matrix.image }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Install missing software on ubuntu if: contains(matrix.image, 'ubuntu') run: | apt-get update apt-get install -y cmake g++ make libxml2-utils libpcre3-dev - name: Install missing software (gui) on latest ubuntu if: matrix.build_gui run: | apt-get install -y qt6-base-dev qt6-charts-dev qt6-tools-dev # needs to be called after the package installation since # - it doesn't call "apt-get update" - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ matrix.image }} - name: CMake build if: ${{ !matrix.build_gui }} run: | mkdir cmake.output cd cmake.output cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache .. cmake --build . -- -j$(nproc) - name: CMake build (with GUI) if: matrix.build_gui run: | cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake --build cmake.output -- -j$(nproc) - name: Run CMake test run: | cmake --build cmake.output --target check -- -j$(nproc) build_make: strategy: matrix: image: ["ubuntu:24.04", "ubuntu:24.10"] fail-fast: false # Prefer quick result runs-on: ubuntu-22.04 container: image: ${{ matrix.image }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Install missing software on ubuntu if: contains(matrix.image, 'ubuntu') run: | apt-get update apt-get install -y g++ make python3 libxml2-utils libpcre3-dev # needs to be called after the package installation since # - it doesn't call "apt-get update" - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ matrix.image }} - name: Build cppcheck run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" make -j$(nproc) HAVE_RULES=yes CXXFLAGS="-w" - name: Build test run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" make -j$(nproc) testrunner HAVE_RULES=yes CXXFLAGS="-w" - name: Run test run: | make -j$(nproc) check HAVE_RULES=yes # requires python3 - name: Run extra tests run: | tools/generate_and_run_more_tests.sh # requires which - name: Validate run: | make -j$(nproc) checkCWEEntries validateXML - name: Test addons run: | ./cppcheck --addon=threadsafety addons/test/threadsafety ./cppcheck --addon=threadsafety --std=c++03 addons/test/threadsafety cppcheck-2.17.1/.github/workflows/CI-unixish.yml000066400000000000000000000526551475760761100215150ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: CI-unixish on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: build_cmake_tinyxml2: strategy: matrix: os: [ubuntu-20.04, ubuntu-22.04, macos-13] include: - use_qt6: On - os: ubuntu-20.04 use_qt6: Off fail-fast: false # Prefer quick result runs-on: ${{ matrix.os }} env: # TODO: figure out why there are cache misses with PCH enabled CCACHE_SLOPPINESS: pch_defines,time_macros steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} - name: Install missing software on ubuntu if: contains(matrix.os, 'ubuntu') && matrix.use_qt6 == 'Off' run: | sudo apt-get update sudo apt-get install libxml2-utils libtinyxml2-dev qtbase5-dev qttools5-dev libqt5charts5-dev qtchooser - name: Install missing software on ubuntu if: contains(matrix.os, 'ubuntu') && matrix.use_qt6 == 'On' run: | sudo apt-get update sudo apt-get install libxml2-utils libtinyxml2-dev # qt6-tools-dev-tools for lprodump # qt6-l10n-tools for lupdate sudo apt-get install qt6-base-dev libqt6charts6-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libglx-dev libgl1-mesa-dev # coreutils contains "nproc" - name: Install missing software on macos if: contains(matrix.os, 'macos') run: | # pcre was removed from runner images in November 2022 brew install coreutils qt@6 tinyxml2 pcre - name: CMake build on ubuntu (with GUI / system tinyxml2) if: contains(matrix.os, 'ubuntu') run: | cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=${{ matrix.use_qt6 }} -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake --build cmake.output.tinyxml2 -- -j$(nproc) - name: CMake build on macos (with GUI / system tinyxml2) if: contains(matrix.os, 'macos') run: | cmake -S . -B cmake.output.tinyxml2 -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_BUNDLED_TINYXML2=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 cmake --build cmake.output.tinyxml2 -- -j$(nproc) - name: Run CMake test (system tinyxml2) run: | cmake --build cmake.output.tinyxml2 --target check -- -j$(nproc) build_cmake: strategy: matrix: os: [ubuntu-20.04, ubuntu-22.04, macos-13] include: - use_qt6: On - os: ubuntu-20.04 use_qt6: Off fail-fast: false # Prefer quick result runs-on: ${{ matrix.os }} env: # TODO: figure out why there are cache misses with PCH enabled CCACHE_SLOPPINESS: pch_defines,time_macros steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} - name: Install missing software on ubuntu if: contains(matrix.os, 'ubuntu') && matrix.use_qt6 == 'Off' run: | sudo apt-get update sudo apt-get install libxml2-utils qtbase5-dev qttools5-dev libqt5charts5-dev qtchooser # TODO: move latest compiler to separate step # TODO: bail out on warnings with latest GCC - name: Set up GCC uses: egor-tensin/setup-gcc@v1 if: false # matrix.os == 'ubuntu-22.04' with: version: 13 platform: x64 - name: Select compiler if: false # matrix.os == 'ubuntu-22.04' run: | echo "CXX=g++-13" >> $GITHUB_ENV - name: Install missing software on ubuntu if: contains(matrix.os, 'ubuntu') && matrix.use_qt6 == 'On' run: | sudo apt-get update sudo apt-get install libxml2-utils # qt6-tools-dev-tools for lprodump # qt6-l10n-tools for lupdate sudo apt-get install qt6-base-dev libqt6charts6-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libglx-dev libgl1-mesa-dev # coreutils contains "nproc" - name: Install missing software on macos if: contains(matrix.os, 'macos') run: | # pcre was removed from runner images in November 2022 brew install coreutils qt@6 pcre - name: Run CMake on ubuntu (with GUI) if: contains(matrix.os, 'ubuntu') run: | cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=${{ matrix.use_qt6 }} -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install - name: Run CMake on macos (with GUI) if: contains(matrix.os, 'macos') run: | cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install -DQt6_DIR=$(brew --prefix qt@6)/lib/cmake/Qt6 - name: Run CMake build run: | cmake --build cmake.output -- -j$(nproc) - name: Run CMake test run: | cmake --build cmake.output --target check -- -j$(nproc) - name: Run CTest run: | pushd cmake.output ctest --output-on-failure -j$(nproc) - name: Run CMake install run: | cmake --build cmake.output --target install build_uchar: strategy: matrix: os: [ubuntu-20.04, ubuntu-22.04, macos-13] fail-fast: false # Prefer quick result runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} # coreutils contains "nproc" - name: Install missing software on macos if: contains(matrix.os, 'macos') run: | brew install coreutils - name: Build with Unsigned char run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" make -j$(nproc) CXXFLAGS=-funsigned-char testrunner - name: Test with Unsigned char run: | ./testrunner TestSymbolDatabase build_mathlib: strategy: matrix: os: [ubuntu-20.04, ubuntu-22.04, macos-13] fail-fast: false # Prefer quick result runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} # coreutils contains "nproc" - name: Install missing software on macos if: contains(matrix.os, 'macos') run: | brew install coreutils - name: Build with TEST_MATHLIB_VALUE run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" make -j$(nproc) CPPFLAGS=-DTEST_MATHLIB_VALUE all - name: Test with TEST_MATHLIB_VALUE run: | make -j$(nproc) CPPFLAGS=-DTEST_MATHLIB_VALUE check check_nonneg: strategy: matrix: os: [ubuntu-20.04, ubuntu-22.04, macos-13] fail-fast: false # Prefer quick result runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: persist-credentials: false # coreutils contains "g++" (default is "c++") and "nproc" - name: Install missing software on macos if: contains(matrix.os, 'macos') run: | brew install coreutils - 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 build: strategy: matrix: os: [ubuntu-20.04, ubuntu-22.04, macos-13] include: - xdist_n: auto # FIXME: test_color_tty fails with xdist - os: macos-13 xdist_n: '1' fail-fast: false # Prefer quick result runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} - name: Install missing software on ubuntu if: contains(matrix.os, 'ubuntu') run: | sudo apt-get update sudo apt-get install libxml2-utils # packages for strict cfg checks - name: Install missing software on ubuntu 22.04 (cfg) if: matrix.os == 'ubuntu-22.04' run: | sudo apt-get install libcairo2-dev libcurl4-openssl-dev liblua5.3-dev libssl-dev libsqlite3-dev libcppunit-dev libsigc++-2.0-dev libgtk-3-dev libboost-all-dev libselinux-dev libwxgtk3.0-gtk3-dev xmlstarlet qtbase5-dev # coreutils contains "nproc" - name: Install missing software on macos if: contains(matrix.os, 'macos') run: | # pcre was removed from runner images in November 2022 brew install coreutils python3 pcre gnu-sed - name: Install missing Python packages run: | python3 -m pip install pip --upgrade python3 -m pip install pytest python3 -m pip install pytest-timeout python3 -m pip install pytest-xdist python3 -m pip install psutil - name: Build cppcheck run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" make -j$(nproc) HAVE_RULES=yes - name: Build test run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" make -j$(nproc) testrunner HAVE_RULES=yes - name: Run test run: | make -j$(nproc) check HAVE_RULES=yes # requires "gnu-sed" installed on macos - name: Run extra tests run: | tools/generate_and_run_more_tests.sh - name: Run test/cli run: | python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }} test/cli # TODO: use the step below instead # do not use pushd in this step since we go below the working directory - name: Run test/cli (symlink) run: | cd .. ln -s cppcheck 'cpp check' cd 'cpp check/test/cli' python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }} # FIXME: proj2_test.py fails because of the relative path cleanups in ImportProject::setRelativePaths() # It fails because the application path used as base path has its symlink resolved by getcwd(). - name: Run test/cli (symlink) if: false run: | ln -s . 'cpp check' python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }} 'cpp check/test/cli' - name: Run test/cli (-j2) run: | python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }} test/cli env: TEST_CPPCHECK_INJECT_J: 2 - name: Run test/cli (--clang) if: false run: | python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }} test/cli env: TEST_CPPCHECK_INJECT_CLANG: clang - name: Run test/cli (--cppcheck-build-dir) run: | python3 -m pytest -Werror --strict-markers -vv -n ${{ matrix.xdist_n }} test/cli env: TEST_CPPCHECK_INJECT_BUILDDIR: injected - name: Run cfg tests if: matrix.os != 'ubuntu-22.04' run: | make -j$(nproc) checkcfg - name: Run cfg tests (strict) if: matrix.os == 'ubuntu-22.04' run: | make -j$(nproc) checkcfg env: STRICT: 1 - name: Run --dump test run: | ./cppcheck test/testpreprocessor.cpp --dump xmllint --noout test/testpreprocessor.cpp.dump - name: Validate run: | make -j$(nproc) checkCWEEntries validateXML - name: Test install run: | # this is only to test the "install" target - since we did not build with FILESDIR it would not work as intended make DESTDIR=cppcheck-make-install FILESDIR=/share/Cppcheck install rm -rf cppcheck-make-install - name: Test Signalhandler run: | cmake -S . -B build.cmake.signal -G "Unix Makefiles" -DBUILD_TESTS=On cmake --build build.cmake.signal --target test-signalhandler -- -j$(nproc) # TODO: how to run this without copying the file? cp build.cmake.signal/bin/test-s* . python3 -m pytest -Werror --strict-markers -vv test/signal/test-signalhandler.py rm test-signalhandler # no unix backtrace support on MacOs - name: Test Stacktrace if: contains(matrix.os, 'ubuntu') run: | cmake -S . -B build.cmake.stack -G "Unix Makefiles" -DBUILD_TESTS=On cmake --build build.cmake.stack --target test-stacktrace -- -j$(nproc) # TODO: how to run this without copying the file? cp build.cmake.stack/bin/test-s* . python3 -m pytest -Werror --strict-markers -vv test/signal/test-stacktrace.py rm test-stacktrace # TODO: move to scriptcheck.yml so these are tested with all Python versions? - name: Test addons run: | set -x ./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety addons/test/threadsafety ./cppcheck --error-exitcode=1 --inline-suppr --addon=threadsafety --std=c++03 addons/test/threadsafety ./cppcheck --error-exitcode=1 --inline-suppr --addon=misra addons/test/misra/crash*.c ./cppcheck --error-exitcode=1 --inline-suppr --addon=misra --enable=information addons/test/misra/config*.c ./cppcheck --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c pushd addons/test # We'll force C89 standard to enable an additional verification for # rules 5.4 and 5.5 which have standard-dependent options. ../../cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64 python3 ../misra.py -verify misra/misra-test.c.dump # Test slight MISRA differences in C11 standard ../../cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test-c11.c --std=c11 --platform=unix64 python3 ../misra.py -verify misra/misra-test-c11.c.dump # TODO: do we need to verify something here? ../../cppcheck --dump -DDUMMY --suppress=uninitvar --suppress=uninitStructMember --std=c89 misra/misra-test.h ../../cppcheck --dump misra/misra-test.cpp python3 ../misra.py -verify misra/misra-test.cpp.dump python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_ascii.txt -verify misra/misra-test.cpp.dump python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_utf8.txt -verify misra/misra-test.cpp.dump python3 ../misra.py --rule-texts=misra/misra2012_rules_dummy_windows1250.txt -verify misra/misra-test.cpp.dump ../../cppcheck --addon=misra --enable=style --platform=avr8 --error-exitcode=1 misra/misra-test-avr8.c ../../cppcheck --dump misc-test.cpp python3 ../misc.py -verify misc-test.cpp.dump ../../cppcheck --dump naming_test.c python3 ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.c.dump ../../cppcheck --dump naming_test.cpp python3 ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.cpp.dump # TODO: run with "-n auto" when misra_test.py can be run in parallel - name: test addons (Python) if: matrix.os != 'ubuntu-22.04' run: | python3 -m pytest -Werror --strict-markers -vv -n 1 addons/test env: PYTHONPATH: ./addons # TODO: run with "-n auto" when misra_test.py can be run in parallel # we cannot specify -Werror since xml/etree/ElementTree.py in Python 3.10 contains an unclosed file - name: test addons (Python) if: matrix.os == 'ubuntu-22.04' run: | python3 -m pytest --strict-markers -vv -n 1 addons/test env: PYTHONPATH: ./addons - name: Build democlient if: matrix.os == 'ubuntu-22.04' run: | warnings="-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" g++ $warnings -c -Ilib -Iexternals/tinyxml2 democlient/democlient.cpp - name: Show all ignored files if: false # TODO: currently lists all the contents of ignored folders - we only need what actually matched run: | git ls-files --others --ignored --exclude-standard - name: Check for changed and unversioned files run: | # TODO: how to do this with a single command? git status --ignored=no git status --ignored=no | grep -q 'working tree clean' selfcheck: needs: build # wait for all tests to be successful first runs-on: ubuntu-22.04 # run on the latest image only steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} - name: Install missing software on ubuntu run: | sudo apt-get update # qt6-tools-dev-tools for lprodump # qt6-l10n-tools for lupdate sudo apt-get install qt6-base-dev libqt6charts6-dev qt6-tools-dev qt6-tools-dev-tools qt6-l10n-tools libglx-dev libgl1-mesa-dev sudo apt-get install libboost-container-dev - name: Self check (build) run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" # compile with verification and ast matchers make -j$(nproc) -s CPPFLAGS="-DCHECK_INTERNAL" CXXFLAGS="-g -O2 -w -DHAVE_BOOST" MATCHCOMPILER=yes VERIFY=1 - name: CMake run: | cmake -S . -B cmake.output -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DENABLE_CHECK_INTERNAL=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On - name: Generate dependencies run: | # make sure auto-generated GUI files exist make -C cmake.output autogen make -C cmake.output gui-build-deps triage-build-ui-deps - name: Self check run: | selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=file-total -D__GNUC__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude --exception-handling --debug-warnings --check-level=exhaustive" cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" ec=0 # TODO: add --check-config # early exit if [ $ec -eq 1 ]; then exit $ec fi # self check externals ./cppcheck $selfcheck_options externals || ec=1 # self check lib/cli mkdir b1 ./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json cli || ec=1 ./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b1 --addon=naming.json --enable=internal lib || ec=1 # check gui with qt settings mkdir b2 ./cppcheck $selfcheck_options $cppcheck_options --cppcheck-build-dir=b2 -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui || ec=1 # self check test and tools ./cppcheck $selfcheck_options $cppcheck_options -Icli test/*.cpp tools/dmake/*.cpp || ec=1 # triage ./cppcheck $selfcheck_options $cppcheck_options -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB --library=qt -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage || ec=1 exit $ec cppcheck-2.17.1/.github/workflows/CI-windows.yml000066400000000000000000000263351475760761100215140ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: CI-windows on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read defaults: run: shell: cmd # TODO: choose/add a step to bail out on compiler warnings (maybe even the release build) jobs: build_qt: strategy: matrix: os: [windows-2019, windows-2022] qt_ver: [5.15.2, 6.8.1] fail-fast: false runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Set up Visual Studio environment uses: ilammy/msvc-dev-cmd@v1 with: arch: x64 - name: Install Qt ${{ matrix.qt_ver }} uses: jurplel/install-qt-action@v4 with: version: ${{ matrix.qt_ver }} modules: 'qtcharts' cache: true - name: Run CMake for GUI release (Qt 5) if: startsWith(matrix.qt_ver, '5') run: | ; TODO: enable rules? ; specify Release build so matchcompiler is used cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DBUILD_GUI=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DBUILD_ONLINE_HELP=On -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install || exit /b !errorlevel! - name: Run CMake for GUI release (Qt 6) if: startsWith(matrix.qt_ver, '6') run: | ; TODO: enable rules? ; specify Release build so matchcompiler is used cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_COMPILE_WARNING_AS_ERROR=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DBUILD_ONLINE_HELP=On -DCMAKE_INSTALL_PREFIX=cppcheck-cmake-install || exit /b !errorlevel! - name: Run CMake build run: | cmake --build build --target cppcheck-gui --config Release || exit /b !errorlevel! - name: Deploy GUI run: | windeployqt build\bin\Release || exit /b !errorlevel! del build\bin\Release\cppcheck-gui.ilk || exit /b !errorlevel! del build\bin\Release\cppcheck-gui.pdb || exit /b !errorlevel! # TODO: run GUI tests - name: Run CMake install run: | cmake --build build --target install build: strategy: matrix: os: [windows-2019, windows-2022] config: [debug, release] fail-fast: false runs-on: ${{ matrix.os }} env: # see https://www.pcre.org/original/changelog.txt PCRE_VERSION: 8.45 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Set up Python 3.13 if: matrix.config == 'release' uses: actions/setup-python@v5 with: python-version: '3.13' check-latest: true - name: Set up Visual Studio environment uses: ilammy/msvc-dev-cmd@v1 with: arch: x64 - name: Cache PCRE id: cache-pcre uses: actions/cache@v4 with: path: | externals\pcre.h externals\pcre.lib externals\pcre64.lib key: pcre-${{ env.PCRE_VERSION }}-x64-bin-win - name: Download PCRE if: steps.cache-pcre.outputs.cache-hit != 'true' run: | curl -fsSL https://github.com/pfultz2/pcre/archive/refs/tags/%PCRE_VERSION%.zip -o pcre-%PCRE_VERSION%.zip || exit /b !errorlevel! - name: Install PCRE if: steps.cache-pcre.outputs.cache-hit != 'true' run: | 7z x pcre-%PCRE_VERSION%.zip || exit /b !errorlevel! cd pcre-%PCRE_VERSION% || exit /b !errorlevel! cmake . -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DPCRE_BUILD_PCRECPP=Off -DPCRE_BUILD_TESTS=Off -DPCRE_BUILD_PCREGREP=Off || exit /b !errorlevel! nmake || exit /b !errorlevel! copy pcre.h ..\externals || exit /b !errorlevel! copy pcre.lib ..\externals\pcre64.lib || exit /b !errorlevel! env: 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! python -m pip install pytest-xdist || exit /b !errorlevel! python -m pip install psutil || exit /b !errorlevel! # TODO: build with CMake - name: Build CLI debug configuration using MSBuild if: matrix.config == 'debug' run: | :: cmake --build build --target check --config Debug || exit /b !errorlevel! msbuild -m cppcheck.sln /p:Configuration=Debug-PCRE;Platform=x64 -maxcpucount || exit /b !errorlevel! env: _CL_: /WX - 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: | :: cmake --build build --target check --config Release || exit /b !errorlevel! msbuild -m cppcheck.sln /p:Configuration=Release-PCRE;Platform=x64 -maxcpucount || exit /b !errorlevel! env: _CL_: /WX - name: Run Release test if: matrix.config == 'release' run: .\bin\testrunner.exe || exit /b !errorlevel! - name: Prepare 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! copy .\bin\cppcheck.exe .\cppcheck.exe || exit /b !errorlevel! copy .\bin\cppcheck-core.dll .\cppcheck-core.dll || exit /b !errorlevel! - name: Run test/cli if: matrix.config == 'release' run: | python -m pytest -Werror --strict-markers -vv -n auto test/cli || exit /b !errorlevel! - name: Run test/cli (-j2) if: matrix.config == 'release' run: | python -m pytest -Werror --strict-markers -vv -n auto test/cli || exit /b !errorlevel! env: TEST_CPPCHECK_INJECT_J: 2 # TODO: install clang - name: Run test/cli (--clang) if: false # matrix.config == 'release' run: | python -m pytest -Werror --strict-markers -vv -n auto test/cli || exit /b !errorlevel! env: TEST_CPPCHECK_INJECT_CLANG: clang - name: Run test/cli (--cppcheck-build-dir) if: matrix.config == 'release' run: | python -m pytest -Werror --strict-markers -vv -n auto test/cli || exit /b !errorlevel! env: TEST_CPPCHECK_INJECT_BUILDDIR: injected # TODO: test with Release configuration? - name: Test SEH wrapper if: matrix.config == 'release' run: | cmake -S . -B build.cmake.seh -DBUILD_TESTS=On || exit /b !errorlevel! cmake --build build.cmake.seh --target test-sehwrapper || exit /b !errorlevel! :: TODO: how to run this without copying the file? copy build.cmake.seh\bin\Debug\test-sehwrapper.exe . || exit /b !errorlevel! python3 -m pytest -Werror --strict-markers -vv test/seh/test-sehwrapper.py || exit /b !errorlevel! del test-sehwrapper.exe || exit /b !errorlevel! - name: Test addons if: matrix.config == 'release' run: | echo on .\cppcheck --addon=threadsafety addons\test\threadsafety || exit /b !errorlevel! .\cppcheck --addon=threadsafety --std=c++03 addons\test\threadsafety || exit /b !errorlevel! .\cppcheck --addon=misra --enable=style --inline-suppr --enable=information --error-exitcode=1 addons\test\misra\misra-ctu-*-test.c || exit /b !errorlevel! cd addons\test rem We'll force C89 standard to enable an additional verification for rem rules 5.4 and 5.5 which have standard-dependent options. ..\..\cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra\misra-test.c --std=c89 --platform=unix64 || exit /b !errorlevel! python3 ..\misra.py -verify misra\misra-test.c.dump || exit /b !errorlevel! rem Test slight MISRA differences in C11 standard ..\..\cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra\misra-test-c11.c --std=c11 --platform=unix64 || exit /b !errorlevel! python3 ..\misra.py -verify misra\misra-test-c11.c.dump || exit /b !errorlevel! rem TODO: do we need to verify something here? ..\..\cppcheck --dump -DDUMMY --suppress=uninitvar --suppress=uninitStructMember --std=c89 misra\misra-test.h || exit /b !errorlevel! ..\..\cppcheck --dump misra\misra-test.cpp || exit /b !errorlevel! python3 ..\misra.py -verify misra\misra-test.cpp.dump || exit /b !errorlevel! python3 ..\misra.py --rule-texts=misra\misra2012_rules_dummy_ascii.txt -verify misra\misra-test.cpp.dump || exit /b !errorlevel! python3 ..\misra.py --rule-texts=misra\misra2012_rules_dummy_utf8.txt -verify misra\misra-test.cpp.dump || exit /b !errorlevel! python3 ..\misra.py --rule-texts=misra\misra2012_rules_dummy_windows1250.txt -verify misra\misra-test.cpp.dump || exit /b !errorlevel! ..\..\cppcheck --addon=misra --enable=style --platform=avr8 --error-exitcode=1 misra\misra-test-avr8.c || exit /b !errorlevel! ..\..\cppcheck --dump misc-test.cpp || exit /b !errorlevel! python3 ..\misc.py -verify misc-test.cpp.dump || exit /b !errorlevel! ..\..\cppcheck --dump naming_test.c || exit /b !errorlevel! rem TODO: fix this - does not fail on Linux rem python3 ..\naming.py --var='[a-z].*' --function='[a-z].*' naming_test.c.dump || exit /b !errorlevel! ..\..\cppcheck --dump naming_test.cpp || exit /b !errorlevel! python3 ..\naming.py --var='[a-z].*' --function='[a-z].*' naming_test.cpp.dump || exit /b !errorlevel! # TODO: run with "-n auto" when misra_test.py can be run in parallel - name: test addons (Python) if: matrix.config == 'release' run: | python -m pytest -Werror --strict-markers -vv -n 1 addons/test || exit /b !errorlevel! env: PYTHONPATH: ./addons - name: Check Windows test syntax if: matrix.config == 'debug' run: | cd test\cfg cl.exe windows.cpp -DUNICODE=1 -D_UNICODE=1 /Zs || exit /b !errorlevel! cl.exe mfc.cpp /EHsc /Zs || exit /b !errorlevel! - name: Show all ignored files if: false # TODO: currently lists all the contents of ignored folders - we only need what actually matched run: | git ls-files --others --ignored --exclude-standard || exit /b !errorlevel! - name: Check for changed and unversioned files run: | :: TODO: how to do this with a single command? git status --ignored=no :: TODO: make this work :: git status --ignored=no | grep -q 'working tree clean' cppcheck-2.17.1/.github/workflows/asan.yml000066400000000000000000000140761475760761100204520ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: address sanitizer on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: build: runs-on: ubuntu-22.04 env: QT_VERSION: 6.8.1 ASAN_OPTIONS: detect_stack_use_after_return=1 # TODO: figure out why there are cache misses with PCH enabled CCACHE_SLOPPINESS: pch_defines,time_macros steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} - name: Set up Python 3.13 uses: actions/setup-python@v5 with: python-version: '3.13' check-latest: true - name: Install missing software on ubuntu run: | sudo apt-get update sudo apt-get install -y cmake make libpcre3-dev libboost-container-dev libxml2-utils sudo apt-get install -y libcups2-dev # required for Qt6PrintSupport in CMake since Qt 6.7.3 - name: Install clang run: | sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 19 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} modules: 'qtcharts' cache: true - name: Install missing Python packages run: | python3 -m pip install pip --upgrade python3 -m pip install pytest python3 -m pip install pytest-timeout python3 -m pip install pytest-xdist python3 -m pip install psutil # TODO: disable all warnings - name: CMake run: | cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_ADDRESS=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache env: CC: clang-19 CXX: clang++-19 - name: Build cppcheck run: | cmake --build cmake.output --target cppcheck -- -j $(nproc) - name: Build test run: | cmake --build cmake.output --target testrunner -- -j $(nproc) - name: Build GUI tests run: | cmake --build cmake.output --target gui-tests -- -j $(nproc) - name: Run tests run: ./cmake.output/bin/testrunner - name: Run cfg tests run: | cmake --build cmake.output --target checkcfg -- -j $(nproc) - name: Run CTest run: | ctest --test-dir cmake.output --output-on-failure -j$(nproc) - name: Run test/cli run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli - name: Run test/cli (-j2) run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli env: TEST_CPPCHECK_INJECT_J: 2 - name: Run test/cli (--clang) if: false run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli env: TEST_CPPCHECK_INJECT_CLANG: clang - name: Run test/cli (--cppcheck-build-dir) run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli env: TEST_CPPCHECK_INJECT_BUILDDIR: injected - name: Generate dependencies if: false run: | # make sure auto-generated GUI files exist make -C cmake.output autogen make -C cmake.output gui-build-deps triage-build-ui-deps # TODO: this is currently way too slow (~60 minutes) to enable it # TODO: only fail the step on sanitizer issues - since we use processes it will only fail the underlying process which will result in an cppcheckError - name: Self check if: false run: | selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=file-total -D__GNUC__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude --exception-handling --debug-warnings --check-level=exhaustive" cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" ec=0 ./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli test/*.cpp tools/dmake/*.cpp || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage/*.cpp || ec=1 exit $ec cppcheck-2.17.1/.github/workflows/buildman.yml000066400000000000000000000027151475760761100213200ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: Build manual on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: convert_via_pandoc: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: persist-credentials: false - run: | mkdir output - uses: docker://pandoc/latex:2.9 with: args: --output=output/manual.html man/manual.md - uses: docker://pandoc/latex:2.9 with: args: --output=output/manual.pdf man/manual.md - uses: docker://pandoc/latex:2.9 with: args: --output=output/manual-premium.pdf man/manual-premium.md - uses: actions/upload-artifact@v4 with: name: output path: output manpage: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Install missing software on ubuntu run: | sudo apt-get update sudo apt-get install -y xsltproc docbook-xsl - name: build manpage run: | make man - uses: actions/upload-artifact@v4 with: name: cppcheck.1 path: cppcheck.1 cppcheck-2.17.1/.github/workflows/cifuzz.yml000066400000000000000000000017501475760761100210350ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: CIFuzz on: [pull_request] permissions: contents: read jobs: Fuzzing: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'danmar' }} steps: - name: Build Fuzzers id: build uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master with: oss-fuzz-project-name: 'cppcheck' dry-run: false language: c++ - name: Run Fuzzers uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master with: oss-fuzz-project-name: 'cppcheck' fuzz-seconds: 300 dry-run: false language: c++ - name: Upload Crash uses: actions/upload-artifact@v4 if: failure() && steps.build.outcome == 'success' with: name: artifacts path: ./out/artifacts cppcheck-2.17.1/.github/workflows/clang-tidy.yml000066400000000000000000000044171475760761100215610ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: clang-tidy on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: build: runs-on: ubuntu-22.04 env: QT_VERSION: 6.8.1 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Install missing software run: | sudo apt-get update sudo apt-get install -y cmake make sudo apt-get install -y libpcre3-dev sudo apt-get install -y libgl-dev # fixes missing dependency for Qt in CMake - name: Install clang run: | sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 19 sudo apt-get install -y clang-tidy-19 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} modules: 'qtcharts' install-deps: false cache: true - name: Verify clang-tidy configuration run: | clang-tidy-19 --verify-config - name: Prepare CMake run: | cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCPPCHK_GLIBCXX_DEBUG=Off -DWARNINGS_ARE_ERRORS=On env: CC: clang-19 CXX: clang++-19 - name: Prepare CMake dependencies run: | # make sure the auto-generated GUI sources exist make -C cmake.output autogen # make sure the precompiled headers exist make -C cmake.output/cli cmake_pch.hxx.pch make -C cmake.output/gui cmake_pch.hxx.pch make -C cmake.output/lib cmake_pch.hxx.pch make -C cmake.output/test cmake_pch.hxx.pch - name: Clang-Tidy run: | cmake --build cmake.output --target run-clang-tidy 2> /dev/null cppcheck-2.17.1/.github/workflows/codeql-analysis.yml000066400000000000000000000026371475760761100226200ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: "CodeQL" on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: analyze: name: Analyze runs-on: ubuntu-22.04 permissions: security-events: write strategy: fail-fast: false matrix: # Override automatic language detection by changing the below list # Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python'] language: ['cpp', 'python'] # Learn more... # https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection steps: - name: Checkout repository uses: actions/checkout@v4 with: persist-credentials: false # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} - name: Build cppcheck if: matrix.language == 'cpp' run: | make -j$(nproc) HAVE_RULES=yes cppcheck - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v3 cppcheck-2.17.1/.github/workflows/coverage.yml000066400000000000000000000037721475760761100213240ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: Coverage on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: build: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ runner.os }} - name: Install missing software on ubuntu run: | sudo apt-get update sudo apt-get install libxml2-utils lcov - name: Install missing Python packages on ubuntu run: | python -m pip install pip --upgrade python -m pip install lcov_cobertura - name: Compile instrumented run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" make -j$(nproc) all CXXFLAGS="-g -fprofile-arcs -ftest-coverage" HAVE_RULES=yes - name: Run instrumented tests run: | ./testrunner test/cfg/runtests.sh - name: Generate coverage report run: | gcov lib/*.cpp -o lib/ lcov --directory ./ --capture --output-file lcov_tmp.info -b ./ lcov --extract lcov_tmp.info "$(pwd)/*" --output-file lcov.info genhtml lcov.info -o coverage_report --frame --legend --demangle-cpp - uses: actions/upload-artifact@v4 with: name: Coverage results path: coverage_report - uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} # file: ./coverage.xml # optional flags: unittests # optional name: ${{ github.repository }} # optional fail_ci_if_error: true # optional (default = false): cppcheck-2.17.1/.github/workflows/coverity.yml000066400000000000000000000030011475760761100213560ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: Coverity on: schedule: - cron: "0 0 * * *" permissions: contents: read jobs: scan: runs-on: ubuntu-latest if: ${{ github.repository_owner == 'danmar' }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Install missing software on ubuntu run: | sudo apt-get update sudo apt-get install qtbase5-dev qttools5-dev libqt5charts5-dev libboost-container-dev - name: Download Coverity build tool run: | wget -c -N https://scan.coverity.com/download/linux64 --post-data "token=${{ secrets.COVERITY_SCAN_TOKEN }}&project=cppcheck" -O coverity_tool.tar.gz mkdir coverity_tool tar xzf coverity_tool.tar.gz --strip 1 -C coverity_tool - name: Build with Coverity build tool run: | export PATH=`pwd`/coverity_tool/bin:$PATH cov-build --dir cov-int make CPPCHK_GLIBCXX_DEBUG= - name: Submit build result to Coverity Scan run: | tar czvf cov.tar.gz cov-int curl --form token=${{ secrets.COVERITY_SCAN_TOKEN }} \ --form email=daniel.marjamaki@gmail.com \ --form file=@cov.tar.gz \ --form version="Commit $GITHUB_SHA" \ --form description="Development" \ https://scan.coverity.com/builds?project=cppcheck cppcheck-2.17.1/.github/workflows/cppcheck-premium.yml000066400000000000000000000040061475760761100227540ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: cppcheck-premium on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: workflow_dispatch: inputs: premium_version: description: 'Cppcheck Premium version' permissions: contents: read jobs: build: runs-on: ubuntu-24.04 # run on the latest image only steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Download cppcheckpremium run: | premium_version=${{ inputs.premium_version }} if [ -z $premium_version ]; then premium_version=24.11.0 #wget https://files.cppchecksolutions.com/devdrop/cppcheckpremium-$premium_version-amd64.tar.gz -O cppcheckpremium.tar.gz wget https://files.cppchecksolutions.com/$premium_version/ubuntu-24.04/cppcheckpremium-$premium_version-amd64.tar.gz -O cppcheckpremium.tar.gz else wget https://files.cppchecksolutions.com/$premium_version/ubuntu-24.04/cppcheckpremium-$premium_version-amd64.tar.gz -O cppcheckpremium.tar.gz fi tar xzf cppcheckpremium.tar.gz mv cppcheckpremium-$premium_version cppcheckpremium - name: Generate a license file run: | echo cppcheck > cppcheck.lic echo 251231 >> cppcheck.lic echo 80000 >> cppcheck.lic echo 4f8dc8e7c8bb288f >> cppcheck.lic echo path:lib >> cppcheck.lic - name: Check run: | cppcheckpremium/premiumaddon --check-loc-license cppcheck.lic > cppcheck-premium-loc cppcheckpremium/cppcheck -j$(nproc) -D__GNUC__ -D__CPPCHECK__ --suppressions-list=cppcheckpremium-suppressions --platform=unix64 --enable=style --premium=misra-c++-2023 --premium=cert-c++-2016 --inline-suppr --error-exitcode=1 lib cppcheck-2.17.1/.github/workflows/format.yml000066400000000000000000000025631475760761100210160ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: format on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: build: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Cache uncrustify uses: actions/cache@v4 id: cache-uncrustify with: path: | ~/uncrustify key: ${{ runner.os }}-uncrustify - name: build uncrustify if: steps.cache-uncrustify.outputs.cache-hit != 'true' run: | wget https://github.com/uncrustify/uncrustify/archive/refs/tags/uncrustify-0.72.0.tar.gz tar xzvf uncrustify-0.72.0.tar.gz && cd uncrustify-uncrustify-0.72.0 cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build -- -j$(nproc) -s mkdir ~/uncrustify cd build && cp uncrustify ~/uncrustify/ - name: Uncrustify check run: | ~/uncrustify/uncrustify -c .uncrustify.cfg -l CPP --no-backup --replace */*.cpp */*.h git diff git diff | diff - /dev/null &> /dev/null cppcheck-2.17.1/.github/workflows/iwyu.yml000066400000000000000000000223031475760761100205150ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: include-what-you-use on: schedule: - cron: '0 0 * * 0' workflow_dispatch: permissions: contents: read jobs: iwyu: strategy: matrix: # "opensuse/tumbleweed:latest" / "fedora:latest" / "debian:unstable" / "archlinux:latest" include: - os: ubuntu-22.04 image: "fedora:latest" stdlib: libstdc++ - os: ubuntu-22.04 image: "fedora:latest" stdlib: libc++ - os: macos-13 image: "" stdlib: libc++ # no libstdc++ on macOS fail-fast: false runs-on: ${{ matrix.os }} if: ${{ github.repository_owner == 'danmar' }} container: image: ${{ matrix.image }} env: QT_VERSION: 6.8.1 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Install missing software on debian/ubuntu if: contains(matrix.image, 'debian') run: | apt-get update apt-get install -y cmake clang make libpcre3-dev apt-get install -y libgl-dev # fixes missing dependency for Qt in CMake apt-get install -y iwyu - name: Install missing software on archlinux if: contains(matrix.image, 'archlinux') run: | set -x pacman -Sy pacman -S cmake make clang pcre --noconfirm pacman -S libglvnd --noconfirm # fixes missing dependency for Qt in CMake pacman-key --init pacman-key --recv-key 3056513887B78AEB --keyserver keyserver.ubuntu.com pacman-key --lsign-key 3056513887B78AEB pacman -U 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst' --noconfirm echo "[chaotic-aur]" >> /etc/pacman.conf echo "Include = /etc/pacman.d/chaotic-mirrorlist" >> /etc/pacman.conf pacman -Sy pacman -S include-what-you-use --noconfirm ln -s iwyu-tool /usr/sbin/iwyu_tool - name: Install missing software on Fedora if: contains(matrix.image, 'fedora') run: | dnf install -y cmake clang pcre-devel dnf install -y libglvnd-devel # fixes missing dependency for Qt in CMake dnf install -y p7zip-plugins # required as fallback for py7zr in Qt installation dnf install -y iwyu ln -s iwyu_tool.py /usr/bin/iwyu_tool - name: Install missing software on Fedora (libc++) if: contains(matrix.image, 'fedora') && matrix.stdlib == 'libc++' run: | dnf install -y libcxx-devel - name: Install missing software on OpenSUSE if: contains(matrix.image, 'opensuse') run: | zypper install -y cmake clang pcre-devel zypper install -y include-what-you-use-tools ln -s iwyu_tool.py /usr/bin/iwyu_tool # coreutils contains "nproc" - name: Install missing software on macOS if: contains(matrix.os, 'macos') run: | brew install include-what-you-use pcre coreutils ln -s iwyu_tool.py /usr/local/bin/iwyu_tool # Fails on OpenSUSE: # Warning: Failed to restore: Tar failed with error: Unable to locate executable file: tar. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable. # Also the shell is broken afterwards: # OCI runtime exec failed: exec failed: unable to start container process: exec: "sh": executable file not found in $PATH: unknown - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} modules: 'qtcharts' install-deps: false cache: true - name: Prepare CMake run: | # TODO: why does it build dmake in the next step? cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCPPCHK_GLIBCXX_DEBUG=Off -DUSE_MATCHCOMPILER=Off -DEXTERNALS_AS_SYSTEM=On -DUSE_LIBCXX=${{ matrix.stdlib == 'libc++' }} env: CC: clang CXX: clang++ # Fails on Debian: # /__w/cppcheck/Qt/6.7.0/gcc_64/libexec/rcc: error while loading shared libraries: libglib-2.0.so.0: cannot open shared object file: No such file or directory - name: Prepare CMake dependencies run: | # make sure the auto-generated GUI sources exist make -C cmake.output autogen # make sure the precompiled headers exist #make -C cmake.output/cli cmake_pch.hxx.pch #make -C cmake.output/gui cmake_pch.hxx.pch #make -C cmake.output/lib cmake_pch.hxx.pch #make -C cmake.output/test cmake_pch.hxx.pch # make sure the auto-generated GUI dependencies exist make -C cmake.output gui-build-deps make -C cmake.output triage-build-ui-deps - name: iwyu_tool run: | # -isystem/usr/lib/clang/17/include # TODO: remove -stdlib= - it should have been taken from the compilation database iwyu_tool -p cmake.output -j $(nproc) -- -w -Xiwyu --max_line_length=1024 -Xiwyu --comment_style=long -Xiwyu --quoted_includes_first -Xiwyu --update_comments -stdlib=${{ matrix.stdlib }} > iwyu.log - uses: actions/upload-artifact@v4 if: success() || failure() with: name: Compilation Database (include-what-you-use - ${{ matrix.os }} ${{ matrix.stdlib }}) path: ./cmake.output/compile_commands.json - uses: actions/upload-artifact@v4 if: success() || failure() with: name: Logs (include-what-you-use - ${{ matrix.os }} ${{ matrix.stdlib }}) path: ./*.log clang-include-cleaner: strategy: matrix: stdlib: [libstdc++, libc++] include: - stdlib: libstdc++ use_libcxx: Off - stdlib: libc++ use_libcxx: On fail-fast: false runs-on: ubuntu-22.04 if: ${{ github.repository_owner == 'danmar' }} env: QT_VERSION: 6.8.1 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Install missing software run: | sudo apt-get update sudo apt-get install -y cmake make libpcre3-dev sudo apt-get install -y libgl-dev # missing dependency for using Qt in CMake - name: Install clang run: | sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 19 sudo apt-get install -y clang-tools-19 - name: Install libc++ if: matrix.stdlib == 'libc++' run: | sudo apt-get install -y libc++-19-dev - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} modules: 'qtcharts' install-deps: false cache: true - name: Prepare CMake run: | # TODO: why does it build dmake in the next step? cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCPPCHK_GLIBCXX_DEBUG=Off -DUSE_MATCHCOMPILER=Off -DEXTERNALS_AS_SYSTEM=On -DUSE_LIBCXX=${{ matrix.use_libcxx }} env: CC: clang-19 CXX: clang++-19 - name: Prepare CMake dependencies run: | # make sure the auto-generated GUI sources exist make -C cmake.output autogen # make sure the precompiled headers exist #make -C cmake.output/cli cmake_pch.hxx.pch #make -C cmake.output/gui cmake_pch.hxx.pch #make -C cmake.output/lib cmake_pch.hxx.pch #make -C cmake.output/test cmake_pch.hxx.pch # make sure the auto-generated GUI dependencies exist make -C cmake.output gui-build-deps - name: clang-include-cleaner run: | # TODO: run multi-threaded find $PWD/cli $PWD/lib $PWD/test $PWD/gui -maxdepth 1 -name "*.cpp" | xargs -t -n 1 clang-include-cleaner-19 --print=changes --extra-arg=-w --extra-arg=-stdlib=${{ matrix.stdlib }} -p cmake.output > clang-include-cleaner.log 2>&1 - uses: actions/upload-artifact@v4 if: success() || failure() with: name: Compilation Database (clang-include-cleaner - ${{ matrix.stdlib }}) path: ./cmake.output/compile_commands.json - uses: actions/upload-artifact@v4 if: success() || failure() with: name: Logs (clang-include-cleaner - ${{ matrix.stdlib }}) path: ./*.log cppcheck-2.17.1/.github/workflows/release-windows.yml000066400000000000000000000217471475760761100226430ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: release-windows on: push: tags: - '2.*' schedule: - cron: '0 0 * * *' workflow_dispatch: permissions: contents: read defaults: run: shell: cmd jobs: build: runs-on: windows-2022 if: ${{ github.repository_owner == 'danmar' }} env: # see https://www.pcre.org/original/changelog.txt PCRE_VERSION: 8.45 QT_VERSION: 6.8.1 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: Set up Visual Studio environment uses: ilammy/msvc-dev-cmd@v1 - name: Cache PCRE id: cache-pcre uses: actions/cache@v4 with: path: | externals\pcre.h externals\pcre64.lib key: pcre-${{ env.PCRE_VERSION }}-bin-x64-win-release-job - name: Download PCRE if: steps.cache-pcre.outputs.cache-hit != 'true' run: | curl -fsSL https://github.com/pfultz2/pcre/archive/refs/tags/%PCRE_VERSION%.zip -o pcre-%PCRE_VERSION%.zip || exit /b !errorlevel! - name: Install PCRE if: steps.cache-pcre.outputs.cache-hit != 'true' run: | 7z x pcre-%PCRE_VERSION%.zip || exit /b !errorlevel! cd pcre-%PCRE_VERSION% || exit /b !errorlevel! cmake . -G "Visual Studio 17 2022" -A x64 -DPCRE_BUILD_PCRECPP=OFF -DPCRE_BUILD_PCREGREP=OFF -DPCRE_BUILD_TESTS=OFF || exit /b !errorlevel! msbuild -m PCRE.sln -p:Configuration=Release -p:Platform=x64 || exit /b !errorlevel! copy pcre.h ..\externals || exit /b !errorlevel! copy Release\pcre.lib ..\externals\pcre64.lib || exit /b !errorlevel! # available modules: https://github.com/miurahr/aqtinstall/blob/master/docs/getting_started.rst#installing-modules # available tools: https://github.com/miurahr/aqtinstall/blob/master/docs/getting_started.rst#installing-tools - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} modules: 'qtcharts' tools: 'tools_opensslv3_x64' cache: true # TODO: build with multiple threads - name: Build x64 release GUI run: | :: TODO: enable rules? :: specify Release build so matchcompiler is used cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_ONLINE_HELP=On || exit /b !errorlevel! cmake --build build --target cppcheck-gui --config Release || exit /b !errorlevel! # TODO: package PDBs - name: Deploy app run: | windeployqt build\bin\Release || exit /b !errorlevel! del build\bin\Release\cppcheck-gui.ilk || exit /b !errorlevel! del build\bin\Release\cppcheck-gui.pdb || exit /b !errorlevel! - uses: actions/upload-artifact@v4 with: name: deploy path: build\bin\Release - name: Matchcompiler run: python tools\matchcompiler.py --write-dir lib || exit /b !errorlevel! # TODO: build with multiple threads # TODO: build with boost enabled - name: Build CLI x64 release configuration using MSBuild run: msbuild -m cppcheck.sln -t:cli -p:Configuration=Release-PCRE -p:Platform=x64 || exit /b !errorlevel! - uses: actions/upload-artifact@v4 with: name: bin path: bin - name: Install missing Python packages run: | pip install -U pyinstaller || exit /b !errorlevel! # TODO: include in installer? - name: Compile misra.py executable run: | cd addons || exit /b !errorlevel! pyinstaller --hidden-import xml --hidden-import xml.etree --hidden-import xml.etree.ElementTree misra.py || exit /b !errorlevel! del *.spec || exit /b !errorlevel! # TODO: include in installer? - name: Compile cppcheck-htmlreport executable run: | cd htmlreport || exit /b !errorlevel! pyinstaller cppcheck-htmlreport || exit /b !errorlevel! del *.spec || exit /b !errorlevel! # TODO: test the compiled Python files - name: Collect files run: | @echo on move build\bin\Release win_installer\files || exit /b !errorlevel! copy AUTHORS win_installer\files\authors.txt || exit /b !errorlevel! copy readme.txt win_installer\files\ || exit /b !errorlevel! copy win_installer\GPLv3.txt win_installer\files\ || exit /b !errorlevel! copy externals\picojson\LICENSE win_installer\files\picojson-license.txt || exit /b !errorlevel! copy externals\simplecpp\LICENSE win_installer\files\simplecpp-license.txt || exit /b !errorlevel! copy externals\tinyxml2\LICENSE win_installer\files\tinyxml2-license.txt || exit /b !errorlevel! copy addons\dist\misra\*.* win_installer\files\addons || exit /b !errorlevel! copy bin\cppcheck.exe win_installer\files || exit /b !errorlevel! copy bin\cppcheck-core.dll win_installer\files || exit /b !errorlevel! :: mkdir win_installer\files\help || exit /b !errorlevel! xcopy /s gui\help win_installer\files\help || exit /b !errorlevel! copy gui\help\online-help.qhc win_installer\files\ || exit /b !errorlevel! copy gui\help\online-help.qch win_installer\files\ || exit /b !errorlevel! del win_installer\files\cfg\*.rng || exit /b !errorlevel! del win_installer\files\platforms\*.rng || exit /b !errorlevel! del win_installer\files\translations\*.qm || exit /b !errorlevel! move build\gui\*.qm win_installer\files\translations || exit /b !errorlevel! copy htmlreport\dist\cppcheck-htmlreport\*.* win_installer\files || exit /b !errorlevel! :: copy libcrypto-3-x64.dll and libssl-3-x64.dll copy %RUNNER_WORKSPACE%\Qt\Tools\OpenSSLv3\Win_x64\bin\lib*.dll win_installer\files || exit /b !errorlevel! - uses: actions/upload-artifact@v4 with: name: collect path: win_installer\files - name: Build Installer run: | cd win_installer || exit /b !errorlevel! :: Read ProductVersion for /f "tokens=4 delims= " %%a in ('find "ProductVersion" productInfo.wxi') do set PRODUCTVER=%%a :: Remove double quotes set PRODUCTVER=%PRODUCTVER:"=% @echo ProductVersion="%PRODUCTVER%" || exit /b !errorlevel! msbuild -m cppcheck.wixproj -p:Platform=x64,ProductVersion=%PRODUCTVER%.${{ github.run_number }} || exit /b !errorlevel! - uses: actions/upload-artifact@v4 with: name: installer path: win_installer/Build/ - name: Clean up deploy run: | @echo on :: del win_installer\files\addons\*.dll || exit /b !errorlevel! del win_installer\files\addons\*.doxyfile || exit /b !errorlevel! del win_installer\files\addons\*.md || exit /b !errorlevel! :: del win_installer\files\addons\*.pyd || exit /b !errorlevel! :: del win_installer\files\addons\base_library.zip || exit /b !errorlevel! rmdir /s /q win_installer\files\addons\test || exit /b !errorlevel! rmdir /s /q win_installer\files\addons\doc || exit /b !errorlevel! :: rmdir /s /q win_installer\files\bearer || exit /b !errorlevel! rmdir /s /q win_installer\files\generic || exit /b !errorlevel! rmdir /s /q win_installer\files\help || exit /b !errorlevel! rmdir /s /q win_installer\files\iconengines || exit /b !errorlevel! rmdir /s /q win_installer\files\imageformats || exit /b !errorlevel! rmdir /s /q win_installer\files\networkinformation || exit /b !errorlevel! :: rmdir /s /q win_installer\files\printsupport || exit /b !errorlevel! rmdir /s /q win_installer\files\sqldrivers || exit /b !errorlevel! rmdir /s /q win_installer\files\tls || exit /b !errorlevel! ren win_installer\files\translations lang || exit /b !errorlevel! del win_installer\files\d3dcompiler_47.dll || exit /b !errorlevel! del win_installer\files\dxcompiler.dll || exit /b !errorlevel! del win_installer\files\dxil.dll || exit /b !errorlevel! del win_installer\files\dmake.exe || exit /b !errorlevel! del win_installer\files\dmake.pdb || exit /b !errorlevel! :: del win_installer\files\libEGL.dll || exit /b !errorlevel! :: del win_installer\files\libGLESv2.dll || exit /b !errorlevel! del win_installer\files\opengl32sw.dll || exit /b !errorlevel! del win_installer\files\Qt6Svg.dll || exit /b !errorlevel! del win_installer\files\vc_redist.x64.exe || exit /b !errorlevel! - uses: actions/upload-artifact@v4 with: name: portable path: win_installer\files cppcheck-2.17.1/.github/workflows/scriptcheck.yml000066400000000000000000000157201475760761100220270ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: scriptcheck on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: build: # 'ubuntu-22.04' removes Python 3.6 so keep the previous LTS version runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ runner.os }} - name: Cache Cppcheck uses: actions/cache@v4 with: path: cppcheck key: ${{ runner.os }}-scriptcheck-cppcheck-${{ github.sha }} - name: build cppcheck run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" make -j$(nproc) -s CXXFLAGS="-w" strip -s ./cppcheck scriptcheck: needs: build # 'ubuntu-22.04' removes Python 3.6 so keep the previous LTS version runs-on: ubuntu-20.04 strategy: matrix: python-version: [3.6, 3.7, 3.8, 3.9, '3.10', '3.11', '3.12', '3.13'] include: - python-version: '3.13' python-latest: true fail-fast: false steps: - uses: actions/checkout@v4 with: persist-credentials: false # TODO: bailout on error - name: Restore Cppcheck uses: actions/cache@v4 with: path: cppcheck key: ${{ runner.os }}-scriptcheck-cppcheck-${{ github.sha }} - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} check-latest: true - name: Install missing software on ubuntu run: | sudo apt-get update sudo apt-get install tidy libxml2-utils - name: Install missing software on ubuntu (Python 3) run: | # shellcheck cannot be installed via pip # ERROR: Could not find a version that satisfies the requirement shellcheck (from versions: none) # ERROR: No matching distribution found for shellcheck sudo apt-get install shellcheck python -m pip install pip --upgrade python -m pip install natsort python -m pip install pexpect python -m pip install 'pylint<=3.3.0' python -m pip install unittest2 python -m pip install pytest python -m pip install pytest-xdist python -m pip install pygments python -m pip install requests python -m pip install psutil python -m pip install setuptools - name: run Shellcheck if: matrix.python-latest run: | find . -name "*.sh" | xargs shellcheck --exclude SC2002,SC2013,SC2034,SC2035,SC2043,SC2046,SC2086,SC2089,SC2090,SC2129,SC2211,SC2231 - name: run pylint if: matrix.python-latest run: | shopt -s globstar pylint --jobs $(nproc) --py-version 3.6 addons/**/*.py htmlreport/cppcheck-htmlreport htmlreport/**/*.py test/**/*.py tools/**/*.py - name: check .json files if: matrix.python-latest run: | find . -name '*.json' | xargs -n 1 python -m json.tool > /dev/null - name: Validate if: matrix.python-latest run: | make -j$(nproc) validateCFG validatePlatforms validateRules - name: check python syntax run: | shopt -s globstar python -m py_compile addons/**/*.py python -m py_compile htmlreport/cppcheck-htmlreport python -m py_compile htmlreport/**/*.py python -m py_compile test/**/*.py python -m py_compile tools/**/*.py - name: compile addons run: | python -m compileall ./addons - name: test matchcompiler run: | python tools/test_matchcompiler.py # TODO: run with "-n auto" when misra_test.py can be run in parallel # we cannot specify -Werror since xml/etree/ElementTree.py in Python 3.9/3.10 contains an unclosed file - name: test addons if: matrix.python-version == '3.9' || matrix.python-version == '3.10' run: | python -m pytest --strict-markers -vv -n 1 addons/test env: PYTHONPATH: ./addons # TODO: run with "-n auto" when misra_test.py can be run in parallel - name: test addons if: matrix.python-version != '3.9' && matrix.python-version != '3.10' run: | python -m pytest -Werror --strict-markers -vv -n 1 addons/test env: PYTHONPATH: ./addons - name: test htmlreport (standalone) run: | test/tools/htmlreport/test_htmlreport.py cd test/tools/htmlreport ./check.sh # Python 3.5 and 3.6 are excluded as they are not supported by setuptools-scm package for getting # package version - name: test htmlreport (pip) if: matrix.python-version != '3.5' && matrix.python-version != '3.6' run: | python -m venv venv source venv/bin/activate python -m pip install -U pip pip install ./htmlreport/ which cppcheck-htmlreport PIP_PACKAGE_TEST=1 test/tools/htmlreport/test_htmlreport.py cd test/tools/htmlreport ./check.sh - name: test reduce run: | python -m pytest -Werror --strict-markers -vv tools/reduce_test.py env: PYTHONPATH: ./tools - name: test donate_cpu_lib run: | python -m pytest -Werror --strict-markers -vv tools/donate_cpu_lib_test.py env: PYTHONPATH: ./tools - name: test donate_cpu_server run: | python -m pytest -Werror --strict-markers -vv tools/donate_cpu_server_test.py # TODO: why is this file generated? also should be in a temporary folder if possible rm -f tools/donate-cpu-server.log env: PYTHONPATH: ./tools - name: Show all ignored files if: false # TODO: currently lists all the contents of ignored folders - we only need what actually matched run: | git ls-files --others --ignored --exclude-standard - name: Check for changed and unversioned files run: | # TODO: how to do this with a single command? git status --ignored=no git status --ignored=no | grep -q 'working tree clean' dmake: strategy: matrix: os: [ubuntu-22.04, macos-13, windows-2022] fail-fast: false runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: run dmake run: | make -j3 CXXFLAGS="-w" run-dmake - name: check diff run: | git diff --exit-code cppcheck-2.17.1/.github/workflows/selfcheck.yml000066400000000000000000000216251475760761100214550ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: selfcheck on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: build: runs-on: ubuntu-22.04 env: QT_VERSION: 6.8.1 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ runner.os }} - name: Install missing software run: | sudo apt-get update sudo apt-get install clang-14 sudo apt-get install libboost-container-dev sudo apt-get install valgrind sudo apt-get install -y libgl-dev # fixes missing dependency for Qt in CMake - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} modules: 'qtcharts' install-deps: false cache: true # TODO: cache this - perform same build as for the other self check - name: Self check (build) run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" # valgrind cannot handle DWARF 5 yet so force version 4 # work around performance regression with -inline-deferral make -j$(nproc) -s CXXFLAGS="-O2 -w -DHAVE_BOOST -gdwarf-4 -mllvm -inline-deferral" MATCHCOMPILER=yes env: CC: clang-14 CXX: clang++-14 # unusedFunction - start - name: CMake run: | cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=ON -DUSE_QT6=On -DWITH_QCHART=ON -DBUILD_TRIAGE=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On - name: Generate dependencies run: | # make sure auto-generated GUI files exist make -C cmake.output autogen # make sure the precompiled headers exist make -C cmake.output lib/CMakeFiles/cppcheck-core.dir/cmake_pch.hxx.cxx make -C cmake.output test/CMakeFiles/testrunner.dir/cmake_pch.hxx.cxx # make sure the auto-generated GUI dependencies exist make -C cmake.output gui-build-deps # TODO: find a way to report unmatched suppressions without need to add information checks - name: Self check (unusedFunction) if: false # TODO: fails with preprocessorErrorDirective - see #10667 run: | ./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --enable=unusedFunction --exception-handling -rp=. --project=cmake.output/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr env: DISABLE_VALUEFLOW: 1 UNUSEDFUNCTION_ONLY: 1 # unusedFunction - end # the following steps are duplicated from above since setting up the build node in a parallel step takes longer than the actual steps # unusedFunction notest - start - name: CMake (no test) run: | cmake -S . -B cmake.output.notest -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=Off -DBUILD_GUI=ON -DUSE_QT6=On -DBUILD_TRIAGE=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On - name: Generate dependencies (no test) run: | # make sure auto-generated GUI files exist make -C cmake.output.notest autogen # make sure the precompiled headers exist make -C cmake.output.notest lib/CMakeFiles/cppcheck-core.dir/cmake_pch.hxx.cxx # make sure the auto-generated GUI dependencies exist make -C cmake.output.notest gui-build-deps # TODO: find a way to report unmatched suppressions without need to add information checks - name: Self check (unusedFunction / no test) run: | ./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.notest/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr env: DISABLE_VALUEFLOW: 1 UNUSEDFUNCTION_ONLY: 1 # unusedFunction notest - end # unusedFunction notest nogui - start - name: CMake (no test / no gui) run: | cmake -S . -B cmake.output.notest_nogui -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=Off -DENABLE_CHECK_INTERNAL=On - name: Generate dependencies (no test / no gui) run: | # make sure the precompiled headers exist make -C cmake.output.notest_nogui lib/CMakeFiles/cppcheck-core.dir/cmake_pch.hxx.cxx # TODO: find a way to report unmatched suppressions without need to add information checks - name: Self check (unusedFunction / no test / no gui) run: | ./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib -D__CPPCHECK__ -D__GNUC__ --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.notest_nogui/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr env: DISABLE_VALUEFLOW: 1 UNUSEDFUNCTION_ONLY: 1 # unusedFunction notest nogui - end # unusedFunction notest nocli - start - name: CMake (no test / no cli) run: | cmake -S . -B cmake.output.notest_nocli -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=Off -DBUILD_CLI=Off -DBUILD_GUI=ON -DUSE_QT6=On -DWITH_QCHART=ON -DBUILD_TRIAGE=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On - name: Generate dependencies (no test / no cli) run: | # make sure auto-generated GUI files exist make -C cmake.output.notest_nocli autogen # make sure the precompiled headers exist make -C cmake.output.notest_nocli lib/CMakeFiles/cppcheck-core.dir/cmake_pch.hxx.cxx # make sure the auto-generated GUI dependencies exist make -C cmake.output.notest_nocli gui-build-deps # TODO: find a way to report unmatched suppressions without need to add information checks - name: Self check (unusedFunction / no test / no cli) if: false # TODO: the findings are currently too intrusive run: | ./cppcheck -q --template=selfcheck --error-exitcode=1 --library=cppcheck-lib --library=qt -D__CPPCHECK__ -D__GNUC__ -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.notest_nocli/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr env: DISABLE_VALUEFLOW: 1 UNUSEDFUNCTION_ONLY: 1 # unusedFunction notest nocli - end - name: Fetch corpus run: | wget https://github.com/danmar/cppcheck/archive/refs/tags/2.8.tar.gz tar xvf 2.8.tar.gz - name: CMake (corpus / no test) run: | cmake -S cppcheck-2.8 -B cmake.output.corpus -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=Off -DBUILD_GUI=ON -DUSE_QT6=On -DWITH_QCHART=ON -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On - name: Generate dependencies (corpus) run: | # make sure auto-generated GUI files exist make -C cmake.output.corpus autogen # make sure the precompiled headers exist make -C cmake.output.corpus lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.cxx # make sure the auto-generated GUI dependencies exist make -C cmake.output.corpus gui-build-deps # TODO: find a way to report unmatched suppressions without need to add information checks - name: Self check (unusedFunction / corpus / no test / callgrind) run: | # TODO: fix -rp so the suppressions actually work valgrind --tool=callgrind ./cppcheck --template=selfcheck --error-exitcode=0 --library=cppcheck-lib --library=qt -D__GNUC__ -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --enable=unusedFunction --exception-handling -rp=. --project=cmake.output.corpus/compile_commands.json --suppressions-list=.selfcheck_unused_suppressions --inline-suppr 2>callgrind.log || (cat callgrind.log && false) cat callgrind.log callgrind_annotate --auto=no > callgrind.annotated.log head -50 callgrind.annotated.log env: DISABLE_VALUEFLOW: 1 - uses: actions/upload-artifact@v4 with: name: Callgrind Output path: ./callgrind.* cppcheck-2.17.1/.github/workflows/tsan.yml000066400000000000000000000143341475760761100204720ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: thread sanitizer on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: build: runs-on: ubuntu-22.04 env: QT_VERSION: 6.8.1 TSAN_OPTIONS: halt_on_error=1 # TODO: figure out why there are cache misses with PCH enabled CCACHE_SLOPPINESS: pch_defines,time_macros steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} - name: Set up Python 3.13 uses: actions/setup-python@v5 with: python-version: '3.13' check-latest: true - name: Install missing software on ubuntu run: | sudo apt-get update sudo apt-get install -y cmake make libpcre3-dev libboost-container-dev libxml2-utils sudo apt-get install -y libcups2-dev # required for Qt6PrintSupport in CMake since Qt 6.7.3 - name: Install clang run: | sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 19 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} modules: 'qtcharts' cache: true - name: Install missing Python packages run: | python3 -m pip install pip --upgrade python3 -m pip install pytest python3 -m pip install pytest-timeout python3 -m pip install pytest-xdist python3 -m pip install psutil - name: CMake run: | cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_THREAD=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=Off -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache env: CC: clang-19 CXX: clang++-19 - name: Build cppcheck run: | cmake --build cmake.output --target cppcheck -- -j $(nproc) - name: Build test run: | cmake --build cmake.output --target testrunner -- -j $(nproc) - name: Build GUI tests run: | cmake --build cmake.output --target gui-tests -- -j $(nproc) - name: Run tests run: ./cmake.output/bin/testrunner - name: Run cfg tests run: | cmake --build cmake.output --target checkcfg -- -j $(nproc) - name: Run CTest if: false # TODO: test-filelist fails with data race in pthread_cond_destroy run: | ctest --test-dir cmake.output --output-on-failure -j$(nproc) - name: Run test/cli run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli env: TEST_CPPCHECK_INJECT_EXECUTOR: thread - name: Run test/cli (-j2) run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli env: TEST_CPPCHECK_INJECT_J: 2 - name: Run test/cli (--clang) if: false run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli env: TEST_CPPCHECK_INJECT_CLANG: clang - name: Run test/cli (--cppcheck-build-dir) run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli env: TEST_CPPCHECK_INJECT_BUILDDIR: injected - name: Generate dependencies if: false run: | # make sure auto-generated GUI files exist make -C cmake.output autogen make -C cmake.output gui-build-deps triage-build-ui-deps # TODO: disabled for now as it takes around 40 minutes to finish # set --error-exitcode=0 so we only fail on sanitizer issues - since it uses threads for execution it will exit the whole process on the first issue - name: Self check if: false run: | selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=file-total -D__GNUC__ --error-exitcode=0 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude --exception-handling --debug-warnings --check-level=exhaustive" selfcheck_options="$selfcheck_options --executor=thread" cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" ec=0 ./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli test/*.cpp tools/dmake/*.cpp || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage/*.cpp || ec=1 exit $ec cppcheck-2.17.1/.github/workflows/ubsan.yml000066400000000000000000000137651475760761100206440ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: undefined behaviour sanitizers on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: build: runs-on: ubuntu-22.04 env: QT_VERSION: 6.8.1 UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1:report_error_type=1 # TODO: figure out why there are cache misses with PCH enabled CCACHE_SLOPPINESS: pch_defines,time_macros steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }} - name: Set up Python 3.13 uses: actions/setup-python@v5 with: python-version: '3.13' check-latest: true - name: Install missing software on ubuntu run: | sudo apt-get update sudo apt-get install -y cmake make libpcre3-dev libboost-container-dev libxml2-utils sudo apt-get install -y libcups2-dev # required for Qt6PrintSupport in CMake since Qt 6.7.3 - name: Install clang run: | sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh 19 - name: Install Qt ${{ env.QT_VERSION }} uses: jurplel/install-qt-action@v4 with: version: ${{ env.QT_VERSION }} modules: 'qtcharts' cache: true - name: Install missing Python packages run: | python3 -m pip install pip --upgrade python3 -m pip install pytest python3 -m pip install pytest-timeout python3 -m pip install pytest-xdist python3 -m pip install psutil # TODO: disable warnings - name: CMake run: | cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DUSE_QT6=On -DWITH_QCHART=On -DBUILD_TRIAGE=On -DUSE_MATCHCOMPILER=Verify -DANALYZE_UNDEFINED=On -DENABLE_CHECK_INTERNAL=On -DUSE_BOOST=On -DCPPCHK_GLIBCXX_DEBUG=Off -DCMAKE_DISABLE_PRECOMPILE_HEADERS=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DDISABLE_DMAKE=On -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache env: CC: clang-19 CXX: clang++-19 - name: Build cppcheck run: | cmake --build cmake.output --target cppcheck -- -j $(nproc) - name: Build test run: | cmake --build cmake.output --target testrunner -- -j $(nproc) - name: Build GUI tests run: | cmake --build cmake.output --target gui-tests -- -j $(nproc) - name: Run tests run: ./cmake.output/bin/testrunner - name: Run cfg tests run: | cmake --build cmake.output --target checkcfg -- -j $(nproc) - name: Run CTest run: | ctest --test-dir cmake.output --output-on-failure -j$(nproc) - name: Run test/cli run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli - name: Run test/cli (-j2) run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli env: TEST_CPPCHECK_INJECT_J: 2 - name: Run test/cli (--clang) if: false run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli env: TEST_CPPCHECK_INJECT_CLANG: clang - name: Run test/cli (--cppcheck-build-dir) run: | pwd=$(pwd) TEST_CPPCHECK_EXE_LOOKUP_PATH="$pwd/cmake.output" python3 -m pytest -Werror --strict-markers -vv -n auto test/cli env: TEST_CPPCHECK_INJECT_BUILDDIR: injected - name: Generate dependencies run: | # make sure auto-generated GUI files exist make -C cmake.output autogen make -C cmake.output gui-build-deps triage-build-ui-deps # TODO: only fail the step on sanitizer issues - since we use processes it will only fail the underlying process which will result in an cppcheckError - name: Self check run: | selfcheck_options="-q -j$(nproc) --std=c++11 --template=selfcheck --showtime=file-total -D__GNUC__ --error-exitcode=1 --inline-suppr --suppressions-list=.selfcheck_suppressions --library=gnu --inconclusive --enable=style,performance,portability,warning,missingInclude --exception-handling --debug-warnings --check-level=exhaustive" cppcheck_options="-D__CPPCHECK__ -DCHECK_INTERNAL -DHAVE_RULES --library=cppcheck-lib -Ilib -Iexternals/simplecpp/ -Iexternals/tinyxml2" ec=0 ./cmake.output/bin/cppcheck $selfcheck_options externals || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json cli || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options --addon=naming.json --enable=internal lib || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQT_VERSION=0x060000 -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt --addon=naming.json -Icmake.output/gui -Igui gui/*.cpp cmake.output/gui/*.cpp || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -Icli test/*.cpp tools/dmake/*.cpp || ec=1 ./cmake.output/bin/cppcheck $selfcheck_options $cppcheck_options -DQ_MOC_OUTPUT_REVISION=68 -DQT_CHARTS_LIB -DQT_MOC_HAS_STRINGDATA --library=qt -Icmake.output/tools/triage -Igui tools/triage/*.cpp cmake.output/tools/triage/*.cpp || ec=1 exit $ec cppcheck-2.17.1/.github/workflows/valgrind.yml000066400000000000000000000040541475760761100213310ustar00rootroot00000000000000# Syntax reference https://help.github.com/en/actions/reference/workflow-syntax-for-github-actions # Environment reference https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners name: valgrind on: push: branches: - 'main' - 'releases/**' - '2.*' tags: - '2.*' pull_request: permissions: contents: read jobs: build: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 with: persist-credentials: false - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ github.workflow }}-${{ runner.os }} - name: Install missing software run: | sudo apt-get update sudo apt-get install libxml2-utils sudo apt-get install valgrind sudo apt-get install libboost-container-dev sudo apt-get install debuginfod - name: Build cppcheck run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" CXXFLAGS="-O1 -g -w -DHAVE_BOOST" make -j$(nproc) HAVE_RULES=yes MATCHCOMPILER=yes - name: Build test run: | export PATH="/usr/lib/ccache:/usr/local/opt/ccache/libexec:$PATH" CXXFLAGS="-O1 -g -w -DHAVE_BOOST" make -j$(nproc) testrunner HAVE_RULES=yes MATCHCOMPILER=yes - name: Run valgrind run: | ec=0 valgrind --error-limit=yes --leak-check=full --num-callers=50 --show-reachable=yes --track-origins=yes --suppressions=valgrind/testrunner.supp --gen-suppressions=all --log-fd=9 --error-exitcode=42 ./testrunner TestGarbage TestOther TestSimplifyTemplate 9>memcheck.log || ec=1 cat memcheck.log exit $ec # TODO: debuginfod.ubuntu.com is currently not responding to any requests causing it to run into a 40(!) minute timeout #env: # DEBUGINFOD_URLS: https://debuginfod.ubuntu.com - uses: actions/upload-artifact@v4 if: success() || failure() with: name: Logs path: ./*.log cppcheck-2.17.1/.gitignore000066400000000000000000000027311475760761100153730ustar00rootroot00000000000000*.bak *.gcno *.o *.pyc /cppcheck /cppcheck.exe cppcheck-core.dll /dmake /dmake.exe reduce reduce.exe tags /testrunner /testrunner.exe tools/daca2*.html tools/errmsg tools/extracttests # dump files generated by Cppcheck *.*.dump # CTU info files generated by Cppcheck *.*.ctu-info # VS generated files *.aps *.idb *.ncb *.obj *.opensdf *.orig *.pdb *.sdf *.suo *.user /.vs/ UpgradeLog*.htm # VS build folders bin/ Build/ BuildTmp/ /cli/temp/ ipch/ /lib/temp/ /test/temp/ # XCode build folders and files *.mode[0-9]v[0-9] *.pbxuser build/ # Other (generated) GUI files /gui/help/online-help.qch /gui/help/online-help.qhc # Doxygen output folder doxyoutput/ # Backup files and stuff from patches *.rej *~ # kdevelop 4.x *.kdev4 # Common cmake build directories build**/ # Temporal files *.swp # Snapcraft build part prime parts stage *.snap /snap/.snapcraft # Manual folder /man/manual.log /man/manual.tex /man/*.pdf /man/*.html # CLion /.idea /.metadata/ /cmake-build-* /.run # clang tooling temporary files /.clangd/ /.cache/ /compile_commands.json #vs code /.vscode # fuzzing output /oss-fuzz/corpus /oss-fuzz/corpus_ /oss-fuzz/samples # Python /.venv/ /venv/ **/*.egg-info/ # cppcheck-htmlreport auto files /htmlreport/cppcheck_htmlreport/run.py # GDB configuration .gdbinit # pyinstaller output /addons/dist /addons/misra.spec /htmlreport/cppcheck-htmlreport.spec /htmlreport/dist # ccache folder in CI /.ccache # PCRE Windows files /externals/pcre.h /externals/pcre64.libcppcheck-2.17.1/.mailmap000066400000000000000000000054471475760761100150330ustar00rootroot00000000000000Andreas Bießmann Andrew Martin acm4me Ankita Gupta Ankita-gupta Benjamin Goose Daniel Marjamäki Daniel Marjamäki Daniel Marjamäki Daniel Marjam�ki Daniel Marjamäki Daniel Marjamäki Deepak Gupta deepak gupta Ettl Martin Martin Ettl Ettl Martin Ettl Martin Martin Ettl Frank Zingsheim Gianluca Scacco Gianluca Scacco Henrik Nilsson Kimmo Varis Kimmo varis Kimmo Varis Kimmo Varis Kimmo Varis Kimmo Varis Kimmo Varis Kimmo Varis Leandro Penz Leandro Lisboa Penz Leandro Penz Leandro Lisboa Penz makulik unknown Nicolas Le Cam Pete Johns PKEuS Philipp K PKEuS Philipp Kloke PKEuS Reijo Tomperi Robert Reif Ryan Pavlik Sébastien Debrard seb777 Sébastien Debrard S�bastien Debrard Sébastien Debrard Debrard Sébastien Stefan Weil Tim Gerundt Vesa Pikki XhmikosR Zachary Blair Zachary Blair Zachary Blair zblair cppcheck-2.17.1/.pylintrc000066400000000000000000000037551475760761100152570ustar00rootroot00000000000000[MESSAGES CONTROL] disable= # W start redefined-builtin, broad-exception-caught, fixme, bare-except, redefined-outer-name, attribute-defined-outside-init, unspecified-encoding, global-statement, protected-access, broad-exception-raised, subprocess-popen-preexec-fn, logging-not-lazy, unknown-option-value, unused-wildcard-import, wildcard-import, unused-argument, deprecated-module, pointless-string-statement, arguments-renamed, duplicate-string-formatting-argument, # C start consider-using-f-string, invalid-name, line-too-long, missing-module-docstring, missing-function-docstring, import-outside-toplevel, missing-class-docstring, superfluous-parens, too-many-lines, trailing-newlines, missing-final-newline, use-implicit-booleaness-not-len, wrong-import-order, use-implicit-booleaness-not-comparison, consider-using-enumerate, unnecessary-lambda-assignment, consider-using-dict-items, consider-iterating-dictionary, # R start duplicate-code, consider-using-with, too-many-statements, too-many-branches, too-many-locals, too-many-arguments, too-few-public-methods, too-many-return-statements, consider-using-in, too-many-nested-blocks, too-many-public-methods, chained-comparison, too-many-instance-attributes, too-many-boolean-expressions, use-a-generator, too-many-positional-arguments [REPORTS] reports=no [TYPECHECK] # See https://stackoverflow.com/questions/10300082/how-to-prevent-python-pylint-complaining-about-socket-class-sendall-method ignored-classes=SQLObject,_socketobject [MASTER] init-hook='import sys; sys.path.append("./addons")' suggestion-mode=yes cppcheck-2.17.1/.selfcheck_suppressions000066400000000000000000000024231475760761100201660ustar00rootroot00000000000000missingIncludeSystem # temporary suppressions - fix the warnings! simplifyUsing:lib/valueptr.h varid0:gui/projectfile.cpp naming-privateMemberVariable:gui/test/cppchecklibrarydata/testcppchecklibrarydata.h symbolDatabaseWarning:*/moc_*.cpp simplifyUsing:*/moc_*.cpp # warnings in Qt generated code we cannot fix funcArgNamesDifferent:*/moc_*.cpp naming-varname:*/ui_*.h functionStatic:*/ui_fileview.h # --debug-warnings suppressions valueFlowBailout valueFlowBailoutIncompleteVar autoNoType # ticket 11631 templateInstantiation:test/testutils.cpp naming-varname:externals/simplecpp/simplecpp.h naming-privateMemberVariable:externals/simplecpp/simplecpp.h valueFlowMaxIterations:externals/tinyxml2/tinyxml2.cpp # TODO: these warnings need to be addressed upstream uninitMemberVar:externals/tinyxml2/tinyxml2.h noExplicitConstructor:externals/tinyxml2/tinyxml2.h missingOverride:externals/tinyxml2/tinyxml2.h invalidPrintfArgType_sint:externals/tinyxml2/tinyxml2.h naming-privateMemberVariable:externals/tinyxml2/tinyxml2.h functionStatic:externals/tinyxml2/tinyxml2.h invalidPrintfArgType_uint:externals/tinyxml2/tinyxml2.cpp funcArgNamesDifferent:externals/tinyxml2/tinyxml2.cpp nullPointerRedundantCheck:externals/tinyxml2/tinyxml2.cpp knownConditionTrueFalse:externals/tinyxml2/tinyxml2.cpp cppcheck-2.17.1/.selfcheck_unused_suppressions000066400000000000000000000004241475760761100215500ustar00rootroot00000000000000# we are not using all methods of their interfaces unusedFunction:externals/*/* # usage is disabled unusedFunction:lib/symboldatabase.cpp # Q_OBJECT functions which are not called in our code unusedFunction:cmake.output.notest/gui/cppcheck-gui_autogen/*/moc_aboutdialog.cpp cppcheck-2.17.1/.uncrustify.cfg000066400000000000000000003622641475760761100163670ustar00rootroot00000000000000# Uncrustify-0.72.0_f # # General options # # The type of line endings. # # Default: auto newlines = auto # lf/crlf/cr/auto # The original size of tabs in the input. # # Default: 8 input_tab_size = 4 # unsigned number # The size of tabs in the output (only used if align_with_tabs=true). # # Default: 8 output_tab_size = 4 # unsigned number # The ASCII value of the string escape char, usually 92 (\) or (Pawn) 94 (^). # # Default: 92 string_escape_char = 92 # unsigned number # Alternate string escape char (usually only used for Pawn). # Only works right before the quote char. string_escape_char2 = 0 # unsigned number # Replace tab characters found in string literals with the escape sequence \t # instead. string_replace_tab_chars = false # true/false # Allow interpreting '>=' and '>>=' as part of a template in code like # 'void f(list>=val);'. If true, 'assert(x<0 && y>=3)' will be broken. # Improvements to template detection may make this option obsolete. tok_split_gte = false # true/false # Disable formatting of NL_CONT ('\\n') ended lines (e.g. multiline macros) disable_processing_nl_cont = false # true/false # Specify the marker used in comments to disable processing of part of the # file. # The comment should be used alone in one line. # # Default: *INDENT-OFF* disable_processing_cmt = " *INDENT-OFF*" # string # Specify the marker used in comments to (re)enable processing in a file. # The comment should be used alone in one line. # # Default: *INDENT-ON* enable_processing_cmt = " *INDENT-ON*" # string # Enable parsing of digraphs. enable_digraphs = false # true/false # Add or remove the UTF-8 BOM (recommend 'remove'). utf8_bom = ignore # ignore/add/remove/force # If the file contains bytes with values between 128 and 255, but is not # UTF-8, then output as UTF-8. utf8_byte = false # true/false # Force the output encoding to UTF-8. utf8_force = false # true/false # Add or remove space between 'do' and '{'. sp_do_brace_open = ignore # ignore/add/remove/force # Add or remove space between '}' and 'while'. sp_brace_close_while = ignore # ignore/add/remove/force # Add or remove space between 'while' and '('. sp_while_paren_open = add # ignore/add/remove/force # # Spacing options # # Add or remove space around non-assignment symbolic operators ('+', '/', '%', # '<<', and so forth). sp_arith = ignore # ignore/add/remove/force # Add or remove space around arithmetic operators '+' and '-'. # # Overrides sp_arith. sp_arith_additive = ignore # ignore/add/remove/force # Add or remove space around assignment operator '=', '+=', etc. sp_assign = ignore # ignore/add/remove/force # Add or remove space around '=' in C++11 lambda capture specifications. # # Overrides sp_assign. sp_cpp_lambda_assign = ignore # ignore/add/remove/force # Add or remove space after the capture specification of a C++11 lambda when # an argument list is present, as in '[] (int x){ ... }'. sp_cpp_lambda_square_paren = ignore # ignore/add/remove/force # Add or remove space after the capture specification of a C++11 lambda with # no argument list is present, as in '[] { ... }'. sp_cpp_lambda_square_brace = ignore # ignore/add/remove/force # Add or remove space after the argument list of a C++11 lambda, as in # '[](int x) { ... }'. sp_cpp_lambda_paren_brace = ignore # ignore/add/remove/force # Add or remove space between a lambda body and its call operator of an # immediately invoked lambda, as in '[]( ... ){ ... } ( ... )'. sp_cpp_lambda_fparen = ignore # ignore/add/remove/force # Add or remove space around assignment operator '=' in a prototype. # # If set to ignore, use sp_assign. sp_assign_default = ignore # ignore/add/remove/force # Add or remove space before assignment operator '=', '+=', etc. # # Overrides sp_assign. sp_before_assign = ignore # ignore/add/remove/force # Add or remove space after assignment operator '=', '+=', etc. # # Overrides sp_assign. sp_after_assign = ignore # ignore/add/remove/force # Add or remove space in 'NS_ENUM ('. sp_enum_paren = ignore # ignore/add/remove/force # Add or remove space around assignment '=' in enum. sp_enum_assign = ignore # ignore/add/remove/force # Add or remove space before assignment '=' in enum. # # Overrides sp_enum_assign. sp_enum_before_assign = ignore # ignore/add/remove/force # Add or remove space after assignment '=' in enum. # # Overrides sp_enum_assign. sp_enum_after_assign = ignore # ignore/add/remove/force # Add or remove space around assignment ':' in enum. sp_enum_colon = ignore # ignore/add/remove/force # Add or remove space around preprocessor '##' concatenation operator. # # Default: add sp_pp_concat = add # ignore/add/remove/force # Add or remove space after preprocessor '#' stringify operator. # Also affects the '#@' charizing operator. sp_pp_stringify = ignore # ignore/add/remove/force # Add or remove space before preprocessor '#' stringify operator # as in '#define x(y) L#y'. sp_before_pp_stringify = ignore # ignore/add/remove/force # Add or remove space around boolean operators '&&' and '||'. sp_bool = force # ignore/add/remove/force # Add or remove space around compare operator '<', '>', '==', etc. sp_compare = ignore # ignore/add/remove/force # Add or remove space inside '(' and ')'. sp_inside_paren = remove # ignore/add/remove/force # Add or remove space between nested parentheses, i.e. '((' vs. ') )'. sp_paren_paren = remove # ignore/add/remove/force # Add or remove space between back-to-back parentheses, i.e. ')(' vs. ') ('. sp_cparen_oparen = ignore # ignore/add/remove/force # Whether to balance spaces inside nested parentheses. sp_balance_nested_parens = false # true/false # Add or remove space between ')' and '{'. sp_paren_brace = force # ignore/add/remove/force # Add or remove space between nested braces, i.e. '{{' vs '{ {'. sp_brace_brace = ignore # ignore/add/remove/force # Add or remove space before pointer star '*'. sp_before_ptr_star = ignore # ignore/add/remove/force # Add or remove space before pointer star '*' that isn't followed by a # variable name. If set to ignore, sp_before_ptr_star is used instead. sp_before_unnamed_ptr_star = ignore # ignore/add/remove/force # Add or remove space between pointer stars '*'. sp_between_ptr_star = remove # ignore/add/remove/force # Add or remove space after pointer star '*', if followed by a word. # # Overrides sp_type_func. sp_after_ptr_star = ignore # ignore/add/remove/force # Add or remove space after pointer caret '^', if followed by a word. sp_after_ptr_block_caret = ignore # ignore/add/remove/force # Add or remove space after pointer star '*', if followed by a qualifier. sp_after_ptr_star_qualifier = ignore # ignore/add/remove/force # Add or remove space after a pointer star '*', if followed by a function # prototype or function definition. # # Overrides sp_after_ptr_star and sp_type_func. sp_after_ptr_star_func = ignore # ignore/add/remove/force # Add or remove space after a pointer star '*', if followed by an open # parenthesis, as in 'void* (*)(). sp_ptr_star_paren = ignore # ignore/add/remove/force # Add or remove space before a pointer star '*', if followed by a function # prototype or function definition. sp_before_ptr_star_func = ignore # ignore/add/remove/force # Add or remove space before a reference sign '&'. sp_before_byref = ignore # ignore/add/remove/force # Add or remove space before a reference sign '&' that isn't followed by a # variable name. If set to ignore, sp_before_byref is used instead. sp_before_unnamed_byref = ignore # ignore/add/remove/force # Add or remove space after reference sign '&', if followed by a word. # # Overrides sp_type_func. sp_after_byref = ignore # ignore/add/remove/force # Add or remove space after a reference sign '&', if followed by a function # prototype or function definition. # # Overrides sp_after_byref and sp_type_func. sp_after_byref_func = ignore # ignore/add/remove/force # Add or remove space before a reference sign '&', if followed by a function # prototype or function definition. sp_before_byref_func = ignore # ignore/add/remove/force # Add or remove space between type and word. In cases where total removal of # whitespace would be a syntax error, a value of 'remove' is treated the same # as 'force'. # # This also affects some other instances of space following a type that are # not covered by other options; for example, between the return type and # parenthesis of a function type template argument, between the type and # parenthesis of an array parameter, or between 'decltype(...)' and the # following word. # # Default: force sp_after_type = force # ignore/add/remove/force # Add or remove space between 'decltype(...)' and word. # # Overrides sp_after_type. sp_after_decltype = ignore # ignore/add/remove/force # (D) Add or remove space before the parenthesis in the D constructs # 'template Foo(' and 'class Foo('. sp_before_template_paren = ignore # ignore/add/remove/force # Add or remove space between 'template' and '<'. # If set to ignore, sp_before_angle is used. sp_template_angle = ignore # ignore/add/remove/force # Add or remove space before '<'. sp_before_angle = remove # ignore/add/remove/force # Add or remove space inside '<' and '>'. sp_inside_angle = remove # ignore/add/remove/force # Add or remove space inside '<>'. sp_inside_angle_empty = ignore # ignore/add/remove/force # Add or remove space between '>' and ':'. sp_angle_colon = ignore # ignore/add/remove/force # Add or remove space after '>'. sp_after_angle = add # ignore/add/remove/force # Add or remove space between '>' and '(' as found in 'new List(foo);'. sp_angle_paren = remove # ignore/add/remove/force # Add or remove space between '>' and '()' as found in 'new List();'. sp_angle_paren_empty = ignore # ignore/add/remove/force # Add or remove space between '>' and a word as in 'List m;' or # 'template static ...'. sp_angle_word = add # ignore/add/remove/force # Add or remove space between '>' and '>' in '>>' (template stuff). # # Default: add sp_angle_shift = ignore # ignore/add/remove/force # (C++11) Permit removal of the space between '>>' in 'foo >'. Note # that sp_angle_shift cannot remove the space without this option. sp_permit_cpp11_shift = true # true/false # Add or remove space before '(' of control statements ('if', 'for', 'switch', # 'while', etc.). sp_before_sparen = force # ignore/add/remove/force # Add or remove space inside '(' and ')' of control statements. sp_inside_sparen = remove # ignore/add/remove/force # Add or remove space after '(' of control statements. # # Overrides sp_inside_sparen. sp_inside_sparen_open = ignore # ignore/add/remove/force # Add or remove space before ')' of control statements. # # Overrides sp_inside_sparen. sp_inside_sparen_close = ignore # ignore/add/remove/force # Add or remove space after ')' of control statements. sp_after_sparen = force # ignore/add/remove/force # Add or remove space between ')' and '{' of of control statements. sp_sparen_brace = force # ignore/add/remove/force # (D) Add or remove space between 'invariant' and '('. sp_invariant_paren = ignore # ignore/add/remove/force # (D) Add or remove space after the ')' in 'invariant (C) c'. sp_after_invariant_paren = ignore # ignore/add/remove/force # Add or remove space before empty statement ';' on 'if', 'for' and 'while'. sp_special_semi = ignore # ignore/add/remove/force # Add or remove space before ';'. # # Default: remove sp_before_semi = remove # ignore/add/remove/force # Add or remove space before ';' in non-empty 'for' statements. sp_before_semi_for = remove # ignore/add/remove/force # Add or remove space before a semicolon of an empty part of a for statement. sp_before_semi_for_empty = ignore # ignore/add/remove/force # Add or remove space after ';', except when followed by a comment. # # Default: add sp_after_semi = add # ignore/add/remove/force # Add or remove space after ';' in non-empty 'for' statements. # # Default: force sp_after_semi_for = force # ignore/add/remove/force # Add or remove space after the final semicolon of an empty part of a for # statement, as in 'for ( ; ; )'. sp_after_semi_for_empty = remove # ignore/add/remove/force # Add or remove space before '[' (except '[]'). sp_before_square = ignore # ignore/add/remove/force # Add or remove space before '[' for a variable definition. # # Default: remove sp_before_vardef_square = remove # ignore/add/remove/force # Add or remove space before '[' for asm block. sp_before_square_asm_block = ignore # ignore/add/remove/force # Add or remove space before '[]'. sp_before_squares = remove # ignore/add/remove/force # Add or remove space before C++17 structured bindings. sp_cpp_before_struct_binding = ignore # ignore/add/remove/force # Add or remove space inside a non-empty '[' and ']'. sp_inside_square = remove # ignore/add/remove/force # Add or remove space inside '[]'. sp_inside_square_empty = ignore # ignore/add/remove/force # (OC) Add or remove space inside a non-empty Objective-C boxed array '@[' and # ']'. If set to ignore, sp_inside_square is used. sp_inside_square_oc_array = ignore # ignore/add/remove/force # Add or remove space after ',', i.e. 'a,b' vs. 'a, b'. sp_after_comma = ignore # ignore/add/remove/force # Add or remove space before ','. # # Default: remove sp_before_comma = remove # ignore/add/remove/force # (C#) Add or remove space between ',' and ']' in multidimensional array type # like 'int[,,]'. sp_after_mdatype_commas = ignore # ignore/add/remove/force # (C#) Add or remove space between '[' and ',' in multidimensional array type # like 'int[,,]'. sp_before_mdatype_commas = ignore # ignore/add/remove/force # (C#) Add or remove space between ',' in multidimensional array type # like 'int[,,]'. sp_between_mdatype_commas = ignore # ignore/add/remove/force # Add or remove space between an open parenthesis and comma, # i.e. '(,' vs. '( ,'. # # Default: force sp_paren_comma = force # ignore/add/remove/force # Add or remove space before the variadic '...' when preceded by a # non-punctuator. sp_before_ellipsis = ignore # ignore/add/remove/force # Add or remove space between a type and '...'. sp_type_ellipsis = ignore # ignore/add/remove/force # (D) Add or remove space between a type and '?'. sp_type_question = ignore # ignore/add/remove/force # Add or remove space between ')' and '...'. sp_paren_ellipsis = ignore # ignore/add/remove/force # Add or remove space between ')' and a qualifier such as 'const'. sp_paren_qualifier = ignore # ignore/add/remove/force # Add or remove space between ')' and 'noexcept'. sp_paren_noexcept = ignore # ignore/add/remove/force # Add or remove space after class ':'. sp_after_class_colon = force # ignore/add/remove/force # Add or remove space before class ':'. sp_before_class_colon = force # ignore/add/remove/force # Add or remove space after class constructor ':'. sp_after_constr_colon = ignore # ignore/add/remove/force # Add or remove space before class constructor ':'. sp_before_constr_colon = ignore # ignore/add/remove/force # Add or remove space before case ':'. # # Default: remove sp_before_case_colon = remove # ignore/add/remove/force # Add or remove space between 'operator' and operator sign. sp_after_operator = ignore # ignore/add/remove/force # Add or remove space between the operator symbol and the open parenthesis, as # in 'operator ++('. sp_after_operator_sym = ignore # ignore/add/remove/force # Overrides sp_after_operator_sym when the operator has no arguments, as in # 'operator *()'. sp_after_operator_sym_empty = ignore # ignore/add/remove/force # Add or remove space after C/D cast, i.e. 'cast(int)a' vs. 'cast(int) a' or # '(int)a' vs. '(int) a'. sp_after_cast = ignore # ignore/add/remove/force # Add or remove spaces inside cast parentheses. sp_inside_paren_cast = ignore # ignore/add/remove/force # Add or remove space between the type and open parenthesis in a C++ cast, # i.e. 'int(exp)' vs. 'int (exp)'. sp_cpp_cast_paren = ignore # ignore/add/remove/force # Add or remove space between 'sizeof' and '('. sp_sizeof_paren = ignore # ignore/add/remove/force # Add or remove space between 'sizeof' and '...'. sp_sizeof_ellipsis = ignore # ignore/add/remove/force # Add or remove space between 'sizeof...' and '('. sp_sizeof_ellipsis_paren = ignore # ignore/add/remove/force # Add or remove space between 'decltype' and '('. sp_decltype_paren = ignore # ignore/add/remove/force # (Pawn) Add or remove space after the tag keyword. sp_after_tag = ignore # ignore/add/remove/force # Add or remove space inside enum '{' and '}'. sp_inside_braces_enum = ignore # ignore/add/remove/force # Add or remove space inside struct/union '{' and '}'. sp_inside_braces_struct = ignore # ignore/add/remove/force # (OC) Add or remove space inside Objective-C boxed dictionary '{' and '}' sp_inside_braces_oc_dict = ignore # ignore/add/remove/force # Add or remove space after open brace in an unnamed temporary # direct-list-initialization. sp_after_type_brace_init_lst_open = ignore # ignore/add/remove/force # Add or remove space before close brace in an unnamed temporary # direct-list-initialization. sp_before_type_brace_init_lst_close = ignore # ignore/add/remove/force # Add or remove space inside an unnamed temporary direct-list-initialization. sp_inside_type_brace_init_lst = ignore # ignore/add/remove/force # Add or remove space inside '{' and '}'. sp_inside_braces = ignore # ignore/add/remove/force # Add or remove space inside '{}'. sp_inside_braces_empty = remove # ignore/add/remove/force # Add or remove space around trailing return operator '->'. sp_trailing_return = ignore # ignore/add/remove/force # Add or remove space between return type and function name. A minimum of 1 # is forced except for pointer return types. sp_type_func = ignore # ignore/add/remove/force # Add or remove space between type and open brace of an unnamed temporary # direct-list-initialization. sp_type_brace_init_lst = ignore # ignore/add/remove/force # Add or remove space between function name and '(' on function declaration. sp_func_proto_paren = ignore # ignore/add/remove/force # Add or remove space between function name and '()' on function declaration # without parameters. sp_func_proto_paren_empty = ignore # ignore/add/remove/force # Add or remove space between function name and '(' with a typedef specifier. sp_func_type_paren = ignore # ignore/add/remove/force # Add or remove space between alias name and '(' of a non-pointer function type typedef. sp_func_def_paren = ignore # ignore/add/remove/force # Add or remove space between function name and '()' on function definition # without parameters. sp_func_def_paren_empty = ignore # ignore/add/remove/force # Add or remove space inside empty function '()'. # Overrides sp_after_angle unless use_sp_after_angle_always is set to true. sp_inside_fparens = ignore # ignore/add/remove/force # Add or remove space inside function '(' and ')'. sp_inside_fparen = ignore # ignore/add/remove/force # Add or remove space inside the first parentheses in a function type, as in # 'void (*x)(...)'. sp_inside_tparen = ignore # ignore/add/remove/force # Add or remove space between the ')' and '(' in a function type, as in # 'void (*x)(...)'. sp_after_tparen_close = ignore # ignore/add/remove/force # Add or remove space between ']' and '(' when part of a function call. sp_square_fparen = ignore # ignore/add/remove/force # Add or remove space between ')' and '{' of function. sp_fparen_brace = ignore # ignore/add/remove/force # Add or remove space between ')' and '{' of a function call in object # initialization. # # Overrides sp_fparen_brace. sp_fparen_brace_initializer = ignore # ignore/add/remove/force # (Java) Add or remove space between ')' and '{{' of double brace initializer. sp_fparen_dbrace = ignore # ignore/add/remove/force # Add or remove space between function name and '(' on function calls. sp_func_call_paren = ignore # ignore/add/remove/force # Add or remove space between function name and '()' on function calls without # parameters. If set to ignore (the default), sp_func_call_paren is used. sp_func_call_paren_empty = ignore # ignore/add/remove/force # Add or remove space between the user function name and '(' on function # calls. You need to set a keyword to be a user function in the config file, # like: # set func_call_user tr _ i18n sp_func_call_user_paren = ignore # ignore/add/remove/force # Add or remove space inside user function '(' and ')'. sp_func_call_user_inside_fparen = ignore # ignore/add/remove/force # Add or remove space between nested parentheses with user functions, # i.e. '((' vs. '( ('. sp_func_call_user_paren_paren = ignore # ignore/add/remove/force # Add or remove space between a constructor/destructor and the open # parenthesis. sp_func_class_paren = ignore # ignore/add/remove/force # Add or remove space between a constructor without parameters or destructor # and '()'. sp_func_class_paren_empty = ignore # ignore/add/remove/force # Add or remove space between 'return' and '('. sp_return_paren = ignore # ignore/add/remove/force # Add or remove space between 'return' and '{'. sp_return_brace = ignore # ignore/add/remove/force # Add or remove space between '__attribute__' and '('. sp_attribute_paren = ignore # ignore/add/remove/force # Add or remove space between 'defined' and '(' in '#if defined (FOO)'. sp_defined_paren = ignore # ignore/add/remove/force # Add or remove space between 'throw' and '(' in 'throw (something)'. sp_throw_paren = ignore # ignore/add/remove/force # Add or remove space between 'throw' and anything other than '(' as in # '@throw [...];'. sp_after_throw = ignore # ignore/add/remove/force # Add or remove space between 'catch' and '(' in 'catch (something) { }'. # If set to ignore, sp_before_sparen is used. sp_catch_paren = ignore # ignore/add/remove/force # (OC) Add or remove space between '@catch' and '(' # in '@catch (something) { }'. If set to ignore, sp_catch_paren is used. sp_oc_catch_paren = ignore # ignore/add/remove/force # (OC) Add or remove space before Objective-C protocol list # as in '@protocol Protocol' or '@interface MyClass : NSObject'. sp_before_oc_proto_list = ignore # ignore/add/remove/force # (OC) Add or remove space between class name and '(' # in '@interface className(categoryName):BaseClass' sp_oc_classname_paren = ignore # ignore/add/remove/force # (D) Add or remove space between 'version' and '(' # in 'version (something) { }'. If set to ignore, sp_before_sparen is used. sp_version_paren = ignore # ignore/add/remove/force # (D) Add or remove space between 'scope' and '(' # in 'scope (something) { }'. If set to ignore, sp_before_sparen is used. sp_scope_paren = ignore # ignore/add/remove/force # Add or remove space between 'super' and '(' in 'super (something)'. # # Default: remove sp_super_paren = remove # ignore/add/remove/force # Add or remove space between 'this' and '(' in 'this (something)'. # # Default: remove sp_this_paren = remove # ignore/add/remove/force # Add or remove space between a macro name and its definition. sp_macro = ignore # ignore/add/remove/force # Add or remove space between a macro function ')' and its definition. sp_macro_func = ignore # ignore/add/remove/force # Add or remove space between 'else' and '{' if on the same line. sp_else_brace = force # ignore/add/remove/force # Add or remove space between '}' and 'else' if on the same line. sp_brace_else = force # ignore/add/remove/force # Add or remove space between '}' and the name of a typedef on the same line. sp_brace_typedef = ignore # ignore/add/remove/force # Add or remove space before the '{' of a 'catch' statement, if the '{' and # 'catch' are on the same line, as in 'catch (decl) {'. sp_catch_brace = force # ignore/add/remove/force # (OC) Add or remove space before the '{' of a '@catch' statement, if the '{' # and '@catch' are on the same line, as in '@catch (decl) {'. # If set to ignore, sp_catch_brace is used. sp_oc_catch_brace = ignore # ignore/add/remove/force # Add or remove space between '}' and 'catch' if on the same line. sp_brace_catch = force # ignore/add/remove/force # (OC) Add or remove space between '}' and '@catch' if on the same line. # If set to ignore, sp_brace_catch is used. sp_oc_brace_catch = ignore # ignore/add/remove/force # Add or remove space between 'finally' and '{' if on the same line. sp_finally_brace = ignore # ignore/add/remove/force # Add or remove space between '}' and 'finally' if on the same line. sp_brace_finally = ignore # ignore/add/remove/force # Add or remove space between 'try' and '{' if on the same line. sp_try_brace = ignore # ignore/add/remove/force # Add or remove space between get/set and '{' if on the same line. sp_getset_brace = ignore # ignore/add/remove/force # Add or remove space between a variable and '{' for C++ uniform # initialization. sp_word_brace_init_lst = ignore # ignore/add/remove/force # Add or remove space between a variable and '{' for a namespace. # # Default: add sp_word_brace_ns = add # ignore/add/remove/force # Add or remove space before the '::' operator. sp_before_dc = ignore # ignore/add/remove/force # Add or remove space after the '::' operator. sp_after_dc = ignore # ignore/add/remove/force # (D) Add or remove around the D named array initializer ':' operator. sp_d_array_colon = ignore # ignore/add/remove/force # Add or remove space after the '!' (not) unary operator. # # Default: remove sp_not = remove # ignore/add/remove/force # Add or remove space after the '~' (invert) unary operator. # # Default: remove sp_inv = remove # ignore/add/remove/force # Add or remove space after the '&' (address-of) unary operator. This does not # affect the spacing after a '&' that is part of a type. # # Default: remove sp_addr = remove # ignore/add/remove/force # Add or remove space around the '.' or '->' operators. # # Default: remove sp_member = remove # ignore/add/remove/force # Add or remove space after the '*' (dereference) unary operator. This does # not affect the spacing after a '*' that is part of a type. # # Default: remove sp_deref = remove # ignore/add/remove/force # Add or remove space after '+' or '-', as in 'x = -5' or 'y = +7'. # # Default: remove sp_sign = remove # ignore/add/remove/force # Add or remove space between '++' and '--' the word to which it is being # applied, as in '(--x)' or 'y++;'. # # Default: remove sp_incdec = remove # ignore/add/remove/force # Add or remove space before a backslash-newline at the end of a line. # # Default: add sp_before_nl_cont = add # ignore/add/remove/force # (OC) Add or remove space after the scope '+' or '-', as in '-(void) foo;' # or '+(int) bar;'. sp_after_oc_scope = ignore # ignore/add/remove/force # (OC) Add or remove space after the colon in message specs, # i.e. '-(int) f:(int) x;' vs. '-(int) f: (int) x;'. sp_after_oc_colon = ignore # ignore/add/remove/force # (OC) Add or remove space before the colon in message specs, # i.e. '-(int) f: (int) x;' vs. '-(int) f : (int) x;'. sp_before_oc_colon = ignore # ignore/add/remove/force # (OC) Add or remove space after the colon in immutable dictionary expression # 'NSDictionary *test = @{@"foo" :@"bar"};'. sp_after_oc_dict_colon = ignore # ignore/add/remove/force # (OC) Add or remove space before the colon in immutable dictionary expression # 'NSDictionary *test = @{@"foo" :@"bar"};'. sp_before_oc_dict_colon = ignore # ignore/add/remove/force # (OC) Add or remove space after the colon in message specs, # i.e. '[object setValue:1];' vs. '[object setValue: 1];'. sp_after_send_oc_colon = ignore # ignore/add/remove/force # (OC) Add or remove space before the colon in message specs, # i.e. '[object setValue:1];' vs. '[object setValue :1];'. sp_before_send_oc_colon = ignore # ignore/add/remove/force # (OC) Add or remove space after the (type) in message specs, # i.e. '-(int)f: (int) x;' vs. '-(int)f: (int)x;'. sp_after_oc_type = ignore # ignore/add/remove/force # (OC) Add or remove space after the first (type) in message specs, # i.e. '-(int) f:(int)x;' vs. '-(int)f:(int)x;'. sp_after_oc_return_type = ignore # ignore/add/remove/force # (OC) Add or remove space between '@selector' and '(', # i.e. '@selector(msgName)' vs. '@selector (msgName)'. # Also applies to '@protocol()' constructs. sp_after_oc_at_sel = ignore # ignore/add/remove/force # (OC) Add or remove space between '@selector(x)' and the following word, # i.e. '@selector(foo) a:' vs. '@selector(foo)a:'. sp_after_oc_at_sel_parens = ignore # ignore/add/remove/force # (OC) Add or remove space inside '@selector' parentheses, # i.e. '@selector(foo)' vs. '@selector( foo )'. # Also applies to '@protocol()' constructs. sp_inside_oc_at_sel_parens = ignore # ignore/add/remove/force # (OC) Add or remove space before a block pointer caret, # i.e. '^int (int arg){...}' vs. ' ^int (int arg){...}'. sp_before_oc_block_caret = ignore # ignore/add/remove/force # (OC) Add or remove space after a block pointer caret, # i.e. '^int (int arg){...}' vs. '^ int (int arg){...}'. sp_after_oc_block_caret = ignore # ignore/add/remove/force # (OC) Add or remove space between the receiver and selector in a message, # as in '[receiver selector ...]'. sp_after_oc_msg_receiver = ignore # ignore/add/remove/force # (OC) Add or remove space after '@property'. sp_after_oc_property = ignore # ignore/add/remove/force # (OC) Add or remove space between '@synchronized' and the open parenthesis, # i.e. '@synchronized(foo)' vs. '@synchronized (foo)'. sp_after_oc_synchronized = ignore # ignore/add/remove/force # Add or remove space around the ':' in 'b ? t : f'. sp_cond_colon = ignore # ignore/add/remove/force # Add or remove space before the ':' in 'b ? t : f'. # # Overrides sp_cond_colon. sp_cond_colon_before = ignore # ignore/add/remove/force # Add or remove space after the ':' in 'b ? t : f'. # # Overrides sp_cond_colon. sp_cond_colon_after = ignore # ignore/add/remove/force # Add or remove space around the '?' in 'b ? t : f'. sp_cond_question = ignore # ignore/add/remove/force # Add or remove space before the '?' in 'b ? t : f'. # # Overrides sp_cond_question. sp_cond_question_before = ignore # ignore/add/remove/force # Add or remove space after the '?' in 'b ? t : f'. # # Overrides sp_cond_question. sp_cond_question_after = ignore # ignore/add/remove/force # In the abbreviated ternary form '(a ?: b)', add or remove space between '?' # and ':'. # # Overrides all other sp_cond_* options. sp_cond_ternary_short = ignore # ignore/add/remove/force # Fix the spacing between 'case' and the label. Only 'ignore' and 'force' make # sense here. sp_case_label = ignore # ignore/add/remove/force # (D) Add or remove space around the D '..' operator. sp_range = ignore # ignore/add/remove/force # Add or remove space after ':' in a Java/C++11 range-based 'for', # as in 'for (Type var : expr)'. sp_after_for_colon = ignore # ignore/add/remove/force # Add or remove space before ':' in a Java/C++11 range-based 'for', # as in 'for (Type var : expr)'. sp_before_for_colon = ignore # ignore/add/remove/force # (D) Add or remove space between 'extern' and '(' as in 'extern (C)'. sp_extern_paren = ignore # ignore/add/remove/force # Add or remove space after the opening of a C++ comment, # i.e. '// A' vs. '//A'. sp_cmt_cpp_start = ignore # ignore/add/remove/force # If true, space is added with sp_cmt_cpp_start will be added after doxygen # sequences like '///', '///<', '//!' and '//!<'. sp_cmt_cpp_doxygen = false # true/false # If true, space is added with sp_cmt_cpp_start will be added after Qt # translator or meta-data comments like '//:', '//=', and '//~'. sp_cmt_cpp_qttr = false # true/false # Add or remove space between #else or #endif and a trailing comment. sp_endif_cmt = ignore # ignore/add/remove/force # Add or remove space after 'new', 'delete' and 'delete[]'. sp_after_new = ignore # ignore/add/remove/force # Add or remove space between 'new' and '(' in 'new()'. sp_between_new_paren = ignore # ignore/add/remove/force # Add or remove space between ')' and type in 'new(foo) BAR'. sp_after_newop_paren = ignore # ignore/add/remove/force # Add or remove space inside parenthesis of the new operator # as in 'new(foo) BAR'. sp_inside_newop_paren = ignore # ignore/add/remove/force # Add or remove space after the open parenthesis of the new operator, # as in 'new(foo) BAR'. # # Overrides sp_inside_newop_paren. sp_inside_newop_paren_open = ignore # ignore/add/remove/force # Add or remove space before the close parenthesis of the new operator, # as in 'new(foo) BAR'. # # Overrides sp_inside_newop_paren. sp_inside_newop_paren_close = ignore # ignore/add/remove/force # Add or remove space before a trailing or embedded comment. sp_before_tr_emb_cmt = ignore # ignore/add/remove/force # Number of spaces before a trailing or embedded comment. sp_num_before_tr_emb_cmt = 0 # unsigned number # (Java) Add or remove space between an annotation and the open parenthesis. sp_annotation_paren = ignore # ignore/add/remove/force # If true, vbrace tokens are dropped to the previous token and skipped. sp_skip_vbrace_tokens = false # true/false # Add or remove space after 'noexcept'. sp_after_noexcept = ignore # ignore/add/remove/force # Add or remove space after '_'. sp_vala_after_translation = ignore # ignore/add/remove/force # If true, a is inserted after #define. force_tab_after_define = false # true/false # # Indenting options # # The number of columns to indent per level. Usually 2, 3, 4, or 8. # # Default: 8 indent_columns = 4 # unsigned number # The continuation indent. If non-zero, this overrides the indent of '(', '[' # and '=' continuation indents. Negative values are OK; negative value is # absolute and not increased for each '(' or '[' level. # # For FreeBSD, this is set to 4. indent_continue = 0 # number # The continuation indent, only for class header line(s). If non-zero, this # overrides the indent of 'class' continuation indents. indent_continue_class_head = 0 # unsigned number # Whether to indent empty lines (i.e. lines which contain only spaces before # the newline character). indent_single_newlines = false # true/false # The continuation indent for func_*_param if they are true. If non-zero, this # overrides the indent. indent_param = 0 # unsigned number # How to use tabs when indenting code. # # 0: Spaces only # 1: Indent with tabs to brace level, align with spaces (default) # 2: Indent and align with tabs, using spaces when not on a tabstop # # Default: 1 indent_with_tabs = 0 # unsigned number # Whether to indent comments that are not at a brace level with tabs on a # tabstop. Requires indent_with_tabs=2. If false, will use spaces. indent_cmt_with_tabs = false # true/false # Whether to indent strings broken by '\' so that they line up. indent_align_string = false # true/false # The number of spaces to indent multi-line XML strings. # Requires indent_align_string=true. indent_xml_string = 0 # unsigned number # Spaces to indent '{' from level. indent_brace = 0 # unsigned number # Whether braces are indented to the body level. indent_braces = false # true/false # Whether to disable indenting function braces if indent_braces=true. indent_braces_no_func = false # true/false # Whether to disable indenting class braces if indent_braces=true. indent_braces_no_class = false # true/false # Whether to disable indenting struct braces if indent_braces=true. indent_braces_no_struct = false # true/false # Whether to indent based on the size of the brace parent, # i.e. 'if' => 3 spaces, 'for' => 4 spaces, etc. indent_brace_parent = false # true/false # Whether to indent based on the open parenthesis instead of the open brace # in '({\n'. indent_paren_open_brace = false # true/false # (C#) Whether to indent the brace of a C# delegate by another level. indent_cs_delegate_brace = false # true/false # (C#) Whether to indent a C# delegate (to handle delegates with no brace) by # another level. indent_cs_delegate_body = false # true/false # Whether to indent the body of a 'namespace'. indent_namespace = true # true/false # Whether to indent only the first namespace, and not any nested namespaces. # Requires indent_namespace=true. indent_namespace_single_indent = false # true/false # The number of spaces to indent a namespace block. # If set to zero, use the value indent_columns indent_namespace_level = 0 # unsigned number # If the body of the namespace is longer than this number, it won't be # indented. Requires indent_namespace=true. 0 means no limit. indent_namespace_limit = 0 # unsigned number # Whether the 'extern "C"' body is indented. indent_extern = false # true/false # Whether the 'class' body is indented. indent_class = true # true/false # Whether to indent the stuff after a leading base class colon. indent_class_colon = false # true/false # Whether to indent based on a class colon instead of the stuff after the # colon. Requires indent_class_colon=true. indent_class_on_colon = false # true/false # Whether to indent the stuff after a leading class initializer colon. indent_constr_colon = false # true/false # Virtual indent from the ':' for member initializers. # # Default: 2 indent_ctor_init_leading = 2 # unsigned number # Additional indent for constructor initializer list. # Negative values decrease indent down to the first column. indent_ctor_init = 0 # number # Whether to indent 'if' following 'else' as a new block under the 'else'. # If false, 'else\nif' is treated as 'else if' for indenting purposes. indent_else_if = false # true/false # Amount to indent variable declarations after a open brace. # # <0: Relative # >=0: Absolute indent_var_def_blk = 0 # number # Whether to indent continued variable declarations instead of aligning. indent_var_def_cont = false # true/false # Whether to indent continued shift expressions ('<<' and '>>') instead of # aligning. Set align_left_shift=false when enabling this. indent_shift = false # true/false # Whether to force indentation of function definitions to start in column 1. indent_func_def_force_col1 = false # true/false # Whether to indent continued function call parameters one indent level, # rather than aligning parameters under the open parenthesis. indent_func_call_param = false # true/false # Whether to indent continued function definition parameters one indent level, # rather than aligning parameters under the open parenthesis. indent_func_def_param = false # true/false # for function definitions, only if indent_func_def_param is false # Allows to align params when appropriate and indent them when not # behave as if it was true if paren position is more than this value # if paren position is more than the option value indent_func_def_param_paren_pos_threshold = 0 # unsigned number # Whether to indent continued function call prototype one indent level, # rather than aligning parameters under the open parenthesis. indent_func_proto_param = false # true/false # Whether to indent continued function call declaration one indent level, # rather than aligning parameters under the open parenthesis. indent_func_class_param = false # true/false # Whether to indent continued class variable constructors one indent level, # rather than aligning parameters under the open parenthesis. indent_func_ctor_var_param = false # true/false # Whether to indent continued template parameter list one indent level, # rather than aligning parameters under the open parenthesis. indent_template_param = false # true/false # Double the indent for indent_func_xxx_param options. # Use both values of the options indent_columns and indent_param. indent_func_param_double = false # true/false # Indentation column for standalone 'const' qualifier on a function # prototype. indent_func_const = 0 # unsigned number # Indentation column for standalone 'throw' qualifier on a function # prototype. indent_func_throw = 0 # unsigned number # How to indent within a macro followed by a brace on the same line # This allows reducing the indent in macros that have (for example) # `do { ... } while (0)` blocks bracketing them. # # true: add an indent for the brace on the same line as the macro # false: do not add an indent for the brace on the same line as the macro # # Default: true indent_macro_brace = true # true/false # The number of spaces to indent a continued '->' or '.'. # Usually set to 0, 1, or indent_columns. indent_member = 0 # unsigned number # Whether lines broken at '.' or '->' should be indented by a single indent. # The indent_member option will not be effective if this is set to true. indent_member_single = false # true/false # Spaces to indent single line ('//') comments on lines before code. indent_sing_line_comments = 0 # unsigned number # When opening a paren for a control statement (if, for, while, etc), increase # the indent level by this value. Negative values decrease the indent level. indent_sparen_extra = 0 # number # Whether to indent trailing single line ('//') comments relative to the code # instead of trying to keep the same absolute column. indent_relative_single_line_comments = false # true/false # Spaces to indent 'case' from 'switch'. Usually 0 or indent_columns. indent_switch_case = 0 # unsigned number # indent 'break' with 'case' from 'switch'. indent_switch_break_with_case = false # true/false # Whether to indent preprocessor statements inside of switch statements. # # Default: true indent_switch_pp = true # true/false # Spaces to shift the 'case' line, without affecting any other lines. # Usually 0. indent_case_shift = 0 # unsigned number # Spaces to indent '{' from 'case'. By default, the brace will appear under # the 'c' in case. Usually set to 0 or indent_columns. Negative values are OK. indent_case_brace = 0 # number # Whether to indent comments found in first column. indent_col1_comment = false # true/false # Whether to indent multi string literal in first column. indent_col1_multi_string_literal = false # true/false # How to indent goto labels. # # >0: Absolute column where 1 is the leftmost column # <=0: Subtract from brace indent # # Default: 1 indent_label = 1 # number # How to indent access specifiers that are followed by a # colon. # # >0: Absolute column where 1 is the leftmost column # <=0: Subtract from brace indent # # Default: 1 indent_access_spec = -4 # number # Whether to indent the code after an access specifier by one level. # If true, this option forces 'indent_access_spec=0'. indent_access_spec_body = false # true/false # If an open parenthesis is followed by a newline, whether to indent the next # line so that it lines up after the open parenthesis (not recommended). indent_paren_nl = false # true/false # How to indent a close parenthesis after a newline. # # 0: Indent to body level (default) # 1: Align under the open parenthesis # 2: Indent to the brace level indent_paren_close = 0 # unsigned number # Whether to indent the open parenthesis of a function definition, # if the parenthesis is on its own line. indent_paren_after_func_def = false # true/false # Whether to indent the open parenthesis of a function declaration, # if the parenthesis is on its own line. indent_paren_after_func_decl = false # true/false # Whether to indent the open parenthesis of a function call, # if the parenthesis is on its own line. indent_paren_after_func_call = false # true/false # Whether to indent a comma when inside a parenthesis. # If true, aligns under the open parenthesis. indent_comma_paren = false # true/false # Whether to indent a Boolean operator when inside a parenthesis. # If true, aligns under the open parenthesis. indent_bool_paren = false # true/false # Whether to indent a semicolon when inside a for parenthesis. # If true, aligns under the open for parenthesis. indent_semicolon_for_paren = false # true/false # Whether to align the first expression to following ones # if indent_bool_paren=true. indent_first_bool_expr = false # true/false # Whether to align the first expression to following ones # if indent_semicolon_for_paren=true. indent_first_for_expr = false # true/false # If an open square is followed by a newline, whether to indent the next line # so that it lines up after the open square (not recommended). indent_square_nl = false # true/false # (ESQL/C) Whether to preserve the relative indent of 'EXEC SQL' bodies. indent_preserve_sql = false # true/false # Whether to align continued statements at the '='. If false or if the '=' is # followed by a newline, the next line is indent one tab. # # Default: true indent_align_assign = true # true/false # If true, the indentation of the chunks after a '=' sequence will be set at # LHS token indentation column before '='. indent_off_after_assign = false # true/false # Whether to align continued statements at the '('. If false or the '(' is # followed by a newline, the next line indent is one tab. # # Default: true indent_align_paren = true # true/false # (OC) Whether to indent Objective-C code inside message selectors. indent_oc_inside_msg_sel = false # true/false # (OC) Whether to indent Objective-C blocks at brace level instead of usual # rules. indent_oc_block = false # true/false # (OC) Indent for Objective-C blocks in a message relative to the parameter # name. # # =0: Use indent_oc_block rules # >0: Use specified number of spaces to indent indent_oc_block_msg = 0 # unsigned number # (OC) Minimum indent for subsequent parameters indent_oc_msg_colon = 0 # unsigned number # (OC) Whether to prioritize aligning with initial colon (and stripping spaces # from lines, if necessary). # # Default: true indent_oc_msg_prioritize_first_colon = true # true/false # (OC) Whether to indent blocks the way that Xcode does by default # (from the keyword if the parameter is on its own line; otherwise, from the # previous indentation level). Requires indent_oc_block_msg=true. indent_oc_block_msg_xcode_style = false # true/false # (OC) Whether to indent blocks from where the brace is, relative to a # message keyword. Requires indent_oc_block_msg=true. indent_oc_block_msg_from_keyword = false # true/false # (OC) Whether to indent blocks from where the brace is, relative to a message # colon. Requires indent_oc_block_msg=true. indent_oc_block_msg_from_colon = false # true/false # (OC) Whether to indent blocks from where the block caret is. # Requires indent_oc_block_msg=true. indent_oc_block_msg_from_caret = false # true/false # (OC) Whether to indent blocks from where the brace caret is. # Requires indent_oc_block_msg=true. indent_oc_block_msg_from_brace = false # true/false # When indenting after virtual brace open and newline add further spaces to # reach this minimum indent. indent_min_vbrace_open = 0 # unsigned number # Whether to add further spaces after regular indent to reach next tabstop # when indenting after virtual brace open and newline. indent_vbrace_open_on_tabstop = false # true/false # How to indent after a brace followed by another token (not a newline). # true: indent all contained lines to match the token # false: indent all contained lines to match the brace # # Default: true indent_token_after_brace = true # true/false # Whether to indent the body of a C++11 lambda. indent_cpp_lambda_body = false # true/false # How to indent compound literals that are being returned. # true: add both the indent from return & the compound literal open brace (ie: # 2 indent levels) # false: only indent 1 level, don't add the indent for the open brace, only add # the indent for the return. # # Default: true indent_compound_literal_return = true # true/false # (C#) Whether to indent a 'using' block if no braces are used. # # Default: true indent_using_block = true # true/false # How to indent the continuation of ternary operator. # # 0: Off (default) # 1: When the `if_false` is a continuation, indent it under `if_false` # 2: When the `:` is a continuation, indent it under `?` indent_ternary_operator = 0 # unsigned number # Whether to indent the statments inside ternary operator. indent_inside_ternary_operator = false # true/false # If true, the indentation of the chunks after a `return` sequence will be set at return indentation column. indent_off_after_return = false # true/false # If true, the indentation of the chunks after a `return new` sequence will be set at return indentation column. indent_off_after_return_new = false # true/false # If true, the tokens after return are indented with regular single indentation. By default (false) the indentation is after the return token. indent_single_after_return = false # true/false # Whether to ignore indent and alignment for 'asm' blocks (i.e. assume they # have their own indentation). indent_ignore_asm_block = false # true/false # Don't indent the close parenthesis of a function definition, # if the parenthesis is on its own line. donot_indent_func_def_close_paren = false # true/false # # Newline adding and removing options # # Whether to collapse empty blocks between '{' and '}'. # If true, overrides nl_inside_empty_func nl_collapse_empty_body = true # true/false # Don't split one-line braced assignments, as in 'foo_t f = { 1, 2 };'. nl_assign_leave_one_liners = false # true/false # Don't split one-line braced statements inside a 'class xx { }' body. nl_class_leave_one_liners = false # true/false # Don't split one-line enums, as in 'enum foo { BAR = 15 };' nl_enum_leave_one_liners = false # true/false # Don't split one-line get or set functions. nl_getset_leave_one_liners = false # true/false # (C#) Don't split one-line property get or set functions. nl_cs_property_leave_one_liners = false # true/false # Don't split one-line function definitions, as in 'int foo() { return 0; }'. # might modify nl_func_type_name nl_func_leave_one_liners = false # true/false # Don't split one-line C++11 lambdas, as in '[]() { return 0; }'. nl_cpp_lambda_leave_one_liners = false # true/false # Don't split one-line if/else statements, as in 'if(...) b++;'. nl_if_leave_one_liners = false # true/false # Don't split one-line while statements, as in 'while(...) b++;'. nl_while_leave_one_liners = false # true/false # Don't split one-line for statements, as in 'for(...) b++;'. nl_for_leave_one_liners = false # true/false # (OC) Don't split one-line Objective-C messages. nl_oc_msg_leave_one_liner = false # true/false # (OC) Add or remove newline between method declaration and '{'. nl_oc_mdef_brace = ignore # ignore/add/remove/force # (OC) Add or remove newline between Objective-C block signature and '{'. nl_oc_block_brace = ignore # ignore/add/remove/force # (OC) Add or remove blank line before '@interface' statement. nl_oc_before_interface = ignore # ignore/add/remove/force # (OC) Add or remove blank line before '@implementation' statement. nl_oc_before_implementation = ignore # ignore/add/remove/force # (OC) Add or remove blank line before '@end' statement. nl_oc_before_end = ignore # ignore/add/remove/force # (OC) Add or remove newline between '@interface' and '{'. nl_oc_interface_brace = ignore # ignore/add/remove/force # (OC) Add or remove newline between '@implementation' and '{'. nl_oc_implementation_brace = ignore # ignore/add/remove/force # Add or remove newlines at the start of the file. nl_start_of_file = ignore # ignore/add/remove/force # The minimum number of newlines at the start of the file (only used if # nl_start_of_file is 'add' or 'force'). nl_start_of_file_min = 0 # unsigned number # Add or remove newline at the end of the file. nl_end_of_file = ignore # ignore/add/remove/force # The minimum number of newlines at the end of the file (only used if # nl_end_of_file is 'add' or 'force'). nl_end_of_file_min = 0 # unsigned number # Add or remove newline between '=' and '{'. nl_assign_brace = ignore # ignore/add/remove/force # (D) Add or remove newline between '=' and '['. nl_assign_square = ignore # ignore/add/remove/force # Add or remove newline between '[]' and '{'. nl_tsquare_brace = ignore # ignore/add/remove/force # (D) Add or remove newline after '= ['. Will also affect the newline before # the ']'. nl_after_square_assign = ignore # ignore/add/remove/force # Add or remove newline between a function call's ')' and '{', as in # 'list_for_each(item, &list) { }'. nl_fcall_brace = ignore # ignore/add/remove/force # Add or remove newline between 'enum' and '{'. nl_enum_brace = ignore # ignore/add/remove/force # Add or remove newline between 'enum' and 'class'. nl_enum_class = ignore # ignore/add/remove/force # Add or remove newline between 'enum class' and the identifier. nl_enum_class_identifier = ignore # ignore/add/remove/force # Add or remove newline between 'enum class' type and ':'. nl_enum_identifier_colon = ignore # ignore/add/remove/force # Add or remove newline between 'enum class identifier :' and type. nl_enum_colon_type = ignore # ignore/add/remove/force # Add or remove newline between 'struct and '{'. nl_struct_brace = ignore # ignore/add/remove/force # Add or remove newline between 'union' and '{'. nl_union_brace = ignore # ignore/add/remove/force # Add or remove newline between 'if' and '{'. nl_if_brace = ignore # ignore/add/remove/force # Add or remove newline between '}' and 'else'. nl_brace_else = ignore # ignore/add/remove/force # Add or remove newline between 'else if' and '{'. If set to ignore, # nl_if_brace is used instead. nl_elseif_brace = ignore # ignore/add/remove/force # Add or remove newline between 'else' and '{'. nl_else_brace = ignore # ignore/add/remove/force # Add or remove newline between 'else' and 'if'. nl_else_if = ignore # ignore/add/remove/force # Add or remove newline before '{' opening brace nl_before_opening_brace_func_class_def = ignore # ignore/add/remove/force # Add or remove newline before 'if'/'else if' closing parenthesis. nl_before_if_closing_paren = ignore # ignore/add/remove/force # Add or remove newline between '}' and 'finally'. nl_brace_finally = ignore # ignore/add/remove/force # Add or remove newline between 'finally' and '{'. nl_finally_brace = ignore # ignore/add/remove/force # Add or remove newline between 'try' and '{'. nl_try_brace = ignore # ignore/add/remove/force # Add or remove newline between get/set and '{'. nl_getset_brace = ignore # ignore/add/remove/force # Add or remove newline between 'for' and '{'. nl_for_brace = ignore # ignore/add/remove/force # Add or remove newline before the '{' of a 'catch' statement, as in # 'catch (decl) {'. nl_catch_brace = ignore # ignore/add/remove/force # (OC) Add or remove newline before the '{' of a '@catch' statement, as in # '@catch (decl) {'. If set to ignore, nl_catch_brace is used. nl_oc_catch_brace = ignore # ignore/add/remove/force # Add or remove newline between '}' and 'catch'. nl_brace_catch = ignore # ignore/add/remove/force # (OC) Add or remove newline between '}' and '@catch'. If set to ignore, # nl_brace_catch is used. nl_oc_brace_catch = ignore # ignore/add/remove/force # Add or remove newline between '}' and ']'. nl_brace_square = ignore # ignore/add/remove/force # Add or remove newline between '}' and ')' in a function invocation. nl_brace_fparen = ignore # ignore/add/remove/force # Add or remove newline between 'while' and '{'. nl_while_brace = ignore # ignore/add/remove/force # (D) Add or remove newline between 'scope (x)' and '{'. nl_scope_brace = ignore # ignore/add/remove/force # (D) Add or remove newline between 'unittest' and '{'. nl_unittest_brace = ignore # ignore/add/remove/force # (D) Add or remove newline between 'version (x)' and '{'. nl_version_brace = ignore # ignore/add/remove/force # (C#) Add or remove newline between 'using' and '{'. nl_using_brace = ignore # ignore/add/remove/force # Add or remove newline between two open or close braces. Due to general # newline/brace handling, REMOVE may not work. nl_brace_brace = ignore # ignore/add/remove/force # Add or remove newline between 'do' and '{'. nl_do_brace = ignore # ignore/add/remove/force # Add or remove newline between '}' and 'while' of 'do' statement. nl_brace_while = ignore # ignore/add/remove/force # Add or remove newline between 'switch' and '{'. nl_switch_brace = ignore # ignore/add/remove/force # Add or remove newline between 'synchronized' and '{'. nl_synchronized_brace = ignore # ignore/add/remove/force # Add a newline between ')' and '{' if the ')' is on a different line than the # if/for/etc. # # Overrides nl_for_brace, nl_if_brace, nl_switch_brace, nl_while_switch and # nl_catch_brace. nl_multi_line_cond = false # true/false # Add a newline after '(' if an if/for/while/switch condition spans multiple # lines nl_multi_line_sparen_open = ignore # ignore/add/remove/force # Add a newline before ')' if an if/for/while/switch condition spans multiple # lines. Overrides nl_before_if_closing_paren if both are specified. nl_multi_line_sparen_close = ignore # ignore/add/remove/force # Force a newline in a define after the macro name for multi-line defines. nl_multi_line_define = false # true/false # Whether to add a newline before 'case', and a blank line before a 'case' # statement that follows a ';' or '}'. nl_before_case = false # true/false # Whether to add a newline after a 'case' statement. nl_after_case = false # true/false # Add or remove newline between a case ':' and '{'. # # Overrides nl_after_case. nl_case_colon_brace = ignore # ignore/add/remove/force # Add or remove newline between ')' and 'throw'. nl_before_throw = ignore # ignore/add/remove/force # Add or remove newline between 'namespace' and '{'. nl_namespace_brace = ignore # ignore/add/remove/force # Add or remove newline after 'template<...>' of a template class. nl_template_class = ignore # ignore/add/remove/force # Add or remove newline after 'template<...>' of a template class declaration. # # Overrides nl_template_class. nl_template_class_decl = ignore # ignore/add/remove/force # Add or remove newline after 'template<>' of a specialized class declaration. # # Overrides nl_template_class_decl. nl_template_class_decl_special = ignore # ignore/add/remove/force # Add or remove newline after 'template<...>' of a template class definition. # # Overrides nl_template_class. nl_template_class_def = ignore # ignore/add/remove/force # Add or remove newline after 'template<>' of a specialized class definition. # # Overrides nl_template_class_def. nl_template_class_def_special = ignore # ignore/add/remove/force # Add or remove newline after 'template<...>' of a template function. nl_template_func = ignore # ignore/add/remove/force # Add or remove newline after 'template<...>' of a template function # declaration. # # Overrides nl_template_func. nl_template_func_decl = ignore # ignore/add/remove/force # Add or remove newline after 'template<>' of a specialized function # declaration. # # Overrides nl_template_func_decl. nl_template_func_decl_special = ignore # ignore/add/remove/force # Add or remove newline after 'template<...>' of a template function # definition. # # Overrides nl_template_func. nl_template_func_def = ignore # ignore/add/remove/force # Add or remove newline after 'template<>' of a specialized function # definition. # # Overrides nl_template_func_def. nl_template_func_def_special = ignore # ignore/add/remove/force # Add or remove newline after 'template<...>' of a template variable. nl_template_var = ignore # ignore/add/remove/force # Add or remove newline between 'template<...>' and 'using' of a templated # type alias. nl_template_using = ignore # ignore/add/remove/force # Add or remove newline between 'class' and '{'. nl_class_brace = ignore # ignore/add/remove/force # Add or remove newline before or after (depending on pos_class_comma, # may not be IGNORE) each',' in the base class list. nl_class_init_args = ignore # ignore/add/remove/force # Add or remove newline after each ',' in the constructor member # initialization. Related to nl_constr_colon, pos_constr_colon and # pos_constr_comma. nl_constr_init_args = ignore # ignore/add/remove/force # Add or remove newline before first element, after comma, and after last # element, in 'enum'. nl_enum_own_lines = ignore # ignore/add/remove/force # Add or remove newline between return type and function name in a function # definition. # might be modified by nl_func_leave_one_liners nl_func_type_name = ignore # ignore/add/remove/force # Add or remove newline between return type and function name inside a class # definition. If set to ignore, nl_func_type_name or nl_func_proto_type_name # is used instead. nl_func_type_name_class = ignore # ignore/add/remove/force # Add or remove newline between class specification and '::' # in 'void A::f() { }'. Only appears in separate member implementation (does # not appear with in-line implementation). nl_func_class_scope = ignore # ignore/add/remove/force # Add or remove newline between function scope and name, as in # 'void A :: f() { }'. nl_func_scope_name = ignore # ignore/add/remove/force # Add or remove newline between return type and function name in a prototype. nl_func_proto_type_name = ignore # ignore/add/remove/force # Add or remove newline between a function name and the opening '(' in the # declaration. nl_func_paren = ignore # ignore/add/remove/force # Overrides nl_func_paren for functions with no parameters. nl_func_paren_empty = ignore # ignore/add/remove/force # Add or remove newline between a function name and the opening '(' in the # definition. nl_func_def_paren = ignore # ignore/add/remove/force # Overrides nl_func_def_paren for functions with no parameters. nl_func_def_paren_empty = ignore # ignore/add/remove/force # Add or remove newline between a function name and the opening '(' in the # call. nl_func_call_paren = ignore # ignore/add/remove/force # Overrides nl_func_call_paren for functions with no parameters. nl_func_call_paren_empty = ignore # ignore/add/remove/force # Add or remove newline after '(' in a function declaration. nl_func_decl_start = ignore # ignore/add/remove/force # Add or remove newline after '(' in a function definition. nl_func_def_start = ignore # ignore/add/remove/force # Overrides nl_func_decl_start when there is only one parameter. nl_func_decl_start_single = ignore # ignore/add/remove/force # Overrides nl_func_def_start when there is only one parameter. nl_func_def_start_single = ignore # ignore/add/remove/force # Whether to add a newline after '(' in a function declaration if '(' and ')' # are in different lines. If false, nl_func_decl_start is used instead. nl_func_decl_start_multi_line = false # true/false # Whether to add a newline after '(' in a function definition if '(' and ')' # are in different lines. If false, nl_func_def_start is used instead. nl_func_def_start_multi_line = false # true/false # Add or remove newline after each ',' in a function declaration. nl_func_decl_args = ignore # ignore/add/remove/force # Add or remove newline after each ',' in a function definition. nl_func_def_args = ignore # ignore/add/remove/force # Add or remove newline after each ',' in a function call. nl_func_call_args = ignore # ignore/add/remove/force # Whether to add a newline after each ',' in a function declaration if '(' # and ')' are in different lines. If false, nl_func_decl_args is used instead. nl_func_decl_args_multi_line = false # true/false # Whether to add a newline after each ',' in a function definition if '(' # and ')' are in different lines. If false, nl_func_def_args is used instead. nl_func_def_args_multi_line = false # true/false # Add or remove newline before the ')' in a function declaration. nl_func_decl_end = ignore # ignore/add/remove/force # Add or remove newline before the ')' in a function definition. nl_func_def_end = ignore # ignore/add/remove/force # Overrides nl_func_decl_end when there is only one parameter. nl_func_decl_end_single = ignore # ignore/add/remove/force # Overrides nl_func_def_end when there is only one parameter. nl_func_def_end_single = ignore # ignore/add/remove/force # Whether to add a newline before ')' in a function declaration if '(' and ')' # are in different lines. If false, nl_func_decl_end is used instead. nl_func_decl_end_multi_line = false # true/false # Whether to add a newline before ')' in a function definition if '(' and ')' # are in different lines. If false, nl_func_def_end is used instead. nl_func_def_end_multi_line = false # true/false # Add or remove newline between '()' in a function declaration. nl_func_decl_empty = ignore # ignore/add/remove/force # Add or remove newline between '()' in a function definition. nl_func_def_empty = ignore # ignore/add/remove/force # Add or remove newline between '()' in a function call. nl_func_call_empty = ignore # ignore/add/remove/force # Whether to add a newline after '(' in a function call, # has preference over nl_func_call_start_multi_line. nl_func_call_start = ignore # ignore/add/remove/force # Whether to add a newline before ')' in a function call. nl_func_call_end = ignore # ignore/add/remove/force # Whether to add a newline after '(' in a function call if '(' and ')' are in # different lines. nl_func_call_start_multi_line = false # true/false # Whether to add a newline after each ',' in a function call if '(' and ')' # are in different lines. nl_func_call_args_multi_line = false # true/false # Whether to add a newline before ')' in a function call if '(' and ')' are in # different lines. nl_func_call_end_multi_line = false # true/false # Whether to respect nl_func_call_XXX option incase of closure args. nl_func_call_args_multi_line_ignore_closures = false # true/false # Whether to add a newline after '<' of a template parameter list. nl_template_start = false # true/false # Whether to add a newline after each ',' in a template parameter list. nl_template_args = false # true/false # Whether to add a newline before '>' of a template parameter list. nl_template_end = false # true/false # (OC) Whether to put each Objective-C message parameter on a separate line. # See nl_oc_msg_leave_one_liner. nl_oc_msg_args = false # true/false # Add or remove newline between function signature and '{'. nl_fdef_brace = ignore # ignore/add/remove/force # Add or remove newline between function signature and '{', # if signature ends with ')'. Overrides nl_fdef_brace. nl_fdef_brace_cond = ignore # ignore/add/remove/force # Add or remove newline between C++11 lambda signature and '{'. nl_cpp_ldef_brace = ignore # ignore/add/remove/force # Add or remove newline between 'return' and the return expression. nl_return_expr = ignore # ignore/add/remove/force # Whether to add a newline after semicolons, except in 'for' statements. nl_after_semicolon = false # true/false # (Java) Add or remove newline between the ')' and '{{' of the double brace # initializer. nl_paren_dbrace_open = ignore # ignore/add/remove/force # Whether to add a newline after the type in an unnamed temporary # direct-list-initialization. nl_type_brace_init_lst = ignore # ignore/add/remove/force # Whether to add a newline after the open brace in an unnamed temporary # direct-list-initialization. nl_type_brace_init_lst_open = ignore # ignore/add/remove/force # Whether to add a newline before the close brace in an unnamed temporary # direct-list-initialization. nl_type_brace_init_lst_close = ignore # ignore/add/remove/force # Whether to add a newline after '{'. This also adds a newline before the # matching '}'. nl_after_brace_open = false # true/false # Whether to add a newline between the open brace and a trailing single-line # comment. Requires nl_after_brace_open=true. nl_after_brace_open_cmt = false # true/false # Whether to add a newline after a virtual brace open with a non-empty body. # These occur in un-braced if/while/do/for statement bodies. nl_after_vbrace_open = false # true/false # Whether to add a newline after a virtual brace open with an empty body. # These occur in un-braced if/while/do/for statement bodies. nl_after_vbrace_open_empty = false # true/false # Whether to add a newline after '}'. Does not apply if followed by a # necessary ';'. nl_after_brace_close = false # true/false # Whether to add a newline after a virtual brace close, # as in 'if (foo) a++; return;'. nl_after_vbrace_close = false # true/false # Add or remove newline between the close brace and identifier, # as in 'struct { int a; } b;'. Affects enumerations, unions and # structures. If set to ignore, uses nl_after_brace_close. nl_brace_struct_var = ignore # ignore/add/remove/force # Whether to alter newlines in '#define' macros. nl_define_macro = false # true/false # Whether to alter newlines between consecutive parenthesis closes. The number # of closing parentheses in a line will depend on respective open parenthesis # lines. nl_squeeze_paren_close = false # true/false # Whether to remove blanks after '#ifxx' and '#elxx', or before '#elxx' and # '#endif'. Does not affect top-level #ifdefs. nl_squeeze_ifdef = false # true/false # Makes the nl_squeeze_ifdef option affect the top-level #ifdefs as well. nl_squeeze_ifdef_top_level = false # true/false # Add or remove blank line before 'if'. nl_before_if = ignore # ignore/add/remove/force # Add or remove blank line after 'if' statement. Add/Force work only if the # next token is not a closing brace. nl_after_if = ignore # ignore/add/remove/force # Add or remove blank line before 'for'. nl_before_for = ignore # ignore/add/remove/force # Add or remove blank line after 'for' statement. nl_after_for = ignore # ignore/add/remove/force # Add or remove blank line before 'while'. nl_before_while = ignore # ignore/add/remove/force # Add or remove blank line after 'while' statement. nl_after_while = ignore # ignore/add/remove/force # Add or remove blank line before 'switch'. nl_before_switch = ignore # ignore/add/remove/force # Add or remove blank line after 'switch' statement. nl_after_switch = ignore # ignore/add/remove/force # Add or remove blank line before 'synchronized'. nl_before_synchronized = ignore # ignore/add/remove/force # Add or remove blank line after 'synchronized' statement. nl_after_synchronized = ignore # ignore/add/remove/force # Add or remove blank line before 'do'. nl_before_do = ignore # ignore/add/remove/force # Add or remove blank line after 'do/while' statement. nl_after_do = ignore # ignore/add/remove/force # Whether to put a blank line before 'return' statements, unless after an open # brace. nl_before_return = false # true/false # Whether to put a blank line after 'return' statements, unless followed by a # close brace. nl_after_return = false # true/false # Whether to put a blank line before a member '.' or '->' operators. nl_before_member = ignore # ignore/add/remove/force # (Java) Whether to put a blank line after a member '.' or '->' operators. nl_after_member = ignore # ignore/add/remove/force # Whether to double-space commented-entries in 'struct'/'union'/'enum'. nl_ds_struct_enum_cmt = false # true/false # Whether to force a newline before '}' of a 'struct'/'union'/'enum'. # (Lower priority than eat_blanks_before_close_brace.) nl_ds_struct_enum_close_brace = false # true/false # Add or remove newline before or after (depending on pos_class_colon) a class # colon, as in 'class Foo : public Bar'. nl_class_colon = ignore # ignore/add/remove/force # Add or remove newline around a class constructor colon. The exact position # depends on nl_constr_init_args, pos_constr_colon and pos_constr_comma. nl_constr_colon = ignore # ignore/add/remove/force # Whether to collapse a two-line namespace, like 'namespace foo\n{ decl; }' # into a single line. If true, prevents other brace newline rules from turning # such code into four lines. nl_namespace_two_to_one_liner = false # true/false # Whether to remove a newline in simple unbraced if statements, turning them # into one-liners, as in 'if(b)\n i++;' => 'if(b) i++;'. nl_create_if_one_liner = false # true/false # Whether to remove a newline in simple unbraced for statements, turning them # into one-liners, as in 'for (...)\n stmt;' => 'for (...) stmt;'. nl_create_for_one_liner = false # true/false # Whether to remove a newline in simple unbraced while statements, turning # them into one-liners, as in 'while (expr)\n stmt;' => 'while (expr) stmt;'. nl_create_while_one_liner = false # true/false # Whether to collapse a function definition whose body (not counting braces) # is only one line so that the entire definition (prototype, braces, body) is # a single line. nl_create_func_def_one_liner = false # true/false # Whether to collapse a function definition whose body (not counting braces) # is only one line so that the entire definition (prototype, braces, body) is # a single line. nl_create_list_one_liner = false # true/false # Whether to split one-line simple unbraced if statements into two lines by # adding a newline, as in 'if(b) i++;'. nl_split_if_one_liner = false # true/false # Whether to split one-line simple unbraced for statements into two lines by # adding a newline, as in 'for (...) stmt;'. nl_split_for_one_liner = false # true/false # Whether to split one-line simple unbraced while statements into two lines by # adding a newline, as in 'while (expr) stmt;'. nl_split_while_one_liner = false # true/false # Don't add a newline before a cpp-comment in a parameter list of a function # call. donot_add_nl_before_cpp_comment = false # true/false # # Blank line options # # The maximum number of consecutive newlines (3 = 2 blank lines). nl_max = 0 # unsigned number # The maximum number of consecutive newlines in a function. nl_max_blank_in_func = 0 # unsigned number # The number of newlines inside an empty function body. # This option is overridden by nl_collapse_empty_body=true nl_inside_empty_func = 0 # unsigned number # The number of newlines before a function prototype. nl_before_func_body_proto = 0 # unsigned number # The number of newlines before a multi-line function definition. nl_before_func_body_def = 0 # unsigned number # The number of newlines before a class constructor/destructor prototype. nl_before_func_class_proto = 0 # unsigned number # The number of newlines before a class constructor/destructor definition. nl_before_func_class_def = 0 # unsigned number # The number of newlines after a function prototype. nl_after_func_proto = 0 # unsigned number # The number of newlines after a function prototype, if not followed by # another function prototype. nl_after_func_proto_group = 0 # unsigned number # The number of newlines after a class constructor/destructor prototype. nl_after_func_class_proto = 0 # unsigned number # The number of newlines after a class constructor/destructor prototype, # if not followed by another constructor/destructor prototype. nl_after_func_class_proto_group = 0 # unsigned number # Whether one-line method definitions inside a class body should be treated # as if they were prototypes for the purposes of adding newlines. # # Requires nl_class_leave_one_liners=true. Overrides nl_before_func_body_def # and nl_before_func_class_def for one-liners. nl_class_leave_one_liner_groups = false # true/false # The number of newlines after '}' of a multi-line function body. nl_after_func_body = 0 # unsigned number # The number of newlines after '}' of a multi-line function body in a class # declaration. Also affects class constructors/destructors. # # Overrides nl_after_func_body. nl_after_func_body_class = 0 # unsigned number # The number of newlines after '}' of a single line function body. Also # affects class constructors/destructors. # # Overrides nl_after_func_body and nl_after_func_body_class. nl_after_func_body_one_liner = 0 # unsigned number # The number of blank lines after a block of variable definitions at the top # of a function body. # # 0: No change (default). nl_func_var_def_blk = 0 # unsigned number # The number of newlines before a block of typedefs. If nl_after_access_spec # is non-zero, that option takes precedence. # # 0: No change (default). nl_typedef_blk_start = 0 # unsigned number # The number of newlines after a block of typedefs. # # 0: No change (default). nl_typedef_blk_end = 0 # unsigned number # The maximum number of consecutive newlines within a block of typedefs. # # 0: No change (default). nl_typedef_blk_in = 0 # unsigned number # The number of newlines before a block of variable definitions not at the top # of a function body. If nl_after_access_spec is non-zero, that option takes # precedence. # # 0: No change (default). nl_var_def_blk_start = 0 # unsigned number # The number of newlines after a block of variable definitions not at the top # of a function body. # # 0: No change (default). nl_var_def_blk_end = 0 # unsigned number # The maximum number of consecutive newlines within a block of variable # definitions. # # 0: No change (default). nl_var_def_blk_in = 0 # unsigned number # The minimum number of newlines before a multi-line comment. # Doesn't apply if after a brace open or another multi-line comment. nl_before_block_comment = 0 # unsigned number # The minimum number of newlines before a single-line C comment. # Doesn't apply if after a brace open or other single-line C comments. nl_before_c_comment = 0 # unsigned number # The minimum number of newlines before a CPP comment. # Doesn't apply if after a brace open or other CPP comments. nl_before_cpp_comment = 0 # unsigned number # Whether to force a newline after a multi-line comment. nl_after_multiline_comment = false # true/false # Whether to force a newline after a label's colon. nl_after_label_colon = false # true/false # The number of newlines after '}' or ';' of a struct/enum/union definition. nl_after_struct = 0 # unsigned number # The number of newlines before a class definition. nl_before_class = 0 # unsigned number # The number of newlines after '}' or ';' of a class definition. nl_after_class = 0 # unsigned number # The number of newlines before a namespace. nl_before_namespace = 0 # unsigned number # The number of newlines after '{' of a namespace. This also adds newlines # before the matching '}'. # # 0: Apply eat_blanks_after_open_brace or eat_blanks_before_close_brace if # applicable, otherwise no change. # # Overrides eat_blanks_after_open_brace and eat_blanks_before_close_brace. nl_inside_namespace = 0 # unsigned number # The number of newlines after '}' of a namespace. nl_after_namespace = 0 # unsigned number # The number of newlines before an access specifier label. This also includes # the Qt-specific 'signals:' and 'slots:'. Will not change the newline count # if after a brace open. # # 0: No change (default). nl_before_access_spec = 0 # unsigned number # The number of newlines after an access specifier label. This also includes # the Qt-specific 'signals:' and 'slots:'. Will not change the newline count # if after a brace open. # # 0: No change (default). # # Overrides nl_typedef_blk_start and nl_var_def_blk_start. nl_after_access_spec = 0 # unsigned number # The number of newlines between a function definition and the function # comment, as in '// comment\n void foo() {...}'. # # 0: No change (default). nl_comment_func_def = 0 # unsigned number # The number of newlines after a try-catch-finally block that isn't followed # by a brace close. # # 0: No change (default). nl_after_try_catch_finally = 0 # unsigned number # (C#) The number of newlines before and after a property, indexer or event # declaration. # # 0: No change (default). nl_around_cs_property = 0 # unsigned number # (C#) The number of newlines between the get/set/add/remove handlers. # # 0: No change (default). nl_between_get_set = 0 # unsigned number # (C#) Add or remove newline between property and the '{'. nl_property_brace = ignore # ignore/add/remove/force # Whether to remove blank lines after '{'. eat_blanks_after_open_brace = false # true/false # Whether to remove blank lines before '}'. eat_blanks_before_close_brace = false # true/false # How aggressively to remove extra newlines not in preprocessor. # # 0: No change (default) # 1: Remove most newlines not handled by other config # 2: Remove all newlines and reformat completely by config nl_remove_extra_newlines = 0 # unsigned number # (Java) Add or remove newline after an annotation statement. Only affects # annotations that are after a newline. nl_after_annotation = ignore # ignore/add/remove/force # (Java) Add or remove newline between two annotations. nl_between_annotation = ignore # ignore/add/remove/force # The number of newlines before a whole-file #ifdef. # # 0: No change (default). nl_before_whole_file_ifdef = 0 # unsigned number # The number of newlines after a whole-file #ifdef. # # 0: No change (default). nl_after_whole_file_ifdef = 0 # unsigned number # The number of newlines before a whole-file #endif. # # 0: No change (default). nl_before_whole_file_endif = 0 # unsigned number # The number of newlines after a whole-file #endif. # # 0: No change (default). nl_after_whole_file_endif = 0 # unsigned number # # Positioning options # # The position of arithmetic operators in wrapped expressions. pos_arith = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # The position of assignment in wrapped expressions. Do not affect '=' # followed by '{'. pos_assign = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # The position of Boolean operators in wrapped expressions. pos_bool = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # The position of comparison operators in wrapped expressions. pos_compare = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # The position of conditional operators, as in the '?' and ':' of # 'expr ? stmt : stmt', in wrapped expressions. pos_conditional = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # The position of the comma in wrapped expressions. pos_comma = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # The position of the comma in enum entries. pos_enum_comma = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # The position of the comma in the base class list if there is more than one # line. Affects nl_class_init_args. pos_class_comma = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # The position of the comma in the constructor initialization list. # Related to nl_constr_colon, nl_constr_init_args and pos_constr_colon. pos_constr_comma = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # The position of trailing/leading class colon, between class and base class # list. Affects nl_class_colon. pos_class_colon = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # The position of colons between constructor and member initialization. # Related to nl_constr_colon, nl_constr_init_args and pos_constr_comma. pos_constr_colon = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # The position of shift operators in wrapped expressions. pos_shift = ignore # ignore/break/force/lead/trail/join/lead_break/lead_force/trail_break/trail_force # # Line splitting options # # Try to limit code width to N columns. code_width = 0 # unsigned number # Whether to fully split long 'for' statements at semi-colons. ls_for_split_full = false # true/false # Whether to fully split long function prototypes/calls at commas. # The option ls_code_width has priority over the option ls_func_split_full. ls_func_split_full = false # true/false # Whether to split lines as close to code_width as possible and ignore some # groupings. # The option ls_code_width has priority over the option ls_func_split_full. ls_code_width = false # true/false # # Code alignment options (not left column spaces/tabs) # # Whether to keep non-indenting tabs. align_keep_tabs = false # true/false # Whether to use tabs for aligning. align_with_tabs = false # true/false # Whether to bump out to the next tab when aligning. align_on_tabstop = false # true/false # Whether to right-align numbers. align_number_right = false # true/false # Whether to keep whitespace not required for alignment. align_keep_extra_space = false # true/false # Whether to align variable definitions in prototypes and functions. align_func_params = false # true/false # The span for aligning parameter definitions in function on parameter name. # # 0: Don't align (default). align_func_params_span = 0 # unsigned number # The threshold for aligning function parameter definitions. # Use a negative number for absolute thresholds. # # 0: No limit (default). align_func_params_thresh = 0 # number # The gap for aligning function parameter definitions. align_func_params_gap = 0 # unsigned number # The span for aligning constructor value. # # 0: Don't align (default). align_constr_value_span = 0 # unsigned number # The threshold for aligning constructor value. # Use a negative number for absolute thresholds. # # 0: No limit (default). align_constr_value_thresh = 0 # number # The gap for aligning constructor value. align_constr_value_gap = 0 # unsigned number # Whether to align parameters in single-line functions that have the same # name. The function names must already be aligned with each other. align_same_func_call_params = false # true/false # The span for aligning function-call parameters for single line functions. # # 0: Don't align (default). align_same_func_call_params_span = 0 # unsigned number # The threshold for aligning function-call parameters for single line # functions. # Use a negative number for absolute thresholds. # # 0: No limit (default). align_same_func_call_params_thresh = 0 # number # The span for aligning variable definitions. # # 0: Don't align (default). align_var_def_span = 0 # unsigned number # How to consider (or treat) the '*' in the alignment of variable definitions. # # 0: Part of the type 'void * foo;' (default) # 1: Part of the variable 'void *foo;' # 2: Dangling 'void *foo;' # Dangling: the '*' will not be taken into account when aligning. align_var_def_star_style = 0 # unsigned number # How to consider (or treat) the '&' in the alignment of variable definitions. # # 0: Part of the type 'long & foo;' (default) # 1: Part of the variable 'long &foo;' # 2: Dangling 'long &foo;' # Dangling: the '&' will not be taken into account when aligning. align_var_def_amp_style = 0 # unsigned number # The threshold for aligning variable definitions. # Use a negative number for absolute thresholds. # # 0: No limit (default). align_var_def_thresh = 0 # number # The gap for aligning variable definitions. align_var_def_gap = 0 # unsigned number # Whether to align the colon in struct bit fields. align_var_def_colon = false # true/false # The gap for aligning the colon in struct bit fields. align_var_def_colon_gap = 0 # unsigned number # Whether to align any attribute after the variable name. align_var_def_attribute = false # true/false # Whether to align inline struct/enum/union variable definitions. align_var_def_inline = false # true/false # The span for aligning on '=' in assignments. # # 0: Don't align (default). align_assign_span = 0 # unsigned number # The span for aligning on '=' in function prototype modifier. # # 0: Don't align (default). align_assign_func_proto_span = 0 # unsigned number # The threshold for aligning on '=' in assignments. # Use a negative number for absolute thresholds. # # 0: No limit (default). align_assign_thresh = 0 # number # How to apply align_assign_span to function declaration "assignments", i.e. # 'virtual void foo() = 0' or '~foo() = {default|delete}'. # # 0: Align with other assignments (default) # 1: Align with each other, ignoring regular assignments # 2: Don't align align_assign_decl_func = 0 # unsigned number # The span for aligning on '=' in enums. # # 0: Don't align (default). align_enum_equ_span = 0 # unsigned number # The threshold for aligning on '=' in enums. # Use a negative number for absolute thresholds. # # 0: no limit (default). align_enum_equ_thresh = 0 # number # The span for aligning class member definitions. # # 0: Don't align (default). align_var_class_span = 0 # unsigned number # The threshold for aligning class member definitions. # Use a negative number for absolute thresholds. # # 0: No limit (default). align_var_class_thresh = 0 # number # The gap for aligning class member definitions. align_var_class_gap = 0 # unsigned number # The span for aligning struct/union member definitions. # # 0: Don't align (default). align_var_struct_span = 0 # unsigned number # The threshold for aligning struct/union member definitions. # Use a negative number for absolute thresholds. # # 0: No limit (default). align_var_struct_thresh = 0 # number # The gap for aligning struct/union member definitions. align_var_struct_gap = 0 # unsigned number # The span for aligning struct initializer values. # # 0: Don't align (default). align_struct_init_span = 0 # unsigned number # The span for aligning single-line typedefs. # # 0: Don't align (default). align_typedef_span = 0 # unsigned number # The minimum space between the type and the synonym of a typedef. align_typedef_gap = 0 # unsigned number # How to align typedef'd functions with other typedefs. # # 0: Don't mix them at all (default) # 1: Align the open parenthesis with the types # 2: Align the function type name with the other type names align_typedef_func = 0 # unsigned number # How to consider (or treat) the '*' in the alignment of typedefs. # # 0: Part of the typedef type, 'typedef int * pint;' (default) # 1: Part of type name: 'typedef int *pint;' # 2: Dangling: 'typedef int *pint;' # Dangling: the '*' will not be taken into account when aligning. align_typedef_star_style = 0 # unsigned number # How to consider (or treat) the '&' in the alignment of typedefs. # # 0: Part of the typedef type, 'typedef int & intref;' (default) # 1: Part of type name: 'typedef int &intref;' # 2: Dangling: 'typedef int &intref;' # Dangling: the '&' will not be taken into account when aligning. align_typedef_amp_style = 0 # unsigned number # The span for aligning comments that end lines. # # 0: Don't align (default). align_right_cmt_span = 0 # unsigned number # Minimum number of columns between preceding text and a trailing comment in # order for the comment to qualify for being aligned. Must be non-zero to have # an effect. align_right_cmt_gap = 0 # unsigned number # If aligning comments, whether to mix with comments after '}' and #endif with # less than three spaces before the comment. align_right_cmt_mix = false # true/false # Whether to only align trailing comments that are at the same brace level. align_right_cmt_same_level = false # true/false # Minimum column at which to align trailing comments. Comments which are # aligned beyond this column, but which can be aligned in a lesser column, # may be "pulled in". # # 0: Ignore (default). align_right_cmt_at_col = 0 # unsigned number # The span for aligning function prototypes. # # 0: Don't align (default). align_func_proto_span = 0 # unsigned number # The threshold for aligning function prototypes. # Use a negative number for absolute thresholds. # # 0: No limit (default). align_func_proto_thresh = 0 # number # Minimum gap between the return type and the function name. align_func_proto_gap = 0 # unsigned number # Whether to align function prototypes on the 'operator' keyword instead of # what follows. align_on_operator = false # true/false # Whether to mix aligning prototype and variable declarations. If true, # align_var_def_XXX options are used instead of align_func_proto_XXX options. align_mix_var_proto = false # true/false # Whether to align single-line functions with function prototypes. # Uses align_func_proto_span. align_single_line_func = false # true/false # Whether to align the open brace of single-line functions. # Requires align_single_line_func=true. Uses align_func_proto_span. align_single_line_brace = false # true/false # Gap for align_single_line_brace. align_single_line_brace_gap = 0 # unsigned number # (OC) The span for aligning Objective-C message specifications. # # 0: Don't align (default). align_oc_msg_spec_span = 0 # unsigned number # Whether to align macros wrapped with a backslash and a newline. This will # not work right if the macro contains a multi-line comment. align_nl_cont = false # true/false # Whether to align macro functions and variables together. align_pp_define_together = false # true/false # The span for aligning on '#define' bodies. # # =0: Don't align (default) # >0: Number of lines (including comments) between blocks align_pp_define_span = 0 # unsigned number # The minimum space between label and value of a preprocessor define. align_pp_define_gap = 0 # unsigned number # Whether to align lines that start with '<<' with previous '<<'. # # Default: true align_left_shift = true # true/false # Whether to align comma-separated statements following '<<' (as used to # initialize Eigen matrices). align_eigen_comma_init = false # true/false # Whether to align text after 'asm volatile ()' colons. align_asm_colon = false # true/false # (OC) Span for aligning parameters in an Objective-C message call # on the ':'. # # 0: Don't align. align_oc_msg_colon_span = 0 # unsigned number # (OC) Whether to always align with the first parameter, even if it is too # short. align_oc_msg_colon_first = false # true/false # (OC) Whether to align parameters in an Objective-C '+' or '-' declaration # on the ':'. align_oc_decl_colon = false # true/false # (OC) Whether to not align parameters in an Objectve-C message call if first # colon is not on next line of the message call (the same way Xcode does # aligment) align_oc_msg_colon_xcode_like = false # true/false # # Comment modification options # # Try to wrap comments at N columns. cmt_width = 0 # unsigned number # How to reflow comments. # # 0: No reflowing (apart from the line wrapping due to cmt_width) (default) # 1: No touching at all # 2: Full reflow cmt_reflow_mode = 0 # unsigned number # Whether to convert all tabs to spaces in comments. If false, tabs in # comments are left alone, unless used for indenting. cmt_convert_tab_to_spaces = true # true/false # Whether to apply changes to multi-line comments, including cmt_width, # keyword substitution and leading chars. # # Default: true cmt_indent_multi = true # true/false # Whether to group c-comments that look like they are in a block. cmt_c_group = false # true/false # Whether to put an empty '/*' on the first line of the combined c-comment. cmt_c_nl_start = false # true/false # Whether to add a newline before the closing '*/' of the combined c-comment. cmt_c_nl_end = false # true/false # Whether to change cpp-comments into c-comments. cmt_cpp_to_c = false # true/false # Whether to group cpp-comments that look like they are in a block. Only # meaningful if cmt_cpp_to_c=true. cmt_cpp_group = false # true/false # Whether to put an empty '/*' on the first line of the combined cpp-comment # when converting to a c-comment. # # Requires cmt_cpp_to_c=true and cmt_cpp_group=true. cmt_cpp_nl_start = false # true/false # Whether to add a newline before the closing '*/' of the combined cpp-comment # when converting to a c-comment. # # Requires cmt_cpp_to_c=true and cmt_cpp_group=true. cmt_cpp_nl_end = false # true/false # Whether to put a star on subsequent comment lines. cmt_star_cont = false # true/false # The number of spaces to insert at the start of subsequent comment lines. cmt_sp_before_star_cont = 0 # unsigned number # The number of spaces to insert after the star on subsequent comment lines. cmt_sp_after_star_cont = 0 # unsigned number # For multi-line comments with a '*' lead, remove leading spaces if the first # and last lines of the comment are the same length. # # Default: true cmt_multi_check_last = true # true/false # For multi-line comments with a '*' lead, remove leading spaces if the first # and last lines of the comment are the same length AND if the length is # bigger as the first_len minimum. # # Default: 4 cmt_multi_first_len_minimum = 4 # unsigned number # Path to a file that contains text to insert at the beginning of a file if # the file doesn't start with a C/C++ comment. If the inserted text contains # '$(filename)', that will be replaced with the current file's name. cmt_insert_file_header = "" # string # Path to a file that contains text to insert at the end of a file if the # file doesn't end with a C/C++ comment. If the inserted text contains # '$(filename)', that will be replaced with the current file's name. cmt_insert_file_footer = "" # string # Path to a file that contains text to insert before a function definition if # the function isn't preceded by a C/C++ comment. If the inserted text # contains '$(function)', '$(javaparam)' or '$(fclass)', these will be # replaced with, respectively, the name of the function, the javadoc '@param' # and '@return' stuff, or the name of the class to which the member function # belongs. cmt_insert_func_header = "" # string # Path to a file that contains text to insert before a class if the class # isn't preceded by a C/C++ comment. If the inserted text contains '$(class)', # that will be replaced with the class name. cmt_insert_class_header = "" # string # Path to a file that contains text to insert before an Objective-C message # specification, if the method isn't preceded by a C/C++ comment. If the # inserted text contains '$(message)' or '$(javaparam)', these will be # replaced with, respectively, the name of the function, or the javadoc # '@param' and '@return' stuff. cmt_insert_oc_msg_header = "" # string # Whether a comment should be inserted if a preprocessor is encountered when # stepping backwards from a function name. # # Applies to cmt_insert_oc_msg_header, cmt_insert_func_header and # cmt_insert_class_header. cmt_insert_before_preproc = false # true/false # Whether a comment should be inserted if a function is declared inline to a # class definition. # # Applies to cmt_insert_func_header. # # Default: true cmt_insert_before_inlines = true # true/false # Whether a comment should be inserted if the function is a class constructor # or destructor. # # Applies to cmt_insert_func_header. cmt_insert_before_ctor_dtor = false # true/false # # Code modifying options (non-whitespace) # # Add or remove braces on a single-line 'do' statement. mod_full_brace_do = ignore # ignore/add/remove/force # Add or remove braces on a single-line 'for' statement. mod_full_brace_for = ignore # ignore/add/remove/force # (Pawn) Add or remove braces on a single-line function definition. mod_full_brace_function = ignore # ignore/add/remove/force # Add or remove braces on a single-line 'if' statement. Braces will not be # removed if the braced statement contains an 'else'. mod_full_brace_if = ignore # ignore/add/remove/force # Whether to enforce that all blocks of an 'if'/'else if'/'else' chain either # have, or do not have, braces. If true, braces will be added if any block # needs braces, and will only be removed if they can be removed from all # blocks. # # Overrides mod_full_brace_if. mod_full_brace_if_chain = false # true/false # Whether to add braces to all blocks of an 'if'/'else if'/'else' chain. # If true, mod_full_brace_if_chain will only remove braces from an 'if' that # does not have an 'else if' or 'else'. mod_full_brace_if_chain_only = false # true/false # Add or remove braces on single-line 'while' statement. mod_full_brace_while = ignore # ignore/add/remove/force # Add or remove braces on single-line 'using ()' statement. mod_full_brace_using = ignore # ignore/add/remove/force # Don't remove braces around statements that span N newlines mod_full_brace_nl = 0 # unsigned number # Whether to prevent removal of braces from 'if'/'for'/'while'/etc. blocks # which span multiple lines. # # Affects: # mod_full_brace_for # mod_full_brace_if # mod_full_brace_if_chain # mod_full_brace_if_chain_only # mod_full_brace_while # mod_full_brace_using # # Does not affect: # mod_full_brace_do # mod_full_brace_function mod_full_brace_nl_block_rem_mlcond = false # true/false # Add or remove unnecessary parenthesis on 'return' statement. mod_paren_on_return = ignore # ignore/add/remove/force # (Pawn) Whether to change optional semicolons to real semicolons. mod_pawn_semicolon = false # true/false # Whether to fully parenthesize Boolean expressions in 'while' and 'if' # statement, as in 'if (a && b > c)' => 'if (a && (b > c))'. mod_full_paren_if_bool = false # true/false # Whether to remove superfluous semicolons. mod_remove_extra_semicolon = false # true/false # If a function body exceeds the specified number of newlines and doesn't have # a comment after the close brace, a comment will be added. mod_add_long_function_closebrace_comment = 0 # unsigned number # If a namespace body exceeds the specified number of newlines and doesn't # have a comment after the close brace, a comment will be added. mod_add_long_namespace_closebrace_comment = 0 # unsigned number # If a class body exceeds the specified number of newlines and doesn't have a # comment after the close brace, a comment will be added. mod_add_long_class_closebrace_comment = 0 # unsigned number # If a switch body exceeds the specified number of newlines and doesn't have a # comment after the close brace, a comment will be added. mod_add_long_switch_closebrace_comment = 0 # unsigned number # If an #ifdef body exceeds the specified number of newlines and doesn't have # a comment after the #endif, a comment will be added. mod_add_long_ifdef_endif_comment = 0 # unsigned number # If an #ifdef or #else body exceeds the specified number of newlines and # doesn't have a comment after the #else, a comment will be added. mod_add_long_ifdef_else_comment = 0 # unsigned number # Whether to take care of the case by the mod_sort_xx options. mod_sort_case_sensitive = false # true/false # Whether to sort consecutive single-line 'import' statements. mod_sort_import = false # true/false # (C#) Whether to sort consecutive single-line 'using' statements. mod_sort_using = false # true/false # Whether to sort consecutive single-line '#include' statements (C/C++) and # '#import' statements (Objective-C). Be aware that this has the potential to # break your code if your includes/imports have ordering dependencies. mod_sort_include = false # true/false # Whether to prioritize '#include' and '#import' statements that contain # filename without extension when sorting is enabled. mod_sort_incl_import_prioritize_filename = false # true/false # Whether to prioritize '#include' and '#import' statements that does not # contain extensions when sorting is enabled. mod_sort_incl_import_prioritize_extensionless = false # true/false # Whether to prioritize '#include' and '#import' statements that contain # angle over quotes when sorting is enabled. mod_sort_incl_import_prioritize_angle_over_quotes = false # true/false # Whether to ignore file extension in '#include' and '#import' statements # for sorting comparison. mod_sort_incl_import_ignore_extension = false # true/false # Whether to group '#include' and '#import' statements when sorting is enabled. mod_sort_incl_import_grouping_enabled = false # true/false # Whether to move a 'break' that appears after a fully braced 'case' before # the close brace, as in 'case X: { ... } break;' => 'case X: { ... break; }'. mod_move_case_break = false # true/false # Add or remove braces around a fully braced case statement. Will only remove # braces if there are no variable declarations in the block. mod_case_brace = ignore # ignore/add/remove/force # Whether to remove a void 'return;' that appears as the last statement in a # function. mod_remove_empty_return = false # true/false # Add or remove the comma after the last value of an enumeration. mod_enum_last_comma = ignore # ignore/add/remove/force # (OC) Whether to organize the properties. If true, properties will be # rearranged according to the mod_sort_oc_property_*_weight factors. mod_sort_oc_properties = false # true/false # (OC) Weight of a class property modifier. mod_sort_oc_property_class_weight = 0 # number # (OC) Weight of 'atomic' and 'nonatomic'. mod_sort_oc_property_thread_safe_weight = 0 # number # (OC) Weight of 'readwrite' when organizing properties. mod_sort_oc_property_readwrite_weight = 0 # number # (OC) Weight of a reference type specifier ('retain', 'copy', 'assign', # 'weak', 'strong') when organizing properties. mod_sort_oc_property_reference_weight = 0 # number # (OC) Weight of getter type ('getter=') when organizing properties. mod_sort_oc_property_getter_weight = 0 # number # (OC) Weight of setter type ('setter=') when organizing properties. mod_sort_oc_property_setter_weight = 0 # number # (OC) Weight of nullability type ('nullable', 'nonnull', 'null_unspecified', # 'null_resettable') when organizing properties. mod_sort_oc_property_nullability_weight = 0 # number # # Preprocessor options # # Add or remove indentation of preprocessor directives inside #if blocks # at brace level 0 (file-level). pp_indent = ignore # ignore/add/remove/force # Whether to indent #if/#else/#endif at the brace level. If false, these are # indented from column 1. pp_indent_at_level = false # true/false # Specifies the number of columns to indent preprocessors per level # at brace level 0 (file-level). If pp_indent_at_level=false, also specifies # the number of columns to indent preprocessors per level # at brace level > 0 (function-level). # # Default: 1 pp_indent_count = 1 # unsigned number # Add or remove space after # based on pp_level of #if blocks. pp_space = ignore # ignore/add/remove/force # Sets the number of spaces per level added with pp_space. pp_space_count = 0 # unsigned number # The indent for '#region' and '#endregion' in C# and '#pragma region' in # C/C++. Negative values decrease indent down to the first column. pp_indent_region = 0 # number # Whether to indent the code between #region and #endregion. pp_region_indent_code = false # true/false # If pp_indent_at_level=true, sets the indent for #if, #else and #endif when # not at file-level. Negative values decrease indent down to the first column. # # =0: Indent preprocessors using output_tab_size # >0: Column at which all preprocessors will be indented pp_indent_if = 0 # number # Whether to indent the code between #if, #else and #endif. pp_if_indent_code = false # true/false # Whether to indent '#define' at the brace level. If false, these are # indented from column 1. pp_define_at_level = false # true/false # Whether to ignore the '#define' body while formatting. pp_ignore_define_body = false # true/false # Whether to indent case statements between #if, #else, and #endif. # Only applies to the indent of the preprocesser that the case statements # directly inside of. # # Default: true pp_indent_case = true # true/false # Whether to indent whole function definitions between #if, #else, and #endif. # Only applies to the indent of the preprocesser that the function definition # is directly inside of. # # Default: true pp_indent_func_def = true # true/false # Whether to indent extern C blocks between #if, #else, and #endif. # Only applies to the indent of the preprocesser that the extern block is # directly inside of. # # Default: true pp_indent_extern = true # true/false # Whether to indent braces directly inside #if, #else, and #endif. # Only applies to the indent of the preprocesser that the braces are directly # inside of. # # Default: true pp_indent_brace = true # true/false # # Sort includes options # # The regex for include category with priority 0. include_category_0 = "" # string # The regex for include category with priority 1. include_category_1 = "" # string # The regex for include category with priority 2. include_category_2 = "" # string # # Use or Do not Use options # # true: indent_func_call_param will be used (default) # false: indent_func_call_param will NOT be used # # Default: true use_indent_func_call_param = true # true/false # The value of the indentation for a continuation line is calculated # differently if the statement is: # - a declaration: your case with QString fileName ... # - an assignment: your case with pSettings = new QSettings( ... # # At the second case the indentation value might be used twice: # - at the assignment # - at the function call (if present) # # To prevent the double use of the indentation value, use this option with the # value 'true'. # # true: indent_continue will be used only once # false: indent_continue will be used every time (default) use_indent_continue_only_once = false # true/false # The value might be used twice: # - at the assignment # - at the opening brace # # To prevent the double use of the indentation value, use this option with the # value 'true'. # # true: indentation will be used only once # false: indentation will be used every time (default) indent_cpp_lambda_only_once = true # true/false # Whether sp_after_angle takes precedence over sp_inside_fparen. This was the # historic behavior, but is probably not the desired behavior, so this is off # by default. use_sp_after_angle_always = false # true/false # Whether to apply special formatting for Qt SIGNAL/SLOT macros. Essentially, # this tries to format these so that they match Qt's normalized form (i.e. the # result of QMetaObject::normalizedSignature), which can slightly improve the # performance of the QObject::connect call, rather than how they would # otherwise be formatted. # # See options_for_QT.cpp for details. # # Default: true use_options_overriding_for_qt_macros = true # true/false # If true: the form feed character is removed from the list # of whitespace characters. # See https://en.cppreference.com/w/cpp/string/byte/isspace use_form_feed_no_more_as_whitespace_character = false # true/false # # Warn levels - 1: error, 2: warning (default), 3: note # # (C#) Warning is given if doing tab-to-\t replacement and we have found one # in a C# verbatim string literal. # # Default: 2 warn_level_tabs_found_in_verbatim_string_literals = 2 # unsigned number # Limit the number of loops. # Used by uncrustify.cpp to exit from infinite loop. # 0: no limit. debug_max_number_of_loops = 0 # number # Set the number of the line to protocol; # Used in the function prot_the_line if the 2. parameter is zero. # 0: nothing protocol. debug_line_number_to_protocol = 0 # number # Set the number of second(s) before terminating formatting the current file, # 0: no timeout. # only for linux debug_timeout = 0 # number # Meaning of the settings: # Ignore - do not do any changes # Add - makes sure there is 1 or more space/brace/newline/etc # Force - makes sure there is exactly 1 space/brace/newline/etc, # behaves like Add in some contexts # Remove - removes space/brace/newline/etc # # # - Token(s) can be treated as specific type(s) with the 'set' option: # `set tokenType tokenString [tokenString...]` # # Example: # `set BOOL __AND__ __OR__` # # tokenTypes are defined in src/token_enum.h, use them without the # 'CT_' prefix: 'CT_BOOL' => 'BOOL' # # # - Token(s) can be treated as type(s) with the 'type' option. # `type tokenString [tokenString...]` # # Example: # `type int c_uint_8 Rectangle` # # This can also be achieved with `set TYPE int c_uint_8 Rectangle` # # # To embed whitespace in tokenStrings use the '\' escape character, or quote # the tokenStrings. These quotes are supported: "'` # # # - Support for the auto detection of languages through the file ending can be # added using the 'file_ext' command. # `file_ext langType langString [langString..]` # # Example: # `file_ext CPP .ch .cxx .cpp.in` # # langTypes are defined in uncrusify_types.h in the lang_flag_e enum, use # them without the 'LANG_' prefix: 'LANG_CPP' => 'CPP' # # # - Custom macro-based indentation can be set up using 'macro-open', # 'macro-else' and 'macro-close'. # `(macro-open | macro-else | macro-close) tokenString` # # Example: # `macro-open BEGIN_TEMPLATE_MESSAGE_MAP` # `macro-open BEGIN_MESSAGE_MAP` # `macro-close END_MESSAGE_MAP` # # # option(s) with 'not default' value: 24 # cppcheck-2.17.1/AUTHORS000066400000000000000000000143651475760761100144610ustar00rootroot00000000000000The cppcheck team, in alphabetical order: 0x41head Abhijit Sawant Abhishek Bharadwaj Abigail Buccaneer Adam J Richter Adrien Chardon Ahti Legonkov Akhilesh Nema Akio Idehara Albert Aribaud Aleksandr Pikalev Aleksey Palazhchenko Alexander Alekseev Alexander Festini Alexander Gushchin Alexander Mai Alexander Tkachev Alexandre Chouvellon Alexey Eryomenko Alexey Zhikhartsev Alfi Maulana Ali Can Demiralp Alon Alexander Alon Liberman Ameen Ali Andreas Bacher Andreas Bießmann Andreas Grob Andreas Pokorny Andreas Rönnquist Andreas Vollenweider Andrei Karas Andrew C Aitchison Andrew C. Martin Andrew D. Bancroft Andy Holmes Andy Maloney Andy Mac Gregor Aneesh Azhakesan S Ankita Gupta anoymouserver Anton Lindqvist Antti Tuppurainen Anurag Garg Armin Müller Arpit Chaudhary Artemis Meursault Gerrard August Sodora Ayaz Salikhov Balázs Tóth Baris Demiray Bart vdr. Meulen Bartlomiej Grzeskowiak bbennetts Benjamin Bannier Benjamin Fovet Benjamin Goose Benjamin Kramer Benjamin Woester Benjamin Wolsey Ben T Bernd Buschinski Bill Egert Björge Dijkstra Björn Blissing booga Boris Barbulovski Boris Egorov Boussaffa Walid Bo Rydberg bzgec Carl Michael Grüner Monzón Carl Morgan Carlo Marcelo Arenas Belón Carlos Gomes Martinho Carl-Oskar Larsson Cary Converse Cary R Changkyoon Kim Chris Lalancette Christian Ehrlicher Christian Franke Christian Göttsche Christoph Grüninger Christoph Schmidt Christoph Strehle Chuck Larson Cilyan Olowen Claus Jensby Madsen Colomban Wendling Conrado Gouvea daisuke-chiba Daniel Friedrich David Korczynski Daniel Marjamäki David Hallas David Korth Dávid Slivka Debrard Sebastien Deepak Gupta Degen's Regens dencat Diego de las Heras Dirk Jagdmann Dirk Mueller Dmitriy Dmitry Marakasov Dmitry-Me dsamo Duraffort Edoardo Prezioso Eivind Tagseth Elbert Pol Emmanuel Blot Eric Lemanissier Eric Malenfant Eric Sesterhenn Erik Hovland Erik Lax Ettl Martin Even Rouault Evgeny Mandrikov feelamee Felipe Pena Felix Faber Felix Geyer Felix Passenberg Felix Wolff Florin Iucha Francesc Elies François Berder Frank Winklmeier Frank Zingsheim Frederik Schwarzer fu7mu4 Galimov Albert Garrett Bodily Gary Leutheuser gaurav kaushik Gennady Feldman Georgi D. Sotirov Georgy Komarov Gerbo Engels Gerhard Zlabinger Gerik Rhoden Gianfranco Costamagna Gianluca Scacco Gleydson Soares Goran Džaferi Graham Whitted Greg Hewgill Guillaume A. Guillaume Chauvel Guillaume Miossec Gustav Palmqvist Günther Makulik Haowei Hsu Harald Scheidl Heiko Bauke Heiko Eißfeldt Heinrich Schuchardt Henrik Nilsson He Yuqi Hoang Tuan Su Igor Rondarev Igor Zhukov Ilya Shipitsin Ivan Maidanski Iván Matellanes Ivan Ryabov Ivar Bonsaksen Jakub Melka Jan Egil Ruud Jan Hellwig János Maros Jay Sigbrandt Jedrzej Klocek Jens Bäckman Jens Yllman Jérémy Lefaure Jes Ramsing Jesse Boswell Jim Kuhn Jim Zhou jlguardi Johan Bertrand Johan Samuelson John Marshall John-Paul Ore John Smits Jonathan Clohessy Jonathan Haehne Jonathan Neuschäfer Jonathan Thackray José Martins Jose Roquette Joshua Beck Joshua Rogers Julian Santander Julien Marrec Julien Peyregne Jure Menart Jussi Lehtola Jørgen Kvalsvik Kamil Dudka Kartik Bajaj Kefu Chai keinflue Ken-Patrick Lehrmann Ketil Skjerve Kevin Christian Kevin Kendzia Kimmo Varis Kleber Tarcísio Konrad Grochowski Konrad Windszus Kumar Ashwani Kushal Chandar Kyle Chisholm Lars Even Almaas larudwer Lau bakman Lauri Nurmi Leandro Lisboa Penz Leila F. Rahman Lena Herscheid Leon De Andrade Lieven de Cock lioncash Lionel Gimbert Lucas Manuel Rodriguez Ludvig Gunne Lindström Luis Díaz Más Luís Pereira Lukas Grützmacher Lukasz Czajczyk Łukasz Jankowski Luxon Jean-Pierre Maarten van der Schrieck Maksim Derbasov Malcolm Parsons Marc-Antoine Perennou Marcel Raad Marco Trevisan Marek Zmysłowski Marian Klymov Mark de Wever Mark Hermeling Markus Elfring Martin Delille Martin Ettl Martin Exner Martin Güthle Martin Herren Márton Csordás Masafumi Koba Massimo Paladin Mateusz Michalak Mateusz Patyk Mateusz Pusz Mathias De Maré Mathias Schmid Matthias Krüger Matthias Kuhn Matthias Schmieder Matt Johnson Maurice Gilden Mavik Michael Drake Michael Løiten Miika-Petteri Matikainen Mika Attila Mike Tzou Milhan Kim Mil Tolstoy Mischa Aster Alff Mohit Mate Monika Lukow Moritz Barsnick Moritz Lipp Moshe Kaplan ms Neszt Tibor Nguyen Duong Tuan Ni2c2k Nick Ridgway Nicolás Alvarez Nicolas Le Cam Nilesh Kumar Ogawa KenIchi Oleksandr Labetskyi Oleksandr Redko Oliver Schode Oliver Stöneberg Olivier Croquette Patrick Oppenlander Paul Aitken Paul Bersee Paul Fultz II Pavel Bibergal Pavel Pimenov Pavel Roschin Pavel Skipenes Pavel Šimovec Pavol Misik Pete Johns Peter Pentchev Peter Schops Philip Chimento Philipp Kloke Pierre Schweitzer Pino Toscano Pranav Khanna Radek Jarecki Rainer Wiesenfarth Ramzan Bekbulatov Raphael Geissert Razvan Ioan Alexe Reijo Tomperi Rainer Wiesenfarth Riccardo Ghetta Richard A. Smith Richard Quirk Rick van der Sluijs Rikard Falkeborn rivdsl Robert Habrich Robert Morin Roberto Martelloni Robert Reif rofl0r Roman Zaytsev Borisovich Ronald Hiemstra root Rosen Penev Rudi Danner Rudolf Grauberger Ryan M. Lederman Ryan Pavlik Samir Aguiar Sam Truscott Samuel Degrande Samuel Poláček Sandeep Dutta Savvas Etairidis Scott Ehlert Scott Furry Seafarix Ltd. Sebastian Held Sebastian Matuschka Sébastien Debrard Sergei Chernykh Sergei Trofimovich Sergey Burgsdorf Shane Tapp Shohei YOSHIDA Simon Cornell Simon Kagstrom Simon Large Simon Martin Simon Shanks Slava Semushin Stas Cymbalov Stefan Beller Stefan Hagen Stefan Naewe Stefan van Kessel Stefan Weil Stéphane Michel Steve Browne Steve Duan Steve Mokris Steven Cook Steven Myint Susi Lehtola Swasti Shrivastava Sylvain Joubert Tam Do Thanh Teddy Didé Temuri Doghonadze Thomas Arnhold Tomasz Edward Posluszny Thomas Jarosch Thomas Niederberger Thomas Otto Thomas P. K. Healy Thomas Sondergaard Thorsten Sick Tim Blume Tim Gerundt tititiou36 Tobias Weber Tobias Weibel Tomasz Kłoczko Tom Pollok Tomo Dote Toralf Förster Troshin V.S. Tyson Nottingham Valentin Batz Valerii Lashmanov Vasily Maslyukov Veli-Matti Visuri Vesa Pikki Ville-Pekka Vahteala Ville Skyttä Vincent Le Garrec Vladimir Petrigo Wang Haoyu WenChung Chiu Wolfgang Stöggl x29a XhmikosR Xuecheng Zhang Yichen Yan Yurii Putin Zachary Blair Zhao Qifa Zhiyuan Zhang Zhu Lei Дмитрий Старцев GUI graphics courtesy of Tango Desktop Project: http://tango.freedesktop.org cppcheck-2.17.1/CMakeLists.txt000066400000000000000000000105671475760761100161510ustar00rootroot00000000000000cmake_minimum_required(VERSION 3.13) project(Cppcheck VERSION 2.17.1 LANGUAGES CXX) include(cmake/options.cmake) include(cmake/cxx11.cmake) use_cxx11() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) include(GNUInstallDirs) include(cmake/compilerCheck.cmake) include(cmake/versions.cmake) include(cmake/findDependencies.cmake) include(cmake/compileroptions.cmake) include(cmake/compilerDefinitions.cmake) include(cmake/buildFiles.cmake) if(BUILD_GUI) include(cmake/qtCompat.cmake) endif() include(cmake/printInfo.cmake) file(GLOB addons_py "addons/*.py") file(GLOB addons_json "addons/*.json") file(GLOB cfgs "cfg/*.cfg") file(GLOB platforms "platforms/*.xml") if(LIBXML2_XMLLINT_EXECUTABLE) add_custom_target(validateCFG DEPENDS validateCFG-cmd) add_custom_command(OUTPUT validateCFG-cmd COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_SOURCE_DIR}/cfg/cppcheck-cfg.rng) foreach(cfg ${cfgs}) add_custom_command(OUTPUT validateCFG-cmd APPEND COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/cfg/cppcheck-cfg.rng ${cfg}) endforeach() # this is a symbolic name for a build rule and not an output file set_source_files_properties(validateCFG-cmd PROPERTIES SYMBOLIC "true") add_custom_target(validatePlatforms ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_SOURCE_DIR}/platforms/cppcheck-platforms.rng) foreach(platform ${platforms}) get_filename_component(platformname ${platform} NAME_WE) add_custom_target(validatePlatforms-${platformname} ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/platforms/cppcheck-platforms.rng ${platform}) add_dependencies(validatePlatforms validatePlatforms-${platformname}) endforeach() add_custom_target(errorlist-xml $ --errorlist > ${CMAKE_BINARY_DIR}/errorlist.xml DEPENDS cppcheck) add_custom_target(example-xml $ --xml --enable=all --inconclusive --max-configs=1 ${CMAKE_SOURCE_DIR}/samples 2> ${CMAKE_BINARY_DIR}/example.xml DEPENDS cppcheck) add_custom_target(createXMLExamples DEPENDS errorlist-xml example-xml) if(Python_EXECUTABLE) add_custom_target(checkCWEEntries ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/tools/listErrorsWithoutCWE.py -F ${CMAKE_BINARY_DIR}/errorlist.xml DEPENDS errorlist-xml) endif() add_custom_target(validateXML ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_SOURCE_DIR}/cppcheck-errors.rng COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/cppcheck-errors.rng ${CMAKE_BINARY_DIR}/errorlist.xml COMMAND ${LIBXML2_XMLLINT_EXECUTABLE} --noout --relaxng ${CMAKE_SOURCE_DIR}/cppcheck-errors.rng ${CMAKE_BINARY_DIR}/example.xml DEPENDS createXMLExamples ) add_custom_target(validateRules ${LIBXML2_XMLLINT_EXECUTABLE} --noout ${CMAKE_SOURCE_DIR}/rules/*.xml) endif() # TODO: add the following Makefile features: # - "man/cppcheck.1" target # - "tags" target # - Cygwin handling # - MinGW handling if(BUILD_TESTS) enable_testing() endif() add_custom_target(copy_cfg ALL ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/cfg" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/cfg" COMMENT "Copying cfg files to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}") # TODO: copy *.py and *.json only add_custom_target(copy_addons ALL ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/addons" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/addons" COMMENT "Copying addons files to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}") add_custom_target(copy_platforms ALL ${CMAKE_COMMAND} -E copy_directory "${PROJECT_SOURCE_DIR}/platforms" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/platforms" COMMENT "Copying platforms files to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}") if(USE_BUNDLED_TINYXML2) message(STATUS "Using bundled version of tinyxml2") add_subdirectory(externals/tinyxml2) endif() add_subdirectory(externals/simplecpp) add_subdirectory(lib) # CppCheck Library add_subdirectory(cli) # Client application add_subdirectory(test) # Tests add_subdirectory(gui) # Graphical application add_subdirectory(tools) add_subdirectory(man) include(cmake/clang_tidy.cmake) cppcheck-2.17.1/COPYING000066400000000000000000001045131475760761100144370ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . cppcheck-2.17.1/Makefile000066400000000000000000002351331475760761100150470ustar00rootroot00000000000000# This file is generated by dmake, do not edit. ifndef VERBOSE VERBOSE= endif # To compile with rules, use 'make HAVE_RULES=yes' ifndef HAVE_RULES HAVE_RULES= endif ifndef MATCHCOMPILER MATCHCOMPILER= endif # use match compiler ifeq ($(MATCHCOMPILER),yes) # Find available Python interpreter ifeq ($(PYTHON_INTERPRETER),) PYTHON_INTERPRETER := $(shell which python3) endif ifeq ($(PYTHON_INTERPRETER),) PYTHON_INTERPRETER := $(shell which python) endif ifeq ($(PYTHON_INTERPRETER),) $(error Did not find a Python interpreter) endif ifdef VERIFY matchcompiler_S := $(shell $(PYTHON_INTERPRETER) tools/matchcompiler.py --verify) else matchcompiler_S := $(shell $(PYTHON_INTERPRETER) tools/matchcompiler.py) endif libcppdir:=build else ifeq ($(MATCHCOMPILER),) libcppdir:=lib else $(error invalid MATCHCOMPILER value '$(MATCHCOMPILER)') endif ifndef CPPFLAGS CPPFLAGS= endif ifdef FILESDIR override CPPFLAGS+=-DFILESDIR=\"$(FILESDIR)\" endif RDYNAMIC=-rdynamic # Set the CPPCHK_GLIBCXX_DEBUG flag. This flag is not used in release Makefiles. # The _GLIBCXX_DEBUG define doesn't work in Cygwin or other Win32 systems. ifndef COMSPEC ifeq ($(VERBOSE),1) $(info COMSPEC not found) endif ifdef ComSpec ifeq ($(VERBOSE),1) $(info ComSpec found) endif #### ComSpec is defined on some WIN32's. WINNT=1 ifeq ($(VERBOSE),1) $(info PATH=$(PATH)) endif ifneq (,$(findstring /cygdrive/,$(PATH))) ifeq ($(VERBOSE),1) $(info /cygdrive/ found in PATH) endif CYGWIN=1 endif # CYGWIN endif # ComSpec endif # COMSPEC ifdef WINNT ifeq ($(VERBOSE),1) $(info WINNT found) endif #### Maybe Windows ifndef CPPCHK_GLIBCXX_DEBUG CPPCHK_GLIBCXX_DEBUG= endif # !CPPCHK_GLIBCXX_DEBUG ifeq ($(VERBOSE),1) $(info MSYSTEM=$(MSYSTEM)) endif ifneq ($(MSYSTEM),MINGW32 MINGW64) RDYNAMIC= endif LDFLAGS+=-lshlwapi else # !WINNT ifeq ($(VERBOSE),1) $(info WINNT not found) endif uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not') ifeq ($(VERBOSE),1) $(info uname_S=$(uname_S)) endif ifeq ($(uname_S),Linux) ifndef CPPCHK_GLIBCXX_DEBUG CPPCHK_GLIBCXX_DEBUG=-D_GLIBCXX_DEBUG endif # !CPPCHK_GLIBCXX_DEBUG endif # Linux ifeq ($(uname_S),GNU/kFreeBSD) ifndef CPPCHK_GLIBCXX_DEBUG CPPCHK_GLIBCXX_DEBUG=-D_GLIBCXX_DEBUG endif # !CPPCHK_GLIBCXX_DEBUG endif # GNU/kFreeBSD LDFLAGS+=-pthread endif # WINNT ifdef CYGWIN ifeq ($(VERBOSE),1) $(info CYGWIN found) endif # Increase stack size for Cygwin builds to avoid segmentation fault in limited recursive tests. CXXFLAGS+=-Wl,--stack,8388608 endif # CYGWIN ifndef CXX CXX=g++ endif ifeq (clang++, $(findstring clang++,$(CXX))) CPPCHK_GLIBCXX_DEBUG= endif ifndef CXXFLAGS CXXFLAGS=-O2 -DNDEBUG -Wall -Wno-sign-compare -Wno-multichar endif ifeq (g++, $(findstring g++,$(CXX))) override CXXFLAGS += -pipe endif override CXXFLAGS += -std=c++11 ifeq ($(HAVE_RULES),yes) PCRE_CONFIG = $(shell which pcre-config) ifeq ($(PCRE_CONFIG),) $(error Did not find pcre-config) endif override CXXFLAGS += -DHAVE_RULES $(shell $(PCRE_CONFIG) --cflags) ifdef LIBS LIBS += $(shell $(PCRE_CONFIG) --libs) else LIBS=$(shell $(PCRE_CONFIG) --libs) endif else ifneq ($(HAVE_RULES),) $(error invalid HAVE_RULES value '$(HAVE_RULES)') endif ifndef PREFIX PREFIX=/usr endif ifndef INCLUDE_FOR_LIB INCLUDE_FOR_LIB=-Ilib -isystem externals -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2 endif ifndef INCLUDE_FOR_CLI INCLUDE_FOR_CLI=-Ilib -isystem externals/picojson -isystem externals/simplecpp -isystem externals/tinyxml2 endif ifndef INCLUDE_FOR_TEST INCLUDE_FOR_TEST=-Ilib -Icli -isystem externals/simplecpp -isystem externals/tinyxml2 endif BIN=$(DESTDIR)$(PREFIX)/bin # For 'make man': sudo apt-get install xsltproc docbook-xsl docbook-xml on Linux DB2MAN?=/usr/share/sgml/docbook/stylesheet/xsl/nwalsh/manpages/docbook.xsl XP=xsltproc -''-nonet -''-param man.charmap.use.subset "0" MAN_SOURCE=man/cppcheck.1.xml ###### Object Files LIBOBJ = $(libcppdir)/valueflow.o \ $(libcppdir)/tokenize.o \ $(libcppdir)/symboldatabase.o \ $(libcppdir)/addoninfo.o \ $(libcppdir)/analyzerinfo.o \ $(libcppdir)/astutils.o \ $(libcppdir)/check.o \ $(libcppdir)/check64bit.o \ $(libcppdir)/checkassert.o \ $(libcppdir)/checkautovariables.o \ $(libcppdir)/checkbool.o \ $(libcppdir)/checkbufferoverrun.o \ $(libcppdir)/checkclass.o \ $(libcppdir)/checkcondition.o \ $(libcppdir)/checkers.o \ $(libcppdir)/checkersidmapping.o \ $(libcppdir)/checkersreport.o \ $(libcppdir)/checkexceptionsafety.o \ $(libcppdir)/checkfunctions.o \ $(libcppdir)/checkinternal.o \ $(libcppdir)/checkio.o \ $(libcppdir)/checkleakautovar.o \ $(libcppdir)/checkmemoryleak.o \ $(libcppdir)/checknullpointer.o \ $(libcppdir)/checkother.o \ $(libcppdir)/checkpostfixoperator.o \ $(libcppdir)/checksizeof.o \ $(libcppdir)/checkstl.o \ $(libcppdir)/checkstring.o \ $(libcppdir)/checktype.o \ $(libcppdir)/checkuninitvar.o \ $(libcppdir)/checkunusedfunctions.o \ $(libcppdir)/checkunusedvar.o \ $(libcppdir)/checkvaarg.o \ $(libcppdir)/clangimport.o \ $(libcppdir)/color.o \ $(libcppdir)/cppcheck.o \ $(libcppdir)/ctu.o \ $(libcppdir)/errorlogger.o \ $(libcppdir)/errortypes.o \ $(libcppdir)/findtoken.o \ $(libcppdir)/forwardanalyzer.o \ $(libcppdir)/fwdanalysis.o \ $(libcppdir)/importproject.o \ $(libcppdir)/infer.o \ $(libcppdir)/keywords.o \ $(libcppdir)/library.o \ $(libcppdir)/mathlib.o \ $(libcppdir)/path.o \ $(libcppdir)/pathanalysis.o \ $(libcppdir)/pathmatch.o \ $(libcppdir)/platform.o \ $(libcppdir)/preprocessor.o \ $(libcppdir)/programmemory.o \ $(libcppdir)/reverseanalyzer.o \ $(libcppdir)/settings.o \ $(libcppdir)/standards.o \ $(libcppdir)/summaries.o \ $(libcppdir)/suppressions.o \ $(libcppdir)/templatesimplifier.o \ $(libcppdir)/timer.o \ $(libcppdir)/token.o \ $(libcppdir)/tokenlist.o \ $(libcppdir)/utils.o \ $(libcppdir)/vf_analyzers.o \ $(libcppdir)/vf_common.o \ $(libcppdir)/vf_settokenvalue.o \ $(libcppdir)/vfvalue.o EXTOBJ = externals/simplecpp/simplecpp.o \ externals/tinyxml2/tinyxml2.o CLIOBJ = cli/cmdlineparser.o \ cli/cppcheckexecutor.o \ cli/executor.o \ cli/filelister.o \ cli/main.o \ cli/processexecutor.o \ cli/sehwrapper.o \ cli/signalhandler.o \ cli/singleexecutor.o \ cli/stacktrace.o \ cli/threadexecutor.o TESTOBJ = test/fixture.o \ test/helpers.o \ test/main.o \ test/options.o \ test/test64bit.o \ test/testanalyzerinformation.o \ test/testassert.o \ test/testastutils.o \ test/testautovariables.o \ test/testbool.o \ test/testbufferoverrun.o \ test/testcharvar.o \ test/testcheck.o \ test/testclangimport.o \ test/testclass.o \ test/testcmdlineparser.o \ test/testcolor.o \ test/testcondition.o \ test/testconstructors.o \ test/testcppcheck.o \ test/testerrorlogger.o \ test/testexceptionsafety.o \ test/testfilelister.o \ test/testfilesettings.o \ test/testfunctions.o \ test/testgarbage.o \ test/testimportproject.o \ test/testincompletestatement.o \ test/testinternal.o \ test/testio.o \ test/testleakautovar.o \ test/testlibrary.o \ test/testmathlib.o \ test/testmemleak.o \ test/testnullpointer.o \ test/testoptions.o \ test/testother.o \ test/testpath.o \ test/testpathmatch.o \ test/testplatform.o \ test/testpostfixoperator.o \ test/testpreprocessor.o \ test/testprocessexecutor.o \ test/testprogrammemory.o \ test/testsettings.o \ test/testsimplifytemplate.o \ test/testsimplifytokens.o \ test/testsimplifytypedef.o \ test/testsimplifyusing.o \ test/testsingleexecutor.o \ test/testsizeof.o \ test/teststandards.o \ test/teststl.o \ test/teststring.o \ test/testsummaries.o \ test/testsuppressions.o \ test/testsymboldatabase.o \ test/testthreadexecutor.o \ test/testtimer.o \ test/testtoken.o \ test/testtokenize.o \ test/testtokenlist.o \ test/testtokenrange.o \ test/testtype.o \ test/testuninitvar.o \ test/testunusedfunctions.o \ test/testunusedprivfunc.o \ test/testunusedvar.o \ test/testutils.o \ test/testvaarg.o \ test/testvalueflow.o \ test/testvarid.o \ test/testvfvalue.o .PHONY: run-dmake tags ###### Targets cppcheck: $(EXTOBJ) $(LIBOBJ) $(CLIOBJ) $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC) all: cppcheck testrunner testrunner: $(EXTOBJ) $(TESTOBJ) $(LIBOBJ) cli/cmdlineparser.o cli/cppcheckexecutor.o cli/executor.o cli/filelister.o cli/processexecutor.o cli/sehwrapper.o cli/signalhandler.o cli/singleexecutor.o cli/stacktrace.o cli/threadexecutor.o $(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ $^ $(LIBS) $(LDFLAGS) $(RDYNAMIC) test: all ./testrunner check: all ./testrunner -q checkcfg: cppcheck validateCFG ./test/cfg/runtests.sh dmake: tools/dmake/dmake.o cli/filelister.o $(libcppdir)/pathmatch.o $(libcppdir)/path.o $(libcppdir)/utils.o externals/simplecpp/simplecpp.o $(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) run-dmake: dmake ./dmake --release clean: rm -f build/*.cpp build/*.o lib/*.o cli/*.o test/*.o tools/dmake/*.o externals/*/*.o testrunner dmake cppcheck cppcheck.exe cppcheck.1 man: man/cppcheck.1 man/cppcheck.1: $(MAN_SOURCE) $(XP) $(DB2MAN) $(MAN_SOURCE) tags: ctags -R --exclude=doxyoutput --exclude=test/cfg cli externals gui lib test install: cppcheck install -d ${BIN} install cppcheck ${BIN} install htmlreport/cppcheck-htmlreport ${BIN} ifdef FILESDIR install -d ${DESTDIR}${FILESDIR} install -d ${DESTDIR}${FILESDIR}/addons install -m 644 addons/*.json ${DESTDIR}${FILESDIR}/addons install -m 644 addons/*.py ${DESTDIR}${FILESDIR}/addons install -d ${DESTDIR}${FILESDIR}/cfg install -m 644 cfg/*.cfg ${DESTDIR}${FILESDIR}/cfg install -d ${DESTDIR}${FILESDIR}/platforms install -m 644 platforms/*.xml ${DESTDIR}${FILESDIR}/platforms else $(error FILESDIR must be set!) endif uninstall: @if test -d ${BIN}; then \ files="cppcheck cppcheck-htmlreport"; \ echo '(' cd ${BIN} '&&' rm -f $$files ')'; \ ( cd ${BIN} && rm -f $$files ); \ fi ifdef FILESDIR @if test -d ${DESTDIR}${FILESDIR}; then \ echo rm -rf ${DESTDIR}${FILESDIR}; \ rm -rf ${DESTDIR}${FILESDIR}; \ fi endif # Validation of library files: ConfigFiles := $(wildcard cfg/*.cfg) ConfigFilesCHECKED := $(patsubst %.cfg,%.checked,$(ConfigFiles)) .PHONY: validateCFG %.checked:%.cfg xmllint --noout --relaxng cfg/cppcheck-cfg.rng $< validateCFG: ${ConfigFilesCHECKED} xmllint --noout cfg/cppcheck-cfg.rng # Validation of platforms files: PlatformFiles := $(wildcard platforms/*.xml) PlatformFilesCHECKED := $(patsubst %.xml,%.checked,$(PlatformFiles)) .PHONY: validatePlatforms %.checked:%.xml xmllint --noout --relaxng platforms/cppcheck-platforms.rng $< validatePlatforms: ${PlatformFilesCHECKED} xmllint --noout platforms/cppcheck-platforms.rng # Validate XML output (to detect regressions) /tmp/errorlist.xml: cppcheck ./cppcheck --errorlist >$@ /tmp/example.xml: cppcheck ./cppcheck --xml --enable=all --inconclusive --max-configs=1 samples 2>/tmp/example.xml createXMLExamples:/tmp/errorlist.xml /tmp/example.xml .PHONY: validateXML validateXML: createXMLExamples xmllint --noout cppcheck-errors.rng xmllint --noout --relaxng cppcheck-errors.rng /tmp/errorlist.xml xmllint --noout --relaxng cppcheck-errors.rng /tmp/example.xml checkCWEEntries: /tmp/errorlist.xml $(eval PYTHON_INTERPRETER := $(if $(PYTHON_INTERPRETER),$(PYTHON_INTERPRETER),$(shell which python3))) $(eval PYTHON_INTERPRETER := $(if $(PYTHON_INTERPRETER),$(PYTHON_INTERPRETER),$(shell which python))) $(eval PYTHON_INTERPRETER := $(if $(PYTHON_INTERPRETER),$(PYTHON_INTERPRETER),$(error Did not find a Python interpreter))) $(PYTHON_INTERPRETER) tools/listErrorsWithoutCWE.py -F /tmp/errorlist.xml .PHONY: validateRules validateRules: xmllint --noout rules/*.xml ###### Build $(libcppdir)/valueflow.o: lib/valueflow.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/calculate.h lib/check.h lib/checkers.h lib/checkuninitvar.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/findtoken.h lib/forwardanalyzer.h lib/infer.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/programmemory.h lib/reverseanalyzer.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vf_analyzers.h lib/vf_common.h lib/vf_settokenvalue.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/valueflow.cpp $(libcppdir)/tokenize.o: lib/tokenize.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/astutils.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/summaries.h lib/symboldatabase.h lib/templatesimplifier.h lib/timer.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/tokenize.cpp $(libcppdir)/symboldatabase.o: lib/symboldatabase.cpp lib/addoninfo.h lib/astutils.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/keywords.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/symboldatabase.cpp $(libcppdir)/addoninfo.o: lib/addoninfo.cpp externals/picojson/picojson.h lib/addoninfo.h lib/config.h lib/json.h lib/path.h lib/standards.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/addoninfo.cpp $(libcppdir)/analyzerinfo.o: lib/analyzerinfo.cpp externals/tinyxml2/tinyxml2.h lib/analyzerinfo.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h lib/utils.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/analyzerinfo.cpp $(libcppdir)/astutils.o: lib/astutils.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkclass.h lib/checkers.h lib/config.h lib/errortypes.h lib/findtoken.h lib/infer.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/astutils.cpp $(libcppdir)/check.o: lib/check.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.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)/check.cpp $(libcppdir)/check64bit.o: lib/check64bit.cpp lib/addoninfo.h lib/check.h lib/check64bit.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.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)/check64bit.cpp $(libcppdir)/checkassert.o: lib/checkassert.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkassert.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.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)/checkassert.cpp $(libcppdir)/checkautovariables.o: lib/checkautovariables.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkautovariables.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkautovariables.cpp $(libcppdir)/checkbool.o: lib/checkbool.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkbool.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.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)/checkbool.cpp $(libcppdir)/checkbufferoverrun.o: lib/checkbufferoverrun.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/astutils.h lib/check.h lib/checkbufferoverrun.h lib/checkers.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkbufferoverrun.cpp $(libcppdir)/checkclass.o: lib/checkclass.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/astutils.h lib/check.h lib/checkclass.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkclass.cpp $(libcppdir)/checkcondition.o: lib/checkcondition.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkcondition.h lib/checkers.h lib/checkother.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.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)/checkers.o: lib/checkers.cpp lib/checkers.h lib/config.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkers.cpp $(libcppdir)/checkersidmapping.o: lib/checkersidmapping.cpp lib/checkers.h lib/config.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkersidmapping.cpp $(libcppdir)/checkersreport.o: lib/checkersreport.cpp lib/addoninfo.h lib/checkers.h lib/checkersreport.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkersreport.cpp $(libcppdir)/checkexceptionsafety.o: lib/checkexceptionsafety.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checkexceptionsafety.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.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 $(libcppdir)/checkfunctions.o: lib/checkfunctions.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checkfunctions.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkfunctions.cpp $(libcppdir)/checkinternal.o: lib/checkinternal.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checkinternal.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.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)/checkinternal.cpp $(libcppdir)/checkio.o: lib/checkio.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checkio.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.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)/checkio.cpp $(libcppdir)/checkleakautovar.o: lib/checkleakautovar.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checkleakautovar.h lib/checkmemoryleak.h lib/checknullpointer.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.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)/checkleakautovar.cpp $(libcppdir)/checkmemoryleak.o: lib/checkmemoryleak.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checkmemoryleak.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.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)/checkmemoryleak.cpp $(libcppdir)/checknullpointer.o: lib/checknullpointer.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checknullpointer.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/findtoken.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checknullpointer.cpp $(libcppdir)/checkother.o: lib/checkother.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checkother.h lib/config.h lib/errortypes.h lib/fwdanalysis.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkother.cpp $(libcppdir)/checkpostfixoperator.o: lib/checkpostfixoperator.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/checkpostfixoperator.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.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)/checkpostfixoperator.cpp $(libcppdir)/checksizeof.o: lib/checksizeof.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/checksizeof.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.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)/checksizeof.cpp $(libcppdir)/checkstl.o: lib/checkstl.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checknullpointer.h lib/checkstl.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/pathanalysis.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkstl.cpp $(libcppdir)/checkstring.o: lib/checkstring.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checkstring.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.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)/checkstring.cpp $(libcppdir)/checktype.o: lib/checktype.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checktype.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checktype.cpp $(libcppdir)/checkuninitvar.o: lib/checkuninitvar.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checknullpointer.h lib/checkuninitvar.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.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)/checkuninitvar.cpp $(libcppdir)/checkunusedfunctions.o: lib/checkunusedfunctions.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/astutils.h lib/checkers.h lib/checkunusedfunctions.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkunusedfunctions.cpp $(libcppdir)/checkunusedvar.o: lib/checkunusedvar.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checkunusedvar.h lib/config.h lib/errortypes.h lib/fwdanalysis.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/checkunusedvar.cpp $(libcppdir)/checkvaarg.o: lib/checkvaarg.cpp lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/checkvaarg.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.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)/checkvaarg.cpp $(libcppdir)/clangimport.o: lib/clangimport.cpp lib/addoninfo.h lib/checkers.h lib/clangimport.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.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)/clangimport.cpp $(libcppdir)/color.o: lib/color.cpp lib/color.h lib/config.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/color.cpp $(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson/picojson.h externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkers.h lib/checkunusedfunctions.h lib/clangimport.h lib/color.h lib/config.h lib/cppcheck.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/json.h lib/library.h lib/mathlib.h lib/path.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 lib/version.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/cppcheck.cpp $(libcppdir)/ctu.o: lib/ctu.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/ctu.cpp $(libcppdir)/errorlogger.o: lib/errorlogger.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/errorlogger.cpp $(libcppdir)/errortypes.o: lib/errortypes.cpp lib/config.h lib/errortypes.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/errortypes.cpp $(libcppdir)/findtoken.o: lib/findtoken.cpp lib/astutils.h lib/config.h lib/errortypes.h lib/findtoken.h lib/library.h lib/mathlib.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/findtoken.cpp $(libcppdir)/forwardanalyzer.o: lib/forwardanalyzer.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/forwardanalyzer.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/valueptr.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/forwardanalyzer.cpp $(libcppdir)/fwdanalysis.o: lib/fwdanalysis.cpp lib/addoninfo.h lib/astutils.h lib/checkers.h lib/config.h lib/errortypes.h lib/fwdanalysis.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/fwdanalysis.cpp $(libcppdir)/importproject.o: lib/importproject.cpp externals/picojson/picojson.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/checkers.h lib/config.h lib/errortypes.h lib/filesettings.h lib/importproject.h lib/json.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/importproject.cpp $(libcppdir)/infer.o: lib/infer.cpp lib/calculate.h lib/config.h lib/errortypes.h lib/infer.h lib/mathlib.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueptr.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/infer.cpp $(libcppdir)/keywords.o: lib/keywords.cpp lib/config.h lib/keywords.h lib/standards.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/keywords.cpp $(libcppdir)/library.o: lib/library.cpp externals/tinyxml2/tinyxml2.h lib/astutils.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/library.cpp $(libcppdir)/mathlib.o: lib/mathlib.cpp externals/simplecpp/simplecpp.h lib/config.h lib/errortypes.h lib/mathlib.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/mathlib.cpp $(libcppdir)/path.o: lib/path.cpp externals/simplecpp/simplecpp.h lib/config.h lib/path.h lib/standards.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/path.cpp $(libcppdir)/pathanalysis.o: lib/pathanalysis.cpp lib/astutils.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/pathanalysis.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/pathanalysis.cpp $(libcppdir)/pathmatch.o: lib/pathmatch.cpp lib/config.h lib/path.h lib/pathmatch.h lib/standards.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/pathmatch.cpp $(libcppdir)/platform.o: lib/platform.cpp externals/tinyxml2/tinyxml2.h lib/config.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/platform.cpp $(libcppdir)/preprocessor.o: lib/preprocessor.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/preprocessor.cpp $(libcppdir)/programmemory.o: lib/programmemory.cpp lib/addoninfo.h lib/astutils.h lib/calculate.h lib/checkers.h lib/config.h lib/errortypes.h lib/infer.h lib/library.h lib/mathlib.h lib/platform.h lib/programmemory.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/programmemory.cpp $(libcppdir)/reverseanalyzer.o: lib/reverseanalyzer.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/checkers.h lib/config.h lib/errortypes.h lib/forwardanalyzer.h lib/library.h lib/mathlib.h lib/platform.h lib/reverseanalyzer.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueptr.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/reverseanalyzer.cpp $(libcppdir)/settings.o: lib/settings.cpp externals/picojson/picojson.h lib/addoninfo.h lib/checkers.h lib/config.h lib/errortypes.h lib/json.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/summaries.h lib/suppressions.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/settings.cpp $(libcppdir)/standards.o: lib/standards.cpp externals/simplecpp/simplecpp.h lib/config.h lib/standards.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/standards.cpp $(libcppdir)/summaries.o: lib/summaries.cpp lib/addoninfo.h lib/analyzerinfo.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/summaries.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)/summaries.cpp $(libcppdir)/suppressions.o: lib/suppressions.cpp externals/tinyxml2/tinyxml2.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h lib/suppressions.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h lib/xml.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/suppressions.cpp $(libcppdir)/templatesimplifier.o: lib/templatesimplifier.cpp lib/addoninfo.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.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)/templatesimplifier.cpp $(libcppdir)/timer.o: lib/timer.cpp lib/config.h lib/timer.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/timer.cpp $(libcppdir)/token.o: lib/token.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/astutils.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/tokenrange.h lib/utils.h lib/valueflow.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/token.cpp $(libcppdir)/tokenlist.o: lib/tokenlist.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/astutils.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/keywords.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/tokenlist.cpp $(libcppdir)/utils.o: lib/utils.cpp lib/config.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/utils.cpp $(libcppdir)/vf_analyzers.o: lib/vf_analyzers.cpp lib/addoninfo.h lib/analyzer.h lib/astutils.h lib/calculate.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/programmemory.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/valueptr.h lib/vf_analyzers.h lib/vf_common.h lib/vf_settokenvalue.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_analyzers.cpp $(libcppdir)/vf_common.o: lib/vf_common.cpp lib/addoninfo.h lib/astutils.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/vf_common.h lib/vf_settokenvalue.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_common.cpp $(libcppdir)/vf_settokenvalue.o: lib/vf_settokenvalue.cpp lib/addoninfo.h lib/astutils.h lib/calculate.h lib/checkers.h lib/config.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/valueflow.h lib/vf_common.h lib/vf_settokenvalue.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vf_settokenvalue.cpp $(libcppdir)/vfvalue.o: lib/vfvalue.cpp lib/config.h lib/errortypes.h lib/mathlib.h lib/templatesimplifier.h lib/token.h lib/utils.h lib/vfvalue.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $(libcppdir)/vfvalue.cpp cli/cmdlineparser.o: cli/cmdlineparser.cpp cli/cmdlinelogger.h cli/cmdlineparser.h cli/filelister.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.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/timer.h lib/utils.h lib/xml.h $(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/cmdlineparser.cpp cli/cppcheckexecutor.o: cli/cppcheckexecutor.cpp cli/cmdlinelogger.h cli/cmdlineparser.h cli/cppcheckexecutor.h cli/executor.h cli/processexecutor.h cli/sehwrapper.h cli/signalhandler.h cli/singleexecutor.h cli/threadexecutor.h externals/picojson/picojson.h lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkers.h lib/checkersreport.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/json.h lib/library.h lib/mathlib.h lib/path.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/executor.o: cli/executor.cpp cli/executor.h lib/addoninfo.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.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_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/executor.cpp cli/filelister.o: cli/filelister.cpp cli/filelister.h lib/config.h lib/filesettings.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/standards.h lib/utils.h $(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/filelister.cpp cli/main.o: cli/main.cpp cli/cppcheckexecutor.h lib/config.h lib/errortypes.h lib/filesettings.h lib/mathlib.h lib/path.h lib/platform.h lib/standards.h $(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/main.cpp cli/processexecutor.o: cli/processexecutor.cpp cli/executor.h cli/processexecutor.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.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/processexecutor.cpp cli/sehwrapper.o: cli/sehwrapper.cpp cli/sehwrapper.h lib/config.h lib/utils.h $(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/sehwrapper.cpp cli/signalhandler.o: cli/signalhandler.cpp cli/signalhandler.h cli/stacktrace.h lib/config.h lib/utils.h $(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/signalhandler.cpp cli/singleexecutor.o: cli/singleexecutor.cpp cli/executor.h cli/singleexecutor.h lib/addoninfo.h lib/check.h lib/checkers.h lib/config.h lib/cppcheck.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/timer.h lib/utils.h $(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/singleexecutor.cpp cli/stacktrace.o: cli/stacktrace.cpp cli/stacktrace.h lib/config.h lib/utils.h $(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/stacktrace.cpp cli/threadexecutor.o: cli/threadexecutor.cpp cli/executor.h cli/threadexecutor.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/timer.h lib/utils.h $(CXX) ${INCLUDE_FOR_CLI} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ cli/threadexecutor.cpp test/fixture.o: test/fixture.cpp externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/xml.h test/fixture.h test/helpers.h test/options.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/fixture.cpp test/helpers.o: test/helpers.cpp cli/filelister.h externals/simplecpp/simplecpp.h externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/checkers.h lib/config.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/xml.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/helpers.cpp test/main.o: test/main.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h test/options.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/main.cpp test/options.o: test/options.cpp test/options.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/options.cpp test/test64bit.o: test/test64bit.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/check64bit.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/test64bit.cpp test/testanalyzerinformation.o: test/testanalyzerinformation.cpp lib/addoninfo.h lib/analyzerinfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testanalyzerinformation.cpp test/testassert.o: test/testassert.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkassert.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testassert.cpp test/testastutils.o: test/testastutils.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/astutils.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/smallvector.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testastutils.cpp test/testautovariables.o: test/testautovariables.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkautovariables.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testautovariables.cpp test/testbool.o: test/testbool.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkbool.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testbool.cpp test/testbufferoverrun.o: test/testbufferoverrun.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkbufferoverrun.h lib/checkers.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testbufferoverrun.cpp test/testcharvar.o: test/testcharvar.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkother.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcharvar.cpp test/testcheck.o: test/testcheck.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcheck.cpp test/testclangimport.o: test/testclangimport.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/clangimport.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testclangimport.cpp test/testclass.o: test/testclass.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkclass.h lib/checkers.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testclass.cpp test/testcmdlineparser.o: test/testcmdlineparser.cpp cli/cmdlinelogger.h cli/cmdlineparser.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcmdlineparser.cpp test/testcolor.o: test/testcolor.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcolor.cpp test/testcondition.o: test/testcondition.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkcondition.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcondition.cpp test/testconstructors.o: test/testconstructors.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkclass.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testconstructors.cpp test/testcppcheck.o: test/testcppcheck.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testcppcheck.cpp test/testerrorlogger.o: test/testerrorlogger.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h lib/xml.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testerrorlogger.cpp test/testexceptionsafety.o: test/testexceptionsafety.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkexceptionsafety.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testexceptionsafety.cpp test/testfilelister.o: test/testfilelister.cpp cli/filelister.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testfilelister.cpp test/testfilesettings.o: test/testfilesettings.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testfilesettings.cpp test/testfunctions.o: test/testfunctions.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkfunctions.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testfunctions.cpp test/testgarbage.o: test/testgarbage.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testgarbage.cpp test/testimportproject.o: test/testimportproject.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/filesettings.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/utils.h test/fixture.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testimportproject.cpp test/testincompletestatement.o: test/testincompletestatement.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkother.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testincompletestatement.cpp test/testinternal.o: test/testinternal.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkinternal.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testinternal.cpp test/testio.o: test/testio.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkio.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testio.cpp test/testleakautovar.o: test/testleakautovar.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkleakautovar.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testleakautovar.cpp test/testlibrary.o: test/testlibrary.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testlibrary.cpp test/testmathlib.o: test/testmathlib.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testmathlib.cpp test/testmemleak.o: test/testmemleak.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkmemoryleak.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testmemleak.cpp test/testnullpointer.o: test/testnullpointer.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checknullpointer.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testnullpointer.cpp test/testoptions.o: test/testoptions.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h test/options.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testoptions.cpp test/testother.o: test/testother.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkother.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testother.cpp test/testpath.o: test/testpath.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpath.cpp test/testpathmatch.o: test/testpathmatch.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/pathmatch.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpathmatch.cpp test/testplatform.o: test/testplatform.cpp externals/tinyxml2/tinyxml2.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h lib/xml.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testplatform.cpp test/testpostfixoperator.o: test/testpostfixoperator.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkpostfixoperator.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpostfixoperator.cpp test/testpreprocessor.o: test/testpreprocessor.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testpreprocessor.cpp test/testprocessexecutor.o: test/testprocessexecutor.cpp cli/executor.h cli/processexecutor.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testprocessexecutor.cpp test/testprogrammemory.o: test/testprogrammemory.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/programmemory.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testprogrammemory.cpp test/testsettings.o: test/testsettings.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsettings.cpp test/testsimplifytemplate.o: test/testsimplifytemplate.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsimplifytemplate.cpp test/testsimplifytokens.o: test/testsimplifytokens.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsimplifytokens.cpp test/testsimplifytypedef.o: test/testsimplifytypedef.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsimplifytypedef.cpp test/testsimplifyusing.o: test/testsimplifyusing.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsimplifyusing.cpp test/testsingleexecutor.o: test/testsingleexecutor.cpp cli/executor.h cli/singleexecutor.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsingleexecutor.cpp test/testsizeof.o: test/testsizeof.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checksizeof.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsizeof.cpp test/teststandards.o: test/teststandards.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/teststandards.cpp test/teststl.o: test/teststl.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkstl.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/teststl.cpp test/teststring.o: test/teststring.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkstring.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/teststring.cpp test/testsummaries.o: test/testsummaries.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/summaries.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsummaries.cpp test/testsuppressions.o: test/testsuppressions.cpp cli/cppcheckexecutor.h cli/executor.h cli/processexecutor.h cli/singleexecutor.h cli/threadexecutor.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsuppressions.cpp test/testsymboldatabase.o: test/testsymboldatabase.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testsymboldatabase.cpp test/testthreadexecutor.o: test/testthreadexecutor.cpp cli/executor.h cli/threadexecutor.h externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/cppcheck.h lib/errorlogger.h lib/errortypes.h lib/filesettings.h lib/library.h lib/mathlib.h lib/path.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/suppressions.h lib/timer.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h test/redirect.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testthreadexecutor.cpp test/testtimer.o: test/testtimer.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/timer.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testtimer.cpp test/testtoken.o: test/testtoken.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testtoken.cpp test/testtokenize.o: test/testtokenize.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testtokenize.cpp test/testtokenlist.o: test/testtokenlist.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testtokenlist.cpp test/testtokenrange.o: test/testtokenrange.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/tokenrange.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testtokenrange.cpp test/testtype.o: test/testtype.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checktype.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testtype.cpp test/testuninitvar.o: test/testuninitvar.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkuninitvar.h lib/color.h lib/config.h lib/ctu.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testuninitvar.cpp test/testunusedfunctions.o: test/testunusedfunctions.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkunusedfunctions.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testunusedfunctions.cpp test/testunusedprivfunc.o: test/testunusedprivfunc.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkclass.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/sourcelocation.h lib/standards.h lib/symboldatabase.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testunusedprivfunc.cpp test/testunusedvar.o: test/testunusedvar.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkunusedvar.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testunusedvar.cpp test/testutils.o: test/testutils.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testutils.cpp test/testvaarg.o: test/testvaarg.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/checkvaarg.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/tokenize.h lib/tokenlist.h lib/utils.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testvaarg.cpp test/testvalueflow.o: test/testvalueflow.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testvalueflow.cpp test/testvarid.o: test/testvarid.cpp externals/simplecpp/simplecpp.h lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/preprocessor.h lib/settings.h lib/standards.h lib/templatesimplifier.h lib/token.h lib/tokenize.h lib/tokenlist.h lib/utils.h lib/vfvalue.h test/fixture.h test/helpers.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testvarid.cpp test/testvfvalue.o: test/testvfvalue.cpp lib/addoninfo.h lib/check.h lib/checkers.h lib/color.h lib/config.h lib/errorlogger.h lib/errortypes.h lib/library.h lib/mathlib.h lib/platform.h lib/settings.h lib/standards.h lib/utils.h lib/vfvalue.h test/fixture.h $(CXX) ${INCLUDE_FOR_TEST} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ test/testvfvalue.cpp externals/simplecpp/simplecpp.o: externals/simplecpp/simplecpp.cpp externals/simplecpp/simplecpp.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) -w -c -o $@ externals/simplecpp/simplecpp.cpp externals/tinyxml2/tinyxml2.o: externals/tinyxml2/tinyxml2.cpp externals/tinyxml2/tinyxml2.h $(CXX) $(CPPFLAGS) $(CXXFLAGS) -w -D_LARGEFILE_SOURCE -c -o $@ externals/tinyxml2/tinyxml2.cpp tools/dmake/dmake.o: tools/dmake/dmake.cpp cli/filelister.h lib/config.h lib/filesettings.h lib/mathlib.h lib/path.h lib/pathmatch.h lib/platform.h lib/standards.h lib/utils.h $(CXX) ${INCLUDE_FOR_LIB} $(CPPFLAGS) $(CXXFLAGS) -c -o $@ tools/dmake/dmake.cpp cppcheck-2.17.1/addons/000077500000000000000000000000001475760761100146505ustar00rootroot00000000000000cppcheck-2.17.1/addons/README.md000066400000000000000000000070601475760761100161320ustar00rootroot00000000000000# Cppcheck addons Addons are scripts that analyses Cppcheck dump files to check compatibility with secure coding standards and to locate various issues. ## Supported addons + [misra.py](https://github.com/danmar/cppcheck/blob/main/addons/misra.py) Used to verify compliance with MISRA C 2012 - a proprietary set of guidelines to avoid such questionable code, developed for embedded systems. Since this standard is proprietary, cppcheck does not display error text by specifying only the number of violated rules (for example, [c2012-21.3]). If you want to display full texts for violated rules, you will need to create a text file containing MISRA rules, which you will have to pass when calling the script with `--rule-texts` key. Some examples of rule texts files available in [tests directory](https://github.com/danmar/cppcheck/blob/main/addons/test/misra/). + [y2038.py](https://github.com/danmar/cppcheck/blob/main/addons/y2038.py) Checks Linux system for [year 2038 problem](https://en.wikipedia.org/wiki/Year_2038_problem) safety. This required [modified environment](https://github.com/3adev/y2038). See complete description [here](https://github.com/danmar/cppcheck/blob/main/addons/doc/y2038.txt). + [threadsafety.py](https://github.com/danmar/cppcheck/blob/main/addons/threadsafety.py) Analyse Cppcheck dump files to locate threadsafety issues like static local objects used by multiple threads. + [naming.py](https://github.com/danmar/cppcheck/blob/main/addons/naming.py) Enforces naming conventions across the code. + [namingng.py](https://github.com/danmar/cppcheck/blob/main/addons/namingng.py) Enforces naming conventions across the code. Enhanced version with support for type prefixes in variable and function names. + [findcasts.py](https://github.com/danmar/cppcheck/blob/main/addons/findcasts.py) Locates casts in the code. + [misc.py](https://github.com/danmar/cppcheck/blob/main/addons/misc.py) Performs miscellaneous checks. ### Other files - doc Additional files for documentation generation. - tests Contains various unit tests for the addons. - cppcheck.py Internal helper used by Cppcheck binary to run the addons. - cppcheckdata.doxyfile Configuration file for documentation generation. - cppcheckdata.py Helper class for reading Cppcheck dump files within an addon. - misra_9.py Implementation of the MISRA 9.x rules used by `misra` addon. - namingng.config.json Example configuration for `namingng` addon. - namingng.json Example JSON file that can be used using --addon=namingng.json, referring to namingng.py and namingng.config.json - ROS_naming.json Example configuration for the `namingng` addon enforcing the [ROS naming convention for C++ ](http://wiki.ros.org/CppStyleGuide#Files). - runaddon.py Internal helper used by Cppcheck binary to run the addons. ## Usage ### Command line interface ```bash cppcheck --addon=misc src/test.c ``` It is also possible to call scripts as follows: ```bash cppcheck --dump --quiet src/test.c python misc.py src/test.c.dump python misra.py --rule-texts=~/misra_rules.txt src/test.c.dump ``` This allows you to add additional parameters when calling the script (for example, `--rule-texts` for `misra.py`). The full list of available parameters can be found by calling any script with the `--help` flag. ### GUI When using the graphical interface `cppcheck-gui`, the selection and configuration of addons is carried out on the tab `Addons and tools` in the project settings (`Edit Project File`): ![Screenshot](https://raw.githubusercontent.com/danmar/cppcheck/main/addons/doc/img/cppcheck-gui-addons.png) cppcheck-2.17.1/addons/ROS_naming.json000066400000000000000000000021341475760761100175370ustar00rootroot00000000000000{ "RE_FILE": [".*[A-Z]"], "RE_NAMESPACE": {".*[A-Z]": [true, "under_scored"], ".*\\_$": [true, "under_scored"]}, "RE_FUNCTIONNAME": {".*\\_": [true, "camelCase"], ".*^[a-z]": [false, "camelCase"]}, "RE_CLASS_NAME": {".*^[A-Z]": [false, "CamelCase"], ".*\\_": [true, "CamelCase"]}, "RE_GLOBAL_VARNAME": {".*^([g]\\_)": [false, "g_under_scored"], ".*[A-Z]": [true, "g_under_scored"], ".*\\_$": [true, "g_under_scored"]}, "RE_VARNAME": {".*^([g]\\_)": [true, "under_scored"], ".*[A-Z]": [true, "under_scored"], ".*\\_$": [true, "under_scored"]}, "RE_PRIVATE_MEMBER_VARIABLE": {".*\\_$": [false, "under_scored_"], ".*[A-Z]": [true, "under_scored_"]}, "RE_PUBLIC_MEMBER_VARIABLE": {".*\\_$": [false, "under_scored_"], ".*[A-Z]": [true, "under_scored_"]}, "var_prefixes": {"uint32_t": "ui32", "int*": "intp"}, "function_prefixes": {"uint16_t": "ui16", "uint32_t": "ui32"}, "skip_one_char_variables": false }cppcheck-2.17.1/addons/__init__.py000066400000000000000000000000001475760761100167470ustar00rootroot00000000000000cppcheck-2.17.1/addons/cppcheck.py000066400000000000000000000020441475760761100170020ustar00rootroot00000000000000 import cppcheckdata import sys import os __checkers__ = [] def checker(f): __checkers__.append(f) return f __errorid__ = '' __addon_name__ = '' def reportError(location, severity, message, errorId=None): cppcheckdata.reportError(location, severity, message, __addon_name__, errorId or __errorid__) def runcheckers(): # If there are no checkers then don't run if len(__checkers__) == 0: return global __addon_name__ global __errorid__ addon = sys.argv[0] parser = cppcheckdata.ArgumentParser() args = parser.parse_args() __addon_name__ = os.path.splitext(os.path.basename(addon))[0] for dumpfile in args.dumpfile: if not args.quiet: print('Checking %s...' % dumpfile) data = cppcheckdata.CppcheckData(dumpfile) for cfg in data.iterconfigurations(): if not args.quiet: print('Checking %s, config %s...' % (dumpfile, cfg.name)) for c in __checkers__: __errorid__ = c.__name__ c(cfg, data) cppcheck-2.17.1/addons/cppcheckdata.doxyfile000066400000000000000000002250471475760761100210410ustar00rootroot00000000000000# Doxyfile 1.8.1.2 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or sequence of words) that should # identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. PROJECT_NAME = "cppcheckdata" # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer # a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify an logo or icon that is # included in the documentation. The maximum height of the logo should not # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding # "class=itcl::class" will allow you to use the command class in the # itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this # tag. The format is ext=language, where ext is a file extension, and language # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all # comments according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you # can mix doxygen, HTML, and XML commands with Markdown formatting. # Disable only in case of backward compatibilities issues. MARKDOWN_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and # unions are shown inside the group in which they are included (e.g. using # @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and # unions with only public data fields will be shown inline in the documentation # of the scope in which they are defined (i.e. file, namespace, or group # documentation), provided this scope is documented. If set to NO (the default), # structs, classes, and unions are shown on a separate page (for HTML and Man # pages) or section (for LaTeX and RTF). INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. SYMBOL_CACHE_SIZE = 0 # Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be # set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given # their name and scope. Since this can be an expensive process and often the # same symbol appear multiple times in the code, doxygen keeps a cache of # pre-resolved symbols. If the cache is too small doxygen will become slower. # If the cache is too large, memory is wasted. The cache size is given by this # formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal scope will be included in the documentation. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = YES # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = YES # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to # do proper type resolution of all parameters of a function it will reject a # match between the prototype and the implementation of a member function even # if there is only one candidate or it is obvious which candidate to choose # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files # containing the references data. This must be a list of .bib files. The # .bib extension is automatically appended if omitted. Using this command # requires the bibtex tool to be installed. See also # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this # feature you need bibtex and perl available in the search path. CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = cppcheckdata.py # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = NO # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) # and it is also possible to disable source filtering for a specific pattern # using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. FILTER_SOURCE_PATTERNS = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C, C++ and Fortran comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = NO # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = NO # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. Note that when using a custom header you are responsible # for the proper inclusion of any scripts and style sheets that doxygen # needs, which is dependent on the configuration options used. # It is advised to generate a default header using "doxygen -w html # header.html footer.html stylesheet.css YourConfigFile" and then modify # that header. Note that the header is subject to change so you typically # have to redo this when upgrading to a newer version of doxygen or when # changing the value of configuration settings such as GENERATE_TREEVIEW! HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # style sheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the style sheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. HTML_DYNAMIC_SECTIONS = NO # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of # entries shown in the various tree structured indices initially; the user # can expand and collapse entries dynamically later on. Doxygen will expand # the tree to such a level that at most the specified number of entries are # visible (unless a fully collapsed tree already exceeds this amount). # So setting the number of entries 1 will produce a full collapsed tree by # default. 0 is a special value representing an infinite number of entries # and will result in a full expanded tree by default. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) # at top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. Since the tabs have the same information as the # navigation tree you can set this option to NO if you already set # GENERATE_TREEVIEW to YES. DISABLE_INDEX = NO # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. # Since the tree basically has the same information as the tab index you # could consider to set DISABLE_INDEX to NO when enabling this option. GENERATE_TREEVIEW = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values # (range [0,1..20]) that doxygen will group on one line in the generated HTML # documentation. Note that a value of 0 will completely suppress the enum # values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to # the MathJax Content Delivery Network so you can quickly see the result without # installing MathJax. # However, it is strongly recommended to install a local # copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension # names that should be enabled during MathJax rendering. MATHJAX_EXTENSIONS = # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client # using Javascript. Doxygen will generate the search PHP script and index # file to put on the web server. The advantage of the server # based approach is that it scales better to large projects and allows # full text search. The disadvantages are that it is more difficult to setup # and does not have live searching capabilities. SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for # the generated latex document. The footer should contain everything after # the last chapter. If it is left blank doxygen will generate a # standard footer. Notice: only use this tag if you know what you are doing! LATEX_FOOTER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See # http://en.wikipedia.org/wiki/BibTeX for more info. LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load style sheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition that # overrules the definition found in the source code. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all references to function-like macros # that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. For each # tag file the location of the external documentation should be added. The # format of a tag file without this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths # or URLs. Note that each tag file must have a unique name (where the name does # NOT include the path). If a tag file is not located in the directory in which # doxygen is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = NO # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 # By default doxygen will use the Helvetica font for all dot files that # doxygen generates. When you want a differently looking font you can specify # the font name using DOT_FONTNAME. You need to make sure dot is able to find # the font, which can be done by putting it in a standard location or by setting # the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the # directory containing the font. DOT_FONTNAME = Helvetica # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the Helvetica font. # If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to # set the path where dot can find it. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If the UML_LOOK tag is enabled, the fields and methods are shown inside # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more # manageable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = NO # If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = NO # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are svg, png, jpg, or gif. # If left blank png will be used. If you choose svg you need to set # HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = png # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to # enable generation of interactive SVG images that allow zooming and panning. # Note that this requires a modern browser other than Internet Explorer. # Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you # need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible. Older versions of IE do not have SVG support. INTERACTIVE_SVG = NO # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = NO # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = NO cppcheck-2.17.1/addons/cppcheckdata.py000077500000000000000000001650631475760761100176520ustar00rootroot00000000000000""" cppcheckdata This is a Python module that helps you access Cppcheck dump data. License: No restrictions, use this as you need. """ import argparse import json import os import sys import subprocess try: import pathlib except ImportError: message = "Failed to load pathlib. Upgrade Python to 3.x or install pathlib with 'pip install pathlib'." error_id = 'pythonError' if '--cli' in sys.argv: msg = { 'file': '', 'linenr': 0, 'column': 0, 'severity': 'error', 'message': message, 'addon': 'cppcheckdata', 'errorId': error_id, 'extra': ''} sys.stdout.write(json.dumps(msg) + '\n') else: sys.stderr.write('%s [%s]\n' % (message, error_id)) sys.exit(1) from xml.etree import ElementTree from fnmatch import fnmatch EXIT_CODE = 0 current_dumpfile_suppressions = [] def _load_location(location, element): """Load location from element/dict""" location.file = element.get('file') line = element.get('line') if line is None: line = element.get('linenr') if line is None: line = '0' location.linenr = int(line) location.column = int(element.get('column', '0')) class Location: """Utility location class""" file = None linenr = None column = None def __init__(self, element): _load_location(self, element) class Directive: """ Directive class. Contains information about each preprocessor directive in the source code. Attributes: str The directive line, with all C or C++ comments removed file Name of (possibly included) file where directive is defined linenr Line number in (possibly included) file where directive is defined To iterate through all directives use such code: @code data = cppcheckdata.parsedump(...) for cfg in data.configurations: for directive in cfg.directives: print(directive.str) @endcode """ #preprocessor.cpp/Preprocessor::dump str = None file = None linenr = None column = None def __init__(self, element): self.str = element.get('str') _load_location(self, element) def __repr__(self): attrs = ["str", "file", "linenr"] return "{}({})".format( "Directive", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class MacroUsage: """ Tracks preprocessor macro usage Attributes: name Name of the macro usefile useline usecolumn isKnownValue """ #preprocessor.cpp/Preprocessor::dump name = None # Macro name file = None linenr = None column = None usefile = None uselinenr = None usecolumn = None def __init__(self, element): self.name = element.get('name') _load_location(self, element) self.usefile = element.get('usefile') self.useline = element.get('useline') self.usecolumn = element.get('usecolumn') self.isKnownValue = element.get('is-known-value', 'false') == 'true' def __repr__(self): attrs = ["name", "file", "linenr", "column", "usefile", "useline", "usecolumn", "isKnownValue"] return "{}({})".format( "MacroUsage", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class PreprocessorIfCondition: """ Information about #if/#elif conditions Attributes: E result """ #preprocessor.cpp/Preprocessor::dump file = None linenr = None column = None E = None result = None def __init__(self, element): _load_location(self, element) self.E = element.get('E') self.result = int(element.get('result')) def __repr__(self): attrs = ["file", "linenr", "column", "E", "result"] return "{}({})".format( "PreprocessorIfCondition", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class ValueType: """ ValueType class. Contains (promoted) type information for each node in the AST. Attributes: type nonstd/pod/record/smart-pointer/container/iterator/void/bool/char/short/wchar_t/int/long/long long/unknown int/float/double/long double sign signed/unsigned bits pointer constness reference typeScopeId originalTypeName bool/const char */long/char */size_t/int/double/std::string/.. """ #symboldatabase.cpp/ValueType::dump type = None sign = None bits = 0 constness = 0 pointer = 0 typeScopeId = None typeScope = None originalTypeName = None def __init__(self, element): self.type = element.get('valueType-type') self.sign = element.get('valueType-sign') self.bits = int(element.get('valueType-bits', 0)) self.pointer = int(element.get('valueType-pointer', 0)) self.constness = int(element.get('valueType-constness', 0)) self.reference = element.get('valueType-reference') self.typeScopeId = element.get('valueType-typeScope') self.originalTypeName = element.get('valueType-originalTypeName') #valueType-containerId TODO add def __repr__(self): attrs = ["type", "sign", "bits", "typeScopeId", "originalTypeName", "constness", "pointer"] return "{}({})".format( "ValueType", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def setId(self, IdMap): self.typeScope = IdMap[self.typeScopeId] def isIntegral(self): return self.type in {'bool', 'char', 'short', 'int', 'long', 'long long'} def isFloat(self): return self.type in {'float', 'double', 'long double'} def isEnum(self): return self.typeScope and self.typeScope.type == "Enum" class Token: """ Token class. Contains information about each token in the source code. The CppcheckData.tokenlist is a list of Token items C++ class: https://cppcheck.sourceforge.io/devinfo/doxyoutput/classToken.html Attributes: str Token string next Next token in tokenlist. For last token, next is None. previous Previous token in tokenlist. For first token, previous is None. link Linked token in tokenlist. Each '(', '[' and '{' are linked to the corresponding '}', ']' and ')'. For templates, the '<' is linked to the corresponding '>'. scope Scope information for this token. See the Scope class. type Type information: name/op/number/string/.. isName Is this token a symbol name isUnsigned Is this token a unsigned type isSigned Is this token a signed type isNumber Is this token a number, for example 123, 12.34 isInt Is this token a int value such as 1234 isFloat Is this token a float value such as 12.34 isString Is this token a string literal such as "hello" strlen string length for string literal isChar Is this token a char literal such as 'x' isBoolean Is this token a boolean isOp Is this token a operator isArithmeticalOp Is this token a arithmetic operator isAssignmentOp Is this token a assignment operator isComparisonOp Is this token a comparison operator isLogicalOp Is this token a logical operator: && || isCast externLang isExpandedMacro Is this token a expanded macro token macroName Macro name that this token is expanded from isRemovedVoidParameter Has void parameter been removed? isSplittedVarDeclComma Is this a comma changed to semicolon in a split variable declaration ('int a,b;' => 'int a; int b;') isSplittedVarDeclEq Is this a '=' changed to semicolon in a split variable declaration ('int a=5;' => 'int a; a=5;') isImplicitInt Is this token an implicit "int"? isComplex isRestrict isAttributeExport varId varId for token, each variable has a unique non-zero id exprId exprId for token, each expression has a unique non-zero id variable Variable information for this token. See the Variable class. function If this token points at a function call, this attribute has the Function information. See the Function class. values Possible/Known values of token typeScope type scope (token->type()->classScope) astParent ast parent astOperand1 ast operand1 astOperand2 ast operand2 orriginalName orriginal name of the token valueType type information: container/.. file file name linenr line number column column To iterate through all tokens use such code: @code data = cppcheckdata.parsedump(...) for cfg in data.configurations: code = '' for token in cfg.tokenlist: code = code + token.str + ' ' print(code) @endcode """ #tokenize.cpp/Tokenizer::dump Id = None str = None next = None previous = None linkId = None link = None scopeId = None scope = None isName = False isNumber = False isInt = False isFloat = False isString = False strlen = None isChar = False isBoolean = False isOp = False isArithmeticalOp = False isAssignmentOp = False isComparisonOp = False isLogicalOp = False isCast = False isUnsigned = False isSigned = False macroName = None isExpandedMacro = False isRemovedVoidParameter = False isSplittedVarDeclComma = False isSplittedVarDeclEq = False isImplicitInt = False isComplex = False isRestrict = False isAttributeExport = False exprId = None varId = None variableId = None variable = None functionId = None function = None valuesId = None values = None impossible_values = None valueType = None typeScopeId = None typeScope = None type = None astParentId = None astParent = None astOperand1Id = None astOperand1 = None astOperand2Id = None astOperand2 = None file = None linenr = None column = None def __init__(self, element): self.Id = element.get('id') self.str = element.get('str') self.next = None self.previous = None self.scopeId = element.get('scope') self.scope = None self.type = element.get('type') if self.type == 'name': self.isName = True if element.get('isUnsigned'): self.isUnsigned = True if element.get('isSigned'): self.isSigned = True elif self.type == 'number': self.isNumber = True if element.get('isInt'): self.isInt = True elif element.get('isFloat'): self.isFloat = True elif self.type == 'string': self.isString = True self.strlen = int(element.get('strlen')) elif self.type == 'char': self.isChar = True elif self.type == 'boolean': self.isBoolean = True elif self.type == 'op': self.isOp = True if element.get('isArithmeticalOp'): self.isArithmeticalOp = True elif element.get('isAssignmentOp'): self.isAssignmentOp = True elif element.get('isComparisonOp'): self.isComparisonOp = True elif element.get('isLogicalOp'): self.isLogicalOp = True if element.get('isCast'): self.isCast = True self.externLang = element.get('externLang') self.macroName = element.get('macroName') if self.macroName or element.get('isExpandedMacro'): self.isExpandedMacro = True if element.get('isRemovedVoidParameter'): self.isRemovedVoidParameter = True if element.get('isSplittedVarDeclComma'): self.isSplittedVarDeclComma = True if element.get('isSplittedVarDeclEq'): self.isSplittedVarDeclEq = True if element.get('isImplicitInt'): self.isImplicitInt = True if element.get('isComplex'): self.isComplex = True if element.get('isRestrict'): self.isRestrict = True if element.get('isAttributeExport'): self.isAttributeExport = True self.linkId = element.get('link') self.link = None if element.get('varId'): self.varId = int(element.get('varId')) if element.get('exprId'): self.exprId = int(element.get('exprId')) self.variableId = element.get('variable') self.variable = None self.functionId = element.get('function') self.function = None self.valuesId = element.get('values') self.values = None self.typeScopeId = element.get('type-scope') self.typeScope = None self.astParentId = element.get('astParent') self.astParent = None self.astOperand1Id = element.get('astOperand1') self.astOperand1 = None self.astOperand2Id = element.get('astOperand2') self.astOperand2 = None self.originalName = element.get('originalName') if element.get('valueType-type'): self.valueType = ValueType(element) else: self.valueType = None _load_location(self, element) def __repr__(self): attrs = ["Id", "str", "scopeId", "isName", "isUnsigned", "isSigned", "isNumber", "isInt", "isFloat", "isString", "strlen", "isChar", "isBoolean", "isOp", "isArithmeticalOp", "isAssignmentOp", "isComparisonOp", "isLogicalOp", "isCast", "externLang", "isExpandedMacro", "isRemovedVoidParameter", "isSplittedVarDeclComma", "isSplittedVarDeclEq", "isImplicitInt", "isComplex", "isRestrict", "isAttributeExport", "linkId", "varId", "variableId", "functionId", "valuesId", "valueType", "typeScopeId", "astParentId", "astOperand1Id", "file", "linenr", "column"] return "{}({})".format( "Token", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def setId(self, IdMap): self.scope = IdMap[self.scopeId] self.link = IdMap[self.linkId] self.variable = IdMap[self.variableId] self.function = IdMap[self.functionId] self.values = [] self.impossible_values = [] if IdMap[self.valuesId]: for v in IdMap[self.valuesId]: if v.isImpossible(): self.impossible_values.append(v) else: self.values.append(v) v.setId(IdMap) self.typeScope = IdMap[self.typeScopeId] self.astParent = IdMap[self.astParentId] self.astOperand1 = IdMap[self.astOperand1Id] self.astOperand2 = IdMap[self.astOperand2Id] if self.valueType: self.valueType.setId(IdMap) def getValue(self, v): """ Get value if it exists Returns None if it doesn't exist """ if not self.values: return None for value in self.values: if value.intvalue == v: return value return None def getKnownIntValue(self): """ If token has a known int value then return that. Otherwise returns None """ if not self.values: return None for value in self.values: if value.valueKind == 'known': return value.intvalue return None def isUnaryOp(self, op): return self.astOperand1 and (self.astOperand2 is None) and self.str == op def isBinaryOp(self): return self.astOperand1 and self.astOperand2 def forward(self, end=None): token = self while token and token != end: yield token token = token.next def backward(self, start=None): token = self while token and token != start: yield token token = token.previous def astParents(self): token = self while token and token.astParent: token = token.astParent yield token def astTop(self): top = None for parent in self.astParents(): top = parent return top def tokAt(self, n): tl = self.forward() if n < 0: tl = self.backward() n = -n for i, t in enumerate(tl): if i == n: return t return None def linkAt(self, n): token = self.tokAt(n) if token: return token.link return None class Scope: """ Scope. Information about global scope, function scopes, class scopes, inner scopes, etc. C++ class: https://cppcheck.sourceforge.io/devinfo/doxyoutput/classScope.html Attributes bodyStart The { Token for this scope bodyEnd The } Token for this scope className Name of this scope. For a function scope, this is the function name; For a class scope, this is the class name. function If this scope belongs at a function call, this attribute has the Function information. See the Function class. functions if this is a Class type, it may have functions defined nestedIn type Type of scope: Function, If/Else/For/While/Switch/Global/Enum/Struct/Namespace/Class/Constructor/Destructor isExecutable True when the type is: Function/If/Else/For/While/Do/Switch/Try/Catch/Unconditional/Lambda definedType """ #symboldatabase.cpp/SymbolDatabase::printXml Id = None bodyStartId = None bodyStart = None bodyEndId = None bodyEnd = None className = None functionId = None function = None nestedInId = None nestedIn = None nestedList = None type = None isExecutable = None varlistId = None varlist = None def __init__(self, element): self.Id = element.get('id') self.className = element.get('className') self.functionId = element.get('function') self.function = None self.functions = [] self.bodyStartId = element.get('bodyStart') self.bodyStart = None self.bodyEndId = element.get('bodyEnd') self.bodyEnd = None self.nestedInId = element.get('nestedIn') self.nestedIn = None self.nestedList = [] self.type = element.get('type') self.definedType = element.get('definedType') self.isExecutable = (self.type in ('Function', 'If', 'Else', 'For', 'While', 'Do', 'Switch', 'Try', 'Catch', 'Unconditional', 'Lambda')) self.varlistId = [] self.varlist = [] def __repr__(self): attrs = ["Id", "className", "functionId", "bodyStartId", "bodyEndId", "nestedInId", "nestedIn", "type", "definedType", "isExecutable", "functions"] return "{}({})".format( "Scope", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def setId(self, IdMap): self.bodyStart = IdMap[self.bodyStartId] self.bodyEnd = IdMap[self.bodyEndId] self.nestedIn = IdMap[self.nestedInId] if self.nestedIn: self.nestedIn.nestedList.append(self) self.function = IdMap[self.functionId] for v in self.varlistId: value = IdMap.get(v) if value: self.varlist.append(value) class Function: """ Information about a function C++ class: https://cppcheck.sourceforge.io/devinfo/doxyoutput/classFunction.html Attributes argument Argument list (dict of argument number and variable) token Token in function implementation tokenDef Token in function definition name type Constructor/CopyConstructor/MoveConstructor/OperatorEqual/Destructor/Function/Lambda/Unknown hasVirtualSpecifier Is this function is virtual isImplicitlyVirtual Is this function is virtual this in the base classes access Public/Protected/Private isInlineKeyword Is inline keyword used isStatic Is this function static isAttributeNoreturn overriddenFunction """ #symboldatabase.cpp/SymbolDatabase::printXml Id = None argument = None argumentId = None token = None tokenId = None tokenDef = None tokenDefId = None name = None type = None access = None isImplicitlyVirtual = None hasVirtualSpecifier = None isInlineKeyword = None isStatic = None isAttributeNoreturn = None overriddenFunction = None nestedIn = None def __init__(self, element, nestedIn): self.Id = element.get('id') self.tokenId = element.get('token') self.tokenDefId = element.get('tokenDef') self.name = element.get('name') self.type = element.get('type') self.hasVirtualSpecifier = element.get('hasVirtualSpecifier', 'false') == 'true' self.isImplicitlyVirtual = element.get('isImplicitlyVirtual', 'false') == 'true' self.access = element.get('access') self.isInlineKeyword = element.get('isInlineKeyword', 'false') == 'true' self.isStatic = element.get('isStatic', 'false') == 'true' self.isAttributeNoreturn = element.get('isAttributeNoreturn', 'false') == 'true' self.overriddenFunction = element.get('overriddenFunction', 'false') == 'true' self.nestedIn = nestedIn self.argument = {} self.argumentId = {} def __repr__(self): attrs = ["Id", "tokenId", "tokenDefId", "name", "type", "hasVirtualSpecifier", "isImplicitlyVirtual", "access", "isInlineKeyword", "isStatic", "isAttributeNoreturn", "overriddenFunction", "nestedIn", "argumentId"] return "{}({})".format( "Function", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def setId(self, IdMap): for argnr, argid in self.argumentId.items(): self.argument[argnr] = IdMap[argid] self.token = IdMap.get(self.tokenId, None) self.tokenDef = IdMap[self.tokenDefId] #todo add class Types: #symboldatabase.cpp/SymbolDatabase::printXml class Variable: """ Information about a variable C++ class: https://cppcheck.sourceforge.io/devinfo/doxyoutput/classVariable.html Attributes: nameToken Name token in variable declaration typeStartToken Start token of variable declaration typeEndToken End token of variable declaration access Global/Local/Namespace/Public/Protected/Public/Throw/Argument/Unknown scope Variable scope constness Variable constness (same encoding as ValueType::constness) isArgument Is this variable a function argument? isGlobal Is this variable a global variable? isLocal Is this variable a local variable? isArray Is this variable an array? isClass Is this variable a class or struct? isConst Is this variable a const variable? isExtern Is this variable an extern variable? isPointer Is this variable a pointer isReference Is this variable a reference isStatic Is this variable static? isVolatile Is this variable volatile? """ #symboldatabase.cpp/SymbolDatabase::printXml Id = None nameTokenId = None nameToken = None typeStartTokenId = None typeStartToken = None typeEndTokenId = None typeEndToken = None access = None scopeId = None scope = None isArgument = False isArray = False isClass = False isConst = False isExtern = False isGlobal = False isLocal = False isPointer = False isReference = False isStatic = False isVolatile = False constness = 0 def __init__(self, element): self.Id = element.get('id') self.nameTokenId = element.get('nameToken') self.nameToken = None self.typeStartTokenId = element.get('typeStartToken') self.typeStartToken = None self.typeEndTokenId = element.get('typeEndToken') self.typeEndToken = None self.access = element.get('access') self.isArgument = (self.access and self.access == 'Argument') self.isGlobal = (self.access and self.access == 'Global') self.isLocal = (self.access and self.access == 'Local') self.scopeId = element.get('scope') self.scope = None self.constness = int(element.get('constness',0)) self.isArray = element.get('isArray') == 'true' self.isClass = element.get('isClass') == 'true' self.isConst = element.get('isConst') == 'true' self.isExtern = element.get('isExtern') == 'true' self.isPointer = element.get('isPointer') == 'true' self.isReference = element.get('isReference') == 'true' self.isStatic = element.get('isStatic') == 'true' self.isVolatile = element.get('isVolatile') == 'true' def __repr__(self): attrs = ["Id", "nameTokenId", "typeStartTokenId", "typeEndTokenId", "access", "scopeId", "isArgument", "isArray", "isClass", "isConst", "isGlobal", "isExtern", "isLocal", "isPointer", "isReference", "isStatic", "isVolatile", "constness"] return "{}({})".format( "Variable", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def setId(self, IdMap): self.nameToken = IdMap[self.nameTokenId] self.typeStartToken = IdMap[self.typeStartTokenId] self.typeEndToken = IdMap[self.typeEndTokenId] self.scope = IdMap[self.scopeId] class Container: """ Container class -- information about containers Attributes: array-like-index-op true/false stdStringLike true/false """ #tokenizer.cpp/tokenizer::dump Id = None def __init__(self, element): self.Id = element.get('id') self.arrayLikeIndexOp = element.get('array-like-index-op') == 'true' self.stdStringLike = element.get('std-string-like') == 'true' class TypedefInfo: """ TypedefInfo class -- information about typedefs Attributes: name name of the typedef used 0/1 """ #tokenizer.cpp/tokenizer::dump name = None used = None file = None linenr = None column = None def __init__(self, element): self.name = element.get('name') _load_location(self, element) self.used = (element.get('used') == '1') class Value: """ Value class Attributes: intvalue integer value tokvalue token value floatvalue float value movedvalue uninit containerSize container size bufferSize buffer size lifetimeScope Local/Argument/SubFunction/ThisPointer/ThisValue lifetimeKind Object/SubObject/Lambda/Iterator/Address symbolicDelta condition condition where this Value comes from bound Upper/Lower/Point valueKind known/possible/impossible/inconclusive path 0/1/2/3/.. """ #token.cpp/token::printValueFlow intvalue = None tokvalue = None floatvalue = None containerSize = None condition = None valueKind = None def isKnown(self): return self.valueKind and self.valueKind == 'known' def isPossible(self): return self.valueKind and self.valueKind == 'possible' def isImpossible(self): return self.valueKind and self.valueKind == 'impossible' def isInconclusive(self): return self.valueKind and self.valueKind == 'inconclusive' def __init__(self, element): self.intvalue = element.get('intvalue') if self.intvalue: self.intvalue = int(self.intvalue) self._tokvalueId = element.get('tokvalue') self.floatvalue = element.get('floatvalue') self.movedvalue = element.get('movedvalue') self.uninit = element.get('uninit') self.bufferSize = element.get('buffer-size') self.containerSize = element.get('container-size') self.iteratorStart = element.get('iterator-start') self.iteratorEnd = element.get('iterator-end') self._lifetimeId = element.get('lifetime') self.lifetimeScope = element.get('lifetime-scope') self.lifetimeKind = element.get('lifetime-kind') self._symbolicId = element.get('symbolic') self.symbolicDelta = element.get('symbolic-delta') self.bound = element.get('bound') self.condition = element.get('condition-line') if self.condition: self.condition = int(self.condition) if element.get('known'): self.valueKind = 'known' elif element.get('possible'): self.valueKind = 'possible' elif element.get('impossible'): self.valueKind = 'impossible' elif element.get('inconclusive'): self.valueKind = 'inconclusive' self.path = element.get('path') def setId(self, IdMap): self.tokvalue = IdMap.get(self._tokvalueId) self.lifetime = IdMap.get(self._lifetimeId) self.symbolic = IdMap.get(self._symbolicId) def __repr__(self): attrs = ["intvalue", "tokvalue", "floatvalue", "movedvalue", "uninit", "bufferSize", "containerSize", "condition", "valueKind"] return "{}({})".format( "Value", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class ValueFlow: """ ValueFlow::Value class Each possible value has a ValueFlow::Value item. Each ValueFlow::Value either has a intvalue or tokvalue C++ class: https://cppcheck.sourceforge.io/devinfo/doxyoutput/classValueFlow_1_1Value.html Attributes: values Possible values """ Id = None values = None def __init__(self, element): self.Id = element.get('id') self.values = [] def __repr__(self): attrs = ["Id", "values"] return "{}({})".format( "ValueFlow", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class Suppression: """ Suppression class This class contains a suppression entry to suppress a warning. Attributes errorId The id string of the error to suppress, can be a wildcard fileName The name of the file to suppress warnings for, can include wildcards lineNumber The number of the line to suppress warnings from, can be 0 to represent any line symbolName The name of the symbol to match warnings for, can include wildcards lineBegin The first line to suppress warnings from lineEnd The last line to suppress warnings from suppressionType The type of suppression which is applied (unique = None (default), file, block, blockBegin, blockEnd, macro) """ errorId = None fileName = None lineNumber = None symbolName = None lineBegin = None lineEnd = None suppressionType = None def __init__(self, element): self.errorId = element.get('errorId') self.fileName = element.get('fileName') self.lineNumber = element.get('lineNumber') self.symbolName = element.get('symbolName') self.lineBegin = element.get('lineBegin') self.lineEnd = element.get('lineEnd') self.suppressionType = element.get('type') def __repr__(self): attrs = ["errorId", "fileName", "lineNumber", "symbolName", "lineBegin", "lineEnd","suppressionType"] return "{}({})".format( "Suppression", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def isMatch(self, file, line, message, errorId): # Line Suppression if ((self.fileName is None or fnmatch(file, self.fileName)) and (self.suppressionType is None) # Verify use of default suppression type (None = unique) and (self.lineNumber is not None and int(line) == int(self.lineNumber)) and (self.symbolName is None or fnmatch(message, '*'+self.symbolName+'*')) and fnmatch(errorId, self.errorId)): return True # File Suppression if ((self.fileName is None or fnmatch(file, self.fileName)) and (self.suppressionType is not None and self.suppressionType == "file") # Verify use of file (global) suppression type and (self.symbolName is None or fnmatch(message, '*'+self.symbolName+'*')) and fnmatch(errorId, self.errorId)): return True # Block Suppression Mode if ((self.fileName is None or fnmatch(file, self.fileName)) and (self.suppressionType is not None and self.suppressionType == "block") # Type for Block suppression and (self.lineBegin is not None and int(line) > int(self.lineBegin)) # Code Match is between the Block suppression and (self.lineEnd is not None and int(line) < int(self.lineEnd)) # Code Match is between the Block suppression and (self.symbolName is None or fnmatch(message, '*'+self.symbolName+'*')) and fnmatch(errorId, self.errorId)): return True # Other Suppression (Globaly set via suppression file or cli command) if ((self.fileName is None or fnmatch(file, self.fileName)) and (self.suppressionType is None) and (self.symbolName is None or fnmatch(message, '*'+self.symbolName+'*')) and fnmatch(errorId, self.errorId)): return True return False class Configuration: """ Configuration class This class contains the directives, tokens, scopes, functions, variables, value flows, and suppressions for one configuration. Attributes: name Name of the configuration, "" for default directives List of Directive items macro_usage List of used macros preprocessor_if_conditions List of preprocessor if conditions that was evaluated during preprocessing tokenlist List of Token items scopes List of Scope items containers List of Container items functions List of Function items variables List of Variable items valueflow List of ValueFlow values standards List of Standards values """ name = '' directives = [] macro_usage = [] preprocessor_if_conditions = [] tokenlist = [] scopes = [] containers = [] functions = [] variables = [] typedefInfo = [] valueflow = [] standards = None clang_warnings = [] def __init__(self, name): self.name = name self.directives = [] self.macro_usage = [] self.preprocessor_if_conditions = [] self.tokenlist = [] self.scopes = [] self.containers = [] self.functions = [] self.variables = [] self.typedefInfo = [] self.valueflow = [] self.standards = Standards() self.clang_warnings = [] def set_tokens_links(self): """Set next/previous links between tokens.""" prev = None for token in self.tokenlist: token.previous = prev if prev: prev.next = token prev = token def set_id_map(self, arguments): IdMap = {None: None, '0': None, '00000000': None, '0000000000000000': None, '0x0': None} for token in self.tokenlist: IdMap[token.Id] = token for scope in self.scopes: IdMap[scope.Id] = scope for container in self.containers: IdMap[container.Id] = container for function in self.functions: IdMap[function.Id] = function for variable in self.variables: IdMap[variable.Id] = variable for variable in arguments: IdMap[variable.Id] = variable for values in self.valueflow: IdMap[values.Id] = values.values for token in self.tokenlist: token.setId(IdMap) for scope in self.scopes: scope.setId(IdMap) #for container in self.containers: # container.setId(IdMap) for function in self.functions: function.setId(IdMap) for variable in self.variables: variable.setId(IdMap) for variable in arguments: variable.setId(IdMap) def setIdMap(self, functions_arguments): """Set relationships between objects stored in this configuration. :param functions_arguments: List of Variable objects which are function arguments """ self.set_tokens_links() self.set_id_map(functions_arguments) class Platform: """ Platform class This class contains type sizes Attributes: name Name of the platform: unspecified/native/win32A/win32W/win64/unix32/unix64/platformFile char_bit CHAR_BIT value short_bit SHORT_BIT value int_bit INT_BIT value long_bit LONG_BIT value long_long_bit LONG_LONG_BIT value pointer_bit POINTER_BIT value """ name = '' char_bit = 0 short_bit = 0 int_bit = 0 long_bit = 0 long_long_bit = 0 pointer_bit = 0 def __init__(self, platformnode): self.name = platformnode.get('name') self.char_bit = int(platformnode.get('char_bit')) self.short_bit = int(platformnode.get('short_bit')) self.int_bit = int(platformnode.get('int_bit')) self.long_bit = int(platformnode.get('long_bit')) self.long_long_bit = int(platformnode.get('long_long_bit')) self.pointer_bit = int(platformnode.get('pointer_bit')) def __repr__(self): attrs = ["name", "char_bit", "short_bit", "int_bit", "long_bit", "long_long_bit", "pointer_bit"] return "{}({})".format( "Platform", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class Standards: """ Standards class This class contains versions of standards that were used for the cppcheck Attributes: c C Standard used cpp C++ Standard used posix If Posix was used """ c = "" cpp = "" posix = False def set_c(self, node): self.c = node.get("version") def set_cpp(self, node): self.cpp = node.get("version") def set_posix(self, node): self.posix = node.get("posix") is not None def __repr__(self): attrs = ["c", "cpp", "posix"] return "{}({})".format( "Standards", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class CppcheckData: """ Class that makes cppcheck dump data available Contains a list of Configuration instances Attributes: filename Path to Cppcheck dump file rawTokens List of rawToken elements suppressions List of Suppressions files Source files for elements occurred in this configuration To iterate through all configurations use such code: @code data = cppcheckdata.parsedump(...) for cfg in data.configurations: print('cfg: ' + cfg.name) @endcode To iterate through all tokens in each configuration use such code: @code data = cppcheckdata.parsedump(...) for cfg in data.configurations: print('cfg: ' + cfg.name) code = '' for token in cfg.tokenlist: code = code + token.str + ' ' print(' ' + code) @endcode To iterate through all scopes (functions, types, etc) use such code: @code data = cppcheckdata.parsedump(...) for cfg in data.configurations: print('cfg: ' + cfg.name) for scope in cfg.scopes: print(' type:' + scope.type + ' name:' + scope.className) @endcode """ def __init__(self, filename): """ :param filename: Path to Cppcheck dump file """ self.language = None self.filename = filename self.rawTokens = [] self.platform = None self.suppressions = [] self.files = [] # source files for elements occurred in this configuration platform_done = False rawtokens_done = False suppressions_done = False # Parse general configuration options from node # We intentionally don't clean node resources here because we # want to serialize in memory only small part of the XML tree. for event, node in ElementTree.iterparse(self.filename, events=('start', 'end')): if platform_done and rawtokens_done and suppressions_done: break if node.tag == 'dumps': self.language = node.get('language') if node.tag == 'platform' and event == 'start': self.platform = Platform(node) platform_done = True elif node.tag == 'rawtokens' and event == 'end': for rawtokens_node in node: if rawtokens_node.tag == 'file': self.files.append(rawtokens_node.get('name')) elif rawtokens_node.tag == 'tok': tok = Token(rawtokens_node) tok.file = self.files[int(rawtokens_node.get('fileIndex'))] self.rawTokens.append(tok) rawtokens_done = True elif node.tag == 'suppressions' and event == 'end': for suppressions_node in node: self.suppressions.append(Suppression(suppressions_node)) suppressions_done = True global current_dumpfile_suppressions current_dumpfile_suppressions = self.suppressions # Set links between rawTokens. for i in range(len(self.rawTokens)-1): self.rawTokens[i+1].previous = self.rawTokens[i] self.rawTokens[i].next = self.rawTokens[i+1] @property def configurations(self): """ Return the list of all available Configuration objects. """ return list(self.iterconfigurations()) def iterconfigurations(self): """ Create and return iterator for the available Configuration objects. The iterator loops over all Configurations in the dump file tree, in document order. """ cfg = None cfg_arguments = [] # function arguments for Configuration node initialization cfg_function = None cfg_valueflow = None # Iterating in a . iter_scope_varlist = False # Iterating iter_typedef_info = False # Iterating iter_directive = False # Use iterable objects to traverse XML tree for dump files incrementally. # Iterative approach is required to avoid large memory consumption. # Calling .clear() is necessary to let the element be garbage collected. for event, node in ElementTree.iterparse(self.filename, events=('start', 'end')): # Serialize new configuration node if node.tag == 'dump': if event == 'start': cfg = Configuration(node.get('cfg')) continue if event == 'end': cfg.setIdMap(cfg_arguments) yield cfg cfg = None cfg_arguments = [] elif node.tag == 'clang-warning' and event == 'start': cfg.clang_warnings.append({'file': node.get('file'), 'line': int(node.get('line')), 'column': int(node.get('column')), 'message': node.get('message')}) # Parse standards elif node.tag == "standards" and event == 'start': continue elif node.tag == 'c' and event == 'start': cfg.standards.set_c(node) elif node.tag == 'cpp' and event == 'start': cfg.standards.set_cpp(node) elif node.tag == 'posix' and event == 'start': cfg.standards.set_posix(node) # Parse directives list elif node.tag == 'directive': if event == 'start': cfg.directives.append(Directive(node)) iter_directive = True elif event == 'end': iter_directive = False # Parse macro usage elif node.tag == 'macro' and event == 'start': cfg.macro_usage.append(MacroUsage(node)) # Preprocessor #if/#elif condition elif node.tag == "if-cond" and event == 'start': cfg.preprocessor_if_conditions.append(PreprocessorIfCondition(node)) # Parse tokens elif node.tag == 'tokenlist' and event == 'start': continue elif node.tag == 'token' and event == 'start' and not iter_directive: cfg.tokenlist.append(Token(node)) # Parse scopes elif node.tag == 'scopes' and event == 'start': continue elif node.tag == 'scope' and event == 'start': cfg.scopes.append(Scope(node)) elif node.tag == 'varlist': if event == 'start': iter_scope_varlist = True elif event == 'end': iter_scope_varlist = False # Parse functions elif node.tag == 'functionList' and event == 'start': continue elif node.tag == 'function': if event == 'start': cfg_function = Function(node, cfg.scopes[-1]) continue if event == 'end': cfg.functions.append(cfg_function) cfg_function = None # Parse function arguments elif node.tag == 'arg' and event == 'start': arg_nr = int(node.get('nr')) arg_variable_id = node.get('variable') cfg_function.argumentId[arg_nr] = arg_variable_id # Parse variables elif node.tag == 'var' and event == 'start': if iter_scope_varlist: cfg.scopes[-1].varlistId.append(node.get('id')) else: var = Variable(node) if var.nameTokenId: cfg.variables.append(var) else: cfg_arguments.append(var) # Parse containers elif node.tag == 'containers' and event == 'start': continue elif node.tag == 'container' and event == 'start': cfg.containers.append(Container(node)) # Parse typedef info elif node.tag == 'typedef-info': iter_typedef_info = (event == 'start') elif iter_typedef_info and node.tag == 'info' and event == 'start': cfg.typedefInfo.append(TypedefInfo(node)) # Parse template-token #elif node.tag == 'TokenAndName' and event == 'start': #todo add processing of containers # cfg.containers.append(Container(node)) # Parse valueflows (list of values) elif node.tag == 'valueflow' and event == 'start': continue elif node.tag == 'values': if event == 'start': cfg_valueflow = ValueFlow(node) continue if event == 'end': cfg.valueflow.append(cfg_valueflow) cfg_valueflow = None # Parse values elif node.tag == 'value' and event == 'start': cfg_valueflow.values.append(Value(node)) # Remove links to the sibling nodes node.clear() def __repr__(self): attrs = ["configurations", "platform"] return "{}({})".format( "CppcheckData", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) # Get function arguments def getArgumentsRecursive(tok, arguments): if tok is None: return if tok.str == ',': getArgumentsRecursive(tok.astOperand1, arguments) getArgumentsRecursive(tok.astOperand2, arguments) else: arguments.append(tok) def getArguments(ftok): if (not ftok.isName) or (ftok.next is None) or ftok.next.str != '(': return None args = [] getArgumentsRecursive(ftok.next.astOperand2, args) return args def parsedump(filename): """ parse a cppcheck dump file """ return CppcheckData(filename) def astIsFloat(token): """ Check if type of ast node is float/double """ if not token: return False if token.str == '.': return astIsFloat(token.astOperand2) if token.str in '+-*/%': return astIsFloat(token.astOperand1) or astIsFloat(token.astOperand2) if not token.variable: # float literal? if token.str[0].isdigit(): for c in token.str: if c == 'f' or c == '.' or c == 'E': return True return False typeToken = token.variable.typeStartToken endToken = token.variable.typeEndToken while typeToken != endToken: if typeToken.str == 'float' or typeToken.str == 'double': return True typeToken = typeToken.next if typeToken.str == 'float' or typeToken.str == 'double': return True return False class CppCheckFormatter(argparse.HelpFormatter): """ Properly formats multiline argument helps """ def _split_lines(self, text, width): # this is the RawTextHelpFormatter._split_lines if text.startswith('R|'): return text[2:].splitlines() return argparse.HelpFormatter._split_lines(self, text, width) def ArgumentParser(): """ Returns an argparse argument parser with an already-added argument definition for -t/--template """ parser = argparse.ArgumentParser(formatter_class=CppCheckFormatter) parser.add_argument('-t', '--template', metavar='', default='{callstack}: ({severity}) {message}', help="R|Format the error messages. E.g.\n" "'{file}:{line},{severity},{id},{message}' or\n" "'{file}({line}):({severity}) {message}' or\n" "'{callstack} {message}'\n" "Pre-defined templates: gcc, vs, edit") parser.add_argument("dumpfile", nargs='*', help="Path of dump files from cppcheck.") parser.add_argument("--cli", help="Addon is executed from Cppcheck", action="store_true") parser.add_argument("--file-list", metavar='', default=None, help="file list in a text file") parser.add_argument("-q", "--quiet", help='do not print "Checking ..." lines', action="store_true") return parser def get_files(args): """Return dump_files, ctu_info_files""" all_files = args.dumpfile if args.file_list: with open(args.file_list, 'rt') as f: for line in f.readlines(): all_files.append(line.rstrip()) dump_files = [] ctu_info_files = [] for f in all_files: if f.endswith('.ctu-info'): ctu_info_files.append(f) else: dump_files.append(f) return dump_files, ctu_info_files def simpleMatch(token, pattern): for p in pattern.split(' '): if not token or token.str != p: return False token = token.next return True patterns = { '%any%': lambda tok: tok, '%assign%': lambda tok: tok if tok.isAssignmentOp else None, '%comp%': lambda tok: tok if tok.isComparisonOp else None, '%name%': lambda tok: tok if tok.isName else None, '%op%': lambda tok: tok if tok.isOp else None, '%or%': lambda tok: tok if tok.str == '|' else None, '%oror%': lambda tok: tok if tok.str == '||' else None, '%var%': lambda tok: tok if tok.variable else None, '(*)': lambda tok: tok.link if tok.str == '(' else None, '[*]': lambda tok: tok.link if tok.str == '[' else None, '{*}': lambda tok: tok.link if tok.str == '{' else None, '<*>': lambda tok: tok.link if tok.str == '<' and tok.link else None, } def match_atom(token, p): if not token: return None if not p: return None if token.str == p: return token if p in ['!', '|', '||', '%', '!=', '*']: return None if p in patterns: return patterns[p](token) if '|' in p: for x in p.split('|'): t = match_atom(token, x) if t: return t elif p.startswith('!!'): t = match_atom(token, p[2:]) if not t: return token elif p.startswith('**'): a = p[2:] t = token while t: if match_atom(t, a): return t if t.link and t.str in ['(', '[', '<', '{']: t = t.link t = t.next return None class MatchResult: def __init__(self, matches, bindings=None, keys=None): self.__dict__.update(bindings or {}) self._matches = matches self._keys = keys or [] def __bool__(self): return self._matches def __nonzero__(self): return self._matches def __getattr__(self, k): if k in self._keys: return None raise AttributeError def bind_split(s): if '@' in s: p = s.partition('@') return (p[0], p[2]) return (s, None) def match(token, pattern): if not pattern: return MatchResult(False) end = None bindings = {} words = [bind_split(word) for word in pattern.split()] for p, b in words: t = match_atom(token, p) if b: bindings[b] = token if not t: return MatchResult(False, keys=[xx for pp, xx in words]+['end']) end = t token = t.next bindings['end'] = end return MatchResult(True, bindings=bindings) def get_function_call_name_args(token): """Get function name and arguments for function call name, args = get_function_call_name_args(tok) """ if token is None: return None, None if not token.isName or not token.scope.isExecutable: return None, None if not simpleMatch(token.next, '('): return None, None if token.function: nametok = token.function.token if nametok is None: nametok = token.function.tokenDef if token in (token.function.token, token.function.tokenDef): return None, None name = nametok.str while nametok.previous and nametok.previous.previous and nametok.previous.str == '::' and nametok.previous.previous.isName: name = nametok.previous.previous.str + '::' + name nametok = nametok.previous.previous scope = token.function.nestedIn while scope: if scope.className: name = scope.className + '::' + name scope = scope.nestedIn else: nametok = token name = nametok.str while nametok.previous and nametok.previous.previous and nametok.previous.str == '::' and nametok.previous.previous.isName: name = nametok.previous.previous.str + '::' + name nametok = nametok.previous.previous return name, getArguments(token) def is_suppressed(location, message, errorId): for suppression in current_dumpfile_suppressions: if suppression.isMatch(location.file, location.linenr, message, errorId): return True return False def log_checker(message, addon): if '--cli' in sys.argv: msg = { 'addon': addon, 'severity': 'none', 'message': message, 'errorId': 'logChecker'} sys.stdout.write(json.dumps(msg) + '\n') def reportError(location, severity, message, addon, errorId, extra='', columnOverride=None): if '--cli' in sys.argv: msg = { 'file': location.file, 'linenr': location.linenr, 'column': location.column if columnOverride is None else columnOverride, 'severity': severity, 'message': message, 'addon': addon, 'errorId': errorId, 'extra': extra} sys.stdout.write(json.dumps(msg) + '\n') else: if is_suppressed(location, message, '%s-%s' % (addon, errorId)): return loc = '[%s:%i]' % (location.file, location.linenr) if len(extra) > 0: message += ' (' + extra + ')' sys.stderr.write('%s (%s) %s [%s-%s]\n' % (loc, severity, message, addon, errorId)) global EXIT_CODE EXIT_CODE = 1 def reportSummary(dumpfile, summary_type, summary_data): msg = {'summary': summary_type, 'data': summary_data} if '--cli' in sys.argv: sys.stdout.write(json.dumps(msg) + '\n') else: # dumpfile ends with ".dump" ctu_info_file = dumpfile[:-4] + "ctu-info" with open(ctu_info_file, 'at') as f: f.write(json.dumps(msg) + '\n') def get_path_premium_addon(): p = pathlib.Path(sys.argv[0]).parent.parent for ext in ('.exe', ''): p1 = os.path.join(p, 'premiumaddon' + ext) p2 = os.path.join(p, 'cppcheck' + ext) if os.path.isfile(p1) and os.path.isfile(p2): return p1 return None def cmd_output(cmd): with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as p: stdout, stderr = p.communicate() rc = p.returncode out = stdout if rc == 1 and len(stderr) > 2: out = stderr return out.decode(encoding='utf-8', errors='ignore') cppcheck-2.17.1/addons/doc/000077500000000000000000000000001475760761100154155ustar00rootroot00000000000000cppcheck-2.17.1/addons/doc/img/000077500000000000000000000000001475760761100161715ustar00rootroot00000000000000cppcheck-2.17.1/addons/doc/img/cppcheck-gui-addons.png000066400000000000000000000561351475760761100225210ustar00rootroot00000000000000PNG  IHDR4觿 pHYs+ IDATxy\Lgi3մLMEP.QiB咾_7pzu* ݒ,mJ6?jܩ~yy99gg3||~Z[[;ځ!"""JJJȷ#@.D^^h2椥!&L0ځ|#TRR8aaaaaaYY1r"Ҍ0lu٣Xɓюo./))TRR"atcL&,--׿cm{4# 0>zo.onnޮݣ#''3F^\^?2юpFx~ B[[y9rxiFG; x%8 1v^\^|3;߿׻#[}V^o>6-F({zz:ujdB޽; SVVfii9iҤSNmڴѣOZQ8}tL87=G _0ntȟ3ghKKhaZ.733h4MUU}ռr劃?g̘cǎ~ǜ9sFOOÇfH ;;{'OVRRz3~k@~~~6l~FbH!֭[{<ܴi?b 6~q#'OH7ov,` y\~С{GL޾͛7AAAͫ~ii2lll1"aֻwשּׂǏΝݻw߸qcRWWy-rrr Nggg_O}.]]jŋ†*k͛7ofm&LB(//OLLl'N|–-[aÆYf͘1ٳgX >}PSSƏ܅ N4i?Pvcnn{' ]r{ OGѱw^mmm55M6577c׮]9s YxʹiLc_{Ç͛8qӖ-[8rc=h4Z[[BHKKٳ ~~~666uvvM4kDKKѣ344Guuumڴɩ~ҤIQQQ2%%%,{L<xÆ ?({{M>};vk2}M6-,,F555>NN!zzzϟ?G}򥱱qɒ%\,@Kׯ766>|_~<6o~9v؜9sOiLfDDÇcbb ݱFB/_믿Lʕ+Ϟ=LtwwTVVzիWG)A~:LWUUegQQђ%KvU]]dee؈5ӧOeeek֬.aqqq/ :u*//̙3xꕂB@@QZZӧOU^m۶>0 BCC?~!##ӣ'޻w/77wիWO =|0$$$!!AWWk}ܹ999k׮p,,,RRRB ǏܹsG&y!ssm۶M4u݄WWקOoܸ+\jF{ULLLxxB{3gNNNNff+mod2/^ZSmm߯[0((˗OKKkjj_Bqqq;v ͽr F[KJJZbEHHy{%Y~k8۷oݺrK.!Ly^|N}}}SSScbb믂,ѱf͚ .>N777--Cmٲ͛7d {ύX`{p[YYYT*_~=**ѣGIIIx#lN244ľ&''O>}C}P`_˖-{٪UPo.V}?vU\\x_&oݺuɤK.\;---88x =z\\\駟=0șKNN˳TQQ ʯ^ $$n:ƍg677'H[n¼UUU8plD$=/##$)==NTTtԩ=QUU5k//̆ rM lľZ[[zzzƲǒ>>>}}ocȹoԩ'Oܾ};Bh̙&MҲ²coZZZ|||ښ`0dee{xb)))"HP>|7MyYXX`MeffVWW_D"͜9s'c… V ]{iffVZZZ__/++?޺u ![XXX^^;mڴD5H---l2e//sII ŋ򋔔OLL B(,,C__`(**b-zyy?P=Y[[I$ {R ? ԩS322B˖-߲e իyyyyyyMMMìWWqXa3++LJW__ɒ%X122JJJs{{MRRRYYϟY{a{p޾}{ƌ3g$Hƍ*GGGZJVVV@@ :89ŋ:::__MИ1chCG_l{7nضm(NߴiSdd$BJFDڵkB4mʔ)؄%HʪQQQ>ŋB4{cccCCWyy9^H"sز4L9r~~~l+***::Z^^̬jUU'MeP{7W`gyy9^'i0SWW nGxbQQQc2 lWij 67y䀀_5//"00Iׯ:u TJb XSUUUt:Da}QYY)&&*))y%h?zBDTRRajjc]v?` 2\YYY|oc٨D"!d2ۻ~-VVVZZZlh48BN dk޼y;wĖMJJ [񃰫kwmjj"MMMا[hmmĽJiii`0 dhhx-EEE##P}}}|bAN"e썀- }֖///=tuuA:Z8Ѐ%d2&$%%4"$$xT/^ ޹s_ooގmi{{/_^zMP]TUUէCjlAFF?eSUU&++ݻmmmWa!!7o ^|رc}/,,6HVon ʞ;wd>~ܼϿÐƍ\Џ?dɒ/^zjѢEY/F_-[v/_*..=xׯ F?3h4!XSS3`׭ӧOGz{{?[ff&V>x X /_Ħpedd=gϞ7@ ̜93::]$ **zY,¤lYYY!!!*AAvlyH7222>>͛_{.wcǎK --]YYq/))>SRRR={fhh-X)--zNщ+))|kqqq؁ؗSbÇl1κggg"&W2}TTTsssӁ111>}"Ӷmbcc󛛛_|}nnn۷oOee%vE˟-((*_~ƍ|f5uT*Օ}C0uԔj?c+~UJJJBB!tzKct:6㗚tR)իWt[z,G}VVV`%::YhٳgZZZa}e```yĉ l?(8b0Ǟ+**9ϐ޽r vFL#Ĵbrą /_.///7oo˗/wtt8pFOOf…X}SN-Y,))IWW+?|ss3gd8q`HHHN;w 9s݀eld%((WGGJfddS^^ڵk۶mtRLL0k#״iӨTeΜ9#..>nrCc~hRRR7#yyS Դm۶>>>CCݻw>;eʔe˖3 55)Sٳg7mJII4FEDDDDDdannbw?sQQѸq㌍¹s [[['LuVPrrmZ[[%%%9r۷WKKˮ.eeNp`|||9xZgggsss33;vlܸ\FFIIk׮bA$Ϟ=O?>|X__ѢEy```O͛7o+:::ǛKII͝;Xti_IJJ۷r;e422:ۃ`M2]tinn9sdO?YFFF'O^[[>bA9onddD"lmmW^ jkkğ;szI&8qbFzc2ϟ߼y3@8qC8ؕ.llllllB"""cKBK,YdI–-[lZ8qDuuu/_{+j Yڵk׮]q",-----{39rȑ~b!`iiiZZZ$ED"͛7r~밾 4? Ν;A H|I Fƍ7,,,F;o8ŋةǧO>}tΜ9јѣ{.X`#!co0wB0گ?9v0?~\jU[[F;~x pc2AAA^^^حthG4Bcr1Řюb|۱LO_.䮳bVTy9rxiFOQmFX{9rxiuo`,Zh={W߸=G;!4A.rA.rA.rA.rA.rA.sm۶nڻΝ; rܹsTjKKpDZ./))y)D0$C塡:::+Wx"^{###111kk/_ѓ'Oܲe ^ظvZYYYyyy??NP^^o7iҤCaoݺ&..`0N86r.wrrrrr+//GuwwYYYlڴҥKX͢"WWא *?)((|YLLѣGz˗/w]PPZjٳgkkk322fΜɩmMSRR544&OzmEE/D2773gVƍg677'H[n/_{n11199m۶bD"qƍ! tDzm]])S8rŋh4Bf///#HX%%%lBQQ[&H !T__?~x\AA#eFPTTԭ[=XY-""]VV!˗ׯ_ZUUNGȼx/ Q(b Aaa!V/wikk vww`5qyLLLwwwzzzZZZZZZFFƬY.^)&&Ͽ}6V&666??!Wׯ_onn&T*`ŋ/_.//xyy[~8z-dqqqMMM|?DrvvްaC_=2̓'OY@ L<ߺ,66f,,,{w\p7w\p7wMMMM555D"H$_@%)))$$4˫( @znii}0yyy_M!2D""C==k R-\p7w\p7w\p7w\p7w\p!޾}0`5 ~AWWwj8B"""l gH/rppPSSkkkc[vDV^^~I}}}11'ݻdb>|0k, 2mڴիW3f̐srr,--Ǐ5 呑޽svv&l+?~ڵkBuڵ+NػwoNNιsBBB.\/--]vm]]BHZZSLYbʕ+Ǐ_\\ӘӧO&#fr9>ڵkO_i4ځ֬Y`0V\ڹsɒ%K^xJKK+((P(k֬uBz\g IDATNJJJJKK+((|kYHHHIIiΜ9ô|. brOOOZ...&Mruu=}ɓ'{|8222&&k.zaaal@ h4uuu__e˖566.\޾ 33300s a9_|rmm'N8::rPޗǏ8q55?`{ׯ_?}TUUUSS% @>|ߡa<<<Ɩ9(gԩSۭ[[[[;::B::: wnnn>w\UU… B7oLHHs^^^]]uɺuTTTɠСC""""""vvv!W&&&JKK9rڵkOдzyy)((̚5֭[H$^~t:}ڴiwF_ *%%%߽{Ƕɓ{:88888Fp NrQQѸT`\0nnnnnn*o߾mhhB`X\Р;`Tv qcCQQQww7ţ 0aBxxxH\\\tׯ_6iii'eeeOOO1lܸNYYK.=z(ޑ7Np*`!6(hڥK+++wڅ777z>}Zvmyyc\]]+**B&MJLLvvvnnnFEDD\tٳgwݹsZZZˏ?ǶS޹sGBB"777$$m ]b+!;;vspJJJ```MM`srr!nnn_7oތ"׮]6m=H466={{B4H$Q(#^)///$$׻;TSSC lbW ,XP\\tRg|.ڻwoCC?#t: ((_sNP墢T=˗/+)))++"***{wnff //WS]xx8ɼr劓ӷN_[|cN8qĉ2( @ iDDk 6ihh LTWWnL&ӦMa+1 xxW%WWW'''333dllm0,׾>|['MJJzjGGG[[[bbbqqqCC??2ByyyXe;;Ϸ ޹d2T*//o_M BHJJǏx5]]]͛7;99~Ẏdݺu*** %%ug2 %%wuuihh[[[?}R#,--ϟڻ~ARRRGGz…}55` !۷KIIXML`A/_ bccmllZ^^...N"9-`nn>`qqq&&&C ʕ+ǏOHH@|:;;kkk؊r|(~{w8)iii9y$vO<)l_ɓ'K,1557,ױfϞ8k$~r9  r9  r9  r9  r9ݾ\J&Bk׮=phGkCCCCC`|.u̙3EEEeeeᇤ8BpM{\~9wwwgg第+WSSiӦq6Q9!d.okk_ٳfYYYQQŋ?~!`0oߎ%9&(''7a„p|ٳVVV?F||>>l^8/_lll\ZZ7"---466644^WMMm߾}˗/f`p2kiiQHB&)$$DP": Ϥ+++ӧO~d2m6l8qD~~~nnF !aaa 7ruuMLL|}ss={@od2y޽ӧ+**o޼ZlΝ;7'''[ZZBǎd/T*СC]]]>]ƍ555ARRD"wtta땕[ZZΜ9llhhWVVF=x //!!!f'%%uvv7nܸq$'Z0p4ww3g\pAUUUUUٳ..._UVVvԩFFFsF988XZZ͟?_UUu]īWFEEhڒutttO:%...((뫯/%%ٳg;88#8544\]]>}v}Z[[cMMM6mVTTlnn޶m PllMUſA5kF;:;;kkk}bQ7\$)) ; `ю5 {rssdddΝ;`0F;"`pe.wsse+\p7w\p7w\p7w\p7NV۷oFP4559/0q2744X-55cUDDmyzz:lw]]]jjjmmmTu̙3EEEeeeᇤAEOcHw9;;;w9+++++kʕisgN$]v U_~ٳgϚ5kŋ/Z!jmm,$$GCCí[+**>IYYB 'Ώ˫lllؠӓFʛ7ojkkY w~g>|WW^]vm߾}&&&A)))555#>L&TjN>Ho~u͛7S>0fq~]HHh޽3g|͛#Tj[[ϟ{O>\H$"LfGGGww7BB qq℣〃rJd-d2T*ի<<<DZ`l,sal32w_~7oB^z˖-^]JJpњ[NEEeA9̙3.\PUUUUU={ Bh&&&sY ĉ9woIC EXN0q\\TT4..n08)0q2s5 \p7w\p7w\p7w\p7w\p7w\p7wVymCCÀ(&2N]]rS`d.G-OOOg0bbb#qAMM:zzzd29??/3gLNKKCm޼õDDD-ZTQQU d2Y\\׬HHH,X)ʄ <<}QQQ:::LfhhhnnˇB%%%...v***nnnX}AAUVܹJ--Geff*++/Zd W.dzTWW׮]|||_ aaaGׯ_,X@@@@FFf岲SD"_ҥKx^zuk׮͛7Jxyymذ#Gtuu%%%W\+PDDh```BBBQQBHOOqL77U222ܺvWW˗cBϊtÆ <q℣!qqӧXYKK:##PVV۷oB˗߿?x `0ɑegg}UZWWBCCIOMM-33[铚Z?1XZZOn 0ÒyxxCJHH}O.))ikk{Ett~:Xo߾MMMMMM}MGGǽ{X888>|˗/Ǐ?z(k+WVWW_p !dgg?c yyy~kk+v{kk+r7nlmmmmmsudݺu***c zVJJݻFFF...=.8'Om...O>??8==}Ŭ***\@DDDDDDd?~K.cEDD DDDLMMB<:t߰PllMU2..dcAgggmm-NNTT***7j89orA.rA.rA.rA.' Ivvv]]Y_OBBJ}Ye_UpT#ICyor@`{NUUGy׍ZJT#i{dҡ{o6lGG]]ݬYF; QT*ӧ˳>];FN[Õ'rYcO+B"Ǽ|c hr9|X{֮]{1<9?.WVVǖ ӦM!8ߡ{YZZy{tqqh#o,X設sθq_x 577q:oBHHhڵiaO#o8sϱ̞=FȬ^!G)) mmUVuvvh4kk뢢)**8p@SS3%%ECCÇ{^k333ٍ7)++?!t---))y eddRSSBUUUrrrO| #>>o޼P۷o9"###''wӖ+VPUU} (njj$ubbb,- =$H'O޾};V+111uuG!/^ǶyfOOOlΝ; , v<<<B?~;w˗ʍrrr۶mwEEEE'Ms.B...gYzqձQ;{ttɓEEEtzHHTTTN81n8Gu`/ܒ'N?gIDAT{=nf666 gϞ~|}}=BÇ4ƦMAAAAAa0S FKrĉű0u,XPYYYTT}"뛛_zuy&p2׳+>>>>>>33s>}deevcǎVTTV8|ldddnn+}:q℣cyyBW^ѦoaaS/^WUUu̙5k`;g֭V$''_S0o߾=}7o>|('';찰CԴO>¢v=uuu3g ccc޿=nܸ+W_v߿S6$##@_9v옜\TTTaaʕ+.]:k,///_\?hQQQd2pXgA2Yv kߜSRR( ۟/--7oތ"~~~Ϟ=cۑ7LkצMfooO$gϞ}޽~:ukڴiD"qeee!777555={^D"mmm2<`lϞ=SSS/1钒K,yB(,,lAAAo2 _p!DZv)vɓ'ׯ_M$?{!SNuwwǵFFFya!aQz{{#Ubbbp{---mmmW^qpp 3f077{oܸ'Hϟh۷|||NNNX ߳g/r%ֵH$RKK۷o F.\\\lmm-[1HoՉN:+"jjj<< MBYlYff-[/߀CayXrVO.--=x𠇇i: Ǧ[|!!!d}b0{CNN_RR 6mguE2ݻׯ߼y}mt6YYŶ*++ɶG}Ⱥ[[[--..ƿj-ǎ¿L4IYYΝ;=5k_{~ ٳKJJk[[ׯg}Etzyy9~AaaB*V# 77]v޽{>}3gVz;99}hٲeYaiXB(##ԩSNNN6lQ,;bc {СCx7nIIIO444HKKKJJ"~SRRjllBݺurIIIW^hkk2A:RRR4B#88855d644ܸq!uVŋ\d2T*__ WRRЀϻx񜜜f++ANc|ۊk׮uwwգv`ssSr۷gee;wnٲe}uvʕӶNNNǏv';;;233cbbcooxeUKHH^Y*j?iPSWbc"1X c,"#B-,Rb;jRmCQG*(XP).q{DJ}͛5 ^'7g˕]rٳR)}ք .666Ϟ=;|FF "66ѣGm!ݹs@Vg(ʬ,Rb $\\\\nYYYWǏ䔔~}˖-t+ٳkܹӿJU^^tWt2sgSo{~;N^[}{XYncc{|DP(o߮;[jG9yNB͛M6a„SN}D"9rHZZ۟^|yLLD"ٶm ,X`iiꚛp~dBȺu 鋬 KJJ,--=<<'Ȍ=q?xž666J2--B8qƍΝ۷o_ggCq8dɒ'O?_re :YYYaaa2L&aCBB󽼼/Quq9x~]xqȑ++ǏرJ&%$$צO;({.ǣOBf͚u~rK$3g&''ӝ'%%IҡC9rҤIyɒ%bX**ʘ6CtEQ)))RT,ٳ'55}Poo+Wv#~ǩSzzzCՌvbψ,f7X7"xҥKLfĈ>aT&B_NNҥKX[[YMbϯ-Y5|p L/s[ݳ0:#,/~,Z-h8皙ZA?,bʕ+ ]|Y,jk/7NztO2)j7;wN> _o.ŇÓ\]ՒOdYdԯ2,6vx-w)b`7d9! YnrvCݘe[/Ak4d9QQh5aZV*Eq8oz݄(VT*U* \"(J.pz9FhbBP(2c`7d9! YnrvCݐ,߻w|`zEv`2 ݽt׮]ڮ())tb+!d֭aaatـ=hαx<!SNߍ0aBQQъ+Μ9#!**&&O?mnn&YXXlذ5"""55o֬Ynnnӧ>srrD"\.߲eKs jmmrOjԨѣGB|}}KKK!fffSN={l_O&EGGB~gOOOp¾}ѣǍ7D"Ѱan*5k鲹9]pww2dHyyBhDT?3gΤS3VKӧjtx'ODK.޿ te͍AUTTB*++ڰ{~/=))ãK0;.si}7n߾vvv۩u+bqfffaaaaa۷+++ xBBB #effFGGK$={[EQ[nLOO߱c-8 t.;;Gkݐ,`7d91 usssMM 5@Gh4KKKFOfUUU}fff]Y (VR]]moo ž={2t Q*0^rq8`Tlf!_D-c`7d9! YnrvCݐ,`7wƍMMMVӧx2˛Fi˗/pPϱ}RVKu8$N=}?ywLq\ф8;;vP^^^"H*;wΨڽ{B1`,̼sNhh(Y;wFDDΚ5+==s;vM9"A+) fڵzZ|*Zo7oT*DSLINN֯s=ooo+++LhѢO퓒ƌ3lذYfT*z5kd2\< AαSOݷo]AAA˖-| UUU7n_ .zYׯN6McR[^^~k׮' N:uB2227o8q֭믿\ցSPP;vިP(N˅BaBBBSSS\\\W !b:NNNr|Ŋ!9]իWss3!R&ubsjeUVV4.Ϙ1###o>(?wwBA9!M,gffo]qEGG +WmmctYWşں.WWWݻuVnn;D&c,733r>jժ;vTVV666,ZHNcc!CAKKKjjj<|PT&&&D")++GO----[O2888< is Y2038-unsafe This reflects the fact that the user code is referring to a symbol which, when glibc defaults to 32-bit time support, might fail Y2038. General note: y2038.py will handle multiple configurations, and will emit diagnostics for each configuration in turn. 4. How to use the Y2038 cppcheck addon The Y2038 cppcheck addon is used like any other cppcheck addon: cppcheck --dump file1.c [ file2.c [...]]] y2038.py file1.c [ file2.c [...]]] Sample test C file is provided: test/y2038-test-1-bad-time-bits.c test/y2038-test-2-no-time-bits.c test/y2038-test-3-no-use-time-bits.c test/y2038-test-4-good.c These cover the cases described above. You can run them through cppcheck and y2038.py to see for yourself how the addon diagnostics look like. If this README is not outdated (and if it is, feel free to submit a patch), you can run cppcheck on these files as on any others: cppcheck --dump addons/y2038/test/y2038-*.c y2038.py addons/y2038/test/y2038-*.dump If you have not installed cppcheck yet, you will have to run these commands from the root of the cppcheck repository: make sudo make install ./cppcheck --dump addons/y2038/test/y2038-*.c PYTHONPATH=addons python addons/y2038/y2038.py addons/y2038/test/y2038-*.c.dump In both cases, y2038.py execution should result in the following: Checking addons/y2038/test/y2038-test-1-bad-time-bits.c.dump... Checking addons/y2038/test/y2038-test-1-bad-time-bits.c.dump, config ""... Checking addons/y2038/test/y2038-test-2-no-time-bits.c.dump... Checking addons/y2038/test/y2038-test-2-no-time-bits.c.dump, config ""... Checking addons/y2038/test/y2038-test-3-no-use-time-bits.c.dump... Checking addons/y2038/test/y2038-test-3-no-use-time-bits.c.dump, config ""... Checking addons/y2038/test/y2038-test-4-good.c.dump... Checking addons/y2038/test/y2038-test-4-good.c.dump, config ""... # Configuration "": # Configuration "": [addons/y2038/test/y2038-test-1-bad-time-bits.c:8]: (error) _TIME_BITS must be defined equal to 64 [addons/y2038/test/y2038-inc.h:9]: (warning) _USE_TIME_BITS64 is defined but _TIME_BITS was not [addons/y2038/test/y2038-test-1-bad-time-bits.c:10]: (information) addons/y2038/test/y2038-inc.h was included from here [addons/y2038/test/y2038-inc.h:9]: (warning) _USE_TIME_BITS64 is defined but _TIME_BITS was not [addons/y2038/test/y2038-test-2-no-time-bits.c:8]: (information) addons/y2038/test/y2038-inc.h was included from here [addons/y2038/test/y2038-test-3-no-use-time-bits.c:13]: (warning) timespec is Y2038-unsafe [addons/y2038/test/y2038-test-3-no-use-time-bits.c:15]: (warning) clock_gettime is Y2038-unsafe Note: y2038.py recognizes option --template as cppcheck does, including pre-defined templates 'gcc', 'vs' and 'edit'. The short form -t is also recognized. cppcheck-2.17.1/addons/findcasts.py000077500000000000000000000015071475760761100172060ustar00rootroot00000000000000#!/usr/bin/env python3 # # Locate casts in the code # import cppcheck @cppcheck.checker def cast(cfg, data): for token in cfg.tokenlist: if token.str != '(' or not token.astOperand1 or token.astOperand2: continue # Is it a lambda? if token.astOperand1.str == '{': continue # we probably have a cast.. if there is something inside the parentheses # there is a cast. Otherwise this is a function call. typetok = token.next if not typetok.isName: continue # cast number => skip output if token.astOperand1.isNumber: continue # void cast => often used to suppress compiler warnings if typetok.str == 'void': continue cppcheck.reportError(token, 'information', 'found a cast') cppcheck-2.17.1/addons/misc.py000066400000000000000000000136611475760761100161640ustar00rootroot00000000000000#!/usr/bin/env python3 # # Misc: Uncategorized checks that might be moved to some better addon later # # Example usage of this addon (scan a sourcefile main.cpp) # cppcheck --dump main.cpp # python misc.py main.cpp.dump import cppcheckdata import sys import re DEBUG = ('-debug' in sys.argv) VERIFY = ('-verify' in sys.argv) VERIFY_EXPECTED = [] VERIFY_ACTUAL = [] def reportError(token, severity, msg, id): if id == 'debug' and not DEBUG: return if VERIFY: VERIFY_ACTUAL.append(str(token.linenr) + ':' + id) else: cppcheckdata.reportError(token, severity, msg, 'misc', id) def simpleMatch(token, pattern): return cppcheckdata.simpleMatch(token, pattern) # Get function arguments def getArgumentsRecursive(tok, arguments): if tok is None: return if tok.str == ',': getArgumentsRecursive(tok.astOperand1, arguments) getArgumentsRecursive(tok.astOperand2, arguments) else: arguments.append(tok) def getArguments(ftok): arguments = [] getArgumentsRecursive(ftok.astOperand2, arguments) return arguments def isStringLiteral(tokenString): return tokenString.startswith('"') # check data def stringConcatInArrayInit(data): # Get all string macros stringMacros = [] for cfg in data.iterconfigurations(): for directive in cfg.directives: res = re.match(r'#define[ ]+([A-Za-z0-9_]+)[ ]+".*', directive.str) if res: macroName = res.group(1) if macroName not in stringMacros: stringMacros.append(macroName) # Check code arrayInit = False for i in range(len(data.rawTokens)): if i < 2: continue tok1 = data.rawTokens[i-2].str tok2 = data.rawTokens[i-1].str tok3 = data.rawTokens[i-0].str if tok3 == '}': arrayInit = False elif tok1 == ']' and tok2 == '=' and tok3 == '{': arrayInit = True elif arrayInit and (tok1 in [',', '{']): isString2 = (isStringLiteral(tok2) or (tok2 in stringMacros)) isString3 = (isStringLiteral(tok3) or (tok3 in stringMacros)) if isString2 and isString3: reportError(data.rawTokens[i], 'style', 'String concatenation in array initialization, missing comma?', 'stringConcatInArrayInit') def implicitlyVirtual(data): for cfg in data.iterconfigurations(): for function in cfg.functions: if function.isImplicitlyVirtual is None: continue if not function.isImplicitlyVirtual: continue reportError(function.tokenDef, 'style', 'Function \'' + function.name + '\' overrides base class function but is not marked with \'virtual\' keyword.', 'implicitlyVirtual') def ellipsisStructArg(data): for cfg in data.iterconfigurations(): for tok in cfg.tokenlist: if tok.str != '(': continue if tok.astOperand1 is None or tok.astOperand2 is None: continue if tok.astOperand2.str != ',': continue if tok.scope.type in ['Global', 'Class']: continue if tok.astOperand1.function is None: continue for argnr, argvar in tok.astOperand1.function.argument.items(): if argnr < 1: continue if not simpleMatch(argvar.typeStartToken, '...'): continue callArgs = getArguments(tok) for i in range(argnr-1, len(callArgs)): valueType = callArgs[i].valueType if valueType is None: argStart = callArgs[i].previous while argStart.str != ',': if argStart.str == ')': argStart = argStart.link argStart = argStart.previous argEnd = callArgs[i] while argEnd.str != ',' and argEnd.str != ')': if argEnd.str == '(': argEnd = argEnd.link argEnd = argEnd.next expression = '' argStart = argStart.next while argStart != argEnd: expression = expression + argStart.str argStart = argStart.next reportError(tok, 'debug', 'Bailout, unknown argument type for argument \'' + expression + '\'.', 'debug') continue if valueType.pointer > 0: continue if valueType.type != 'record' and valueType.type != 'container': continue reportError(tok, 'style', 'Passing record to ellipsis function \'' + tok.astOperand1.function.name + '\'.', 'ellipsisStructArg') break for arg in sys.argv[1:]: if arg in ['-debug', '-verify', '--cli']: continue print("Checking %s..." % arg) data = cppcheckdata.CppcheckData(arg) if VERIFY: VERIFY_ACTUAL = [] VERIFY_EXPECTED = [] for tok in data.rawTokens: if tok.str.startswith('//'): for word in tok.str[2:].split(' '): if word in ['stringConcatInArrayInit', 'implicitlyVirtual', 'ellipsisStructArg']: VERIFY_EXPECTED.append(str(tok.linenr) + ':' + word) stringConcatInArrayInit(data) implicitlyVirtual(data) ellipsisStructArg(data) if VERIFY: for expected in VERIFY_EXPECTED: if expected not in VERIFY_ACTUAL: print('Expected but not seen: ' + expected) sys.exit(1) for actual in VERIFY_ACTUAL: if actual not in VERIFY_EXPECTED: print('Not expected: ' + actual) sys.exit(1) sys.exit(cppcheckdata.EXIT_CODE) cppcheck-2.17.1/addons/misra.py000077500000000000000000006160141475760761100163500ustar00rootroot00000000000000#!/usr/bin/env python3 # # MISRA C 2012 checkers (including amendment 1 and 2) # # Example usage of this addon (scan a sourcefile main.cpp) # cppcheck --dump main.cpp # python misra.py --rule-texts= main.cpp.dump # # Limitations: This addon is released as open source. We are not allowed by # MISRA to distribute rule texts openly. # # The MISRA standard documents may be obtained from https://www.misra.org.uk # # Total number of rules: 143 from __future__ import print_function import cppcheckdata import itertools import json import sys import re import os import argparse import codecs import string import copy try: from itertools import izip as zip except ImportError: pass import misra_9 def grouped(iterable, n): """s -> (s0,s1,s2,...sn-1), (sn,sn+1,sn+2,...s2n-1), (s2n,s2n+1,s2n+2,...s3n-1), ...""" return zip(*[iter(iterable)] * n) INT_TYPES = ['bool', 'char', 'short', 'int', 'long', 'long long'] STDINT_TYPES = ['%s%d_t' % (n, v) for n, v in itertools.product( ['int', 'uint', 'int_least', 'uint_least', 'int_fast', 'uint_fast'], [8, 16, 32, 64])] typeBits = { 'CHAR': None, 'SHORT': None, 'INT': None, 'LONG': None, 'LONG_LONG': None, 'POINTER': None } def isUnsignedType(ty): return ty == 'unsigned' or ty.startswith('uint') def simpleMatch(token, pattern): return cppcheckdata.simpleMatch(token, pattern) def rawlink(rawtoken): if rawtoken.str == '}': indent = 0 while rawtoken: if rawtoken.str == '}': indent = indent + 1 elif rawtoken.str == '{': indent = indent - 1 if indent == 0: break rawtoken = rawtoken.previous else: rawtoken = None return rawtoken # Identifiers described in Section 7 "Library" of C90 Standard # Based on ISO/IEC9899:1990 Annex D -- Library summary and # Annex E -- Implementation limits. C90_STDLIB_IDENTIFIERS = { # D.1 Errors 'errno.h': ['EDOM', 'ERANGE', 'errno'], # D.2 Common definitions 'stddef.h': ['NULL', 'offsetof', 'ptrdiff_t', 'size_t', 'wchar_t'], # D.3 Diagnostics 'assert.h': ['NDEBUG', 'assert'], # D.4 Character handling 'ctype.h': [ 'isalnum', 'isalpha', 'isblank', 'iscntrl', 'isdigit', 'isgraph', 'islower', 'isprint', 'ispunct', 'isspace', 'isupper', 'isxdigit', 'tolower', 'toupper', ], # D.5 Localization 'locale.h': [ 'LC_ALL', 'LC_COLLATE', 'LC_CTYPE', 'LC_MONETARY', 'LC_NUMERIC', 'LC_TIME', 'NULL', 'lconv', 'setlocale', 'localeconv', ], # D.6 Mathematics 'math.h': [ 'HUGE_VAL', 'acos', 'asin' , 'atan2', 'cos', 'sin', 'tan', 'cosh', 'sinh', 'tanh', 'exp', 'frexp', 'ldexp', 'log', 'loglO', 'modf', 'pow', 'sqrt', 'ceil', 'fabs', 'floor', 'fmod', ], # D.7 Nonlocal jumps 'setjmp.h': ['jmp_buf', 'setjmp', 'longjmp'], # D.8 Signal handling 'signal.h': [ 'sig_atomic_t', 'SIG_DFL', 'SIG_ERR', 'SIG_IGN', 'SIGABRT', 'SIGFPE', 'SIGILL', 'SIGINT', 'SIGSEGV', 'SIGTERM', 'signal', 'raise', ], # D.9 Variable arguments 'stdarg.h': ['va_list', 'va_start', 'va_arg', 'va_end'], # D.10 Input/output 'stdio.h': [ '_IOFBF', '_IOLBF', '_IONBF', 'BUFSIZ', 'EOF', 'FILE', 'FILENAME_MAX', 'FOPEN_MAX', 'fpos_t', 'L_tmpnam', 'NULL', 'SEEK_CUR', 'SEEK_END', 'SEEK_SET', 'size_t', 'stderr', 'stdin', 'stdout', 'TMP_MAX', 'remove', 'rename', 'tmpfile', 'tmpnam', 'fclose', 'fflush', 'fopen', 'freopen', 'setbuf', 'setvbuf', 'fprintf', 'fscanf', 'printf', 'scanf', 'sprintf', 'sscanf', 'vfprintf', 'vprintf', 'vsprintf', 'fgetc', 'fgets', 'fputc', 'fputs', 'getc', 'getchar', 'gets', 'putc', 'putchar', 'puts', 'ungetc', 'fread', 'fwrite', 'fgetpos', 'fseek', 'fsetpos', 'rewind', 'clearerr', 'feof', 'ferror', 'perror', ], # D.11 General utilities 'stdlib.h': [ 'EXIT_FAILURE', 'EXIT_SUCCESS', 'MB_CUR_MAX', 'NULL', 'RAND_MAX', 'div_t', 'ldiv_t', 'wchar_t', 'atof', 'atoi', 'strtod', 'rand', 'srand', 'calloc', 'free', 'malloc', 'realloc', 'abort', 'atexit', 'exit', 'getenv', 'system', 'bsearch', 'qsort', 'abs', 'div', 'ldiv', 'mblen', 'mbtowc', 'wctomb', 'mbstowcs', 'wcstombs', ], # D.12 String handling 'string.h': [ 'NULL', 'size_t', 'memcpy', 'memmove', 'strcpy', 'strncpy', 'strcat', 'strncat', 'memcmp', 'strcmp', 'strcoll', 'strncmp', 'strxfrm', 'memchr', 'strchr', 'strcspn', 'strpbrk', 'strrchr', 'strspn', 'strstr', 'strtok', 'memset', 'strerror', 'strlen', ], # D.13 Date and time 'time.h': [ 'CLK_TCK', 'NULL', 'clock_t', 'time_t', 'size_t', 'tm', 'clock', 'difftime', 'mktime', 'time', 'asctime', 'ctime', 'gmtime', 'localtime', 'strftime', ], # Annex E: Implementation limits 'limits.h': [ 'CHAR_BIT', 'SCHAR_MIN', 'SCHAR_MAX', 'UCHAR_MAX', 'CHAR_MIN', 'CHAR_MAX', 'MB_LEN_MAX', 'SHRT_MIN', 'SHRT_MAX', 'USHRT_MAX', 'INT_MIN', 'INT_MAX', 'UINT_MAX', 'LONG_MIN', 'LONG_MAX', 'ULONG_MAX', ], 'float.h': [ 'FLT_ROUNDS', 'FLT_RADIX', 'FLT_MANT_DIG', 'DBL_MANT_DIG', 'LDBL_MANT_DIG', 'DECIMAL_DIG', 'FLT_DIG', 'DBL_DIG', 'LDBL_DIG', 'DBL_MIN_EXP', 'LDBL_MIN_EXP', 'FLT_MIN_10_EXP', 'DBL_MIN_10_EXP', 'LDBL_MIN_10_EXP', 'FLT_MAX_EXP', 'DBL_MAX_EXP', 'LDBL_MAX_EXP', 'FLT_MAX_10_EXP', 'DBL_MAX_10_EXP', 'LDBL_MAX_10_EXP', 'FLT_MAX', 'DBL_MAX', 'LDBL_MAX', 'FLT_MIN', 'DBL_MIN', 'LDBL_MIN', 'FLT_EPSILON', 'DBL_EPSILON', 'LDBL_EPSILON' ], } # Identifiers described in Section 7 "Library" of C99 Standard # Based on ISO/IEC 9899 WF14/N1256 Annex B -- Library summary C99_STDLIB_IDENTIFIERS = { # B.1 Diagnostics 'assert.h': C90_STDLIB_IDENTIFIERS['assert.h'], # B.2 Complex 'complex.h': [ 'complex', 'imaginary', 'I', '_Complex_I', '_Imaginary_I', 'CX_LIMITED_RANGE', 'cacos', 'cacosf', 'cacosl', 'casin', 'casinf', 'casinl', 'catan', 'catanf', 'catanl', 'ccos', 'ccosf', 'ccosl', 'csin', 'csinf', 'csinl', 'ctan', 'ctanf', 'ctanl', 'cacosh', 'cacoshf', 'cacoshl', 'casinh', 'casinhf', 'casinhl', 'catanh', 'catanhf', 'catanhl', 'ccosh', 'ccoshf', 'ccoshl', 'csinh', 'csinhf', 'csinhl', 'ctanh', 'ctanhf', 'ctanhl', 'cexp', 'cexpf', 'cexpl', 'clog', 'clogf', 'clogl', 'cabs', 'cabsf', 'cabsl', 'cpow', 'cpowf', 'cpowl', 'csqrt', 'csqrtf', 'csqrtl', 'carg', 'cargf', 'cargl', 'cimag', 'cimagf', 'cimagl', 'conj', 'conjf', 'conjl', 'cproj', 'cprojf', 'cprojl', 'creal', 'crealf', 'creall', ], # B.3 Character handling 'ctype.h': C90_STDLIB_IDENTIFIERS['ctype.h'], # B.4 Errors 'errno.h': C90_STDLIB_IDENTIFIERS['errno.h'] + ['EILSEQ'], # B.5 Floating-point environment 'fenv.h': [ 'fenv_t', 'FE_OVERFLOW', 'FE_TOWARDZERO', 'fexcept_t', 'FE_UNDERFLOW', 'FE_UPWARD', 'FE_DIVBYZERO', 'FE_ALL_EXCEPT', 'FE_DFL_ENV', 'FE_INEXACT', 'FE_DOWNWARD', 'FE_INVALID', 'FE_TONEAREST', 'FENV_ACCESS', 'feclearexcept', 'fegetexceptflag', 'fegetround', 'fesetround', 'fegetenv', 'feholdexcept', 'fesetenv', 'feupdateenv', ], # B.6 Characteristics of floating types 'float.h': C90_STDLIB_IDENTIFIERS['float.h'] + ['FLT_EVAL_METHOD'], # B.7 Format conversion of integer types 'inttypes.h': [ 'imaxdiv_t', 'imaxabs', 'imaxdiv', 'strtoimax', 'strtoumax', 'wcstoimax', 'wcstoumax', ], # B.8 Alternative spellings 'iso646.h': [ 'and', 'and_eq', 'bitand', 'bitor', 'compl', 'not', 'not_eq', 'or', 'or_eq', 'xor', 'xor_eq', ], # B.9 Size of integer types 'limits.h': C90_STDLIB_IDENTIFIERS['limits.h'] + ['LLONG_MIN', 'LLONG_MAX', 'ULLONG_MAX'], # B.10 Localization 'locale.h': C90_STDLIB_IDENTIFIERS['locale.h'], # B.11 Mathematics 'math.h': C90_STDLIB_IDENTIFIERS['math.h'] + [ 'float_t', 'double_t', 'HUGE_VAL', 'HUGE_VALF', 'HUGE_VALL', 'INFINITY', 'NAN', 'FP_INFINITE', 'FP_NAN', 'FP_NORMAL', 'FP_SUBNORMAL', 'FP_ZERO', 'FP_FAST_FMA', 'FP_FAST_FMAF', 'FP_FAST_FMAL', 'FP_ILOGB0', 'FP_ILOGBNAN', 'MATH_ERRNO', 'MATH_ERREXCEPT', 'math_errhandling', 'FP_CONTRACT', 'fpclassify', 'isfinite', 'isinf', 'isnan', 'isnormal', 'signbit', 'acosf', 'acosl', 'asinf', 'asinl', 'atanf', 'atanl', 'atan2', 'atan2f', 'atan2l', 'cosf', 'cosl', 'sinf', 'sinl', 'tanf', 'tanl', 'acosh', 'acoshf', 'acoshl', 'asinh', 'asinhf', 'asinhl', 'atanh', 'atanhf', 'atanhl', 'cosh', 'coshf', 'coshl', 'sinh', 'sinhf', 'sinhl', 'tanh', 'tanhf', 'tanhl', 'expf', 'expl', 'exp2', 'exp2f', 'exp2l', 'expm1', 'expm1f', 'expm1l', 'frexpf', 'frexpl', 'ilogb', 'ilogbf', 'ilogbl', 'float', 'ldexpl', 'logf', 'logl', 'log10f', 'log10l', 'log1p', 'log1pf', 'log1pl', 'log2', 'log2f', 'log2l', 'logb', 'logbf', 'logbl', 'modff', 'modfl', 'scalbn', 'scalbnf', 'scalbnl', 'scalbln', 'scalblnf', 'scalblnl', 'hypotl', 'powf', 'powl', 'sqrtf', 'sqrtl', 'erf', 'erff', 'erfl', 'erfc', 'erfcf', 'erfcl', 'lgamma', 'lgammaf', 'lgammal', 'tgamma', 'tgammaf', 'tgammal', 'ceilf', 'ceill', 'floorf', 'floorl', 'nearbyint', 'nearbyintf', 'nearbyintl', 'rint', 'rintf', 'rintl', 'lrint', 'lrintf', 'lrintl', 'llrint', 'llrintf', 'llrintl', 'round', 'roundf', 'roundl', 'lround', 'lroundf', 'lroundl', 'llround', 'llroundf', 'llroundl', 'trunc', 'truncf', 'truncl', 'fmodf', 'fmodl', 'remainder', 'remainderf', 'remainderl', 'remquo', 'remquof', 'remquol', 'copysign', 'copysignf', 'copysignl', 'nan', 'nanf', 'nanl', 'nextafter', 'nextafterf', 'nextafterl', 'nexttoward', 'nexttowardf', 'nexttowardl', 'fdim', 'fdimf', 'fdiml', 'fmax', 'fmaxf', 'fmaxl', 'fmin', 'fminf', 'fminl', 'fmal', 'isgreater', 'isgreaterequal', 'isless', 'islessequal', 'islessgreater', 'isunordered', ], # B.12 Nonlocal jumps 'setjmp.h': C90_STDLIB_IDENTIFIERS['setjmp.h'], # B.13 Signal handling 'signal.h': C90_STDLIB_IDENTIFIERS['signal.h'], # B.14 Variable arguments 'stdarg.h': C90_STDLIB_IDENTIFIERS['stdarg.h'] + ['va_copy'], # B.15 Boolean type and values 'stdbool.h': ['bool', 'true', 'false', '__bool_true_false_are_defined'], # B.16 Common definitions 'stddef.h': C90_STDLIB_IDENTIFIERS['stddef.h'], # B.17 Integer types 'stdint.h': [ 'intptr_t', 'uintptr_t', 'intmax_t', 'uintmax_t', 'INTN_MIN', 'INTN_MAX', 'UINTN_MAX', 'INT_LEASTN_MIN', 'INT_LEASTN_MAX', 'UINT_LEASTN_MAX', 'INT_FASTN_MIN', 'INT_FASTN_MAX', 'UINT_FASTN_MAX', 'INTPTR_MIN', 'INTPTR_MAX', 'UINTPTR_MAX', 'INTMAX_MIN', 'INTMAX_MAX', 'UINTMAX_MAX', 'PTRDIFF_MIN', 'PTRDIFF_MAX', 'SIG_ATOMIC_MIN', 'SIG_ATOMIC_MAX', 'SIZE_MAX', 'WCHAR_MIN', 'WCHAR_MAX', 'WINT_MIN', 'WINT_MAX', 'INTN_C', 'UINTN_C', 'INTMAX_C', 'UINTMAX_C', ] + STDINT_TYPES, # B.18 Input/output 'stdio.h': C90_STDLIB_IDENTIFIERS['stdio.h'] + [ 'mode', 'restrict', 'snprintf', 'vfscanf', 'vscanf', 'vsnprintf', 'vsscanf', ], # B.19 General utilities 'stdlib.h': C90_STDLIB_IDENTIFIERS['stdlib.h'] + [ '_Exit', 'labs', 'llabs', 'lldiv', 'lldiv_t', 'strtof', 'strtol', 'strtold', 'strtoll', 'strtoul', 'strtoull' ], # B.20 String handling 'string.h': C90_STDLIB_IDENTIFIERS['string.h'], # B.21 Type-generic math 'tgmath.h': [ 'acos', 'asin', 'atan', 'acosh', 'asinh', 'atanh', 'cos', 'sin', 'tan', 'cosh', 'sinh', 'tanh', 'exp', 'log', 'pow', 'sqrt', 'fabs', 'atan2', 'cbrt', 'ceil', 'copysign', 'erf', 'erfc', 'exp2', 'expm1', 'fdim', 'floor', 'fma', 'fmax', 'fmin', 'fmod', 'frexp', 'hypot', 'ilogb', 'ldexp', 'lgamma', 'llrint', 'llround', 'log10', 'log1p', 'log2', 'logb', 'lrint', 'lround', 'nearbyint', 'nextafter', 'nexttoward', 'remainder', 'remquo', 'rint', 'round', 'scalbn', 'scalbln', 'tgamma', 'trunc', 'carg', 'cimag', 'conj', 'cproj', 'creal', ], # B.22 Date and time 'time.h': C90_STDLIB_IDENTIFIERS['time.h'] + ['CLOCKS_PER_SEC'], # B.23 Extended multibyte/wide character utilities 'wchar.h': [ 'wchar_t', 'size_t', 'mbstate_t', 'wint_t', 'tm', 'NULL', 'WCHAR_MAX', 'WCHAR_MIN', 'WEOF', 'fwprintf', 'fwscanf', 'swprintf', 'swscanf', 'vfwprintf', 'vfwscanf', 'vswprintf', 'vswscanf', 'vwprintf', 'vwscanf', 'wprintf', 'wscanf', 'fgetwc', 'fgetws', 'fputwc', 'fputws', 'fwide', 'getwc', 'getwchar', 'putwc', 'putwchar', 'ungetwc', 'wcstod', 'wcstof', 'double', 'int', 'long', 'long', 'long', 'wcscpy', 'wcsncpy', 'wmemcpy', 'wmemmove', 'wcscat', 'wcsncat', 'wcscmp', 'wcscoll', 'wcsncmp', 'wcsxfrm', 'wmemcmp', 'wcschr', 'wcscspn', 'wcspbrk', 'wcsrchr', 'wcsspn', 'wcsstr', 'wcstok', 'wmemchr', 'wcslen', 'wmemset', 'wcsftime', 'btowc', 'wctob', 'mbsinit', 'mbrlen', 'mbrtowc', 'wcrtomb', 'mbsrtowcs', 'wcsrtombs', ], } def isStdLibId(id_, standard='c99'): id_lists = [] if standard == 'c89': id_lists = C90_STDLIB_IDENTIFIERS.values() elif standard in ('c99', 'c11'): id_lists = C99_STDLIB_IDENTIFIERS.values() for l in id_lists: if id_ in l: return True return False # Reserved keywords defined in ISO/IEC9899:1990 -- ch 6.1.1 C90_KEYWORDS = { 'auto', 'break', 'case', 'char', 'const', 'continue', 'default', 'do', 'double', 'else', 'enum', 'extern', 'float', 'for', 'goto', 'if', 'int', 'long', 'register', 'return', 'short', 'signed', 'sizeof', 'static', 'struct', 'switch', 'typedef', 'union', 'unsigned', 'void', 'volatile', 'while' } # Reserved keywords defined in ISO/IEC 9899 WF14/N1256 -- ch. 6.4.1 C99_ADDED_KEYWORDS = { 'inline', 'restrict', '_Bool', '_Complex', '_Imaginary', 'bool', 'complex', 'imaginary' } C11_ADDED_KEYWORDS = { '_Alignas', '_Alignof', '_Atomic', '_Generic', '_Noreturn', '_Statis_assert', '_Thread_local' , 'alignas', 'alignof', 'noreturn', 'static_assert' } def isKeyword(keyword, standard='c99'): kw_set = {} if standard == 'c89': kw_set = C90_KEYWORDS elif standard == 'c99': kw_set = copy.copy(C90_KEYWORDS) kw_set.update(C99_ADDED_KEYWORDS) else: kw_set = copy.copy(C90_KEYWORDS) kw_set.update(C99_ADDED_KEYWORDS) kw_set.update(C11_ADDED_KEYWORDS) return keyword in kw_set def is_source_file(file): return file.endswith('.c') def is_header(file): return file.endswith('.h') def is_errno_setting_function(function_name): return function_name and \ function_name in ('ftell', 'fgetpos', 'fsetpos', 'fgetwc', 'fputwc' 'strtoimax', 'strtoumax', 'strtol', 'strtoul', 'strtoll', 'strtoull', 'strtof', 'strtod', 'strtold' 'wcstoimax', 'wcstoumax', 'wcstol', 'wcstoul', 'wcstoll', 'wcstoull', 'wcstof', 'wcstod', 'wcstold' 'wcrtomb', 'wcsrtombs', 'mbrtowc') def get_type_conversion_to_from(token): def get_vartok(expr): while expr: if isCast(expr): if expr.astOperand2 is None: expr = expr.astOperand1 else: expr = expr.astOperand2 elif expr.str in ('.', '::'): expr = expr.astOperand2 elif expr.str == '[': expr = expr.astOperand1 else: break return expr if (expr and expr.variable) else None if isCast(token): vartok = get_vartok(token) if vartok: return (token.next, vartok.variable.typeStartToken) elif token.str == '=': lhs = get_vartok(token.astOperand1) rhs = get_vartok(token.astOperand2) if lhs and rhs: return (lhs.variable.typeStartToken, rhs.variable.typeStartToken) return None def is_composite_expr(expr, composite_operator=False): """MISRA C 2012, section 8.10.3""" if expr is None: return False if not composite_operator: if expr.str == '?' and simpleMatch(expr.astOperand2, ':'): colon = expr.astOperand2 return is_composite_expr(colon.astOperand1,True) or is_composite_expr(colon.astOperand2, True) if (expr.str in ('+', '-', '*', '/', '%', '&', '|', '^', '>>', "<<", "?", ":", '~')): return is_composite_expr(expr.astOperand1,True) or is_composite_expr(expr.astOperand2, True) return False # non constant expression? if expr.isNumber: return False if expr.astOperand1 or expr.astOperand2: return is_composite_expr(expr.astOperand1,True) or is_composite_expr(expr.astOperand2, True) return True def getEssentialTypeCategory(expr): if not expr: return None if expr.str == ',': return getEssentialTypeCategory(expr.astOperand2) if expr.str in ('<', '<=', '==', '!=', '>=', '>', '&&', '||', '!'): return 'bool' if expr.str in ('<<', '>>'): # TODO this is incomplete return getEssentialTypeCategory(expr.astOperand1) if len(expr.str) == 1 and expr.str in '+-*/%&|^': # TODO this is incomplete e1 = getEssentialTypeCategory(expr.astOperand1) e2 = getEssentialTypeCategory(expr.astOperand2) # print('{0}: {1} {2}'.format(expr.str, e1, e2)) if e1 and e2 and e1 == e2: return e1 if expr.valueType: return expr.valueType.sign if expr.valueType and expr.valueType.typeScope and expr.valueType.typeScope.className: return "enum<" + expr.valueType.typeScope.className + ">" # Unwrap membership, dereferences and array indexing vartok = expr while True: if simpleMatch(vartok, '[') or (vartok and vartok.str == '*' and vartok.astOperand2 is None): vartok = vartok.astOperand1 elif simpleMatch(vartok, '.'): vartok = vartok.astOperand2 else: break if vartok and vartok.variable: typeToken = vartok.variable.typeStartToken while typeToken and typeToken.isName: if typeToken.str == 'char' and not typeToken.isSigned and not typeToken.isUnsigned: return 'char' if typeToken.valueType: if typeToken.valueType.type == 'bool': return typeToken.valueType.type if typeToken.valueType.type in ('float', 'double', 'long double'): return "float" if typeToken.valueType.sign: return typeToken.valueType.sign typeToken = typeToken.next # See Appendix D, section D.6, Character constants if expr.str[0] == "'" and expr.str[-1] == "'": if len(expr.str) == 3 or (len(expr.str) == 4 and expr.str[1] == '\\'): return 'char' return expr.valueType.sign if (expr.isCast and expr.str == "("): castTok = expr.next while castTok.isName or castTok.str == "*": if castTok.str == 'char' and not castTok.isSigned and not castTok.isUnsigned: return 'char' castTok = castTok.next if expr.valueType: return expr.valueType.sign return None def getEssentialCategorylist(operand1, operand2): if not operand1 or not operand2: return None, None if (operand1.str in ('++', '--') or operand2.str in ('++', '--')): return None, None if ((operand1.valueType and operand1.valueType.pointer) or (operand2.valueType and operand2.valueType.pointer)): return None, None e1 = getEssentialTypeCategory(operand1) e2 = getEssentialTypeCategory(operand2) return e1, e2 def get_essential_type_from_value(value, is_signed): if value is None: return None for t in ('char', 'short', 'int', 'long', 'long long'): bits = bitsOfEssentialType(t) if bits >= 64: continue if is_signed: range_min = -(1 << (bits - 1)) range_max = (1 << (bits - 1)) - 1 else: range_min = 0 range_max = (1 << bits) - 1 sign = 'signed' if is_signed else 'unsigned' if is_signed and value < 0 and value >= range_min: return '%s %s' % (sign, t) if value >= 0 and value <= range_max: return '%s %s' % (sign, t) return None def getEssentialType(expr): if not expr: return None # See Appendix D, section D.6, Character constants if expr.str[0] == "'" and expr.str[-1] == "'": if len(expr.str) == 3 or (len(expr.str) == 4 and expr.str[1] == '\\'): return 'char' return '%s %s' % (expr.valueType.sign, expr.valueType.type) if expr.variable or isCast(expr): typeToken = expr.variable.typeStartToken if expr.variable else expr.next while typeToken and typeToken.isName: if typeToken.str == 'char' and not typeToken.isSigned and not typeToken.isUnsigned: return 'char' typeToken = typeToken.next if expr.valueType: if expr.valueType.type == 'bool': return 'bool' if expr.valueType.isFloat(): return expr.valueType.type if expr.valueType.isIntegral(): if (expr.valueType.sign is None) and expr.valueType.type == 'char': return 'char' return '%s %s' % (expr.valueType.sign, expr.valueType.type) elif expr.isNumber: # Appendix D, D.6 The essential type of literal constants # Integer constants if expr.valueType.type == 'bool': return 'bool' if expr.valueType.isFloat(): return expr.valueType.type if expr.valueType.isIntegral(): if expr.valueType.type != 'int': return '%s %s' % (expr.valueType.sign, expr.valueType.type) return get_essential_type_from_value(expr.getKnownIntValue(), expr.valueType.sign == 'signed') elif expr.str in ('<', '<=', '>=', '>', '==', '!=', '&&', '||', '!'): return 'bool' elif expr.astOperand1 and expr.astOperand2 and expr.str in ( '+', '-', '*', '/', '%', '&', '|', '^', '>>', "<<", "?", ":"): if expr.astOperand1.valueType and expr.astOperand1.valueType.pointer > 0: return None if expr.astOperand2.valueType and expr.astOperand2.valueType.pointer > 0: return None e1 = getEssentialType(expr.astOperand1) e2 = getEssentialType(expr.astOperand2) if e1 is None or e2 is None: return None if is_constant_integer_expression(expr): sign1 = e1.split(' ')[0] sign2 = e2.split(' ')[0] if sign1 == sign2 and sign1 in ('signed', 'unsigned'): e = get_essential_type_from_value(expr.getKnownIntValue(), sign1 == 'signed') if e: return e if bitsOfEssentialType(e2) >= bitsOfEssentialType(e1): return e2 return e1 elif expr.str == "~": e1 = getEssentialType(expr.astOperand1) return e1 return None def bitsOfEssentialType(ty): if ty is None: return 0 last_type = ty.split(' ')[-1] if last_type == 'Boolean': return 1 if last_type == 'char': return typeBits['CHAR'] if last_type == 'short': return typeBits['SHORT'] if last_type == 'int': return typeBits['INT'] if ty.endswith('long long'): return typeBits['LONG_LONG'] if last_type == 'long': return typeBits['LONG'] for sty in STDINT_TYPES: if ty == sty: return int(''.join(filter(str.isdigit, sty))) return 0 def get_function_pointer_type(tok): ret = '' while tok and (tok.isName or tok.str == '*'): ret += ' ' + tok.str tok = tok.next if tok is None or tok.str != '(': return None tok = tok.link if not simpleMatch(tok, ') ('): return None ret += '(' tok = tok.next.next while tok and (tok.str not in '()'): if tok.varId is None: ret += ' ' + tok.str tok = tok.next if (tok is None) or tok.str != ')': return None return ret[1:] + ')' def isCast(expr): if not expr or expr.str != '(' or not expr.astOperand1 or expr.astOperand2: return False if simpleMatch(expr, '( )'): return False return True def is_constant_integer_expression(expr): if expr is None: return False if expr.isInt: return True if not expr.isArithmeticalOp: return False if expr.astOperand1 and not is_constant_integer_expression(expr.astOperand1): return False if expr.astOperand2 and not is_constant_integer_expression(expr.astOperand2): return False return True def isFunctionCall(expr, std='c99'): if not expr: return False if expr.str != '(' or not expr.astOperand1: return False if expr.astOperand1 != expr.previous: return False if isKeyword(expr.astOperand1.str, std): return False return True def hasExternalLinkage(var): return var.isGlobal and not var.isStatic def countSideEffects(expr): if not expr or expr.str in (',', ';'): return 0 ret = 0 if expr.str in ('++', '--', '='): ret = 1 return ret + countSideEffects(expr.astOperand1) + countSideEffects(expr.astOperand2) def getForLoopExpressions(forToken): if not forToken or forToken.str != 'for': return None lpar = forToken.next if not lpar or lpar.str != '(': return None if not lpar.astOperand2 or lpar.astOperand2.str != ';': return None if not lpar.astOperand2.astOperand2 or lpar.astOperand2.astOperand2.str != ';': return None return [lpar.astOperand2.astOperand1, lpar.astOperand2.astOperand2.astOperand1, lpar.astOperand2.astOperand2.astOperand2] def get_function_scope(cfg, func): if func: for scope in cfg.scopes: if scope.function == func: return scope return None def is_variable_changed(start_token, end_token, var): """Check if variable is updated between body_start and body_end""" tok = start_token while tok != end_token: if tok.isAssignmentOp: vartok = tok.astOperand1 while vartok.astOperand1: vartok = vartok.astOperand1 if vartok and vartok.variable == var: return True tok = tok.next return False def getForLoopCounterVariables(forToken, cfg): """ Return a set of Variable objects defined in ``for`` statement and satisfy requirements to loop counter term from section 8.14 of MISRA document. """ if not forToken or forToken.str != 'for': return None tn = forToken.next if not tn or tn.str != '(': return None vars_defined = set() vars_initialized = set() vars_exit = set() vars_modified = set() cur_clause = 1 te = tn.link while tn and tn != te: if tn.variable: if cur_clause == 1 and tn.variable.nameToken == tn: vars_defined.add(tn.variable) elif cur_clause == 2: vars_exit.add(tn.variable) elif cur_clause == 3: if tn.next and countSideEffectsRecursive(tn.next) > 0: vars_modified.add(tn.variable) elif tn.previous and tn.previous.str in ('++', '--'): tn_ast = tn.astParent if tn_ast and tn_ast == tn.previous: vars_modified.add(tn.variable) elif tn_ast and tn_ast.str == '.' and tn_ast.astOperand2 and tn_ast.astOperand2.variable: vars_modified.add(tn_ast.astOperand2.variable) if cur_clause == 1 and tn.isAssignmentOp: var_token = tn.astOperand1 while var_token and var_token.str == '.': var_token = var_token.astOperand2 if var_token and var_token.variable: vars_initialized.add(var_token.variable) if cur_clause == 1 and tn.isName and tn.next.str == '(': function_args_in_init = getArguments(tn.next) function_scope = get_function_scope(cfg, tn.function) for arg_nr in range(len(function_args_in_init)): init_arg = function_args_in_init[arg_nr] if init_arg is None or not init_arg.isUnaryOp('&'): continue var_token = init_arg.astOperand1 while var_token and var_token.str == '.': var_token = var_token.astOperand2 if var_token is None or var_token.variable is None: continue changed = False if function_scope is None: changed = True elif tn.function is None: changed = True else: function_body_start = function_scope.bodyStart function_body_end = function_scope.bodyEnd args = tn.function.argument[arg_nr + 1] if function_scope is None or is_variable_changed(function_body_start, function_body_end, args): changed = True if changed: vars_initialized.add(var_token.variable) if tn.str == ';': cur_clause += 1 tn = tn.next return vars_defined | vars_initialized, vars_exit & vars_modified def findCounterTokens(cond): if not cond: return [] if cond.str in ['&&', '||']: c = findCounterTokens(cond.astOperand1) c.extend(findCounterTokens(cond.astOperand2)) return c ret = [] if ((cond.isArithmeticalOp and cond.astOperand1 and cond.astOperand2) or (cond.isComparisonOp and cond.astOperand1 and cond.astOperand2)): if cond.astOperand1.isName: ret.append(cond.astOperand1) if cond.astOperand2.isName: ret.append(cond.astOperand2) if cond.astOperand1.isOp: ret.extend(findCounterTokens(cond.astOperand1)) if cond.astOperand2.isOp: ret.extend(findCounterTokens(cond.astOperand2)) return ret def isFloatCounterInWhileLoop(whileToken): if not simpleMatch(whileToken, 'while ('): return False lpar = whileToken.next rpar = lpar.link counterTokens = findCounterTokens(lpar.astOperand2) tok_varid = tuple(tok.varId for tok in counterTokens if tok.varId) whileBodyStart = None if simpleMatch(rpar, ') {'): whileBodyStart = rpar.next elif simpleMatch(whileToken.previous, '} while') and simpleMatch(whileToken.previous.link.previous, 'do {'): whileBodyStart = whileToken.previous.link else: return False token = whileBodyStart while token != whileBodyStart.link: token = token.next if not token.varId: continue if token.varId not in tok_varid: continue if not token.astParent or not token.valueType or not token.valueType.isFloat(): continue parent = token.astParent if parent.str in ('++', '--'): return True while parent: if parent.isAssignmentOp and parent.str != "=" and parent.astOperand1 == token: return True if parent.str == "=" and parent.astOperand1.str == token.str and parent.astOperand1 != token: return True parent = parent.astParent return False def countSideEffectsRecursive(expr): if not expr or expr.str == ';': return 0 if expr.str == '=' and expr.astOperand1 and expr.astOperand1.str == '[': prev = expr.astOperand1.previous if prev and (prev.str == '{' or prev.str == '{'): return countSideEffectsRecursive(expr.astOperand2) if expr.str == '=' and expr.astOperand1 and expr.astOperand1.str == '.': e = expr.astOperand1 while e and e.str == '.' and e.astOperand2: e = e.astOperand1 if e and e.str == '.': return 0 if expr.isAssignmentOp or expr.str in {'++', '--'}: return 1 # Todo: Check function calls return countSideEffectsRecursive(expr.astOperand1) + countSideEffectsRecursive(expr.astOperand2) def isBoolExpression(expr): if not expr: return False if expr.valueType and (expr.valueType.type == 'bool' or expr.valueType.bits == 1): return True return expr.str in ['!', '==', '!=', '<', '<=', '>', '>=', '&&', '||', '0', '1', 'true', 'false'] def isEnumConstant(expr): if not expr or not expr.values: return False values = expr.values return len(values) == 1 and values[0].valueKind == 'known' def isConstantExpression(expr): if expr.isNumber: return True if expr.isName and not isEnumConstant(expr): return False if simpleMatch(expr.previous, 'sizeof ('): return True if expr.astOperand1 and not isConstantExpression(expr.astOperand1): return False if expr.astOperand2 and not isConstantExpression(expr.astOperand2): return False return True def isUnknownConstantExpression(expr): if expr.isName and not isEnumConstant(expr) and expr.variable is None: return True if expr.astOperand1 and isUnknownConstantExpression(expr.astOperand1): return True if expr.astOperand2 and isUnknownConstantExpression(expr.astOperand2): return True return False def isUnsignedInt(expr): return expr and expr.valueType and expr.valueType.type in ('short', 'int') and expr.valueType.sign == 'unsigned' def getPrecedence(expr): if not expr: return 16 if not expr.astOperand1 or not expr.astOperand2: return 16 if expr.str in ('*', '/', '%'): return 12 if expr.str in ('+', '-'): return 11 if expr.str in ('<<', '>>'): return 10 if expr.str in ('<', '>', '<=', '>='): return 9 if expr.str in ('==', '!='): return 8 if expr.str == '&': return 7 if expr.str == '^': return 6 if expr.str == '|': return 5 if expr.str == '&&': return 4 if expr.str == '||': return 3 if expr.str in ('?', ':'): return 2 if expr.isAssignmentOp: return 1 if expr.str == ',': return 0 return -1 def findRawLink(token): tok1 = None tok2 = None forward = False if token.str in '{([': tok1 = token.str tok2 = '})]'['{(['.find(token.str)] forward = True elif token.str in '})]': tok1 = token.str tok2 = '{(['['})]'.find(token.str)] forward = False else: return None # try to find link indent = 0 while token: if token.str == tok1: indent = indent + 1 elif token.str == tok2: if indent <= 1: return token indent = indent - 1 if forward is True: token = token.next else: token = token.previous # raw link not found return None def numberOfParentheses(tok1, tok2): while tok1 and tok1 != tok2: if tok1.str == '(' or tok1.str == ')': return False tok1 = tok1.next return tok1 == tok2 def findGotoLabel(gotoToken): label = gotoToken.next.str tok = gotoToken.next.next while tok: if tok.str == '}' and tok.scope.type == 'Function': break if tok.str == label and tok.next.str == ':': return tok tok = tok.next return None def findInclude(directives, header): for directive in directives: if directive.str == '#include ' + header: return directive return None # Get function arguments def getArgumentsRecursive(tok, arguments): if tok is None: return if tok.str == ',': getArgumentsRecursive(tok.astOperand1, arguments) getArgumentsRecursive(tok.astOperand2, arguments) else: arguments.append(tok) def getArguments(ftok): arguments = [] getArgumentsRecursive(ftok.astOperand2, arguments) return arguments def isalnum(c): return c in string.digits or c in string.ascii_letters def isHexEscapeSequence(symbols): """Checks that given symbols are valid hex escape sequence. hexadecimal-escape-sequence: \\x hexadecimal-digit hexadecimal-escape-sequence hexadecimal-digit Reference: n1570 6.4.4.4""" if len(symbols) < 3 or symbols[:2] != '\\x': return False return all([s in string.hexdigits for s in symbols[2:]]) def isOctalEscapeSequence(symbols): r"""Checks that given symbols are valid octal escape sequence: octal-escape-sequence: \ octal-digit \ octal-digit octal-digit \ octal-digit octal-digit octal-digit Reference: n1570 6.4.4.4""" if len(symbols) not in range(2, 5) or symbols[0] != '\\': return False return all([s in string.octdigits for s in symbols[1:]]) def isSimpleEscapeSequence(symbols): """Checks that given symbols are simple escape sequence. Reference: n1570 6.4.4.4""" if len(symbols) != 2 or symbols[0] != '\\': return False return symbols[1] in ("'", '"', '?', '\\', 'a', 'b', 'f', 'n', 'r', 't', 'v') def isTernaryOperator(token): if not token: return False if not token.astOperand2: return False return token.str == '?' and token.astOperand2.str == ':' def getTernaryOperandsRecursive(token): """Returns list of ternary operands including nested ones.""" if not isTernaryOperator(token): return [] result = [] result += getTernaryOperandsRecursive(token.astOperand2.astOperand1) if token.astOperand2.astOperand1 and not isTernaryOperator(token.astOperand2.astOperand1): result += [token.astOperand2.astOperand1] result += getTernaryOperandsRecursive(token.astOperand2.astOperand2) if token.astOperand2.astOperand2 and not isTernaryOperator(token.astOperand2.astOperand2): result += [token.astOperand2.astOperand2] return result def hasNumericEscapeSequence(symbols): """Check that given string contains octal or hexadecimal escape sequences.""" if '\\' not in symbols: return False for c, cn in grouped(symbols, 2): if c == '\\' and cn in ('x' + string.octdigits): return True return False def isNoReturnScope(tok): if tok is None or tok.str != '}': return False if tok.previous is None or tok.previous.str != ';': return False if simpleMatch(tok.previous.previous, 'break ;'): return True prev = tok.previous.previous while prev and prev.str not in ';{}': if prev.str in '])': prev = prev.link prev = prev.previous if prev and prev.next.str in ['throw', 'return']: return True return False # Return the token which the value is assigned to def getAssignedVariableToken(vartok): if not vartok: return None parent = vartok.astParent while parent and parent.isArithmeticalOp: parent = parent.astParent if parent and parent.isAssignmentOp: return parent.astOperand1 return None # If the value is used as a return value, return the function definition def getFunctionUsingReturnValue(valueToken): if not valueToken: return None if not valueToken.astParent: return None operator = valueToken.astParent if operator.str == 'return': return operator.scope.function if operator.isArithmeticalOp: return getFunctionUsingReturnValue(operator) return None # Return true if the token follows a specific sequence of token str values def tokenFollowsSequence(token, sequence): if not token: return False for i in reversed(sequence): prev = token.previous if not prev: return False if prev.str != i: return False token = prev return True class Define: def __init__(self, directive): self.name = '' self.args = [] self.expansionList = '' res = re.match(r'#define ([A-Za-z0-9_]+)\(([A-Za-z0-9_, ]+)\)[ ]+(.*)', directive.str) if res: self.name = res.group(1) self.args = res.group(2).strip().split(',') self.expansionList = res.group(3) else: res = re.match(r'#define ([A-Za-z0-9_]+)[ ]+(.*)', directive.str) if res: self.name = res.group(1) self.expansionList = res.group(2) def __repr__(self): attrs = ["name", "args", "expansionList"] return "{}({})".format( "Define", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def getAddonRules(): """Returns dict of MISRA rules handled by this addon.""" addon_rules = [] compiled = re.compile(r'.*def[ ]+misra_([0-9]+)_([0-9]+)[(].*') with open(__file__) as f: for line in f: res = compiled.match(line) if res is None: continue addon_rules.append(res.group(1) + '.' + res.group(2)) return addon_rules def getCppcheckRules(): """Returns list of rules handled by cppcheck.""" return ['1.3', # '2.1', # alwaysFalse, duplicateBreak '2.2', # alwaysTrue, redundantCondition, redundantAssignment, redundantAssignInSwitch, unreadVariable '2.6', # unusedLabel '5.3', # shadowVariable '8.3', # funcArgNamesDifferent '8.13', # constPointer '9.1', # uninitvar '14.3', # alwaysTrue, alwaysFalse, compareValueOutOfTypeRangeError '13.2', # unknownEvaluationOrder '13.6', # sizeofCalculation '17.4', # missingReturn '17.5', # argumentSize '18.1', # pointerOutOfBounds '18.2', # comparePointers '18.3', # comparePointers '18.6', # danglingLifetime '19.1', # overlappingWriteUnion, overlappingWriteFunction '20.6', # preprocessorErrorDirective '21.13', # invalidFunctionArg '21.17', # bufferAccessOutOfBounds '21.18', # bufferAccessOutOfBounds '22.1', # memleak, resourceLeak, memleakOnRealloc, leakReturnValNotUsed, leakNoVarFunctionCall '22.2', # autovarInvalidDeallocation '22.3', # incompatibleFileOpen '22.4', # writeReadOnlyFile '22.6' # useClosedFile ] def generateTable(): # print table numberOfRules = {} numberOfRules[1] = 3 numberOfRules[2] = 7 numberOfRules[3] = 2 numberOfRules[4] = 2 numberOfRules[5] = 9 numberOfRules[6] = 2 numberOfRules[7] = 4 numberOfRules[8] = 14 numberOfRules[9] = 5 numberOfRules[10] = 8 numberOfRules[11] = 9 numberOfRules[12] = 4 numberOfRules[13] = 6 numberOfRules[14] = 4 numberOfRules[15] = 7 numberOfRules[16] = 7 numberOfRules[17] = 8 numberOfRules[18] = 8 numberOfRules[19] = 2 numberOfRules[20] = 14 numberOfRules[21] = 21 numberOfRules[22] = 10 # Rules that can be checked with compilers: # compiler = ['1.1', '1.2'] addon = getAddonRules() cppcheck = getCppcheckRules() for i1 in range(1, 23): for i2 in range(1, numberOfRules[i1] + 1): num = str(i1) + '.' + str(i2) s = '' if num in addon: s = 'X (Addon)' elif num in cppcheck: s = 'X (Cppcheck)' num = num + ' ' print(num[:8] + s) def remove_file_prefix(file_path, prefix): """ Remove a file path prefix from a give path. leftover directory separators at the beginning of a file after the removal are also stripped. Example: '/remove/this/path/file.c' with a prefix of: '/remove/this/path' becomes: file.c """ result = None if file_path.startswith(prefix): result = file_path[len(prefix):] # Remove any leftover directory separators at the # beginning result = result.lstrip('\\/') else: result = file_path return result class Rule(): """Class to keep rule text and metadata""" MISRA_SEVERITY_LEVELS = ['Required', 'Mandatory', 'Advisory'] def __init__(self, num1, num2): self.num1 = num1 self.num2 = num2 self.text = '' self.misra_severity = '' @property def num(self): return self.num1 * 100 + self.num2 @property def misra_severity(self): return self._misra_severity @misra_severity.setter def misra_severity(self, val): if val in self.MISRA_SEVERITY_LEVELS: self._misra_severity = val else: self._misra_severity = '' @property def cppcheck_severity(self): return 'style' def __repr__(self): return "%d.%d (%s)" % (self.num1, self.num2, self.misra_severity) class MisraSettings(): """Hold settings for misra.py script.""" __slots__ = ["verify", "quiet", "show_summary"] def __init__(self, args): """ :param args: Arguments given by argparse. """ self.verify = False self.quiet = False self.show_summary = True if args.verify: self.verify = True if args.cli: self.quiet = True self.show_summary = False if args.quiet: self.quiet = True if args.no_summary: self.show_summary = False def __repr__(self): attrs = ["verify", "quiet", "show_summary", "verify"] return "{}({})".format( "MisraSettings", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class MisraChecker: def __init__(self, settings, stdversion="c89"): """ :param settings: misra.py script settings. """ self.settings = settings # Test validation rules lists self.verify_expected = [] self.verify_actual = [] # List of formatted violation messages self.violations = {} # if --rule-texts is specified this dictionary # is loaded with descriptions of each rule # by rule number (in hundreds). # ie rule 1.2 becomes 102 self.ruleTexts = {} self.ruleText_filename = None # Dictionary of dictionaries for rules to suppress # Dict1 is keyed by rule number in the hundreds format of # Major * 100 + minor. ie Rule 5.2 = (5*100) + 2 # Dict 2 is keyed by filename. An entry of None means suppress globally. # Each file name entry contains a list of tuples of (lineNumber, symbolName) # or an item of None which indicates suppress rule for the entire file. # The line and symbol name tuple may have None as either of its elements but # should not be None for both. self.suppressedRules = {} # Prefix to ignore when matching suppression files. self.filePrefix = None # Number of all violations suppressed per rule self.suppressionStats = {} self.stdversion = stdversion self.severity = None self.existing_violations = set() self._ctu_summary_typedefs = False self._ctu_summary_tagnames = False self._ctu_summary_identifiers = False self._ctu_summary_usage = False self.path_premium_addon = None def __repr__(self): attrs = ["settings", "verify_expected", "verify_actual", "violations", "ruleTexts", "suppressedRules", "filePrefix", "suppressionStats", "stdversion", "severity"] return "{}({})".format( "MisraChecker", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def get_num_significant_naming_chars(self, cfg): if cfg.standards and cfg.standards.c == "c89": return 31 return 63 def _save_ctu_summary_typedefs(self, dumpfile, typedef_info): if self._ctu_summary_typedefs: return self._ctu_summary_typedefs = True summary = [] for ti in typedef_info: summary.append({ 'name': ti.name, 'file': ti.file, 'line': ti.linenr, 'column': ti.column, 'used': ti.used }) if len(summary) > 0: cppcheckdata.reportSummary(dumpfile, 'MisraTypedefInfo', summary) def _save_ctu_summary_tagnames(self, dumpfile, cfg): if self._ctu_summary_tagnames: return self._ctu_summary_tagnames = True summary = [] # structs/enums for scope in cfg.scopes: if scope.className is None: continue if scope.className.startswith('Anonymous'): continue if scope.type not in ('Struct', 'Enum'): continue used = False tok = scope.bodyEnd while tok: if tok.str == scope.className: used = True break tok = tok.next summary.append({'name': scope.className, 'used':used, 'file': scope.bodyStart.file, 'line': scope.bodyStart.linenr, 'column': scope.bodyStart.column}) if len(summary) > 0: cppcheckdata.reportSummary(dumpfile, 'MisraTagName', summary) def _save_ctu_summary_identifiers(self, dumpfile, cfg): if self._ctu_summary_identifiers: return self._ctu_summary_identifiers = True external_identifiers = [] internal_identifiers = [] local_identifiers = [] def identifier(nameToken): return {'name':nameToken.str, 'file':nameToken.file, 'line':nameToken.linenr, 'column':nameToken.column} names = [] for var in cfg.variables: if var.nameToken is None: continue if var.access != 'Global': if var.nameToken.str in names: continue names.append(var.nameToken.str) local_identifiers.append(identifier(var.nameToken)) elif var.isStatic: names.append(var.nameToken.str) i = identifier(var.nameToken) i['inlinefunc'] = False internal_identifiers.append(i) else: names.append(var.nameToken.str) i = identifier(var.nameToken) i['decl'] = var.isExtern external_identifiers.append(i) for func in cfg.functions: if func.tokenDef is None: continue if func.isStatic: i = identifier(func.tokenDef) i['inlinefunc'] = func.isInlineKeyword internal_identifiers.append(i) else: if func.token is None: i = identifier(func.tokenDef) else: i = identifier(func.token) i['decl'] = func.token is None external_identifiers.append(i) cppcheckdata.reportSummary(dumpfile, 'MisraExternalIdentifiers', external_identifiers) cppcheckdata.reportSummary(dumpfile, 'MisraInternalIdentifiers', internal_identifiers) cppcheckdata.reportSummary(dumpfile, 'MisraLocalIdentifiers', local_identifiers) def _save_ctu_summary_usage(self, dumpfile, cfg): if self._ctu_summary_usage: return self._ctu_summary_usage = True names = [] for token in cfg.tokenlist: if not token.isName: continue if token.function and token != token.function.tokenDef: if (not token.function.isStatic) and (token.str not in names): names.append({'name': token.str, 'file': token.file}) elif token.variable: if token == token.variable.nameToken: continue if token.variable.access == 'Global' and (not token.variable.isStatic) and (token.str not in names): names.append({'name': token.str, 'file': token.file}) if len(names) > 0: 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'): self.reportError(token, 1, 4) if token.str.endswith('_s') and isFunctionCall(token.next): # See C specification C11 - Annex K, page 578 if token.str in ('tmpfile_s', 'tmpnam_s', 'fopen_s', 'freopen_s', 'fprintf_s', 'fscanf_s', 'printf_s', 'scanf_s', 'snprintf_s', 'sprintf_s', 'sscanf_s', 'vfprintf_s', 'vfscanf_s', 'vprintf_s', 'vscanf_s', 'vsnprintf_s', 'vsprintf_s', 'vsscanf_s', 'gets_s', 'set_constraint_handler_s', 'abort_handler_s', 'ignore_handler_s', 'getenv_s', 'bsearch_s', 'qsort_s', 'wctomb_s', 'mbstowcs_s', 'wcstombs_s', 'memcpy_s', 'memmove_s', 'strcpy_s', 'strncpy_s', 'strcat_s', 'strncat_s', 'strtok_s', 'memset_s', 'strerror_s', 'strerrorlen_s', 'strnlen_s', 'asctime_s', 'ctime_s', 'gmtime_s', 'localtime_s', 'fwprintf_s', 'fwscanf_s', 'snwprintf_s', 'swprintf_s', 'swscanf_s', 'vfwprintf_s', 'vfwscanf_s', 'vsnwprintf_s', 'vswprintf_s', 'vswscanf_s', 'vwprintf_s', 'vwscanf_s', 'wprintf_s', 'wscanf_s', 'wcscpy_s', 'wcsncpy_s', 'wmemcpy_s', 'wmemmove_s', 'wcscat_s', 'wcsncat_s', 'wcstok_s', 'wcsnlen_s', 'wcrtomb_s', 'mbsrtowcs_s', 'wcsrtombs_s'): self.reportError(token, 1, 4) def misra_2_2(self, cfg): for token in cfg.tokenlist: if token.isExpandedMacro: continue if (token.str in '+-') and token.astOperand2: if simpleMatch(token.astOperand1, '0'): self.reportError(token.astOperand1, 2, 2) elif simpleMatch(token.astOperand2, '0'): self.reportError(token.astOperand2, 2, 2) if token.str == '*' and token.astOperand2: if simpleMatch(token.astOperand2, '0'): self.reportError(token.astOperand1, 2, 2) elif simpleMatch(token.astOperand1, '0'): self.reportError(token.astOperand2, 2, 2) elif simpleMatch(token.astOperand1, '1'): self.reportError(token.astOperand1, 2, 2) elif simpleMatch(token.astOperand2, '1'): self.reportError(token.astOperand2, 2, 2) def misra_2_3(self, dumpfile, typedefInfo): self._save_ctu_summary_typedefs(dumpfile, typedefInfo) def misra_2_4(self, dumpfile, cfg): self._save_ctu_summary_tagnames(dumpfile, cfg) def misra_2_5(self, dumpfile, cfg): used_macros = [] unused_macro = {} for m in cfg.macro_usage: used_macros.append(m.name) for directive in cfg.directives: res_define = re.match(r'#define[ \t]+([a-zA-Z_][a-zA-Z_0-9]*).*', directive.str) res_undef = re.match(r'#undef[ \t]+([a-zA-Z_][a-zA-Z_0-9]*).*', directive.str) if res_define: macro_name = res_define.group(1) unused_macro[macro_name] = {'name': macro_name, 'used': (macro_name in used_macros), 'file': directive.file, 'line': directive.linenr, 'column': directive.column} elif res_undef: macro_name = res_undef.group(1) # assuming that if we have #undef, we also have #define somewhere if macro_name in unused_macro: unused_macro[macro_name]['used'] = True else: unused_macro[macro_name] = {'name': macro_name, 'used': True, 'file': directive.file, 'line': directive.linenr, 'column': directive.column} used_macros.append(macro_name) if unused_macro: cppcheckdata.reportSummary(dumpfile, 'MisraMacro', list(unused_macro.values())) def misra_2_7(self, data): for func in data.functions: # Skip function with no parameter if len(func.argument) == 0: continue # Setup list of function parameters func_param_list = [] for arg in func.argument: func_arg = func.argument[arg] if func_arg.typeStartToken and func_arg.typeStartToken.str == '...': continue func_param_list.append(func_arg) # Search for scope of current function for scope in data.scopes: if (scope.type == "Function") and (scope.function == func): # Search function body: remove referenced function parameter from list token = scope.bodyStart while token.next is not None and token != scope.bodyEnd and len(func_param_list) > 0: if token.variable is not None and token.variable in func_param_list: func_param_list.remove(token.variable) token = token.next # Emit a warning for each unused variable, but no more that one warning per line reported_linenrs = set() for func_param in func_param_list: if func_param.nameToken: linenr = func_param.nameToken if linenr not in reported_linenrs: self.reportError(func_param.nameToken, 2, 7) reported_linenrs.add(linenr) else: linenr = func.tokenDef.linenr if linenr not in reported_linenrs: self.reportError(func.tokenDef, 2, 7) reported_linenrs.add(linenr) def misra_3_1(self, rawTokens): for token in rawTokens: starts_with_double_slash = token.str.startswith('//') starts_with_block_comment = token.str.startswith("/*") s = token.str.lstrip('/') if (starts_with_double_slash or starts_with_block_comment) and "/*" in s: # Block comment inside of regular comment, violation self.reportError(token, 3, 1) elif starts_with_block_comment and "//" in s: # "//" in block comment, check if it's a uri while "//" in s: possible_uri, s = s.split("//", 1) if not re.search(r"\w+:$", possible_uri): # Violation if no uri was found self.reportError(token, 3, 1) break def misra_3_2(self, rawTokens): for token in rawTokens: if token.str.startswith('//'): # Check for comment ends with trigraph which might be replaced # by a backslash. if token.str.endswith('??/'): self.reportError(token, 3, 2) # Check for comment which has been merged with subsequent line # because it ends with backslash. # The last backslash is no more part of the comment token thus # check if next token exists and compare line numbers. elif (token.next is not None) and (token.linenr == token.next.linenr): self.reportError(token, 3, 2) def misra_4_1(self, rawTokens): for token in rawTokens: if (token.str[0] != '"') and (token.str[0] != '\''): continue if len(token.str) < 3: continue delimiter = token.str[0] symbols = token.str[1:-1] # No closing delimiter. This will not compile. if token.str[-1] != delimiter: continue if len(symbols) < 2: continue if not hasNumericEscapeSequence(symbols): continue # String literals that contains one or more escape sequences. All of them should be # terminated. for sequence in ['\\' + t for t in symbols.split('\\')][1:]: if (isHexEscapeSequence(sequence) or isOctalEscapeSequence(sequence) or isSimpleEscapeSequence(sequence)): continue self.reportError(token, 4, 1) def misra_4_2(self, rawTokens): for token in rawTokens: if (token.str[0] != '"') or (token.str[-1] != '"'): continue # Check for trigraph sequence as defined by ISO/IEC 9899:1999 for sequence in ['??=', '??(', '??/', '??)', '??\'', '??<', '??!', '??>', '??-']: if sequence in token.str[1:-1]: # First trigraph sequence match, report error and leave loop. self.reportError(token, 4, 2) break def misra_5_1(self, data): long_vars = {} num_sign_chars = self.get_num_significant_naming_chars(data) for var in data.variables: if var.nameToken is None: continue if len(var.nameToken.str) <= num_sign_chars: continue if not hasExternalLinkage(var): continue long_vars.setdefault(var.nameToken.str[:num_sign_chars], []).append(var.nameToken) for name_prefix in long_vars: tokens = long_vars[name_prefix] if len(tokens) < 2: continue for tok in sorted(tokens, key=lambda t: (t.linenr, t.column))[1:]: self.reportError(tok, 5, 1) def misra_5_2(self, data): scopeVars = {} num_sign_chars = self.get_num_significant_naming_chars(data) for var in data.variables: if var.nameToken is None: continue if len(var.nameToken.str) <= num_sign_chars: continue if var.nameToken.scope not in scopeVars: scopeVars.setdefault(var.nameToken.scope, {})["varlist"] = [] scopeVars.setdefault(var.nameToken.scope, {})["scopelist"] = [] scopeVars[var.nameToken.scope]["varlist"].append(var) for scope in data.scopes: if scope.nestedIn and scope.className: if scope.nestedIn not in scopeVars: scopeVars.setdefault(scope.nestedIn, {})["varlist"] = [] scopeVars.setdefault(scope.nestedIn, {})["scopelist"] = [] scopeVars[scope.nestedIn]["scopelist"].append(scope) for scope in scopeVars: if len(scopeVars[scope]["varlist"]) <= 1: continue for i, variable1 in enumerate(scopeVars[scope]["varlist"]): for variable2 in scopeVars[scope]["varlist"][i + 1:]: if variable1.isArgument and variable2.isArgument: continue if hasExternalLinkage(variable1) or hasExternalLinkage(variable2): continue if (variable1.nameToken.str[:num_sign_chars] == variable2.nameToken.str[:num_sign_chars] and variable1 is not variable2): if int(variable1.nameToken.linenr) > int(variable2.nameToken.linenr): self.reportError(variable1.nameToken, 5, 2) else: self.reportError(variable2.nameToken, 5, 2) for innerscope in scopeVars[scope]["scopelist"]: if variable1.nameToken.str[:num_sign_chars] == innerscope.className[:num_sign_chars]: if int(variable1.nameToken.linenr) > int(innerscope.bodyStart.linenr): self.reportError(variable1.nameToken, 5, 2) else: self.reportError(innerscope.bodyStart, 5, 2) if len(scopeVars[scope]["scopelist"]) <= 1: continue for i, scopename1 in enumerate(scopeVars[scope]["scopelist"]): for scopename2 in scopeVars[scope]["scopelist"][i + 1:]: if scopename1.className[:num_sign_chars] == scopename2.className[:num_sign_chars]: if int(scopename1.bodyStart.linenr) > int(scopename2.bodyStart.linenr): self.reportError(scopename1.bodyStart, 5, 2) else: self.reportError(scopename2.bodyStart, 5, 2) def misra_5_4(self, data): num_sign_chars = self.get_num_significant_naming_chars(data) macro = {} compile_name = re.compile(r'#define ([a-zA-Z0-9_]+)') compile_param = re.compile(r'#define ([a-zA-Z0-9_]+)[(]([a-zA-Z0-9_, ]+)[)]') short_names = {} macro_w_arg = [] for dir in data.directives: res1 = compile_name.match(dir.str) if res1: if dir not in macro: macro.setdefault(dir, {})["name"] = [] macro.setdefault(dir, {})["params"] = [] full_name = res1.group(1) macro[dir]["name"] = full_name short_name = full_name[:num_sign_chars] if short_name in short_names: _dir = short_names[short_name] if full_name != macro[_dir]["name"]: self.reportError(dir, 5, 4) else: short_names[short_name] = dir res2 = compile_param.match(dir.str) if res2: res_gp2 = res2.group(2).split(",") res_gp2 = [macroname.replace(" ", "") for macroname in res_gp2] macro[dir]["params"].extend(res_gp2) macro_w_arg.append(dir) for mvar in macro_w_arg: for i, macroparam1 in enumerate(macro[mvar]["params"]): for j, macroparam2 in enumerate(macro[mvar]["params"]): if j > i and macroparam1[:num_sign_chars] == macroparam2[:num_sign_chars]: self.reportError(mvar, 5, 4) param = macroparam1 if param[:num_sign_chars] in short_names: m_var1 = short_names[param[:num_sign_chars]] if m_var1.linenr > mvar.linenr: self.reportError(m_var1, 5, 4) else: self.reportError(mvar, 5, 4) def misra_5_5(self, data): num_sign_chars = self.get_num_significant_naming_chars(data) macroNames = {} compiled = re.compile(r'#define ([A-Za-z0-9_]+)') for dir in data.directives: res = compiled.match(dir.str) if res: macroNames[res.group(1)[:num_sign_chars]] = dir for var in data.variables: if var.nameToken and var.nameToken.str[:num_sign_chars] in macroNames: self.reportError(var.nameToken, 5, 5) for scope in data.scopes: if scope.className and scope.className[:num_sign_chars] in macroNames: self.reportError(scope.bodyStart, 5, 5) def misra_5_6(self, dumpfile, typedefInfo): self._save_ctu_summary_typedefs(dumpfile, typedefInfo) def misra_5_7(self, dumpfile, cfg): self._save_ctu_summary_tagnames(dumpfile, cfg) def misra_5_8(self, dumpfile, cfg): self._save_ctu_summary_identifiers(dumpfile, cfg) def misra_5_9(self, dumpfile, cfg): self._save_ctu_summary_identifiers(dumpfile, cfg) def misra_6_1(self, data): # Bitfield type must be bool or explicitly signed/unsigned int for token in data.tokenlist: if not token.valueType: continue if token.valueType.bits == 0: continue if not token.variable: continue if not token.scope: continue if token.scope.type not in 'Struct': continue if data.standards.c == 'c89': if token.valueType.type != 'int' and not isUnsignedType(token.variable.typeStartToken.str): self.reportError(token, 6, 1) elif data.standards.c in ('c99', 'c11', 'c17', 'c18'): if token.valueType.type == 'bool': continue isExplicitlySignedOrUnsigned = False typeToken = token.variable.typeStartToken while typeToken: if typeToken.isUnsigned or typeToken.isSigned or isUnsignedType(typeToken.str): isExplicitlySignedOrUnsigned = True break if typeToken is token.variable.typeEndToken: break typeToken = typeToken.next if not isExplicitlySignedOrUnsigned: self.reportError(token, 6, 1) def misra_6_2(self, data): # Bitfields of size 1 can not be signed for token in data.tokenlist: if not token.valueType: continue if not token.scope: continue if token.scope.type not in 'Struct': continue if token.valueType.bits == 1 and token.valueType.sign == 'signed': self.reportError(token, 6, 2) def misra_7_1(self, rawTokens): compiled = re.compile(r'^0[0-7]+$') for tok in rawTokens: if compiled.match(tok.str): self.reportError(tok, 7, 1) def misra_7_2(self, data): for token in data.tokenlist: if token.isInt and ('U' not in token.str.upper()) and token.valueType and token.valueType.sign == 'unsigned': self.reportError(token, 7, 2) def misra_7_3(self, rawTokens): compiled = re.compile(r'^[0-9.]+[Uu]*l+[Uu]*$') for tok in rawTokens: if compiled.match(tok.str): self.reportError(tok, 7, 3) def misra_7_4(self, data): # A string literal shall not be assigned to an object unless the object's type # is constant. def reportErrorIfVariableIsNotConst(variable, stringLiteral): if variable.valueType: if (variable.valueType.constness % 2) != 1: self.reportError(stringLiteral, 7, 4) for token in data.tokenlist: if token.isString: # Check normal variable assignment variable = getAssignedVariableToken(token) if variable: reportErrorIfVariableIsNotConst(variable, token) # Check use as return value function = getFunctionUsingReturnValue(token) if function: # "Primitive" test since there is no info available on return value type if not tokenFollowsSequence(function.tokenDef, ['const', 'char', '*']): self.reportError(token, 7, 4) # Check use as function parameter if isFunctionCall(token) and token.astOperand1 and token.astOperand1.function: functionDeclaration = token.astOperand1.function if functionDeclaration.tokenDef: if functionDeclaration.tokenDef is token.astOperand1: # Token is not a function call, but it is the definition of the function continue parametersUsed = getArguments(token) for i in range(len(parametersUsed)): usedParameter = parametersUsed[i] parameterDefinition = functionDeclaration.argument.get(i+1) if usedParameter.isString and parameterDefinition and parameterDefinition.nameToken: reportErrorIfVariableIsNotConst(parameterDefinition.nameToken, usedParameter) def misra_8_1(self, cfg): for token in cfg.tokenlist: if token.isImplicitInt and not token.isUnsigned and not token.isSigned: self.reportError(token, 8, 1) def misra_8_2(self, data, rawTokens): def getFollowingRawTokens(rawTokens, token, count): following =[] for rawToken in rawTokens: if (rawToken.file == token.file and rawToken.linenr == token.linenr and rawToken.column == token.column): for _ in range(count): rawToken = rawToken.next # Skip comments while rawToken and (rawToken.str.startswith('/*') or rawToken.str.startswith('//')): rawToken = rawToken.next if rawToken is None: break following.append(rawToken) return following # Zero arguments should be in form ( void ) def checkZeroArguments(func, startCall, endCall): if not startCall.isRemovedVoidParameter and len(func.argument) == 0: if func.tokenDef.next: self.reportError(func.tokenDef.next, 8, 2) else: self.reportError(func.tokenDef, 8, 2) def checkDeclarationArgumentsViolations(func, startCall, endCall): # Collect the tokens for the arguments in function definition argNameTokens = set() for arg in func.argument: argument = func.argument[arg] typeStartToken = argument.typeStartToken if typeStartToken is None: continue nameToken = argument.nameToken if nameToken is None: continue argNameTokens.add(nameToken) # Check if we have the same number of variables in both the # declaration and the definition. # # TODO: We actually need to check if the names of the arguments are # the same. But we can't do this because we have no links to # variables in the arguments in function definition in the dump file. foundVariables = 0 while startCall and startCall != endCall: if startCall.varId: foundVariables += 1 startCall = startCall.next if len(argNameTokens) != foundVariables: if func.tokenDef.next: self.reportError(func.tokenDef.next, 8, 2) else: self.reportError(func.tokenDef, 8, 2) def checkDefinitionArgumentsViolations(func, startCall, endCall): for arg in func.argument: argument = func.argument[arg] typeStartToken = argument.typeStartToken if typeStartToken is None: continue # Arguments should have a name unless variable length arg nameToken = argument.nameToken if nameToken is None and typeStartToken.str != '...': self.reportError(typeStartToken, 8, 2) # Type declaration on next line (old style declaration list) is not allowed if typeStartToken.linenr > endCall.linenr: self.reportError(typeStartToken, 8, 2) # Check arguments in function declaration for func in data.functions: # Check arguments in function definition tokenImpl = func.token if tokenImpl: startCall = tokenImpl.next if startCall is None or startCall.str != '(': continue endCall = startCall.link if endCall is None or endCall.str != ')': continue checkZeroArguments(func, startCall, endCall) checkDefinitionArgumentsViolations(func, startCall, endCall) # Check arguments in function declaration tokenDef = func.tokenDef if tokenDef: startCall = func.tokenDef.next if startCall is None or startCall.str != '(': continue endCall = startCall.link if endCall is None or endCall.str != ')': continue checkZeroArguments(func, startCall, endCall) if tokenImpl: checkDeclarationArgumentsViolations(func, startCall, endCall) else: # When there is no function definition, we should execute # its checks for the declaration token. The point is that without # a known definition we have no Function.argument list required # for declaration check. checkDefinitionArgumentsViolations(func, startCall, endCall) # Check arguments in pointer declarations for var in data.variables: if not var.isPointer: continue if var.nameToken is None: continue rawTokensFollowingPtr = getFollowingRawTokens(rawTokens, var.nameToken, 3) if len(rawTokensFollowingPtr) != 3: continue # Compliant: returnType (*ptrName) ( ArgType ) # Non-compliant: returnType (*ptrName) ( ) if (rawTokensFollowingPtr[0].str == ')' and rawTokensFollowingPtr[1].str == '(' and rawTokensFollowingPtr[2].str == ')'): self.reportError(var.nameToken, 8, 2) def insert_in_dict(self, dict_name,key, value): if key not in dict_name: dict_name[key] = [] dict_name[key].append(value) def misra_8_4(self, cfg): for func in cfg.functions: if func.isStatic: continue if func.token is None: continue if not is_source_file(func.token.file): continue if func.token != func.tokenDef: continue if func.tokenDef.str == 'main': continue self.reportError(func.tokenDef, 8, 4) extern_var_with_def = {} extern_var_without_def = {} for var in cfg.variables: if not var.isGlobal: continue if var.isStatic: continue if var.nameToken is None: continue tok = var.nameToken if tok.next.str == ";": if tok.next.isSplittedVarDeclEq: self.insert_in_dict(extern_var_with_def, tok.str, tok) else: self.insert_in_dict(extern_var_without_def, tok.str, tok) else: self.insert_in_dict(extern_var_without_def, var.nameToken.str, var.nameToken) for var in extern_var_with_def: if var not in extern_var_without_def: for t in extern_var_with_def[var]: self.reportError(t, 8, 4) for var_str, var_tok in extern_var_without_def.items(): warn = True if var_str not in extern_var_with_def: for t in var_tok: if t.variable.isExtern: warn = False break if warn: for t in var_tok: self.reportError(t, 8, 4) def misra_8_5(self, dumpfile, cfg): self._save_ctu_summary_identifiers(dumpfile, cfg) def misra_8_6(self, dumpfile, cfg): self._save_ctu_summary_identifiers(dumpfile, cfg) def misra_8_7(self, dumpfile, cfg): self._save_ctu_summary_usage(dumpfile, cfg) def misra_8_8(self, cfg): vars = {} for var in cfg.variables: if var.access != 'Global': continue if var.nameToken is None: continue varname = var.nameToken.str if varname in vars: vars[varname].append(var) else: vars[varname] = [var] for varname, varlist in vars.items(): static_var = None extern_var = None for var in varlist: if var.isStatic: static_var = var elif var.isExtern: extern_var = var if static_var and extern_var: self.reportError(extern_var.nameToken, 8, 8) def misra_8_9(self, cfg): variables = {} for scope in cfg.scopes: if scope.type != 'Function': continue variables_used_in_scope = [] tok = scope.bodyStart while tok != scope.bodyEnd: if tok.variable and tok.variable.access == 'Global' and tok.variable.isStatic: if tok.variable not in variables_used_in_scope: variables_used_in_scope.append(tok.variable) tok = tok.next for var in variables_used_in_scope: if var in variables: variables[var] += 1 else: variables[var] = 1 for var, count in variables.items(): if count == 1: self.reportError(var.nameToken, 8, 9) def misra_8_10(self, cfg): for func in cfg.functions: if func.isInlineKeyword and not func.isStatic: self.reportError(func.tokenDef, 8, 10) def misra_8_11(self, data): for var in data.variables: if var.isExtern and simpleMatch(var.nameToken.next, '[ ]') and var.nameToken.scope.type == 'Global': self.reportError(var.nameToken, 8, 11) def misra_8_12(self, data): for scope in data.scopes: if scope.type != 'Enum': continue enum_values = [] implicit_enum_values = [] e_token = scope.bodyStart.next while e_token != scope.bodyEnd: if e_token.str == '(': e_token = e_token.link continue if e_token.previous.str not in ',{': e_token = e_token.next continue if e_token.isName and e_token.values and e_token.valueType and e_token.valueType.typeScope == scope: token_values = [v.intvalue for v in e_token.values] enum_values += token_values if e_token.next.str != "=": implicit_enum_values += token_values e_token = e_token.next for implicit_enum_value in implicit_enum_values: if enum_values.count(implicit_enum_value) != 1: self.reportError(scope.bodyStart, 8, 12) def misra_8_14(self, rawTokens): for token in rawTokens: if token.str == 'restrict': self.reportError(token, 8, 14) def misra_9_2(self, data): misra_9.misra_9_x(self, data, 902) def misra_9_3(self, data): misra_9.misra_9_x(self, data, 903) def misra_9_4(self, data): misra_9.misra_9_x(self, data, 904) def misra_9_5(self, data, rawTokens): misra_9.misra_9_x(self, data, 905, rawTokens) #for token in rawTokens: # if simpleMatch(token, '[ ] = { ['): # self.reportError(token, 9, 5) def misra_10_1(self, data): for token in data.tokenlist: if not token.isOp: continue for t1, t2 in itertools.product( list(getTernaryOperandsRecursive(token.astOperand1) or [token.astOperand1]), list(getTernaryOperandsRecursive(token.astOperand2) or [token.astOperand2]), ): e1 = getEssentialTypeCategory(t1) e2 = getEssentialTypeCategory(t2) if not e1 or not e2: continue if token.str in ('<<', '>>'): if not isUnsignedType(e1): self.reportError(token, 10, 1) elif not isUnsignedType(e2) and not token.astOperand2.isNumber: self.reportError(token, 10, 1) elif token.str in ('~', '&', '|', '^'): e1_et = getEssentialType(token.astOperand1) e2_et = getEssentialType(token.astOperand2) if e1_et == 'char' or e2_et == 'char': self.reportError(token, 10, 1) def misra_10_2(self, data): def isEssentiallySignedOrUnsigned(op): e = getEssentialType(op) return e and (e.split(' ')[0] in ('unsigned', 'signed')) def isEssentiallyChar(op): if op is None: return False if op.str == '+': return isEssentiallyChar(op.astOperand1) or isEssentiallyChar(op.astOperand2) return op.isChar for token in data.tokenlist: if token.str not in ('+', '-'): continue if (not isEssentiallyChar(token.astOperand1)) and (not isEssentiallyChar(token.astOperand2)): continue if token.str == '+': if isEssentiallyChar(token.astOperand1) and not isEssentiallySignedOrUnsigned(token.astOperand2): self.reportError(token, 10, 2) if isEssentiallyChar(token.astOperand2) and not isEssentiallySignedOrUnsigned(token.astOperand1): self.reportError(token, 10, 2) if token.str == '-': e1 = getEssentialType(token.astOperand1) if e1 and e1.split(' ')[-1] != 'char': self.reportError(token, 10, 2) if not isEssentiallyChar(token.astOperand2) and not isEssentiallySignedOrUnsigned(token.astOperand2): self.reportError(token, 10, 2) def misra_10_3(self, cfg): def get_category(essential_type): if essential_type: if essential_type in ('bool', 'char'): return essential_type if essential_type.split(' ')[-1] in ('float', 'double'): return 'floating' if essential_type.split(' ')[0] in ('unsigned', 'signed'): return essential_type.split(' ')[0] return None for tok in cfg.tokenlist: if tok.isAssignmentOp: lhs = getEssentialType(tok.astOperand1) rhs = getEssentialType(tok.astOperand2) #print(lhs) #print(rhs) if lhs is None or rhs is None: continue lhs_category = get_category(lhs) rhs_category = get_category(rhs) if lhs_category and rhs_category and lhs_category != rhs_category and rhs_category not in ('signed','unsigned'): self.reportError(tok, 10, 3) if bitsOfEssentialType(lhs) < bitsOfEssentialType(rhs) and (lhs != "bool" or tok.astOperand2.str not in ('0','1')): self.reportError(tok, 10, 3) def misra_10_4(self, data): op = {'+', '-', '*', '/', '%', '&', '|', '^', '+=', '-=', ':'} for token in data.tokenlist: if token.str not in op and not token.isComparisonOp: continue if not token.astOperand1 or not token.astOperand2: continue if not token.astOperand1.valueType or not token.astOperand2.valueType: continue if ((token.astOperand1.str in op or token.astOperand1.isComparisonOp) and (token.astOperand2.str in op or token.astOperand2.isComparisonOp)): e1, e2 = getEssentialCategorylist(token.astOperand1.astOperand2, token.astOperand2.astOperand1) elif token.astOperand1.str in op or token.astOperand1.isComparisonOp: e1, e2 = getEssentialCategorylist(token.astOperand1.astOperand2, token.astOperand2) elif token.astOperand2.str in op or token.astOperand2.isComparisonOp: e1, e2 = getEssentialCategorylist(token.astOperand1, token.astOperand2.astOperand1) else: e1, e2 = getEssentialCategorylist(token.astOperand1, token.astOperand2) if token.str == "+=" or token.str == "+": if e1 == "char" and (e2 == "signed" or e2 == "unsigned"): continue if e2 == "char" and (e1 == "signed" or e1 == "unsigned"): continue if token.str == "-=" or token.str == "-": if e1 == "char" and (e2 == "signed" or e2 == "unsigned"): continue if e1 and e2 and (e1.find('Anonymous') != -1 and (e2 == "signed" or e2 == "unsigned")): continue if e1 and e2 and (e2.find('Anonymous') != -1 and (e1 == "signed" or e1 == "unsigned")): continue if e1 and e2 and e1 != e2: self.reportError(token, 10, 4) def misra_10_5(self, cfg): def _get_essential_category(token): essential_type = getEssentialType(token) #print(essential_type) if essential_type: if essential_type in ('bool', 'char'): return essential_type if essential_type.split(' ')[-1] in ('float', 'double'): return 'floating' if essential_type.split(' ')[0] in ('unsigned', 'signed'): return essential_type.split(' ')[0] return None for token in cfg.tokenlist: if not isCast(token): continue to_type = _get_essential_category(token) #print(to_type) if to_type is None: continue from_type = _get_essential_category(token.astOperand1) #print(from_type) if from_type is None: continue if to_type == from_type: continue if to_type == 'bool' or from_type == 'bool': if token.astOperand1.isInt and token.astOperand1.getKnownIntValue() == 1: # Exception continue self.reportError(token, 10, 5) continue if to_type == 'enum': self.reportError(token, 10, 5) continue if from_type == 'float' and to_type == 'char': self.reportError(token, 10, 5) continue if from_type == 'char' and to_type == 'float': self.reportError(token, 10, 5) continue def misra_10_6(self, data): for token in data.tokenlist: if token.str != '=' or not token.astOperand1 or not token.astOperand2: continue if not is_composite_expr(token.astOperand2): continue vt1 = token.astOperand1.valueType vt2 = token.astOperand2.valueType if not vt1 or vt1.pointer > 0: continue if not vt2 or vt2.pointer > 0: continue try: if isCast(token.astOperand2): e = vt2.type else: e = getEssentialType(token.astOperand2) if not e: continue if e == "char" and vt1.type == "int": # When arithmetic operations are performed on char values, they are usually promoted to int continue lhsbits = vt1.bits if vt1.bits else bitsOfEssentialType(vt1.type) if lhsbits > bitsOfEssentialType(e): self.reportError(token, 10, 6) except ValueError: pass def misra_10_7(self, cfg): for token in cfg.tokenlist: if token.astOperand1 is None or token.astOperand2 is None: continue if not token.isArithmeticalOp: continue if not is_composite_expr(token): continue parent = token.astParent if parent is None: continue if not parent.isArithmeticalOp: if not parent.isAssignmentOp: continue if parent.str == '=': continue token_type = getEssentialType(token) if token_type is None: continue sibling = parent.astOperand1 if (token == parent.astOperand2) else parent.astOperand2 sibling_type = getEssentialType(sibling) if sibling_type is None: continue b1 = bitsOfEssentialType(token_type) b2 = bitsOfEssentialType(sibling_type) if b1 > 0 and b1 < b2: self.reportError(token, 10, 7) def misra_10_8(self, data): for token in data.tokenlist: if not isCast(token): continue if not token.valueType or token.valueType.pointer > 0: continue if not token.astOperand1.valueType or token.astOperand1.valueType.pointer > 0: continue if not token.astOperand1.astOperand1: continue if token.astOperand1.str not in ('+', '-', '*', '/', '%', '&', '|', '^', '>>', "<<", "?", ":", '~'): continue if token.astOperand1.str != '~' and not token.astOperand1.astOperand2: continue if token.astOperand1.str == '~': e2 = getEssentialTypeCategory(token.astOperand1.astOperand1) else: e2, e3 = getEssentialCategorylist(token.astOperand1.astOperand1, token.astOperand1.astOperand2) if e2 != e3: continue e1 = getEssentialTypeCategory(token) if e1 != e2: self.reportError(token, 10, 8) else: try: e = getEssentialType(token.astOperand1) if not e: continue if bitsOfEssentialType(token.valueType.type) > bitsOfEssentialType(e): self.reportError(token, 10, 8) except ValueError: pass def misra_11_1(self, data): for token in data.tokenlist: to_from = get_type_conversion_to_from(token) if to_from is None: continue from_type = get_function_pointer_type(to_from[1]) if from_type is None: continue to_type = get_function_pointer_type(to_from[0]) if to_type is None or to_type != from_type: self.reportError(token, 11, 1) def misra_11_2(self, data): def get_pointer_type(type_token): while type_token and (type_token.str in ('const', 'struct')): type_token = type_token.next if type_token is None: return None if not type_token.isName: return None return type_token if (type_token.next and type_token.next.str == '*') else None incomplete_types = [] for token in data.tokenlist: if token.str == 'struct' and token.next and token.next.next and token.next.isName and token.next.next.str == ';': incomplete_types.append(token.next.str) to_from = get_type_conversion_to_from(token) if to_from is None: continue to_pointer_type_token = get_pointer_type(to_from[0]) if to_pointer_type_token is None: continue from_pointer_type_token = get_pointer_type(to_from[1]) if from_pointer_type_token is None: continue if to_pointer_type_token.str == from_pointer_type_token.str: continue if from_pointer_type_token.typeScope is None and (from_pointer_type_token.str in incomplete_types): self.reportError(token, 11, 2) elif to_pointer_type_token.typeScope is None and (to_pointer_type_token.str in incomplete_types): self.reportError(token, 11, 2) def misra_11_3(self, data): for token in data.tokenlist: if not isCast(token): continue vt1 = token.valueType vt2 = token.astOperand1.valueType if not vt1 or not vt2: continue if vt1.type == 'void' or vt2.type == 'void': continue if (vt1.pointer > 0 and vt1.type == 'record' and vt2.pointer > 0 and vt2.type == 'record' and vt1.typeScopeId != vt2.typeScopeId): self.reportError(token, 11, 3) elif (vt1.pointer == vt2.pointer and vt1.pointer > 0 and vt1.type != vt2.type and vt1.type != 'char'): self.reportError(token, 11, 3) def misra_11_4(self, data): # Get list of macro definitions macros = {} for directive in data.directives: #define X ((peripheral_t *)0x40000U) res = re.match(r'#define ([A-Za-z0-9_]+).*', directive.str) if res: if res.group(1) in macros: macros[res.group(1)].append(directive) else: macros[res.group(1)] = [directive] # If macro definition is non-compliant then warn about the macro definition instead of # the macro usages. To reduce diagnostics for a non-compliant macro. bad_macros = [] for token in data.tokenlist: if not isCast(token): continue vt1 = token.valueType vt2 = token.astOperand1.valueType if not vt1 or not vt2: continue if vt2.pointer > 0 and vt1.pointer == 0 and (vt1.isIntegral() or vt1.isEnum()) and vt2.type != 'void': self.reportError(token, 11, 4) elif vt1.pointer > 0 and vt2.pointer == 0 and (vt2.isIntegral() or vt2.isEnum()) and vt1.type != 'void': if token.macroName is not None and \ token.macroName == token.astOperand1.macroName and \ token.astOperand1.isInt and \ token.link.previous.str == '*' and \ token.macroName == token.link.previous.macroName and \ token.macroName in macros and \ len(macros[token.macroName]) == 1: if token.macroName not in bad_macros: bad_macros.append(token.macroName) self.reportError(macros[token.macroName][0], 11, 4) continue self.reportError(token, 11, 4) def misra_11_5(self, data): for token in data.tokenlist: if not isCast(token): if token.astOperand1 and token.astOperand2 and token.str == "=" and token.next.str != "(": vt1 = token.astOperand1.valueType vt2 = token.astOperand2.valueType if not vt1 or not vt2: continue if vt1.pointer > 0 and vt1.type != 'void' and vt2.pointer == vt1.pointer and vt2.type == 'void': self.reportError(token, 11, 5) continue if token.astOperand1.astOperand1 and token.astOperand1.astOperand1.str in ( 'malloc', 'calloc', 'realloc', 'free'): continue vt1 = token.valueType vt2 = token.astOperand1.valueType if not vt1 or not vt2: continue if vt1.pointer > 0 and vt1.type != 'void' and vt2.pointer == vt1.pointer and vt2.type == 'void': self.reportError(token, 11, 5) def misra_11_6(self, data): for token in data.tokenlist: if not isCast(token): continue vt1 = token.valueType vt2 = token.astOperand1.valueType if not vt1 or not vt2: continue if vt1.pointer == 1 and vt1.type == 'void' and vt2.pointer == 0 and token.astOperand1.getKnownIntValue() != 0: self.reportError(token, 11, 6) elif vt1.pointer == 0 and vt1.type != 'void' and vt2.pointer == 1 and vt2.type == 'void': self.reportError(token, 11, 6) def misra_11_7(self, data): for token in data.tokenlist: if not isCast(token): continue vt1 = token.valueType vt2 = token.astOperand1.valueType if not vt1 or not vt2: continue if token.astOperand1.astOperand1: continue if (vt2.pointer > 0 and vt1.pointer == 0 and not vt1.isIntegral() and not vt1.isEnum() and vt1.type != 'void'): self.reportError(token, 11, 7) elif (vt1.pointer > 0 and vt2.pointer == 0 and not vt2.isIntegral() and not vt2.isEnum() and vt1.type != 'void'): self.reportError(token, 11, 7) def misra_11_8(self, data): # TODO: reuse code in CERT-EXP05 for token in data.tokenlist: if isCast(token): # C-style cast if not token.valueType: continue if not token.astOperand1.valueType: continue if token.valueType.pointer == 0: continue if token.astOperand1.valueType.pointer == 0: continue const1 = token.valueType.constness const2 = token.astOperand1.valueType.constness if (const1 % 2) < (const2 % 2): self.reportError(token, 11, 8) elif token.str == '(' and token.astOperand1 and token.astOperand2 and token.astOperand1.function: # Function call function = token.astOperand1.function arguments = getArguments(token) for argnr, argvar in function.argument.items(): if argnr < 1 or argnr > len(arguments): continue if not argvar.isPointer: continue argtok = arguments[argnr - 1] if not argtok.valueType: continue if argtok.valueType.pointer == 0: continue const1 = argvar.constness const2 = arguments[argnr - 1].valueType.constness if (const1 % 2) < (const2 % 2): self.reportError(token, 11, 8) def misra_11_9(self, data): for token in data.tokenlist: if token.astOperand1 and token.astOperand2 and token.str in ["=", "==", "!=", "?", ":"]: vt1 = token.astOperand1.valueType vt2 = token.astOperand2.valueType if not vt1 or not vt2: continue if vt1.pointer > 0 and vt2.pointer == 0 and token.astOperand2.str == "NULL": continue if (token.astOperand2.values and vt1.pointer > 0 and vt2.pointer == 0 and token.astOperand2.values): if token.astOperand2.getValue(0): self.reportError(token, 11, 9) def misra_12_1_sizeof(self, rawTokens): state = 0 compiled = re.compile(r'^[a-zA-Z_]') for tok in rawTokens: if tok.str.startswith('//') or tok.str.startswith('/*'): continue if tok.str == 'sizeof': state = 1 elif state == 1: if compiled.match(tok.str): state = 2 else: state = 0 elif state == 2: if tok.str in ('+', '-', '*', '/', '%'): self.reportError(tok, 12, 1) else: state = 0 def misra_12_1(self, data): for token in data.tokenlist: p = getPrecedence(token) if p < 2 or p > 12: continue p1 = getPrecedence(token.astOperand1) if p < p1 <= 12 and numberOfParentheses(token.astOperand1, token): self.reportError(token, 12, 1) continue p2 = getPrecedence(token.astOperand2) if p < p2 <= 12 and numberOfParentheses(token, token.astOperand2): self.reportError(token, 12, 1) continue def misra_12_2(self, data): for token in data.tokenlist: if not (token.str in ('<<', '>>')): continue if (not token.astOperand2) or (not token.astOperand2.values): continue maxval = 0 for val in token.astOperand2.values: if val.intvalue and val.intvalue > maxval: maxval = val.intvalue if maxval == 0: continue sz = bitsOfEssentialType(getEssentialType(token.astOperand1)) if sz <= 0: continue if maxval >= sz: self.reportError(token, 12, 2) def misra_12_3(self, data): for token in data.tokenlist: if token.str == ';' and (token.isSplittedVarDeclComma is True): self.reportError(token, 12, 3) if token.str == ',' and token.astParent and token.astParent.str == ';': self.reportError(token, 12, 3) if token.str == ',' and token.astParent is None: if token.scope.type in ('Class', 'Struct'): # Is this initlist.. tok = token while tok and tok.str == ',': tok = tok.next if tok and tok.next and tok.isName and tok.next.str == '(': tok = tok.next.link.next if tok.str == '{': # This comma is used in initlist, do not warn continue prev = token.previous while prev: if prev.str == ';': self.reportError(token, 12, 3) break if prev.str in '({[': break if prev.str in ')}]': prev = prev.link prev = prev.previous def misra_12_4_check_expr(self, expr): if not expr.astOperand2 or not expr.astOperand1: return if expr.valueType is None: return if expr.valueType.sign is None or expr.valueType.sign != 'unsigned': return if expr.valueType.pointer > 0: return if not expr.valueType.isIntegral(): return op1 = expr.astOperand1.getKnownIntValue() if op1 is None: return op2 = expr.astOperand2.getKnownIntValue() if op2 is None: return bits = bitsOfEssentialType('unsigned ' + expr.valueType.type) if bits <= 0 or bits >= 64: return max_value = (1 << bits) - 1 if not is_constant_integer_expression(expr): return if expr.str == '+' and op1 + op2 > max_value: self.reportError(expr, 12, 4) elif expr.str == '-' and op1 - op2 < 0: self.reportError(expr, 12, 4) elif expr.str == '*' and op1 * op2 > max_value: self.reportError(expr, 12, 4) def misra_12_4(self, cfg): if not cfg.tokenlist: return expr = cfg.tokenlist[0] while expr.next: expr = expr.next if expr.str == "?" and expr.astOperand2.str == ":": known_value = expr.astOperand1.getKnownIntValue() if known_value == 1: tok = expr while tok != expr.astOperand2: self.misra_12_4_check_expr(tok) tok = tok.next expr = tok while expr.str not in (";", "{", "}"): expr = expr.next continue if known_value == 0: expr = expr.astOperand2 self.misra_12_4_check_expr(expr) def misra_13_1(self, data): for token in data.tokenlist: if simpleMatch(token, ") {") and token.next.astParent == token.link: pass elif not simpleMatch(token, '= {'): continue init = token.next end = init.link if not end: continue # syntax is broken tn = init while tn and tn != end: if tn.str == '[' and tn.link: tn = tn.link if tn and tn.next and tn.next.str == '=': tn = tn.next.next continue break if tn.str == '.' and tn.next and tn.next.isName: tn = tn.next if tn.next and tn.next.str == '=': tn = tn.next.next continue if tn.str in {'++', '--'} or tn.isAssignmentOp: self.reportError(init, 13, 1) tn = tn.next def misra_13_3(self, data): for token in data.tokenlist: if token.str not in ('++', '--'): continue astTop = token while astTop.astParent and astTop.astParent.str not in (',', ';'): astTop = astTop.astParent if countSideEffects(astTop) >= 2: self.reportError(astTop, 13, 3) def misra_13_4(self, data): for token in data.tokenlist: if token.str != '=': continue if not token.astParent: continue if (token.astOperand1 is None) or (token.astOperand2 is None): continue if token.astOperand1.str == '[' and token.astOperand1.previous.str in ('{', ','): continue if not (token.astParent.str in [',', ';', '{']): self.reportError(token, 13, 4) def misra_13_5(self, data): for token in data.tokenlist: if token.isLogicalOp and countSideEffectsRecursive(token.astOperand2) > 0: self.reportError(token, 13, 5) def misra_13_6(self, data): for token in data.tokenlist: if token.str == 'sizeof' and countSideEffectsRecursive(token.next) > 0: self.reportError(token, 13, 6) def misra_14_1(self, data): for token in data.tokenlist: if token.str == 'for': exprs = getForLoopExpressions(token) if not exprs: continue for counter in findCounterTokens(exprs[1]): if counter.valueType and counter.valueType.isFloat(): self.reportError(token, 14, 1) elif token.str == 'while': if isFloatCounterInWhileLoop(token): self.reportError(token, 14, 1) def misra_14_2(self, data): for token in data.tokenlist: if token.str == 'for': expressions = getForLoopExpressions(token) if not expressions: continue if expressions[0] and not expressions[0].isAssignmentOp: if expressions[0].str != "(" or not expressions[0].previous.isName: self.reportError(token, 14, 2) if countSideEffectsRecursive(expressions[1]) > 0: self.reportError(token, 14, 2) if countSideEffectsRecursive(expressions[2]) > 1: self.reportError(token, 14, 2) counter_vars_first_clause, counter_vars_exit_modified = getForLoopCounterVariables(token, data) if len(counter_vars_exit_modified) == 0: # if it's not possible to identify a loop counter, all 3 clauses must be empty for idx in range(len(expressions)): if expressions[idx]: self.reportError(token, 14, 2) break elif len(counter_vars_exit_modified) > 1: # there shall be a single loop counter self.reportError(token, 14, 2) else: # len(counter_vars_exit_modified) == 1: loop_counter = counter_vars_exit_modified.pop() # if the first clause is not empty, then it shall (declare and) initialize the loop counter if expressions[0] is not None and loop_counter not in counter_vars_first_clause: self.reportError(token, 14, 2) # Inspect modification of loop counter in loop body body_scope = token.next.link.next.scope if not body_scope: continue tn = body_scope.bodyStart while tn and tn != body_scope.bodyEnd: if tn.variable == loop_counter: if tn.next: # TODO: Check modifications in function calls if countSideEffectsRecursive(tn.next) > 0: self.reportError(tn, 14, 2) tn = tn.next def misra_14_4(self, data): for token in data.tokenlist: if token.str != '(': continue if not token.astOperand1 or not (token.astOperand1.str in ['if', 'while']): continue if isBoolExpression(token.astOperand2): continue if token.astOperand2.valueType: self.reportError(token, 14, 4) def misra_15_1(self, data): for token in data.tokenlist: if token.str == "goto": self.reportError(token, 15, 1) def misra_15_2(self, data): for token in data.tokenlist: if token.str != 'goto': continue if (not token.next) or (not token.next.isName): continue if not findGotoLabel(token): self.reportError(token, 15, 2) def misra_15_3(self, data): for token in data.tokenlist: if token.str != 'goto': continue if (not token.next) or (not token.next.isName): continue tok = findGotoLabel(token) if not tok: continue scope = token.scope while scope and scope != tok.scope: scope = scope.nestedIn if not scope: self.reportError(token, 15, 3) # Jump crosses from one switch-clause to another is non-compliant elif scope.type == 'Switch': # Search for start of a current case block tcase_start = token while tcase_start and tcase_start.str not in ('case', 'default'): tcase_start = tcase_start.previous # Make sure that goto label doesn't occurs in the other # switch-clauses if tcase_start: t = scope.bodyStart in_this_case = False while t and t != scope.bodyEnd: if t == tcase_start: in_this_case = True if in_this_case and t.str not in ('case', 'default'): in_this_case = False if t == tok and not in_this_case: self.reportError(token, 15, 3) break t = t.next def misra_15_4(self, data): # Return a list of scopes affected by a break or goto def getLoopsAffectedByBreak(knownLoops, scope, isGoto): if scope and scope.type and scope.type not in ['Global', 'Function']: if not isGoto and scope.type == 'Switch': return if scope.type in ['For', 'While', 'Do']: knownLoops.append(scope) if not isGoto: return getLoopsAffectedByBreak(knownLoops, scope.nestedIn, isGoto) loopWithBreaks = {} for token in data.tokenlist: if token.str not in ['break', 'goto']: continue affectedLoopScopes = [] getLoopsAffectedByBreak(affectedLoopScopes, token.scope, token.str == 'goto') for scope in affectedLoopScopes: if scope in loopWithBreaks: loopWithBreaks[scope] += 1 else: loopWithBreaks[scope] = 1 for scope, breakCount in loopWithBreaks.items(): if breakCount > 1: self.reportError(scope.bodyStart, 15, 4) def misra_15_5(self, data): for token in data.tokenlist: if token.str == 'return' and token.scope.type != 'Function': self.reportError(token, 15, 5) def misra_15_6(self, rawTokens): state = 0 indent = 0 tok1 = None def tokAt(tok,i): while i < 0 and tok: tok = tok.previous if tok.str.startswith('//') or tok.str.startswith('/*'): continue i += 1 while i > 0 and tok: tok = tok.next if tok.str.startswith('//') or tok.str.startswith('/*'): continue i -= 1 return tok def strtokens(tok, i1, i2): tok1 = tokAt(tok, i1) tok2 = tokAt(tok, i2) tok = tok1 s = '' while tok != tok2: if tok.str.startswith('//') or tok.str.startswith('/*'): tok = tok.next continue s += ' ' + tok.str tok = tok.next s += ' ' + tok.str return s[1:] for token in rawTokens: if token.str in ['if', 'for', 'while']: if strtokens(token,-1,0) == '# if': continue if strtokens(token,-1,0) == "} while": # is there a 'do { .. } while'? start = rawlink(tokAt(token,-1)) if start and strtokens(start, -1, 0) == 'do {': continue if state == 2: self.reportError(tok1, 15, 6) state = 1 indent = 0 tok1 = token elif token.str == 'else': if strtokens(token,-1,0) == '# else': continue if strtokens(token,0,1) == 'else if': continue if state == 2: self.reportError(tok1, 15, 6) state = 2 indent = 0 tok1 = token elif state == 1: if indent == 0 and token.str != '(': state = 0 continue if token.str == '(': indent = indent + 1 elif token.str == ')': if indent == 0: state = 0 elif indent == 1: state = 2 indent = indent - 1 elif state == 2: if token.str.startswith('//') or token.str.startswith('/*'): continue state = 0 if token.str not in ('{', '#'): self.reportError(tok1, 15, 6) def misra_15_7(self, data): for scope in data.scopes: if scope.type != 'Else': continue if not simpleMatch(scope.bodyStart, '{ if ('): continue if scope.bodyStart.column > 0: continue tok = scope.bodyStart.next.next.link if not simpleMatch(tok, ') {'): continue tok = tok.next.link if not simpleMatch(tok, '} else'): self.reportError(tok, 15, 7) def misra_16_1(self, cfg): for scope in cfg.scopes: if scope.type != 'Switch': continue in_case_or_default = False tok = scope.bodyStart.next while tok != scope.bodyEnd: if not in_case_or_default: if tok.str not in ('case', 'default'): self.reportError(tok, 16, 1) else: in_case_or_default = True else: if simpleMatch(tok, 'break ;'): in_case_or_default = False tok = tok.next if tok.str == '{': tok = tok.link if tok.scope.type == 'Unconditional' and simpleMatch(tok.previous.previous, 'break ;'): in_case_or_default = False tok = tok.next def misra_16_2(self, data): for token in data.tokenlist: if token.str == 'case' and token.scope.type != 'Switch': self.reportError(token, 16, 2) def misra_16_3(self, rawTokens): STATE_NONE = 0 # default state, not in switch case/default block STATE_BREAK = 1 # break/comment is seen but not its ';' STATE_OK = 2 # a case/default is allowed (we have seen 'break;'/'comment'/'{'/attribute) STATE_SWITCH = 3 # walking through switch statement scope define = None state = STATE_NONE end_switch_token = None # end '}' for the switch scope for token in rawTokens: if simpleMatch(token, '# define'): define = token if define: if token.linenr != define.linenr: define = None else: continue # Find switch scope borders if token.str == 'switch': state = STATE_SWITCH if state == STATE_SWITCH: if token.str == '{': end_switch_token = findRawLink(token) else: continue if token.str == 'break' or token.str == 'return' or token.str == 'throw': state = STATE_BREAK elif token.str == ';': if state == STATE_BREAK: state = STATE_OK elif token.next and token.next == end_switch_token: self.reportError(token.next, 16, 3) else: state = STATE_NONE elif token.str.startswith('/*') or token.str.startswith('//'): if 'fallthrough' in token.str.lower(): state = STATE_OK elif simpleMatch(token, '[ [ fallthrough ] ] ;'): state = STATE_BREAK elif token.str == '{': state = STATE_OK elif token.str == '}' and state == STATE_OK: # is this {} an unconditional block of code? prev = findRawLink(token) if prev: prev = prev.previous while prev and prev.str[:2] in ('//', '/*'): prev = prev.previous if (prev is None) or (prev.str not in ':;{}'): state = STATE_NONE elif token.str == 'case' or token.str == 'default': if state != STATE_OK: self.reportError(token, 16, 3) state = STATE_OK def misra_16_4(self, data): for token in data.tokenlist: if token.str != 'switch': continue if not simpleMatch(token, 'switch ('): continue if not simpleMatch(token.next.link, ') {'): continue startTok = token.next.link.next tok = startTok.next while tok and tok.str != '}': if tok.str == '{': tok = tok.link elif tok.str == 'default': break tok = tok.next if tok and tok.str != 'default': self.reportError(token, 16, 4) def misra_16_5(self, data): for token in data.tokenlist: if token.str != 'default': continue if token.previous and token.previous.str == '{': continue tok2 = token while tok2: if tok2.str in ('}', 'case'): break if tok2.str == '{': tok2 = tok2.link tok2 = tok2.next if tok2 and tok2.str == 'case': self.reportError(token, 16, 5) def misra_16_6(self, data): for token in data.tokenlist: if not (simpleMatch(token, 'switch (') and simpleMatch(token.next.link, ') {')): continue tok = token.next.link.next.next count = 0 while tok: if tok.str in ['break', 'return', 'throw']: count = count + 1 elif tok.str == '{': tok = tok.link if isNoReturnScope(tok): count = count + 1 elif tok.str == '}': break tok = tok.next if count < 2: self.reportError(token, 16, 6) def misra_16_7(self, data): for token in data.tokenlist: if simpleMatch(token, 'switch (') and isBoolExpression(token.next.astOperand2): self.reportError(token, 16, 7) def misra_17_1(self, data): for token in data.tokenlist: if isFunctionCall(token) and token.astOperand1.str in ( 'va_list', 'va_arg', 'va_start', 'va_end', 'va_copy'): self.reportError(token, 17, 1) elif token.str == 'va_list': self.reportError(token, 17, 1) def misra_17_2(self, data): # find recursions.. def find_recursive_call(search_for_function, direct_call, calls_map, visited=None): if visited is None: visited = set() if direct_call == search_for_function: return True for indirect_call in calls_map.get(direct_call, []): if indirect_call == search_for_function: return True if indirect_call in visited: # This has already been handled continue visited.add(indirect_call) if find_recursive_call(search_for_function, indirect_call, calls_map, visited): return True return False # List functions called in each function function_calls = {} for scope in data.scopes: if scope.type != 'Function': continue calls = [] tok = scope.bodyStart while tok != scope.bodyEnd: tok = tok.next if not isFunctionCall(tok, data.standards.c): continue f = tok.astOperand1.function if f is not None and f not in calls: calls.append(f) function_calls[scope.function] = calls # Report warnings for all recursions.. for func in function_calls: for call in function_calls[func]: if not find_recursive_call(func, call, function_calls): # Function call is not recursive continue # Warn about all functions calls.. for scope in data.scopes: if scope.type != 'Function' or scope.function != func: continue tok = scope.bodyStart while tok != scope.bodyEnd: if tok.function and tok.function == call: self.reportError(tok, 17, 2) tok = tok.next def misra_17_3(self, cfg): for w in cfg.clang_warnings: if w['message'].endswith('[-Wimplicit-function-declaration]'): self.reportError(cppcheckdata.Location(w), 17, 3) for token in cfg.tokenlist: if token.str not in ["while", "if"]: continue if token.next.str != "(": continue tok = token.next end_token = token.next.link while tok != end_token: if tok.isName and tok.function is None and tok.valueType is None and tok.next.str == "(" and \ tok.next.valueType is None and not isKeyword(tok.str) and not isStdLibId(tok.str): self.reportError(tok, 17, 3) break tok = tok.next def misra_config(self, data): for var in data.variables: if not var.isArray or var.nameToken is None or not cppcheckdata.simpleMatch(var.nameToken.next, '['): continue tok = var.nameToken.next while tok.str == '[': sz = tok.astOperand2 if sz and sz.getKnownIntValue() is None: has_var = False unknown_constant = False tokens = [sz] while len(tokens) > 0: t = tokens[-1] tokens = tokens[:-1] if t: if t.isName and t.getKnownIntValue() is None: if t.varId or t.variable: has_var = True continue unknown_constant = True self.report_config_error(tok, 'Unknown constant {}, please review configuration'.format(t.str)) if t.isArithmeticalOp: tokens += [t.astOperand1, t.astOperand2] if not unknown_constant and not has_var: self.report_config_error(tok, 'Unknown array size, please review configuration') tok = tok.link.next for token in data.tokenlist: if token.str not in ("while", "if"): continue tok = token.next if token is None or tok.str != "(": continue end_token = tok.link while tok != end_token: tok = tok.next if tok.str == 'sizeof' and tok.next.str == '(': tok = tok.next.link continue if tok.str == "(" and tok.isCast: tok = tok.link continue if not tok.isName: continue if tok.function or tok.variable or tok.varId or tok.valueType or tok.typeScope: continue if tok.next.str == "(" or tok.str in ["EOF"]: continue if isKeyword(tok.str) or isStdLibId(tok.str): continue if tok.astParent is None: continue if tok.astParent.str == "." and tok.astParent.valueType: continue self.report_config_error(tok, "Variable '%s' is unknown" % tok.str) def misra_17_6(self, rawTokens): for token in rawTokens: if simpleMatch(token, '[ static'): self.reportError(token, 17, 6) def misra_17_7(self, data): for token in data.tokenlist: if not token.scope.isExecutable: continue if token.str != '(' or token.astParent: continue if token.astOperand1 is None or not token.astOperand1.isName: continue if token.astOperand1.varId and (token.astOperand1.variable is None or get_function_pointer_type(token.astOperand1.variable.typeStartToken) is None): continue if token.valueType is None: continue if token.valueType.type == 'void' and token.valueType.pointer == 0: continue self.reportError(token, 17, 7) def misra_17_8(self, data): for token in data.tokenlist: if not (token.isAssignmentOp or (token.str in ('++', '--'))): continue if not token.astOperand1: continue var = token.astOperand1.variable if var and var.isArgument: self.reportError(token, 17, 8) def misra_18_4(self, data): for token in data.tokenlist: if token.str not in ('+', '-', '+=', '-='): continue if token.astOperand1 is None or token.astOperand2 is None: continue vt1 = token.astOperand1.valueType vt2 = token.astOperand2.valueType if vt1 and vt1.pointer > 0: self.reportError(token, 18, 4) elif vt2 and vt2.pointer > 0: self.reportError(token, 18, 4) def misra_18_5(self, data): for var in data.variables: if not var.isPointer: continue typetok = var.nameToken count = 0 while typetok: if typetok.str == '*': count = count + 1 elif not typetok.isName: break typetok = typetok.previous if count > 2: self.reportError(var.nameToken, 18, 5) def misra_18_7(self, data): for scope in data.scopes: if scope.type != 'Struct': continue token = scope.bodyStart.next while token != scope.bodyEnd and token is not None: # Handle nested structures to not duplicate an error. if token.str == '{': token = token.link # skip function pointer parameter types if token.astOperand1 is None: pass elif cppcheckdata.simpleMatch(token, "[ ]"): self.reportError(token, 18, 7) break token = token.next def misra_18_8(self, data): for var in data.variables: if not var.isArray or not var.isLocal: continue # TODO Array dimensions are not available in dump, must look in tokens typetok = var.nameToken.next if not typetok or typetok.str != '[': continue # Unknown define or syntax error if not typetok.astOperand2: continue if not isConstantExpression(typetok.astOperand2) and not isUnknownConstantExpression(typetok.astOperand2): self.reportError(var.nameToken, 18, 8) def misra_19_2(self, data): for token in data.tokenlist: if token.str == 'union': self.reportError(token, 19, 2) def misra_20_1(self, data): token_in_file = {} for token in data.tokenlist: if token.file not in token_in_file: token_in_file[token.file] = int(token.linenr) else: token_in_file[token.file] = min(token_in_file[token.file], int(token.linenr)) for directive in data.directives: if not directive.str.startswith('#include'): continue if directive.file not in token_in_file: continue if token_in_file[directive.file] < int(directive.linenr): self.reportError(directive, 20, 1) def misra_20_2(self, data): for directive in data.directives: if not directive.str.startswith('#include '): continue for pattern in ('\\', '//', '/*', ',', "'"): if pattern in directive.str: self.reportError(directive, 20, 2) break def misra_20_3(self, data): for directive in data.directives: if not directive.str.startswith('#include '): continue words = directive.str.split(' ') # If include directive contains more than two words, here would be # violation anyway. if len(words) > 2: self.reportError(directive, 20, 3) # Handle include directives with not quoted argument elif len(words) > 1: filename = words[1] if not ((filename.startswith('"') and filename.endswith('"')) or (filename.startswith('<') and filename.endswith('>'))): # We are handle only directly included files in the # following format: #include file.h # Cases with macro expansion provided by MISRA document are # skipped because we don't always have access to directive # definition. if '.' in filename: self.reportError(directive, 20, 3) def misra_20_4(self, data): for directive in data.directives: res = re.search(r'#define ([a-z][a-z0-9_]+)', directive.str) if res and isKeyword(res.group(1), data.standards.c): self.reportError(directive, 20, 4) def misra_20_5(self, data): for directive in data.directives: if directive.str.startswith('#undef '): self.reportError(directive, 20, 5) def misra_20_7(self, data): def find_string_concat(exp, arg, directive_args): # Handle concatenation of string literals, e.g.: # #define MACRO(A, B) (A " " B) # Addon should not report errors for both macro arguments. arg_pos = exp.find(arg, 0) need_check = False skip_next = False state_in_string = False pos_search = arg_pos + 1 directive_args = [a.strip() for a in directive_args if a != arg] arg = arg.strip() while pos_search < len(exp): if exp[pos_search] == '"': if state_in_string: state_in_string = False else: state_in_string = True pos_search += 1 elif exp[pos_search].isalnum(): word = "" while pos_search < len(exp) and exp[pos_search].isalnum(): word += exp[pos_search] pos_search += 1 if word == arg: pos_search += 1 elif word in directive_args: skip_next = True break elif exp[pos_search] == ' ': pos_search += 1 elif state_in_string: pos_search += 1 else: need_check = True break return need_check, skip_next for directive in data.directives: d = Define(directive) exp = '(' + d.expansionList + ')' skip_next = False for arg in d.args: if skip_next: _, skip_next = find_string_concat(exp, arg, d.args) continue need_check, skip_next = find_string_concat(exp, arg, d.args) if not need_check: continue pos = 0 while pos < len(exp): pos = exp.find(arg, pos) if pos < 0: break # is 'arg' used at position pos pos1 = pos - 1 pos2 = pos + len(arg) pos = pos2 if pos1 >= 0 and (isalnum(exp[pos1]) or exp[pos1] == '_'): continue if pos2 < len(exp) and (isalnum(exp[pos2]) or exp[pos2] == '_'): continue while pos1 >= 0 and exp[pos1] == ' ': pos1 -= 1 if exp[pos1] == '#': continue if exp[pos1] not in '([,.': self.reportError(directive, 20, 7) break while pos2 < len(exp) and exp[pos2] == ' ': pos2 += 1 if pos2 < len(exp) and exp[pos2] not in ')]#,': self.reportError(directive, 20, 7) break def misra_20_8(self, cfg): for cond in cfg.preprocessor_if_conditions: #print(cond) if cond.result and cond.result not in (0,1): self.reportError(cond, 20, 8) def misra_20_9(self, cfg): for cond in cfg.preprocessor_if_conditions: if cond.E is None: continue defined = [] for directive in cfg.directives: if directive.file == cond.file and directive.linenr == cond.linenr: for name in re.findall(r'[^_a-zA-Z0-9]defined[ ]*\([ ]*([_a-zA-Z0-9]+)[ ]*\)', directive.str): defined.append(name) for name in re.findall(r'[^_a-zA-Z0-9]defined[ ]*([_a-zA-Z0-9]+)', directive.str): defined.append(name) break for s in cond.E.split(' '): if (s[0] >= 'A' and s[0] <= 'Z') or (s[0] >= 'a' and s[0] <= 'z'): if isKeyword(s): continue if s in defined: continue self.reportError(cond, 20, 9) def misra_20_10(self, data): for directive in data.directives: d = Define(directive) if d.expansionList.find('#') >= 0: self.reportError(directive, 20, 10) def misra_20_11(self, cfg): for directive in cfg.directives: d = Define(directive) for arg in d.args: res = re.search(r'[^#]#[ ]*%s[ ]*##' % arg, ' ' + d.expansionList) if res: self.reportError(directive, 20, 11) def misra_20_12(self, cfg): def _is_hash_hash_op(expansion_list, arg): return re.search(r'##[ ]*%s[^a-zA-Z0-9_]' % arg, expansion_list) or \ re.search(r'[^a-zA-Z0-9_]%s[ ]*##' % arg, expansion_list) def _is_other_op(expansion_list, arg): pos = expansion_list.find(arg) while pos >= 0: pos1 = pos - 1 pos2 = pos + len(arg) pos = expansion_list.find(arg, pos2) if isalnum(expansion_list[pos1]) or expansion_list[pos1] == '_': continue if isalnum(expansion_list[pos2]) or expansion_list[pos2] == '_': continue while expansion_list[pos1] == ' ': pos1 = pos1 - 1 if expansion_list[pos1] == '#': continue while expansion_list[pos2] == ' ': pos2 = pos2 + 1 if expansion_list[pos2] == '#': continue return True return False def _is_arg_macro_usage(directive, arg): for macro_usage in cfg.macro_usage: if macro_usage.file == directive.file and macro_usage.linenr == directive.linenr: for macro_usage_arg in cfg.macro_usage: if macro_usage_arg == macro_usage: continue if (macro_usage.usefile == macro_usage_arg.usefile and macro_usage.uselinenr == macro_usage_arg.uselinenr and macro_usage.usecolumn == macro_usage_arg.usecolumn): # TODO: check arg better return True return False for directive in cfg.directives: define = Define(directive) expansion_list = '(%s)' % define.expansionList for arg in define.args: if not _is_hash_hash_op(expansion_list, arg): continue if not _is_other_op(expansion_list, arg): continue if _is_arg_macro_usage(directive, arg): self.reportError(directive, 20, 12) break def misra_20_13(self, data): dir_pattern = re.compile(r'#[ ]*([^ (<]*)') for directive in data.directives: dir = directive.str mo = dir_pattern.match(dir) if mo: dir = mo.group(1) if dir not in ['define', 'elif', 'else', 'endif', 'error', 'if', 'ifdef', 'ifndef', 'include', 'pragma', 'undef', 'warning']: self.reportError(directive, 20, 13) def misra_20_14(self, data): # stack for #if blocks. contains the #if directive until the corresponding #endif is seen. # the size increases when there are inner #if directives. ifStack = [] for directive in data.directives: if directive.str.startswith('#if ') or directive.str.startswith('#ifdef ') or directive.str.startswith( '#ifndef '): ifStack.append(directive) elif directive.str == '#else' or directive.str.startswith('#elif '): if len(ifStack) == 0: self.reportError(directive, 20, 14) ifStack.append(directive) elif directive.file != ifStack[-1].file: self.reportError(directive, 20, 14) elif directive.str == '#endif': if len(ifStack) == 0: self.reportError(directive, 20, 14) elif directive.file != ifStack[-1].file: self.reportError(directive, 20, 14) ifStack.pop() def misra_21_1(self, data): re_forbidden_macro = re.compile(r'#(?:define|undef) _[_A-Z]+') re_macro_name = re.compile(r'#(?:define|undef) (.+)[ $]') for d in data.directives: # Search for forbidden identifiers m = re.search(re_forbidden_macro, d.str) if m: self.reportError(d, 21, 1) continue # Search standard library identifiers in macro names m = re.search(re_macro_name, d.str) if not m: continue name = m.group(1) if isStdLibId(name, data.standards.c): self.reportError(d, 21, 1) def misra_21_2(self, cfg): for directive in cfg.directives: define = Define(directive) if re.match(r'_+BUILTIN_.*', define.name.upper()): self.reportError(directive, 21, 2) for func in cfg.functions: if isStdLibId(func.name, cfg.standards.c): tok = func.tokenDef if func.tokenDef else func.token self.reportError(tok, 21, 2) def misra_21_3(self, data): for token in data.tokenlist: if isFunctionCall(token) and (token.astOperand1.str in ('malloc', 'calloc', 'realloc', 'free')): self.reportError(token, 21, 3) def misra_21_4(self, data): directive = findInclude(data.directives, '') if directive: self.reportError(directive, 21, 4) def misra_21_5(self, data): directive = findInclude(data.directives, '') if directive: self.reportError(directive, 21, 5) def misra_21_6(self, data): dir_stdio = findInclude(data.directives, '') dir_wchar = findInclude(data.directives, '') if dir_stdio: self.reportError(dir_stdio, 21, 6) if dir_wchar: self.reportError(dir_wchar, 21, 6) def misra_21_7(self, data): for token in data.tokenlist: if isFunctionCall(token) and (token.astOperand1.str in ('atof', 'atoi', 'atol', 'atoll')): self.reportError(token, 21, 7) def misra_21_8(self, data): for token in data.tokenlist: if isFunctionCall(token) and (token.astOperand1.str in ('abort', 'exit', 'getenv')): self.reportError(token, 21, 8) def misra_21_9(self, data): for token in data.tokenlist: if (token.str in ('bsearch', 'qsort')) and token.next and token.next.str == '(': self.reportError(token, 21, 9) def misra_21_10(self, data): directive = findInclude(data.directives, '') if directive: self.reportError(directive, 21, 10) for token in data.tokenlist: if (token.str == 'wcsftime') and token.next and token.next.str == '(': self.reportError(token, 21, 10) def misra_21_11(self, data): directive = findInclude(data.directives, '') if directive: self.reportError(directive, 21, 11) def misra_21_12(self, data): if findInclude(data.directives, ''): for token in data.tokenlist: if token.str == 'fexcept_t' and token.isName: self.reportError(token, 21, 12) if isFunctionCall(token) and (token.astOperand1.str in ( 'feclearexcept', 'fegetexceptflag', 'feraiseexcept', 'fesetexceptflag', 'fetestexcept')): self.reportError(token, 21, 12) def misra_21_14(self, data): # buffers used in strcpy/strlen/etc function calls string_buffers = [] for token in data.tokenlist: if token.str[0] == 's' and isFunctionCall(token.next): name, args = cppcheckdata.get_function_call_name_args(token) if name is None: continue def _get_string_buffers(match, args, argnum): if not match: return [] ret = [] for a in argnum: if a < len(args): arg = args[a] while arg and arg.str in ('.', '::'): arg = arg.astOperand2 if arg and arg.varId != 0 and arg.varId not in ret: ret.append(arg.varId) return ret string_buffers += _get_string_buffers(name == 'strcpy', args, [0, 1]) string_buffers += _get_string_buffers(name == 'strncpy', args, [0, 1]) string_buffers += _get_string_buffers(name == 'strlen', args, [0]) string_buffers += _get_string_buffers(name == 'strcmp', args, [0, 1]) string_buffers += _get_string_buffers(name == 'sprintf', args, [0]) string_buffers += _get_string_buffers(name == 'snprintf', args, [0, 3]) for token in data.tokenlist: if token.str != 'memcmp': continue name, args = cppcheckdata.get_function_call_name_args(token) if name is None: continue if len(args) != 3: continue for arg in args[:2]: if arg.str[-1] == '\"': self.reportError(arg, 21, 14) continue while arg and arg.str in ('.', '::'): arg = arg.astOperand2 if arg and arg.varId and arg.varId in string_buffers: self.reportError(arg, 21, 14) def misra_21_15(self, data): for token in data.tokenlist: if token.str not in ('memcpy', 'memmove', 'memcmp'): continue name, args = cppcheckdata.get_function_call_name_args(token) if name is None: continue if len(args) != 3: continue if args[0].valueType is None or args[1].valueType is None: continue if args[0].valueType.type == args[1].valueType.type: continue if args[0].valueType.type == 'void' or args[1].valueType.type == 'void': continue self.reportError(token, 21, 15) def misra_21_16(self, cfg): for token in cfg.tokenlist: if token.str != 'memcmp': continue name, args = cppcheckdata.get_function_call_name_args(token) if name is None: continue if len(args) != 3: continue for arg in args[:2]: if arg.valueType is None: continue if arg.valueType.pointer > 1: continue if getEssentialTypeCategory(arg) in ('unsigned', 'signed', 'bool'): continue if arg.valueType.isEnum(): continue self.reportError(token, 21, 16) def misra_21_19(self, cfg): for token in cfg.tokenlist: if token.str in ('localeconv', 'getenv', 'setlocale', 'strerror') and simpleMatch(token.next, '('): name, _ = cppcheckdata.get_function_call_name_args(token) if name is None or name != token.str: continue parent = token.next while simpleMatch(parent.astParent, '+'): parent = parent.astParent # x = f() if simpleMatch(parent.astParent, '=') and parent == parent.astParent.astOperand2: lhs = parent.astParent.astOperand1 if lhs and lhs.valueType and lhs.valueType.pointer > 0 and lhs.valueType.constness == 0: self.reportError(token, 21, 19) if token.str == '=': lhs = token.astOperand1 while simpleMatch(lhs, '*') and lhs.astOperand2 is None: lhs = lhs.astOperand1 if not simpleMatch(lhs, '.'): continue while simpleMatch(lhs, '.'): lhs = lhs.astOperand1 if lhs and lhs.variable and simpleMatch(lhs.variable.typeStartToken, 'lconv'): self.reportError(token, 21, 19) def misra_21_20(self, cfg): assigned = {} invalid = [] for token in cfg.tokenlist: # No sophisticated data flow analysis, bail out if control flow is "interrupted" if token.str in ('{', '}', 'break', 'continue', 'return'): assigned = {} invalid = [] continue # When pointer is assigned, remove it from 'assigned' and 'invalid' if token.varId and token.varId > 0 and simpleMatch(token.next, '='): for name in assigned.keys(): while token.varId in assigned[name]: assigned[name].remove(token.varId) while token.varId in invalid: invalid.remove(token.varId) continue # Calling dangerous function if token.str in ('asctime', 'ctime', 'gmtime', 'localtime', 'localeconv', 'getenv', 'setlocale', 'strerror'): name, _ = cppcheckdata.get_function_call_name_args(token) if name and name == token.str: # make assigned pointers invalid for varId in assigned.get(name, ()): if varId not in invalid: invalid.append(varId) # assign pointer parent = token.next while parent.astParent and (parent.astParent.str == '+' or isCast(parent.astParent)): parent = parent.astParent if simpleMatch(parent.astParent, '='): eq = parent.astParent vartok = eq.previous if vartok and vartok.varId and vartok.varId > 0: if name not in assigned: assigned[name] = [vartok.varId] elif vartok.varId not in assigned[name]: assigned[name].append(vartok.varId) continue # taking value of invalid pointer.. if token.astParent and token.varId: if token.varId in invalid: self.reportError(token, 21, 20) def misra_21_21(self, cfg): for token in cfg.tokenlist: if token.str == 'system': name, args = cppcheckdata.get_function_call_name_args(token) if name == 'system' and len(args) == 1: self.reportError(token, 21, 21) def misra_22_5(self, cfg): for token in cfg.tokenlist: if token.isUnaryOp("*") or (token.isBinaryOp() and token.str == '.'): fileptr = token.astOperand1 if fileptr.variable and cppcheckdata.simpleMatch(fileptr.variable.typeStartToken, 'FILE *'): self.reportError(token, 22, 5) def misra_22_7(self, cfg): for eofToken in cfg.tokenlist: if eofToken.str != 'EOF': continue if eofToken.astParent is None or not eofToken.astParent.isComparisonOp: continue if eofToken.astParent.astOperand1 == eofToken: eofTokenSibling = eofToken.astParent.astOperand2 else: eofTokenSibling = eofToken.astParent.astOperand1 while isCast(eofTokenSibling) and eofTokenSibling.valueType and eofTokenSibling.valueType.type and eofTokenSibling.valueType.type == 'int': eofTokenSibling = eofTokenSibling.astOperand2 if eofTokenSibling.astOperand2 else eofTokenSibling.astOperand1 if eofTokenSibling is not None and eofTokenSibling.valueType and eofTokenSibling.valueType and eofTokenSibling.valueType.type in ('bool', 'char', 'short'): self.reportError(eofToken, 22, 7) def misra_22_8(self, cfg): is_zero = False for token in cfg.tokenlist: if simpleMatch(token, 'errno = 0'): is_zero = True if token.str == '(' and not simpleMatch(token.link, ') {'): name, _ = cppcheckdata.get_function_call_name_args(token.previous) if name is None: continue if is_errno_setting_function(name): if not is_zero: self.reportError(token, 22, 8) else: is_zero = False def misra_22_9(self, cfg): errno_is_set = False for token in cfg.tokenlist: if token.str == '(' and not simpleMatch(token.link, ') {'): name, _ = cppcheckdata.get_function_call_name_args(token.previous) if name is None: continue errno_is_set = is_errno_setting_function(name) if errno_is_set and token.str in '{};': errno_is_set = False tok = token.next while tok and tok.str not in ('{','}',';','errno'): tok = tok.next if tok is None or tok.str != 'errno': self.reportError(token, 22, 9) elif (tok.astParent is None) or (not tok.astParent.isComparisonOp): self.reportError(token, 22, 9) def misra_22_10(self, cfg): last_function_call = None for token in cfg.tokenlist: if token.isName and token.next and token.next.str == '(' and not simpleMatch(token.next.link, ') {'): name, _ = cppcheckdata.get_function_call_name_args(token) last_function_call = name if token.str == '}': last_function_call = None if token.str == 'errno' and token.astParent and token.astParent.isComparisonOp: if last_function_call is None: self.reportError(token, 22, 10) elif not is_errno_setting_function(last_function_call): self.reportError(token, 22, 10) def get_verify_expected(self): """Return the list of expected violations in the verify test""" return self.verify_expected def get_verify_actual(self): """Return the list of actual violations in for the verify test""" return self.verify_actual def get_violations(self, violation_type=None): """Return the list of violations for a normal checker run""" if violation_type is None: return self.violations.items() return self.violations[violation_type] def get_violation_types(self): """Return the list of violations for a normal checker run""" return self.violations.keys() def addSuppressedRule(self, ruleNum, fileName=None, lineNumber=None, symbolName=None): """ Add a suppression to the suppressions data structure Suppressions are stored in a dictionary of dictionaries that contains a list of tuples. The first dictionary is keyed by the MISRA rule in hundreds format. The value of that dictionary is a dictionary of filenames. If the value is None then the rule is assumed to be suppressed for all files. If the filename exists then the value of that dictionary contains a list with the scope of the suppression. If the list contains an item of None then the rule is assumed to be suppressed for the entire file. Otherwise the list contains line number, symbol name tuples. For each tuple either line number or symbol name can can be none. """ normalized_filename = None if fileName is not None: normalized_filename = os.path.expanduser(fileName) normalized_filename = os.path.normpath(normalized_filename) if lineNumber is not None or symbolName is not None: line_symbol = (lineNumber, symbolName) else: line_symbol = None # If the rule is not in the dict already then add it if ruleNum not in self.suppressedRules: ruleItemList = [] ruleItemList.append(line_symbol) fileDict = {} fileDict[normalized_filename] = ruleItemList self.suppressedRules[ruleNum] = fileDict # Rule is added. Done. return # Rule existed in the dictionary. Check for # filename entries. # Get the dictionary for the rule number fileDict = self.suppressedRules[ruleNum] # If the filename is not in the dict already add it if normalized_filename not in fileDict: ruleItemList = [] ruleItemList.append(line_symbol) fileDict[normalized_filename] = ruleItemList # Rule is added with a file scope. Done return # Rule has a matching filename. Get the rule item list. # Check the lists of rule items # to see if this (lineNumber, symbolName) combination # or None already exists. ruleItemList = fileDict[normalized_filename] if line_symbol is None: # is it already in the list? if line_symbol not in ruleItemList: ruleItemList.append(line_symbol) else: # Check the list looking for matches matched = False for each in ruleItemList: if each is not None: if (each[0] == line_symbol[0]) and (each[1] == line_symbol[1]): matched = True # Append the rule item if it was not already found if not matched: ruleItemList.append(line_symbol) def isRuleSuppressed(self, file_path, linenr, ruleNum): """ Check to see if a rule is suppressed. :param ruleNum: is the rule number in hundreds format :param file_path: File path of checked location :param linenr: Line number of checked location If the rule exists in the dict then check for a filename If the filename is None then rule is suppressed globally for all files. If the filename exists then look for list of line number, symbol name tuples. If the list is None then the rule is suppressed for the entire file If the list of tuples exists then search the list looking for matching line numbers. Symbol names are currently ignored because they can include regular expressions. TODO: Support symbol names and expression matching. """ ruleIsSuppressed = False # Remove any prefix listed in command arguments from the filename. filename = None if file_path is not None: if self.filePrefix is not None: filename = remove_file_prefix(file_path, self.filePrefix) else: filename = os.path.basename(file_path) if ruleNum in self.suppressedRules: fileDict = self.suppressedRules[ruleNum] # a file name entry of None means that the rule is suppressed # globally if None in fileDict: ruleIsSuppressed = True else: # Does the filename match one of the names in # the file list if filename in fileDict: # Get the list of ruleItems ruleItemList = fileDict[filename] if None in ruleItemList: # Entry of None in the ruleItemList means the rule is # suppressed for all lines in the filename ruleIsSuppressed = True else: # Iterate though the the list of line numbers # and symbols looking for a match of the line # number. Matching the symbol is a TODO: for each in ruleItemList: if each is not None: if each[0] == linenr: ruleIsSuppressed = True return ruleIsSuppressed def isRuleGloballySuppressed(self, rule_num): """ Check to see if a rule is globally suppressed. :param rule_num: is the rule number in hundreds format """ if rule_num not in self.suppressedRules: return False return None in self.suppressedRules[rule_num] def showSuppressedRules(self): """ Print out rules in suppression list sorted by Rule Number """ print("Suppressed Rules List:") outlist = [] for ruleNum in self.suppressedRules: fileDict = self.suppressedRules[ruleNum] for fname in fileDict: ruleItemList = fileDict[fname] for item in ruleItemList: if item is None: item_str = "None" else: item_str = str(item[0]) outlist.append("%s: %s: %s (%d locations suppressed)" % ( float(ruleNum) / 100, fname, item_str, self.suppressionStats.get(ruleNum, 0))) for line in sorted(outlist, reverse=True): print(" %s" % line) def setFilePrefix(self, prefix): """ Set the file prefix to ignore from files when matching suppression files """ self.filePrefix = prefix def setSeverity(self, severity): """ Set the severity for all errors. """ self.severity = severity def setSuppressionList(self, suppressionlist): num1 = 0 num2 = 0 rule_pattern = re.compile(r'([0-9]+).([0-9]+)') strlist = suppressionlist.split(",") # build ignore list for item in strlist: res = rule_pattern.match(item) if res: num1 = int(res.group(1)) num2 = int(res.group(2)) ruleNum = (num1 * 100) + num2 self.addSuppressedRule(ruleNum) def report_config_error(self, location, errmsg): errmsg = 'Because of missing configuration, misra checking is incomplete. There can be false negatives! ' + errmsg cppcheck_severity = 'error' error_id = 'config' if self.settings.verify: self.verify_actual.append('%s:%d %s' % (location.file, location.linenr, error_id)) else: cppcheckdata.reportError(location, cppcheck_severity, errmsg, 'misra', error_id) def reportError(self, location, num1, num2): ruleNum = num1 * 100 + num2 if self.isRuleGloballySuppressed(ruleNum): return if self.settings.verify: self.verify_actual.append('%s:%d %d.%d' % (location.file, location.linenr, num1, num2)) elif self.isRuleSuppressed(location.file, location.linenr, ruleNum): # Error is suppressed. Ignore self.suppressionStats.setdefault(ruleNum, 0) self.suppressionStats[ruleNum] += 1 return else: errorId = 'c2012-' + str(num1) + '.' + str(num2) misra_severity = 'Undefined' cppcheck_severity = 'style' if ruleNum in self.ruleTexts: errmsg = self.ruleTexts[ruleNum].text if self.ruleTexts[ruleNum].misra_severity: misra_severity = self.ruleTexts[ruleNum].misra_severity cppcheck_severity = self.ruleTexts[ruleNum].cppcheck_severity elif len(self.ruleTexts) == 0: if self.ruleText_filename is None: errmsg = 'misra violation (use --rule-texts= to get proper output)' else: errmsg = 'misra violation (rule-texts-file not found: ' + self.ruleText_filename + ')' else: errmsg = 'misra violation %s with no text in the supplied rule-texts-file' % (ruleNum) if self.severity: cppcheck_severity = self.severity this_violation = '{}-{}-{}-{}'.format(location.file, location.linenr, location.column, ruleNum) # If this is new violation then record it and show it. If not then # skip it since it has already been displayed. if this_violation not in self.existing_violations: self.existing_violations.add(this_violation) cppcheckdata.reportError(location, cppcheck_severity, errmsg, 'misra', errorId, misra_severity) if misra_severity not in self.violations: self.violations[misra_severity] = [] self.violations[misra_severity].append('misra-' + errorId) def loadRuleTexts(self, filename): num1 = 0 num2 = 0 appendixA = False Rule_pattern = re.compile(r'^Rule ([0-9]+)\.([0-9]+)') severity_pattern = re.compile(r'.*[ ]*(Advisory|Required|Mandatory)$') xA_Z_pattern = re.compile(r'^[#A-Z].*') a_z_pattern = re.compile(r'^[a-z].*') # Try to detect the file encoding file_stream = None encodings = ['ascii', 'utf-8', 'windows-1250', 'windows-1252'] for e in encodings: try: file_stream = codecs.open(filename, 'r', encoding=e) file_stream.readlines() file_stream.seek(0) except UnicodeDecodeError: file_stream.close() file_stream = None else: break if not file_stream: print('Could not find a suitable codec for "' + filename + '".') print('If you know the codec please report it to the developers so the list can be enhanced.') print('Trying with default codec now and ignoring errors if possible ...') try: file_stream = open(filename, 'rt', errors='ignore') except TypeError: # Python 2 does not support the errors parameter file_stream = open(filename, 'rt') rule = None rule_line_number = 0 for line in file_stream: line = line.strip() if len(line) == 0: continue if not appendixA: if line.find('Appendix A') >= 0 and line.find('Summary of guidelines') >= 10: appendixA = True continue if line.find('Appendix B') >= 0: break # Parse rule declaration. res = Rule_pattern.match(line) if res: rule_line_number = 0 num1 = int(res.group(1)) num2 = int(res.group(2)) rule = Rule(num1, num2) res = severity_pattern.match(line) if res: rule.misra_severity = res.group(1) rule_line_number = 1 continue if rule is None: continue rule_line_number += 1 if rule_line_number == 1: res = severity_pattern.match(line) if res: rule.misra_severity = res.group(1) continue rule_line_number = 2 # Parse beginning of rule text. if not rule.text and xA_Z_pattern.match(line): rule.text = line.strip() self.ruleTexts[rule.num] = rule continue # Parse continuing of rule text. if a_z_pattern.match(line): self.ruleTexts[rule.num].text += ' ' + line.strip() continue rule = None file_stream.close() def verifyRuleTexts(self): """Prints rule numbers without rule text.""" rule_texts_rules = [] for rule_num in self.ruleTexts: rule = self.ruleTexts[rule_num] rule_texts_rules.append(str(rule.num1) + '.' + str(rule.num2)) all_rules = list(getAddonRules() + getCppcheckRules()) missing_rules = list(set(all_rules) - set(rule_texts_rules)) if len(missing_rules) == 0: print("Rule texts are correct.") else: print("Missing rule texts: " + ', '.join(missing_rules)) def printStatus(self, *args, **kwargs): if not self.settings.quiet: print(*args, **kwargs) def executeCheck(self, rule_num, check_function, *args): """Execute check function for a single MISRA rule. :param rule_num: Number of rule in hundreds format :param check_function: Check function to execute :param args: Check function arguments """ if not self.isRuleGloballySuppressed(rule_num): misra_cpp = ( 202, # misra-c2012-2.3 : misra c++2008 0-1-9 203, # misra-c2012-2.3 : misra c++2008 0-1-5 402, # misra-c2012-4.2 : misra c++2008 2-3-1 701, # misra-c2012-7.1 : misra c++2008 2-3-1 702, # misra-c2012-7.2 : misra c++2008 2-13-2 1203, # misra-c2012-12.3 : misra c++2008 5-14-1 1204, # misra-c2012-12.4 : misra c++2008 5-18-1 1305, # misra-c2012-13.5 : misra c++2008 5-19-1 1702, # misra-c2012-17.2 : misra c++2008 7-5-4 1901) # misra-c2012-19.1 : misra c++2008 2-13-3 if (not self.is_cpp) or rule_num in misra_cpp: # log checker errmsg = 'Misra C: %i.%i' % (rule_num // 100, rule_num % 100) cppcheckdata.log_checker(errmsg, 'misra') check_function(*args) def parseDump(self, dumpfile, path_premium_addon=None): def fillVerifyExpected(verify_expected, tok): """Add expected suppressions to verify_expected list.""" rule_re = re.compile(r'[0-9]+\.[0-9]+') if tok.str.startswith('//') and 'TODO' not in tok.str: for word in tok.str[2:].split(' '): if rule_re.match(word) or word == "config": verify_expected.append('%s:%d %s' % (tok.file, tok.linenr, word)) data = cppcheckdata.parsedump(dumpfile) typeBits['CHAR'] = data.platform.char_bit typeBits['SHORT'] = data.platform.short_bit typeBits['INT'] = data.platform.int_bit typeBits['LONG'] = data.platform.long_bit typeBits['LONG_LONG'] = data.platform.long_long_bit typeBits['POINTER'] = data.platform.pointer_bit if self.settings.verify: # Add suppressions from the current file for tok in data.rawTokens: fillVerifyExpected(self.verify_expected, tok) # Add suppressions from the included headers include_re = re.compile(r'^#include [<"]([a-zA-Z0-9]+[a-zA-Z\-_./\\0-9]*)[">]$') dump_dir = os.path.dirname(data.filename) for conf in data.configurations: for directive in conf.directives: m = re.match(include_re, directive.str) if not m: continue header_dump_path = os.path.join(dump_dir, m.group(1) + '.dump') if not os.path.exists(header_dump_path): continue header_data = cppcheckdata.parsedump(header_dump_path) for tok in header_data.rawTokens: fillVerifyExpected(self.verify_expected, tok) else: self.printStatus('Checking ' + dumpfile + '...') self.is_cpp = data.language == 'cpp' for cfgNumber, cfg in enumerate(data.iterconfigurations()): 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) self.executeCheck(203, self.misra_2_3, dumpfile, cfg.typedefInfo) self.executeCheck(204, self.misra_2_4, dumpfile, cfg) self.executeCheck(205, self.misra_2_5, dumpfile, cfg) self.executeCheck(207, self.misra_2_7, cfg) # data.rawTokens is same for all configurations if cfgNumber == 0: self.executeCheck(301, self.misra_3_1, data.rawTokens) self.executeCheck(302, self.misra_3_2, data.rawTokens) self.executeCheck(401, self.misra_4_1, data.rawTokens) self.executeCheck(402, self.misra_4_2, data.rawTokens) self.executeCheck(501, self.misra_5_1, cfg) self.executeCheck(502, self.misra_5_2, cfg) self.executeCheck(504, self.misra_5_4, cfg) self.executeCheck(505, self.misra_5_5, cfg) self.executeCheck(506, self.misra_5_6, dumpfile, cfg.typedefInfo) self.executeCheck(507, self.misra_5_7, dumpfile, cfg) self.executeCheck(508, self.misra_5_8, dumpfile, cfg) self.executeCheck(509, self.misra_5_9, dumpfile, cfg) self.executeCheck(601, self.misra_6_1, cfg) self.executeCheck(602, self.misra_6_2, cfg) if cfgNumber == 0: self.executeCheck(701, self.misra_7_1, data.rawTokens) self.executeCheck(702, self.misra_7_2, cfg) if cfgNumber == 0: self.executeCheck(703, self.misra_7_3, data.rawTokens) self.executeCheck(704, self.misra_7_4, cfg) self.executeCheck(801, self.misra_8_1, cfg) if cfgNumber == 0: self.executeCheck(802, self.misra_8_2, cfg, data.rawTokens) self.executeCheck(804, self.misra_8_4, cfg) self.executeCheck(805, self.misra_8_5, dumpfile, cfg) self.executeCheck(806, self.misra_8_6, dumpfile, cfg) self.executeCheck(807, self.misra_8_7, dumpfile, cfg) self.executeCheck(808, self.misra_8_8, cfg) self.executeCheck(809, self.misra_8_9, cfg) self.executeCheck(810, self.misra_8_10, cfg) self.executeCheck(811, self.misra_8_11, cfg) self.executeCheck(812, self.misra_8_12, cfg) if cfgNumber == 0: self.executeCheck(814, self.misra_8_14, data.rawTokens) self.executeCheck(902, self.misra_9_2, cfg) self.executeCheck(903, self.misra_9_3, cfg) self.executeCheck(904, self.misra_9_4, cfg) if cfgNumber == 0: self.executeCheck(905, self.misra_9_5, cfg, data.rawTokens) if not path_premium_addon: self.executeCheck(1001, self.misra_10_1, cfg) self.executeCheck(1002, self.misra_10_2, cfg) self.executeCheck(1003, self.misra_10_3, cfg) self.executeCheck(1004, self.misra_10_4, cfg) self.executeCheck(1005, self.misra_10_5, cfg) self.executeCheck(1006, self.misra_10_6, cfg) self.executeCheck(1007, self.misra_10_7, cfg) self.executeCheck(1008, self.misra_10_8, cfg) self.executeCheck(1101, self.misra_11_1, cfg) self.executeCheck(1102, self.misra_11_2, cfg) self.executeCheck(1103, self.misra_11_3, cfg) self.executeCheck(1104, self.misra_11_4, cfg) self.executeCheck(1105, self.misra_11_5, cfg) self.executeCheck(1106, self.misra_11_6, cfg) self.executeCheck(1107, self.misra_11_7, cfg) self.executeCheck(1108, self.misra_11_8, cfg) self.executeCheck(1109, self.misra_11_9, cfg) if cfgNumber == 0: self.executeCheck(1201, self.misra_12_1_sizeof, data.rawTokens) self.executeCheck(1201, self.misra_12_1, cfg) self.executeCheck(1202, self.misra_12_2, cfg) self.executeCheck(1203, self.misra_12_3, cfg) self.executeCheck(1204, self.misra_12_4, cfg) self.executeCheck(1301, self.misra_13_1, cfg) self.executeCheck(1303, self.misra_13_3, cfg) self.executeCheck(1304, self.misra_13_4, cfg) self.executeCheck(1305, self.misra_13_5, cfg) self.executeCheck(1306, self.misra_13_6, cfg) self.executeCheck(1401, self.misra_14_1, cfg) self.executeCheck(1402, self.misra_14_2, cfg) self.executeCheck(1404, self.misra_14_4, cfg) self.executeCheck(1501, self.misra_15_1, cfg) self.executeCheck(1502, self.misra_15_2, cfg) self.executeCheck(1503, self.misra_15_3, cfg) self.executeCheck(1504, self.misra_15_4, cfg) self.executeCheck(1505, self.misra_15_5, cfg) if cfgNumber == 0: self.executeCheck(1506, self.misra_15_6, data.rawTokens) self.executeCheck(1507, self.misra_15_7, cfg) self.executeCheck(1601, self.misra_16_1, cfg) self.executeCheck(1602, self.misra_16_2, cfg) if cfgNumber == 0: self.executeCheck(1603, self.misra_16_3, data.rawTokens) self.executeCheck(1604, self.misra_16_4, cfg) self.executeCheck(1605, self.misra_16_5, cfg) self.executeCheck(1606, self.misra_16_6, cfg) self.executeCheck(1607, self.misra_16_7, cfg) self.executeCheck(1701, self.misra_17_1, cfg) self.executeCheck(1702, self.misra_17_2, cfg) self.executeCheck(1703, self.misra_17_3, cfg) self.misra_config(cfg) if cfgNumber == 0: self.executeCheck(1706, self.misra_17_6, data.rawTokens) self.executeCheck(1707, self.misra_17_7, cfg) self.executeCheck(1708, self.misra_17_8, cfg) self.executeCheck(1804, self.misra_18_4, cfg) self.executeCheck(1805, self.misra_18_5, cfg) self.executeCheck(1807, self.misra_18_7, cfg) self.executeCheck(1808, self.misra_18_8, cfg) self.executeCheck(1902, self.misra_19_2, cfg) self.executeCheck(2001, self.misra_20_1, cfg) self.executeCheck(2002, self.misra_20_2, cfg) self.executeCheck(2003, self.misra_20_3, cfg) self.executeCheck(2004, self.misra_20_4, cfg) self.executeCheck(2005, self.misra_20_5, cfg) self.executeCheck(2007, self.misra_20_7, cfg) self.executeCheck(2008, self.misra_20_8, cfg) self.executeCheck(2009, self.misra_20_9, cfg) self.executeCheck(2010, self.misra_20_10, cfg) self.executeCheck(2011, self.misra_20_11, cfg) self.executeCheck(2012, self.misra_20_12, cfg) self.executeCheck(2013, self.misra_20_13, cfg) self.executeCheck(2014, self.misra_20_14, cfg) self.executeCheck(2101, self.misra_21_1, cfg) self.executeCheck(2102, self.misra_21_2, cfg) self.executeCheck(2103, self.misra_21_3, cfg) self.executeCheck(2104, self.misra_21_4, cfg) self.executeCheck(2105, self.misra_21_5, cfg) self.executeCheck(2106, self.misra_21_6, cfg) self.executeCheck(2107, self.misra_21_7, cfg) self.executeCheck(2108, self.misra_21_8, cfg) self.executeCheck(2109, self.misra_21_9, cfg) self.executeCheck(2110, self.misra_21_10, cfg) self.executeCheck(2111, self.misra_21_11, cfg) self.executeCheck(2112, self.misra_21_12, cfg) self.executeCheck(2114, self.misra_21_14, cfg) self.executeCheck(2115, self.misra_21_15, cfg) self.executeCheck(2116, self.misra_21_16, cfg) self.executeCheck(2119, self.misra_21_19, cfg) self.executeCheck(2120, self.misra_21_20, cfg) self.executeCheck(2121, self.misra_21_21, cfg) # 22.4 is already covered by Cppcheck writeReadOnlyFile self.executeCheck(2205, self.misra_22_5, cfg) self.executeCheck(2207, self.misra_22_7, cfg) self.executeCheck(2208, self.misra_22_8, cfg) self.executeCheck(2209, self.misra_22_9, cfg) self.executeCheck(2210, self.misra_22_10, cfg) def read_ctu_info_line(self, line): if not line.startswith('{'): return None try: ctu_info = json.loads(line) except json.decoder.JSONDecodeError: return None if 'summary' not in ctu_info: return None if 'data' not in ctu_info: return None return ctu_info def analyse_ctu_info(self, ctu_info_files): all_typedef_info = {} all_tagname_info = {} all_macro_info = {} all_external_identifiers_decl = {} all_external_identifiers_def = {} all_internal_identifiers = {} all_local_identifiers = {} all_usage_files = {} from cppcheckdata import Location def is_different_location(loc1, loc2): return loc1['file'] != loc2['file'] or loc1['line'] != loc2['line'] def is_different_file(loc1, loc2): return loc1['file'] != loc2['file'] try: for filename in ctu_info_files: for line in open(filename, 'rt'): s = self.read_ctu_info_line(line) if s is None: continue summary_type = s.get('summary', '') summary_data = s.get('data', None) if summary_type == 'MisraTypedefInfo': for new_typedef_info in summary_data: key = new_typedef_info['name'] existing_typedef_info = all_typedef_info.get(key, None) if existing_typedef_info: if is_different_location(existing_typedef_info, new_typedef_info): self.reportError(Location(existing_typedef_info), 5, 6) self.reportError(Location(new_typedef_info), 5, 6) else: existing_typedef_info['used'] = existing_typedef_info['used'] or new_typedef_info['used'] else: all_typedef_info[key] = new_typedef_info if summary_type == 'MisraTagName': for new_tagname_info in summary_data: key = new_tagname_info['name'] existing_tagname_info = all_tagname_info.get(key, None) if existing_tagname_info: if is_different_location(existing_tagname_info, new_tagname_info): self.reportError(Location(existing_tagname_info), 5, 7) self.reportError(Location(new_tagname_info), 5, 7) else: existing_tagname_info['used'] = existing_tagname_info['used'] or new_tagname_info['used'] else: all_tagname_info[key] = new_tagname_info if summary_type == 'MisraMacro': for new_macro in summary_data: key = new_macro['name'] existing_macro = all_macro_info.get(key, None) if existing_macro: existing_macro['used'] = existing_macro['used'] or new_macro['used'] else: all_macro_info[key] = new_macro if summary_type == 'MisraExternalIdentifiers': for s in sorted(summary_data, key=lambda d: "%s %s %s" %(d['file'],d['line'], d['column'] )): is_declaration = s['decl'] if is_declaration: all_external_identifiers = all_external_identifiers_decl else: all_external_identifiers = all_external_identifiers_def name = s['name'] if name in all_external_identifiers: if is_declaration and is_different_location(s, all_external_identifiers[name]): self.reportError(Location(s), 8, 5) self.reportError(Location(all_external_identifiers[name]), 8, 5) elif is_different_file(s, all_external_identifiers[name]): self.reportError(Location(s), 8, 6) self.reportError(Location(all_external_identifiers[name]), 8, 6) all_external_identifiers[name] = s if summary_type == 'MisraInternalIdentifiers': for s in summary_data: if s['name'] in all_internal_identifiers: if not s['inlinefunc'] or s['file'] != all_internal_identifiers[s['name']]['file']: self.reportError(Location(s), 5, 9) self.reportError(Location(all_internal_identifiers[s['name']]), 5, 9) all_internal_identifiers[s['name']] = s if summary_type == 'MisraLocalIdentifiers': for s in summary_data: all_local_identifiers[s['name']] = s if summary_type == 'MisraUsage': for s in summary_data: if s['name'] in all_usage_files: all_usage_files[s['name']].append(s['file']) else: all_usage_files[s['name']] = [s['file']] except FileNotFoundError: return unused_typedefs = [tdi for tdi in all_typedef_info.values() if not tdi['used']] for tdi in unused_typedefs: self.reportError(Location(tdi), 2, 3) unused_tags = [tag for tag in all_tagname_info.values() if not tag['used']] for tag in unused_tags: self.reportError(Location(tag), 2, 4) unused_macros = [m for m in all_macro_info.values() if not m['used']] for m in unused_macros: self.reportError(Location(m), 2, 5) all_external_identifiers = all_external_identifiers_decl all_external_identifiers.update(all_external_identifiers_def) for name, external_identifier in all_external_identifiers.items(): internal_identifier = all_internal_identifiers.get(name) if internal_identifier: self.reportError(Location(internal_identifier), 5, 8) self.reportError(Location(external_identifier), 5, 8) local_identifier = all_local_identifiers.get(name) if local_identifier: self.reportError(Location(local_identifier), 5, 8) self.reportError(Location(external_identifier), 5, 8) for name, files in all_usage_files.items(): #print('%s:%i' % (name, count)) count = len(files) if count != 1 or name not in all_external_identifiers_def: continue if files[0] != Location(all_external_identifiers_def[name]).file: continue if name in all_external_identifiers: self.reportError(Location(all_external_identifiers[name]), 8, 7) RULE_TEXTS_HELP = '''Path to text file of MISRA rules If you have the tool 'pdftotext' you might be able to generate this textfile with such command: pdftotext MISRA_C_2012.pdf MISRA_C_2012.txt Otherwise you can more or less copy/paste the chapter Appendix A Summary of guidelines from the MISRA pdf. You can buy the MISRA pdf from http://www.misra.org.uk/ Format: <..arbitrary text..> Appendix A Summary of guidelines Rule 1.1 Required Rule text for 1.1 continuation of rule text for 1.1 Rule 1.2 Mandatory Rule text for 1.2 continuation of rule text for 1.2 <...> ''' SUPPRESS_RULES_HELP = '''MISRA rules to suppress (comma-separated) For example, if you'd like to suppress rules 15.1, 11.3, and 20.13, run: python misra.py --suppress-rules 15.1,11.3,20.13 ... ''' def get_args_parser(): """Generates list of command-line arguments acceptable by misra.py script.""" parser = cppcheckdata.ArgumentParser() parser.add_argument("--rule-texts", type=str, help=RULE_TEXTS_HELP) parser.add_argument("--verify-rule-texts", help="Verify that all supported rules texts are present in given file and exit.", action="store_true") parser.add_argument("--suppress-rules", type=str, help=SUPPRESS_RULES_HELP) parser.add_argument("--no-summary", help="Hide summary of violations", action="store_true") parser.add_argument("--show-suppressed-rules", help="Print rule suppression list", action="store_true") parser.add_argument("-P", "--file-prefix", type=str, help="Prefix to strip when matching suppression file rules") parser.add_argument("-generate-table", help=argparse.SUPPRESS, action="store_true") parser.add_argument("-verify", help=argparse.SUPPRESS, action="store_true") parser.add_argument("--severity", type=str, help="Set a custom severity string, for example 'error' or 'warning'. ") return parser def main(): parser = get_args_parser() args = parser.parse_args() settings = MisraSettings(args) checker = MisraChecker(settings) checker.path_premium_addon = cppcheckdata.get_path_premium_addon() if args.generate_table: generateTable() sys.exit(0) if args.rule_texts: filename = os.path.expanduser(args.rule_texts) filename = os.path.normpath(filename) checker.ruleText_filename = filename if os.path.isfile(filename): checker.loadRuleTexts(filename) if args.verify_rule_texts: checker.verifyRuleTexts() sys.exit(0) else: if args.verify_rule_texts: print('Fatal error: file is not found: ' + filename) sys.exit(1) if args.verify_rule_texts and not args.rule_texts: print("Error: Please specify rule texts file with --rule-texts=") sys.exit(1) if args.suppress_rules: checker.setSuppressionList(args.suppress_rules) if args.file_prefix: checker.setFilePrefix(args.file_prefix) dump_files, ctu_info_files = cppcheckdata.get_files(args) if (not dump_files) and (not ctu_info_files): if not args.quiet: print("No input files.") sys.exit(0) if args.severity: checker.setSeverity(args.severity) for item in dump_files: checker.parseDump(item,checker.path_premium_addon) if settings.verify: verify_expected = checker.get_verify_expected() verify_actual = checker.get_verify_actual() exitCode = 0 for expected in verify_expected: if expected not in verify_actual: print('Expected but not seen: ' + expected) exitCode = 1 for actual in verify_actual: if actual not in verify_expected: print('Not expected: ' + actual) exitCode = 1 # Existing behavior of verify mode is to exit # on the first un-expected output. # TODO: Is this required? or can it be moved to after # all input files have been processed if exitCode != 0: sys.exit(exitCode) checker.analyse_ctu_info(ctu_info_files) if settings.verify: sys.exit(exitCode) number_of_violations = len(checker.get_violations()) if number_of_violations > 0: if settings.show_summary: print("\nMISRA rules violations found:\n\t%s\n" % ( "\n\t".join(["%s: %d" % (viol, len(checker.get_violations(viol))) for viol in checker.get_violation_types()]))) rules_violated = {} for severity, ids in checker.get_violations(): for misra_id in ids: rules_violated[misra_id] = rules_violated.get(misra_id, 0) + 1 print("MISRA rules violated:") convert = lambda text: int(text) if text.isdigit() else 0 misra_sort = lambda key: [convert(c) for c in re.split(r'[\.-]([0-9]*)', key)] for misra_id in sorted(rules_violated.keys(), key=misra_sort): res = re.match(r'misra-c2012-([0-9]+)\\.([0-9]+)', misra_id) if res is None: num = 0 else: num = int(res.group(1)) * 100 + int(res.group(2)) severity = '-' if num in checker.ruleTexts: severity = checker.ruleTexts[num].cppcheck_severity print("\t%15s (%s): %d" % (misra_id, severity, rules_violated[misra_id])) if args.show_suppressed_rules: checker.showSuppressedRules() if __name__ == '__main__': main() sys.exit(cppcheckdata.EXIT_CODE) cppcheck-2.17.1/addons/misra_9.py000066400000000000000000000525701475760761100165760ustar00rootroot00000000000000# Holds information about an array, struct or union's element definition. class ElementDef: def __init__(self, elementType, name, valueType, dimensions = None): self.elementType = elementType # 'array', 'record' or 'value' self.name = str(name) self.valueType = valueType self.children = [] self.dimensions = dimensions self.parent = None self.isDesignated = False self.isPositional = False self.numInits = 0 self.childIndex = -1 self.flexibleToken = None self.isFlexible = False self.structureViolationToken = None def __repr__(self): inits = "" if self.isPositional: inits += 'P' if self.isDesignated: inits += 'D' if not (self.isPositional or self.isDesignated) and self.numInits == 0: inits += '_' if self.numInits > 1: inits += str(self.numInits) attrs = ["childIndex", "elementType", "valueType"] return "{}({}, {}, {})".format( "ElementDef", self.getLongName(), inits, ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) @property def isArray(self): return self.elementType == 'array' @property def isRecord(self): return self.elementType == 'record' @property def isValue(self): return self.elementType == 'value' def getLongName(self): return self.parent.getLongName() + "." + self.name if self.parent else self.name def getInitDump(self): t = [] if self.isPositional: t.append('P') if self.isDesignated: t.append('D') if self.numInits == 0: t.append('_') if self.numInits > 1: t.append(str(self.numInits)) myDump = "".join(t) if len(self.children): childDumps = [] for c in self.children: childDumps.append(c.getInitDump()) if self.structureViolationToken is not None: myDump += "!" myDump += "{ " + ", ".join(childDumps) + " }" return myDump def addChild(self, child): self.children.append(child) child.parent = self def getNextChild(self): self.childIndex += 1 return self.getChildByIndex(self.childIndex) def getChildByIndex(self, index): if self.isFlexible: while len(self.children) <= index: createChild(self, self.flexibleToken, len(self.children), None) return self.children[index] if 0 <= index < len(self.children) else None def getChildByName(self, name): for c in self.children: if c.name == name: return c return None def getNextValueElement(self, root): current = self while current != root: if not current.parent: return None # Get next index of parent i = current.parent.children.index(current) + 1 # Next index of parent exists if i < len(current.parent.children): current = current.parent.children[i] return current.getFirstValueElement() # Next index of parent doesn't exist. Move up current = current.parent return None def getFirstValueElement(self): current = self # Move to first child as long as children exists next_child = current.getChildByIndex(0) while next_child: current = next_child next_child = current.getChildByIndex(0) return current def getLastValueElement(self): current = self # Move to last child as long as children exists while len(current.children) > 0: current = current.children[-1] return current def getChildByValueElement(self, ed): potentialChild = ed while potentialChild and potentialChild not in self.children: potentialChild = potentialChild.parent return self.children[self.children.index(potentialChild)] if potentialChild else None def getEffectiveLevel(self): if self.parent and self.parent.elementType == "array": return self.parent.getEffectiveLevel() + 1 return 0 def setInitialized(self, designated=False, positional=False): if designated: self.isDesignated = True if positional or not designated: self.isPositional = True self.numInits += 1 def initializeChildren(self): for child in self.children: child.setInitialized(positional=True) child.initializeChildren() def unset(self): self.isDesignated = False self.isPositional = False # Unset is always recursive for child in self.children: child.unset() def markStuctureViolation(self, token): if self.name == '->': self.children[0].markStuctureViolation(token) elif not self.structureViolationToken: self.structureViolationToken = token def markAsFlexibleArray(self, token): self.flexibleToken = token self.isFlexible = True def markAsCurrent(self): if self.parent: if self.name == '<-': self.parent.childIndex = self.parent.children.index(self.children[0]) else: self.parent.childIndex = self.parent.children.index(self) self.parent.markAsCurrent() def isAllChildrenSet(self): myself = len(self.children) == 0 and (self.isDesignated or self.isPositional) mychildren = len(self.children) > 0 and all([child.isAllChildrenSet() for child in self.children]) return myself or mychildren def isAllSet(self): return all([child.isPositional or child.isDesignated for child in self.children]) def isOnlyDesignated(self): return all([not child.isPositional for child in self.children]) def isMisra92Compliant(self): return self.structureViolationToken is None and all([child.isMisra92Compliant() for child in self.children]) def isMisra93Compliant(self): if self.elementType == 'array': result = self.isAllChildrenSet() or \ ((self.isAllSet() or self.isOnlyDesignated()) and all([not (child.isDesignated or child.isPositional) or child.isMisra93Compliant() for child in self.children])) return result if self.elementType == 'record': result = all([child.isMisra93Compliant() for child in self.children]) return result return True def isMisra94Compliant(self): return self.numInits <= 1 and all([child.isMisra94Compliant() for child in self.children]) def isMisra95Compliant(self): return not self.isFlexible or all([not child.isDesignated for child in self.children]) # Parses the initializers and update the ElementDefs status accordingly class InitializerParser: def __init__(self): self.token = None self.root = None self.ed = None self.rootStack = [] def parseInitializer(self, root, token): self.root = root self.token = token dummyRoot = ElementDef('array', '->', self.root.valueType) dummyRoot.children = [self.root] self.rootStack = [] self.root = dummyRoot self.ed = self.root.getFirstValueElement() isFirstElement = False isDesignated = False while self.token: if self.token.str == ',': self.token = self.token.astOperand1 isFirstElement = False # Designated initializer ( [2]=... or .name=... ) elif self.token.isAssignmentOp and not self.token.valueType: self.popFromStackIfExitElement() self.ed = getElementByDesignator(self.root, self.token.astOperand1) if self.ed: # Update root self.pushToRootStackAndMarkAsDesignated() # Make sure ed points to valueElement self.ed = self.ed.getFirstValueElement() self.token = self.token.astOperand2 isFirstElement = False isDesignated = True elif self.token.isString and self.ed and self.ed.isArray: self.ed.setInitialized(isDesignated) if self.token == self.token.astParent.astOperand1 and self.token.astParent.astOperand2: self.token = self.token.astParent.astOperand2 self.ed.markAsCurrent() self.ed = self.root.getNextChild() else: self.unwindAndContinue() continue elif self.token.str == '{': nextChild = self.root.getNextChild() if self.root is not None else None if nextChild: if nextChild.isArray or nextChild.isRecord: nextChild.unset() nextChild.setInitialized(isDesignated) self.ed = nextChild.getFirstValueElement() isDesignated = False elif nextChild.valueType is None: # No type information available - unable to check structure - assume correct initialization nextChild.setInitialized(isDesignated) self.unwindAndContinue() continue elif self.token.astOperand1: # Create dummy nextChild to represent excess levels in initializer dummyRoot = ElementDef('array', '<-', self.root.valueType) dummyRoot.parent = self.root dummyRoot.childIndex = 0 dummyRoot.children = [nextChild] nextChild.parent = dummyRoot self.root.markStuctureViolation(self.token) # Fake dummy as nextChild (of current root) nextChild = dummyRoot if nextChild and self.token.astOperand1: self.root = nextChild self.token = self.token.astOperand1 isFirstElement = True else: if self.root: # {} if self.root.name == '<-': self.root.parent.markStuctureViolation(self.token) else: self.root.markStuctureViolation(self.token) self.ed = None self.unwindAndContinue() else: if self.ed and self.ed.isValue: if not isDesignated and len(self.rootStack) > 0 and self.rootStack[-1][1] == self.root: self.rootStack[-1][0].markStuctureViolation(self.token) if isFirstElement and self.token.str == '0' and self.token.next.str == '}': # Zero initializer causes recursive initialization self.root.initializeChildren() elif self.token.isString and self.ed.valueType and self.ed.valueType.pointer > 0: if self.ed.valueType.pointer - self.ed.getEffectiveLevel() == 1: if self.ed.parent != self.root: self.root.markStuctureViolation(self.token) self.ed.setInitialized(isDesignated) elif self.ed.valueType.pointer == self.ed.getEffectiveLevel(): if(self.root.name != '->' and self.ed.parent.parent != self.root) or (self.root.name == '->' and self.root.children[0] != self.ed.parent): self.root.markStuctureViolation(self.token) else: self.ed.parent.setInitialized(isDesignated) self.ed.parent.initializeChildren() else: if self.root is not None and self.ed.parent != self.root: # Check if token is correct value type for self.root.children[?] child = self.root.getChildByValueElement(self.ed) if self.token.valueType: if child.elementType != 'record' or self.token.valueType.type != 'record' or child.valueType.typeScope != self.token.valueType.typeScope: self.root.markStuctureViolation(self.token) self.ed.setInitialized(isDesignated) # Mark all elements up to root with positional or designated # (for complex designators, or missing structure) parent = self.ed.parent while parent and parent != self.root: parent.isDesignated = isDesignated if isDesignated and not parent.isPositional else parent.isDesignated parent.isPositional = not isDesignated if not isDesignated and not parent.isDesignated else parent.isPositional parent = parent.parent isDesignated = False if self.token.isString and self.ed.parent.isArray: self.ed = self.ed.parent self.unwindAndContinue() def pushToRootStackAndMarkAsDesignated(self): new = self.ed.parent if new != self.root: # Mark all elements up to self.root root as designated parent = new while parent and parent != self.root: parent.isDesignated = True parent = parent.parent self.rootStack.append((self.root, new)) new.markAsCurrent() new.childIndex = new.children.index(self.ed) - 1 self.root = new def popFromStackIfExitElement(self): if len(self.rootStack) > 0 and self.rootStack[-1][1] == self.root: old = self.rootStack.pop()[0] old.markAsCurrent() self.root = old def unwindAndContinue(self): while self.token: if self.token.astParent.astOperand1 == self.token and self.token.astParent.astOperand2: if self.ed: if self.token.astParent.astOperand2.str == "{" and self.ed.isDesignated: self.popFromStackIfExitElement() else: self.ed.markAsCurrent() self.ed = self.ed.getNextValueElement(self.root) self.token = self.token.astParent.astOperand2 break self.token = self.token.astParent if self.token.str == '{': if self.root: self.ed = self.root.getLastValueElement() self.ed.markAsCurrent() # Cleanup if root is dummy node representing excess levels in initializer if self.root.name == '<-': self.root.children[0].parent = self.root.parent self.root = self.root.parent if self.token.astParent is None: self.token = None break def misra_9_x(self, data, rule, rawTokens = None): parser = InitializerParser() for variable in data.variables: if variable.nameToken is None: continue nameToken = variable.nameToken # Check if declaration and initialization is # split into two separate statements in ast. if nameToken.next and nameToken.next.isSplittedVarDeclEq: nameToken = nameToken.next.next # Find declarations with initializer assignment eq = nameToken while not eq.isAssignmentOp and eq.astParent: eq = eq.astParent # We are only looking for initializers if not eq.isAssignmentOp or eq.astOperand2.isName: continue if variable.isArray or variable.isClass: ed = getElementDef(nameToken, rawTokens) # No need to check non-arrays if valueType is missing, # since we can't say anything useful about the structure # without it. if ed.valueType is None and not variable.isArray: continue parser.parseInitializer(ed, eq.astOperand2) # print(rule, nameToken.str + '=', ed.getInitDump()) if rule == 902 and not ed.isMisra92Compliant(): self.reportError(nameToken, 9, 2) if rule == 903 and not ed.isMisra93Compliant(): # Do not check when variable is pointer type type_token = variable.nameToken while type_token and type_token.isName: type_token = type_token.previous if type_token and type_token.str == '*': continue self.reportError(nameToken, 9, 3) if rule == 904 and not ed.isMisra94Compliant(): self.reportError(nameToken, 9, 4) if rule == 905 and not ed.isMisra95Compliant(): self.reportError(nameToken, 9, 5) def getElementDef(nameToken, rawTokens = None): if nameToken.variable.isArray: ed = ElementDef("array", nameToken.str, nameToken.valueType) createArrayChildrenDefs(ed, nameToken.astParent, nameToken.variable, rawTokens) elif nameToken.variable.isClass: ed = ElementDef("record", nameToken.str, nameToken.valueType) createRecordChildrenDefs(ed, nameToken.variable) else: ed = ElementDef("value", nameToken.str, nameToken.valueType) return ed def createArrayChildrenDefs(ed, token, var, rawTokens = None): if token and token.str == '[': if rawTokens is not None: foundToken = next((rawToken for rawToken in rawTokens if rawToken.file == token.file and rawToken.linenr == token.linenr and rawToken.column == token.column ), None) if foundToken and foundToken.next and foundToken.next.str == ']': ed.markAsFlexibleArray(token) if (token.astOperand2 is not None) and (token.astOperand2.getKnownIntValue() is not None): for i in range(token.astOperand2.getKnownIntValue()): createChild(ed, token, i, var) else: ed.markAsFlexibleArray(token) def createChild(ed, token, name, var): if token.astParent and token.astParent.str == '[': child = ElementDef("array", name, ed.valueType) createArrayChildrenDefs(child, token.astParent, var) else: if ed.valueType and ed.valueType.type == "record": child = ElementDef("record", name, ed.valueType) createRecordChildrenDefs(child, var) else: child = ElementDef("value", name, ed.valueType) ed.addChild(child) def createRecordChildrenDefs(ed, var): valueType = ed.valueType if not valueType or not valueType.typeScope: return if var is None: return typeToken = var.typeEndToken while typeToken and typeToken.isName: typeToken = typeToken.previous if typeToken and typeToken.str == '*': child = ElementDef("pointer", var.nameToken, var.nameToken.valueType) ed.addChild(child) return child_dict = {} for variable in valueType.typeScope.varlist: if variable is var: continue child = getElementDef(variable.nameToken) child_dict[variable.nameToken] = child for scopes in valueType.typeScope.nestedList: varscope = False if scopes.nestedIn == valueType.typeScope: for variable in valueType.typeScope.varlist: if variable.nameToken and variable.nameToken.valueType and variable.nameToken.valueType.typeScope == scopes: varscope = True break if not varscope: ed1 = ElementDef("record", scopes.Id, valueType) for variable in scopes.varlist: child = getElementDef(variable.nameToken) ed1.addChild(child) child_dict[scopes.bodyStart] = ed1 sorted_keys = sorted(list(child_dict.keys()), key=lambda k: (k.file, k.linenr, k.column)) for _key in sorted_keys: ed.addChild(child_dict[_key]) def getElementByDesignator(ed, token): if not token.str in [ '.', '[' ]: return None while token.str in [ '.', '[' ]: token = token.astOperand1 while ed and not token.isAssignmentOp: token = token.astParent if token.str == '[': if not ed.isArray: ed.markStuctureViolation(token) chIndex = -1 if token.astOperand2 is not None: chIndex = token.astOperand2.getKnownIntValue() elif token.astOperand1 is not None: chIndex = token.astOperand1.getKnownIntValue() ed = ed.getChildByIndex(chIndex) if chIndex is not None else None elif token.str == '.': if not ed.isRecord: ed.markStuctureViolation(token) name = "" if token.astOperand2 is not None: name = token.astOperand2.str elif token.astOperand1 is not None: name = token.astOperand1.str ed = ed.getChildByName(name) return ed cppcheck-2.17.1/addons/naming.py000077500000000000000000000067661475760761100165150ustar00rootroot00000000000000#!/usr/bin/env python3 # # cppcheck addon for naming conventions # # Example usage (variable name must start with lowercase, function name must start with uppercase): # $ cppcheck --dump path-to-src/ # $ python addons/naming.py --var='[a-z].*' --function='[A-Z].*' path-to-src/*.dump # import cppcheckdata import sys import re def validate_regex(expr): try: re.compile(expr) except re.error: print('Error: "{}" is not a valid regular expression.'.format(expr)) sys.exit(1) RE_VARNAME = None RE_CONSTNAME = None RE_PRIVATE_MEMBER_VARIABLE = None RE_FUNCTIONNAME = None for arg in sys.argv[1:]: if arg[:6] == '--var=': RE_VARNAME = arg[6:] validate_regex(RE_VARNAME) elif arg.startswith('--const='): RE_CONSTNAME = arg[arg.find('=')+1:] validate_regex(RE_CONSTNAME) elif arg.startswith('--private-member-variable='): RE_PRIVATE_MEMBER_VARIABLE = arg[arg.find('=')+1:] validate_regex(RE_PRIVATE_MEMBER_VARIABLE) elif arg[:11] == '--function=': RE_FUNCTIONNAME = arg[11:] validate_regex(RE_FUNCTIONNAME) # TODO: bail out on unknown parameter def reportError(token, severity, msg, errorId): cppcheckdata.reportError(token, severity, msg, 'naming', errorId) for arg in sys.argv[1:]: if not arg.endswith('.dump'): continue print('Checking ' + arg + '...') data = cppcheckdata.CppcheckData(arg) for cfg in data.iterconfigurations(): print('Checking %s, config %s...' % (arg, cfg.name)) if RE_VARNAME: for var in cfg.variables: if var.access == 'Private': continue if var.nameToken and not var.isConst: res = re.match(RE_VARNAME, var.nameToken.str) if not res: reportError(var.typeStartToken, 'style', 'Variable ' + var.nameToken.str + ' violates naming convention', 'varname') if RE_CONSTNAME: for var in cfg.variables: if var.access == 'Private': continue if var.nameToken and var.isConst: res = re.match(RE_CONSTNAME, var.nameToken.str) if not res: reportError(var.typeStartToken, 'style', 'Constant ' + var.nameToken.str + ' violates naming convention', 'constname') if RE_PRIVATE_MEMBER_VARIABLE: for var in cfg.variables: if (var.access is None) or var.access != 'Private': continue res = re.match(RE_PRIVATE_MEMBER_VARIABLE, var.nameToken.str) if not res: reportError(var.typeStartToken, 'style', 'Private member variable ' + var.nameToken.str + ' violates naming convention', 'privateMemberVariable') if RE_FUNCTIONNAME: for scope in cfg.scopes: if scope.type == 'Function': function = scope.function if function is not None and function.type in ('Constructor', 'Destructor', 'CopyConstructor', 'MoveConstructor'): continue res = re.match(RE_FUNCTIONNAME, scope.className) if not res: reportError( scope.bodyStart, 'style', 'Function ' + scope.className + ' violates naming convention', 'functionName') sys.exit(cppcheckdata.EXIT_CODE) cppcheck-2.17.1/addons/namingng.config.json000066400000000000000000000010571475760761100206100ustar00rootroot00000000000000{ "RE_VARNAME": ["[a-z]*[a-zA-Z0-9_]*\\Z"], "RE_PRIVATE_MEMBER_VARIABLE": null, "RE_FUNCTIONNAME": ["[a-z0-9A-Z]*\\Z"], "include_guard": { "input": "path", "prefix": "", "suffix": "", "case": "upper", "max_linenr": 5, "RE_HEADERFILE": "[^/].*\\.h\\Z", "required": true }, "var_prefixes": {"uint32_t": "ui32", "int*": "intp"}, "function_prefixes": {"uint16_t": "ui16", "uint32_t": "ui32"}, "skip_one_char_variables": false } cppcheck-2.17.1/addons/namingng.json000066400000000000000000000001371475760761100173420ustar00rootroot00000000000000{ "script":"namingng.py", "args":[ "--configfile=namingng.config.json" ] } cppcheck-2.17.1/addons/namingng.py000077500000000000000000000404551475760761100170330ustar00rootroot00000000000000#!/usr/bin/env python3 # # cppcheck addon for naming conventions # An enhanced version. Configuration is taken from a json file # It supports to check for type-based prefixes in function or variable names. # Aside from include guard naming, include guard presence can also be tested. # # Example usage (variable name must start with lowercase, function name must start with uppercase): # $ cppcheck --dump path-to-src/ # $ python namingng.py test.c.dump # # JSON format: # # { # "RE_VARNAME": ["[a-z]*[a-zA-Z0-9_]*\\Z"], # "RE_PRIVATE_MEMBER_VARIABLE": null, # "RE_FUNCTIONNAME": ["[a-z0-9A-Z]*\\Z"], # "_comment": "comments can be added to the config with underscore-prefixed keys", # "include_guard": { # "input": "path", # "prefix": "GUARD_", # "case": "upper", # "max_linenr": 5, # "RE_HEADERFILE": "[^/].*\\.h\\Z", # "required": true # }, # "var_prefixes": {"uint32_t": "ui32"}, # "function_prefixes": {"uint16_t": "ui16", # "uint32_t": "ui32"} # } # # RE_VARNAME, RE_PRIVATE_MEMBER_VARIABLE and RE_FUNCTIONNAME are regular expressions to cover the basic names # In var_prefixes and function_prefixes there are the variable-type/prefix pairs import cppcheckdata import sys import os import re import json # Auxiliary class class DataStruct: def __init__(self, file, linenr, string, column=0): self.file = file self.linenr = linenr self.str = string self.column = column def reportNamingError(location,message,errorId='namingConvention',severity='style',extra='',column=None): cppcheckdata.reportError(location,severity,message,'namingng',errorId,extra,columnOverride=column) def configError(error,fatal=True): print('config error: %s'%error) if fatal: sys.exit(1) def validateConfigREs(list_or_dict,json_key): have_error = False for item in list_or_dict: try: re.compile(item) except re.error as err: configError("item '%s' of '%s' is not a valid regular expression: %s"%(item,json_key,err),fatal=False) have_error = True continue if not isinstance(list_or_dict,dict): continue # item is actually a dict key; check value value = list_or_dict[item] if (not isinstance(value,list) or len(value) != 2 or not isinstance(value[0],bool) or not isinstance(value[1],str)): configError("item '%s' of '%s' must be an array [bool,string]"%(item,json_key),fatal=False) have_error = True return have_error def loadConfig(configfile): if not os.path.exists(configfile): configError("cannot find config file '%s'"%configfile) try: with open(configfile) as fh: data = json.load(fh) except json.JSONDecodeError as e: configError("error parsing config file as JSON at line %d: %s"%(e.lineno,e.msg)) except Exception as e: configError("error opening config file '%s': %s"%(configfile,e)) if not isinstance(data, dict): configError('config file must contain a JSON object at the top level') # All errors are emitted before bailing out, to make the unit test more # effective. have_error = False # Put config items in a class, so that settings can be accessed using # config.feature class Config: pass config = Config() mapping = { 'file': ('RE_FILE', (list,)), 'namespace': ('RE_NAMESPACE', (list,dict)), 'include_guard': ('include_guard', (dict,)), 'variable': ('RE_VARNAME', (list,dict)), 'variable_prefixes': ('var_prefixes', (dict,), {}), 'private_member': ('RE_PRIVATE_MEMBER_VARIABLE', (list,dict)), 'public_member': ('RE_PUBLIC_MEMBER_VARIABLE', (list,dict)), 'global_variable': ('RE_GLOBAL_VARNAME', (list,dict)), 'function_name': ('RE_FUNCTIONNAME', (list,dict)), 'function_prefixes': ('function_prefixes', (dict,), {}), 'class_name': ('RE_CLASS_NAME', (list,dict)), 'skip_one_char_variables': ('skip_one_char_variables', (bool,)), } # parse defined keys and store as members of config object for key,opts in mapping.items(): json_key = opts[0] req_type = opts[1] default = None if len(opts)<3 else opts[2] value = data.pop(json_key,default) if value is not None and type(value) not in req_type: req_typename = ' or '.join([tp.__name__ for tp in req_type]) got_typename = type(value).__name__ configError('%s must be %s (not %s), or not set'%(json_key,req_typename,got_typename),fatal=False) have_error = True continue # type list implies that this is either a list of REs or a dict with RE keys if list in req_type and value is not None: re_error = validateConfigREs(value,json_key) if re_error: have_error = True setattr(config,key,value) # check remaining keys, only accept underscore-prefixed comments for key,value in data.items(): if key == '' or key[0] != '_': configError("unknown config key '%s'"%key,fatal=False) have_error = True if have_error: sys.exit(1) # pylint: disable-next=no-member - TODO: fix this if config.include_guard: # pylint: disable-next=no-member - TODO: fix this config.include_guard_header_re = config.include_guard.get('RE_HEADERFILE',"[^/].*\\.h\\Z") return config def evalExpr(conf, exp, mockToken, msgType): report_as_error = False msg = msgType + ' ' + mockToken.str + ' violates naming convention' if isinstance(conf, dict): report_as_error = conf[exp][0] msg += ': ' + conf[exp][1] res = re.match(exp,mockToken.str) if bool(res) == report_as_error: reportNamingError(mockToken,msg) def check_include_guard_name(conf,directive): parts = directive.str.split() if len(parts) != 2: msg = 'syntax error' reportNamingError(directive,msg,'syntax') return None,None guard_name = parts[1] guard_column = 1+directive.str.find(guard_name) filename = directive.file if conf.include_guard.get('input','path') == 'basename': filename = os.path.basename(filename) use_case = conf.include_guard.get('case','upper') if use_case == 'upper': filename = filename.upper() elif use_case == 'lower': filename = filename.lower() elif use_case == 'keep': pass # keep filename case as-is else: print("invalid config value for 'case': '%s'"%use_case,file=sys.stderr) sys.exit(1) barename = re.sub('[^A-Za-z0-9]','_',filename).strip('_') expect_guard_name = conf.include_guard.get('prefix','') + barename + conf.include_guard.get('suffix','') if expect_guard_name != guard_name: msg = 'include guard naming violation; %s != %s'%(guard_name,expect_guard_name) reportNamingError(directive,msg,'includeGuardName',column=guard_column) return guard_name,guard_column def check_include_guards(conf,cfg,unguarded_include_files): # Scan for '#ifndef FILE_H' as the first directive, in the first N lines. # Then test whether the next directive #defines the found name. # Various tests are done: # - check include guards for their naming and consistency # - test whether include guards are in place max_linenr = conf.include_guard.get('max_linenr', 5) def report(directive,msg,errorId,severity='style',column=0): reportNamingError(directive,msg,errorId,severity=severity,column=column) def report_pending_ifndef(directive,column): report(directive,'include guard #ifndef is not followed by #define','includeGuardIncomplete',column=column) last_fn = None pending_ifndef = None guard_column = None phase = 0 for directive in cfg.directives: if last_fn != directive.file: if pending_ifndef: report_pending_ifndef(pending_ifndef,guard_column) pending_ifndef = None last_fn = directive.file phase = 0 if phase == -1: # ignore (the remainder of) this file continue if not re.match(conf.include_guard_header_re,directive.file): phase = -1 continue if directive.linenr > max_linenr: if phase == 0 and conf.include_guard.get('required',1): report(directive,'include guard not found before line %d'%max_linenr,'includeGuardMissing') phase = -1 continue if phase == 0: # looking for '#ifndef FILE_H' if not directive.str.startswith('#ifndef'): if conf.include_guard.get('required',1): report(directive,'first preprocessor directive should be include guard #ifndef','includeGuardMissing') phase = -1 continue guard_name,guard_column = check_include_guard_name(conf,directive) if guard_name is None: phase = -1 continue pending_ifndef = directive phase = 1 elif phase == 1: pending_ifndef = None # looking for '#define FILE_H' if not directive.str.startswith('#define'): report(directive,'second preprocessor directive should be include guard #define','includeGuardIncomplete') phase = -1 continue parts = directive.str.split() if len(parts) == 1: report(directive,'syntax error','syntax') phase = -1 continue if guard_name != parts[1]: report(directive,'include guard does not guard; %s != %s'%(guard_name,parts[1]),'includeGuardAwayFromDuty',severity='warning',column=guard_column) unguarded_include_files.remove(directive.file) phase = -1 if pending_ifndef: report_pending_ifndef(pending_ifndef,guard_column) def process(dumpfiles, configfile, cli, debugprint): conf = loadConfig(configfile) for afile in dumpfiles: if not afile[-5:] == '.dump': continue if not cli: print('Checking ' + afile + '...') data = cppcheckdata.CppcheckData(afile) process_data(conf,data,cli,debugprint) def check_file_naming(conf,data): for source_file in data.files: basename = os.path.basename(source_file) good = False for exp in conf.file: good |= bool(re.match(exp, source_file)) good |= bool(re.match(exp, basename)) if not good: mockToken = DataStruct(source_file, 0, basename) reportNamingError(mockToken, 'File name ' + basename + ' violates naming convention') def check_namespace_naming(conf,data): for tk in data.rawTokens: if tk.str != 'namespace': continue mockToken = DataStruct(tk.next.file, tk.next.linenr, tk.next.str, tk.next.column) for exp in conf.namespace: evalExpr(conf.namespace, exp, mockToken, 'Namespace') def check_variable_naming(conf,cfg,debugprint): for var in cfg.variables: if not var.nameToken: continue if var.access in ('Global','Public','Private'): continue prev = var.nameToken.previous varType = prev.str while "*" in varType and len(varType.replace("*", "")) == 0: prev = prev.previous varType = prev.str + varType if debugprint: print("Variable Name: " + str(var.nameToken.str)) print("original Type Name: " + str(var.nameToken.valueType.originalTypeName)) print("Type Name: " + var.nameToken.valueType.type) print("Sign: " + str(var.nameToken.valueType.sign)) print("variable type: " + varType) print("\n") print("\t-- {} {}".format(varType, str(var.nameToken.str))) if conf.skip_one_char_variables and len(var.nameToken.str) == 1: continue if varType in conf.variable_prefixes: prefix = conf.variable_prefixes[varType] if not var.nameToken.str.startswith(prefix): reportNamingError(var.typeStartToken, 'Variable ' + var.nameToken.str + ' violates naming convention', column=var.nameToken.column) mockToken = DataStruct(var.typeStartToken.file, var.typeStartToken.linenr, var.nameToken.str, var.nameToken.column) for exp in conf.variable: evalExpr(conf.variable, exp, mockToken, 'Variable') # Naming check for Global, Private and Public member variables def check_gpp_naming(conf_list,cfg,access,message): for var in cfg.variables: if var.access != access: continue mockToken = DataStruct(var.typeStartToken.file, var.typeStartToken.linenr, var.nameToken.str, var.nameToken.column) for exp in conf_list: evalExpr(conf_list, exp, mockToken, message) def check_function_naming(conf,cfg,debugprint): for token in cfg.tokenlist: if not token.function: continue if token.function.type in ('Constructor', 'Destructor', 'CopyConstructor', 'MoveConstructor'): continue retval = token.previous.str prev = token.previous while "*" in retval and len(retval.replace("*", "")) == 0: prev = prev.previous retval = prev.str + retval if debugprint: print("\t:: {} {}".format(retval, token.function.name)) if retval and retval in conf.function_prefixes: if not token.function.name.startswith(conf.function_prefixes[retval]): reportNamingError(token, 'Function ' + token.function.name + ' violates naming convention', column=token.column) mockToken = DataStruct(token.file, token.linenr, token.function.name, token.column) msgType = 'Function' for exp in conf.function_name: evalExpr(conf.function_name, exp, mockToken, msgType) def check_class_naming(conf,cfg): for fnc in cfg.functions: if fnc.type not in ('Constructor','Destructor'): continue mockToken = DataStruct(fnc.tokenDef.file, fnc.tokenDef.linenr, fnc.name, fnc.tokenDef.column) msgType = 'Class ' + fnc.type for exp in conf.class_name: evalExpr(conf.class_name, exp, mockToken, msgType) def process_data(conf,data,cli,debugprint): if conf.file: check_file_naming(conf,data) if conf.namespace: check_namespace_naming(conf,data) unguarded_include_files = [] if conf.include_guard and conf.include_guard.get('required',1): unguarded_include_files = [fn for fn in data.files if re.match(conf.include_guard_header_re,fn)] for cfg in data.configurations: if not cli: print('Checking config %s...' % cfg.name) if conf.variable: check_variable_naming(conf,cfg,debugprint) if conf.private_member: check_gpp_naming(conf.private_member,cfg,'Private','Private member variable') if conf.public_member: check_gpp_naming(conf.public_member,cfg,'Public','Public member variable') if conf.global_variable: check_gpp_naming(conf.global_variable,cfg,'Global','Global variable') if conf.function_name: check_function_naming(conf,cfg,debugprint) if conf.class_name: check_class_naming(conf,cfg) if conf.include_guard: check_include_guards(conf,cfg,unguarded_include_files) for fn in unguarded_include_files: mockToken = DataStruct(fn,0,os.path.basename(fn)) reportNamingError(mockToken,'Missing include guard','includeGuardMissing') if __name__ == "__main__": parser = cppcheckdata.ArgumentParser() parser.add_argument("--debugprint", action="store_true", default=False, help="Add debug prints") parser.add_argument("--configfile", type=str, default="namingng.config.json", help="Naming check config file") args = parser.parse_args() process(args.dumpfile, args.configfile, args.cli, args.debugprint) sys.exit(0) cppcheck-2.17.1/addons/runaddon.py000066400000000000000000000005361475760761100170400ustar00rootroot00000000000000import cppcheckdata import cppcheck import runpy import sys import os if __name__ == '__main__': addon = sys.argv[1] __addon_name__ = os.path.splitext(os.path.basename(addon))[0] sys.argv.pop(0) runpy.run_path(addon, run_name='__main__') # Run registered checkers cppcheck.runcheckers() sys.exit(cppcheckdata.EXIT_CODE)cppcheck-2.17.1/addons/test/000077500000000000000000000000001475760761100156275ustar00rootroot00000000000000cppcheck-2.17.1/addons/test/__init__.py000066400000000000000000000000001475760761100177260ustar00rootroot00000000000000cppcheck-2.17.1/addons/test/misc-test.cpp000066400000000000000000000014061475760761100202440ustar00rootroot00000000000000// To test: // ~/cppcheck/cppcheck --dump misc-test.cpp && python ../misc.py -verify misc-test.cpp.dump #include #include // Warn about string concatenation in array initializers.. const char *a[] = {"a" "b"}; // stringConcatInArrayInit const char *b[] = {"a","b" "c"}; // stringConcatInArrayInit #define MACRO "MACRO" const char *c[] = { MACRO "text" }; // stringConcatInArrayInit // Function is implicitly virtual class base { virtual void dostuff(int); }; class derived : base { void dostuff(int); // implicitlyVirtual }; // Pass struct to ellipsis function struct {int x;int y;} s; void ellipsis(int x, ...); void foo(std::vector v) { ellipsis(321, s); // ellipsisStructArg ellipsis(321, v[0]); // ellipsisStructArg } cppcheck-2.17.1/addons/test/misra/000077500000000000000000000000001475760761100167425ustar00rootroot00000000000000cppcheck-2.17.1/addons/test/misra/config1.c000066400000000000000000000001501475760761100204300ustar00rootroot00000000000000 struct S { uint32_t some[100]; }; void foo( void ) { if (((S *)0x8000)->some[0] != 0U) { } } cppcheck-2.17.1/addons/test/misra/crash1.c000066400000000000000000000001501475760761100202630ustar00rootroot00000000000000 struct expression { int nargs; struct expression *args[3]; }; struct expression plvar = {0}; cppcheck-2.17.1/addons/test/misra/crash10.c000066400000000000000000000002541475760761100203500ustar00rootroot00000000000000//#12267 extern uint32_t end; //#define KEEP // if uncomment this then wont crash KEEP static const int32_t ptr_to_end = &end; void foo(void) { (void)ptr_to_end; } cppcheck-2.17.1/addons/test/misra/crash11.c000066400000000000000000000000221475760761100203420ustar00rootroot00000000000000// #12651 __arm__ cppcheck-2.17.1/addons/test/misra/crash12.c000066400000000000000000000005011475760761100203450ustar00rootroot00000000000000// 13140 #line 78 "tmp.h" typedef struct { int vara [30] ; int varb [5] ; } S0 ; typedef struct { bool var1 ; S2 var2 ; S2 var3 ; S2 var4 ; short var5 ; short var6 ; S1 var7 ; S1 var8 ; S1 var9 ; S1 var10 ; S1 var11 ; float var12 ; short var13 [ 3 ] ; } S3 ; #line 33 "tmp.c" static const S3 s3 = { 0 , { 0, 0 } , } ;cppcheck-2.17.1/addons/test/misra/crash2.c000066400000000000000000000003051475760761100202660ustar00rootroot00000000000000 // #11793 typedef struct pfmlib_pmu { int flags ; int (*get_event_encoding[10])(void* this, pfmlib_event_desc_t* e); } pfmlib_pmu_t ; pfmlib_pmu_t sparc_ultra3_support = { .flags = 0 }; cppcheck-2.17.1/addons/test/misra/crash3.c000066400000000000000000000007371475760761100203000ustar00rootroot00000000000000 /* This is the representation of the expressions to determine the plural form. */ struct expression { int nargs; /* Number of arguments. */ union { unsigned long int num; /* Number value for `num'. */ struct expression *args[3]; /* Up to three arguments. */ } val; }; struct expression GERMANIC_PLURAL = { .nargs = 2, .val = { .args = { [0] = (struct expression *) &plvar, [1] = (struct expression *) &plone } } }; cppcheck-2.17.1/addons/test/misra/crash4.c000066400000000000000000000002631475760761100202730ustar00rootroot00000000000000 struct ConDesDesc { unsigned Order; unsigned Import; }; // cppcheck-suppress misra-config static ConDesDesc ConDes[CD_TYPE_COUNT] = { { 0, 0 }, { 0, 0 }, }; cppcheck-2.17.1/addons/test/misra/crash5.c000066400000000000000000000006551475760761100203010ustar00rootroot00000000000000 struct _boardcnf_ch { // cppcheck-suppress misra-config uint8_t ddr_density[CS_CNT]; uint64_t ca_swap; }; struct _boardcnf { uint16_t dqdm_dly_r; // cppcheck-suppress misra-config struct _boardcnf_ch ch[DRAM_CH_CNT]; }; static const struct _boardcnf boardcnfs[1] = { { 0x0a0, { { {0x02, 0x02}, 0x00345201 }, { {0x02, 0x02}, 0x00302154 } } }, }; cppcheck-2.17.1/addons/test/misra/crash6.c000066400000000000000000000003031475760761100202700ustar00rootroot00000000000000 typedef struct _tGames { char magicdirname[10]; unsigned int expectedmask; unsigned char pictureorder[3]; } tGames; static const tGames games[1]={ {"Pawn", 1, {0,1,2}} }; cppcheck-2.17.1/addons/test/misra/crash7.c000066400000000000000000000001701475760761100202730ustar00rootroot00000000000000 static const struct id3_frametype wordlist[] = { {0, "Encryption method registration"}, {1, "Popularimeter"}, }; cppcheck-2.17.1/addons/test/misra/crash8.c000066400000000000000000000002531475760761100202760ustar00rootroot00000000000000 struct three_d_filter_t { char name[16]; double elem[2]; }; static three_d_filter_t base_filters[] = { {"Identity", { 1.0, 0.0 } }, {"Echo", { 0.4, 0.0 } } }; cppcheck-2.17.1/addons/test/misra/crash9.c000066400000000000000000000000601475760761100202730ustar00rootroot00000000000000 #line 3 "" typedef int8_t flex_int8_t; cppcheck-2.17.1/addons/test/misra/crash_misra9_parseInitializer.c000066400000000000000000000002311475760761100250640ustar00rootroot00000000000000union { struct { uint8_t a; uint8_t b; } a; } bar; struct foo { uint8_t a; union bar w; uint8_t b; }; struct foo asdf = { 0, {{0,0}}, 1 }; cppcheck-2.17.1/addons/test/misra/misra-ctu-1-test.c000066400000000000000000000025621475760761100221320ustar00rootroot00000000000000// Test with command: // ./cppcheck --enable=information --enable=style --addon=misra --inline-suppr addons/test/misra/misra-ctu-*-test.c #include "misra-ctu-test.h" extern MISRA_2_3_A misra_2_3_a; x = MISRA_2_5_OK_1; // cppcheck-suppress misra-c2012-20.5 #undef MISRA_2_5_OK_3 // cppcheck-suppress misra-c2012-2.3 // cppcheck-suppress misra-c2012-5.6 typedef int MISRA_5_6_VIOLATION; // cppcheck-suppress misra-c2012-5.7 struct misra_5_7_violation_t { int x; // cppcheck-suppress unusedStructMember }; static misra_5_7_violation_t misra_5_7_use_type_1; // #11443 - FP static struct { // no warning uint16_t x; // cppcheck-suppress unusedStructMember } misra_5_7_false_positive_1; // cppcheck-suppress misra-c2012-8.4 // cppcheck-suppress misra-c2012-5.8 int misra_5_8_var1; // cppcheck-suppress misra-c2012-8.4 // cppcheck-suppress misra-c2012-5.8 int misra_5_8_var2; // cppcheck-suppress misra-c2012-5.8 static void misra_5_8_f(void) {} // cppcheck-suppress misra-c2012-5.9 static int misra_5_9_count; // cppcheck-suppress misra-c2012-5.9 static void misra_5_8_foo(void) {} // cppcheck-suppress misra-c2012-8.5 extern int misra_8_5; // cppcheck-suppress misra-c2012-8.4 // cppcheck-suppress misra-c2012-8.6 int32_t misra_8_6 = 1; void misra_8_7_external(void) {} // #12362 void misra_8_7_compliant( void ){} static void misra_8_7_call(void) { misra_8_7_compliant(); }cppcheck-2.17.1/addons/test/misra/misra-ctu-2-test.c000066400000000000000000000030511475760761100221250ustar00rootroot00000000000000// Test with command: // ./cppcheck --enable=information --enable=style --addon=misra --inline-suppr addons/test/misra/misra-ctu-*-test.c #include "misra-ctu-test.h" extern MISRA_2_3_B misra_2_3_b; x = MISRA_2_5_OK_2; // cppcheck-suppress misra-c2012-5.6 typedef int MISRA_5_6_VIOLATION; static MISRA_5_6_VIOLATION misra_5_6_x; // cppcheck-suppress misra-c2012-5.7 struct misra_5_7_violation_t { int x; // cppcheck-suppress unusedStructMember }; static misra_5_7_violation_t misra_5_7_use_type_2; // #11443 - FP static struct { // no warning uint16_t x; // cppcheck-suppress unusedStructMember } misra_5_7_false_positive_2; // cppcheck-suppress misra-c2012-5.8 static int misra_5_8_var1; // cppcheck-suppress misra-c2012-8.4 // cppcheck-suppress misra-c2012-5.8 void misra_5_8_f(void) { // cppcheck-suppress [misra-c2012-5.8, unusedVariable] char misra_5_8_var2; } // cppcheck-suppress misra-c2012-5.9 static int misra_5_9_count; // cppcheck-suppress misra-c2012-5.9 static void misra_5_8_foo(void) {} // cppcheck-suppress misra-c2012-8.5 extern int misra_8_5; // cppcheck-suppress misra-c2012-8.4 // cppcheck-suppress misra-c2012-8.6 int32_t misra_8_6 = 2; int32_t misra_8_6_1; // cppcheck-suppress misra-c2012-8.7 int32_t misra_8_6_1 = 2; // cppcheck-suppress misra-c2012-8.4 // cppcheck-suppress misra-c2012-8.7 void misra_8_7(void) {} static void misra_8_7_caller(void) { misra_8_7(); misra_8_7_external(); } // #12362 typedef void(*misra_8_7_func_ptr)( void ); static const misra_8_7_func_ptr ptrs[] = { misra_8_7_compliant, NULL };cppcheck-2.17.1/addons/test/misra/misra-ctu-test.h000066400000000000000000000007441475760761100220010ustar00rootroot00000000000000 typedef int MISRA_2_3_A; typedef int MISRA_2_3_B; typedef int MISRA_2_3_VIOLATION; // cppcheck-suppress misra-c2012-2.3 // cppcheck-suppress misra-c2012-2.4 struct misra_2_4_violation_t { int x; }; static inline void misra_5_9_exception(void) {} void misra_8_7_external(void); #define MISRA_2_5_OK_1 1 #define MISRA_2_5_OK_2 2 // cppcheck-suppress misra-c2012-2.5 #define MISRA_2_5_VIOLATION 0 // #12362 extern void misra_8_7_compliant( void ); #define MISRA_2_5_OK_3 Thiscppcheck-2.17.1/addons/test/misra/misra-suppressions1-test.c000066400000000000000000000021341475760761100240320ustar00rootroot00000000000000// To test: // ../../cppcheck --suppressions-list=suppressions.txt --dump misra-suppressions*-test.c && python ../misra.py misra-suppressions*-test.c.dump // There should be no violations reported // This needs to stay at line number 7 to make the test pass // If it is changed update suppressions.txt with the new line number // cppcheck-suppress-file misra-c2012-5.2 #include //21.6 extern int misra_5_2_var_hides_var______31x;//8.4 static int misra_5_2_var_hides_var______31y;//5.2 static int misra_5_2_function_hides_var_31x; static void misra_5_2_function_hides_var_31y(void) {}//5.2 static void foo(void) { int i; // cppcheck-suppress-begin misra-c2012-16.4 // cppcheck-suppress misra-c2012-16.6 switch(misra_5_2_func1()) //16.4 16.6 { case 1: { do { for(i = 0; i < 10; i++) { if(misra_5_2_func3()) //17.3 { int misra_5_2_var_hides_var_1____31x; int misra_5_2_var_hides_var_1____31y;//5.2 } } } while(misra_5_2_func2()); //17.3 } } // cppcheck-suppress-end misra-c2012-16.4 } cppcheck-2.17.1/addons/test/misra/misra-suppressions2-test.c000066400000000000000000000012321475760761100240310ustar00rootroot00000000000000// To test: // ../../cppcheck --suppressions-list=suppressions.txt --dump misra-suppressions*-test.c && python ../misra.py misra-suppressions*-test.c.dump // There should be no violations reported // cppcheck-suppress-file misra-c2012-5.2 union misra_5_2_field_hides_field__63x { //19.2 int misra_5_2_field_hides_field__31x; int misra_5_2_field_hides_field__31y;//5.2 }; struct misra_5_2_field_hides_field__63y { //5.2 int misra_5_2_field_hides_field1_31x; int misra_5_2_field_hides_field1_31y;//5.2 }; const char *s41_1 = "\x41g"; // 4.1 8.4 const char *s41_2 = "\x41\x42"; // 8.4 // cppcheck-suppress misra-c2012-5.7 struct misra_5_7_violation_t { int x; }; cppcheck-2.17.1/addons/test/misra/misra-test-avr8.c000066400000000000000000000012331475760761100220530ustar00rootroot00000000000000// To test: // ~/cppcheck/cppcheck--dump -DDUMMY --suppress=uninitvar misra/misra-test-avr8.c --std=c89 --platform=avr8 && python3 ../misra.py -verify misra/misra-test-avr8.c.dump static void misra_10_4(void) { // #10480 const char buf1[1] = {a}; const char c = '0'; x = buf1[0] - c; const char buf2[2] = {x,y}; x = 'a' == buf2[0]; // no-warning typedef struct { int t; char buf[2]; } foo_t; const foo_t cmd = {0}; x = 'b' == cmd.buf[0]; // no-warning const foo_t * pcmd = &cmd; x='c' == pcmd->buf[0]; // no-warning (void)cmd.t; } static void misra_12_2(void) { a = (((uint64_t)0xFF) << 32); } cppcheck-2.17.1/addons/test/misra/misra-test-c11.c000066400000000000000000000016031475760761100215600ustar00rootroot00000000000000// To test: // ~/cppcheck/cppcheck --dump misra/misra-test-c11.c --std=c11 // ~/cppcheck/cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test-c11.c --std=c11 --platform=unix64 && python3 ../misra.py -verify misra/misra-test-c11.c.dump #include typedef unsigned int UINT_TYPEDEF; struct struct_with_bitfields { unsigned int a:2; // Compliant signed int b:2; // Compliant UINT_TYPEDEF c:2; // Compliant int d:2; // 6.1 - plain int not compliant signed long f:2; // Compliant in c99 or later - explicitly signed integer type unsigned int g:1; // Compliant signed int h:1; // 6.2 - signed int with size 1 is not compliant uint16_t i:1; // Compliant bool j:1; // Compliant in C99 or later }; static void misra6_1_fn(void) { // "Use" occurrence should not generate warnings struct_with_bitfields s; s.h = 61; } cppcheck-2.17.1/addons/test/misra/misra-test.c000066400000000000000000001757011475760761100212110ustar00rootroot00000000000000// To test: // ~/cppcheck/cppcheck --dump misra/misra-test.h --std=c89 // ~/cppcheck/cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64 && python3 ../misra.py -verify misra/misra-test.c.dump #include "path\file.h" // 20.2 #include "file//.h" // 20.2 #include "file/*.h" // 20.2 #include "file'.h" // 20.2 #include // 20.2 #include "file,.h" // 20.2 #include "misra-test.h" #include /*abc*/ "file.h" // no warning /*foo*/#include "file.h" // no warning #include "./file.h" // no warning #include \ "file.h" #include /*abc*/ \ "file.h" #include "fi" "le.h" // 20.3 (strings are concatenated after preprocessing) #include "fi" // 20.3 #include // 20.3 #include PATH "file.h" // 20.3 #define H_20_3_ok "file.h" #include H_20_3_ok #include file.h // 20.3 #define H_20_3_bad file.h #include H_20_3_bad // TODO: 20.3 Trac #9606 #include "//file.h" // 20.2 #include "//file.h" H_20_3_bad // 20.2 20.3 //#include H_20_3_bad // no warning #include H_20_3_ok H_20_3_ok // 20.3 #include // no warning #include // 21.4 #include // 21.5 #include //21.6 #include //21.6 #include // 21.10 #include // 21.11 #include // Check that the addon doesn't crash typedef struct { union { // 19.2 struct { unsigned a : 2; unsigned : 14; }; uint16_t value; }; } STRUCT_BITS; typedef unsigned char u8; typedef unsigned short u16; typedef unsigned int u32; typedef signed int s32; typedef unsigned long long u64; static void misra_1_2(bool expr) { (void)(condition ? : 0); // 1.2 a = 1 + ({if (!expr) {code;} 1;}); // 1.2 } static _Atomic int misra_1_4_var; // 1.4 static _Noreturn void misra_1_4_func(void) // 1.4 { if (0 != _Generic(misra_1_4_var)) {} // 1.4 17.3 printf_s("hello"); // 1.4 } #define MISRA_2_2 (1*60) static void misra_2_2(int x) { int a; a = x + 0; // 2.2 a = 0 + x; // 2.2 a = x * 0; // 2.2 a = 0 * x; // 2.2 a = x * 1; // 2.2 a = 1 * x; // 2.2 a = MISRA_2_2; (void)a; } /* // */ // 3.1 /* /* */ // 3.1 //// /* https://cppcheck.net */ // http://example.com // no warning static void misra_2_7_unused_param (int *param1, int unused_param) // 2.7 { *param1 = 42U; } static void misra_2_7_used_params (int *param1, int param2, int param3) { (void)param3; *param1 = param2; } static void misra_2_7_a(int a, int b, // 2.7 int c, int d) // 2.7 { (void)a; (void)c; } static void misra_2_7_b(int a, int b, int c, // 2.7 int d) // 2.7 { (void)a; } static void misra_2_7_c(int a, ...) { (void)a; } static void misra_2_7_d(int) { } // 2.7 8.2 static void misra_3_2(int enable) { // This won't generate a violation because of subsequent blank line \ int y = 0; int x = 0; // 3.2 non-compliant comment ends with backslash \ if (enable != 0) { ++x; // This is always executed // 3.2 potentially non-compliant comment ends with trigraph resolved to backslash ??/ ++y; // This is hidden if trigraph replacement is active } (void)printf("x=%i, y=%i\n", x, y); } extern int misra_5_1_extern_var_hides_var_x; extern int misra_5_1_extern_var_hides_var_y; //5.1 int misra_5_1_var_hides_var________a; // 8.4 int misra_5_1_var_hides_var________b; int misra_5_1_var_hides_var________b1; int misra_5_1_var_hides_var________b2; //5.1 8.4 int misra_5_1_var_hides_var________c; //5.1 8.4 int misra_5_1_var_hides_var________d; //5.1 8.4 int misra_5_1_var_hides_var________e; //5.1 8.4 extern const uint8_t misra_5_2_var1; const uint8_t misra_5_2_var1 = 3; static int misra_5_2_var_hides_var______31x; static int misra_5_2_var_hides_var______31y;//5.2 static int misra_5_2_function_hides_var_31x; static void misra_5_2_function_hides_var_31y(void) {}//5.2 static void foo(void) { int i; switch(misra_5_2_func1()) //16.4 16.6 { case 1: { do { for(i = 0; i < 10; i++) { if(misra_5_2_func3()) //17.3 { int misra_5_2_var_hides_var_1____31x; int misra_5_2_var_hides_var_1____31y;//5.2 } } } while(misra_5_2_func2()); //17.3 } break; } } union misra_5_2_field_hides_field__63x { //19.2 int misra_5_2_field_hides_field__31x; int misra_5_2_field_hides_field__31y;//5.2 }; struct misra_5_2_field_hides_field__63y { //5.2 int misra_5_2_field_hides_field1_31x; int misra_5_2_field_hides_field1_31y;//5.2 }; const char *s41_1 = "\x41g"; // 4.1 8.4 const char *s41_2 = "\x41\x42"; // 8.4 const char *s41_3 = "\x41" "\x42"; // 8.4 const char *s41_4 = "\x41" "g"; // 8.4 const char *s41_5 = "\x41\xA"; // 8.4 const char *s41_6 = "\xA\x41"; // 8.4 const char *s41_7 = "\xAA\xg\x41"; // 4.1 8.4 const char *s41_8 = "\xAA\x\x41"; // 4.1 8.4 const char *s41_9 = "unknown\gsequence"; // 8.4 const char *s41_10 = "simple\nsequence"; // 8.4 const char *s41_11 = "string"; // 8.4 int c41_3 = '\141t'; // 4.1 8.4 int c41_4 = '\141\t'; // 8.4 int c41_5 = '\0'; // 10.3 8.4 int c41_6 = '\0\t'; // 8.4 int c41_7 = '\12\t'; // 8.4 int c41_8 = '\0t'; // 4.1 8.4 int c41_9 = '\12'; // 8.4 int c41_10 = '\12\n'; // 8.4 int c41_11 = '\12n'; // 4.1 8.4 int c41_12 = '\12323'; // 4.1 8.4 int c41_13 = '\123\3'; // 8.4 // TODO int c41_14 = '\777\777'; int c41_15 = 'a'; // 10.3 8.4 static void misra_4_1(void) { (void)printf("\x41g"); // 4.1 (void)printf("\x41\x42"); (void)printf("\x41" "g"); } const char *s42_1 = "String containing trigraphs ??-??-??"; // 4.2 8.4 const char *s42_2 = "String containing trigraph???=preceded by question mark"; // 4.2 8.4 const char *s42_3 = "No trigraph?(?'?)"; // 8.4 static void misra_4_2(void) { (void)printf("??=Trigraph\n"); // 4.2 (void)printf("No?/Trigraph\n"); } #define misra_5_4_macro_hides_macro__31x 1 #define misra_5_4_param_hides_macro__31x 1 #define misra_5_4_macro_hides_macro__31y 2 //5.4 #define m1(misra_5_4_param_hides_macro__31y) 1 //5.4 #define m2(misra_5_4_param_hides_param__31x,misra_5_4_param_hides_param__31y) 1 //5.4 #ifdef misra_5_4_macro_hides_macro__31x #define misra_5_4_macro 1 // no warning #else #define misra_5_4_macro 2 // no warning #endif #define misra_5_5_var_hides_macro____31x 1 #define misra_5_5_functionhides_macro31x 1 #define misra_5_5_param_hides_macro__31x 1 #define misra_5_5_tag_hides_macro____31x 1 #define misra_5_5_hides_macro________31x 1 int misra_5_5_var_hides_macro____31y; //5.5 8.4 static void misra_5_5_functionhides_macro31y(int misra_5_5_param_hides_macro__31y){(void)misra_5_5_param_hides_macro__31y;} //5.5 struct misra_5_5_tag_hides_macro____31y { //5.5 int x; }; static void misra_5_5_func1(void) { switch(misra_5_5_func2()) //16.4 16.6 { case 1: { do { if(misra_5_5_func3()) //17.3 { int misra_5_5_hides_macro________31y; //5.5 } } while(misra_5_5_func2()); //17.3 } break; } } typedef unsigned int UINT_TYPEDEF; struct struct_with_bitfields { unsigned int a:2; // Compliant signed int b:2; // Compliant UINT_TYPEDEF c:2; // Compliant int d:2; // 6.1 - plain int not compliant signed long f:2; // 6.1 - signed long not compliant unsigned int g:1; // Compliant signed int h:1; // 6.2 - signed int with size 1 is not compliant uint16_t i:1; // Compliant bool j:1; // 6.1 - bool not legal until c99 }; static void misra6_1_fn(void) { // "Use" occurrence should not generate warnings struct_with_bitfields s; s.h = 61; } static void misra_7_1(void) { int x = 066; // 7.1 } static void misra_7_2(void) { uint32_t a = 0x7fffffff; uint32_t b = 0x80000000; // 7.2 uint32_t c = 0x80000000U; uint32_t d = 2147483647; uint64_t e = 2147483648; uint32_t f = 2147483648U; } // The addon should not generate false positives for the identifiers. struct misra_7_3_s { uint32_t ul_clka; uint32_t test123l; }; static void misra_7_3(void) { long misra_7_3_a = 0l; //7.3 long misra_7_3_b = 0lU; //7.3 long long misra_7_3_c = 0Ull; //7.3 long long misra_7_3_d = 0ll; //7.3 long double misra_7_3_e = 7.3l; //7.3 struct misra_7_3_s misra_7_3_f = { .ul_clka = 19U, .test123l = 23U }; } typedef const char* MISRA_7_4_CHAR_CONST; static MISRA_7_4_CHAR_CONST misra_7_4_return_const_type_def (void) { return "return_typedef_const"; } static char *misra_7_4_return_non_const (void) { return 1 + "return_non_const"; } // 7.4 18.4 static const char *misra_7_4_return_const (void) { return 1 + "return_const"; } // 18.4 static void misra_7_4_const_call(int a, const char* b) { } // 2.7 static void misra_7_4_const_ptr_call(int a, const char const* b) { } // 2.7 static void misra_7_4_call(int a, char* b) { } // 2.7 static void misra_7_4_call_2(int a, ...) { } // 2.7 static void misra_7_4(void) { const char *a = "text a"; char* const b = "text_b"; // 7.4 char *c = "text c"; // 7.4 char *d = 1 + "text d"; // 7.4 18.4 char *e = "text e" + 1 + 2; // 7.4 18.4 char *f = 1 + "text f" + 2; // 7.4 18.4 const wchar_t *g = "text_g"; wchar_t *h = "text_h"; // 7.4 misra_7_4_const_call(1, ("text_const_call")); misra_7_4_const_ptr_call(1, ("text_const_call")); misra_7_4_call(1, "text_call"); // 7.4 11.8 misra_7_4_call_2(1, "a", "b"); } const misra_8_1_a; // 8.1 8.4 static int misra_8_2_a (int n, ...); extern int misra_8_2_b (int n); extern int misra_8_2_c (int); // 8.2 static int misra_8_2_d (); // 8.2 static int misra_8_2_e (void); static int misra_8_2_f (vec, n ) int *vec; // 8.2 int n; // 8.2 { return vec[ n - 1 ]; } static int misra_8_2_g ( /* comment */ ); // 8.2 static int misra_8_2_h ( /* comment 1 */ /* comment 2 */ ); // 8.2 static int misra_8_2_i ( /* comment */ void); static int misra_8_2_j ( /* comment */ void /* comment */); static int misra_8_2_k ( // void); static int misra_8_2_l ( // 8.2 ); static void misra_8_2_m(uint8_t * const x); static void misra_8_2_m(uint8_t * const x) { (void)x; } int16_t ( *misra_8_2_p_a ) (); // 8.2 8.4 int16_t ( *misra_8_2_p_b ) (void); // 8.4 int16_t ( *misra_8_2_p_c ) (int); // 8.4 static int misra_8_2_n(int a) { return a + 42; } static int misra_8_2_o( const uint32_t a1, const uint8_t *const a2 ) { return *a2 + a1; } static int misra_8_2_p( const uint32_t a1, const uint8_t *const a2 ); static int misra_8_2_q (); // 8.2 void misra_8_4_foo(void) {} // 8.4 extern void misra_8_4_func(void); void misra_8_4_func(void) {} static void misra_8_4_bar(void) {} // Declared in header extern int16_t misra_8_4_count; // no-warning int16_t misra_8_4_count = 0; // Compliant extern uint8_t misra_8_4_buf1[13]; // no-warning uint8_t misra_8_4_buf2[24]; // 8.4 typedef struct { uint16_t a; uint16_t b; } misra_8_4_struct; extern misra_8_4_struct bar[42]; misra_8_4_struct bar[42]; // compliant extern uint16_t misra_8_4_speed = 6000u; //8.4 uint8_t misra_8_4_pressure = 101u; //8.4 int32_t misra_8_4_ext_val2; int32_t misra_8_4_ext_val2 = 3; // compliant int32_t misra_8_4_ext_val4; //8.4 // #12978 const stError_t * m8_4_pubTestPointer; //compliant static int32_t misra_8_8 = 123; extern int32_t misra_8_8; // 8.8 static int32_t misra_8_9_i; // 8.9 static int32_t misra_8_9_foo(void) { return misra_8_9_i++; } inline int32_t misra_8_10_value(void) { return 123; } // 8.10 8.4 extern int a811[]; // 8.11 enum misra_8_12_a { misra_a1 = 1, misra_a2 = 2, misra_a3, misra_a4 = 3 }; //8.12 enum misra_8_12_b { misra_b1, misra_b2, misra_b3 = 3, misra_b4 = 3 }; // no-warning enum misra_8_12_c { misra_c1 = misra_a1, misra_c2 = 1 }; // no-warning enum misra_8_12_d { misra_d1 = 1, misra_d2 = 2, misra_d3 = misra_d1 }; // no-warning enum misra_8_12_e { misra_e1 = sizeof(int), misra_e2}; // no-crash static void misra_8_14(char * restrict str) {(void)str;} // 8.14 // #11707 -- false positive struct S_9_3 { struct S_9_3* p; int x; }; struct S_9_3* s_9_3_array[] = { x, NULL }; // 8.4 // #10854 struct Entry_9_2{ union{ // 19.2 const int *p; int x; }; int y; }; static void misra_9_2_10854(void){ struct Entry_9_2 e1[] = { {{ .x = 1 }, .y = 2 } }; } static void misra_9_empty_or_zero_initializers(void) { int a[2] = {}; // 9.2 int b[2][2] = {}; // 9.2 int c[2][2] = { {} }; // 9.2 9.3 int d[2][2] = { {}, {} }; // 9.2 int e[2][2] = { { 1 , 2 }, {} }; // 9.2 int f[5] = { 0 }; int f1[5] = { 0u }; // 9.3 unsigned int f1[ 3 ][ 2 ] = { 0U }; // 9.3 9.2 unsigned int f2[ 3 ] = { 0U }; // 9.3 float f3[ 3 ][ 2 ] = { 0.0F }; // 9.3 9.2 int g[5][2] = { 0 }; int h[2][2] = { { 0 } }; // 9.3 int i[2][2] = { { 0 }, { 0 } }; int j[2][2] = { { 1, 2 }, { 0 } }; int k[2][2] = { [0] = { 1 , 2 }, { 0 } }; int l[1][2] = { { 0 }, [0] = { 1 } }; // 9.3 9.4 typedef struct { int a; int b; } struct1; struct1 m = { }; // 9.2 struct1 n = { 0 }; } static void misra_9_string_initializers(void) { const char a[12] = { "Hello world" }; // 9.2 const char b[2][20] = "Hello world"; // 9.2 9.3 const char c[] = "Hello world"; const char d[15] = "Hello world"; const char e[1][12] = { "Hello world" }; const char *f[2] = { "Hello", [1] = "world" }; const char *g[1] = "Hello world"; // 9.2 const char h[2][15] = { { 0 }, "Hello world" }; char **str_p = &f[0]; char **i[1] = { str_p }; char **j[1] = { { str_p } }; // 9.2 } static void misra_9_array_initializers(void) { char a[4] = { 1, 2, 3, 4 }; char b[2][2] = { {1, 2}, {3, 4} }; char c[2][2] = { 1, 2, 3, 4 }; // 9.2 char d[6] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; // 9.2 9.3 char e[2][2] = { {1, 2}, {4} }; // 9.3 char f[2][2] = { 1, 2, 3 }; // 9.2 9.3 char g[2][2] = { {1, 2, 3, 4} }; // 9.3 char h[2][2] = { { 1, { 2 } }, { 3, { 5 } } }; // 9.2 char i[2][2] = { { 1, { 2 } }, { 3 } }; // 9.2 9.3 char j[2][3] = { { 1, { 2 }, 3 }, { 4, { 5 }, 6 } }; // 9.2 char k[2][3] = { { 1, { 2 }, 3 }, { 4, { 5 } } }; // 9.2 9.3 char l[3] = { 1, { 2, 3 } }; // 9.2 9.3 } static void misra_9_array_initializers_with_designators(void) { char a[1] = { [0][1] = 1 }; // 9.2 char b[1] = { [0] = { 1, 2 } }; // 9.2 char c[2][2] = { [0] = {1, 2, 3} }; char d[1][2] = { [0] = 1 }; // 9.2 char e[2][2] = { { 1, 2 }, [1][0] = {3, 4} }; // 9.2 int e1[2][2] = { [ 0 ][ 1 ] = 0, { 5, 6 } }; // no warning #12419 char f[2] = { [0] = 1, 2 }; char g[2] = { [1] = 2, [0] = 1 }; char h[2][2] = { { 1, 2 }, [1] = { 3 } }; // 9.3 char i[2][2] = { { 1, 2 }, [1] = { 3, 4 } }; char j[2][2] = { { 1, 2 }, [1] = { [0] = 3 } }; char k[2][2] = { { 1, 2 }, [1][0] = 3 }; char l[2][2] = { { 1, 2 }, [1][0] = 3, 4}; // 9.2 char m[2][2] = { [0] = { [2] = 2 }, [1][5] = 4 }; char n[2][2] = { [0] = { 1 } }; // 9.3 char o[2][2] = { { 1 }, [1][0] = 3 }; // 9.3 char p[2][2] = { { 1, 2 }, { 3, 4 }, [1] = { 3 } }; // 9.3 9.4 // cppcheck-suppress unknownEvaluationOrder char q[2][2] = { { 1, 2 }, { 1 }, [1] = { [1] = 3 } }; // 9.4 char r[2][2][2] = { [0][0] = { 1, 2 }, [1] = { [0] = {5, 6} } }; char s[2][2][2] = { [0][0] = { 1, 2 }, [1] = {5, 6, 7, 8}}; // 9.2 char t[2][2][2] = { [0][0] = { 1, 2 }, {3, 4}, [1] = {5, 6}}; // 9.2 9.3 char u[2][2][2] = { [0] = { 1, 2, {3, 4} } }; // 9.2 char v[2][2][2] = { [0] = { 1, 2, [1] = {3, 4} }}; // 9.2 } static void misra_9_struct_initializers(void) { typedef struct { int i1; int i2; } struct1; typedef struct { char c1; struct1 is1; char c2[4]; } struct2; typedef struct { struct1 s[2][2]; } struct3; typedef struct { unknown_field_type f1; unknown_field_type f2[2]; int f3[2]; } struct_with_unknown_fields; struct3 sa[2] = { [1].s[1][0].i1 = 3, 4 }; // 9.2 struct1 sa = 1; // 9.2 struct1 sb = { 1, 2 }; struct2 sc = { 1, { 2 }, {4, 5, 6, 7} }; struct2 sd = { 1, { 2, 3 }, {4, 5, 6} }; // 9.3 struct2 se = { 1, 2, 3, 4, 5, 6, 7 }; // 9.2 struct2 sf = { 1, { 2, 3 }, 4, 5, 6, 7 }; // 9.2 struct2 sg = { 1, { 2 }, 4, 5, 6, 7 }; // 9.2 struct2 sh = { 1, { 2, 3 }, 4, 5, 6 }; // 9.2 9.3 struct2 si = { 1, 2, 3, {4,5,6,7} }; // 9.2 int a; struct1 sj = { a = 1, 2 }; // 13.1 // Struct types struct2 sta = { .is1 = sc }; // 9.2 struct2 stb = { .is1 = sb }; struct1 stc[1] = { sc }; // 9.2 struct1 std[1] = { sb }; // Struct designators struct1 sda = { 1, .i2 = 2 }; struct2 sdb = { 1, { 2, .i2=3 }, .c2[1]=5 }; struct2 sdc = { 1, { 2, .i2=3 }, .c2 = { 5 } }; // 9.3 struct2 sdd = { 1, { 2, .i2=3 }, .c2 = 5 }; // 9.2 struct2 sde = { .is1 = { 2, 3 }, { 4, 5, 6, 7 } }; // Struct arrays struct1 asa[2] = { {1,2}, {3,4} }; struct1 asb[2] = { {1}, {3,4} }; struct1 asc[2] = { {1,2} }; // 9.3 struct1 asd[2] = { 1,2, 3,4 }; // 9.2 struct1 ase[2] = { 1,2, 3 }; // 9.2 struct1 asf[2] = { 1,2 }; // 9.2 9.3 struct1 asg[2] = { [1].i1 = 3 }; struct3 ash[2] = { [1].s[1][0].i1 = 3 }; struct3 asi[2] = { [0] = { .s[0] = { { 1, 2 } }}}; // 9.3 struct3 asj[2] = { [0] = { .s[0] = { 1, 2 }}}; // 9.2 9.3 // Missing type information dummy_struct dsa = { 1, .a = 2 }; dummy_struct dsb[2] = { {1,2}, {3,4} }; dummy_struct dsc[2][2] = { {1,2}, {3,4} }; dummy_struct dsd[2][2] = { 1, 2, 3, 4 }; // 9.2 dummy_struct dse[3] = { {1,2}, {3,4}, [1] = {5,6} }; // 9.3 9.4 dummy_struct dsf[] = { [0] = 1 }; // 9.5 dummy_struct dsg = { .a = {0}, .b = {0} }; dummy_struct dsh[2][2] = { { {.a = 0, .b = {0}}, { 0 } }, { { 0 }, {.a = 0, .b = {0}}} }; // Struct with fields of unknown type struct_with_unknown_fields ufa = { 1, { 1, 2 }, { 1, 2 } }; struct_with_unknown_fields ufb = { 1, 1, 2 }; // 9.2 struct_with_unknown_fields ufc[2] = { {1, { 1, 2 }, { 1, 2 } }, { 2, { 1, 2 }, { 1, 2 } } }; struct_with_unknown_fields ufd[2][2] = { {1, { 1, 2 }, { 1, 2 } }, // 9.2 9.3 { 2, { 1, 2 }, { 1, 2 } } }; struct_with_unknown_fields ufe[2] = { 1, { 1, 2 }, { 1, 2 }, // 9.2 9.3 2, { 1, 2 }, { 1, 2 } }; struct_with_unknown_fields uff[3] = { { 1, { 1, 2 }, { 1, 2 }}, // 9.3 9.4 {2, { 1, 2 }, { 1, 2 }}, [1] = { 2, { 1, 2 }, { 1, 2 }} }; // Obsolete initialization syntax for GCC struct1 os1 = { i1: 1, i2: 2 }; // 10.4 13.4 } static void misra_9_2(void) { union misra_9_2_union { // 19.2 char c; struct1 i; } u = { 3 }; // 19.2 } static void misra_9_5(void) { char a[] = { 1, 2, 3 }; char b[] = { [2] = 5 }; // 9.5 char c[] = { 1, [1] = 5 }; // 9.5 char d[] = { [1] = 2, [0] = 1 }; // 9.5 char e[][2] = { { 1, 2 }, { 3, 4 } }; char f[][2] = { [1] = { 3, 4 } }; // 9.5 char g[][2] = { { 1, 2 }, [1] = { 3, 4 } }; // 9.5 char h[][2] = { [1] = { 1, 2 }, [0] = { 3, 4 } }; // 9.5 } typedef char misra_10_1_char_t; #define MISRA_10_1_CHAR char static void misra_10_1(uint32_t u, char c1, char c2, uint8_t u8) { int32_t i; char c; enum { E1 = 1 }; i = 3 << 1; // 10.1 i = (u & u) << 4; // no-warning c = c1 & c2; // 10.1 c = c1 << 1; // 10.1 i = c1 > c2; // 10.3 i = E1 + i; // no-warning char ch1 = 'a'; char ch2 = 'b'; char ch3; ch3 = ch1 & ch2; // 10.1 misra_10_1_char_t ct1 = 'a'; misra_10_1_char_t ct2 = 'b'; misra_10_1_char_t ct3; ct3 = ct1 & ct2; // 10.1 MISRA_10_1_CHAR cd1 = 'a'; MISRA_10_1_CHAR cd2 = 'b'; MISRA_10_1_CHAR cd3; cd3 = cd1 & cd2; // 10.1 uint8_t temp1 = u8 & 0x42U; // no-warning } static void misra_10_1_ternary(void) { int a; uint8_t ui8; uint16_t ui16; int8_t i8; int16_t i16; a = ui16 << ui16; // 10.6 a = ui16 << (get_bool(42) ? ui16 : ui16); a = ui16 << (get_bool(42) ? ui16 : (get_bool(34) ? ui16 : ui16)); a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui16) : ui16); a = ui16 << (get_bool(42) ? i16 : (get_bool(34) ? ui16 : ui16)); // 10.1 10.4 a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : i16) : ui16); // 10.1 10.4 a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui16) : i16); // 10.1 10.4 a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8); // 10.4 a = ui16 << (get_bool(42) ? (get_bool(34) ? i16 : ui8) : ui8); // 10.1 10.4 a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8) << ui16; // 10.4 a = (get_bool(42) ? (get_bool(34) ? i16 : ui8) : ui8) << ui16; // 10.1 10.4 a = (get_bool(42) ? (get_bool(34) ? ui16 : i8) : ui8) << ui16; // 10.1 10.4 a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : i8) << ui16; // 10.1 a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8) << (get_bool(19) ? ui16 : ui8); // 10.4 a = (get_bool(42) ? (get_bool(34) ? i16 : ui8) : ui8) << (get_bool(19) ? ui16 : ui8); // 10.1 10.4 a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8) << (get_bool(19) ? i16 : ui8); // 10.1 10.4 } static void misra_10_2(void) { uint8_t u8a = 0; char cha = 0; int8_t s8a = 0; int16_t s16a = 0; float f32a = 0.0; char res; res = '0' + u8a; // Convert u8a to digit res = s8a + '0'; res = cha - '0'; res = '0' - s8a; res = cha + ':'; // 10.2 res = s16a - 'a'; // 10.2 10.3 10.4 res = '0' + f32a; // 10.2 10.4 // 10481 - crash char buf[1] = {'f'}; x = buf[0] - '0'; } static void misra_10_3(uint32_t u32a, uint32_t u32b) { uint8_t res; res = u32a + u32b; // 10.3 res = (uint16_t)(2U + 3U); // 10.3 10.8 res = 2U + 3U; // no warning, utlr=unsigned char res = 0.1f; // 10.3 const char c = '0'; // no-warning bool b = true; // no-warning uint32_t u = UINT32_C(10); // no-warning } static void misra_10_4(u32 x, s32 y) { z = x + 3; // 10.4 enum misra_10_4_enuma { misra_10_4_A1, misra_10_4_A2, misra_10_4_A3 } a; enum misra_10_4_enumb { misra_10_4_B1, misra_10_4_B2, misra_10_4_B3 }; if ( misra_10_4_B1 > misra_10_4_A1 ) //10.4 { ; } z = x + y; //10.4 z = (a == misra_10_4_A3) ? x : y; //10.4 z = (a == misra_10_4_A3) ? y : y; // no-warning // #10499 const char buf[10] = {0}; if ('0' == buf[x]) // no-warning { } const struct foo_s{ int t; char buf[2]; } cmd = {0}; if ('\0' == cmd.buf[0]) //no-warning { } // #10652 char c; if ((char)'1' == c) {} // no warning if ((unsigned char)'1' == c) {} //10.4 if ((signed char)'1' == c) {} //10.4 } static void misra_10_5(uint16_t x) { // bool res = (uint16_t) (x > 10u); // 10.5 res = (bool) 1u; // no-warning // char <=> float res = (char) 0.1f; res = (float) 'x'; } struct misra_10_6_s { unsigned int a:4; }; static void misra_10_6(u8 x, char c1, char c2) { u16 y1 = x+x; // 10.6 u16 y2 = (0x100u - 0x80u); // rhs is not a composite expression because it's a constant expression int b = (y2 == y2) ? 0 : 1; // no-warning u16 z = ~u8 x ;//10.6 s32 i = c1 - c2; // 10.3 struct misra_10_6_s s; s.a = x & 1U; // no-warning (#10487) } static void misra_10_6_1(uint32_t *a, uint16_t b, uint16_t c) { *a = b + c ; // 10.6 } static void misra_10_7_f1(struct Timer *pSelf, uint32_t interval_ms); static void misra_10_7(uint16_t u16a, uint16_t u16b) { uint32_t u32a = 100u; res = u32a * u16a + u16b; // 12.1 no-warning res = (u32a * u16a) + u16b; // no-warning res = u32a * ( ( uint32_t ) u16a + u16b ); // no-warning res = u32a * (u16a + u16b); // 10.7 u32a *= u16a + u16b; // 10.7 u32a = ((uint32_t)4 * (uint32_t)2 * (uint32_t)4 ); // no-warning (#10488) dostuff(&t, (2*60*1000)); // no-warning } static void misra_10_8(u8 x, s32 a, s32 b) { y = (u16)x; y = (u16)(x+x); // 10.8 y = (u16) (a + b) //10.8 } int (*misra_11_1_p)(void); // 8.4 void *misra_11_1_bad1 = (void*)misra_11_1_p; // 11.1 8.4 // #12172 typedef void (*pfFunc_11_1)(uint32_t some); extern pfFunc_11_1 data_11_1[10]; void func_11_1(pfFunc_11_1 ptr){ //8.4 data_11_1[index] = ptr; // no-warning } struct misra_11_2_s; struct misra_11_2_t; static struct misra_11_2_s * sp; static struct misra_11_2_t * tp = sp; // 11.2 struct Fred {}; struct Wilma {}; static void misra_11_3(u8* p, struct Fred *fred) { x = (u64*)p; // 11.3 struct Wilma *wilma = (struct Wilma *)fred; // 11.3 } typedef struct { uint32_t something; } struct_11_4; #define A_11_4 ((struct_11_4 *)0x40000U) // 11.4 static void misra_11_4(u8*p) { u64 y = (u64)p; // 11.4 u8 *misra_11_4_A = ( u8 * ) 0x0005;// 11.4 s32 misra_11_4_B; u8 *q = ( u8 * ) misra_11_4_B; // 11.4 dummy = A_11_4->something; // no-warning } static void misra_11_5(void *p) { u16 *p16; x = (u8 *)p; // 11.5 p16 = p; // 11.5 } static intptr_t get_intptr_constant(void) { return 456; } static void misra_11_6(void) { void *p; struct { int i; } s = { .i = 7 }; p = (void*)123; // 11.6 x = (u64)p; // 11.6 p = (void*)(1+1);// 11.6 p = (void*)get_intptr_constant(); // 11.6 p = (void*)s.i; // 11.6 p = ( void * )0; // no-warning (void)p; // no-warning // # 12184 p = (void*)0U; // no-warning } static void misra_11_7(int *p, float f) { x = ( float ) p; //11.7 y = ( int * ) f; //11.7 } static void misra_11_7_extra(int *p, float f, bool b) { (void) p; // no-warning (void) f; // no-warning (void) b; // no-warning } static void misra_11_8_const(const char *str) {(void)str;} static char * misra_11_8(const char *str) { (void)misra_11_8_const(str); // no-warning return (char *)str; // 11.8 } #define MISRA_11_9_NULL_1 (1-1) #define MISRA_11_9_NULL_2 ( void * ) 0 #define MISRA_11_9_NULL_3 NULL static void misra_11_9(void) { int *p1 = (5-5); //11.9 int *p2 = MISRA_11_9_NULL_2 ; // no-warning int *p3 = MISRA_11_9_NULL_3 ; // no-warning if ( p1 == MISRA_11_9_NULL_1 ) //11.9 { ; } } static void misra_12_1(void) { sz = sizeof x + y; // 12.1 a = (b * c) + d; a = b << c + d; // 12.1 } static void misra_12_2(u8 x) { a = x << 8; // 12.2 } static int misra_12_3_v1 = 0, misra_12_3_v2; // 12.3 static int misra_12_3_v3, misra_12_3_v4; // 12.3 enum misra_12_3_e1 { M123A1, M123B1, M123C1 }; enum misra_12_3_e2 { M123A2 = 3, M123B2 = 4, M123C2 }; typedef enum misra_12_3_e3 { M123A3 , M123B3, M123C3 } misra_12_3_e3_t; typedef enum { M123A4 , M123B4, M123C4 } misra_12_3_e4_t; struct misra_12_3_s1 { int a; int b; int c, d; }; // 12.3 static struct misra_12_3_s1 misra_12_3_s1_inst = { 3, 4, 5, 6, // no warning }; typedef struct misra_12_3_s2 { int a; int b; int c, d; } misra_12_3_s2_t; // 12.3 typedef struct { int a; int b; int c, d; } misra_12_3_s3_t; // 12.3 static void misra_12_3_fn1(int, int); static int misra_12_3_v5, misra_12_4_v6; // 12.3 8.2 static void misra_12_3_fn2(int a, int b) // 2.7 { int d, e; } // 12.3 static int misra_12_3_fn3(int a, int b) { return a+b;} static int misra_12_3_v5, misra_12_4_v6; // 12.3 static void misra_12_3_fn4(const uint32_t value, uint8_t * const y) {} // 2.7 static void misra_12_3_fn5(const uint32_t * const, const uint8_t) {} // 2.7 8.2 extern void misra_12_3_fn6(const uint32_t value, uint8_t * const y); extern uint32_t misra_12_3_fn7(const uint32_t * const, const uint8_t); // 8.2 #define MISRA_12_3_FN3_1(A, B) (misra_12_3_fn3(A, B)) #define MISRA_12_3_FN3_2(A, B) (misra_12_3_fn3(A, \ B)) #define MISRA_12_3_FN3_2_MSG(x) x, fflush(stderr) static void misra_12_3(int, int, int); // 8.2 void misra_12_3(int a, int b, int c) { int a1, a2; // 12.3 int a3; int a4; // no warning int a5 = 9, a6; // 12.3 int a7, a8 = 11; // 12.3 int a9 = foo(), a10; // 12.3 int a11 = a = b = c; // 17.8 struct s1 {int a, b;}; int a12, a13; // 12.3 int a14, a15; misra_12_3_fn3(a14, a15); // 12.3 17.7 ; int a16, a17; // 12.3 int a18; int a19, a20; // 12.3 int a21, a22; int a23; // 12.3 int a24, // 12.3 a25; int a26 , a27; // 12.3 int a28 , // 12.3 a29; struct misra_12_3_s2 a30 = {1, 2}, a31; // 12.3 struct misra_12_3_s2 a32, a33; // 12.3 struct misra_12_3_s2 a34, a35 = {1, 2}, a36; // 12.3 // cppcheck-suppress uninitStructMember int a37 = MISRA_12_3_FN3_1(a34, a35), a38; // 12.3 int a39, a40 = MISRA_12_3_FN3_1(a34, a35); // 12.3 int a41 = MISRA_12_3_FN3_2(a34, a35), a42; // 12.3 int a43, a44 = MISRA_12_3_FN3_2(a34, a35); // 12.3 MISRA_12_3_FN3_2_MSG(fprintf(stderr, "test\n")); // 12.3 f((1,2),3); // TODO // third clause: 2 persistent side effects instead of 1 (14.2) for (i=0; i<10; i++, j++){} // 12.3 14.2 for (int i = 0, p = &a1; // 12.3 14.2 i < 42; ++i, ++p ) // 12.3 {} // No false positives in local and extern function calls misra_12_3_fn4(misra_12_3_fn5(&a1, 32), &a1); misra_12_3_fn4(misra_12_3_fn7(&a1, 32), &a1); misra_12_3_fn6(misra_12_3_fn5(&a1, 32), &a1); misra_12_3_fn6(misra_12_3_fn7(&a1, 32), &a1); misra_12_3_fn7(maxlen, fn(va, unsigned long), false); misra_12_3_fn8(maxlen, (unsigned long)((uintptr_t)fn(va, void*)), false); const struct fun_t { int64_t x; uint32_t y; } moreFun[2U] = { { 900000000000000LL, 0x20000UL }, { 450000000000000LL, 0x10000UL } }; } #define MISRA12_4a 2000000000u #define MISRA12_4b 4000000000u static void misra_12_4(uint8_t t) { x = 123456u * 123456u; // 12.4 x = MISRA12_4a + MISRA12_4b; // 12.4 x = 0u - 1u; // 12.4 x = t ? 0u : (0u-1u); // 12.4 x = (0u==0u) ? 0u : (0u-1u); x = (0u!=0u) ? 0u : (0u-1u); // 12.4 x = (0u==0u) ? 0u : (2*(0u-1u)); // 10.4 } struct misra_13_1_t { int a; int b; }; uint8_t misra_13_1_x = 0; // 8.4 static void misra_13_1_bar(uint8_t a[2]); static void misra_13_1(int *p) { volatile int v; int a1[3] = {0, (*p)++, 2}; // 13.1 int a2[3] = {0, ((*p) += 1), 2}; // 13.1 int a3[3] = {0, ((*p) = 19), 2}; // 13.1 misra_13_1_bar((uint8_t[2]){ misra_13_1_x++, misra_13_1_x++ } ); // 13.1 int b[2] = {v,1}; struct misra_13_1_t c = { .a=4, .b=5 }; // no fp volatile int vv; int v = 42; int a1[3] = { 0, (*p)++, 2 }; // 13.1 int a2[2] = { [0]=19, [1]=42 }; int a3[2] = { [0]=v, [1]=42 }; int a4[2] = { [0]=0, [1]=(v+=1) }; // 13.1 int a5[2] = { [0]=0, [1]=(v+1) }; int a6[2] = { v, 1 }; int a6[2] = { v >>= 3 }; // 13.1 9.3 int a7[2] = { v, ++v }; // 13.1 int a8[1] = { vv }; // TODO: 13.1 Trac #9504 struct misra_13_1_t c01 = { 4, 5 }; struct misra_13_1_t c02 = { 16 == 1, 5+1 }; struct misra_13_1_t c03 = { (v += 1), 5+1 }; // 13.1 struct misra_13_1_t c04 = { v <<= 1, 5+1 }; // 13.1 struct misra_13_1_t c05 = { v += 1, 5+1 }; // 13.1 struct misra_13_1_t c06 = { (4.5 + 0.5), 1 }; struct misra_13_1_t c07 = { (4.5 + 0.5), ++v }; // 13.1 struct misra_13_1_t c08 = { (int)4.5, 5 }; struct misra_13_1_t c09 = { (int)4.5+(*p)++, 5 }; // 13.1 struct misra_13_1_t c10 = { (int)4.5, (*p)++ }; // 13.1 struct misra_13_1_t c11 = { .a=4+1, .b=3/3 }; struct misra_13_1_t c12 = { .a=4, .b=5 }; struct misra_13_1_t c13 = { (*v)<<=(int)(4.5), .b=5 }; // 13.1 struct misra_13_1_t c14 = { (*p)/=(int)(4.5) }; // 13.1 } // Large arrays for R13.1. Size exceeds default Python's max recursion depth. static uint8_t misra_13_1_large_ok[1024] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; static uint8_t misra_13_1_large_bad[1024] = { // 13.1 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, i++, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; static void misra_13_3(void) { x = y++; // 13.3 } #define STRING_DEF_13_4 "This is a string" typedef struct { char string[sizeof(STRING_DEF_13_4)]; } s13_4_t; static s13_4_t s13_4 = { .string = STRING_DEF_13_4 // no-warning }; static void misra_13_4(int x, int z) { int y; if (x != (y = z)) {} // 13.4 else {} } static void misra_13_5(void) { int x = 0; int y = 0; if (x && (y++ < 123)){} // 13.5 if (x || ((y += 19) > 33)){} // 13.5 if (x || ((y = 25) > 33)){} // 13.5 13.4 if (x || ((--y) > 33)){} // 13.5 else {} } static void misra_13_6(void) { int a = sizeof(x|=42); // 13.6 a = sizeof(--x); // 13.6 13.3 return sizeof(x++); // 13.6 } static void misra_14_1(void) { for (float f=0.1f; f<1.0f; f += 0.1f){} // 14.1 float a = 0.0f; int b = 10; while ((a<100.0f) || (b > 100)) //14.1 { a++; } do { ; } while ( a < 10.0f ); // no-warning } //13143 static bool misra_14_1_is_increasing (const double* const x, const size_t n) { double last = -INFINITY; size_t i = ((size_t) 0); while ((i < n) && isfinite(x[i]) && (x[i] > last)) { //no-warning for 14_1 last = x[i]; i++; } return i == n; } static void misra_14_1_compliant1_foo(float x){ int i = 0; while(i < x){ // 10.4 i += x + x; // 10.3 10.4 no-warning for 14_1 } } static void misra_14_1_compliant2_foo(void){ int i = 0; float f = 0f; while (f < 10 && i < 10) { //10.4 12.1 float f = 0f; f = f + i; // 10.3 10.4 no warning for 14_1 i++; } } static void misra_14_2_init_value(int32_t *var) { *var = 0; } static void misra_14_2_init_value_1(int32_t *var); static void misra_14_2_fn1(bool b) { for (;i++<10;) {} // 14.2 for (;i<10;dostuff()) {} // 14.2 int32_t g = 0; int g_arr[42]; g += 2; // no-warning for (int32_t i2 = 0; i2 < 8; ++i2) { i2 += 2; // 14.2 i2 |= 2; // 14.2 g += 2; i2 ^= 2; // 14.2 if (i2 == 2) { g += g_arr[i2]; // cppcheck-suppress legacyUninitvar } misra_14_2_init_value(&i2); // TODO: Fix false negative in function call } int i1; int i2; for (misra_14_2_init_value(&i1); i1 < 10; ++i1) {} // no-warning for (misra_14_2_init_value_1(&i2); i2 < 10; ++i2) {} // no-warning for (misra_14_2_init_value_2(&i2); i2 < 10; ++i2) {} // no-warning bool abort = false; for (i = 0; (i < 10) && !abort; ++i) { // 14.2 as 'i' is not a variable if (b) { abort = true; } } for (int i = 0; (i < 10) && !abort; ++i) { // no warning if (b) { abort = true; } } for (;;) {} // no-warning int x = 10; for (int i = x; i < 42; i++) { x++; // no warning } // 1st clause item 2 + loop counter modification for(x = 0; x < 10; x++) { x++; // 14.2 } // third clause: 2 persistent side effects instead of 1 (14.2) for (int i = 0; i < 10; i++, x++) { // 12.3 14.2 } // 2 loop counters, there shall be only 1 for(int i=0, j=0; (i<10) && (j<10); i++, j++) { // 12.3 14.2 } for (int i = (x - 3); i < 42; i++) { x ^= 3; // no warning } for (int i = 0, j = 19; i < 42; i++) { // 12.3 14.2 i += 12; // 14.2 j /= 3; // TODO: 14.2 } for (int i = 0; i < 19; i++) { for (int j = 0; j < 42; j++) { i--; // 14.2 for (int k = j; k > 5; k--) { i++; // 14.2 for (int h = 35; h > 5; k++) // 14.2 {} } } } static struct { uint16_t block; bool readSuccessful; int32_t i; } opState; for (opState.block = 0U; opState.block < 10U; opState.block++) {;} //no-warning for (misra_14_2_init_value(&opState.i); opState.i < 10; ++opState.i) {} //no-warning } static void misra_14_2_fn2(void) { int y = 0; // Handle cases when i is not treated as loop counter according MISRA // definition. for (int i = 0, j = 19; y < 10, --j > 10; y++, j--) { // 14.2 12.3 i++; // no warning } for (int i = 0, j = 19; y < 10, --j > 10; y++, j--) { // 14.2 12.3 i++; // no warning } // 1st clause is not empty, but is not used in 2nd and 3rd clause for (int i = 0; y < 10; y++) { // 14.2 i++; // no warning } for (; y < 10; y++) {} // without 1st clause, no error for (int i = 0; i < 10; y++) { // 14.2 i++; // no warning } for (int i = 0; y < 10; i++) { // 14.2 i++; // no warning } for (int i = 0; i < 10; (y+=i)) { // 14.2 i++; // no warning } // i is a loop counter according MISRA definition for (int i = 0; i < 10; i++) { i++; // 14.2 if (++i > 5) { // 14.2 break; } } for (int i = 0; i < 10; (i+=42)) { i++; // 14.2 } for (int i = 0; i < 10; (i|=y)) { i++; // 14.2 } return 0; } struct { unsigned int x:1; unsigned int y:1; } r14_4_struct; // 8.4 static void misra_14_4(bool b) { if (x+4){} //config else {} if (b) {} else {} if (r14_4_struct.x) {} // #12079 if (z) {} //config } // #12417 struct bar_12417{ int a; }; static int foo_12417(void){ int ret = 1; if (sizeof(struct bar_12417) == 0U){ // no warning for misra-config ret = 0; } return ret; } static void misra_15_1(void) { goto a1; // 15.1 a1: } static void misra_15_2(void) { label: goto label; // 15.2 15.1 } static void misra_15_3(int a) { int x = 0; int y; if (x!=0) { goto L1; // 15.3 15.1 if (y!=0) { L1: } else {} } else {} switch (x) { case 0: if (x == y) { goto L2; // 15.3 15.1 } goto L2; // 15.3 15.1 L3: foo(); if (a == 0x42) { // Compliant: goto L3; // 15.1 15.2 } break; case 1: y = x; L2: ++x; break; default: break; } } static void misra_15_4(void) { misra_15_4_label: return; int x = 0; int y = 0; int z = 0; // Break on different loop scopes for (x = 0; x < 42; ++x) { if (x==1) { break; } for (y = 0; y < 42; ++y) { // 15.4 if (y==1) { break; } if (y==2) { break; } for (z = 0; y < 42; ++z) { // 14.2 if (z==1) { break; } } } } // Break in while loop do { // 15.4 if(x == 1) { break; } if(x == 2) { break } x++; } while(x != 42); // Break and goto in same loop for (int x = 0; x < 10; ++x) { // 15.4 if (x == 1) { break; } if (x == 2) { goto misra_15_4_label; // 15.1 15.2 } } // Inner loop uses goto for (x = 0; x < 42; ++x) { // 15.4 if (x==1) { break; } for (y = 0; y < 42; ++y) { if (y == 1) { goto misra_15_4_label; // 15.1 15.2 } } } // Allow switch with multiple breaks inside loop for (x = 0; x < 42; ++x) { switch (x) { case 1: break; default: break; } } // Do not allow switch with multiple gotos inside loop for (x = 0; x < 42; ++x) { // 15.4 switch (x) { case 1: goto misra_15_4_label; // 15.1 15.2 break; default: goto misra_15_4_label; // 15.1 15.2 break; } } } static int misra_15_5(int x) { if (x!=0) { return 1; // 15.5 } else {} return 2; } static void misra_15_6(int x) { if (x!=0); // 15.6 else{} #if A>1 // 20.9 (void)0; #endif #if A > 0x42 // 20.9 if (true) { (void)0; } if (true) #endif { (void)0; } // no-warning do {} while (x<0); // no-warning } static void misra_15_6_fp(void) { uint8_t value = 0U; do // Test { value++; } while (value < 2U); } #if defined(M_20_9) && M_20_9 > 1 // no-warning (#10380) #endif static void misra_15_7(int x, int a, int b) { uint32_t var = 0; uint32_t var2 = 0; if (x!=0){} // no-warning if (x!=0){} else if(x==1){} // 15.7 if (x!=0){} else if(x==1){}else{;} // no-warning if (x!=0) { } else { var = 5u; if (var != 5u) { var2 = 10u; } // no-warning } if (a==2) {} else if (b==4) {} // 15.7 if (a==2) {} else { if (b==4) {} } // no-warning } static void misra_16_1(int32_t i) { switch (i) { int8_t x; // 16.1 default: // 16.3 16.5 break; if (i != 18) {} // 16.1 case 1: // 16.3 break; } } static void misra_16_2(int y) { switch (x) { default: break; case 1: while (y>4) { case 2: break; // 16.2 } break; } } static void misra_16_3(int b) { int a; switch (x) { case 1: case 2: a=1; case 3: // 16.3 a=2; // fallthrough case 5: break; case 7: a=3; [[fallthrough]]; case 8: a=4; break; case 9: if (a==b) { break; } case 10: // 16.3 return; // 15.5 case 11: { break; } case 12: default: break; } switch (x) { case 1: // comment 1 { a = 1; break; } case 2: // comment 2 { a = 2; break; } default: { break; } } switch (x) { case 1: break; default: // 16.5 x++; case 19: // 16.3 break; case 20: x + 2; x + 3; break; } switch (x) { // 16.6 default:; } // 16.3 switch (x) { default:; } // 16.3 16.6 switch (x) { case 20: x + 2; x + 3; break; case 21: x + 2; x + 3; break; default: ; } // 16.3 switch (x) { // 16.4 16.6 case 1: x++; break; case 2: x++; } // 16.3 #define M_16_3(a,b,default) { (a), (b), (default) }, } static void misra_16_4(void) { switch (x) { // 16.4 case 1: break; case 2: break; } } static void misra_16_5(void) { switch (x) { case 1: break; default: // 16.5 break; case 2: break; } } static void misra_16_6(void) { switch (x) { // 16.6 default: break; } switch (x) { case 1: break; case 2: break; default: break; } // No 16 6 in this switch: switch (x) { case A: return 1; // 15.5 case B: return 1; // 15.5 case C: return 1; // 15.5 default: return 2; // 15.5 } } static void misra_16_7(void) { switch (x != 123) { // 16.7 case 1: break; default: break; } } static void misra_17_1(void) { va_list(); // 17.1 17.7 va_arg(); // 17.1 va_start(); // 17.1 va_end(); // 17.1 va_copy(); // 17.1 } static void misra_17_2_ok_1(void) { ; } static void misra_17_2_ok_2(void) { misra_17_2_ok_1(); // no-warning } static void misra_17_2_1(void) { misra_17_2_ok_1(); // no-warning misra_17_2_1(); // 17.2 misra_17_2_ok_2(); // no-warning misra_17_2_1(); // 17.2 } static void misra_17_2_2(void) { misra_17_2_3(); // 17.2 } static void misra_17_2_3(void) { misra_17_2_4(); // 17.2 } static void misra_17_2_4(void) { misra_17_2_2(); // 17.2 misra_17_2_3(); // 17.2 } static void misra_17_2_5(void) { misra_17_2_ok_1(); // no-warning misra_17_2_5(); // 17.2 misra_17_2_1(); // no-warning } bool (*dostuff)(); //8.2 8.4 static void misra_17_3(void) { if (dostuff()) {} } static void misra_config(const char* str) { if (strlen(str) > 3){} //10.4 if (sizeof(int) > 1){} //10.4 } static void misra_17_6(int x[static 20]) {(void)x;} // 17.6 static int calculation(int x) { return x + 1; } static void misra_17_7(void) { calculation(123); // 17.7 int (*calc_ptr)(int) = &calculation; calc_ptr(123); // 17.7 int y = calc_ptr(123); } static void misra_17_8(int x) { x = 3; // 17.8 } static void misra_18_4(void) { int b = 42; int *bp = &b; bp += 1; // 18.4 bp -= 2; // 18.4 int *p = bp - 2; // 18.4 int *ab = &b + 1; // 18.4 p = bp + p; // 18.4 bp = 1 + p + 1; // 18.4 b += 19; // no-warning b = b + 9; // no-warning } static void misra_18_5(void) { int *** p; // 18.5 } struct { uint16_t len; struct { uint8_t data_1[]; // 18.7 } nested_1; struct named { struct { uint8_t len_1; uint32_t data_2[]; // 18.7 } nested_2; uint8_t data_3[]; // 18.7 } nested_3; } r18_7_struct; // 8.4 struct { uint16_t len; int (*array_param_func_ptr)(char const *argv[], int argc); // no-warning uint8_t data_1[ 19 ]; uint8_t data_2[ ]; // 18.7 } r18_7_struct; // 8.4 typedef enum { R18_8_ENUM_CONSTANT_0, R18_8_ENUM_CONSTANT_1, } r18_8_enum; static void misra_18_8(int x) { int buf1[10]; int buf2[sizeof(int)]; int vla[x]; // 18.8 // #9498 int vlb[y]; // config static const unsigned char arr18_8_1[] = UNDEFINED_ID; static uint32_t enum_test_0[R18_8_ENUM_CONSTANT_0] = {0}; } union misra_19_2 { }; // 19.2 #include "notfound.h" // 20.1 #define int short // 20.4 #define inline "foo" // no warning in C90 standard #undef X // 20.5 #define M_20_7_1(A) (A+1) // 20.7 #define M_20_7_2(A,B) (1+AB+2) // no warning #define M_20_7_3(A) ((A)+A) // 20.7 #define M_20_7_4(A) x##A // 20.10 this test was written to see there are not FPs #define M_20_7_5(A,B) f(A, B) // no warning #define M_20_7_6(x) a ## x = ( x ) // 20.10 #define M_20_7_7(x) a = # x // 20.10 #define M_20_7_8(x, fn) a = fn ( # x ) // 20.7 20.10 #define M_20_7_9(x, fn) a = (fn) ( # x ) // 20.10 #define M_20_7_10(A, B) (A " " B) #define M_20_7_11(A, B, C) (A " " B " " C) #define M_20_7_12(A, B, C) (A " " B + C) // 20.7 #define M_20_7_13(A, B, C) (A + B " " C) // 20.7 #define M_20_7_14(STRING1, STRING2) (STRING1 " " STRING2) #define M_20_7_15(STRING1, STRING2, STRING3) (STRING1 " " STRING2 " " STRING3) #define M_20_7_16(STRING1, STRING2, STRING3) (STRING1 " " STRING2 + STRING3) // 20.7 #define M_20_7_17(STRING1, STRING2, STRING3) (STRING1 + STRING2 " " STRING3) // 20.7 // Compliant: M is a structure member name, not an expression struct { int a; } struct_20_7_s; // 8.4 #define M_20_7_6(M) struct_20_7.M #define M_20_7_7(M) (struct_20_7).M #define MUL(a ,b ) ( a * b ) // 20.7 #if __LINE__ // 20.8 #elif 2+5 // 20.8 #elif 2-2 #endif #if A // 20.9 #elif B || C // 20.9 #endif #define M_20_10(a) (#a) // 20.10 #define M_20_11(a) # a ## 1 // 20.11 20.10 #define M_20_12_AA 0xffff #define M_20_12_BB(x) (x) + wow ## x // 20.12 20.10 misra_20_12 = M_20_12_BB(M_20_12_AA); #else1 // 20.13 #ifdef A # define somethingis 5 // no warning # define func_20_13(v) (v) // no warning #else # definesomethingis 6 // 20.13 # def fun_2013(v) () // 20.13 #endif #define _Incompatible 0xdeadbeef // 21.1 #define __Incompatible 0xdeadbeef // 21.1 #define __starts_with_lower 0xdeadbeef // 21.1 #define __MY_HEADER_ // 21.1 #define _macro_starts_with_lower 1 // no warning static int _file_scope_id_21_1 = 42; // no warning static int _file_scope_id_21_1_fn(void) { return 42; } // no warning static int misra_21_1(void) { int _a = 42; // no warning: only directives affected errno = EINVAL; // no warning _a ++; // no warning _exit(1); // no warning return _a; // no warning } static int _misra_21_1_2(void); // no warning #define errno 11 // 21.1 #undef errno // 20.5 #define __BUILTIN_SOMETHING 123 // 21.2 21.1 extern void *memcpy ( void *restrict s1, const void *restrict s2, size_t n ); // 21.2 8.14 static void misra_21_3(void) { p1=malloc(10); // 21.3 p2=calloc(10); // 21.3 realloc(10); // 21.3 free(p1); // 21.3 } static void misra_21_7(void) { (void)atof(str); // 21.7 (void)atoi(str); // 21.7 (void)atol(str); // 21.7 (void)atoll(str); // 21.7 } static void misra_21_8(void) { abort(); // 21.8 (void)getenv("foo"); // 21.8 exit(-1); // 21.8 } static void misra_21_9(void) { (void)bsearch(key,base,num,size,cmp); // 21.9 qsort(base,num,size,cmp); // 21.9 } static void misra_21_12(void) { int rc; fexcept_t f; // 21.12 rc = feclearexcept(1); // 21.12 rc = fegetexceptflag(&f, 1); // 21.12 rc = feraiseexcept(1); // 21.12 rc = fesetexceptflag(&f, 1); // 21.12 rc = fetestexcept(1); // 21.12 } static void misra_21_14(uint8_t *x) { (void)strcpy(x, "123"); (void)memcmp(x, y, 100); // 21.14 (void)memcmp("abc", y, 100); // 21.14 21.16 } static void misra_21_15(uint8_t *x, uint16_t *y) { (void)memcpy(x, y, 10); // 21.15 (void)memmove(x, y, 10); // 21.15 (void)memcmp(x, y, 10); // 21.15 } struct misra_21_16_S { int a; int b; }; static void misra_21_16_f1(struct misra_21_16_S *s1, struct misra_21_16_S *s2) { (void)memcmp(s1, s2, 10); // 21.16 } static void misra_21_16_f2(char *x, char *y) { (void)memcmp(x, y, 10); // 21.16 } typedef enum { R21_16_A, R21_16_B} r21_16_enum; static void misra_21_16_f3(void) { int const a[2] = {0}; int const b[2] = {0}; (void)memcmp(a, b, 2); // no-warning uint8_t const c[2] = {0}; uint8_t const d[2] = {0}; (void)memcmp(c, d, 2); // no-warning bool const e[2] = {0}; bool const f[2] = {0}; (void)memcmp(e, f, 2); // no-warning r21_16_enum const g[2] = {0}; r21_16_enum const h[2] = {0}; (void)memcmp(g, h, 2); // no-warning char const i[2] = {0}; char const j[2] = {0}; (void)memcmp(i, j, 2); // 21.16 } static void misra_21_19(void) { char *s = setlocale(LC_ALL,0); // 21.19 const struct lconv *conv = localeconv (); conv->decimal_point = "^"; // 21.19 } static void misra_21_20(void) { const char *res1 = setlocale ( LC_ALL, 0 ); (void) setlocale ( LC_MONETARY, "French" ); if (res1) {} // 21.20 14.4 } static void misra_21_21(void) { (void)system("ls"); // 21.21 } static void misra_22_5(FILE *f) { int x = *f; // 22.5 int y = f->pos; // 22.5 } static void misra_22_7(char ch) { if (EOF == ch) {} // 22.7 } static void misra_22_8(void) { (void)strtoll("123", NULL, 10); // 22.8 if (errno == 0) {} } static void misra_22_9(void) { errno = 0; (void)strtoll("123", NULL, 10); // 22.9 } static void misra_22_10(void) { errno = 0; f = atof ( "A.12" ); // 21.7 if ( 0 == errno ) {} // 22.10 errno = 0; f = strtod ( "A.12", NULL ); if ( 0 == errno ) {} // #10855 f = strtol(numbuf, 0, (formatHex == 0U) ? 0 : 16); if (errno != 0) {} // #11752 #define NULL_PTR ((void*)0) f = strtod(inStr, NULL_PTR); if(errno != 0) {} } // #12448 static void check_misra_config(void) { if (sizeof(struct bar) == 0U) {} //no warning if (sizeof(int abc) == 0U) {} //no warning if (sizeof(xyz) == 0U) {} //no warning if (sizeof(const pqr) == 0U) {} //no warning if (sizeof(const int* const pqrs) == 0U) {} //no-warning } cppcheck-2.17.1/addons/test/misra/misra-test.cpp000066400000000000000000000005211475760761100215340ustar00rootroot00000000000000// #8441 class C { int a; int b; C(void) : a(1), b(1) { c; } }; class misra_21_1_C { public: misra_21_1_C operator=(const misra_21_1_C &); }; class C2 { public: C2(void); private: void* f; }; C2::C2(void) : f(NULL) {} static void test_misra_21_1_crash(void) { auto misra_21_1_C a, b; // 12.3 a = b; } cppcheck-2.17.1/addons/test/misra/misra-test.h000066400000000000000000000004731475760761100212070ustar00rootroot00000000000000#ifndef MISRA_TEST_H #define MISRA_TEST_H struct misra_h_s { int foo; }; bool test(char *a); // OK int misra_8_2_no_fp(int a); void misra_8_4_bar(void); // #12978 typedef struct m8_4_stErrorDef { uint8_t ubReturnVal; } m8_4_stErrorDef; extern const m8_4_stErrorDef * m8_4_pubTestPointer; #endif // MISRA_TEST_H cppcheck-2.17.1/addons/test/misra/misra2012_rules_dummy_ascii.txt000066400000000000000000000001251475760761100247160ustar00rootroot00000000000000Appendix A Summary of guidelines Rule 1.1 Text of rule 1.1 Rule 1.2 Text of rule 1.2 cppcheck-2.17.1/addons/test/misra/misra2012_rules_dummy_utf8.txt000066400000000000000000000001451475760761100245160ustar00rootroot00000000000000Appendix A Summary of guidelines Rule 1.1 Text of rule 1.1, utf8 test: ∑ Rule 1.2 Text of rule 1.2 cppcheck-2.17.1/addons/test/misra/misra2012_rules_dummy_windows1250.txt000066400000000000000000000001521475760761100256300ustar00rootroot00000000000000Appendix A Summary of guidelines Rule 1.1 Text of rule 1.1, windows1250 test: Rule 1.2 Text of rule 1.2 cppcheck-2.17.1/addons/test/misra/misra_rules_dummy.txt000066400000000000000000000005141475760761100232430ustar00rootroot00000000000000Appendix A Summary of guidelines Rule 3.1 Required R3.1 text. Rule 4.1 Required R4.1 text. Rule 10.4 Mandatory R10.4 text. Rule 11.5 Advisory R11.5 text. Rule 15.5 Advisory R15.5 text. Rule 15.6 Required R15.6 text. Rule 17.7 Required R17.7 text. Rule 20.1 Advisory R20.1 text. Rule 21.3 Required R21.3 text. Rule 21.4 R21.4 text. cppcheck-2.17.1/addons/test/misra/misra_rules_empty_lines.txt000066400000000000000000000003231475760761100244360ustar00rootroot00000000000000Appendix A Summary of guidelines Rule 1.1 Add this rule and parse to next, skipping empty lines. Rule 1.2 Rule text. Rule 1.3 There is 3 rules. cppcheck-2.17.1/addons/test/misra/misra_rules_multiple_lines.txt000066400000000000000000000004061475760761100251350ustar00rootroot00000000000000Appendix A Summary of guidelines Rule 1.1 Multiple lines text. Rule 1.2 Multiple lines text. Rule 1.3 Required Multiple lines text. Rule 1.4 Should Starts from lowercase letter. Rule 1.5 Should starts from lowercase letter. Rule 1.6 Can contain empty lines. cppcheck-2.17.1/addons/test/misra/misra_rules_structure.txt000066400000000000000000000003721475760761100241520ustar00rootroot00000000000000Here can be any text. Incorrect definitions: Appendix A Appendix A Summary: Rule 1.1 Error! Here we go: Appendix A Summary of guidelines Rule 1.2 Rule text. Rule 2.1 Rule text for 2.1. Stop parsing after this line: Appendix B Rule 1.3 Error! cppcheck-2.17.1/addons/test/misra/suppressions.txt000066400000000000000000000003661475760761100222650ustar00rootroot00000000000000misra-c2012-21.6:*/misra-suppressions1-test.c:7 misra-c2012-17.3 misra-c2012-8.4:*/misra-suppressions1-test.c misra-c2012-4.1:*/misra-suppressions2-test.c misra-c2012-8.4:*/misra-suppressions2-test.c misra-c2012-19.2:*/misra-suppressions2-test.c cppcheck-2.17.1/addons/test/misra_test.py000066400000000000000000000151751475760761100203640ustar00rootroot00000000000000# Running the test with Python 3: # Command in cppcheck directory: # PYTHONPATH=./addons python3 -m pytest addons/test/misra_test.py import pytest import re import sys import os from .util import dump_create, dump_remove, convert_json_output TEST_SOURCE_FILES = [os.path.join('addons','test','misra','misra-test.c')] def remove_misra_config(s:str): ret = '' for line in s.splitlines(): if '[misra-config]' not in line: ret += line + '\n' return ret @pytest.fixture(scope="function") def checker(): from addons.misra import MisraChecker, MisraSettings, get_args_parser parser = get_args_parser() args = parser.parse_args([]) settings = MisraSettings(args) return MisraChecker(settings) # FIXME: files are generates in the source tree so it will cause issues if tests are run with xdist. @pytest.fixture def test_files(): for f in TEST_SOURCE_FILES: dump_create(f) yield for f in TEST_SOURCE_FILES: dump_remove(f) def test_loadRuleTexts_structure(checker): checker.loadRuleTexts("./addons/test/misra/misra_rules_structure.txt") assert(checker.ruleTexts.get(101, None) is None) assert(checker.ruleTexts[102].text == "Rule text.") assert(checker.ruleTexts.get(103, None) is None) assert(checker.ruleTexts[201].text == "Rule text for 2.1.") assert(checker.ruleTexts.get(202, None) is None) def test_loadRuleTexts_empty_lines(checker): checker.loadRuleTexts("./addons/test/misra/misra_rules_empty_lines.txt") assert(len(checker.ruleTexts) == 3) assert(len(checker.ruleTexts[102].text) == len("Rule text.")) def test_loadRuleTexts_mutiple_lines(checker): checker.loadRuleTexts("./addons/test/misra/misra_rules_multiple_lines.txt") assert(checker.ruleTexts[101].text == "Multiple lines text.") assert(checker.ruleTexts[102].text == "Multiple lines text.") assert(checker.ruleTexts[103].text == "Multiple lines text.") assert(checker.ruleTexts[104].text == "Should") assert(checker.ruleTexts[105].text == "Should starts from lowercase letter.") assert(checker.ruleTexts[106].text == "Can contain empty lines.") def test_verifyRuleTexts(checker, capsys): checker.loadRuleTexts("./addons/test/misra/misra_rules_dummy.txt") checker.verifyRuleTexts() captured = capsys.readouterr().out assert("21.3" not in captured) assert("1.3" in captured) def test_rules_misra_severity(checker): checker.loadRuleTexts("./addons/test/misra/misra_rules_dummy.txt") assert(checker.ruleTexts[1004].misra_severity == 'Mandatory') assert(checker.ruleTexts[401].misra_severity == 'Required') assert(checker.ruleTexts[1505].misra_severity == 'Advisory') assert(checker.ruleTexts[2104].misra_severity == '') def test_json_out(checker, capsys, test_files): sys.argv.append("--cli") checker.loadRuleTexts("./addons/test/misra/misra_rules_dummy.txt") checker.parseDump("./addons/test/misra/misra-test.c.dump") captured = capsys.readouterr() captured = captured.out.splitlines() sys.argv.remove("--cli") json_output = convert_json_output(captured) assert("Mandatory" in json_output['c2012-10.4'][0]['extra']) assert("Required" in json_output['c2012-21.3'][0]['extra']) assert("Advisory" in json_output['c2012-20.1'][0]['extra']) def test_rules_cppcheck_severity(checker, capsys, test_files): checker.loadRuleTexts("./addons/test/misra/misra_rules_dummy.txt") checker.parseDump("./addons/test/misra/misra-test.c.dump") captured = capsys.readouterr().err assert("(error)" not in remove_misra_config(captured)) assert("(warning)" not in captured) assert("(style)" in captured) def test_rules_cppcheck_severity_custom(checker, capsys, test_files): checker.loadRuleTexts("./addons/test/misra/misra_rules_dummy.txt") checker.setSeverity("custom-severity") checker.parseDump("./addons/test/misra/misra-test.c.dump") captured = capsys.readouterr().err assert("(error)" not in remove_misra_config(captured)) assert("(warning)" not in captured) assert("(style)" not in captured) assert("(custom-severity)" in captured) def test_rules_suppression(checker, capsys): test_sources = ["addons/test/misra/misra-suppressions1-test.c", "addons/test/misra/misra-suppressions2-test.c"] for src in test_sources: re_suppressed= r"\[%s\:[0-9]+\]" % src dump_create(src, "--suppressions-list=addons/test/misra/suppressions.txt","--inline-suppr") checker.parseDump(src + ".dump") captured = capsys.readouterr().err found = re.search(re_suppressed, captured) assert found is None, 'Unexptected output:\n' + captured dump_remove(src) def test_arguments_regression(): args_ok = ["-generate-table", "--rule-texts=./addons/test/assets/misra_rules_multiple_lines.txt", "--verify-rule-texts", "-t=foo", "--template=foo", "--suppress-rules=15.1", "--quiet", "--cli", "--no-summary", "--show-suppressed-rules", "-P=src/", "--file-prefix=src/", "--severity=misra-warning"] # Arguments with expected SystemExit args_exit = ["--non-exists", "--non-exists-param=42", "-h", "--help"] from addons.misra import get_args_parser # sys.argv contains all pytest arguments - so clear all existing arguments first and restore afterwards sys_argv_old = sys.argv sys.argv = [sys.argv[0]] try: for arg in args_exit: sys.argv.append(arg) with pytest.raises(SystemExit): parser = get_args_parser() parser.parse_args() sys.argv.remove(arg) for arg in args_ok: sys.argv.append(arg) try: parser = get_args_parser() parser.parse_args() except SystemExit: pytest.fail("Unexpected SystemExit with '%s'" % arg) sys.argv.remove(arg) finally: sys.argv = sys_argv_old def test_read_ctu_info_line(checker): assert checker.read_ctu_info_line('{') is None assert checker.read_ctu_info_line('{"summary":"123"}') is None assert checker.read_ctu_info_line('{"data":123}') is None assert checker.read_ctu_info_line('{"summary":"123","data":123}') is not None def test_platform(checker): test_file = os.path.join('addons','test','misra','misra-test.c') dump_create(test_file, "--language=c++") checker.parseDump(test_file + ".dump") assert checker.is_cpp is True dump_create(test_file, "--language=c") checker.parseDump(test_file + ".dump") assert checker.is_cpp is False cppcheck-2.17.1/addons/test/naming_test.c000066400000000000000000000003161475760761100203030ustar00rootroot00000000000000// To test: // ~/cppcheck/cppcheck --dump naming_test.c && python ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.c.dump // Should not crash when there is no name void func(int number, int); cppcheck-2.17.1/addons/test/naming_test.cpp000066400000000000000000000005661475760761100206520ustar00rootroot00000000000000// To test: // ~/cppcheck/cppcheck --dump naming_test.cpp && python ../naming.py --var='[a-z].*' --function='[a-z].*' naming_test.cpp.dump // No error for mismatching Constructor/Destructor names should be issued, they can not be changed. class TestClass1 { TestClass1() {} ~TestClass1() {} TestClass1(const TestClass1 &) {} TestClass1(TestClass1 &&) {} }; cppcheck-2.17.1/addons/test/path1/000077500000000000000000000000001475760761100166445ustar00rootroot00000000000000cppcheck-2.17.1/addons/test/path1/misra-suppressions1-test.c000066400000000000000000000016351475760761100237410ustar00rootroot00000000000000// To test: // ../../cppcheck --suppressions-list=suppressions.txt --dump misra-suppressions*-test.c && python ../misra.py misra-suppressions*-test.c.dump // There should be no violations reported // This needs to stay at line number 7 to make the test pass // If it is changed update suppressions.txt with the new line number #include //21.6 extern int misra_5_2_var_hides_var______31x; static int misra_5_2_var_hides_var______31y;//5.2 static int misra_5_2_function_hides_var_31x; void misra_5_2_function_hides_var_31y(void) {}//5.2 void foo(void) { int i; switch(misra_5_2_func1()) //16.4 16.6 { case 1: { do { for(i = 0; i < 10; i++) { if(misra_5_2_func3()) //14.4 { int misra_5_2_var_hides_var_1____31x; int misra_5_2_var_hides_var_1____31y;//5.2 } } } while(misra_5_2_func2()); //14.4 } } } cppcheck-2.17.1/addons/test/path1/misra-suppressions2-test.c000066400000000000000000000010221475760761100237300ustar00rootroot00000000000000// To test: // ../../cppcheck --suppressions-list=suppressions.txt --dump misra-suppressions*-test.c && python ../misra.py misra-suppressions*-test.c.dump // There should be no violations reported union misra_5_2_field_hides_field__63x { //19.2 int misra_5_2_field_hides_field__31x; int misra_5_2_field_hides_field__31y;//5.2 }; struct misra_5_2_field_hides_field__63y { //5.2 int misra_5_2_field_hides_field1_31x; int misra_5_2_field_hides_field1_31y;//5.2 }; const char *s41_1 = "\x41g"; // 4.1 const char *s41_2 = "\x41\x42"; cppcheck-2.17.1/addons/test/threadsafety/000077500000000000000000000000001475760761100203125ustar00rootroot00000000000000cppcheck-2.17.1/addons/test/threadsafety/MT-Unsafe.cpp000066400000000000000000000034231475760761100225570ustar00rootroot00000000000000/* * Cppcheck - A tool for static C/C++ code analysis * Copyright (C) 2023 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /* * This does not match the standard cppchek test code, * because I haven't figured that out yet. * This code does compile and run, and does demonstrate * the issues that the threadsafety.py addon is supposed to find. * It does not use threads ! */ #include #include #include void threadsafety_static() { // cppcheck-suppress threadsafety-threadsafety static unsigned int nCount = 0; nCount++; printf("%d\n", nCount); } void threadsafety_call() { time_t now = time(nullptr); // cppcheck-suppress threadsafety-unsafe-call printf("%s\n", ctime(&now)); } // cppcheck --addon=threadsafety // should *not* find any problems with this function. void threadsafety_safecall() { char haystack[] = "alphabet"; char needle[] = "Alph"; char* found = strcasestr(haystack, needle); printf("%s %sin %s\n", needle, found ? "" : "not ", haystack); } int main() { threadsafety_static(); threadsafety_call(); threadsafety_safecall(); threadsafety_static(); return 0; } cppcheck-2.17.1/addons/test/threadsafety/local_static.cpp000066400000000000000000000001651475760761100234610ustar00rootroot00000000000000struct Dummy { int x; }; void func() { // cppcheck-suppress threadsafety-threadsafety static Dummy dummy; } cppcheck-2.17.1/addons/test/threadsafety/local_static_const.cpp000066400000000000000000000001751475760761100246700ustar00rootroot00000000000000struct Dummy { int x; }; void func() { // cppcheck-suppress threadsafety-threadsafety-const static const Dummy dummy; } cppcheck-2.17.1/addons/test/util.py000066400000000000000000000024011475760761100171530ustar00rootroot00000000000000# Helpers for pytest tests import subprocess import json import os def find_cppcheck_binary(): possible_locations = [ "./cppcheck", "./build/bin/cppcheck", r".\bin\cppcheck.exe", ] for location in possible_locations: if os.path.exists(location): break else: raise RuntimeError("Could not find cppcheck binary") return location def dump_create(fpath, *argv): cppcheck_binary = find_cppcheck_binary() cmd = [cppcheck_binary, "--dump", "-DDUMMY", "--quiet", fpath] + list(argv) with subprocess.Popen(cmd) as p: p.communicate() if p.returncode != 0: raise OSError("cppcheck returns error code: %d" % p.returncode) def dump_remove(fpath): os.remove(fpath + ".dump") def convert_json_output(raw_json_strings): """Convert raw stdout/stderr cppcheck JSON output to python dict.""" json_output = {} for line in raw_json_strings: if line.startswith('{"summary":'): continue try: json_line = json.loads(line) # json_output[json_line['errorId']] = json_line json_output.setdefault(json_line['errorId'], []).append(json_line) except ValueError: pass return json_output cppcheck-2.17.1/addons/test/y2038/000077500000000000000000000000001475760761100164145ustar00rootroot00000000000000cppcheck-2.17.1/addons/test/y2038/y2038-inc.h000066400000000000000000000007771475760761100201340ustar00rootroot00000000000000#ifndef __INC2038 #define _INC2038 /* * This file defines _USE_TIME_BITS64. * It plays the role of a Y2038-proof glibc. */ #define _USE_TIME_BITS64 /* * Declare just enough for clock_gettime */ typedef int clockid_t; typedef int __time_t; typedef long int __syscall_slong_t; struct timespec { __time_t tv_sec; /* Seconds. */ __syscall_slong_t tv_nsec; /* Nanoseconds. */ }; extern int clock_gettime(clockid_t clk_id, struct timespec *tp); #define CLOCK_REALTIME 0 #endif /* INC2038 */ cppcheck-2.17.1/addons/test/y2038/y2038-test-1-bad-time-bits.c000066400000000000000000000004521475760761100231000ustar00rootroot00000000000000#include #include /* * Define _TIME_BITS unequal to 64 to trigger error */ #define _TIME_BITS 62 #include "y2038-inc.h" int main(int argc, char **argv) { clockid_t my_clk_id = CLOCK_REALTIME; struct timespec *my_tp; return clock_gettime(my_clk_id, &my_tp); } cppcheck-2.17.1/addons/test/y2038/y2038-test-2-no-time-bits.c000066400000000000000000000004351475760761100227700ustar00rootroot00000000000000#include #include /* * Do not define _TIME_BITS but have _USE_TIME_BITS64 defined */ #include "y2038-inc.h" int main(int argc, char **argv) { clockid_t my_clk_id = CLOCK_REALTIME; struct timespec *my_tp; return clock_gettime(my_clk_id, &my_tp); } cppcheck-2.17.1/addons/test/y2038/y2038-test-3-no-use-time-bits.c000066400000000000000000000004321475760761100235600ustar00rootroot00000000000000#include #include /* * Include bad _USE_TIME_BITS64 definition to trigger error */ #define _TIME_BITS 64 int main(int argc, char **argv) { clockid_t my_clk_id = CLOCK_REALTIME; struct timespec *my_tp; return clock_gettime(my_clk_id, &my_tp); } cppcheck-2.17.1/addons/test/y2038/y2038-test-4-good.c000066400000000000000000000004331475760761100214110ustar00rootroot00000000000000/* * Define _TIME_BITS equal to 64 so that glibc knows we want Y2038 support. */ #define _TIME_BITS 64 #include "y2038-inc.h" int main(int argc, char **argv) { clockid_t my_clk_id = CLOCK_REALTIME; struct timespec *my_tp; return clock_gettime(my_clk_id, &my_tp); } cppcheck-2.17.1/addons/test/y2038/y2038-test-5-good-no-time-used.c000066400000000000000000000003301475760761100237120ustar00rootroot00000000000000/* * C file that does not use any time functionality -> no errors should * be reported. */ #include int main(int argc, char **argv) { if (argc > 1) { printf("Hello"); } return 0; } cppcheck-2.17.1/addons/test/y2038_test.py000066400000000000000000000117371475760761100200360ustar00rootroot00000000000000# Running the test with Python 2: # Be sure to install pytest version 4.6.4 (newer should also work) # Command in cppcheck directory: # python -m pytest addons/test/test-y2038.py # # Running the test with Python 3: # Command in cppcheck directory: # PYTHONPATH=./addons python3 -m pytest addons/test/test-y2038.py import sys import pytest from addons.y2038 import check_y2038_safe from .util import dump_create, dump_remove, convert_json_output TEST_SOURCE_FILES = ['./addons/test/y2038/y2038-test-1-bad-time-bits.c', './addons/test/y2038/y2038-test-2-no-time-bits.c', './addons/test/y2038/y2038-test-3-no-use-time-bits.c', './addons/test/y2038/y2038-test-4-good.c', './addons/test/y2038/y2038-test-5-good-no-time-used.c'] def setup_module(module): sys.argv.append("--cli") for f in TEST_SOURCE_FILES: dump_create(f) def teardown_module(module): sys.argv.remove("--cli") for f in TEST_SOURCE_FILES: dump_remove(f) def test_1_bad_time_bits(capsys): is_safe = check_y2038_safe('./addons/test/y2038/y2038-test-1-bad-time-bits.c.dump', quiet=True) assert(is_safe is False) captured = capsys.readouterr() captured = captured.out.splitlines() json_output = convert_json_output(captured) # Has exactly one warnings of _TIME_BITS and _USE_TIME_BITS64 kind. assert(len(json_output['type-bits-undef']) == 1) assert(len(json_output['type-bits-not-64']) == 1) # There are 2 unsafe calls in test source and 3 in y2038-in.h unsafe_calls = json_output['unsafe-call'] assert(len([c for c in unsafe_calls if c['file'].endswith('h')]) == 3) assert(len([c for c in unsafe_calls if c['file'].endswith('c')]) == 0) def test_2_no_time_bits(capsys): is_safe = check_y2038_safe('./addons/test/y2038/y2038-test-2-no-time-bits.c.dump', quiet=True) assert(is_safe is False) captured = capsys.readouterr() captured = captured.out.splitlines() json_output = convert_json_output(captured) # _USE_TIME_BITS64 defined in y2038-inc.h header, but there is not # _TIME_BITS definition. Here must be appropriate warning. assert(len(json_output['type-bits-undef']) == 1) assert(json_output.get('type-bits-not-64') is None) # y2038-in.h still has y2038-unsafe calls. unsafe_calls = json_output['unsafe-call'] assert(len([c for c in unsafe_calls if c['file'].endswith('h')]) == 3) def test_3_no_use_time_bits(capsys): is_safe = check_y2038_safe('./addons/test/y2038/y2038-test-3-no-use-time-bits.c.dump', quiet=True) assert(is_safe is False) captured = capsys.readouterr() captured = captured.out.splitlines() json_output = convert_json_output(captured) # Included bad _USE_TIME_BITS64 definition must trigger the errors. unsafe_calls = json_output['unsafe-call'] assert(len(unsafe_calls) == 2) def test_4_good(capsys): # pylint: disable-next=unused-variable - FIXME is_safe = check_y2038_safe('./addons/test/y2038/y2038-test-4-good.c.dump', quiet=True) # assert(is_safe is True) # FIXME: This should be a "good" example returning "True" instead of "False" captured = capsys.readouterr() captured = captured.out.splitlines() json_output = convert_json_output(captured) # Defined _TIME_BITS equal to 64 so that glibc knows we want Y2038 support. # There are no warnings from C sources. unsafe_calls = json_output['unsafe-call'] assert(len([c for c in unsafe_calls if c['file'].endswith('.c')]) == 0) def test_5_good(capsys): is_safe = check_y2038_safe('./addons/test/y2038/y2038-test-5-good-no-time-used.c.dump', quiet=True) assert(is_safe is True) captured = capsys.readouterr() captured = captured.out.splitlines() json_output = convert_json_output(captured) # There are no warnings from C sources. if 'unsafe-call' in json_output: unsafe_calls = json_output['unsafe-call'] assert(len([c for c in unsafe_calls if c['file'].endswith('.c')]) == 0) def test_arguments_regression(): args_ok = ["-t=foo", "--template=foo", "-q", "--quiet", "--cli"] # Arguments with expected SystemExit args_exit = ["--non-exists", "--non-exists-param=42", "-h", "--help"] from addons.y2038 import get_args_parser # sys.argv contains all pytest arguments - so clear all existing arguments first and restore afterwards sys_argv_old = sys.argv sys.argv = [sys.argv[0]] try: for arg in args_exit: sys.argv.append(arg) with pytest.raises(SystemExit): parser = get_args_parser() parser.parse_args() sys.argv.remove(arg) for arg in args_ok: sys.argv.append(arg) try: parser = get_args_parser() parser.parse_args() except SystemExit: pytest.fail("Unexpected SystemExit with '%s'" % arg) sys.argv.remove(arg) finally: sys.argv = sys_argv_oldcppcheck-2.17.1/addons/threadsafety.py000077500000000000000000000167271475760761100177250ustar00rootroot00000000000000#!/usr/bin/env python3 """ cppcheck addon for threadsafety detection. This script analyses Cppcheck dump files to locate threadsafety issues. It warns about - static local objects - MT-Unsafe symbols listed in the "Attributes" sections of man pages. """ import re import sys import cppcheckdata # -------------------------------- # List of MT-Unsafe identifiers # -------------------------------- # This is Work In Progress. # Eventually it should contain all identifiers (types # and functions) which are MT-Unsafe. # The script tools/MT-Unsafe.py can help to re-generate this list. # It reads a man-page tree and report identifiers marked as "MT-Unsafe" # (see man 7 attributes for what this means), eg # MT-Unsafe.py /usr/share/man/man3 id_MTunsafe_full = { # MT-Unsafe types by definition # 'pthread_t', # Types marked MT-Unsafe 'const:env', 'const:hostid', 'const:mallopt', 'const:sigintr', 'race:LogMask', 'race:asctime', 'race:crypt', 'race:crypt_gensalt', 'race:cuserid/!string', 'race:dirstream', 'race:drand48', 'race:ecvt', 'race:exit', 'race:fcvt', 'race:fgetgrent', 'race:fgetpwent', 'race:fgetspent', 'race:fsent', 'race:getdate', 'race:getlogin', 'race:getopt', 'race:getspent', 'race:getspnam', 'race:grent', 'race:grgid', 'race:grnam', 'race:hostbyaddr', 'race:hostbyname', 'race:hostbyname2', 'race:hostent', 'race:hsearch', 'race:l64a', 'race:localeconv', 'race:mbrlen/!ps', 'race:mbrtowc/!ps', 'race:mbsnrtowcs/!ps', 'race:mbsrtowcs/!ps', 'race:mcheck', 'race:mntentbuf', 'race:netbyaddr', 'race:netbyname', 'race:netent', 'race:netgrent', 'race:protobyname', 'race:protobynumber', 'race:protoent', 'race:ptsname', 'race:pwent', 'race:pwnam', 'race:pwuid', 'race:qecvt', 'race:qfcvt', 'race:servbyname', 'race:servbyport', 'race:servent', 'race:sgetspent', 'race:signgam', 'race:stdin', 'race:stdout', 'race:streams', 'race:strerror', 'race:strsignal', 'race:strtok', 'race:tmbuf', 'race:tmpnam/!s', 'race:ttyent', 'race:ttyname', 'race:utent', 'race:wcrtomb/!ps', 'race:wcsnrtombs/!ps', 'race:wcsrtombs/!ps', 'sig:ALRM', 'sig:SIGCHLD/linux', # APIs marked MT-Unsafe 'asctime', 'clearenv', 'ctime', 'cuserid', 'drand48', 'ecvt', 'encrypt', 'endfsent', 'endgrent', 'endhostent', 'endnetent', 'endnetgrent', 'endprotoent', 'endpwent', 'endservent', 'endspent', 'endttyent', 'endusershell', 'endutent', 'erand48', 'error_at_line', 'ether_aton', 'ether_ntoa', 'exit', 'fcloseall', 'fcvt', 'fgetgrent', 'fgetpwent', 'fgetspent', 'fts_children', 'fts_read', 'gamma', 'gammaf', 'gammal', 'getaliasbyname', 'getaliasent', 'getchar_unlocked', 'getdate', 'getfsent', 'getfsfile', 'getfsspec', 'getgrent', 'getgrent_r', 'getgrgid', 'getgrnam', 'gethostbyaddr', 'gethostbyname', 'gethostbyname2', 'gethostent', 'gethostent_r', 'getlogin', 'getlogin_r', 'getmntent', 'getnetbyaddr', 'getnetbyname', 'getnetent', 'getnetgrent', 'getnetgrent_r', 'getopt', 'getopt_long', 'getopt_long_only', 'getpass', 'getprotobyname', 'getprotobynumber', 'getprotoent', 'getpwent', 'getpwent_r', 'getpwnam', 'getpwuid', 'getrpcbyname', 'getrpcbynumber', 'getrpcent', 'getservbyname', 'getservbyport', 'getservent', 'getspent', 'getspent_r', 'getspnam', 'getttyent', 'getttynam', 'getusershell', 'getutent', 'getutid', 'getutline', 'getwchar_unlocked', 'glob', 'gmtime', 'hcreate', 'hdestroy', 'hsearch', 'innetgr', 'jrand48', 'l64a', 'lcong48', 'localeconv', 'localtime', 'login', 'login_tty', 'logout', 'logwtmp', 'lrand48', 'mallinfo', 'mallinfo2', 'mblen', 'mbrlen', 'mbrtowc', 'mbsnrtowcs', 'mbsrtowcs', 'mbtowc', 'mcheck', 'mcheck_check_all', 'mcheck_pedantic', 'mprobe', 'mrand48', 'mtrace', 'muntrace', 'nrand48', 'profil', 'ptsname', 'putchar_unlocked', 'putenv', 'pututline', 'putwchar_unlocked', 'pvalloc', 'qecvt', 'qfcvt', 'rcmd', 'rcmd_af', 're_comp', 're_exec', 'readdir', 'rexec', 'rexec_af', 'seed48', 'setenv', 'setfsent', 'setgrent', 'sethostent', 'sethostid', 'setkey', 'setlogmask', 'setnetent', 'setnetgrent', 'setprotoent', 'setpwent', 'setservent', 'setspent', 'setttyent', 'setusershell', 'setutent', 'sgetspent', 'siginterrupt', 'sleep', 'srand48', 'strerror', 'strsignal', 'strtok', 'tmpnam', 'ttyname', 'ttyslot', 'unsetenv', 'updwtmp', 'utmpname', 'valloc', 'wcrtomb', 'wcsnrtombs', 'wcsrtombs', 'wctomb', 'wordexp' } # From man 7 attributes # the full token could be feature:function/condition - we just want function. id_MTunsafe = [re.sub('^.*:', '', re.sub('/.*$', '', x)) for x in id_MTunsafe_full ] def reportError(token, severity, msg, errid): # noqa: D103 cppcheckdata.reportError(token, severity, msg, 'threadsafety', errid) def checkstatic(data): # noqa: D103 for var in data.variables: if var.isStatic and var.isLocal: vartype = None if var.isClass: vartype = 'object' else: vartype = 'variable' if var.isConst: if data.standards.cpp == 'c++03': reportError( var.typeStartToken, 'warning', 'Local constant static ' + vartype + "'" + var.nameToken.str + "', dangerous if it is initialized" + ' in parallel threads', 'threadsafety-const') else: reportError(var.typeStartToken, 'warning', 'Local static ' + vartype + ': ' + var.nameToken.str, 'threadsafety') def check_MTunsafe(cfg): """ Look for functions marked MT-unsafe in their man pages. The MT-unsafe functions are listed in id_MTunsafe (and id_MTunsafe_full). That section of code can be regenerated by the external script MT-Unsafe.py """ for token in cfg.tokenlist: if token.str in id_MTunsafe: reportError(token, 'warning', token.str + ' is MT-unsafe', 'unsafe-call') if __name__ == '__main__': parser = cppcheckdata.ArgumentParser() args = parser.parse_args() quiet = args.quiet or args.cli if not args.dumpfile: if not args.quiet: print('no input files.') sys.exit(0) for dumpfile in args.dumpfile: # load XML from .dump file data = cppcheckdata.CppcheckData(dumpfile) for cfg in data.iterconfigurations(): if not args.quiet: srcfile = data.files[0] print('Checking %s, config %s...' % (srcfile, cfg.name)) check_MTunsafe(cfg) checkstatic(cfg) sys.exit(cppcheckdata.EXIT_CODE) cppcheck-2.17.1/addons/y2038.py000077500000000000000000000150111475760761100160100ustar00rootroot00000000000000#!/usr/bin/env python3 # # cppcheck addon for Y2038 safeness detection # # Detects: # # 1. _TIME_BITS being defined to something else than 64 bits # 2. _USE_TIME_BITS64 being defined when _TIME_BITS is not # 3. Any Y2038-unsafe symbol when _USE_TIME_BITS64 is not defined. # # Example usage: # $ cppcheck --addon=y2038 path-to-src/test.c # from __future__ import print_function import cppcheckdata import sys import re # -------------------------------------------- # #define/#undef detection regular expressions # -------------------------------------------- # test for '#define _TIME_BITS 64' re_define_time_bits_64 = re.compile(r'^\s*#\s*define\s+_TIME_BITS\s+64\s*$') # test for '#define _TIME_BITS ...' (combine w/ above to test for 'not 64') re_define_time_bits = re.compile(r'^\s*#\s*define\s+_TIME_BITS\s+.*$') # test for '#undef _TIME_BITS' (if it ever happens) re_undef_time_bits = re.compile(r'^\s*#\s*undef\s+_TIME_BITS\s*$') # test for '#define _USE_TIME_BITS64' re_define_use_time_bits64 = re.compile(r'^\s*#\s*define\s+_USE_TIME_BITS64\s*$') # test for '#undef _USE_TIME_BITS64' (if it ever happens) re_undef_use_time_bits64 = re.compile(r'^\s*#\s*undef\s+_USE_TIME_BITS64\s*$') # -------------------------------- # List of Y2038-unsafe identifiers # -------------------------------- # This is WIP. Eventually it should contain all identifiers (types # and functions) which would be affected by the Y2038 bug. id_Y2038 = { # Y2038-unsafe types by definition 'time_t' # Types using Y2038-unsafe types 'lastlog', 'msqid_ds', 'semid_ds', 'timeb', 'timespec', 'timeval', 'utimbuf', 'itimerspec', 'clnt_ops', 'elf_prstatus', 'itimerval', 'ntptimeval', 'rusage', 'timex', 'utmp', 'utmpx', # APIs using 2038-unsafe types 'ctime', 'ctime_r', 'difftime', 'gmtime', 'gmtime_r', 'localtime', 'localtime_r', 'mktime', 'stime', 'timegm', 'timelocal', 'time', 'msgctl', 'ftime', 'aio_suspend', 'clock_getres', 'clock_gettime', 'clock_nanosleep', 'clock_settime', 'futimens', 'mq_timedreceive', 'mq_timedsend', 'nanosleep', 'pselect', 'pthread_cond_timedwait', 'pthread_mutex_timedlock', 'pthread_rwlock_timedrdlock', 'pthread_rwlock_timedwrlock', 'sched_rr_get_interval', 'sem_timedwait', 'sigtimedwait', 'timespec_get', 'utimensat', 'adjtime', 'pmap_rmtcall', 'clntudp_bufcreate', 'clntudp_create', 'futimes', 'gettimeofday', 'lutimes', 'select', 'settimeofday', 'utimes', 'utime', 'timerfd_gettime', 'timerfd_settime', 'timer_gettime', 'timer_settime', 'fstatat', 'fstat', '__fxstatat', '__fxstat', 'lstat', '__lxstat', 'stat', '__xstat', 'struct itimerval', 'setitimer', 'getitimer', 'ntp_gettime', 'getrusage', 'wait3', 'wait4', 'adjtimex', 'ntp_adjtime', 'getutent_r', 'getutent', 'getutid_r', 'getutid', 'getutline_r', 'getutline', 'login', 'pututline', 'updwtmp', 'getutxent', 'getutxid', 'getutxline', 'pututxline' } def check_y2038_safe(dumpfile, quiet=False): # Assume that the code is Y2038 safe until proven otherwise y2038safe = True # load XML from .dump file data = cppcheckdata.CppcheckData(dumpfile) srcfile = data.files[0] for cfg in data.iterconfigurations(): if not quiet: print('Checking %s, config %s...' % (srcfile, cfg.name)) safe_ranges = [] safe = -1 time_bits_defined = False srclinenr = 0 for directive in cfg.directives: # track source line number if directive.file == srcfile: srclinenr = directive.linenr # check for correct _TIME_BITS if present if re_define_time_bits_64.match(directive.str): time_bits_defined = True elif re_define_time_bits.match(directive.str): cppcheckdata.reportError(directive, 'error', '_TIME_BITS must be defined equal to 64', 'y2038', 'type-bits-not-64') time_bits_defined = False y2038safe = False elif re_undef_time_bits.match(directive.str): time_bits_defined = False # check for _USE_TIME_BITS64 (un)definition if re_define_use_time_bits64.match(directive.str): safe = int(srclinenr) # warn about _TIME_BITS not being defined if not time_bits_defined: cppcheckdata.reportError(directive, 'warning', '_USE_TIME_BITS64 is defined but _TIME_BITS was not', 'y2038', 'type-bits-undef') elif re_undef_use_time_bits64.match(directive.str): unsafe = int(srclinenr) # do we have a safe..unsafe area? if unsafe > safe > 0: safe_ranges.append((safe, unsafe)) safe = -1 # check end of source beyond last directive if len(cfg.tokenlist) > 0: unsafe = int(cfg.tokenlist[-1].linenr) if unsafe > safe > 0: safe_ranges.append((safe, unsafe)) # go through all tokens for token in cfg.tokenlist: if token.str in id_Y2038: if not any(lower <= int(token.linenr) <= upper for (lower, upper) in safe_ranges): cppcheckdata.reportError(token, 'warning', token.str + ' is Y2038-unsafe', 'y2038', 'unsafe-call') y2038safe = False token = token.next return y2038safe def get_args_parser(): parser = cppcheckdata.ArgumentParser() return parser if __name__ == '__main__': parser = get_args_parser() args = parser.parse_args() exit_code = 0 quiet = args.quiet or args.cli if not args.dumpfile: if not args.quiet: print("no input files.") sys.exit(0) for dumpfile in args.dumpfile: if not quiet: print('Checking ' + dumpfile + '...') check_y2038_safe(dumpfile, quiet) sys.exit(cppcheckdata.EXIT_CODE) cppcheck-2.17.1/build-pcre.txt000066400000000000000000000025171475760761100161740ustar00rootroot00000000000000PCRE is a library that is used by the optional "rules" feature for the command line version of cppcheck. It is readily available on Linux and Mac OS X, but must be obtained separately for Windows. Build instructions ------------------ Windows ------- Visual Studio To build PCRE, download the source code from www.pcre.org and CMake (https://cmake.org/download/). We assume you use Visual Studio 2015 - otherwise adapt the commands for your version. VS Solution file cmake . -G "Visual Studio 14 2015" Open PCRE.sln with VS IDE or via cmd: call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86 MSBuild PCRE.sln /target:Build /property:Configuration="Release" For 64-bit target: cmake . -G "Visual Studio 14 2015 Win64" or using NMake call "%VS140COMNTOOLS%..\..\VC\vcvarsall.bat" x86 cmake . -G "NMake Makefiles" nmake or using MSYS cmake . -G "MSYS Makefiles" make Linux ----- The normal Makefile should work. Install PCRE on Ubuntu might be needed: sudo apt-get install libpcre3 libpcre3-dev Mac OSX ------- Install PCRE: homebre brew install pcre or macport sudo port install pcre Ensure /path/to/pcre.h is in CXXFLAGS, e.g: for homebrew export CXXFLAGS=${CXXFLAGS}:/usr/local/include or macport export CXXFLAGS=${CXXFLAGS}:/opt/local/include Or for MSVC copy pcre.lib and pcre.h in /externals directory. cppcheck-2.17.1/cfg/000077500000000000000000000000001475760761100141375ustar00rootroot00000000000000cppcheck-2.17.1/cfg/avr.cfg000066400000000000000000000254611475760761100154200ustar00rootroot00000000000000 false 0:255 false false false false false false false false false 0: false false false false false false false false false false false false false false false false cppcheck-2.17.1/cfg/bento4.cfg000066400000000000000000000205211475760761100160130ustar00rootroot00000000000000 false cppcheck-2.17.1/cfg/boost.cfg000066400000000000000000001360061475760761100157540ustar00rootroot00000000000000 false false false false false arg1==0?0:(arg1<0?-1:1) false arg1<0?1:0 false false false 5.000000000000000000000000000000000000e-01 false 3.333333333333333333333333333333333333e-01 false 6.666666666666666666666666666666666666e-01 false 6.666666666666666666666666666666666666e-01 false 1.66666666666666666666666666666666666666666e-01 false 7.500000000000000000000000000000000000e-01 false 1.414213562373095048801688724209698078e+00 false 1.732050807568877293527446341505872366e+00 false 7.071067811865475244008443621048490392e-01 false 6.931471805599453094172321214581765680e-01 false -3.665129205816643270124391582326694694e-01 false 1.177410022515474691011569326459699637e+00 false 7.071067811865475244008443621048490392e-01 false 3.141592653589793238462643383279502884e+00 false 1.570796326794896619231321691639751442e+00 false 1.047197551196597746154214461093167628e+00 false 5.235987755982988730771072305465838140e-01 false 6.283185307179586476925286766559005768e+00 false 2.094395102393195492308428922186335256e+00 false 2.356194490192344928846982537459627163e+00 false 4.188790204786390984616857844372670512e+00 false 1.591549430918953357688837633725143620e-01 false 3.989422804014326779399460599343818684e-01 false 1.772453850905516027298167483341145182e+00 false 1.253314137315500251207882642405522626e+00 false 2.506628274631000502415765284811045253e+00 false 9.189385332046727417803297364056176398e-01 false 5.641895835477562869480794515607725858e-01 false 5.641895835477562869480794515607725858e-01 false 1.415926535897932384626433832795028841e-01 false 8.584073464102067615373566167204971158e-01 false 7.953167673715975443483953350568065807e-01 false 2.245915771836104547342715220454373502e+01 false 9.869604401089358618834490999876151135e+00 false 1.644934066848226436472415166646025189e+00 false 3.100627668029982017547631506710139520e+01 false 1.464591887561523263020142527263790391e+00 false 6.827840632552956814670208331581645981e-01 false 2.718281828459045235360287471352662497e+00 false 6.065306597126334236037995349911804534e-01 false 2.314069263277926900572908636794854738e+01 false 1.648721270700128146848650787814163571e+00 false 4.342944819032518276511289189166050822e-01 false 2.302585092994045684017991454684364207e+00 false 2.302585092994045684017991454684364207e+00 false 1.745329251994329576923690768488612713e-02 false 5.729577951308232087679815481410517033e+01 false 8.414709848078965066525023216302989996e-01 false 5.403023058681397174009366074429766037e-01 false 1.175201193643801456882381850595600815e+00 false 1.543080634815243778477905620757061682e+00 false 1.618033988749894848204586834365638117e+00 false 4.812118250596034474977589134243684231e-01 false 2.078086921235027537601322606117795767e+00 false 5.772156649015328606065120900824024310e-01 false 1.732454714600633473583025315860829681e+00 false 3.331779238077186743183761363552442266e-01 false 1.644934066848226436472415166646025189e+00 false 1.202056903159594285399738161511449990e+00 false 9.159655941772190150546035149323841107e-01 false 1.282427129100622636875342568869791727e+00 false 2.685452001065306445309714835481795693e+00 false 1.139547099404648657492793019389846112e+00 false 6.311106578189371381918993515442277798e-01 false 3.245089300687638062848660410619754415e+00 false 2.450893006876380628486604106197544154e-01 false 6.366197723675813430755350534900574481e-01 false 7.978845608028653558798921198687637369e-01 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false true boost::lock_guard boost::mutex::scoped_lock boost::recursive_mutex::scoped_lock boost::unique_lock boost::shared_lock boost::mutex boost::recursive_mutex cppcheck-2.17.1/cfg/bsd.cfg000066400000000000000000000356671475760761100154110ustar00rootroot00000000000000 false false false false false false false false false false false false false false false 0: false 0: false 0: false 0: 0: 0: 0: 0: 0: 0: 0: 0: 0: 0: 0: 0: 0: 0: 0: false false 1: false 2: false false 0: false 1: -1: true true true true false 0: 0: reallocarray free cppcheck-2.17.1/cfg/cairo.cfg000066400000000000000000000064761475760761100157320ustar00rootroot00000000000000 false false false false false false cppcheck-2.17.1/cfg/cppcheck-cfg.rng000066400000000000000000000574371475760761100172040ustar00rootroot00000000000000 2 true false maybe error-code (::)?([a-zA-Z_:][a-zA-Z_0-9:]*[ ])*([a-zA-Z_][a-zA-Z_0-9]*::)*([a-zA-Z_][a-zA-Z_0-9]*([ ]?[*& ])*)+ all|([0-9]*:[0-9]*) error warning style performance portability information Obsolescent Obsolete c99 any variadic ([-!]?[0-9]*(\.[0-9]+)?([eE][-+]?[0-9]+)?[,:])*([-!]?[0-9]+(\.[0-9]+)?([eE][-+]?[0-9]+)?)? strlen sizeof mul value argvalue first middle last [.][a-z]+ std-like std-like erase insert array-like bool char short int long long long 1 2 4 8 s u 1 40 0 2 in out inout true false [a-zA-Z_][a-zA-Z_0-9]* [a-zA-Z_][a-zA-Z_0-9:]* [a-zA-Z_][a-zA-Z_0-9:,]* malloc(:[1-5])?|calloc(:[1-5],[1-5])?|strdup(:[1-5])? resize clear push pop find find-const insert erase append change-content change-internal change at_index item buffer buffer-nt start-iterator end-iterator iterator size empty 1 9223372036854775807 cppcheck-2.17.1/cfg/cppcheck-lib.cfg000066400000000000000000000040221475760761100171420ustar00rootroot00000000000000 false false false false -50:50 false -50:50 false cppcheck-2.17.1/cfg/cppunit.cfg000066400000000000000000000052021475760761100163010ustar00rootroot00000000000000 false false false cppcheck-2.17.1/cfg/dpdk.cfg000066400000000000000000000003331475760761100155410ustar00rootroot00000000000000 true cppcheck-2.17.1/cfg/embedded_sql.cfg000066400000000000000000000001551475760761100172310ustar00rootroot00000000000000 cppcheck-2.17.1/cfg/emscripten.cfg000066400000000000000000000074031475760761100167750ustar00rootroot00000000000000 false false false false false false false emscripten_asm_const_ptr emscripten_asm_const_ptr_sync_on_main_thread free cppcheck-2.17.1/cfg/ginac.cfg000066400000000000000000014217321475760761100157130ustar00rootroot00000000000000 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false cppcheck-2.17.1/cfg/gnu.cfg000066400000000000000000001407061475760761100154210ustar00rootroot00000000000000 free get_current_dir_name asprintf free xmalloc xcalloc xstrdup xrealloc free xfree backtrace_symbols free pvalloc free false ((arg1 & 0xff00u) >> 8) | ((arg1 & 0x00ffu) << 8) false ((arg1 & 0xff000000ul) >> 24) | ((arg1 & 0x00ff0000ul) >> 8) | ((arg1 & 0x0000ff00ul) << 8) | ((arg1 & 0x000000fful) << 24) false ((arg1 & 0xff00000000000000ull) >> 56) | ((arg1 & 0x00ff000000000000ull) >> 40) | ((arg1 & 0x0000ff0000000000ull) >> 24) | ((arg1 & 0x000000ff00000000ull) >> 8) | ((arg1 & 0x00000000ff000000ull) << 8) | ((arg1 & 0x0000000000ff0000ull) << 24) | ((arg1 & 0x000000000000ff00ull) << 40) | ((arg1 & 0x00000000000000ffull) << 56) false 0: false 0: 0: false arg1 false 0: false false false false false false true false false 0: false 0: true 0: false 0: 0: 1: false 0: 0: 1: false 1: 0: 0: false 0: false arg1>=0 && arg1<=0x7F false 0:255 false false 0: false 0: 0: false 0: false 0: false 0: false false 0: false 0: 0: false false false false false 0: false false false false 0: false 0: false 0: false 0: false 0: false false false false false false false false 0:4294967295 0:4294967295 false false false false false false false false false 0: 0: false 0: 0: false 0: false 0: 0: arg1==0 &0 false false false false 1: false false 0: 0: false 0: 1: false 0: 1: false 0: false false false false false false false false false false 1: -1: false 0: false 0: false false true mkostemp mkstemps mkostemps close close epoll_create close epoll_create1 cppcheck-2.17.1/cfg/googletest.cfg000066400000000000000000000164671475760761100170120ustar00rootroot00000000000000 cppcheck-2.17.1/cfg/gtk.cfg000066400000000000000000023514501475760761100154170ustar00rootroot00000000000000 g_thread_new g_thread_try_new g_thread_ref g_thread_unref g_thread_join g_variant_iter_copy g_variant_iter_new g_variant_iter_free g_source_new g_idle_source_new g_timeout_source_new g_timeout_source_new_seconds g_child_watch_source_new g_cancellable_source_new g_io_create_watch g_source_ref g_source_unref g_date_time_new g_date_time_new_now g_date_time_new_now_local g_date_time_new_now_utc g_date_time_new_from_unix_local g_date_time_new_from_unix_utc g_date_time_new_from_timeval_local g_date_time_new_from_timeval_utc g_date_time_new_local g_date_time_new_utc g_date_time_add g_date_time_add_years g_date_time_add_months g_date_time_add_weeks g_date_time_add_days g_date_time_add_hours g_date_time_add_minutes g_date_time_add_seconds g_date_time_add_full g_date_time_to_timezone g_date_time_to_local g_date_time_to_utc g_date_time_ref g_date_time_unref g_dir_open g_dir_rewind g_dir_close g_timer_new g_timer_destroy g_file_attribute_info_list_new g_file_attribute_info_list_dup g_file_attribute_info_list_ref g_file_attribute_info_list_unref g_slist_alloc g_slist_copy g_slist_copy_deep g_slist_free g_slist_free_1 g_slist_free_full g_variant_new g_variant_new_va g_variant_new_boolean g_variant_new_byte g_variant_new_int16 g_variant_new_uint16 g_variant_new_int32 g_variant_new_uint32 g_variant_new_int64 g_variant_new_uint64 g_variant_new_handle g_variant_new_double g_variant_new_string g_variant_new_take_string g_variant_new_printf g_variant_new_signature g_variant_new_object_path g_variant_new_variant g_variant_new_objv g_variant_new_strv g_variant_new_bytestring g_variant_new_bytestring_array g_variant_new_maybe g_variant_new_array g_variant_new_tuple g_variant_new_dict_entry g_variant_new_fixed_array g_variant_new_from_data g_variant_new_from_bytes g_variant_builder_end g_variant_new_parsed_va g_variant_new_parsed g_variant_byteswap g_variant_get_child_value g_variant_get_normal_form g_variant_parse g_variant_ref g_variant_take_ref g_variant_ref_sink g_variant_unref g_variant_iter_new g_variant_iter_free g_variant_type_new g_variant_type_copy g_variant_type_new_array g_variant_type_new_dict_entry g_variant_type_new_maybe g_variant_type_new_tuple g_variant_type_free g_allocator_new g_allocator_free g_bookmark_file_new g_bookmark_file_free g_srv_target_new g_srv_target_free g_string_chunk_new g_string_chunk_free g_test_log_buffer_new g_test_log_buffer_free g_value_array_new g_value_array_free g_cache_new g_cache_destroy g_cclosure_new g_cclosure_new_swap g_cclosure_new_object g_cclosure_new_object_swap g_closure_new_object g_closure_new_simple g_closure_ref g_closure_unref g_array_new g_array_sized_new g_array_ref g_array_free g_array_unref g_async_queue_new g_async_queue_new_full g_async_queue_ref g_async_queue_unref g_byte_array_new g_byte_array_sized_new g_byte_array_new_take g_byte_array_sized_new g_bytes_unref_to_array g_byte_array_ref g_byte_array_free g_byte_array_unref g_checksum_new g_checksum_copy g_checksum_free g_main_loop_new g_main_new g_main_loop_ref g_main_loop_unref g_main_destroy g_main_context_new g_main_context_ref g_main_context_unref g_main_destroy g_thread_pool_new g_thread_pool_free g_error_copy g_error_new_valist g_error_new_literal g_error_new g_error_free g_string_new g_string_new_len g_string_sized_new g_variant_print_string g_string_free g_ptr_array_new g_ptr_array_new_full g_ptr_array_new_with_free_func g_ptr_array_ref g_ptr_array_free g_ptr_array_unref g_pattern_spec_new g_pattern_spec_free g_key_file_new g_key_file_ref g_key_file_free g_key_file_unref g_io_module_scope_new g_io_module_scope_free g_ascii_strdown g_ascii_strup g_base64_decode g_base64_encode g_bookmark_file_get_description g_bookmark_file_get_mime_type g_bookmark_file_get_title g_bookmark_file_to_data g_build_filename g_build_filenamev g_build_path g_build_pathv g_bytes_unref_to_data g_compute_checksum_for_bytes g_compute_checksum_for_data g_compute_checksum_for_string g_compute_hmac_for_data g_compute_hmac_for_string g_convert g_convert_with_fallback g_convert_with_iconv g_credentials_to_string g_date_time_format g_filename_display_basename g_filename_display_name g_filename_from_uri g_filename_to_uri g_get_codeset g_get_current_dir g_get_locale_variants g_key_file_get_start_group g_key_file_to_data g_malloc g_realloc g_malloc0 g_malloc0_n g_malloc_n g_realloc_n g_memdup g_path_get_basename g_path_get_dirname g_slice_alloc g_slice_alloc0 g_slice_copy g_strcompress g_strconcat g_strdup g_strdup_printf g_strdup_vprintf g_strescape g_strjoin g_strjoinv g_strndup g_strnfill g_time_val_to_iso8601 g_try_malloc g_try_realloc g_try_malloc0 g_try_malloc0_n g_try_malloc_n g_try_realloc_n g_ucs4_to_utf16 g_ucs4_to_utf8 g_unicode_canonical_decomposition g_utf16_to_ucs4 g_utf16_to_utf8 g_utf8_casefold g_utf8_collate_key g_utf8_collate_key_for_filename g_utf8_normalize g_utf8_strdown g_utf8_strreverse g_utf8_strup g_utf8_substring g_utf8_to_ucs4 g_utf8_to_ucs4_fast g_utf8_to_ucs4_fast g_utf8_to_utf16 g_key_file_get_locale_string g_key_file_get_value g_key_file_get_string g_key_file_get_boolean_list g_key_file_get_integer_list g_key_file_get_double_list g_key_file_get_comment g_dbus_proxy_get_name_owner g_file_info_get_attribute_as_string g_file_attribute_matcher_to_string g_app_launch_context_get_environment g_app_launch_context_get_startup_notify_id g_filename_completer_get_completion_suffix g_inet_address_mask_to_string g_variant_dup_string g_variant_dup_bytestring g_variant_get_objv g_variant_get_strv g_variant_print g_datalist_id_dup_data g_dir_make_tmp g_filename_from_utf8 g_filename_to_utf8 g_file_read_link g_find_program_in_path g_format_size g_format_size_for_display g_format_size_full g_hostname_to_ascii g_hostname_to_unicode g_locale_from_utf8 g_locale_to_utf8 g_markup_escape_text g_markup_printf_escaped g_markup_vprintf_escaped g_match_info_expand_references g_match_info_fetch g_match_info_fetch_named g_option_context_get_help g_regex_escape_nul g_regex_escape_string g_regex_replace g_regex_replace_eval g_regex_replace_literal g_shell_quote g_shell_unquote g_uri_escape_string g_uri_parse_scheme g_uri_unescape_segment g_uri_unescape_string g_variant_type_dup_string g_value_dup_string g_register_data g_free g_hash_table_new_full g_hash_table_new g_hash_table_ref g_hash_table_destroy g_hash_table_unref g_io_channel_unix_new g_io_channel_win32_new_fd g_io_channel_win32_new_socket g_io_channel_win32_new_messages g_io_channel_new_file g_io_channel_ref g_io_channel_close g_io_channel_shutdown g_io_channel_unref g_emblemed_icon_get_emblems g_list_alloc g_list_copy g_list_copy_deep g_app_info_get_all g_app_info_get_all_for_type g_app_info_get_fallback_for_type g_app_info_get_recommended_for_type g_io_modules_load_all_in_directory g_io_modules_load_all_in_directory_with_scope g_hash_table_get_keys g_hash_table_get_values g_list_free g_list_free_1 g_list_free_full g_regex_new g_regex_ref g_regex_unref g_node_new g_node_copy g_node_copy_deep g_node_destroy g_time_zone_new g_time_zone_new_local g_time_zone_new_utc g_time_zone_ref g_time_zone_unref g_markup_parse_context_new g_markup_parse_context_free g_mapped_file_new g_mapped_file_new_from_fd g_mapped_file_ref g_mapped_file_free g_mapped_file_unref g_mutex_new g_mutex_free g_mem_chunk_new g_mem_chunk_free g_option_group_new g_option_group_free g_option_context_new g_option_context_free g_rand_new g_rand_copy g_rand_new_with_seed g_rand_new_with_seed_array g_rand_free g_queue_new g_queue_copy g_queue_free g_slice_new g_slice_free g_slice_free1 g_sequence_new g_sequence_free g_completion_new g_completion_free g_chunk_new g_chunk_free g_bytes_new g_bytes_new_take g_bytes_new_static g_bytes_new_with_free_func g_bytes_new_from_bytes g_byte_array_free_to_bytes g_memory_output_stream_steal_as_bytes g_variant_get_data_as_bytes g_mapped_file_get_bytes g_bytes_ref g_bytes_unref g_bookmark_file_get_uris g_bookmark_file_get_groups g_bookmark_file_get_applications g_key_file_get_groups g_key_file_get_keys g_strdupv g_strsplit g_strsplit_set g_uri_list_extract_uris g_key_file_get_string_list g_key_file_get_locale_string_list g_file_info_list_attributes g_file_info_get_attribute_stringv g_app_launch_context_get_environment g_filename_completer_get_completions g_io_module_query g_variant_dup_objv g_variant_dup_bytestring_array g_environ_setenv g_environ_unsetenv g_get_environ g_listenv g_match_info_fetch_all g_regex_split g_regex_split_full g_regex_split_simple g_regex_split_simple g_variant_dup_strv g_strfreev g_hmac_new g_hmac_copy g_hmac_ref g_hmac_unref g_hook_alloc g_hook_ref g_hook_unref g_hook_destroy g_hook_free g_date_new g_date_new_dmy g_date_new_julian g_date_free g_variant_builder_new g_variant_builder_ref g_variant_builder_unref g_cond_new g_cond_free g_app_launch_context_new g_app_info_create_from_commandline g_app_info_dup g_app_info_get_default_for_type g_app_info_get_default_for_uri_scheme g_application_new g_application_get_dbus_connection g_application_get_default g_buffered_input_stream_new g_buffered_output_stream_new g_cancellable_new g_charset_converter_new g_converter_input_stream_new g_converter_output_stream_new g_credentials_new g_data_input_stream_new g_data_output_stream_new g_dbus_auth_observer_new g_dbus_connection_new_finish g_dbus_connection_new_sync g_dbus_connection_new_for_address_finish g_dbus_connection_new_for_address_sync g_dbus_message_new g_dbus_message_new_signal g_dbus_message_new_method_call g_dbus_message_new_method_reply g_dbus_message_new_method_error g_dbus_message_new_method_error_valist g_dbus_message_new_method_error_literal g_dbus_object_manager_client_new_finish g_dbus_object_manager_client_new_sync g_dbus_object_manager_client_new_for_bus_finish g_dbus_object_manager_client_new_for_bus_sync g_dbus_object_manager_server_new g_dbus_object_manager_server_get_connection g_dbus_object_proxy_new g_dbus_object_skeleton_new g_dbus_proxy_new_finish g_dbus_proxy_new_sync g_dbus_proxy_new_for_bus_finish g_dbus_proxy_new_for_bus_sync g_emblemed_icon_new g_emblem_new g_emblem_new_with_origin g_file_icon_new g_file_icon_get_file g_file_info_new g_file_info_dup g_file_info_get_icon g_file_info_get_symbolic_icon g_file_info_get_attribute_object g_file_info_get_deletion_date g_filename_completer_new g_inet_address_mask_new g_inet_address_mask_new_from_string g_inet_address_mask_get_address g_inet_socket_address_new g_inet_socket_address_get_address g_initable_new g_initable_new_valist g_initable_newv g_io_module_new g_io_module_scope_new g_keyfile_settings_backend_new g_memory_input_stream_new g_memory_input_stream_new_from_data g_memory_input_stream_new_from_bytes g_memory_output_stream_new g_memory_output_stream_new_resizable g_memory_settings_backend_new g_null_settings_backend_new g_menu_item_new g_menu_item_new_section g_menu_item_new_submenu g_menu_item_new_from_model g_menu_new g_mount_operation_new g_network_address_new g_network_service_new g_object_new g_param_spec_pool_new g_pollable_source_new g_private_new g_proxy_address_new g_ptr_array_sized_new g_relation_new g_scanner_new g_settings_new g_signal_type_cclosure_new g_simple_action_group_new g_simple_action_new g_simple_async_result_new g_simple_permission_new g_socket_client_new g_socket_listener_new g_socket_new g_socket_service_new g_tcp_wrapper_connection_new g_test_dbus_new g_themed_icon_new g_threaded_socket_service_new g_tls_client_connection_new g_tls_file_database_new g_tls_password_new g_tls_server_connection_new g_unix_signal_source_new g_zlib_compressor_new g_zlib_decompressor_new g_object_ref g_object_unref gtk_widget_destroy g_tree_new g_tree_new_full g_tree_new_with_data g_tree_ref g_tree_unref g_file_attribute_matcher_new g_file_attribute_matcher_subtract g_file_attribute_matcher_ref g_file_attribute_matcher_unref true true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false arg1 false false false false false g_value_set_object_take_ownership has been deprecated since version 2.4 and should not be used in newly-written code. Use g_value_take_object() instead. false false false g_value_set_string_take_ownership has been deprecated since version 2.4 and should not be used in newly-written code. Use g_value_take_string() instead. false false false false false false false false false false false false false false false 0:255 false false false 0:255 false 0:255 false 0:255 false 0:255 false 0:255 false 0:255 false 0:255 false 0:255 false 0:255 false 0:255 false 0:255 false false false false false 0,2:36 false 0,2:36 false false 0:255 false 0:255 false 0:255 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false g_basename has been deprecated since version 2.2 and should not be used in newly-written code. Use g_path_get_basename() instead, but notice that g_path_get_basename() allocates new memory for the returned string, unlike this function which returns a pointer into the argument. false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false g_dirname is deprecated and should not be used in newly-written code. Use g_path_get_dirname() instead. false false false false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: false false false false false false false false false false false false false false false false false false false false 1: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: 0: 0: false false false false false false false false false false false false false false false false false false false false false false false false false false 0: false false false false false false false false false false false false false false false false false false false false false false g_strcasecmp has been deprecated since version 2.2 and should not be used in newly-written code. false arg1 false arg1 false false false false false false false false false g_strncasecmp has been deprecated since version 2.2 and should not be used in newly-written code. 0: false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: false 0: 0: false 0: false 0: 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: 0: 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false g_string_down has been deprecated since version 2.2 and should not be used in newly-written code. This function uses the locale-specific tolower() function, which is almost never the right thing. Use g_string_ascii_down() or g_utf8_strdown() instead. false false false false false false false false false false false false false false false false false false false false 0: false g_string_sprintf is deprecated and should not be used in newly-written code. This function has been renamed to g_string_printf(). false g_string_sprintfa is deprecated and should not be used in newly-written code. This function has been renamed to g_string_append_printf() false false g_string_up has been deprecated since version 2.2 and should not be used in newly-written code. This function uses the locale-specific toupper() function, which is almost never the right thing. Use g_string_ascii_up() or g_utf8_strup() instead. false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false g_type_class_add_private has been deprecated since version 2.58 and should not be used in newly-written code. Use the G_ADD_PRIVATE() macro with the G_DEFINE_* family of macros to add instance private data to a type. false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false gtk_hbox_new has been deprecated since version 3.2 and should not be used in newly-written code. You can use gtk_box_new() with GTK_ORIENTATION_HORIZONTAL instead, which is a quick and easy change. But the recommendation is to switch to GtkGrid, since GtkBox is going to go away eventually. See Migrating from other containers to GtkGrid. false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false gtk_vbox_new has been deprecated since version 3.2 and should not be used in newly-written code. You can use gtk_box_new() with GTK_ORIENTATION_VERTICAL instead, which is a quick and easy change. But the recommendation is to switch to GtkGrid, since GtkBox is going to go away eventually. See Migrating from other containers to GtkGrid. false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false true gtk_exit is deprecated and should not be used in newly-written code. Use the standard exit() function instead. false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false gtk_signal_connect_object_while_alive is deprecated and should not be used in newly-written code. Use g_signal_connect_object() instead, passing G_CONNECT_SWAPPED as connect_flags. false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false gtk_label_get is deprecated and should not be used in newly-written code. false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false cppcheck-2.17.1/cfg/icu.cfg000066400000000000000000000306201475760761100154010ustar00rootroot00000000000000 cppcheck-2.17.1/cfg/kde.cfg000066400000000000000000000104151475760761100153640ustar00rootroot00000000000000 false false false false false cppcheck-2.17.1/cfg/libcerror.cfg000066400000000000000000000204771475760761100166150ustar00rootroot00000000000000 false false false false false false 0: false cppcheck-2.17.1/cfg/libcurl.cfg000066400000000000000000000343441475760761100162640ustar00rootroot00000000000000 curl_easy_init curl_easy_duphandle curl_easy_cleanup curl_easy_escape curl_easy_unescape curl_escape curl_unescape curl_free curl_getenv curl_maprintf curl_mvaprintf free false false false 0: false false false false false 0: false false 0: false false false 0: false false 0: false false This function will be removed from the public libcurl API in a near future. It will instead be made "available" by source code access only, and then as curlx_getenv(). false These functions will be removed from the public libcurl API in the future. Do not use them in any new programs or projects. false false false 0: false false Usage of curl_multi_socket is deprecated, whereas the function is equivalent to curl_multi_socket_action with ev_bitmask set to 0. false false These functions will be removed from the public libcurl API in the future. Do not use them in any new programs or projects. false false false 0: false false These functions will be removed from the public libcurl API in a near future. They will instead be made "available" by source code access only, and then as curlx_strequal() and curlx_strenqual(). false These functions will be removed from the public libcurl API in a near future. They will instead be made "available" by source code access only, and then as curlx_strequal() and curlx_strenqual(). 0: false 0: cppcheck-2.17.1/cfg/libsigc++.cfg000066400000000000000000000047711475760761100163730ustar00rootroot00000000000000 false cppcheck-2.17.1/cfg/lua.cfg000066400000000000000000000223651475760761100154110ustar00rootroot00000000000000 true false false false false false 1: false false false false false false 0: false false false false false false false false false false false false false false false true cppcheck-2.17.1/cfg/mfc.cfg000066400000000000000000000316111475760761100153670ustar00rootroot00000000000000 cppcheck-2.17.1/cfg/microsoft_atl.cfg000066400000000000000000000045561475760761100174770ustar00rootroot00000000000000 cppcheck-2.17.1/cfg/microsoft_sal.cfg000066400000000000000000000644031475760761100174730ustar00rootroot00000000000000 cppcheck-2.17.1/cfg/microsoft_unittest.cfg000066400000000000000000000024741475760761100205730ustar00rootroot00000000000000 cppcheck-2.17.1/cfg/motif.cfg000066400000000000000000000166011475760761100157420ustar00rootroot00000000000000 false false false false false false false false false false MrmCloseHierarchy MrmOpenHierarchy MrmOpenHierarchyPerDisplay XmStringFree XmStringCreateLocalized XmStringCreateSimple XmStringGenerate XmCvtCTToXmString XtFree XmFontListEntryGetTag XmTextGetString XmCvtXmStringToCT XmWidgetGetBaselines XmFontListEntryFree XmFontListCreate XmFontListAppendEntry false false false false false false false XtFree XtMalloc XtCalloc XtRealloc XtNew XtNewString false false false false false false XOpenDisplay XCloseDisplay cppcheck-2.17.1/cfg/nspr.cfg000066400000000000000000000035441475760761100156100ustar00rootroot00000000000000 cppcheck-2.17.1/cfg/ntl.cfg000066400000000000000000005767721475760761100154450ustar00rootroot00000000000000 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false cppcheck-2.17.1/cfg/opencv2.cfg000066400000000000000000000122241475760761100161750ustar00rootroot00000000000000 cv::fastMalloc cv::fastFree true false false 0: false false false false cppcheck-2.17.1/cfg/opengl.cfg000066400000000000000000000530771475760761100161200ustar00rootroot00000000000000 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false cppcheck-2.17.1/cfg/openmp.cfg000066400000000000000000000113651475760761100161240ustar00rootroot00000000000000 omp_target_alloc omp_target_free omp_alloc omp_free false false false false This routine has been deprecated. See OpenMP specification. false false false false false false false false This routine has been deprecated. See OpenMP specification. false 1: false 0: false 0: cppcheck-2.17.1/cfg/openssl.cfg000066400000000000000000000114211475760761100163020ustar00rootroot00000000000000 EVP_CIPHER_CTX_new EVP_CIPHER_CTX_free false false false false 0: false false false 0: false false false false false false 0: cppcheck-2.17.1/cfg/pcre.cfg000066400000000000000000000204521475760761100155540ustar00rootroot00000000000000 cppcheck-2.17.1/cfg/posix.cfg000066400000000000000000005462411475760761100157760ustar00rootroot00000000000000 false false 0: 0: false 0: 0: false false false false false 0: false 0: false false 0: arg1>=0x30 && arg1<=0x39 || arg1>=0x41 && arg1 <=0x5A || arg1>=0x61 && arg1 <=0x7A false 0:255 arg1>='A' && arg1<='Z' || arg1>='a' && arg1 <='z' false 0:255 arg1==' ' || arg1=='\t' false 0:255 arg1==0x7F || arg1<=0x1F false 0:255 arg1>='0' && arg1<='9' false 0:255 arg1>=0x21 && arg1<=0x7E false 0:255 arg1>=0x61 && arg1<=0x7A false 0:255 arg1>=0x20 && arg1<=0x7E false 0:255 arg1>=0x21 && arg1<=0x2F || arg1>=0x3A && arg1<=0x40 || arg1>=0x5B && arg1<=0x60 || arg1>=0x7B && arg1<=0x7E false 0:255 arg1>=0x09 && arg1<=0x0D || arg1==0x20 false 0:255 arg1>=0 && arg1<=0x7F false 0:255 arg1>=0x41 && arg1<=0x5A false 0:255 arg1>=0x30 && arg1<=0x39 || arg1>=0x41 && arg1<=0x46 || arg1>=0x61 && arg1<=0x66 false 0:255 false 0: false false dlopen dlclose false 0: 0: false 0: false 0: false 0: false false false false false 0: false 0: 0: false false false 0: false 0: false 0: false false 0: false false 0: false false false 0: false 0: false false false 0: false false false false false 0: false 0:999999 Obsolescent function 'usleep' called. It is recommended to use 'nanosleep' or 'setitimer' instead. The obsolescent function 'usleep' is called. POSIX.1-2001 declares usleep() function obsolescent and POSIX.1-2008 removes it. It is recommended that new applications use the 'nanosleep' or 'setitimer' function. true false false false false 0: false Non reentrant function 'getrpcent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getrpcent_r'. false Non reentrant function 'getrpcbyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getrpcbyname_r'. false Non reentrant function 'getrpcbynumber' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getrpcbynumber_r'. false Non reentrant function 'getprotoent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getprotoent_r'. false Non reentrant function 'getprotobyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getprotobyname_r'. false Non reentrant function 'getprotobynumber' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getprotobynumber_r'. false Non reentrant function 'getservent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getservent_r'. false Non reentrant function 'getservbyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getservbyname_r'. false Non reentrant function 'getservbyport' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getservbyport_r'. false Non reentrant function 'getnetent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getnetent_r'. false Non reentrant function 'getnetbyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getnetbyname_r'. false Non reentrant function 'getnetbyaddr' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getnetbyaddr_r'. false Non reentrant function 'gethostent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'gethostent_r'. false false Non reentrant function 'gethostbyname2' called. For threadsafe applications it is recommended to use the reentrant replacement function 'gethostbyname2_r'. false false false false false false false 0: false false false false Obsolete function 'mktemp' called. It is recommended to use 'mkstemp' or 'mkdtemp' instead. The function 'mktemp' is considered to be dangerous due to race conditions and some implementations generating only up to 26 different filenames out of each template. This function has been removed in POSIX.1-2008. Use 'mkstemp' or 'mkdtemp' instead. false 0: false false false false false false false false false false false 0: 0: false 0: false false false false 0: false 0: false false false 0: false false false 0: false false false false 0: false false false false 0: false 0: false false false false 0: false false -20:19 false false 0: false 0: false 0: false false false 0: false false false false false false false 0: false 0: 0: 0: 1: 0: 0: 0: 0: false 0: 0: false 0: 0: 0: 0: 0: 0: 0: 0: 0: 0: 0: 0: false 1: 0: false 1: 0: false 1: false false 0: false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: false 0: 0: false false false false false false false false false false false false false false false false 0: 0: 0: false false false false false false Non reentrant function 'getpwent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwent_r'. false 0: false 0: false Non reentrant function 'getpwnam' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwnam_r'. Non reentrant function 'strtok' called. For threadsafe applications it is recommended to use the reentrant replacement function 'strtok_r'. false false 0: false Non reentrant function 'getpwuid' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwuid_r'. false 0: false false false false false false 1: false 1: false 0: 0: false false 0: false 0: false false false false 0: false 0: false false 0: false 0: false false false false false 0: 0:2 false 0: 0:2 false 0: 0:2 false false false false false false false false false Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'. false false Non reentrant function 'readdir' called. For threadsafe applications it is recommended to use the reentrant replacement function 'readdir_r'. false false 0: false 0: 0: false 0: 0: false 0: false false false false Non reentrant function 'gmtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'gmtime_r'. false false false false false false false Obsolescent function 'makecontext' called. Applications are recommended to be rewritten to use POSIX threads. false Obsolescent function 'swapcontext' called. Applications are recommended to be rewritten to use POSIX threads. false Obsolescent function 'getcontext' called. Applications are recommended to be rewritten to use POSIX threads. false false false 0: false 0: false 0: false false false false false false false false false false false false false true false false false false false false false false false 0: false false 0: false 0: false 1: 0: false 0: false false false false false false false Non reentrant function 'tempnam' called. For threadsafe applications it is recommended to use the reentrant replacement function 'tempnam_r'. false Non reentrant function 'crypt' called. For threadsafe applications it is recommended to use the reentrant replacement function 'crypt_r'. false 0: Non reentrant function 'ttyname' called. For threadsafe applications it is recommended to use the reentrant replacement function 'ttyname_r'. false 0: 0: false Non reentrant function 'getspnam' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getspnam_r'. false Non reentrant function 'getspent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getspent_r'. false Non reentrant function 'fgetspent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'fgetspent_r'. false Non reentrant function 'sgetspent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'sgetspent_r'. false Non reentrant function 'fgetpwent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'fgetpwent_r'. false Non reentrant function 'getgrent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getgrent_r'. false 0: false Non reentrant function 'fgetgrent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'fgetgrent_r'. false Non reentrant function 'getnetgrent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getnetgrent_r'. false Non reentrant function 'getgrnam' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getgrnam_r'. false Non reentrant function 'getgrgid' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getgrgid_r'. false 0: false 0: false Non reentrant function 'getlogin' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getlogin_r'. false false 0:255 false 0: false Non reentrant function 'ctermid' called. For threadsafe applications it is recommended to use the reentrant replacement function 'ctermid_r'. false false false 0: false false false 0:2 false false false false false 0: false arg1==0 &0 false false false 0: false false false false false false false 0: false 0: false 0: 0: false 0: false false false false true false false false false false false false false false false false false false false false 0: false 0: false 0: false 0: false 0: false 0: false 0: false false 0: false false 0: false false 1: false 0: false 0: valloc free posix_memalign free scandir free strndup wcsdup free getline getdelim free mmap mmap64 munmap open mkstemp creat openat socket close fdopen opendir fdopendir closedir fdopen fclose popen pclose mq_open mq_close getaddrinfo freeaddrinfo cppcheck-2.17.1/cfg/protobuf.cfg000066400000000000000000000006741475760761100164670ustar00rootroot00000000000000 cppcheck-2.17.1/cfg/python.cfg000066400000000000000000000471641475760761100161550ustar00rootroot00000000000000 PyMem_Malloc PyMem_Calloc PyMem_Realloc PyMem_Free PyMem_RawMalloc PyMem_RawCalloc PyMem_RawRealloc PyMem_RawFree PyObject_Malloc PyObject_Calloc PyObject_Realloc PyObject_Free false false true true false false false false false false 0: false false false false false false false false false NULL false NULL false false false NULL false false false false false false false false false false false false false false 1: 0: false false 0: false 0: false false false false false false false false cppcheck-2.17.1/cfg/qt.cfg000066400000000000000000005547221475760761100152630ustar00rootroot00000000000000 READ READ WRITE NOTIFY connect invokeMethod false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: false 0: false 0: false false false false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: false false false false false false false false false 0: false false false false false false false false false false false false false false false false 0,2:36 false 0,2:36 false 0,2:36 false false 0,2:36 false false false false false 0,2:36 false 0,2:36 false 0,2:36 false 0,2:36 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false false false false false false false false false false false :-1,1: 1:12 1:31 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: false false false false false false false false false false false false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false QApplication QMutexLocker QRect QRectF QSize QSizeF QPoint QPointF QRegion QTransform QMutex QRecursiveMutex QSemaphore QReadWriteLock cppcheck-2.17.1/cfg/ruby.cfg000066400000000000000000000102111475760761100155740ustar00rootroot00000000000000 false false false false false false false false false false false true cppcheck-2.17.1/cfg/sdl.cfg000066400000000000000000000245311475760761100154070ustar00rootroot00000000000000 false false false false false false false false false false false false false false false false false false -1 false false false SDL_FreeSurface SDL_CreateRGBSurface SDL_CreateRGBSurfaceFrom SDL_ConvertSurface TTF_RenderUTF8_Blended IMG_LoadPNG_RW IMG_LoadJPG_RW IMG_Load SDL_DestroyMutex SDL_CreateMutex SDL_WaitThread SDL_CreateThread SDL_RWclose SDL_RWFromFile SDL_FreeRW SDL_AllocRW Mix_FreeMusic Mix_LoadMUSType_RW cppcheck-2.17.1/cfg/selinux.cfg000066400000000000000000003102441475760761100163130ustar00rootroot00000000000000 false false false false false false false false false false get_default_type free false 0:5 false selabel_open selabel_close false selabel_lookup freecon false selabel_lookup_raw freecon false false selabel_get_digests_all_partial_matches free selabel_get_digests_all_partial_matches free false false selabel_lookup_best_match freecon false selabel_lookup_best_match_raw freecon false false false false false false context_new context_free false false false false false false false false false get_ordered_context_list freeconary false get_ordered_context_list_with_level freeconary false get_default_context freecon false get_default_context_with_level freecon false get_default_context_with_role freecon false get_default_context_with_rolelevel freecon false query_user_context freecon false manual_user_enter_context freecon false avc_sid_to_context freecon false avc_sid_to_context freecon false false false false false false false false false false false false false false false false false false false false 0,1 false false false false false false 0,1 false false false false false false false false false false getcon freecon false getcon_raw freecon false getprevcon freecon false getprevcon_raw freecon false getexeccon freecon false getexeccon_raw freecon false getpidcon freecon false getpidcon_raw freecon false getpidprevcon freecon false getpidprevcon_raw freecon false false false false false false getfscreatecon freecon false getfscreatecon_raw freecon false false false getkeycreatecon freecon false getkeycreatecon_raw freecon false false false getsockcreatecon freecon false getsockcreatecon_raw freecon false false false 0: getpeercon freecon false 0: getpeercon_raw freecon false getfilecon freecon false getfilecon_raw freecon false lgetfilecon freecon false lgetfilecon_raw freecon false 0: fgetfilecon freecon false 0: fgetfilecon_raw freecon false false false false false 0: false 0: false 0:4 false 0:4 false false false false false security_compute_create freecon false security_compute_create_raw freecon false security_compute_create_name freecon false security_compute_create_name_raw freecon false security_compute_relabel freecon false security_compute_relabel freecon false security_compute_member freecon false security_compute_member_raw freecon false security_compute_user freeconary false security_compute_user_raw freeconary false false false false false false security_get_initial_context freecon false security_get_initial_context_raw freecon false false 0,1 false false 0 false security_get_boolean_names free false false false 0,1 false false false false false security_canonicalize_context freecon false security_canonicalize_context freecon false false 0,1 false false false false Disabling SELinux at runtime is deprecated and may not be supported on modern Linux kernels. false false false false false false false false security_av_string free false false false false false 0:7 false false false false false false matchpathcon freecon false matchpathcon_index freecon false false false false false matchmediacon freecon false false selinux_boolean_sub free false selinux_getpolicytype free false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false selinux_raw_context_to_color free false selinux_trans_to_raw_context free false selinux_raw_to_trans_context free false getseuserbyname free getseuserbyname free false getseuser free getseuser free false false false false This function is not thread safe. Be very sure that no other threads are calling into libselinux when this is called. cppcheck-2.17.1/cfg/sfml.cfg000066400000000000000000000220141475760761100155600ustar00rootroot00000000000000 false false false false false false false false false 0: false 0: false 0: false false false false false false false false false false false false false false false false false false false false false false 0: false 0:100 false false false false cppcheck-2.17.1/cfg/sqlite3.cfg000066400000000000000000001655661475760761100162270ustar00rootroot00000000000000 sqlite3_malloc sqlite3_malloc64 sqlite3_free sqlite3_str_new sqlite3_str_finish sqlite3_str_finish sqlite3_free sqlite3_mprintf sqlite3_vmprintf sqlite3_free sqlite3_expanded_sql sqlite3_free sqlite3_open sqlite3_open16 sqlite3_open_v2 sqlite3_close sqlite3_close_v2 false 1: 0: false 1: false 1: false 1: false 1: false false false 0: false false 0: false 0: false 0: false 0: false 0: false 0: false 0: false false -1:127 false false false false false false false false false 1: false 1: false false false false false false false false false false false false false The sqlite3_prepare() interface is legacy and should be avoided false The sqlite3_prepare16() interface is legacy and should be avoided false false false false false false false false false false false false false 0: false false false 0: false false false false false false false false false false false false cppcheck-2.17.1/cfg/std.cfg000066400000000000000000010665501475760761100154270ustar00rootroot00000000000000 true true arg1>0?arg1:-arg1 false arg1>0?arg1:-arg1 false false false false acos(arg1) false -1.0:1.0 acos(arg1) false -1.0:1.0 acos(arg1) false -1.0:1.0 acosh(arg1) false 1.0: acosh(arg1) false 1.0: acosh(arg1) false 1.0: false false 26: sqrt(arg1) false 0.0: sqrt(arg1) false 0.0: sqrt(arg1) false 0.0: false sinh(arg1) false sinh(arg1) false sinh(arg1) false sin(arg1) false sin(arg1) false sin(arg1) false false false asin(arg1) false -1.0:1.0 asin(arg1) false -1.0:1.0 asin(arg1) false -1.0:1.0 false asinh(arg1) false asinh(arg1) false asinh(arg1) false false false 0: tan(arg1) false tan(arg1) false tan(arg1) false false tanh(arg1) false tanh(arg1) false tanh(arg1) false false false false false false false false false false 1:31 false false 1:31 false atan(arg1) false atan(arg1) false atan(arg1) false false tgamma(arg1) false !0.0: tgamma(arg1) false !0.0: tgamma(arg1) false !0.0: trunc(arg1) false trunc(arg1) false trunc(arg1) false atanh(arg1) false -1.0:1.0 atanh(arg1) false -1.0:1.0 atanh(arg1) false -1.0:1.0 false atan2(arg1, arg2) false atan2(arg1, arg2) false atan2(arg1, arg2) false false false false false false false 0: 0: ceil(arg1) false ceil(arg1) false ceil(arg1) false false false false false false cbrt(arg1) false cbrt(arg1) false cbrt(arg1) false cos(arg1) false cos(arg1) false cos(arg1) false false false false false false false false 26: false false :-1,1: false :-1,1: true erf(arg1) false erf(arg1) false erf(arg1) false erfc(arg1) false erfc(arg1) false erfc(arg1) false false false false exp(arg1) false exp(arg1) false exp(arg1) false false false exp2(arg1) false exp2(arg1) false exp2(arg1) false expm1(arg1) false expm1(arg1) false expm1(arg1) false true false fabs(arg1) false fabs(arg1) false fabs(arg1) false fdim(arg1, arg2) false fdim(arg1, arg2) false fdim(arg1, arg2) false false false false false false false false floor(arg1) false floor(arg1) false floor(arg1) false false false false fmax(arg1,arg2) false fmax(arg1,arg2) false fmax(arg1,arg2) false fmin(arg1,arg2) false fmin(arg1,arg2) false fmin(arg1,arg2) false fmod(arg1,arg2) false !0.0 fmod(arg1,arg2) false !0.0 fmod(arg1,arg2) false !0.0 false false false false false false 0: false false false false 0: 0: false false false false false false hypot(arg1, arg2) false hypot(arg1, arg2) false hypot(arg1, arg2) false false false false false 0:2 false false 0: false 0: false false false 0: 0: false 0: false 0: false 0: false 0:255 false false false 0: false 0: false false false 0: false false 0:255 false false false Obsolete function 'gets' called. It is recommended to use 'fgets' or 'gets_s' instead. The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun if the input data exceeds the size of the buffer. It is recommended to use the functions 'fgets' or 'gets_s' instead. false 0: false arg1>=0x30 && arg1<=0x39 || arg1>=0x41 && arg1 <=0x5A || arg1>=0x61 && arg1 <=0x7A false 0:255 arg1>=0x30 && arg1<=0x39 || arg1>=0x41 && arg1 <=0x5A || arg1>=0x61 && arg1 <=0x7A false arg1>='A' && arg1<='Z' || arg1>='a' && arg1 <='z' false 0:255 arg1>='A' && arg1<='Z' || arg1>='a' && arg1 <='z' false arg1==' ' || arg1=='\t' false 0:255 arg1==' ' || arg1=='\t' false arg1==0x7F || arg1<=0x1F false 0:255 arg1==0x7F || arg1<=0x1F false false arg1>='0' && arg1<='9' false 0:255 arg1>='0' && arg1<='9' false arg1>=0x21 && arg1<=0x7E false 0:255 arg1>=0x21 && arg1<=0x7E false arg1>=0x61 && arg1<=0x7A false 0:255 arg1>=0x61 && arg1<=0x7A false arg1>=0x20 && arg1<=0x7E false 0:255 arg1>=0x20 && arg1<=0x7E false arg1>=0x21 && arg1<=0x2F || arg1>=0x3A && arg1<=0x40 || arg1>=0x5B && arg1<=0x60 || arg1>=0x7B && arg1<=0x7E false 0:255 arg1>=0x21 && arg1<=0x2F || arg1>=0x3A && arg1<=0x40 || arg1>=0x5B && arg1<=0x60 || arg1>=0x7B && arg1<=0x7E false arg1>=0x09 && arg1<=0x0D || arg1==0x20 false 0:255 arg1>=0x09 && arg1<=0x0D || arg1==0x20 false arg1>=0x41 && arg1<=0x5A false 0:255 arg1>=0x41 && arg1<=0x5A false arg1>=0x30 && arg1<=0x39 || arg1>=0x41 && arg1<=0x46 || arg1>=0x61 && arg1<=0x66 false 0:255 arg1>=0x30 && arg1<=0x39 || arg1>=0x41 && arg1<=0x46 || arg1>=0x61 && arg1<=0x66 false false arg1 < 'A' || arg1 > 'Z' ? arg1 : arg1 + 32 false arg1 < 'a' || arg1 > 'z' ? arg1 : arg1 - 32 false false false false false false arg1>0?arg1:-arg1 false arg1>0?arg1:-arg1 false ldexp(arg1,arg2) false ldexp(arg1,arg2) false ldexp(arg1,arg2) false lgamma(arg1) false !0.0: lgamma(arg1) false !0.0: lgamma(arg1) false !0.0: false false false false false false false false false 0: false :-1,1: false :-1,1: false false log(arg1) false 4.94066e-324: log(arg1) false 1.4013e-45: log(arg1) false 4.94066e-324: false false false false false arg1>arg2?1:0 false arg1>arg2?1:0 false arg1 >= arg2?1:0 false arg1 >= arg2?1:0 false false false logb(arg1) false logb(arg1) false logb(arg1) false arg1<arg2?1:0 false arg1 <= arg2?1:0 false (arg1<arg2 || arg1>arg2)?1:0 false false false false false false false ilogb(arg1) false ilogb(arg1) false ilogb(arg1) false log10(arg1) false 4.94066e-324: log10(arg1) false 1.4013e-45: log10(arg1) false 4.94066e-324: log1p(arg1) false log1p(arg1) false log1p(arg1) false log2(arg1) false 4.94066e-324: log2(arg1) false 1.4013e-45: log2(arg1) false 4.94066e-324: nearbyint(arg1) false nearbyint(arg1) false nearbyint(arg1) false nextafter(arg1) false nextafter(arg1) false nextafter(arg1) false nexttoward(arg1) false nexttoward(arg1) false nexttoward(arg1) false true false 0: false 0: false 0: false 0: 0: false 0: 0: false 0: false 0: false 0: false 0: false 0: 0: false 0: false 0: false 0: 0: false 0: false 0: false false false false false pow(arg1, arg2) false pow(arg1, arg2) false pow(arg1, arg2) false false false !0.0 false !0.0 false !0.0 remainder(arg1,arg2) false !0.0 remainder(arg1,arg2) false !0.0 remainder(arg1,arg2) false !0.0 false false false false 0: 0: false 0: 0: false 0: 0: false 0: false false 0: false 0: false 0: false false false 0: false false false round(arg1) false round(arg1) false round(arg1) false false false false maybe false false false false false false false 0:2 0: false false false false false 0:255 false false arg1 false false 1: false false 0: strlen(arg1) false arg1 false 0: false 0: false false 0: false 0: false 0: false 0: false 0: false false false false 0: false 0: false false false false false false false false false false 0: false false false 0:255 false false 0: false false false false false 0,2:36 false 0,2:36 false 0,2:36 false 0,2:36 false 0,2:36 false 0,2:36 false false false 0: false false arg1 < 'A' || arg1 > 'Z' ? arg1 : arg1 + 32 false 0:255 arg1 < 'a' || arg1 > 'z' ? arg1 : arg1 - 32 false 0:255 false false false false false false false false false false false false 0,2:36 false 0,2:36 false 0,2:36 false 0,2:36 false 0,2:36 false false 0: 0:255 false false 0: false false 0,2:36 false 0,2:36 false 0,2:36 false 0,2:36 false 0,2:36 false 0,2:36 false false false 0: false 0: false false 0: false false 0: false 0: false false false false false false false false false false false arg1<arg2?arg2:arg1>arg3?arg3:arg1 false arg1<arg2?arg1:arg2 false arg1>arg2?arg1:arg2 false false false false false false false false false 0: false false 0: false false false 0: false false false false false false false false false false 0: false 0: false false 0: false 0: false false false false false false false false false 0: false 0: false false 0: false false false arg1 false & arg1 false false false 0: false 0: false 0: false 0: false false false false false 0: 0: false false false false 0: 0: false 0: 0: false 0: 0: false 0: 0: false false false 0: false 0: false 0: false 0: false 0: false 2:36 false false false false false false false false false false false false false false false false false false false false false 0: false 0: 0: false 0: 0: false false false false false false false false false false 0: false false false false false false false false false false false false false false false false false false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false true false false false false false false false false false false false false false false false false false false false false false false false false 0: false 0: false 0: 0: false false false false false false false false false false malloc,std::malloc calloc,std::calloc aligned_alloc,std::aligned_alloc realloc,std::realloc free,std::free strdup,std::strdup free,std::free fopen,std::fopen tmpfile,std::tmpfile freopen,std::freopen fclose,std::fclose std::fstream std::wfstream std::ofstream std::wofstream std::basic_fstream std::basic_ofstream std::insert_iterator std::lock_guard std::scoped_lock std::unique_lock std::shared_lock std::pair std::complex std::exception std::logic_error std::domain_error std::invalid_argument std::length_error std::out_of_range std::future_error std::runtime_error std::range_error std::overflow_error std::underflow_error std::regex_error std::system_error std::format_error std::bad_typeid std::bad_cast std::monostate std::bad_optional_access std::bad_expected_access std::bad_weak_ptr std::bad_function_call std::bad_alloc std::bad_array_new_length std::bad_exception std::ios_base::failure std::filesystem::filesystem_error std::bad_variant_access std::span std::stringstream std::wstringstream std::istringstream std::wistringstream std::ostringstream std::wostringstream std::mutex std::recursive_mutex cppcheck-2.17.1/cfg/tinyxml2.cfg000066400000000000000000000023731475760761100164130ustar00rootroot00000000000000 false false false cppcheck-2.17.1/cfg/vcl.cfg000066400000000000000000000001361475760761100154040ustar00rootroot00000000000000 cppcheck-2.17.1/cfg/windows.cfg000066400000000000000000030163471475760761100163300ustar00rootroot00000000000000 CreatePen CreateBrushIndirect CreateDIBPatternBrush CreateDIBPatternBrushPt CreateHatchBrush CreatePatternBrush CreateSolidBrush CreateFont CreateFontIndirect CreateFontIndirectEx CreateBitmap CreateBitmapIndirect CreateCompatibleBitmap CreateDIBitmap CreateDIBSection CreateDiscardableBitmap CreateEllipticRgn CreateEllipticRgnIndirect CreatePolygonRgn CreatePolyPolygonRgn CreateRectRgn CreateRectRgnIndirect CreateRoundRectRgn CreateHalftonePalette CreatePalette DeleteObject closesocket socket CreateThread CreateFile CreateFileA CreateFileW OpenFile CreateJobObject CreateRemoteThread CreateConsoleScreenBuffer OpenBackupEventLog OpenEventLog CreateFileMapping CreateFileMappingFromApp CreateFileMappingNuma CreateMemoryResourceNotification OpenFileMapping CreateNamedPipe CreateEvent CreateEventA CreateEventW CreateEventEx CreateEventExA CreateEventExW CreateMutex CreateMutexA CreateMutexW CreateMutexEx CreateMutexExA CreateMutexExW CreateSemaphore CreateSemaphoreA CreateSemaphoreW CreateSemaphoreEx CreateSemaphoreExA CreateSemaphoreExW CreateTimerQueue CreateWaitableTimer OpenEvent OpenEventA OpenEventW OpenMutex OpenMutexA OpenMutexW OpenSemaphore OpenSemaphoreA OpenSemaphoreW OpenWaitableTimer OpenJobObject OpenProcess OpenThread CreateMailslot CloseHandle FindFirstFile FindFirstFileW FindFirstFileA FindFirstFileEx FindFirstFileExW FindFirstFileExA FindFirstFileNameW FindFirstFileNameTransactedW FindFirstStreamTransactedW FindFirstFileTransacted FindFirstFileTransactedA FindFirstFileTransactedW FindFirstStreamW FindClose OpenSCManager OpenService CreateService CloseServiceHandle LockServiceDatabase UnlockServiceDatabase HeapCreate HeapDestroy _wfopen _tfopen _wfopen_s _tfopen_s fclose _fcloseall _open _topen _wopen _close _popen _wpopen _tpopen _pclose LoadLibrary LoadLibraryA LoadLibraryW LoadLibraryEx LoadLibraryExA LoadLibraryExW FreeLibrary FreeLibraryAndExitThread UuidToString UuidToStringA UuidToStringW RpcStringFree ExAllocatePool ExAllocatePoolWithQuota ExAllocatePoolWithQuotaTag ExAllocatePoolWithTag ExAllocatePoolWithTagPriority ExFreePool ExFreePoolWithTag _dupenv_s _wdupenv_s _tdupenv_s free HeapAlloc HeapReAlloc HeapFree IoAllocateErrorLogEntry IoWriteErrorLogEntry IoFreeErrorLogEntry IoAllocateIrp IoFreeIrp IofCallDriver IoCallDriver IoAllocateMdl IoFreeMdl MmAllocateContiguousMemory MmFreeContiguousMemory MmAllocateContiguousMemorySpecifyCache MmAllocateContiguousMemorySpecifyCacheNode MmFreeContiguousMemorySpecifyCache IoAllocateWorkItem IoFreeWorkItem RtlAllocateHeap RtlFreeHeap ExAllocateFromPagedLookasideList ExFreeToPagedLookasideList ExAllocateFromNPagedLookasideList ExFreeToNPagedLookasideList AllocateHeap FreeHeap AllocateLsaHeap FreeLsaHeap AllocatePrivateHeap FreePrivateHeap VirtualAlloc VirtualFree VirtualAllocEx VirtualAllocExNuma VirtualFreeEx LocalAlloc LocalFree GlobalAlloc GlobalFree SetClipboardData MapViewOfFile MapViewOfFileEx MapViewOfFileExNuma MapViewOfFileFromApp UnmapViewOfFile RtlCreateHeap RtlDestroyHeap strdup wcsdup _strdup _wcsdup _mbsdup _tcsdup _malloc_dbg _calloc_dbg _strdup_dbg _wcsdup_dbg _tcsdup_dbg free _free_dbg _aligned_malloc _aligned_malloc_dbg _aligned_offset_malloc _aligned_offset_malloc_dbg _aligned_free _aligned_free_dbg CoTaskMemAlloc CoTaskMemFree _malloca _freea AllocateAndInitializeSid FreeSid false 0: false false 0: false 0: false false false false false false 0: false 0: true true false false false false false false false 0: false 0: false false 0: 0: false false false false false false false false false false false false false false arg1 false arg1 false false 1: Security Warning: Consider using StringCchCopy instead. Using this function incorrectly can compromise the security of your application. This function uses structured exception handling (SEH) to catch access violations and other errors. When this function catches SEH errors, it returns NULL without null-terminating the string and without notifying the caller of the error. The caller is not safe to assume that insufficient space is the error condition. false 1: Security Warning: Consider using StringCchCopy instead. Using this function incorrectly can compromise the security of your application. This function uses structured exception handling (SEH) to catch access violations and other errors. When this function catches SEH errors, it returns NULL without null-terminating the string and without notifying the caller of the error. The caller is not safe to assume that insufficient space is the error condition. false 1: false false false 1: false false false false false false false false false false false false false false false 0: false false false false false false false It is recommend you use _stricmp instead. false false false false false 0: false false false false 0: false 0: false 0: 0: false 0: 0: false false These POSIX functions are deprecated. Use the ISO C++ conformant _strdup, _wcsdup, _mbsdup instead. false false 0: false strcmp(arg1,arg2) false strcmp(arg1,arg2) false 0: false false 0: false false false false 0:2 false false false 0: false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false arg1>0?arg1:-arg1 false false false false false false false false false 0 false false false false false 0: false false false false 0: false 0: false false 0: false false false false false false false 0: 0: false false false 0: false 0: false 0: false 0: false 0: false 0: false false strlen(arg1) false strlen(arg1) false false false false false 0: false 0: false false false 0: false 0: false 0: false 0: false false false false false false false false false false false false false false false false false false false false false 0 false false false false false 0: false false true false 1: false false false false false false false false false false false false false false false false false Due to security concerns it is not recommended to use this function, see MSDN for details. false Due to security concerns it is not recommended to use this function, see MSDN for details. false false Due to security concerns it is not recommended to use this function, see MSDN for details. false Due to security concerns it is not recommended to use this function, see MSDN for details. false 1: false 1: 0 false false 1: false false false 0,1 false false false 0: false 0: This function is deprecated because a more secure version is available '_malloca'. false arg1 false arg1 false false false false false false false false 0: false 0: false false false false false false false false 1: false false false false 0: false 0: false false false false false false false false false false false false false false false false false false 0: false false false false false false false false arg1 < 'A' || arg1 > 'Z' ? arg1 : arg1 + 32 false 0:255 false 0:255 false arg1 < 'a' || arg1 > 'z' ? arg1 : arg1 - 32 false 0:255 false 0:255 false false 0: false 0: false false false false false false false 0: false 0: false 0: false false 2:36 false 2:36 false 0: false 0: false false false false false false This function is obsolete. The ControlTrace function supersedes this function. false 0: 0: false false false false false false false false false false false false GetVersion may be altered or unavailable for releases after Windows 8.1. Instead, use the Version Helper functions false GetVersionEx may be altered or unavailable for releases after Windows 8.1. Instead, use the Version Helper functions false false false false false false cppcheck-2.17.1/cfg/wxsqlite3.cfg000066400000000000000000002002671475760761100165720ustar00rootroot00000000000000 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false cppcheck-2.17.1/cfg/wxsvg.cfg000066400000000000000000022115361475760761100160100ustar00rootroot00000000000000 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -3.402823e+38:3.402823e+38 false -3.402823e+38:3.402823e+38 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false -3.402823e+38:3.402823e+38 false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false -3.402823e+38:3.402823e+38 false -3.402823e+38:3.402823e+38 -3.402823e+38:3.402823e+38 false -3.402823e+38:3.402823e+38 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false false false false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false false false false false false false false false false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false -1.79769e+308:1.79769e+308 false false false false false false false false false -1.79769e+308:1.79769e+308 -1.79769e+308:1.79769e+308 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false cppcheck-2.17.1/cfg/wxwidgets.cfg000066400000000000000000026540271475760761100166650ustar00rootroot00000000000000 wxAcceleratorEntry wxAny wxArchiveIterator wxArrayDouble wxArrayInt wxArrayPtrVoid wxArrayShort wxArrayString wxBitmap wxBitmapBundle wxBitmapHandler wxBoxSizer wxBrush wxChar wxUniChar wxUniCharRef wxColour wxColourDatabase wxCursor wxDateSpan wxDelegateRendererNative wxHeaderButtonParams wxRendererNative wxRendererVersion wxTextWrapper wxDCClipper wxDCBrushChanger wxDCFontChanger wxDCPenChanger wxDCTextColourChanger wxDCTextBgColourChanger wxDCTextBgModeChanger wxFileType wxFont wxFlexGridSizer wxFontEnumerator wxFontInfo wxFontList wxFontMetrics wxGBPosition wxGBSizerItem wxGBSpan wxGDIObject wxGraphicsBrush wxGraphicsFont wxGraphicsGradientStop wxGraphicsGradientStops wxGraphicsMatrix wxGraphicsPath wxGridBagSizer wxGridSizer wxIcon wxIconBundle wxIconLocation wxIFFHandler wxImage wxImageHandler wxGIFHandler wxJPEGHandler wxPCXHandler wxPNGHandler wxPNMHandler wxTGAHandler wxTIFFHandler wxXPMHandler wxMask wxMetafile wxNativeFontInfo wxPalette wxPen wxPenList wxPoint wxPoint2DDouble wxPoint2DInt wxPosition wxRealPoint wxRegion wxRegionContain wxRegionIterator wxRegEx wxRect wxSize wxSizer wxSizerItem wxSplitterRenderParams wxStaticBoxSizer wxStdDialogButtonSizer wxSystemOptions wxSystemSettings wxTarEntry wxTarInputStream wxTimeSpan wxUString wxVariant wxVariantData wxVariantDataCurrency wxVariantDataErrorCode wxVariantDataSafeArray wxVector wxVersionInfo wxWrapSizer wxZipEntry wxZipInputStream false false false 0: false false false false false false "#arg1" false false false This is the same as 'wxString::IsEmpty' and is kept for wxWidgets 1.xx compatibility. You should not use it in new code. false This is a wxWidgets 1.xx compatibility function; you should not use it in new code. false This is a wxWidgets 1.xx compatibility function; you should not use it in new code. false false This is a wxWidgets 1.xx compatibility function; you should not use it in new code. false This is a wxWidgets 1.xx compatibility function; you should not use it in new code. false This is the same as 'wxString::Len' and is kept for wxWidgets 1.xx compatibility. You should not use it in new code. false false false false false false false false false false true false false false false false false false false false 10,16 false false 0: false false false false false 0: false false false false false false false false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 1: false false 0: false false false false false false false false false false false false false false false false false false false false false false false This function is deprecated and kept mostly for backwards compatibility. Please override 'wxApp::MacOpenFiles' method instead in any new code. false This function is deprecated, use 'wxPlatformInfo::GetBitness()' instead. false This function is deprecated, please use 'ToWChar()' instead. false This function is deprecated, please use 'FromWChar()' instead. false This function has been deprecated in favour of 'wxMenuBar::SetMenuLabel()'. false This function only exists for compatibility, please override FormatTimeMS() in the new code. false This function is deprecated. Please use 'wxMenuItem::GetMenuLabel()' or 'wxMenuItem::GetMenuLabelText()' instead. false This function is deprecated. Please use 'wxMenuItem::GetItemLabel()' or 'wxMenuItem::GetItemLabelText()' instead. false This function is deprecated in favour of 'wxMenuItem::GetItemLabel()'. false This function is deprecated, use 'wxPlatformInfo::GetBitness()' instead. false This function is deprecated, use 'wxPGProperty::AddPrivateChild()' instead. false This function is deprecated. Ids generated by it can conflict with the Ids defined by the user code, use wxID_ANY to assign ids which are guaranteed to not conflict with the user-defined ids for the controls and menu items you create instead of using this function. false This function is deprecated, use 'wxPGProperty::GetValueAsString()' instead. false false This function is deprecated, use 'wxPlatformInfo::GetBitnessName()' instead. false This function is deprecated, use 'wxPlatformInfo::SetBitness()' instead. false This function is deprecated in favour of 'wxMenuItem::SetItemLabel()'. false This function is deprecated, please use 'wxFileName::SplitPath()' instead. false This function is deprecated. This is the old way of detecting tool right clicks, although it will still work, you should use the EVT_TOOL_RCLICKED() macro instead. false The setup dialog is deprecated, though retained for backward compatibility. false This function has been deprecated, use 'wxWindow::Close()' instead. false The setup dialog is deprecated, though retained for backward compatibility. false This function is deprecated use 'CreateThread()' instead. false This function is deprecated in favour of 'IsShown()'. false This function is deprecated and kept mostly for backwards compatibility. Please override 'PushBack' method instead in any new code. false This function should be used instead of changing 'wxCAL_NO_YEAR_CHANGE' style bit directly. It allows or disallows the user to change the year interactively. Only in generic 'wxCalendarCtrl'. false This function is deprecated. Construct a wxFileName with wxPATH_UNIX and then use wxFileName::GetFullPath(wxPATH_DOS) instead. false This function is deprecated. false This function is kept mostly for backwards compatibility. Use 'LastReadCount()' or 'LastWriteCount()' instead. 'LastCount()' is still needed for use with less commonly used functions: 'Discard()', 'Peek()', and 'Unread()'. false This function is deprecated. false This function is deprecated, use GetStream() instead false This function is deprecated because its name is misleading: notice that the argument is in milliseconds, not microseconds. Please use either 'wxMilliSleep()' or 'wxMicroSleep()' depending on the resolution you need. false This function is kept mostly for backwards compatibility. false This function is deprecated, use 'wxWindow::SetInitialSize' instead. false This function is deprecated, use 'wxTextInputStream::ReadLine()' or 'wxTextInputStream::ReadWord()' instead. false Use 'wxStyledTextEvent::GetString()' instead. false false false This function is deprecated. false false This function is deprecated, use 'wxDC::SetPalette' instead. false This function is deprecated and kept mostly for backwards compatibility. Please override 'GetMargins()' method instead in any new code. false false This function is deprecated and kept mostly for backwards compatibility. Please override 'Dismiss()' method instead in any new code. false This function is deprecated and kept mostly for backwards compatibility. Please override 'Popup()' method instead in any new code. false This function is deprecated and kept mostly for backwards compatibility. Please override 'SetMargins()' method instead in any new code. false This function is deprecated and kept mostly for backwards compatibility. Please override 'wxDataViewCustomRenderer::ActivateCell()' method instead in any new code. false This function is deprecated and kept mostly for backwards compatibility. Please override 'wxDataViewCustomRenderer::ActivateCell()' method instead in any new code. false false false This function is deprecated and is replaced by 'wxLog' functionality. false This function is deprecated and is replaced by 'wxLog' functionality. false This function is deprecated. Construct a 'wxFileName' with 'wxPATH_DOS' and then use 'wxFileName::GetFullPath(wxPATH_UNIX)' instead. false This function is deprecated. Please use 'wxFileName::SplitPath()' instead. false false false false This function is deprecated. false false This function is deprecated. This is exactly the same as 'FitInside()' in wxWidgets 2.9 and later, please replace calls to it with 'FitInside()'. false This function is deprecated. This function does not free the old sizer which may result in memory leaks, use 'wxSizerItem::AssignSizer' which does free it instead. false This is identical to 'wxSizerItem::SetMinSize()', prefer to use the other function, as its name is more clear false false false false false false false false false false false false false 0: false false This function is deprecated. This function does not free the old sizer which may result in memory leaks, use 'wxSizerItem::AssignSpacer' which does free it instead. false This function is for backward compatibility only, and applications should use 'wxHelpControllerBase::DisplaySection()' instead. false This function is deprecated. false This function is deprecated in favour of 'wxIconizeEvent::IsIconized()'. false This function is deprecated, use 'wxList::GetCount()' instead. Returns the number of elements in the list. false This function is deprecated since version 3.1.2, dimensions and depth can only be set at construction time. false false false false false false This function is deprecated, please use 'wxWindow::FindWindowByLabel()' instead. false This function is deprecated, please use 'wxWindow::FindWindowByName()' instead. false This function is deprecated, please use 'wxFileName::CreateTempFileName()' instead. false This function is deprecated, use 'wxGetUserId()' with no arguments instead. false This function is deprecated, use 'wxGetEmailAddress()' with no arguments instead. false This function is deprecated, use 'wxGetHostName()' with no arguments instead. false This function is deprecated, use 'wxGetUserName()' with no arguments instead. false This function is deprecated, use 'wxGetCwd()' instead. false This function is deprecated. Please use 'wxGrid::SetCellAlignment(row, col, horiz, vert)' instead. false false false false false false false false false false false false 0 false false false false false false false false false false false false false false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false strlen(arg1) false false false false false false This is the same as wxString::Trim() except that it doesn't change this string. This is a wxWidgets 1.xx compatibility function; you should not use it in new code. false false This function is deprecated since version 3.1.2, dimensions and depth can only be set at construction time. false 0: false 0,2:36 false false false false false false false false false 0,1 false false false false false false false false false false false false false false false false false false false false false false false 0: 0: false false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false true false false false false 0: false false false false false false false false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 1: false 1: false false false false false false false false false false false 0: false 0: false false false false false 0: false false false false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: false 0: false 0: false 0: false 1: false false false false false false false false false false false 0: false false false false false false false false false false 1: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: false 0: false false false 0: 0: false 0: 0: false false false false false 0: false false false false false false false false false false false 0:59 false 0:60 false 0:23 false false 1:12 false 1:31 false false false false false false 0: false false false false false 1: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0.0:1.0 false false false false false false false false false false false false false false false false false false false false false false false false false This is a wxWidgets 1.xx compatibility function. Use 'wxString::Mid' in new applications instead. false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false arg1<arg2?arg1:arg2 false arg1>arg2?arg1:arg2 false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 1: false 0: false false false This is a wxWidgets 1.xx compatibility function. Use 'wxString::Find' in new applications instead. false This is a wxWidgets 1.xx compatibility function. You should not use it in new code. false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false This is a wxWidgets 1.xx compatibility function. Use 'wxString::Truncate' in new applications instead. false false This is a wxWidgets 1.xx compatibility function. Use 'wxString::MakeUpper' in new applications instead. false This is a wxWidgets 1.xx compatibility function. Use 'wxString::MakeLower' in new applications instead. false false false false false 0:255 0:255 0:255 false false false false false false false false false false false false 0: 1: false false 1: false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false false 0: false false false false false false false false false false false 0: false false false false 0: 0: false false false false false false false 0: false 0: false 0: false 0: false false false false false 0:15 false 0:15 false false false false false false false false false false false false false false false false false false false false false false false false false 0: false false false false false 0: false 0: false false false 0: 1: false 0: false false false false 0: 0: 0: false false false false false false false false false false false false false false false Please note that this method does the same thing as the standard 'reserve()' one and should not be used in new code. false false false false 0: false false false false false false false false false false false false false false false false false false false false false false false false false false false false cppcheck-2.17.1/cfg/zephyr.cfg000066400000000000000000000052671475760761100161530ustar00rootroot00000000000000 false false false false false false 0:2147483647 false cppcheck-2.17.1/cfg/zlib.cfg000066400000000000000000001131471475760761100155670ustar00rootroot00000000000000 false false false false false false false false false 0: false false false false false false 0: false false :16 false false false 0: false false false false false false :16 false false false false false false 0: false 0: false 0: false 0: false gzopen gzopen64 gzdopen gzopen_w gzclose gzclose_r gzclose_w false false false 0: false false 0: false 0: 0: false 0: false 0: 0: false false false 0: false 0:255 false false 0:255 false false false false false false false false false false false false false false 0: 0: false 0: 0: false 0: 0: false 0: 0: false 0: 0: false 0: 0: false false false false false false false false cppcheck-2.17.1/clang-tidy.md000066400000000000000000000151701475760761100157610ustar00rootroot00000000000000# clang-tidy Below are the reasoning why certain checks are (currently) disabled for out code base ## Externals We do not perform static analysis of the source of the external libraries. `simplecpp` has its own CI with a clang-tidy workflow. ## Disabled Checks `abseil-*`
`altera-*`
`android-*`
`boost-*`
`darwin-*`
`fuchsia-*`
`linuxkernel-*`
`llvm-*`
`llvmlibc-*`
`mpi-*`
`objc-*`
`openmp-*`
`zircon-*`
These are disabled since the platforms/libraries in question are not targeted by us. `cert-*`
`cppcoreguidelines-*`
`google-*`
`hicpp-*`
These are coding guidelines we do not follow. Some of the checks might be explicitly enabled though. `readability-braces-around-statements`
`readability-isolate-declaration`
`modernize-use-trailing-return-type`
`readability-uppercase-literal-suffix`
`readability-identifier-length`
These do not reflect the style we are (currently) enforcing. `readability-function-size`
`readability-function-cognitive-complexity`
We are not interested in the size/complexity of a function. `readability-magic-numbers`
These do not (always) increase readability. `bugprone-macro-parentheses`
To be documented. `readability-implicit-bool-conversion`
This does not appear to be useful as it is reported on very common code. `bugprone-narrowing-conversions`
`performance-no-automatic-move`
It was decided not to apply these. `modernize-loop-convert`
These might change the behavior of code which might not be intended (need to file an upstream issue) `modernize-raw-string-literal`
This leads to a mismatch of raw string literals and regular ones and does reduce the readability. `-clang-analyzer-*`
Disabled because of false positives (need to file upstream bug reports). The checks are also quite time consuming. `misc-non-private-member-variables-in-classes`
We intentionally use this. `misc-no-recursion`
Leads to lots of "false positives". This seem to enforce a coding guidelines of certain codebases. `bugprone-easily-swappable-parameters`
This produces a lot of noise and they are not fixable that easily. `readability-container-data-pointer`
Disable because of false positives and inconsistent warnings (need to file an upstream bug report). `misc-const-correctness`
Work in progress. `bugprone-assignment-in-if-condition`
Is reported for valid patterns we are using. `readability-suspicious-call-argument`
Produces a lot of false positives since it is too vague in its analysis. `performance-inefficient-string-concatenation`
Produces warnings which might be considered false positives starting with C++11 - see https://github.com/llvm/llvm-project/issues/54526. `modernize-avoid-c-arrays`
Produces warnings when `const char[]` is being used which is quite common in our code. Does not make sense to enable before C++17 when `std::string_view` becomes available. Also reports a false positive about templates which deduce the array length: https://github.com/llvm/llvm-project/issues/60053. `misc-include-cleaner`
We run this separately via `clang-include-cleaner` in the `iwyu.yml` workflow as the findings of the include checkers still need to be reviewed manually before applying them. `bugprone-branch-clone`
`modernize-return-braced-init-list`
`misc-throw-by-value-catch-by-reference`
`bugprone-signed-char-misuse`
`concurrency-mt-unsafe`
`misc-use-anonymous-namespace`
`performance-avoid-endl`
`bugprone-switch-missing-default-case`
`bugprone-empty-catch`
`readability-avoid-nested-conditional-operator`
`modernize-use-designated-initializers`
`readability-enum-initial-value`
To be evaluated (need to remove exclusion). `cppcoreguidelines-missing-std-forward`
`cppcoreguidelines-avoid-const-or-ref-data-members`
`cppcoreguidelines-macro-usage`
`cppcoreguidelines-pro-type-member-init`
`cppcoreguidelines-prefer-member-initializer`
`cppcoreguidelines-misleading-capture-default-by-value`
`bugprone-argument-comment.CommentBoolLiterals`
`cert-err33-c`
`google-readability-namespace-comments`
`cppcoreguidelines-special-member-functions`
To be evaluated (need to enable explicitly). `modernize-type-traits`
`modernize-use-nodiscard`
These apply to codebases which use later standards then C++11 (C++17 is used when building with Qt6) so we cannot simply apply them. ### Disabled for performance reasons `portability-std-allocator-const`
Only necessary for code which is exclusively compiled with `libc++`. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. `modernize-deprecated-ios-base-aliases`
Warns about aliases which are removed in C++20. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. `bugprone-unchecked-optional-access`
We are not using any `optional` implementation. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. `modernize-replace-auto-ptr`
Still available until C++17. It is unlikely such code will ever be introduced. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. `readability-identifier-naming`
We are currently using our own `naming.json` to enforce naming schemes. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. `portability-simd-intrinsics`
We are not using SIMD instructions and it suggests to use `std::experiemental::` features which might not be commonly available. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. `modernize-macro-to-enum`
It does not seem to produce any warnings for us (needs to be investigated) and it is one of the more expensive checks. `misc-unused-using-decls`
This is the most expensive check for several files and it is providing much in terms of code quality. Reported upstream as https://github.com/llvm/llvm-project/issues/72300. ### Disabled for GUI only `readability-convert-member-functions-to-static`
Disabled because of false positives with Qt `slot` methods (see https://github.com/llvm/llvm-project/issues/57520). `readability-redundant-access-specifiers`
Reports warning with the Qt ` slots:` syntax in class declarations - see https://github.com/llvm/llvm-project/issues/60055. cppcheck-2.17.1/cli/000077500000000000000000000000001475760761100141475ustar00rootroot00000000000000cppcheck-2.17.1/cli/CMakeLists.txt000066400000000000000000000070741475760761100167170ustar00rootroot00000000000000if (BUILD_CLI) file(GLOB hdrs "*.h") file(GLOB srcs "*.cpp") file(GLOB mainfile "main.cpp") list(REMOVE_ITEM srcs ${mainfile}) add_library(cli_objs OBJECT ${hdrs} ${srcs}) target_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/lib/) if(USE_BUNDLED_TINYXML2) target_externals_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/) else() target_include_directories(cli_objs SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS}) endif() target_externals_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/picojson/) target_externals_include_directories(cli_objs PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/) if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS) target_precompile_headers(cli_objs PRIVATE precompiled.h) endif() if (BUILD_CORE_DLL) target_compile_definitions(cli_objs PRIVATE CPPCHECKLIB_IMPORT TINYXML2_IMPORT) endif() if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 13) # false positive warning in Clang 13 - caused by FD_ZERO macro set_source_files_properties(processexecutor.cpp PROPERTIES COMPILE_FLAGS -Wno-reserved-identifier) endif() list(APPEND cppcheck_SOURCES ${hdrs} ${mainfile} $) if (NOT BUILD_CORE_DLL) list(APPEND cppcheck_SOURCES $) list(APPEND cppcheck_SOURCES $) if(USE_BUNDLED_TINYXML2) list(APPEND cppcheck_SOURCES $) endif() endif() if (WIN32) list(APPEND cppcheck_SOURCES version.rc) endif() add_executable(cppcheck ${cppcheck_SOURCES}) target_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/lib/) if(USE_BUNDLED_TINYXML2) target_externals_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/externals/tinyxml2/) else() target_include_directories(cppcheck SYSTEM PRIVATE ${tinyxml2_INCLUDE_DIRS}) endif() target_externals_include_directories(cppcheck PRIVATE ${PROJECT_SOURCE_DIR}/externals/simplecpp/) if (HAVE_RULES) target_link_libraries(cppcheck ${PCRE_LIBRARY}) endif() if (WIN32 AND NOT BORLAND) if(NOT MINGW) target_link_libraries(cppcheck Shlwapi.lib) else() target_link_libraries(cppcheck shlwapi) endif() endif() if(tinyxml2_FOUND AND NOT USE_BUNDLED_TINYXML2) target_link_libraries(cppcheck ${tinyxml2_LIBRARIES}) endif() target_link_libraries(cppcheck ${CMAKE_THREAD_LIBS_INIT}) if (BUILD_CORE_DLL) target_link_libraries(cppcheck cppcheck-core) endif() add_dependencies(cppcheck copy_cfg) add_dependencies(cppcheck copy_addons) add_dependencies(cppcheck copy_platforms) if (NOT DISABLE_DMAKE) add_dependencies(cppcheck run-dmake) endif() install(TARGETS cppcheck RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications) install(PROGRAMS ${CMAKE_SOURCE_DIR}/htmlreport/cppcheck-htmlreport DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications) install(FILES ${addons_py} DESTINATION ${FILESDIR_DEF}/addons COMPONENT headers) install(FILES ${addons_json} DESTINATION ${FILESDIR_DEF}/addons COMPONENT headers) install(FILES ${cfgs} DESTINATION ${FILESDIR_DEF}/cfg COMPONENT headers) install(FILES ${platforms} DESTINATION ${FILESDIR_DEF}/platforms COMPONENT headers) endif() cppcheck-2.17.1/cli/cli.vcxproj000066400000000000000000000375051475760761100163450ustar00rootroot00000000000000 Debug-PCRE x64 Debug x64 Release-PCRE x64 Release x64 {35CBDF51-2456-3EC3-99ED-113C30858883} cli 10.0 Application Unicode false v142 Application Unicode false v142 Application Unicode false v142 Application Unicode false v142 $(SolutionDir)bin\debug\ $(SolutionDir)bin\debug\ temp\$(Configuration)_$(PlatformName)\ temp\$(Configuration)_$(PlatformName)\ cppcheck cppcheck true true $(SolutionDir)bin\ $(SolutionDir)bin\ temp\$(Configuration)_$(PlatformName)\ temp\$(Configuration)_$(PlatformName)\ cppcheck cppcheck true true true true ..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) true ProgramDatabase Disabled CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level4 4018;4127;4146;4244;4251;4267;4389;4701;4706;4800;4805 true Use precompiled.h precompiled.h true stdcpp14 /Zc:throwingNew /Zc:__cplusplus %(AdditionalOptions) shlwapi.lib;%(AdditionalDependencies) ../externals;%(AdditionalLibraryDirectories) true Console true 8000000 8000000 true ..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) true ProgramDatabase Disabled CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) MultiThreadedDebugDLL Level4 4018;4127;4146;4244;4251;4267;4389;4701;4706;4800;4805 true Use precompiled.h precompiled.h true stdcpp14 /Zc:throwingNew /Zc:__cplusplus %(AdditionalOptions) shlwapi.lib;%(AdditionalDependencies) ../externals;%(AdditionalLibraryDirectories) true Console true 8000000 8000000 true ..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) false MaxSpeed CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) MultiThreadedDLL Level4 AnySuitable true Speed true true true 4018;4127;4146;4244;4251;4267;4389;4701;4706;4800;4805 ProgramDatabase true Use precompiled.h precompiled.h /Zc:throwingNew /Zc:__cplusplus %(AdditionalOptions) true stdcpp14 shlwapi.lib;%(AdditionalDependencies) ../externals;%(AdditionalLibraryDirectories) true Console true true true true 8000000 8000000 true ..\lib;..\externals;..\externals\picojson;..\externals\simplecpp;..\externals\tinyxml2;%(AdditionalIncludeDirectories) false MaxSpeed CPPCHECKLIB_IMPORT;TINYXML2_IMPORT;NDEBUG;WIN32;HAVE_RULES;_CRT_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN;_WIN64;%(PreprocessorDefinitions) MultiThreadedDLL Level4 AnySuitable true Speed true true true 4018;4127;4146;4244;4251;4267;4389;4701;4706;4800;4805 ProgramDatabase true Use precompiled.h precompiled.h /Zc:throwingNew /Zc:__cplusplus %(AdditionalOptions) true stdcpp14 shlwapi.lib;%(AdditionalDependencies) ../externals;%(AdditionalLibraryDirectories) true Console true true true true 8000000 8000000 true {c183db5b-ad6c-423d-80ca-1f9549555a1a} Create Create Create Create cppcheck-2.17.1/cli/cli.vcxproj.filters000066400000000000000000000057151475760761100200120ustar00rootroot00000000000000 {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx {6d3be647-edb6-43e6-a7eb-3031a2c7b655} Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Resource Files cppcheck-2.17.1/cli/cmdlinelogger.h000066400000000000000000000023051475760761100171330ustar00rootroot00000000000000/* -*- C++ -*- * Cppcheck - A tool for static C/C++ code analysis * Copyright (C) 2007-2024 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef CMD_LINE_LOGGER_H #define CMD_LINE_LOGGER_H #include class CmdLineLogger { public: virtual ~CmdLineLogger() = default; /** print a regular message */ virtual void printMessage(const std::string &message) = 0; /** print an error message */ virtual void printError(const std::string &message) = 0; /** print to the output */ virtual void printRaw(const std::string &message) = 0; }; #endif // CMD_LINE_LOGGER_H cppcheck-2.17.1/cli/cmdlineparser.cpp000066400000000000000000003023011475760761100175020ustar00rootroot00000000000000/* * Cppcheck - A tool for static C/C++ code analysis * Copyright (C) 2007-2025 Cppcheck team. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "cmdlineparser.h" #include "addoninfo.h" #include "check.h" #include "checkers.h" #include "color.h" #include "config.h" #include "cppcheck.h" #include "errorlogger.h" #include "errortypes.h" #include "filelister.h" #include "filesettings.h" #include "importproject.h" #include "library.h" #include "path.h" #include "pathmatch.h" #include "platform.h" #include "settings.h" #include "standards.h" #include "suppressions.h" #include "timer.h" #include "utils.h" #include #include #include #include #include // EXIT_FAILURE #include #include #include #include #include #include #include #include #include #ifdef HAVE_RULES // xml is used for rules #include "xml.h" #endif static bool addFilesToList(const std::string& fileList, std::vector& pathNames) { std::istream *files; std::ifstream infile; if (fileList == "-") { // read from stdin files = &std::cin; } else { infile.open(fileList); if (!infile.is_open()) return false; files = &infile; } std::string fileName; // cppcheck-suppress accessMoved - FP while (std::getline(*files, fileName)) { // next line // cppcheck-suppress accessMoved - FP if (!fileName.empty()) { pathNames.emplace_back(std::move(fileName)); } } return true; } static bool addIncludePathsToList(const std::string& fileList, std::list& pathNames) { std::ifstream files(fileList); if (files) { std::string pathName; // cppcheck-suppress accessMoved - FP while (std::getline(files, pathName)) { // next line if (!pathName.empty()) { pathName = Path::removeQuotationMarks(std::move(pathName)); pathName = Path::fromNativeSeparators(std::move(pathName)); // If path doesn't end with / or \, add it if (!endsWith(pathName, '/')) pathName += '/'; pathNames.emplace_back(std::move(pathName)); } } return true; } return false; } static bool addPathsToSet(const std::string& fileName, std::set& set) { std::list templist; if (!addIncludePathsToList(fileName, templist)) return false; set.insert(templist.cbegin(), templist.cend()); return true; } namespace { class XMLErrorMessagesLogger : public ErrorLogger { void reportOut(const std::string & outmsg, Color /*c*/ = Color::Reset) override { std::cout << outmsg << std::endl; } void reportErr(const ErrorMessage &msg) override { reportOut(msg.toXML()); } void reportProgress(const std::string & /*filename*/, const char /*stage*/[], const std::size_t /*value*/) override {} }; } CmdLineParser::CmdLineParser(CmdLineLogger &logger, Settings &settings, Suppressions &suppressions) : mLogger(logger) , mSettings(settings) , mSuppressions(suppressions) {} bool CmdLineParser::fillSettingsFromArgs(int argc, const char* const argv[]) { const Result result = parseFromArgs(argc, argv); switch (result) { case Result::Success: break; case Result::Exit: Settings::terminate(); return true; case Result::Fail: return false; } // Libraries must be loaded before FileLister is executed to ensure markup files will be // listed properly. if (!loadLibraries(mSettings)) return false; if (!loadAddons(mSettings)) return false; // Check that all include paths exist { for (auto iter = mSettings.includePaths.cbegin(); iter != mSettings.includePaths.cend(); ) { const std::string path(Path::toNativeSeparators(*iter)); if (Path::isDirectory(path)) ++iter; else { // TODO: this bypasses the template format and other settings // If the include path is not found, warn user and remove the non-existing path from the list. if (mSettings.severity.isEnabled(Severity::information)) std::cout << "(information) Couldn't find path given by -I '" << path << '\'' << std::endl; iter = mSettings.includePaths.erase(iter); } } } // Output a warning for the user if he tries to exclude headers const std::vector& ignored = getIgnoredPaths(); const bool warn = std::any_of(ignored.cbegin(), ignored.cend(), [](const std::string& i) { return Path::isHeader(i); }); if (warn) { mLogger.printMessage("filename exclusion does not apply to header (.h and .hpp) files."); mLogger.printMessage("Please use --suppress for ignoring results from the header files."); } const std::vector& pathnamesRef = getPathNames(); const std::list& fileSettingsRef = getFileSettings(); // the inputs can only be used exclusively - CmdLineParser should already handle this assert(!(!pathnamesRef.empty() && !fileSettingsRef.empty())); if (!fileSettingsRef.empty()) { // TODO: de-duplicate std::list fileSettings; if (!mSettings.fileFilters.empty()) { // filter only for the selected filenames from all project files std::copy_if(fileSettingsRef.cbegin(), fileSettingsRef.cend(), std::back_inserter(fileSettings), [&](const FileSettings &fs) { return matchglobs(mSettings.fileFilters, fs.filename()); }); if (fileSettings.empty()) { mLogger.printError("could not find any files matching the filter."); return false; } } else { fileSettings = fileSettingsRef; } mFileSettings.clear(); if (mSettings.enforcedLang != Standards::Language::None) { // apply enforced language for (auto& fs : fileSettings) { if (mSettings.library.markupFile(fs.filename())) continue; fs.file.setLang(mSettings.enforcedLang); } } else { // identify files for (auto& fs : fileSettings) { if (mSettings.library.markupFile(fs.filename())) continue; bool header = false; fs.file.setLang(Path::identify(fs.filename(), mSettings.cppHeaderProbe, &header)); // unknown extensions default to C++ if (!header && fs.file.lang() == Standards::Language::None) fs.file.setLang(Standards::Language::CPP); } } // enforce the language since markup files are special and do not adhere to the enforced language for (auto& fs : fileSettings) { if (mSettings.library.markupFile(fs.filename())) { fs.file.setLang(Standards::Language::C); } } // sort the markup last std::copy_if(fileSettings.cbegin(), fileSettings.cend(), std::back_inserter(mFileSettings), [&](const FileSettings &fs) { return !mSettings.library.markupFile(fs.filename()) || !mSettings.library.processMarkupAfterCode(fs.filename()); }); std::copy_if(fileSettings.cbegin(), fileSettings.cend(), std::back_inserter(mFileSettings), [&](const FileSettings &fs) { return mSettings.library.markupFile(fs.filename()) && mSettings.library.processMarkupAfterCode(fs.filename()); }); if (mFileSettings.empty()) { mLogger.printError("could not find or open any of the paths given."); return false; } } if (!pathnamesRef.empty()) { std::list filesResolved; // TODO: this needs to be inlined into PathMatch as it depends on the underlying filesystem #if defined(_WIN32) // For Windows we want case-insensitive path matching const bool caseSensitive = false; #else const bool caseSensitive = true; #endif // Execute recursiveAddFiles() to each given file parameter // TODO: verbose log which files were ignored? const PathMatch matcher(ignored, caseSensitive); for (const std::string &pathname : pathnamesRef) { const std::string err = FileLister::recursiveAddFiles(filesResolved, Path::toNativeSeparators(pathname), mSettings.library.markupExtensions(), matcher); if (!err.empty()) { // TODO: bail out? mLogger.printMessage(err); } } if (filesResolved.empty()) { mLogger.printError("could not find or open any of the paths given."); // TODO: PathMatch should provide the information if files were ignored if (!ignored.empty()) mLogger.printMessage("Maybe all paths were ignored?"); return false; } // de-duplicate files { auto it = filesResolved.begin(); while (it != filesResolved.end()) { const std::string& name = it->path(); // TODO: log if duplicated files were dropped filesResolved.erase(std::remove_if(std::next(it), filesResolved.end(), [&](const FileWithDetails& entry) { return entry.path() == name; }), filesResolved.end()); ++it; } } std::list files; if (!mSettings.fileFilters.empty()) { std::copy_if(filesResolved.cbegin(), filesResolved.cend(), std::inserter(files, files.end()), [&](const FileWithDetails& entry) { return matchglobs(mSettings.fileFilters, entry.path()); }); if (files.empty()) { mLogger.printError("could not find any files matching the filter."); return false; } } else { files = std::move(filesResolved); } if (mSettings.enforcedLang != Standards::Language::None) { // apply enforced language for (auto& f : files) { if (mSettings.library.markupFile(f.path())) continue; f.setLang(mSettings.enforcedLang); } } else { // identify remaining files for (auto& f : files) { if (f.lang() != Standards::Language::None) continue; if (mSettings.library.markupFile(f.path())) continue; bool header = false; f.setLang(Path::identify(f.path(), mSettings.cppHeaderProbe, &header)); // unknown extensions default to C++ if (!header && f.lang() == Standards::Language::None) f.setLang(Standards::Language::CPP); } } // enforce the language since markup files are special and do not adhere to the enforced language for (auto& f : files) { if (mSettings.library.markupFile(f.path())) { f.setLang(Standards::Language::C); } } // sort the markup last std::copy_if(files.cbegin(), files.cend(), std::inserter(mFiles, mFiles.end()), [&](const FileWithDetails& entry) { return !mSettings.library.markupFile(entry.path()) || !mSettings.library.processMarkupAfterCode(entry.path()); }); std::copy_if(files.cbegin(), files.cend(), std::inserter(mFiles, mFiles.end()), [&](const FileWithDetails& entry) { return mSettings.library.markupFile(entry.path()) && mSettings.library.processMarkupAfterCode(entry.path()); }); if (mFiles.empty()) { mLogger.printError("could not find or open any of the paths given."); return false; } } return true; } // TODO: normalize/simplify/native all path parameters // TODO: error out on all missing given files/paths CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const argv[]) { mSettings.exename = Path::getCurrentExecutablePath(argv[0]); // default to --check-level=normal from CLI for now mSettings.setCheckLevel(Settings::CheckLevel::normal); if (argc <= 1) { printHelp(); return Result::Exit; } // check for exclusive options for (int i = 1; i < argc; i++) { // documentation.. if (std::strcmp(argv[i], "--doc") == 0) { std::ostringstream doc; // Get documentation.. for (const Check * it : Check::instances()) { const std::string& name(it->name()); const std::string info(it->classInfo()); if (!name.empty() && !info.empty()) doc << "## " << name << " ##\n" << info << "\n"; } mLogger.printRaw(doc.str()); return Result::Exit; } // print all possible error messages.. if (std::strcmp(argv[i], "--errorlist") == 0) { if (!loadCppcheckCfg()) return Result::Fail; { XMLErrorMessagesLogger xmlLogger; std::cout << ErrorMessage::getXMLHeader(mSettings.cppcheckCfgProductName, 2); CppCheck::getErrorMessages(xmlLogger); std::cout << ErrorMessage::getXMLFooter(2) << std::endl; } return Result::Exit; } // Print help if (std::strcmp(argv[i], "-h") == 0 || std::strcmp(argv[i], "--help") == 0) { printHelp(); return Result::Exit; } if (std::strcmp(argv[i], "--version") == 0) { if (!loadCppcheckCfg()) return Result::Fail; const std::string version = getVersion(); mLogger.printRaw(version); return Result::Exit; } } bool def = false; bool maxconfigs = false; ImportProject project; bool executorAuto = true; for (int i = 1; i < argc; i++) { if (argv[i][0] == '-') { // User define if (std::strncmp(argv[i], "-D", 2) == 0) { std::string define; // "-D define" if (std::strcmp(argv[i], "-D") == 0) { ++i; if (i >= argc || argv[i][0] == '-') { mLogger.printError("argument to '-D' is missing."); return Result::Fail; } define = argv[i]; } // "-Ddefine" else { define = 2 + argv[i]; } // No "=", append a "=1" if (define.find('=') == std::string::npos) define += "=1"; if (!mSettings.userDefines.empty()) mSettings.userDefines += ";"; mSettings.userDefines += define; def = true; } // -E else if (std::strcmp(argv[i], "-E") == 0) { mSettings.preprocessOnly = true; mSettings.quiet = true; } // Include paths else if (std::strncmp(argv[i], "-I", 2) == 0) { std::string path; // "-I path/" if (std::strcmp(argv[i], "-I") == 0) { ++i; if (i >= argc || argv[i][0] == '-') { mLogger.printError("argument to '-I' is missing."); return Result::Fail; } path = argv[i]; } // "-Ipath/" else { path = 2 + argv[i]; } path = Path::removeQuotationMarks(std::move(path)); path = Path::fromNativeSeparators(std::move(path)); // If path doesn't end with / or \, add it if (!endsWith(path,'/')) path += '/'; mSettings.includePaths.emplace_back(std::move(path)); } // User undef else if (std::strncmp(argv[i], "-U", 2) == 0) { std::string undef; // "-U undef" if (std::strcmp(argv[i], "-U") == 0) { ++i; if (i >= argc || argv[i][0] == '-') { mLogger.printError("argument to '-U' is missing."); return Result::Fail; } undef = argv[i]; } // "-Uundef" else { undef = 2 + argv[i]; } mSettings.userUndefs.insert(std::move(undef)); } else if (std::strncmp(argv[i], "--addon=", 8) == 0) mSettings.addons.emplace(argv[i]+8); else if (std::strncmp(argv[i],"--addon-python=", 15) == 0) mSettings.addonPython.assign(argv[i]+15); // Check configuration else if (std::strcmp(argv[i], "--check-config") == 0) mSettings.checkConfiguration = true; // Check level else if (std::strncmp(argv[i], "--check-level=", 14) == 0) { Settings::CheckLevel level = Settings::CheckLevel::normal; const std::string level_s(argv[i] + 14); if (level_s == "reduced") level = Settings::CheckLevel::reduced; else if (level_s == "normal") level = Settings::CheckLevel::normal; else if (level_s == "exhaustive") level = Settings::CheckLevel::exhaustive; else { mLogger.printError("unknown '--check-level' value '" + level_s + "'."); return Result::Fail; } mSettings.setCheckLevel(level); } // Check library definitions else if (std::strcmp(argv[i], "--check-library") == 0) { mSettings.checkLibrary = true; } else if (std::strncmp(argv[i], "--check-version=", 16) == 0) { if (!loadCppcheckCfg()) return Result::Fail; const std::string actualVersion = getVersion(); const std::string wantedVersion = argv[i] + 16; if (actualVersion != wantedVersion) { mLogger.printError("--check-version check failed. Aborting."); return Result::Fail; } } else if (std::strncmp(argv[i], "--checkers-report=", 18) == 0) mSettings.checkersReportFilename = argv[i] + 18; else if (std::strncmp(argv[i], "--checks-max-time=", 18) == 0) { if (!parseNumberArg(argv[i], 18, mSettings.checksMaxTime, true)) return Result::Fail; } else if (std::strcmp(argv[i], "--clang") == 0) { mSettings.clang = true; } else if (std::strncmp(argv[i], "--clang=", 8) == 0) { mSettings.clang = true; mSettings.clangExecutable = argv[i] + 8; } else if (std::strncmp(argv[i], "--config-exclude=",17) ==0) { mSettings.configExcludePaths.insert(Path::fromNativeSeparators(argv[i] + 17)); } else if (std::strncmp(argv[i], "--config-excludes-file=", 23) == 0) { // open this file and read every input file (1 file name per line) const std::string cfgExcludesFile(23 + argv[i]); if (!addPathsToSet(cfgExcludesFile, mSettings.configExcludePaths)) { mLogger.printError("unable to open config excludes file at '" + cfgExcludesFile + "'"); return Result::Fail; } } else if (std::strncmp(argv[i], "--cppcheck-build-dir=", 21) == 0) { std::string path = Path::fromNativeSeparators(argv[i] + 21); if (path.empty()) { mLogger.printError("no path has been specified for --cppcheck-build-dir"); return Result::Fail; } if (endsWith(path, '/')) path.pop_back(); mSettings.buildDir = std::move(path); } else if (std::strcmp(argv[i], "--cpp-header-probe") == 0) { mSettings.cppHeaderProbe = true; } // Show debug warnings for lookup for configuration files else if (std::strcmp(argv[i], "--debug-clang-output") == 0) mSettings.debugClangOutput = true; // Show --debug output after the first simplifications else if (std::strcmp(argv[i], "--debug") == 0 || std::strcmp(argv[i], "--debug-normal") == 0) mSettings.debugnormal = true; // Show debug warnings for lookup for configuration files else if (std::strcmp(argv[i], "--debug-lookup") == 0) mSettings.debuglookup = true; else if (std::strncmp(argv[i], "--debug-lookup=", 15) == 0) { const std::string lookup = argv[i] + 15; if (lookup == "all") mSettings.debuglookup = true; else if (lookup == "addon") mSettings.debuglookupAddon = true; else if (lookup == "config") mSettings.debuglookupConfig = true; else if (lookup == "library") mSettings.debuglookupLibrary = true; else if (lookup == "platform") mSettings.debuglookupPlatform = true; else { mLogger.printError("unknown lookup '" + lookup + "'"); return Result::Fail; } } // Flag used for various purposes during debugging else if (std::strcmp(argv[i], "--debug-simplified") == 0) mSettings.debugSimplified = true; // Show template information else if (std::strcmp(argv[i], "--debug-template") == 0) mSettings.debugtemplate = true; // Show debug warnings else if (std::strcmp(argv[i], "--debug-warnings") == 0) mSettings.debugwarnings = true; else if (std::strncmp(argv[i], "--disable=", 10) == 0) { const std::string errmsg = mSettings.removeEnabled(argv[i] + 10); if (!errmsg.empty()) { mLogger.printError(errmsg); return Result::Fail; } } // dump cppcheck data else if (std::strcmp(argv[i], "--dump") == 0) mSettings.dump = true; else if (std::strcmp(argv[i], "--emit-duplicates") == 0) mSettings.emitDuplicates = true; else if (std::strncmp(argv[i], "--enable=", 9) == 0) { const std::string enable_arg = argv[i] + 9; const std::string errmsg = mSettings.addEnabled(enable_arg); if (!errmsg.empty()) { mLogger.printError(errmsg); return Result::Fail; } // when "style" is enabled, also enable "warning", "performance" and "portability" if (enable_arg.find("style") != std::string::npos) { mSettings.addEnabled("warning"); mSettings.addEnabled("performance"); mSettings.addEnabled("portability"); } } // --error-exitcode=1 else if (std::strncmp(argv[i], "--error-exitcode=", 17) == 0) { if (!parseNumberArg(argv[i], 17, mSettings.exitCode)) return Result::Fail; } // Exception handling inside cppcheck client else if (std::strcmp(argv[i], "--exception-handling") == 0) { #if defined(USE_WINDOWS_SEH) || defined(USE_UNIX_SIGNAL_HANDLING) mSettings.exceptionHandling = true; #else mLogger.printError("Option --exception-handling is not supported since Cppcheck has not been built with any exception handling enabled."); return Result::Fail; #endif } // Exception handling inside cppcheck client else if (std::strncmp(argv[i], "--exception-handling=", 21) == 0) { #if defined(USE_WINDOWS_SEH) || defined(USE_UNIX_SIGNAL_HANDLING) const std::string exceptionOutfilename = argv[i] + 21; if (exceptionOutfilename != "stderr" && exceptionOutfilename != "stdout") { mLogger.printError("invalid '--exception-handling' argument"); return Result::Fail; } mSettings.exceptionHandling = true; mSettings.exceptionOutput = (exceptionOutfilename == "stderr") ? stderr : stdout; #else mLogger.printError("Option --exception-handling is not supported since Cppcheck has not been built with any exception handling enabled."); return Result::Fail; #endif } else if (std::strncmp(argv[i], "--executor=", 11) == 0) { const std::string type = 11 + argv[i]; if (type == "auto") { executorAuto = true; mSettings.executor = Settings::defaultExecutor(); } else if (type == "thread") { #if defined(HAS_THREADING_MODEL_THREAD) executorAuto = false; mSettings.executor = Settings::ExecutorType::Thread; #else mLogger.printError("executor type 'thread' cannot be used as Cppcheck has not been built with a respective threading model."); return Result::Fail; #endif } else if (type == "process") { #if defined(HAS_THREADING_MODEL_FORK) executorAuto = false; mSettings.executor = Settings::ExecutorType::Process; #else mLogger.printError("executor type 'process' cannot be used as Cppcheck has not been built with a respective threading model."); return Result::Fail; #endif } else { mLogger.printError("unknown executor: '" + type + "'."); return Result::Fail; } } // Filter errors else if (std::strncmp(argv[i], "--exitcode-suppressions=", 24) == 0) { // exitcode-suppressions=filename.txt std::string filename = 24 + argv[i]; std::ifstream f(filename); if (!f.is_open()) { mLogger.printError("couldn't open the file: \"" + filename + "\"."); return Result::Fail; } const std::string errmsg(mSuppressions.nofail.parseFile(f)); if (!errmsg.empty()) { mLogger.printError(errmsg); return Result::Fail; } } // use a file filter else if (std::strncmp(argv[i], "--file-filter=", 14) == 0) { const char *filter = argv[i] + 14; if (std::strcmp(filter, "-") == 0) { if (!addFilesToList(filter, mSettings.fileFilters)) { mLogger.printError("Failed: --file-filter=-"); return Result::Fail; } } else { mSettings.fileFilters.emplace_back(filter); } } // file list specified else if (std::strncmp(argv[i], "--file-list=", 12) == 0) { // open this file and read every input file (1 file name per line) const std::string fileList = argv[i] + 12; if (!addFilesToList(fileList, mPathNames)) { mLogger.printError("couldn't open the file: \"" + fileList + "\"."); return Result::Fail; } } // Force checking of files that have "too many" configurations else if (std::strcmp(argv[i], "-f") == 0 || std::strcmp(argv[i], "--force") == 0) mSettings.force = true; else if (std::strcmp(argv[i], "--fsigned-char") == 0) mSettings.platform.defaultSign = 's'; else if (std::strcmp(argv[i], "--funsigned-char") == 0) mSettings.platform.defaultSign = 'u'; // Ignored paths else if (std::strncmp(argv[i], "-i", 2) == 0) { std::string path; // "-i path/" if (std::strcmp(argv[i], "-i") == 0) { ++i; if (i >= argc || argv[i][0] == '-') { mLogger.printError("argument to '-i' is missing."); return Result::Fail; } path = argv[i]; } // "-ipath/" else { path = 2 + argv[i]; } if (!path.empty()) { path = Path::removeQuotationMarks(std::move(path)); path = Path::simplifyPath(std::move(path)); // TODO: this only works when it exists if (Path::isDirectory(path)) { // If directory name doesn't end with / or \, add it if (!endsWith(path, '/')) path += '/'; } mIgnoredPaths.emplace_back(std::move(path)); } } else if (std::strncmp(argv[i], "--include=", 10) == 0) { mSettings.userIncludes.emplace_back(Path::fromNativeSeparators(argv[i] + 10)); } else if (std::strncmp(argv[i], "--includes-file=", 16) == 0) { // open this file and read every input file (1 file name per line) const std::string includesFile(16 + argv[i]); if (!addIncludePathsToList(includesFile, mSettings.includePaths)) { mLogger.printError("unable to open includes file at '" + includesFile + "'"); return Result::Fail; } } // Inconclusive checking else if (std::strcmp(argv[i], "--inconclusive") == 0) mSettings.certainty.enable(Certainty::inconclusive); // Enables inline suppressions. else if (std::strcmp(argv[i], "--inline-suppr") == 0) mSettings.inlineSuppressions = true; // Checking threads else if (std::strncmp(argv[i], "-j", 2) == 0) { std::string numberString; // "-j 3" if (std::strcmp(argv[i], "-j") == 0) { ++i; if (i >= argc || argv[i][0] == '-') { mLogger.printError("argument to '-j' is missing."); return Result::Fail; } numberString = argv[i]; } // "-j3" else numberString = argv[i]+2; unsigned int tmp; std::string err; if (!strToInt(numberString, tmp, &err)) { mLogger.printError("argument to '-j' is not valid - " + err + "."); return Result::Fail; } if (tmp == 0) { // TODO: implement get CPU logical core count and use that. // Usually, -j 0 would mean "use all available cores," but // if we get a 0, we just stall and don't do any work. mLogger.printError("argument for '-j' must be greater than 0."); return Result::Fail; } if (tmp > 1024) { // Almost nobody has 1024 logical cores, but somebody out // there does. mLogger.printError("argument for '-j' is allowed to be 1024 at max."); return Result::Fail; } mSettings.jobs = tmp; } else if (std::strncmp(argv[i], "-l", 2) == 0) { #ifdef HAS_THREADING_MODEL_FORK std::string numberString; // "-l 3" if (std::strcmp(argv[i], "-l") == 0) { ++i; if (i >= argc || argv[i][0] == '-') { mLogger.printError("argument to '-l' is missing."); return Result::Fail; } numberString = argv[i]; } // "-l3" else numberString = argv[i]+2; int tmp; std::string err; if (!strToInt(numberString, tmp, &err)) { mLogger.printError("argument to '-l' is not valid - " + err + "."); return Result::Fail; } mSettings.loadAverage = tmp; #else mLogger.printError("Option -l cannot be used as Cppcheck has not been built with fork threading model."); return Result::Fail; #endif } // Enforce language (--language=, -x) else if (std::strncmp(argv[i], "--language=", 11) == 0 || std::strcmp(argv[i], "-x") == 0) { std::string str; if (argv[i][2]) { str = argv[i]+11; } else { i++; if (i >= argc || argv[i][0] == '-') { mLogger.printError("no language given to '-x' option."); return Result::Fail; } str = argv[i]; } if (str == "c") mSettings.enforcedLang = Standards::Language::C; else if (str == "c++") mSettings.enforcedLang = Standards::Language::CPP; else { mLogger.printError("unknown language '" + str + "' enforced."); return Result::Fail; } } // --library else if (std::strncmp(argv[i], "--library=", 10) == 0) { std::vector libs = splitString(argv[i] + 10, ','); for (auto& l : libs) { if (l.empty()) { mLogger.printError("empty library specified."); return Result::Fail; } mSettings.libraries.emplace_back(std::move(l)); } } // Set maximum number of #ifdef configurations to check else if (std::strncmp(argv[i], "--max-configs=", 14) == 0) { int tmp; if (!parseNumberArg(argv[i], 14, tmp)) return Result::Fail; if (tmp < 1) { mLogger.printError("argument to '--max-configs=' must be greater than 0."); return Result::Fail; } mSettings.maxConfigs = tmp; mSettings.force = false; maxconfigs = true; } // max ctu depth else if (std::strncmp(argv[i], "--max-ctu-depth=", 16) == 0) { int temp = 0; if (!parseNumberArg(argv[i], 16, temp)) return Result::Fail; if (temp > 10) { mLogger.printMessage("--max-ctu-depth is being capped at 10. This limitation will be removed in a future Cppcheck version."); temp = 10; } mSettings.maxCtuDepth = temp; } else if (std::strncmp(argv[i], "--max-template-recursion=", 25) == 0) { if (!parseNumberArg(argv[i], 25, mSettings.maxTemplateRecursion)) return Result::Fail; } // undocumented option for usage in Python tests to indicate that no build dir should be injected else if (std::strcmp(argv[i], "--no-cppcheck-build-dir") == 0) { mSettings.buildDir.clear(); } else if (std::strcmp(argv[i], "--no-cpp-header-probe") == 0) { mSettings.cppHeaderProbe = false; } // Write results in file else if (std::strncmp(argv[i], "--output-file=", 14) == 0) mSettings.outputFile = Path::simplifyPath(argv[i] + 14); else if (std::strncmp(argv[i], "--output-format=", 16) == 0) { const std::string format = argv[i] + 16; // plist can not be handled here because it requires additional data if (format == "text") mSettings.outputFormat = Settings::OutputFormat::text; else if (format == "sarif") mSettings.outputFormat = Settings::OutputFormat::sarif; else if (format == "xml") mSettings.outputFormat = Settings::OutputFormat::xml; else { mLogger.printError("argument to '--output-format=' must be 'text', 'sarif' or 'xml'."); return Result::Fail; } mSettings.plistOutput = ""; } // Experimental: limit execution time for extended valueflow analysis. basic valueflow analysis // is always executed. else if (std::strncmp(argv[i], "--performance-valueflow-max-time=", 33) == 0) { if (!parseNumberArg(argv[i], 33, mSettings.vfOptions.maxTime, true)) return Result::Fail; } else if (std::strncmp(argv[i], "--performance-valueflow-max-if-count=", 37) == 0) { if (!parseNumberArg(argv[i], 37, mSettings.vfOptions.maxIfCount, true)) return Result::Fail; } else if (std::strncmp(argv[i], "--performance-valueflow-max-iterations=", 39) == 0) { if (!parseNumberArg(argv[i], 39, mSettings.vfOptions.maxIterations, true)) return Result::Fail; } // Specify platform else if (std::strncmp(argv[i], "--platform=", 11) == 0) { const std::string platform(11+argv[i]); std::string errstr; const std::vector paths = {argv[0]}; if (!mSettings.platform.set(platform, errstr, paths, mSettings.debuglookup || mSettings.debuglookupPlatform)) { mLogger.printError(errstr); return Result::Fail; } // TODO: remove // these are loaded via external files and thus have Settings::PlatformFile set instead. // override the type so they behave like the regular platforms. if (platform == "unix32-unsigned") mSettings.platform.type = Platform::Type::Unix32; else if (platform == "unix64-unsigned") mSettings.platform.type = Platform::Type::Unix64; } // Write results in results.plist else if (std::strncmp(argv[i], "--plist-output=", 15) == 0) { std::string path = Path::simplifyPath(argv[i] + 15); if (path.empty()) path = "."; const std::string plistOutput = Path::toNativeSeparators(path); if (!Path::isDirectory(plistOutput)) { std::string message("plist folder does not exist: '"); message += plistOutput; message += "'."; mLogger.printError(message); return Result::Fail; } if (!endsWith(path,'/')) path += '/'; mSettings.outputFormat = Settings::OutputFormat::plist; mSettings.plistOutput = std::move(path); } // Special Cppcheck Premium options else if ((std::strncmp(argv[i], "--premium=", 10) == 0 || std::strncmp(argv[i], "--premium-", 10) == 0) && isCppcheckPremium()) { // valid options --premium=.. const std::set valid{ "autosar", "cert-c-2016", "cert-c++-2016", "cert-cpp-2016", "misra-c-2012", "misra-c-2023", "misra-c++-2008", "misra-cpp-2008", "misra-c++-2023", "misra-cpp-2023", "bughunting", "safety"}; // valid options --premium-..= const std::set valid2{ "cert-c-int-precision", "license-file" }; if (std::strcmp(argv[i], "--premium=safety-off") == 0) { mSettings.safety = false; continue; } if (std::strcmp(argv[i], "--premium=safety") == 0) mSettings.safety = true; if (!mSettings.premiumArgs.empty()) mSettings.premiumArgs += " "; const std::string p(argv[i] + 10); const std::string p2(p.find('=') != std::string::npos ? p.substr(0, p.find('=')) : ""); if (!valid.count(p) && !valid2.count(p2)) { mLogger.printError("invalid --premium option '" + (p2.empty() ? p : p2) + "'."); return Result::Fail; } mSettings.premiumArgs += "--" + p; if (p == "misra-c-2012" || p == "misra-c-2023") mSettings.addons.emplace("misra"); if (startsWith(p, "autosar") || startsWith(p, "cert") || startsWith(p, "misra")) { // All checkers related to the coding standard should be enabled. The coding standards // do not all undefined behavior or portability issues. mSettings.addEnabled("warning"); mSettings.addEnabled("portability"); } } // --project else if (std::strncmp(argv[i], "--project=", 10) == 0) { if (project.projectType != ImportProject::Type::NONE) { mLogger.printError("multiple --project options are not supported."); return Result::Fail; } mSettings.checkAllConfigurations = false; // Can be overridden with --max-configs or --force std::string projectFile = argv[i]+10; ImportProject::Type projType = project.import(projectFile, &mSettings, &mSuppressions); project.projectType = projType; if (projType == ImportProject::Type::CPPCHECK_GUI) { for (const std::string &lib : project.guiProject.libraries) mSettings.libraries.emplace_back(lib); const auto& excludedPaths = project.guiProject.excludedPaths; std::copy(excludedPaths.cbegin(), excludedPaths.cend(), std::back_inserter(mIgnoredPaths)); std::string platform(project.guiProject.platform); // keep existing platform from command-line intact if (!platform.empty()) { std::string errstr; const std::vector paths = {projectFile, argv[0]}; if (!mSettings.platform.set(platform, errstr, paths, mSettings.debuglookup || mSettings.debuglookupPlatform)) { mLogger.printError(errstr); return Result::Fail; } } const auto& projectFileGui = project.guiProject.projectFile; if (!projectFileGui.empty()) { // read underlying project projectFile = projectFileGui; projType = project.import(projectFileGui, &mSettings, &mSuppressions); if (projType == ImportProject::Type::CPPCHECK_GUI) { mLogger.printError("nested Cppcheck GUI projects are not supported."); return Result::Fail; } } } if (projType == ImportProject::Type::VS_SLN || projType == ImportProject::Type::VS_VCXPROJ) { if (project.guiProject.analyzeAllVsConfigs == "false") project.selectOneVsConfig(mSettings.platform.type); mSettings.libraries.emplace_back("windows"); } if (projType == ImportProject::Type::MISSING) { mLogger.printError("failed to open project '" + projectFile + "'. The file does not exist."); return Result::Fail; } if (projType == ImportProject::Type::UNKNOWN) { mLogger.printError("failed to load project '" + projectFile + "'. The format is unknown."); return Result::Fail; } if (projType == ImportProject::Type::FAILURE) { mLogger.printError("failed to load project '" + projectFile + "'. An error occurred."); return Result::Fail; } } // --project-configuration else if (std::strncmp(argv[i], "--project-configuration=", 24) == 0) { mVSConfig = argv[i] + 24; // TODO: provide error when this does nothing if (!mVSConfig.empty() && (project.projectType == ImportProject::Type::VS_SLN || project.projectType == ImportProject::Type::VS_VCXPROJ)) project.ignoreOtherConfigs(mVSConfig); } // Only print something when there are errors else if (std::strcmp(argv[i], "-q") == 0 || std::strcmp(argv[i], "--quiet") == 0) mSettings.quiet = true; // Output relative paths else if (std::strcmp(argv[i], "-rp") == 0 || std::strcmp(argv[i], "--relative-paths") == 0) mSettings.relativePaths = true; else if (std::strncmp(argv[i], "-rp=", 4) == 0 || std::strncmp(argv[i], "--relative-paths=", 17) == 0) { mSettings.relativePaths = true; if (argv[i][argv[i][3]=='='?4:17] != 0) { std::string paths = argv[i]+(argv[i][3]=='='?4:17); for (;;) { const std::string::size_type pos = paths.find(';'); if (pos == std::string::npos) { mSettings.basePaths.emplace_back(Path::fromNativeSeparators(paths)); break; } mSettings.basePaths.emplace_back(Path::fromNativeSeparators(paths.substr(0, pos))); paths.erase(0, pos + 1); } } else { mLogger.printError("no paths specified for the '" + std::string(argv[i]) + "' option."); return Result::Fail; } } // Report progress else if (std::strcmp(argv[i], "--report-progress") == 0) { mSettings.reportProgress = 10; } else if (std::strncmp(argv[i], "--report-progress=", 18) == 0) { if (!parseNumberArg(argv[i], 18, mSettings.reportProgress, true)) return Result::Fail; } else if (std::strncmp(argv[i], "--report-type=", 14) == 0) { const std::string typeStr = argv[i] + 14; if (typeStr == "normal") { mSettings.reportType = ReportType::normal; } else if (typeStr == "autosar") { mSettings.reportType = ReportType::autosar; } else if (typeStr == "cert-c-2016") { mSettings.reportType = ReportType::certC; } else if (typeStr == "cert-cpp-2016") { mSettings.reportType = ReportType::certCpp; } else if (typeStr == "misra-c-2012" || typeStr == "misra-c-2023") { mSettings.reportType = ReportType::misraC; } else if (typeStr == "misra-cpp-2008") { mSettings.reportType = ReportType::misraCpp2008; } else if (typeStr == "misra-cpp-2023") { mSettings.reportType = ReportType::misraCpp2023; } else { mLogger.printError("Unknown report type \'" + typeStr + "\'"); return Result::Fail; } } // Rule given at command line else if (std::strncmp(argv[i], "--rule=", 7) == 0) { #ifdef HAVE_RULES Settings::Rule rule; rule.pattern = 7 + argv[i]; if (rule.pattern.empty()) { mLogger.printError("no rule pattern provided."); return Result::Fail; } mSettings.rules.emplace_back(std::move(rule)); #else mLogger.printError("Option --rule cannot be used as Cppcheck has not been built with rules support."); return Result::Fail; #endif } // Rule file else if (std::strncmp(argv[i], "--rule-file=", 12) == 0) { #ifdef HAVE_RULES // TODO: improved error handling - wrong root node, etc. // TODO: consume unused "version" attribute const std::string ruleFile = argv[i] + 12; tinyxml2::XMLDocument doc; const tinyxml2::XMLError err = doc.LoadFile(ruleFile.c_str()); if (err == tinyxml2::XML_SUCCESS) { const tinyxml2::XMLElement *node = doc.FirstChildElement(); // check if it is a single or multi rule configuration if (node && strcmp(node->Value(), "rules") == 0) node = node->FirstChildElement("rule"); for (; node && strcmp(node->Value(), "rule") == 0; node = node->NextSiblingElement()) { Settings::Rule rule; for (const tinyxml2::XMLElement *subnode = node->FirstChildElement(); subnode; subnode = subnode->NextSiblingElement()) { const char * const subname = subnode->Name(); const char * const subtext = subnode->GetText(); if (std::strcmp(subname, "tokenlist") == 0) { rule.tokenlist = empty_if_null(subtext); } else if (std::strcmp(subname, "pattern") == 0) { rule.pattern = empty_if_null(subtext); } else if (std::strcmp(subname, "message") == 0) { for (const tinyxml2::XMLElement *msgnode = subnode->FirstChildElement(); msgnode; msgnode = msgnode->NextSiblingElement()) { const char * const msgname = msgnode->Name(); const char * const msgtext = msgnode->GetText(); if (std::strcmp(msgname, "severity") == 0) { rule.severity = severityFromString(empty_if_null(msgtext)); } else if (std::strcmp(msgname, "id") == 0) { rule.id = empty_if_null(msgtext); } else if (std::strcmp(msgname, "summary") == 0) { rule.summary = empty_if_null(msgtext); } else { mLogger.printError("unable to load rule-file '" + ruleFile + "' - unknown element '" + msgname + "' encountered in 'message'."); return Result::Fail; } } } else { mLogger.printError("unable to load rule-file '" + ruleFile + "' - unknown element '" + subname + "' encountered in 'rule'."); return Result::Fail; } } if (rule.pattern.empty()) { mLogger.printError("unable to load rule-file '" + ruleFile + "' - a rule is lacking a pattern."); return Result::Fail; } if (rule.id.empty()) { mLogger.printError("unable to load rule-file '" + ruleFile + "' - a rule is lacking an id."); return Result::Fail; } if (rule.tokenlist.empty()) { mLogger.printError("unable to load rule-file '" + ruleFile + "' - a rule is lacking a tokenlist."); return Result::Fail; } if (rule.tokenlist != "normal" && rule.tokenlist != "define" && rule.tokenlist != "raw") { mLogger.printError("unable to load rule-file '" + ruleFile + "' - a rule is using the unsupported tokenlist '" + rule.tokenlist + "'."); return Result::Fail; } if (rule.severity == Severity::none) { mLogger.printError("unable to load rule-file '" + ruleFile + "' - a rule has an invalid severity."); return Result::Fail; } mSettings.rules.emplace_back(std::move(rule)); } } else { mLogger.printError("unable to load rule-file '" + ruleFile + "' (" + tinyxml2::XMLDocument::ErrorIDToName(err) + ")."); return Result::Fail; } #else mLogger.printError("Option --rule-file cannot be used as Cppcheck has not been built with rules support."); return Result::Fail; #endif } // Safety certified behavior else if (std::strcmp(argv[i], "--safety") == 0) mSettings.safety = true; // show timing information.. else if (std::strncmp(argv[i], "--showtime=", 11) == 0) { const std::string showtimeMode = argv[i] + 11; if (showtimeMode == "file") mSettings.showtime = SHOWTIME_MODES::SHOWTIME_FILE; else if (showtimeMode == "file-total") mSettings.showtime = SHOWTIME_MODES::SHOWTIME_FILE_TOTAL; else if (showtimeMode == "summary") mSettings.showtime = SHOWTIME_MODES::SHOWTIME_SUMMARY; else if (showtimeMode == "top5") { mSettings.showtime = SHOWTIME_MODES::SHOWTIME_TOP5_FILE; mLogger.printMessage("--showtime=top5 is deprecated and will be removed in Cppcheck 2.14. Please use --showtime=top5_file or --showtime=top5_summary instead."); } else if (showtimeMode == "top5_file") mSettings.showtime = SHOWTIME_MODES::SHOWTIME_TOP5_FILE; else if (showtimeMode == "top5_summary") mSettings.showtime = SHOWTIME_MODES::SHOWTIME_TOP5_SUMMARY; else if (showtimeMode == "none") mSettings.showtime = SHOWTIME_MODES::SHOWTIME_NONE; else if (showtimeMode.empty()) { mLogger.printError("no mode provided for --showtime"); return Result::Fail; } else { mLogger.printError("unrecognized --showtime mode: '" + showtimeMode + "'. Supported modes: file, file-total, summary, top5, top5_file, top5_summary."); return Result::Fail; } } // --std else if (std::strncmp(argv[i], "--std=", 6) == 0) { const std::string std = argv[i] + 6; if (!mSettings.standards.setStd(std)) { mLogger.printError("unknown --std value '" + std + "'"); return Result::Fail; } } else if (std::strncmp(argv[i], "--suppress=", 11) == 0) { const std::string suppression = argv[i]+11; const std::string errmsg(mSuppressions.nomsg.addSuppressionLine(suppression)); if (!errmsg.empty()) { mLogger.printError(errmsg); return Result::Fail; } } // Filter errors else if (std::strncmp(argv[i], "--suppressions-list=", 20) == 0) { std::string filename = argv[i]+20; std::ifstream f(filename); if (!f.is_open()) { std::string message("couldn't open the file: \""); message += filename; message += "\"."; if (std::count(filename.cbegin(), filename.cend(), ',') > 0 || std::count(filename.cbegin(), filename.cend(), '.') > 1) { // If user tried to pass multiple files (we can only guess that) // e.g. like this: --suppressions-list=a.txt,b.txt // print more detailed error message to tell user how he can solve the problem message += "\nIf you want to pass two files, you can do it e.g. like this:"; message += "\n cppcheck --suppressions-list=a.txt --suppressions-list=b.txt file.cpp"; } mLogger.printError(message); return Result::Fail; } const std::string errmsg(mSuppressions.nomsg.parseFile(f)); if (!errmsg.empty()) { mLogger.printError(errmsg); return Result::Fail; } } else if (std::strncmp(argv[i], "--suppress-xml=", 15) == 0) { const char * filename = argv[i] + 15; const std::string errmsg(mSuppressions.nomsg.parseXmlFile(filename)); if (!errmsg.empty()) { mLogger.printError(errmsg); return Result::Fail; } } // Output formatter else if (std::strncmp(argv[i], "--template=", 11) == 0) { mSettings.templateFormat = argv[i] + 11; // TODO: bail out when no template is provided? if (mSettings.templateFormat == "gcc") { mSettings.templateFormat = "{bold}{file}:{line}:{column}: {magenta}warning:{default} {message} [{id}]{reset}\\n{code}"; mSettings.templateLocation = "{bold}{file}:{line}:{column}: {dim}note:{reset} {info}\\n{code}"; } else if (mSettings.templateFormat == "daca2") { mSettings.daca = true; mSettings.templateFormat = "{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]"; mSettings.templateLocation = "{file}:{line}:{column}: note: {info}"; } else if (mSettings.templateFormat == "vs") mSettings.templateFormat = "{file}({line}): {severity}: {message}"; else if (mSettings.templateFormat == "edit") mSettings.templateFormat = "{file} +{line}: {severity}: {message}"; else if (mSettings.templateFormat == "cppcheck1") mSettings.templateFormat = "{callstack}: ({severity}{inconclusive:, inconclusive}) {message}"; else if (mSettings.templateFormat == "selfcheck") { mSettings.templateFormat = "{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}"; mSettings.templateLocation = "{file}:{line}:{column}: note: {info}\\n{code}"; mSettings.daca = true; } else if (mSettings.templateFormat == "simple") { mSettings.templateFormat = "{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]"; mSettings.templateLocation = ""; } // TODO: bail out when no placeholders are found? } else if (std::strncmp(argv[i], "--template-location=", 20) == 0) { mSettings.templateLocation = argv[i] + 20; // TODO: bail out when no template is provided? // TODO: bail out when no placeholders are found? } else if (std::strncmp(argv[i], "--template-max-time=", 20) == 0) { if (!parseNumberArg(argv[i], 20, mSettings.templateMaxTime)) return Result::Fail; } else if (std::strncmp(argv[i], "--typedef-max-time=", 19) == 0) { if (!parseNumberArg(argv[i], 19, mSettings.typedefMaxTime)) return Result::Fail; } else if (std::strncmp(argv[i], "--valueflow-max-iterations=", 27) == 0) { if (!parseNumberArg(argv[i], 27, mSettings.vfOptions.maxIterations)) return Result::Fail; } else if (std::strcmp(argv[i], "-v") == 0 || std::strcmp(argv[i], "--verbose") == 0) mSettings.verbose = true; // Write results in results.xml else if (std::strcmp(argv[i], "--xml") == 0) { mSettings.outputFormat = Settings::OutputFormat::xml; } // Define the XML file version (and enable XML output) else if (std::strncmp(argv[i], "--xml-version=", 14) == 0) { int tmp; if (!parseNumberArg(argv[i], 14, tmp)) return Result::Fail; if (tmp != 2 && tmp != 3) { // We only have xml version 2 and 3 mLogger.printError("'--xml-version' can only be 2 or 3."); return Result::Fail; } mSettings.xml_version = tmp; // Enable also XML if version is set mSettings.outputFormat = Settings::OutputFormat::xml; } else { std::string message("unrecognized command line option: \""); message += argv[i]; message += "\"."; mLogger.printError(message); return Result::Fail; } } else { mPathNames.emplace_back(Path::fromNativeSeparators(Path::removeQuotationMarks(argv[i]))); } } if (!loadCppcheckCfg()) return Result::Fail; // TODO: bail out? if (!executorAuto && mSettings.useSingleJob()) mLogger.printMessage("'--executor' has no effect as only a single job will be used."); // Default template format.. if (mSettings.templateFormat.empty()) { mSettings.templateFormat = "{bold}{file}:{line}:{column}: {red}{inconclusive:{magenta}}{severity}:{inconclusive: inconclusive:}{default} {message} [{id}]{reset}\\n{code}"; if (mSettings.templateLocation.empty()) mSettings.templateLocation = "{bold}{file}:{line}:{column}: {dim}note:{reset} {info}\\n{code}"; } // replace static parts of the templates substituteTemplateFormatStatic(mSettings.templateFormat); substituteTemplateLocationStatic(mSettings.templateLocation); if (mSettings.force || maxconfigs) mSettings.checkAllConfigurations = true; if (mSettings.force) mSettings.maxConfigs = INT_MAX; else if ((def || mSettings.preprocessOnly) && !maxconfigs) mSettings.maxConfigs = 1U; if (mSettings.jobs > 1 && mSettings.buildDir.empty()) { // TODO: bail out instead? if (mSettings.checks.isEnabled(Checks::unusedFunction)) mLogger.printMessage("unusedFunction check requires --cppcheck-build-dir to be active with -j."); // TODO: enable //mLogger.printMessage("whole program analysis requires --cppcheck-build-dir to be active with -j."); } if (!mPathNames.empty() && project.projectType != ImportProject::Type::NONE) { mLogger.printError("--project cannot be used in conjunction with source files."); return Result::Fail; } if (!mSettings.buildDir.empty() && !Path::isDirectory(mSettings.buildDir)) { mLogger.printError("Directory '" + mSettings.buildDir + "' specified by --cppcheck-build-dir argument has to be existent."); return Result::Fail; } // Print error only if we have "real" command and expect files if (mPathNames.empty() && project.guiProject.pathNames.empty() && project.fileSettings.empty()) { // TODO: this message differs from the one reported in fillSettingsFromArgs() mLogger.printError("no C or C++ source files found."); return Result::Fail; } if (!project.guiProject.pathNames.empty()) mPathNames = project.guiProject.pathNames; if (!project.fileSettings.empty()) { project.ignorePaths(mIgnoredPaths); if (project.fileSettings.empty()) { mLogger.printError("no C or C++ source files found."); mLogger.printMessage("all paths were ignored"); // TODO: log this differently? return Result::Fail; } mFileSettings = project.fileSettings; } if (mSettings.debugnormal && mSettings.outputFormat == Settings::OutputFormat::xml && (mPathNames.size() > 1 || mFileSettings.size() > 1)) { mLogger.printError("printing debug output in XML format does not support multiple input files."); return Result::Fail; } // Use paths _pathnames if no base paths for relative path output are given if (mSettings.basePaths.empty() && mSettings.relativePaths) mSettings.basePaths = mPathNames; return Result::Success; } void CmdLineParser::printHelp() const { const std::string manualUrl(isCppcheckPremium() ? "https://cppcheck.sourceforge.io/manual.pdf" : "https://files.cppchecksolutions.com/manual.pdf"); std::ostringstream oss; oss << "Cppcheck - A tool for static C/C++ code analysis\n" "\n" "Syntax:\n" " cppcheck [OPTIONS] [files or paths]\n" "\n" "If a directory is given instead of a filename, *.cpp, *.cxx, *.cc, *.c++, *.c, *.ipp,\n" "*.ixx, *.tpp, and *.txx files are checked recursively from the given directory.\n\n" "Options:\n" " --addon=\n" " Execute addon. i.e. --addon=misra. If options must be\n" " provided a json configuration is needed.\n" " --addon-python=\n" " You can specify the python interpreter either in the\n" " addon json files or through this command line option.\n" " If not present, Cppcheck will try \"python3\" first and\n" " then \"python\".\n" " --cppcheck-build-dir=\n" " Cppcheck work folder. Advantages:\n" " * whole program analysis\n" " * faster analysis; Cppcheck will reuse the results if\n" " the hash for a file is unchanged.\n" " * some useful debug information, i.e. commands used to\n" " execute clang/clang-tidy/addons.\n" " --check-config Check cppcheck configuration. The normal code\n" " analysis is disabled by this flag.\n" " --check-level=\n" " Configure how much valueflow analysis you want:\n" " * reduced: Reduce valueflow to finish checking quickly.\n" " * normal: Cppcheck uses some compromises in the analysis so\n" " the checking will finish in reasonable time.\n" " * exhaustive: deeper analysis that you choose when you can\n" " wait.\n" " The default choice is 'normal'.\n" " --check-library Show information messages when library files have\n" " incomplete info.\n" " --checkers-report=\n" " Write a report of all the active checkers to the given file.\n" " --clang= Experimental: Use Clang parser instead of the builtin Cppcheck\n" " parser. Takes the executable as optional parameter and\n" " defaults to `clang`. Cppcheck will run the given Clang\n" " executable, import the Clang AST and convert it into\n" " Cppcheck data. After that the normal Cppcheck analysis is\n" " used. You must have the executable in PATH if no path is\n" " given.\n" " --config-exclude=\n" " Path (prefix) to be excluded from configuration\n" " checking. Preprocessor configurations defined in\n" " headers (but not sources) matching the prefix will not\n" " be considered for evaluation.\n" " --config-excludes-file=\n" " A file that contains a list of config-excludes\n" " --disable= Disable individual checks.\n" " Please refer to the documentation of --enable=\n" " for further details.\n" " --dump Dump xml data for each translation unit. The dump\n" " files have the extension .dump and contain ast,\n" " tokenlist, symboldatabase, valueflow.\n" " -D Define preprocessor symbol. Unless --max-configs or\n" " --force is used, Cppcheck will only check the given\n" " configuration when -D is used.\n" " Example: '-DDEBUG=1 -D__cplusplus'.\n" " -E Print preprocessor output on stdout and don't do any\n" " further processing.\n" " --enable= Enable additional checks. The available ids are:\n" " * all\n" " Enable all checks. It is recommended to only\n" " use --enable=all when the whole program is\n" " scanned, because this enables unusedFunction.\n" " * warning\n" " Enable warning messages\n" " * style\n" " Enable all coding style checks. All messages\n" " with the severities 'style', 'warning',\n" " 'performance' and 'portability' are enabled.\n" " * performance\n" " Enable performance messages\n" " * portability\n" " Enable portability messages\n" " * information\n" " Enable information messages\n" " * unusedFunction\n" " Check for unused functions. It is recommended\n" " to only enable this when the whole program is\n" " scanned.\n" " * missingInclude\n" " Warn if there are missing includes.\n" " Several ids can be given if you separate them with\n" " commas. See also --std\n" " --error-exitcode= If errors are found, integer [n] is returned instead of\n" " the default '0'. '" << EXIT_FAILURE << "' is returned\n" " if arguments are not valid or if no input files are\n" " provided. Note that your operating system can modify\n" " this value, e.g. '256' can become '0'.\n" " --errorlist Print a list of all the error messages in XML format.\n" " --exitcode-suppressions=\n" " Used when certain messages should be displayed but\n" " should not cause a non-zero exitcode.\n" " --file-filter= Analyze only those files matching the given filter str\n" " Can be used multiple times\n" " Example: --file-filter=*bar.cpp analyzes only files\n" " that end with bar.cpp.\n" " --file-list= Specify the files to check in a text file. Add one\n" " filename per line. When file is '-,' the file list will\n" " be read from standard input.\n" " -f, --force Force checking of all configurations in files. If used\n" " together with '--max-configs=', the last option is the\n" " one that is effective.\n" " --fsigned-char Treat char type as signed.\n" " --funsigned-char Treat char type as unsigned.\n" " -h, --help Print this help.\n" " -I Give path to search for include files. Give several -I\n" " parameters to give several paths. First given path is\n" " searched for contained header files first. If paths are\n" " relative to source files, this is not needed.\n" " --includes-file=\n" " Specify directory paths to search for included header\n" " files in a text file. Add one include path per line.\n" " First given path is searched for contained header\n" " files first. If paths are relative to source files,\n" " this is not needed.\n" " --include=\n" " Force inclusion of a file before the checked file.\n" " -i Give a source file or source file directory to exclude\n" " from the check. This applies only to source files so\n" " header files included by source files are not matched.\n" " Directory name is matched to all parts of the path.\n" " --inconclusive Allow that Cppcheck reports even though the analysis is\n" " inconclusive.\n" " There are false positives with this option. Each result\n" " must be carefully investigated before you know if it is\n" " good or bad.\n" " --inline-suppr Enable inline suppressions. Use them by placing one or\n" " more comments, like: '// cppcheck-suppress warningId'\n" " on the lines before the warning to suppress.\n" " -j Start threads to do the checking simultaneously.\n" " -l Specifies that no new threads should be started if\n" " there are other threads running and the load average is\n" " at least .\n" " --language=, -x \n" " Forces cppcheck to check all files as the given\n" " language. Valid values are: c, c++\n" " --library= Load file that contains information about types\n" " and functions. With such information Cppcheck\n" " understands your code better and therefore you\n" " get better results. The std.cfg file that is\n" " distributed with Cppcheck is loaded automatically.\n" " For more information about library files, read the\n" " manual.\n" " --max-configs=\n" " Maximum number of configurations to check in a file\n" " before skipping it. Default is '12'. If used together\n" " with '--force', the last option is the one that is\n" " effective.\n" " --max-ctu-depth=N Max depth in whole program analysis. The default value\n" " is 2. A larger value will mean more errors can be found\n" " but also means the analysis will be slower.\n" " --output-file= Write results to file, rather than standard error.\n" " --output-format=\n" " Specify the output format. The available formats are:\n" " * text\n" " * sarif\n" " * xml\n" " --platform=, --platform=\n" " Specifies platform specific types and sizes. The\n" " available builtin platforms are:\n" " * unix32\n" " 32 bit unix variant\n" " * unix64\n" " 64 bit unix variant\n" " * win32A\n" " 32 bit Windows ASCII character encoding\n" " * win32W\n" " 32 bit Windows UNICODE character encoding\n" " * win64\n" " 64 bit Windows\n" " * avr8\n" " 8 bit AVR microcontrollers\n" " * elbrus-e1cp\n" " Elbrus e1c+ architecture\n" " * pic8\n" " 8 bit PIC microcontrollers\n" " Baseline and mid-range architectures\n" " * pic8-enhanced\n" " 8 bit PIC microcontrollers\n" " Enhanced mid-range and high end (PIC18) architectures\n" " * pic16\n" " 16 bit PIC microcontrollers\n" " * mips32\n" " 32 bit MIPS microcontrollers\n" " * native\n" " Type sizes of host system are assumed, but no\n" " further assumptions.\n" " * unspecified\n" " Unknown type sizes\n" " --plist-output=\n" " Generate Clang-plist output files in folder.\n"; if (isCppcheckPremium()) { oss << " --premium=