diff --git a/.github/workflows/CI-cygwin.yml b/.github/workflows/CI-cygwin.yml
index bf67967c5f8..6b0ad2cc5bd 100644
--- a/.github/workflows/CI-cygwin.yml
+++ b/.github/workflows/CI-cygwin.yml
@@ -37,7 +37,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
diff --git a/.github/workflows/CI-mingw.yml b/.github/workflows/CI-mingw.yml
index 1b0cf3e5672..f308cfa5110 100644
--- a/.github/workflows/CI-mingw.yml
+++ b/.github/workflows/CI-mingw.yml
@@ -33,7 +33,7 @@ jobs:
timeout-minutes: 19 # max + 3*std of the last 7K runs
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
diff --git a/.github/workflows/CI-unixish-docker.yml b/.github/workflows/CI-unixish-docker.yml
index 16c1615ed04..adf4a74c81b 100644
--- a/.github/workflows/CI-unixish-docker.yml
+++ b/.github/workflows/CI-unixish-docker.yml
@@ -43,7 +43,7 @@ jobs:
image: ${{ matrix.image }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -96,7 +96,7 @@ jobs:
image: ${{ matrix.image }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
diff --git a/.github/workflows/CI-unixish.yml b/.github/workflows/CI-unixish.yml
index 8fb5c8d76d6..9bac980c853 100644
--- a/.github/workflows/CI-unixish.yml
+++ b/.github/workflows/CI-unixish.yml
@@ -30,7 +30,7 @@ jobs:
CCACHE_SLOPPINESS: pch_defines,time_macros
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -85,7 +85,7 @@ jobs:
CCACHE_SLOPPINESS: pch_defines,time_macros
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -97,7 +97,7 @@ jobs:
# 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
+ uses: egor-tensin/setup-gcc@v2
if: false # matrix.os == 'ubuntu-22.04'
with:
version: 13
@@ -216,7 +216,7 @@ jobs:
CCACHE_SLOPPINESS: pch_defines,time_macros
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -265,7 +265,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -299,7 +299,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -333,7 +333,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -361,7 +361,7 @@ jobs:
CCACHE_SLOPPINESS: pch_defines,time_macros
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -417,7 +417,7 @@ jobs:
CMAKE_VERSION_FULL: 3.22.6
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -461,7 +461,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -712,7 +712,7 @@ jobs:
runs-on: ubuntu-22.04 # run on the latest image only
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
diff --git a/.github/workflows/CI-windows.yml b/.github/workflows/CI-windows.yml
index a63be4e0ad9..66858c7afbe 100644
--- a/.github/workflows/CI-windows.yml
+++ b/.github/workflows/CI-windows.yml
@@ -31,7 +31,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -82,7 +82,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -108,7 +108,7 @@ jobs:
CMAKE_VERSION_FULL: 3.22.6
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -154,13 +154,13 @@ jobs:
PCRE_VERSION: 8.45
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
- name: Set up Python
if: matrix.config == 'release'
- uses: actions/setup-python@v5
+ uses: actions/setup-python@v6
with:
python-version: '3.14'
check-latest: true
@@ -172,7 +172,7 @@ jobs:
- name: Cache PCRE
id: cache-pcre
- uses: actions/cache@v4
+ uses: actions/cache@v5
with:
path: |
externals\pcre.h
diff --git a/.github/workflows/buildman.yml b/.github/workflows/buildman.yml
index b0b399dd851..e84cf4bffd9 100644
--- a/.github/workflows/buildman.yml
+++ b/.github/workflows/buildman.yml
@@ -19,7 +19,7 @@ jobs:
convert_via_pandoc:
runs-on: ubuntu-24.04
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -38,7 +38,7 @@ jobs:
with:
args: --output=output/manual-premium.pdf man/manual-premium.md
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: output
path: output
@@ -46,7 +46,7 @@ jobs:
manpage:
runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -59,7 +59,7 @@ jobs:
run: |
make man
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: cppcheck.1
path: cppcheck.1
diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml
index c54d47da4f1..400fb929786 100644
--- a/.github/workflows/cifuzz.yml
+++ b/.github/workflows/cifuzz.yml
@@ -27,7 +27,7 @@ jobs:
dry-run: false
language: c++
- name: Upload Crash
- uses: actions/upload-artifact@v4
+ uses: actions/upload-artifact@v7
if: failure() && steps.build.outcome == 'success'
with:
name: artifacts
diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml
index 7a5b317693a..4f2db4ab113 100644
--- a/.github/workflows/clang-tidy.yml
+++ b/.github/workflows/clang-tidy.yml
@@ -27,7 +27,7 @@ jobs:
QT_VERSION: 6.10.0
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -86,7 +86,7 @@ jobs:
run: |
cmake --build cmake.output --target run-clang-tidy-csa 2> /dev/null
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
if: success() || failure()
with:
name: Compilation Database
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index 12e758d2c9e..84d37423d2e 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -33,13 +33,13 @@ jobs:
steps:
- name: Checkout repository
- uses: actions/checkout@v4
+ uses: actions/checkout@v6
with:
persist-credentials: false
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
- uses: github/codeql-action/init@v3
+ uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
@@ -49,4 +49,4 @@ jobs:
make -j$(nproc) CXXOPTS="-Werror" HAVE_RULES=yes CPPCHK_GLIBCXX_DEBUG= cppcheck
- name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v3
+ uses: github/codeql-action/analyze@v4
diff --git a/.github/workflows/corpus.yml b/.github/workflows/corpus.yml
index 0c1aeda94de..2d9f1424fad 100644
--- a/.github/workflows/corpus.yml
+++ b/.github/workflows/corpus.yml
@@ -16,7 +16,7 @@ jobs:
if: ${{ github.repository_owner == 'cppcheck-opensource' }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -51,7 +51,7 @@ jobs:
# print largest size
ls -l ./store | cut -d' ' -f5 | sort -u -n -r | head -n1
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
if: success()
with:
name: corpus
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 13f56172a80..b5e496adcf6 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -57,12 +57,12 @@ jobs:
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
+ - uses: actions/upload-artifact@v7
with:
name: Coverage results
path: coverage_report
- - uses: codecov/codecov-action@v4
+ - uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
# file: ./coverage.xml # optional
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml
index 006160c7779..4c62971e4c4 100644
--- a/.github/workflows/coverity.yml
+++ b/.github/workflows/coverity.yml
@@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'cppcheck-opensource' }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
- name: Install missing software on ubuntu
diff --git a/.github/workflows/cppcheck-premium.yml b/.github/workflows/cppcheck-premium.yml
index ed0f2a1bcd5..b99cccd69da 100644
--- a/.github/workflows/cppcheck-premium.yml
+++ b/.github/workflows/cppcheck-premium.yml
@@ -25,7 +25,7 @@ jobs:
build:
runs-on: ubuntu-24.04 # run on the latest image only
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -60,13 +60,13 @@ jobs:
#sed -i 's|"security-severity":.*||' results.sarif
cat results.sarif
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: results
path: results.sarif
- name: Upload report
- uses: github/codeql-action/upload-sarif@v3
+ uses: github/codeql-action/upload-sarif@v4
with:
sarif_file: results.sarif
category: cppcheckpremium
diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml
index fd491c0ec0e..4ec72f935fd 100644
--- a/.github/workflows/format.yml
+++ b/.github/workflows/format.yml
@@ -24,12 +24,12 @@ jobs:
UNCRUSTIFY_VERSION: 0.80.1
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
- name: Cache uncrustify
- uses: actions/cache@v4
+ uses: actions/cache@v5
id: cache-uncrustify
with:
path: |
diff --git a/.github/workflows/gcc-versions.yml b/.github/workflows/gcc-versions.yml
new file mode 100644
index 00000000000..3402bade743
--- /dev/null
+++ b/.github/workflows/gcc-versions.yml
@@ -0,0 +1,39 @@
+# the purpose of this github action is to test that cppcheck source code can be compiled using old gcc versions.
+# the gcc images we use here are copied from the official gcc images on docker hub
+
+name: gcc-versions
+
+on:
+ push:
+ branches:
+ - 'main'
+ - 'releases/**'
+ - '2.*'
+ tags:
+ - '2.*'
+ pull_request:
+
+permissions:
+ contents: read
+
+jobs:
+ build:
+
+ strategy:
+ matrix:
+ #image: ["ghcr.io/cppcheck-opensource/gcc:5.4", "ghcr.io/cppcheck-opensource/gcc:6.5", "ghcr.io/cppcheck-opensource/gcc:7.5", "ghcr.io/cppcheck-opensource/gcc:8.5", "ghcr.io/cppcheck-opensource/gcc:9.5"]
+ image: ["ghcr.io/cppcheck-opensource/gcc:5.4"]
+ fail-fast: false
+
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ persist-credentials: false
+
+ - name: Build cppcheck
+ run: |
+ # FIXME: simplecpp-1.8.0 can't be compiled with gcc 5.4, so we can't run 'make test' now
+ #docker run --rm -v ${{ github.workspace }}:/cppcheck -w /cppcheck ${{ matrix.image }} make -j$(nproc) CXXOPTS="-Werror" test
+ docker run --rm -v ${{ github.workspace }}:/cppcheck -w /cppcheck ${{ matrix.image }} g++ -fsyntax-only -Iexternals -Iexternals/picojson -Iexternals/simplecpp -Iexternals/tinyxml2 -std=c++11 -Wno-multichar lib/*.cpp
diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml
index de047b8d10a..2e54b92541e 100644
--- a/.github/workflows/iwyu.yml
+++ b/.github/workflows/iwyu.yml
@@ -39,7 +39,7 @@ jobs:
QT_VERSION: 6.10.0
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -160,13 +160,13 @@ jobs:
IWYU: include-what-you-use
IWYU_CLANG_INC: ${{ matrix.clang_inc }}
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
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
+ - uses: actions/upload-artifact@v7
if: ${{ contains(matrix.os, 'macos') && (success() || failure()) }}
with:
name: macOS Mappings
@@ -174,7 +174,7 @@ jobs:
./iwyu-mapgen-apple-libc.py
./macos.imp
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
if: success() || failure()
with:
name: Logs (include-what-you-use - ${{ matrix.os }} ${{ matrix.stdlib }})
@@ -199,7 +199,7 @@ jobs:
QT_VERSION: 6.10.0
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -256,13 +256,13 @@ jobs:
# TODO: run multi-threaded
find $PWD/cli $PWD/lib $PWD/test $PWD/gui -maxdepth 1 -name "*.cpp" | xargs -t -n 1 clang-include-cleaner-22 --print=changes --extra-arg=-w --extra-arg=-stdlib=${{ matrix.stdlib }} -p cmake.output > clang-include-cleaner.log 2>&1
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
if: success() || failure()
with:
name: Compilation Database (clang-include-cleaner - ${{ matrix.stdlib }})
path: ./cmake.output/compile_commands.json
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
if: success() || failure()
with:
name: Logs (clang-include-cleaner - ${{ matrix.stdlib }})
diff --git a/.github/workflows/release-windows-mingw.yml b/.github/workflows/release-windows-mingw.yml
index 3b9b836347f..8085990e39d 100644
--- a/.github/workflows/release-windows-mingw.yml
+++ b/.github/workflows/release-windows-mingw.yml
@@ -33,7 +33,7 @@ jobs:
timeout-minutes: 19 # max + 3*std of the last 7K runs
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -63,7 +63,7 @@ jobs:
cp /mingw64/bin/libstdc*.dll cppcheck-mingw/
cp /mingw64/bin/libwinpthread-1.dll cppcheck-mingw/
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: cppcheck-mingw
path: cppcheck-mingw
diff --git a/.github/workflows/release-windows.yml b/.github/workflows/release-windows.yml
index 8d09a55302e..aa467d7b875 100644
--- a/.github/workflows/release-windows.yml
+++ b/.github/workflows/release-windows.yml
@@ -32,7 +32,7 @@ jobs:
BOOST_MINOR_VERSION: 89
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -95,7 +95,7 @@ jobs:
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
+ - uses: actions/upload-artifact@v7
with:
name: deploy
path: build\bin\Release
@@ -109,7 +109,7 @@ jobs:
env:
_CL_: /WX
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: bin
path: bin
@@ -158,7 +158,7 @@ jobs:
:: 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
+ - uses: actions/upload-artifact@v7
with:
name: collect
path: win_installer\files
@@ -173,7 +173,7 @@ jobs:
@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
+ - uses: actions/upload-artifact@v7
with:
name: installer
path: win_installer/Build/
@@ -209,7 +209,7 @@ jobs:
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
+ - uses: actions/upload-artifact@v7
with:
name: portable
path: win_installer\files
diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml
index ea0a0276c99..6021d1237d2 100644
--- a/.github/workflows/sanitizers.yml
+++ b/.github/workflows/sanitizers.yml
@@ -50,7 +50,7 @@ jobs:
CCACHE_SLOPPINESS: pch_defines,time_macros
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -60,7 +60,7 @@ jobs:
key: ${{ github.workflow }}-${{ github.job }}-${{ matrix.os }}-${{ matrix.sanitizer }}
- name: Set up Python
- uses: actions/setup-python@v5
+ uses: actions/setup-python@v6
with:
python-version: '3.14'
check-latest: true
diff --git a/.github/workflows/scriptcheck.yml b/.github/workflows/scriptcheck.yml
index 844b1d5c2f3..8cee3c5a5b4 100644
--- a/.github/workflows/scriptcheck.yml
+++ b/.github/workflows/scriptcheck.yml
@@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -31,7 +31,7 @@ jobs:
key: ${{ github.workflow }}-${{ runner.os }}
- name: Cache Cppcheck
- uses: actions/cache@v4
+ uses: actions/cache@v5
with:
path: cppcheck
key: ${{ runner.os }}-scriptcheck-cppcheck-${{ github.sha }}
@@ -56,19 +56,19 @@ jobs:
fail-fast: false
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
# TODO: bailout on error
- name: Restore Cppcheck
- uses: actions/cache@v4
+ uses: actions/cache@v5
with:
path: cppcheck
key: ${{ runner.os }}-scriptcheck-cppcheck-${{ github.sha }}
- name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v5
+ uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
check-latest: true
@@ -209,7 +209,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
diff --git a/.github/workflows/selfcheck.yml b/.github/workflows/selfcheck.yml
index 3517486df31..f16ce8d8332 100644
--- a/.github/workflows/selfcheck.yml
+++ b/.github/workflows/selfcheck.yml
@@ -24,7 +24,7 @@ jobs:
QT_VERSION: 6.10.0
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -215,7 +215,7 @@ jobs:
env:
DISABLE_VALUEFLOW: 1
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: Callgrind Output
path: ./callgrind.*
@@ -228,7 +228,7 @@ jobs:
env:
DISABLE_VALUEFLOW: 1
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
with:
name: Memcheck Output
path: ./memcheck.*
diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml
index 3e4a02dbb48..25ef4dd63a2 100644
--- a/.github/workflows/valgrind.yml
+++ b/.github/workflows/valgrind.yml
@@ -21,7 +21,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- - uses: actions/checkout@v4
+ - uses: actions/checkout@v6
with:
persist-credentials: false
@@ -64,7 +64,7 @@ jobs:
#env:
# DEBUGINFOD_URLS: https://debuginfod.ubuntu.com
- - uses: actions/upload-artifact@v4
+ - uses: actions/upload-artifact@v7
if: success() || failure()
with:
name: Logs
diff --git a/AUTHORS b/AUTHORS
index b4917d7d157..e804ab53e16 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,6 +1,7 @@
The cppcheck team, in alphabetical order:
0x41head
+Aaron Danen
Abhijit Sawant
Abhishek Bharadwaj
Abigail Buccaneer
@@ -100,6 +101,7 @@ daisuke-chiba
Daniel Friedrich
David Korczynski
Daniel Marjamäki
+Daschle Newberry
David Hallas
David Korth
Dávid Slivka
diff --git a/Makefile b/Makefile
index 42b754733ec..a7f3feefba6 100644
--- a/Makefile
+++ b/Makefile
@@ -600,7 +600,7 @@ $(libcppdir)/cppcheck.o: lib/cppcheck.cpp externals/picojson/picojson.h external
$(libcppdir)/ctu.o: lib/ctu.cpp externals/tinyxml2/tinyxml2.h lib/astutils.h lib/check.h lib/config.h lib/ctu.h lib/errorlogger.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/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/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/smallvector.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
+$(libcppdir)/errorlogger.o: lib/errorlogger.cpp externals/tinyxml2/tinyxml2.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/smallvector.h lib/sourcelocation.h lib/standards.h lib/suppressions.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)/errorlogger.cpp
$(libcppdir)/errortypes.o: lib/errortypes.cpp lib/config.h lib/errortypes.h lib/utils.h
diff --git a/cfg/gtk.cfg b/cfg/gtk.cfg
index 5e94a0bbb5c..a1d7763670e 100644
--- a/cfg/gtk.cfg
+++ b/cfg/gtk.cfg
@@ -5221,7 +5221,6 @@
-
false
diff --git a/cfg/qt.cfg b/cfg/qt.cfg
index c7bf3d8779b..95dc022cf57 100644
--- a/cfg/qt.cfg
+++ b/cfg/qt.cfg
@@ -5520,7 +5520,7 @@
-
+
diff --git a/cfg/std.cfg b/cfg/std.cfg
index 4662d0a4632..6c434b8715c 100644
--- a/cfg/std.cfg
+++ b/cfg/std.cfg
@@ -8343,9 +8343,7 @@ initializer list (7) string& replace (const_iterator i1, const_iterator i2, init
-
-
-
+
false
diff --git a/cfg/windows.cfg b/cfg/windows.cfg
index 6a0bd111afa..b2251900d42 100644
--- a/cfg/windows.cfg
+++ b/cfg/windows.cfg
@@ -1331,6 +1331,11 @@
AllocateAndInitializeSid
FreeSid
+
+ _create_locale
+ _wcreate_locale
+ _free_locale
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
arg1
diff --git a/externals/simplecpp/simplecpp.cpp b/externals/simplecpp/simplecpp.cpp
index d2c398c49e1..8237ac75fab 100644
--- a/externals/simplecpp/simplecpp.cpp
+++ b/externals/simplecpp/simplecpp.cpp
@@ -96,6 +96,8 @@ static const simplecpp::TokenString IFNDEF("ifndef");
static const simplecpp::TokenString DEFINED("defined");
static const simplecpp::TokenString ELSE("else");
static const simplecpp::TokenString ELIF("elif");
+static const simplecpp::TokenString ELIFDEF("elifdef");
+static const simplecpp::TokenString ELIFNDEF("elifndef");
static const simplecpp::TokenString ENDIF("endif");
static const simplecpp::TokenString PRAGMA("pragma");
@@ -475,26 +477,26 @@ namespace {
simplecpp::TokenList::TokenList(std::vector &filenames) : frontToken(nullptr), backToken(nullptr), files(filenames) {}
-simplecpp::TokenList::TokenList(std::istream &istr, std::vector &filenames, const std::string &filename, OutputList *outputList)
+simplecpp::TokenList::TokenList(std::istream &istr, std::vector &filenames, const std::string &filename, const DUI &dui, OutputList *outputList)
: frontToken(nullptr), backToken(nullptr), files(filenames)
{
StdIStream stream(istr);
- readfile(stream,filename,outputList);
+ readfile(stream,filename,dui,outputList);
}
-simplecpp::TokenList::TokenList(const unsigned char* data, std::size_t size, std::vector &filenames, const std::string &filename, OutputList *outputList, int /*unused*/)
+simplecpp::TokenList::TokenList(const unsigned char* data, std::size_t size, std::vector &filenames, const std::string &filename, const DUI &dui, OutputList *outputList, int /*unused*/)
: frontToken(nullptr), backToken(nullptr), files(filenames)
{
StdCharBufStream stream(data, size);
- readfile(stream,filename,outputList);
+ readfile(stream,filename,dui,outputList);
}
-simplecpp::TokenList::TokenList(const std::string &filename, std::vector &filenames, OutputList *outputList)
+simplecpp::TokenList::TokenList(const std::string &filename, std::vector &filenames, const DUI &dui, OutputList *outputList)
: frontToken(nullptr), backToken(nullptr), files(filenames)
{
try {
FileStream stream(filename, filenames);
- readfile(stream,filename,outputList);
+ readfile(stream,filename,dui,outputList);
} catch (const simplecpp::Output & e) {
outputList->emplace_back(e);
}
@@ -659,18 +661,24 @@ void simplecpp::TokenList::lineDirective(unsigned int fileIndex_, unsigned int l
static const std::string COMMENT_END("*/");
-void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename, OutputList *outputList)
+void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename, const DUI &dui, OutputList *outputList)
{
unsigned int multiline = 0U;
+ bool trailing_nl = true;
const Token *oldLastToken = nullptr;
+ const cstd_t cstd = getCStd(dui.std);
+ const cppstd_t cppstd = getCppStd(dui.std);
+
Location location(fileIndex(filename), 1, 1);
while (stream.good()) {
unsigned char ch = stream.readChar();
if (!stream.good())
break;
+ trailing_nl = false;
+
if (ch >= 0x80) {
if (outputList) {
simplecpp::Output err{
@@ -693,6 +701,7 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
} else {
location.line += multiline + 1;
multiline = 0U;
+ trailing_nl = true;
}
if (!multiline)
location.col = 1;
@@ -723,10 +732,64 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
if (ppTok->str() == "line")
ppTok = advanceAndSkipComments(ppTok);
+ if (ppTok && (ppTok->str()[0] == '-' || ppTok->str()[0] == '+')) {
+ if (outputList) {
+ simplecpp::Output err{
+ simplecpp::Output::SYNTAX_ERROR,
+ location,
+ "Invalid character in line directive: '" + ppTok->str() + "'."
+ };
+ outputList->emplace_back(std::move(err));
+ }
+ clear();
+ return;
+ }
+
if (!ppTok || !ppTok->number)
continue;
- const unsigned int line = std::atol(ppTok->str().c_str());
+ constexpr unsigned long line_limit = std::numeric_limits::max();
+ unsigned long line;
+ try {
+ line = std::min(line_limit, std::stoul(ppTok->str()));
+ } catch (...) {
+ line = line_limit;
+ }
+
+ unsigned long maxline;
+ if ((cstd != CUnknown && cstd < C99) || (cppstd != CPPUnknown && cppstd < CPP11))
+ maxline = 32767;
+ else
+ maxline = 2147483647;
+
+ if (line == 0 || line > maxline) {
+ if (outputList) {
+ const bool unknown_std = cstd == CUnknown && cppstd == CPPUnknown;
+ std::string msg = "Line number out of range: " + ppTok->str() + ". ";
+ if (line == 0) {
+ msg += "Line number zero is undefined behavior.";
+ } else {
+ msg += "Line numbers above " + std::to_string(maxline) + " are ";
+ if (unknown_std)
+ msg += "undefined behavior or conditionally supported";
+ else if (cppstd >= CPP26)
+ msg += "conditionally supported";
+ else
+ msg += "undefined behavior";
+ if (cstd != CUnknown)
+ msg += std::string(" in ") + getCStdName(cstd);
+ else if (cppstd != CPPUnknown)
+ msg += std::string(" in ") + getCppStdName(cppstd);
+ msg += ".";
+ }
+ simplecpp::Output err{
+ simplecpp::Output::PORTABILITY_LINE_DIRECTIVE,
+ location, msg
+ };
+ outputList->emplace_back(std::move(err));
+ }
+ }
+
ppTok = advanceAndSkipComments(ppTok);
unsigned int fileindex;
@@ -961,6 +1024,15 @@ void simplecpp::TokenList::readfile(Stream &stream, const std::string &filename,
location.adjust(currentToken);
}
+ if ((cstd != CUnknown || cppstd == CPPUnknown) && !trailing_nl && outputList) {
+ Output err{
+ Output::PORTABILITY_NO_EOF_NEWLINE,
+ location,
+ "No newline at end of file is undefined behavior in C."
+ };
+ outputList->emplace_back(std::move(err));
+ }
+
combineOperators();
}
@@ -1523,7 +1595,7 @@ namespace simplecpp {
* @throws std::runtime_error thrown on bad macro syntax
*/
Macro(const std::string &name, const std::string &value, std::vector &f) : nameTokDef(nullptr), files(f), tokenListDefine(f), valueDefinedInCode_(false) {
- const std::string def(name + ' ' + value);
+ const std::string def(name + ' ' + value + '\n');
StdCharBufStream stream(reinterpret_cast(def.data()), def.size());
tokenListDefine.readfile(stream);
if (!parseDefine(tokenListDefine.cfront()))
@@ -1602,7 +1674,7 @@ namespace simplecpp {
else if (rawtok->op == ')')
--par;
else if (rawtok->op == '#' && !sameline(rawtok->previous, rawtok))
- throw Error(rawtok->location, "it is invalid to use a preprocessor directive as macro parameter");
+ throw invalidDirectiveAsMacroParameter(rawtok->location);
rawtokens2.push_back(new Token(rawtok->str(), rawtok1->location, rawtok->whitespaceahead));
rawtok = rawtok->next;
}
@@ -1635,7 +1707,7 @@ namespace simplecpp {
if (output2.cfront() != output2.cback() && macro2tok->str() == this->name())
break;
const MacroMap::const_iterator macro = macros.find(macro2tok->str());
- if (macro == macros.end() || !macro->second.functionLike())
+ if (macro == macros.end() || !macro->second.functionLike() || macro2tok->isExpandedFrom(¯o->second))
break;
TokenList rawtokens2(inputFiles);
const Location loc(macro2tok->location);
@@ -1698,6 +1770,11 @@ namespace simplecpp {
const std::string what;
};
+ struct invalidDirectiveAsMacroParameter : public Error {
+ explicit invalidDirectiveAsMacroParameter(const Location &loc)
+ : Error(loc, "it is invalid to use a preprocessor directive as macro parameter") {}
+ };
+
/** Struct that is thrown when macro is expanded with wrong number of parameters */
struct wrongNumberOfParameters : public Error {
wrongNumberOfParameters(const Location &loc, const std::string ¯oName) : Error(loc, "Wrong number of parameters for macro \'" + macroName + "\'.") {}
@@ -1917,14 +1994,17 @@ namespace simplecpp {
if (nameTokInst->str() == "__FILE__") {
output.push_back(new Token('\"'+output.file(loc)+'\"', loc));
+ output.back()->macro = "__FILE__";
return nameTokInst->next;
}
if (nameTokInst->str() == "__LINE__") {
output.push_back(new Token(toString(loc.line), loc));
+ output.back()->macro = "__LINE__";
return nameTokInst->next;
}
if (nameTokInst->str() == "__COUNTER__") {
output.push_back(new Token(toString(usageList.size()-1U), loc));
+ output.back()->macro = "__COUNTER__";
return nameTokInst->next;
}
@@ -2084,39 +2164,37 @@ namespace simplecpp {
return functionLike() ? parametertokens2.back()->next : nameTokInst->next;
}
- const Token *recursiveExpandToken(TokenList &output, TokenList &temp, const Location &loc, const Token *tok, const MacroMap ¯os, const std::set &expandedmacros, const std::vector ¶metertokens) const {
- if (!temp.cback() || !temp.cback()->name || !tok->next || tok->next->op != '(') {
- output.takeTokens(temp);
- return tok->next;
- }
-
- if (!sameline(tok, tok->next)) {
- output.takeTokens(temp);
- return tok->next;
- }
-
+ /** Returns the macro to expand when the last token of @p temp is the name of a
+ * function-like macro and the tokens after @p tok supply its arguments; nullptr otherwise */
+ static const Macro *rescanMacro(const TokenList &temp, const Token *tok, const MacroMap ¯os, const std::set &expandedmacros) {
+ if (!temp.cback() || !temp.cback()->name || !sameline(tok, tok->next) || tok->next->op != '(')
+ return nullptr;
const MacroMap::const_iterator it = macros.find(temp.cback()->str());
- if (it == macros.end() || expandedmacros.find(temp.cback()->str()) != expandedmacros.end()) {
- output.takeTokens(temp);
- return tok->next;
- }
+ if (it == macros.end() || expandedmacros.find(temp.cback()->str()) != expandedmacros.end())
+ return nullptr;
+ if (!it->second.functionLike() || temp.cback()->isExpandedFrom(&it->second))
+ return nullptr;
+ return &it->second;
+ }
- const Macro &calledMacro = it->second;
- if (!calledMacro.functionLike()) {
+ const Token *recursiveExpandToken(TokenList &output, TokenList &temp, const Location &loc, const Token *tok, const MacroMap ¯os, const std::set &expandedmacros, const std::vector ¶metertokens) const {
+ // Expand while the expansion result ends with the name of a function-like
+ // macro whose arguments are supplied by the tokens that follow it. Each round
+ // consumes that macro call from the token stream, so tok always advances.
+ while (const Macro * const calledMacro = rescanMacro(temp, tok, macros, expandedmacros)) {
+ TokenList temp2(files);
+ temp2.push_back(new Token(temp.cback()->str(), tok->location));
+
+ const Token * const tok2 = appendTokens(temp2, loc, tok->next, macros, expandedmacros, parametertokens);
+ if (!tok2)
+ break;
output.takeTokens(temp);
- return tok->next;
+ output.deleteToken(output.back());
+ calledMacro->expand(temp, loc, temp2.cfront(), macros, expandedmacros);
+ tok = tok2;
}
-
- TokenList temp2(files);
- temp2.push_back(new Token(temp.cback()->str(), tok->location));
-
- const Token * const tok2 = appendTokens(temp2, loc, tok->next, macros, expandedmacros, parametertokens);
- if (!tok2)
- return tok->next;
output.takeTokens(temp);
- output.deleteToken(output.back());
- calledMacro.expand(output, loc, temp2.cfront(), macros, expandedmacros);
- return tok2->next;
+ return tok->next;
}
const Token *expandToken(TokenList &output, const Location &loc, const Token *tok, const MacroMap ¯os, const std::set &expandedmacros, const std::vector ¶metertokens) const {
@@ -3126,8 +3204,8 @@ simplecpp::FileDataCache::FileDataCache()
{}
simplecpp::FileDataCache::~FileDataCache() = default;
-simplecpp::FileDataCache::FileDataCache(FileDataCache &&) noexcept = default;
-simplecpp::FileDataCache &simplecpp::FileDataCache::operator=(simplecpp::FileDataCache &&) noexcept = default;
+simplecpp::FileDataCache::FileDataCache(FileDataCache &&) SIMPLECPP_NOEXCEPT = default;
+simplecpp::FileDataCache &simplecpp::FileDataCache::operator=(simplecpp::FileDataCache &&) SIMPLECPP_NOEXCEPT = default;
static bool getFileId(const std::string &path, FileID &id);
@@ -3145,7 +3223,7 @@ std::pair simplecpp::FileDataCache::tryload(FileDat
return {id_it->second, false};
}
- auto *const data = new FileData {path, TokenList(path, filenames, outputList)};
+ auto *const data = new FileData {path, TokenList(path, filenames, {}, outputList)};
if (dui.removeComments)
data->tokens.removeComments();
@@ -3154,13 +3232,10 @@ std::pair simplecpp::FileDataCache::tryload(FileDat
mImpl->mIdMap.emplace(fileId, data);
mData.emplace_back(data);
- if (mLoadCallback)
- mLoadCallback(*data);
-
return {data, true};
}
-std::pair simplecpp::FileDataCache::get(const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader, std::vector &filenames, simplecpp::OutputList *outputList)
+std::pair simplecpp::FileDataCache::get_private(const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader, std::vector &filenames, simplecpp::OutputList *outputList)
{
if (isAbsolutePath(header)) {
auto ins = mNameMap.emplace(simplecpp::simplifyPath(header), nullptr);
@@ -3206,6 +3281,16 @@ std::pair simplecpp::FileDataCache::get(const std::
return {nullptr, false};
}
+std::pair simplecpp::FileDataCache::get(const std::string &sourcefile, const std::string &header, const simplecpp::DUI &dui, bool systemheader, std::vector &filenames, simplecpp::OutputList *outputList)
+{
+ auto ret = get_private(sourcefile, header, dui, systemheader, filenames, outputList);
+
+ if (mLoadCallback && ret.first)
+ mLoadCallback(*ret.first, ret.second);
+
+ return ret;
+}
+
void simplecpp::FileDataCache::clear()
{
mImpl->clear();
@@ -3336,7 +3421,7 @@ simplecpp::FileDataCache simplecpp::load(const simplecpp::TokenList &rawtokens,
return cache;
}
-static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token *&tok1, simplecpp::MacroMap ¯os, std::vector &files, simplecpp::OutputList *outputList)
+static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token *&tok1, simplecpp::MacroMap ¯os, std::vector &files, simplecpp::OutputList *outputList, const simplecpp::DUI &dui)
{
const simplecpp::Token * const tok = tok1;
const simplecpp::MacroMap::const_iterator it = tok->name ? macros.find(tok->str()) : macros.end();
@@ -3344,6 +3429,16 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token
simplecpp::TokenList value(files);
try {
tok1 = it->second.expand(value, tok, macros, files);
+ } catch (const simplecpp::Macro::invalidDirectiveAsMacroParameter &err) {
+ if (outputList) {
+ simplecpp::Output out{
+ simplecpp::Output::DIRECTIVE_AS_MACRO_PARAMETER,
+ err.location,
+ "failed to expand \'" + tok->str() + "\', " + err.what
+ };
+ outputList->emplace_back(std::move(out));
+ }
+ return false;
} catch (const simplecpp::Macro::Error &err) {
if (outputList) {
simplecpp::Output out{
@@ -3357,7 +3452,7 @@ static bool preprocessToken(simplecpp::TokenList &output, const simplecpp::Token
}
output.takeTokens(value);
} else {
- if (!tok->comment)
+ if (!tok->comment || !dui.removeComments)
output.push_back(new simplecpp::Token(*tok));
tok1 = tok->next;
}
@@ -3552,7 +3647,9 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
continue;
}
- if (ifstates.size() <= 1U && (rawtok->str() == ELIF || rawtok->str() == ELSE || rawtok->str() == ENDIF)) {
+ if (ifstates.size() <= 1U && (rawtok->str() == ELIF || rawtok->str() == ELIFDEF ||
+ rawtok->str() == ELIFNDEF || rawtok->str() == ELSE ||
+ rawtok->str() == ENDIF)) {
if (outputList) {
simplecpp::Output err{
Output::SYNTAX_ERROR,
@@ -3632,7 +3729,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
TokenList inc2(files);
if (!inc1.empty() && inc1.cfront()->name) {
const Token *inctok = inc1.cfront();
- if (!preprocessToken(inc2, inctok, macros, files, outputList)) {
+ if (!preprocessToken(inc2, inctok, macros, files, outputList, dui)) {
output.clear();
return;
}
@@ -3693,7 +3790,8 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
rawtok = filedata->tokens.cfront();
continue;
}
- } else if (rawtok->str() == IF || rawtok->str() == IFDEF || rawtok->str() == IFNDEF || rawtok->str() == ELIF) {
+ } else if (rawtok->str() == IF || rawtok->str() == IFDEF || rawtok->str() == IFNDEF || rawtok->str() == ELIF ||
+ rawtok->str() == ELIFDEF || rawtok->str() == ELIFNDEF) {
if (!sameline(rawtok,rawtok->next)) {
if (outputList) {
simplecpp::Output out{
@@ -3708,15 +3806,28 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
}
bool conditionIsTrue;
- if (ifstates.top() == AlwaysFalse || (ifstates.top() == ElseIsTrue && rawtok->str() != ELIF)) {
+ if (ifstates.top() == AlwaysFalse || (ifstates.top() == ElseIsTrue && rawtok->str() != ELIF &&
+ rawtok->str() != ELIFDEF && rawtok->str() != ELIFNDEF)) {
conditionIsTrue = false;
}
- else if (rawtok->str() == IFDEF) {
- conditionIsTrue = (macros.find(rawtok->next->str()) != macros.end() || (hasInclude && rawtok->next->str() == HAS_INCLUDE));
- maybeUsedMacros[rawtok->next->str()].emplace_back(rawtok->next->location);
- } else if (rawtok->str() == IFNDEF) {
- conditionIsTrue = (macros.find(rawtok->next->str()) == macros.end() && !(hasInclude && rawtok->next->str() == HAS_INCLUDE));
- maybeUsedMacros[rawtok->next->str()].emplace_back(rawtok->next->location);
+ else if (rawtok->str() == IFDEF || rawtok->str() == ELIFDEF) {
+ const std::string &name = rawtok->next->str();
+ conditionIsTrue = (macros.find(name) != macros.end() || (hasInclude && name == HAS_INCLUDE));
+ maybeUsedMacros[name].emplace_back(rawtok->next->location);
+ if (ifCond) {
+ const std::string E = conditionIsTrue ? "1" : "0";
+ const long long result = conditionIsTrue ? 1 : 0;
+ ifCond->emplace_back(rawtok->location, E, result);
+ }
+ } else if (rawtok->str() == IFNDEF || rawtok->str() == ELIFNDEF) {
+ const std::string &name = rawtok->next->str();
+ conditionIsTrue = (macros.find(name) == macros.end() && !(hasInclude && name == HAS_INCLUDE));
+ maybeUsedMacros[name].emplace_back(rawtok->next->location);
+ if (ifCond) {
+ const std::string E = conditionIsTrue ? "1" : "0";
+ const long long result = conditionIsTrue ? 1 : 0;
+ ifCond->emplace_back(rawtok->location, E, result);
+ }
} else { /*if (rawtok->str() == IF || rawtok->str() == ELIF)*/
TokenList expr(files);
for (const Token *tok = rawtok->next; tok && tok->location.sameline(rawtok->location); tok = tok->next) {
@@ -3802,7 +3913,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
maybeUsedMacros[rawtok->next->str()].emplace_back(rawtok->next->location);
const Token *tmp = tok;
- if (!preprocessToken(expr, tmp, macros, files, outputList)) {
+ if (!preprocessToken(expr, tmp, macros, files, outputList, dui)) {
output.clear();
return;
}
@@ -3839,7 +3950,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
}
}
- if (rawtok->str() != ELIF) {
+ if (rawtok->str() != ELIF && rawtok->str() != ELIFDEF && rawtok->str() != ELIFNDEF) {
// push a new ifstate..
if (ifstates.top() != True)
ifstates.push(AlwaysFalse);
@@ -3900,7 +4011,7 @@ void simplecpp::preprocess(simplecpp::TokenList &output, const simplecpp::TokenL
const Location loc(rawtok->location);
TokenList tokens(files);
- if (!preprocessToken(tokens, rawtok, macros, files, outputList)) {
+ if (!preprocessToken(tokens, rawtok, macros, files, outputList, dui)) {
output.clear();
return;
}
@@ -3959,6 +4070,20 @@ simplecpp::cstd_t simplecpp::getCStd(const std::string &std)
return CUnknown;
}
+const char *simplecpp::getCStdName(cstd_t std)
+{
+ switch (std) {
+ case CUnknown: return "C";
+ case C89: return "C89";
+ case C99: return "C99";
+ case C11: return "C11";
+ case C17: return "C17";
+ case C23: return "C23";
+ case C2Y: return "C2Y";
+ }
+ return "";
+}
+
std::string simplecpp::getCStdString(cstd_t std)
{
switch (std) {
@@ -4011,6 +4136,21 @@ simplecpp::cppstd_t simplecpp::getCppStd(const std::string &std)
return CPPUnknown;
}
+const char *simplecpp::getCppStdName(cppstd_t std)
+{
+ switch (std) {
+ case CPPUnknown: return "C++";
+ case CPP03: return "C++03";
+ case CPP11: return "C++11";
+ case CPP14: return "C++14";
+ case CPP17: return "C++17";
+ case CPP20: return "C++20";
+ case CPP23: return "C++23";
+ case CPP26: return "C++26";
+ }
+ return "";
+}
+
std::string simplecpp::getCppStdString(cppstd_t std)
{
switch (std) {
diff --git a/externals/simplecpp/simplecpp.h b/externals/simplecpp/simplecpp.h
index 3d6fc5262b9..f4dca18374a 100644
--- a/externals/simplecpp/simplecpp.h
+++ b/externals/simplecpp/simplecpp.h
@@ -60,6 +60,15 @@
# endif
#endif
+#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ <= 9
+// Hack to workaround GCC bug.
+// Details: https://trac.cppcheck.net/ticket/14850
+// seen on g++ before 10.x
+#define SIMPLECPP_NOEXCEPT
+#else
+#define SIMPLECPP_NOEXCEPT noexcept
+#endif
+
namespace simplecpp {
/** C code standard */
enum cstd_t : std::int8_t { CUnknown=-1, C89, C99, C11, C17, C23, C2Y };
@@ -238,7 +247,10 @@ namespace simplecpp {
MISSING_HEADER,
INCLUDE_NESTED_TOO_DEEPLY,
SYNTAX_ERROR,
+ DIRECTIVE_AS_MACRO_PARAMETER,
PORTABILITY_BACKSLASH,
+ PORTABILITY_LINE_DIRECTIVE,
+ PORTABILITY_NO_EOF_NEWLINE,
UNHANDLED_CHAR_ERROR,
EXPLICIT_INCLUDE_NOT_FOUND,
FILE_NOT_FOUND,
@@ -251,6 +263,21 @@ namespace simplecpp {
using OutputList = std::list