Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
Checks: '*,-abseil-*,-altera-*,-android-*,-cert-*,-cppcoreguidelines-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-modernize-use-override,-modernize-pass-by-value,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-misc-unused-using-decls,-modernize-use-emplace,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-modernize-use-equals-delete,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument'
Checks: '*,-abseil-*,-altera-*,-android-*,-cert-*,-cppcoreguidelines-*,-fuchsia-*,-google-*,-hicpp-*,-linuxkernel-*,-llvm-*,-llvmlibc-*,-mpi-*,-objc-*,-openmp-*,-zircon-*,-readability-braces-around-statements,-readability-magic-numbers,-bugprone-macro-parentheses,-readability-isolate-declaration,-readability-function-size,-modernize-use-trailing-return-type,-readability-implicit-bool-conversion,-readability-uppercase-literal-suffix,-modernize-use-auto,-readability-else-after-return,-modernize-use-default-member-init,-readability-named-parameter,-readability-redundant-member-init,-performance-faster-string-find,-modernize-avoid-c-arrays,-modernize-use-equals-default,-readability-container-size-empty,-readability-simplify-boolean-expr,-modernize-use-override,-modernize-pass-by-value,-bugprone-branch-clone,-bugprone-narrowing-conversions,-modernize-raw-string-literal,-readability-convert-member-functions-to-static,-modernize-loop-convert,-misc-unused-using-decls,-modernize-use-emplace,-readability-const-return-type,-performance-unnecessary-value-param,-modernize-return-braced-init-list,-performance-inefficient-string-concatenation,-misc-throw-by-value-catch-by-reference,-readability-avoid-const-params-in-decls,-readability-non-const-parameter,-misc-non-private-member-variables-in-classes,-bugprone-suspicious-string-compare,-clang-analyzer-*,-bugprone-signed-char-misuse,-readability-make-member-function-const,-misc-no-recursion,-readability-use-anyofallof,-performance-no-automatic-move,-bugprone-suspicious-include,-modernize-replace-random-shuffle,-readability-function-cognitive-complexity,-readability-redundant-access-specifiers,-modernize-use-equals-delete,-performance-noexcept-move-constructor,-concurrency-mt-unsafe,-bugprone-easily-swappable-parameters,-readability-suspicious-call-argument,-readability-identifier-length,-readability-container-data-pointer'
WarningsAsErrors: '*'
CheckOptions:
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/CI-unixish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
image: ["centos:7", "ubuntu:14.04", "ubuntu:16.04", "ubuntu:21.10"]
image: ["centos:7", "ubuntu:14.04", "ubuntu:16.04", "ubuntu:22.04"]
fail-fast: false # Prefer quick result

runs-on: ubuntu-20.04
Expand All @@ -23,19 +23,19 @@ jobs:
- name: Install missing software on CentOS 7
if: matrix.image == 'centos:7'
run: |
yum install -y cmake gcc-c++ make
yum install -y cmake gcc-c++ make which python3
yum install -y pcre-devel

- name: Install missing software on ubuntu
if: matrix.image != 'centos:7'
run: |
apt-get update
apt-get install -y cmake g++ make python libxml2-utils
apt-get install -y cmake g++ make python3 libxml2-utils
apt-get install -y libpcre3-dev

# tests require CMake 3.4
- name: Test CMake build (no tests)
if: matrix.image != 'ubuntu:21.10'
if: matrix.image != 'ubuntu:22.04'
run: |
mkdir cmake.output
cd cmake.output
Expand All @@ -44,7 +44,7 @@ jobs:
cd ..

- name: Test CMake build
if: matrix.image == 'ubuntu:21.10'
if: matrix.image == 'ubuntu:22.04'
run: |
mkdir cmake.output
cd cmake.output
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-20.04

container:
image: "ubuntu:21.10"
image: "ubuntu:22.04"

env:
ASAN_OPTIONS: detect_stack_use_after_return=1
Expand All @@ -27,13 +27,13 @@ jobs:
run: |
apt-get update
apt-get install -y make libpcre3-dev
apt-get install -y clang-13
apt-get install -y clang-14

- name: Build
run: make -j$(nproc) cppcheck testrunner HAVE_RULES=yes MATCHCOMPILER=yes VERIFY=1
env:
CC: clang-13
CXX: clang++-13
CC: clang-14
CXX: clang++-14
CXXFLAGS: "-fsanitize=address -O2 -g3 -DCPPCHK_GLIBCXX_DEBUG"
CPPFLAGS: "-DCHECK_INTERNAL"

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-20.04

container:
image: "ubuntu:21.10"
image: "ubuntu:22.04"

env:
QT_VERSION: 5.15.2
Expand All @@ -21,10 +21,10 @@ jobs:
- name: Install missing software
run: |
apt-get update
apt-get install -y cmake clang-13 make
apt-get install -y cmake clang-14 make
apt-get install -y libpcre3-dev
apt-get install -y libffi7 # work around missing dependency for Qt install step
apt-get install -y clang-tidy-13
apt-get install -y clang-tidy-14

- name: Cache Qt ${{ env.QT_VERSION }}
id: cache-qt
Expand All @@ -48,8 +48,8 @@ jobs:
cmake -G "Unix Makefiles" -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DWITH_QCHART=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCPPCHK_GLIBCXX_DEBUG=Off ..
cd ..
env:
CC: clang-13
CXX: clang++-13
CC: clang-14
CXX: clang++-14

- name: Prepare CMake dependencies
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ubsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-20.04

container:
image: "ubuntu:21.10"
image: "ubuntu:22.04"

env:
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
Expand All @@ -27,13 +27,13 @@ jobs:
run: |
apt-get update
apt-get install -y make libpcre3-dev
apt-get install -y clang-13
apt-get install -y clang-14

- name: Build
run: make -j$(nproc) cppcheck testrunner HAVE_RULES=yes MATCHCOMPILER=yes VERIFY=1
env:
CC: clang-13
CXX: clang++-13
CC: clang-14
CXX: clang++-14
CXXFLAGS: "-fsanitize=undefined -fsanitize=nullability -fno-sanitize=signed-integer-overflow -O2 -g3 -DCPPCHK_GLIBCXX_DEBUG"
CPPFLAGS: "-DCHECK_INTERNAL"

Expand Down
13 changes: 8 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ ifeq ($(SRCDIR),build)
endif
ifeq ($(MATCHCOMPILER),yes)
# Find available Python interpreter
ifndef PYTHON_INTERPRETER
ifeq ($(PYTHON_INTERPRETER),)
PYTHON_INTERPRETER := $(shell which python3)
endif
ifndef PYTHON_INTERPRETER
ifeq ($(PYTHON_INTERPRETER),)
PYTHON_INTERPRETER := $(shell which python)
endif
ifndef PYTHON_INTERPRETER
ifeq ($(PYTHON_INTERPRETER),)
$(error Did not find a Python interpreter)
endif
ifdef VERIFY
Expand Down Expand Up @@ -304,7 +304,7 @@ run-dmake: dmake
./dmake

clean:
rm -f build/*.o lib/*.o cli/*.o test/*.o tools/*.o externals/*/*.o testrunner dmake cppcheck cppcheck.exe cppcheck.1
rm -f build/*.cpp build/*.o lib/*.o cli/*.o test/*.o tools/*.o externals/*/*.o testrunner dmake cppcheck cppcheck.exe cppcheck.1

man: man/cppcheck.1

Expand Down Expand Up @@ -383,7 +383,10 @@ validateXML: createXMLExamples
xmllint --noout --relaxng cppcheck-errors.rng /tmp/example.xml

checkCWEEntries: /tmp/errorlist.xml
./tools/listErrorsWithoutCWE.py -F /tmp/errorlist.xml
$(eval PYTHON_INTERPRETER := $(if $(PYTHON_INTERPRETER),$(PYTHON_INTERPRETER),$(shell which python3)))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a very strong opinion but I think we can require python3 for this script. It's not something a normal user will run.

Copy link
Collaborator Author

@firewave firewave May 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As outlined in #3596 I think we can completely drop Python 2.7. We also already switched to the distro versions of Python so the CI coverage also exists. But that is also outlined in the other PR.

Also after this is merged we can hopefully merge #3596 as well and we default to Python 3.x everywhere.

I would give it a release cycle to sink in, adding deprecation warnings to the build at the start of the next dev cycle (2.9) and drop it in the one afterward (2.10).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I wonder what the motivation is to set PYTHON_INTERPRETER here. isn't it enough to use the shebang as we used to?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can specify the interpreter when running make:

PYTHON_INTERPRETER=/usr/local/bin/python3.11 make

So this is done for consistency. It will mainly be necessary for testing and MinGW on Windows if the interpreter is not in the PATH.

Before this change it was done once globally but only with MATCHCOMPILER=yes. Since that might not be set and we don't want to do it unconditionally I had to replicate this since I was not able to do it in conditional code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, until now those that used checkCweEntries was satisfied with the shebang path. It's a script that is used very rarelly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It also fails on platforms like Ubuntu 22.04 where python not longer exists by default and the shebang is not changed yet. The other way around it would fail if no Python 3 is installed by default like CentOS after the shebang is changed. So this is a required change to make the CI work.

$(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
Expand Down
2 changes: 1 addition & 1 deletion cmake/clang_tidy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if (NOT NPROC)
endif()
message(STATUS "NPROC=${NPROC}")

find_program(RUN_CLANG_TIDY NAMES run-clang-tidy run-clang-tidy-13 run-clang-tidy-12 run-clang-tidy-11 run-clang-tidy-10 run-clang-tidy-9 run-clang-tidy-8)
find_program(RUN_CLANG_TIDY NAMES run-clang-tidy 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)
message(STATUS "RUN_CLANG_TIDY=${RUN_CLANG_TIDY}")
if (RUN_CLANG_TIDY)
# disable all compiler warnings since we are just interested in the tidy ones
Expand Down
10 changes: 10 additions & 0 deletions cmake/compileroptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wsuggest-attribute=noreturn)
add_compile_options(-Wno-shadow) # whenever a local variable or type declaration shadows another one
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 14)
if (CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
# work around performance regression - see https://github.com/llvm/llvm-project/issues/53555
add_compile_options(-mllvm -inline-deferral)
endif()

# use force DWARF 4 debug format since not all tools might be able to handle DWARF 5 yet - e.g. valgrind on ubuntu 20.04
add_compile_options(-gdwarf-4)
endif()

add_compile_options_safe(-Wno-documentation-unknown-command)

Expand Down Expand Up @@ -86,6 +95,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options_safe(-Wno-tautological-type-limit-compare)
add_compile_options_safe(-Wno-unused-member-function)
add_compile_options(-Wno-disabled-macro-expansion)
add_compile_options_safe(-Wno-bitwise-instead-of-logical) # TODO: fix these

# warnings we are not interested in
add_compile_options(-Wno-four-char-constants)
Expand Down
16 changes: 11 additions & 5 deletions tools/dmake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,17 @@ int main(int argc, char **argv)
<< " $(warning Usage of SRCDIR to activate match compiler is deprecated. Use MATCHCOMPILER=yes instead.)\n"
<< " MATCHCOMPILER:=yes\n"
<< "endif\n";
// TODO: bail out when matchcompiler.py fails (i.e. invalid PYTHON_INTERPRETER specified)
// TODO: handle "PYTHON_INTERPRETER="
fout << "ifeq ($(MATCHCOMPILER),yes)\n"
<< " # Find available Python interpreter\n"
<< " ifndef PYTHON_INTERPRETER\n"
<< " ifeq ($(PYTHON_INTERPRETER),)\n"
<< " PYTHON_INTERPRETER := $(shell which python3)\n"
<< " endif\n"
<< " ifndef PYTHON_INTERPRETER\n"
<< " ifeq ($(PYTHON_INTERPRETER),)\n"
<< " PYTHON_INTERPRETER := $(shell which python)\n"
<< " endif\n"
<< " ifndef PYTHON_INTERPRETER\n"
<< " ifeq ($(PYTHON_INTERPRETER),)\n"
<< " $(error Did not find a Python interpreter)\n"
<< " endif\n"
<< " ifdef VERIFY\n"
Expand Down Expand Up @@ -424,7 +426,7 @@ int main(int argc, char **argv)
fout << "run-dmake: dmake\n";
fout << "\t./dmake\n\n";
fout << "clean:\n";
fout << "\trm -f build/*.o lib/*.o cli/*.o test/*.o tools/*.o externals/*/*.o testrunner dmake cppcheck cppcheck.exe cppcheck.1\n\n";
fout << "\trm -f build/*.cpp build/*.o lib/*.o cli/*.o test/*.o tools/*.o externals/*/*.o testrunner dmake cppcheck cppcheck.exe cppcheck.1\n\n";
fout << "man:\tman/cppcheck.1\n\n";
fout << "man/cppcheck.1:\t$(MAN_SOURCE)\n\n";
fout << "\t$(XP) $(DB2MAN) $(MAN_SOURCE)\n\n";
Expand Down Expand Up @@ -494,7 +496,11 @@ int main(int argc, char **argv)
fout << "\txmllint --noout --relaxng cppcheck-errors.rng /tmp/errorlist.xml\n";
fout << "\txmllint --noout --relaxng cppcheck-errors.rng /tmp/example.xml\n";
fout << "\ncheckCWEEntries: /tmp/errorlist.xml\n";
fout << "\t./tools/listErrorsWithoutCWE.py -F /tmp/errorlist.xml\n";
// TODO: handle "PYTHON_INTERPRETER="
fout << "\t$(eval PYTHON_INTERPRETER := $(if $(PYTHON_INTERPRETER),$(PYTHON_INTERPRETER),$(shell which python3)))\n";
fout << "\t$(eval PYTHON_INTERPRETER := $(if $(PYTHON_INTERPRETER),$(PYTHON_INTERPRETER),$(shell which python)))\n";
fout << "\t$(eval PYTHON_INTERPRETER := $(if $(PYTHON_INTERPRETER),$(PYTHON_INTERPRETER),$(error Did not find a Python interpreter)))\n";
fout << "\t$(PYTHON_INTERPRETER) tools/listErrorsWithoutCWE.py -F /tmp/errorlist.xml\n";
fout << ".PHONY: validateRules\n";
fout << "validateRules:\n";
fout << "\txmllint --noout rules/*.xml\n";
Expand Down
2 changes: 1 addition & 1 deletion tools/run_more_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if test -f ./bin/cppcheck; then
CPPCHECK=$(pwd)/bin/cppcheck
fi

python $DIR/extracttests.py --code=$(pwd)/test1 $1
python3 $DIR/extracttests.py --code=$(pwd)/test1 $1

cd test1

Expand Down
2 changes: 1 addition & 1 deletion tools/triage/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void MainWindow::showResult(QListWidgetItem *item)
const QStringList lines = item->text().split("\n");
if (lines.size() < 2)
return;
const QString url = lines[0];
const QString &url = lines[0];
QString msg = lines[1];
const QRegularExpressionMatch matchRes = mVersionRe.match(msg);
if (matchRes.hasMatch())
Expand Down