updated CI to Clang 17 (#4797)

This commit is contained in:
Oliver Stöneberg 2023-08-09 12:45:15 +02:00 committed by GitHub
parent 2502897265
commit 4e8c240129
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 105 additions and 80 deletions

View File

@ -20,12 +20,15 @@ Checks: >
-zircon-*, -zircon-*,
cert-err34-c, cert-err34-c,
google-explicit-constructor, google-explicit-constructor,
cppcoreguidelines-rvalue-reference-param-not-moved,
-bugprone-assignment-in-if-condition, -bugprone-assignment-in-if-condition,
-bugprone-branch-clone, -bugprone-branch-clone,
-bugprone-easily-swappable-parameters, -bugprone-easily-swappable-parameters,
-bugprone-empty-catch,
-bugprone-macro-parentheses, -bugprone-macro-parentheses,
-bugprone-narrowing-conversions, -bugprone-narrowing-conversions,
-bugprone-signed-char-misuse, -bugprone-signed-char-misuse,
-bugprone-switch-missing-default-case,
-bugprone-unchecked-optional-access, -bugprone-unchecked-optional-access,
-clang-analyzer-*, -clang-analyzer-*,
-concurrency-mt-unsafe, -concurrency-mt-unsafe,
@ -36,6 +39,7 @@ Checks: >
-misc-use-anonymous-namespace, -misc-use-anonymous-namespace,
-modernize-avoid-c-arrays, -modernize-avoid-c-arrays,
-modernize-deprecated-ios-base-aliases, -modernize-deprecated-ios-base-aliases,
-misc-include-cleaner,
-modernize-loop-convert, -modernize-loop-convert,
-modernize-raw-string-literal, -modernize-raw-string-literal,
-modernize-replace-auto-ptr, -modernize-replace-auto-ptr,
@ -43,8 +47,10 @@ Checks: >
-modernize-use-auto, -modernize-use-auto,
-modernize-use-equals-default, -modernize-use-equals-default,
-modernize-use-trailing-return-type, -modernize-use-trailing-return-type,
-performance-avoid-endl,
-performance-inefficient-string-concatenation, -performance-inefficient-string-concatenation,
-performance-no-automatic-move, -performance-no-automatic-move,
-performance-noexcept-swap,
-portability-simd-intrinsics, -portability-simd-intrinsics,
-portability-std-allocator-const, -portability-std-allocator-const,
-readability-avoid-const-params-in-decls, -readability-avoid-const-params-in-decls,

View File

@ -42,7 +42,7 @@ jobs:
sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14
wget https://apt.llvm.org/llvm.sh wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh chmod +x llvm.sh
sudo ./llvm.sh 16 sudo ./llvm.sh 17
- name: Install Qt ${{ env.QT_VERSION }} - name: Install Qt ${{ env.QT_VERSION }}
if: false if: false
@ -56,8 +56,8 @@ jobs:
run: | run: |
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off -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=Off -DDISABLE_DMAKE=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off -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=Off -DDISABLE_DMAKE=On -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env: env:
CC: clang-16 CC: clang-17
CXX: clang++-16 CXX: clang++-17
- name: Build cppcheck - name: Build cppcheck
run: | run: |

View File

@ -30,8 +30,8 @@ jobs:
sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14
wget https://apt.llvm.org/llvm.sh wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh chmod +x llvm.sh
sudo ./llvm.sh 16 sudo ./llvm.sh 17
sudo apt-get install -y clang-tidy-16 sudo apt-get install -y clang-tidy-17
- name: Install Qt ${{ env.QT_VERSION }} - name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v3 uses: jurplel/install-qt-action@v3
@ -42,14 +42,14 @@ jobs:
- name: Verify clang-tidy configuration - name: Verify clang-tidy configuration
run: | run: |
clang-tidy-16 --verify-config clang-tidy-17 --verify-config
- name: Prepare CMake - name: Prepare CMake
run: | run: |
cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCPPCHK_GLIBCXX_DEBUG=Off cmake -S . -B cmake.output -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCPPCHK_GLIBCXX_DEBUG=Off
env: env:
CC: clang-16 CC: clang-17
CXX: clang++-16 CXX: clang++-17
- name: Prepare CMake dependencies - name: Prepare CMake dependencies
run: | run: |

View File

@ -42,7 +42,7 @@ jobs:
sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14
wget https://apt.llvm.org/llvm.sh wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh chmod +x llvm.sh
sudo ./llvm.sh 16 sudo ./llvm.sh 17
- name: Install Qt ${{ env.QT_VERSION }} - name: Install Qt ${{ env.QT_VERSION }}
if: false if: false
@ -56,8 +56,8 @@ jobs:
run: | run: |
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off -DUSE_MATCHCOMPILER=Verify -DANALYZE_THREAD=On -DUSE_THREADS=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 -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=Off -DWITH_QCHART=Off -DUSE_MATCHCOMPILER=Verify -DANALYZE_THREAD=On -DUSE_THREADS=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 -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env: env:
CC: clang-16 CC: clang-17
CXX: clang++-16 CXX: clang++-17
- name: Build cppcheck - name: Build cppcheck
run: | run: |

View File

@ -42,7 +42,7 @@ jobs:
sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14 sudo apt-get purge --auto-remove llvm python3-lldb-14 llvm-14
wget https://apt.llvm.org/llvm.sh wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh chmod +x llvm.sh
sudo ./llvm.sh 16 sudo ./llvm.sh 17
- name: Install Qt ${{ env.QT_VERSION }} - name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v3 uses: jurplel/install-qt-action@v3
@ -55,8 +55,8 @@ jobs:
run: | run: |
cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=ON -DWITH_QCHART=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 -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache cmake -S . -B cmake.output -DCMAKE_BUILD_TYPE=RelWithDebInfo -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=ON -DWITH_QCHART=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 -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env: env:
CC: clang-16 CC: clang-17
CXX: clang++-16 CXX: clang++-17
- name: Build cppcheck - name: Build cppcheck
run: | run: |

View File

@ -8,156 +8,169 @@ We do not perform static analysis of the source of the external libraries. `simp
## Disabled Checks ## Disabled Checks
`abseil-*`<br> `abseil-*`<br/>
`altera-*`<br> `altera-*`<br/>
`android-*`<br> `android-*`<br/>
`boost-*`<br> `boost-*`<br/>
`darwin-*`<br> `darwin-*`<br/>
`fuchsia-*`<br> `fuchsia-*`<br/>
`linuxkernel-*`<br> `linuxkernel-*`<br/>
`llvm-*`<br> `llvm-*`<br/>
`llvmlibc-*`<br> `llvmlibc-*`<br/>
`mpi-*`<br> `mpi-*`<br/>
`objc-*`<br> `objc-*`<br/>
`openmp-*`<br> `openmp-*`<br/>
`zircon-*`<br> `zircon-*`<br/>
These are disabled since the platforms/libraries in question are not targeted by us. These are disabled since the platforms/libraries in question are not targeted by us.
`cert-*`<br> `cert-*`<br/>
`cppcoreguidelines-*`<br> `cppcoreguidelines-*`<br/>
`google-*`<br> `google-*`<br/>
`hicpp-*`<br> `hicpp-*`<br/>
These are coding guidelines we do not follow. Some of the checks might be explicitly enabled though. These are coding guidelines we do not follow. Some of the checks might be explicitly enabled though.
`readability-braces-around-statements`<br> `readability-braces-around-statements`<br/>
`readability-isolate-declaration`<br> `readability-isolate-declaration`<br/>
`modernize-use-trailing-return-type`<br> `modernize-use-trailing-return-type`<br/>
`modernize-use-auto`<br> `modernize-use-auto`<br/>
`readability-uppercase-literal-suffix`<br> `readability-uppercase-literal-suffix`<br/>
`readability-else-after-return`<br> `readability-else-after-return`<br/>
`readability-identifier-length`<br> `readability-identifier-length`<br/>
These do not reflect the style we are (currently) enforcing. These do not reflect the style we are (currently) enforcing.
`readability-function-size`<br> `readability-function-size`<br/>
`readability-function-cognitive-complexity`<br> `readability-function-cognitive-complexity`<br/>
We are not interested in the size/complexity of a function. We are not interested in the size/complexity of a function.
`readability-magic-numbers`<br> `readability-magic-numbers`<br/>
These do not (always) increase readability. These do not (always) increase readability.
`bugprone-macro-parentheses`<br> `bugprone-macro-parentheses`<br/>
To be documented. To be documented.
`readability-implicit-bool-conversion`<br> `readability-implicit-bool-conversion`<br/>
This does not appear to be useful as it is reported on very common code. This does not appear to be useful as it is reported on very common code.
`bugprone-narrowing-conversions`<br> `bugprone-narrowing-conversions`<br/>
`performance-no-automatic-move`<br> `performance-no-automatic-move`<br/>
It was decided not to apply these. It was decided not to apply these.
`modernize-use-equals-default`<br> `modernize-use-equals-default`<br/>
`modernize-loop-convert`<br> `modernize-loop-convert`<br/>
These might change the behavior of code which might not be intended (need to file an upstream issue) These might change the behavior of code which might not be intended (need to file an upstream issue)
`modernize-raw-string-literal`<br> `modernize-raw-string-literal`<br/>
This leads to a mismatch of raw string literals and regular ones and does reduce the readability. This leads to a mismatch of raw string literals and regular ones and does reduce the readability.
`readability-convert-member-functions-to-static`<br> `readability-convert-member-functions-to-static`<br/>
Disabled because of false positives with Qt `slot` methods (see https://github.com/llvm/llvm-project/issues/57520). Disabled because of false positives with Qt `slot` methods (see https://github.com/llvm/llvm-project/issues/57520).
`-clang-analyzer-*`<br> `-clang-analyzer-*`<br/>
Disabled because of false positives (needs to file an upstream bug report). Disabled because of false positives (needs to file an upstream bug report).
`misc-non-private-member-variables-in-classes`<br> `misc-non-private-member-variables-in-classes`<br/>
We intentionally use this. We intentionally use this.
`misc-no-recursion`<br> `misc-no-recursion`<br/>
Leads to lots of "false positives". This seem to enforce a coding guidelines of certain codebases. Leads to lots of "false positives". This seem to enforce a coding guidelines of certain codebases.
`readability-use-anyofallof`<br> `readability-use-anyofallof`<br/>
We currently don't even apply our own `useStlAlgorithm` findings. We currently don't even apply our own `useStlAlgorithm` findings.
`bugprone-easily-swappable-parameters`<br> `bugprone-easily-swappable-parameters`<br/>
This produces a lot of noise and they are not fixable that easily. This produces a lot of noise and they are not fixable that easily.
`readability-container-data-pointer`<br> `readability-container-data-pointer`<br/>
Disable because of false positives and inconsistent warnings (need to file an upstream bug report). Disable because of false positives and inconsistent warnings (need to file an upstream bug report).
`misc-const-correctness`<br> `misc-const-correctness`<br/>
Work in progress. Work in progress.
`bugprone-assignment-in-if-condition`<br> `bugprone-assignment-in-if-condition`<br/>
Is reported for valid patterns we are using. Is reported for valid patterns we are using.
`readability-suspicious-call-argument`<br> `readability-suspicious-call-argument`<br/>
Produces a lot of false positives since it is too vague in its analysis. Produces a lot of false positives since it is too vague in its analysis.
`performance-inefficient-string-concatenation`<br> `performance-inefficient-string-concatenation`<br/>
Produces warnings which might be considered false positives starting with C++11 - see https://github.com/llvm/llvm-project/issues/54526. Produces warnings which might be considered false positives starting with C++11 - see https://github.com/llvm/llvm-project/issues/54526.
`readability-redundant-access-specifiers`<br> `readability-redundant-access-specifiers`<br/>
Reports warning with the Qt `<access-specifier> slots:` syntax in class declarations - see https://github.com/llvm/llvm-project/issues/60055. Reports warning with the Qt `<access-specifier> slots:` syntax in class declarations - see https://github.com/llvm/llvm-project/issues/60055.
`modernize-avoid-c-arrays`<br> `modernize-avoid-c-arrays`<br/>
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. 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. Also reports a false positive about templates which deduce the array length: https://github.com/llvm/llvm-project/issues/60053.
`readability-container-size-empty`<br> `misc-include-cleaner`<br/>
`bugprone-branch-clone`<br>
`readability-const-return-type`<br>
`modernize-return-braced-init-list`<br>
`misc-throw-by-value-catch-by-reference`<br>
`readability-avoid-const-params-in-decls`<br>
`bugprone-signed-char-misuse`<br>
`readability-redundant-access-specifiers`<br>
`concurrency-mt-unsafe`<br>
`misc-use-anonymous-namespace`<br>
To be evaluated. 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.
`portability-std-allocator-const`<br> `readability-container-size-empty`<br/>
`bugprone-branch-clone`<br/>
`readability-const-return-type`<br/>
`modernize-return-braced-init-list`<br/>
`misc-throw-by-value-catch-by-reference`<br/>
`readability-avoid-const-params-in-decls`<br/>
`bugprone-signed-char-misuse`<br/>
`readability-redundant-access-specifiers`<br/>
`concurrency-mt-unsafe`<br/>
`misc-use-anonymous-namespace`<br/>
`performance-avoid-endl`<br/>
`performance-noexcept-swap`<br/>
`bugprone-switch-missing-default-case`<br/>
`bugprone-empty-catch`<br/>
To be evaluated (need to remove exclusion).
`cppcoreguidelines-missing-std-forward`<br/>
`cppcoreguidelines-avoid-const-or-ref-data-members`<br/>
To be evaluated (need to enable explicitly).
`portability-std-allocator-const`<br/>
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. 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`<br> `modernize-deprecated-ios-base-aliases`<br/>
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. 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`<br> `bugprone-unchecked-optional-access`<br/>
We are not using any `optional` implementation. Also disabled for performance reasons - see https://github.com/llvm/llvm-project/issues/57527#issuecomment-1237935132. 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`<br> `modernize-replace-auto-ptr`<br/>
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. 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`<br> `readability-identifier-naming`<br/>
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. 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`<br> `portability-simd-intrinsics`<br/>
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. 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.

View File

@ -9,7 +9,7 @@ if (NOT CMAKE_DISABLE_PRECOMPILE_HEADERS)
message(STATUS "Cannot use non-Clang compiler with clang-tidy when precompiled headers are enabled - skipping 'run-clang-tidy' target generation") message(STATUS "Cannot use non-Clang compiler with clang-tidy when precompiled headers are enabled - skipping 'run-clang-tidy' target generation")
endif() endif()
else() else()
set(RUN_CLANG_TIDY_NAMES run-clang-tidy run-clang-tidy-16 run-clang-tidy-15 run-clang-tidy-14 run-clang-tidy-13 run-clang-tidy-12 run-clang-tidy-11 run-clang-tidy-10 run-clang-tidy-9 run-clang-tidy-8) set(RUN_CLANG_TIDY_NAMES run-clang-tidy run-clang-tidy-17 run-clang-tidy-16 run-clang-tidy-15 run-clang-tidy-14 run-clang-tidy-13 run-clang-tidy-12 run-clang-tidy-11 run-clang-tidy-10 run-clang-tidy-9 run-clang-tidy-8)
endif() endif()
if (RUN_CLANG_TIDY_NAMES) if (RUN_CLANG_TIDY_NAMES)

View File

@ -330,10 +330,15 @@ bool TokenList::createTokens(std::istream &code, const std::string& file0)
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
void TokenList::createTokens(simplecpp::TokenList&& tokenList) void TokenList::createTokens(simplecpp::TokenList&& tokenList)
{ {
if (tokenList.cfront()) if (tokenList.cfront()) {
// this is a copy
// TODO: the same as TokenList.files - move that instead
// TODO: this points to mFiles when called from createTokens(std::istream &, const std::string&)
mOrigFiles = mFiles = tokenList.cfront()->location.files; mOrigFiles = mFiles = tokenList.cfront()->location.files;
}
else else
mFiles.clear(); mFiles.clear();
@ -341,6 +346,7 @@ void TokenList::createTokens(simplecpp::TokenList&& tokenList)
for (const simplecpp::Token *tok = tokenList.cfront(); tok;) { for (const simplecpp::Token *tok = tokenList.cfront(); tok;) {
// TODO: move from TokenList
std::string str = tok->str(); std::string str = tok->str();
// Float literal // Float literal