Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated CI to Clang 19 #5945

Merged
merged 15 commits into from
Jul 30, 2024
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
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Checks: >
-bugprone-signed-char-misuse,
-bugprone-switch-missing-default-case,
-bugprone-unchecked-optional-access,
-bugprone-unused-return-value,
-clang-analyzer-*,
-concurrency-mt-unsafe,
-misc-const-correctness,
Expand All @@ -48,6 +49,7 @@ Checks: >
-modernize-return-braced-init-list,
-modernize-type-traits,
-modernize-use-auto,
-modernize-use-designated-initializers,
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-performance-avoid-endl,
Expand All @@ -60,6 +62,7 @@ Checks: >
-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,
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/asan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
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 18
sudo ./llvm.sh 19

- name: Install Qt ${{ env.QT_VERSION }}
if: false
Expand All @@ -71,8 +71,8 @@ jobs:
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 -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env:
CC: clang-18
CXX: clang++-18
CC: clang-19
CXX: clang++-19

- name: Build cppcheck
run: |
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 @@ -37,8 +37,8 @@ jobs:
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 18
sudo apt-get install -y clang-tidy-18
sudo ./llvm.sh 19
sudo apt-get install -y clang-tidy-19

- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v3
Expand All @@ -49,14 +49,14 @@ jobs:

- name: Verify clang-tidy configuration
run: |
clang-tidy-18 --verify-config
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 -DENABLE_CHECK_INTERNAL=On -DCMAKE_GLOBAL_AUTOGEN_TARGET=On -DCPPCHK_GLIBCXX_DEBUG=Off
env:
CC: clang-18
CXX: clang++-18
CC: clang-19
CXX: clang++-19

- name: Prepare CMake dependencies
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/iwyu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ jobs:
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 18
sudo apt-get install -y clang-tools-18
sudo ./llvm.sh 19
sudo apt-get install -y clang-tools-19

- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v3
Expand All @@ -162,8 +162,8 @@ jobs:
run: |
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 -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
env:
CC: clang-18
CXX: clang++-18
CC: clang-19
CXX: clang++-19

- name: Prepare CMake dependencies
run: |
Expand All @@ -180,7 +180,7 @@ jobs:
- 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-18 --print=changes --extra-arg=-w -p cmake.output > clang-include-cleaner.log 2>&1
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 -p cmake.output > clang-include-cleaner.log 2>&1

- uses: actions/upload-artifact@v4
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
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 18
sudo ./llvm.sh 19

- name: Install Qt ${{ env.QT_VERSION }}
if: false
Expand All @@ -70,8 +70,8 @@ jobs:
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 -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-18
CXX: clang++-18
CC: clang-19
CXX: clang++-19

- name: Build cppcheck
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ubsan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
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 18
sudo ./llvm.sh 19

- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v3
Expand All @@ -70,8 +70,8 @@ jobs:
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 -DFILESDIR= -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env:
CC: clang-18
CXX: clang++-18
CC: clang-19
CXX: clang++-19

- name: Build cppcheck
run: |
Expand Down
9 changes: 6 additions & 3 deletions clang-tidy.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ We run this separately via `clang-include-cleaner` in the `iwyu.yml` workflow as
`performance-noexcept-swap`<br/>
`bugprone-switch-missing-default-case`<br/>
`bugprone-empty-catch`<br/>
`readability-avoid-nested-conditional-operator`</br>
`readability-avoid-nested-conditional-operator`<br/>
`modernize-use-designated-initializers`<br/>
`readability-enum-initial-value`<br/>

To be evaluated (need to remove exclusion).

Expand All @@ -140,11 +142,12 @@ To be evaluated (need to remove exclusion).
`cert-err33-c`<br/>
`google-readability-namespace-comments`<br/>
`cppcoreguidelines-special-member-functions`<br/>
`bugprone-unused-return-value`<br/>

To be evaluated (need to enable explicitly).

`modernize-type-traits`</br>
`modernize-use-nodiscard`</br>
`modernize-type-traits`<br/>
`modernize-use-nodiscard`<br/>

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.

Expand Down
2 changes: 1 addition & 1 deletion cli/signalhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

// TODO: __USE_DYNAMIC_STACK_SIZE is dependent on the features.h include and not a built-in compiler define, so it might be problematic to depend on it
#ifdef __USE_DYNAMIC_STACK_SIZE
static constexpr size_t MYSTACKSIZE = 16*1024+32768; // wild guess about a reasonable buffer
static constexpr size_t MYSTACKSIZE = (16*1024)+32768; // wild guess about a reasonable buffer
#else
static constexpr size_t MYSTACKSIZE = 16*1024+SIGSTKSZ; // wild guess about a reasonable buffer
#endif
Expand Down
2 changes: 1 addition & 1 deletion cmake/clang_tidy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,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")
endif()
else()
set(RUN_CLANG_TIDY_NAMES run-clang-tidy run-clang-tidy-18 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)
set(RUN_CLANG_TIDY_NAMES run-clang-tidy run-clang-tidy-19 run-clang-tidy-18 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()

if(RUN_CLANG_TIDY_NAMES)
Expand Down
4 changes: 2 additions & 2 deletions gui/codeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,9 @@ int CodeEditor::lineNumberAreaWidth()
}

#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
const int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits;
const int space = 3 + (fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits);
#else
const int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits;
const int space = 3 + (fontMetrics().width(QLatin1Char('9')) * digits);
#endif
return space;
}
Expand Down
6 changes: 2 additions & 4 deletions gui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,9 +1200,7 @@ QPair<bool,Settings> MainWindow::getCppcheckSettings()
result.standards.setC(mSettings->value(SETTINGS_STD_C, QString()).toString().toStdString());
result.enforcedLang = (Standards::Language)mSettings->value(SETTINGS_ENFORCED_LANGUAGE, 0).toInt();

if (result.jobs <= 1) {
result.jobs = 1;
}
result.jobs = std::max(result.jobs, 1u);

Settings::terminate(false);

Expand Down Expand Up @@ -2169,7 +2167,7 @@ static int getVersion(const QString& nameWithVersion) {
break;
if (c == ' ') {
if (ret > 0 && dot == 1 && nameWithVersion.endsWith(" dev"))
return ret * 1000000 + v * 1000 + 500;
return (ret * 1000000) + (v * 1000) + 500;
dot = ret = v = 0;
}
else if (c == '.') {
Expand Down
2 changes: 1 addition & 1 deletion gui/projectfiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
mUI->mBtnSafeClasses->setChecked(projectFile->safeChecks.classes);
setExcludedPaths(projectFile->getExcludedPaths());
setLibraries(projectFile->getLibraries());
const QString platform = projectFile->getPlatform();
const QString& platform = projectFile->getPlatform();
if (platform.endsWith(".xml")) {
int i;
for (i = numberOfBuiltinPlatforms; i < mUI->mComboBoxPlatform->count(); ++i) {
Expand Down
4 changes: 2 additions & 2 deletions gui/resultstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "threadhandler.h"
#include "xmlreportv2.h"

#include <algorithm>
#include <utility>
#include <vector>

Expand Down Expand Up @@ -849,8 +850,7 @@ void ResultsTree::contextMenuEvent(QContextMenuEvent * e)
if (mContextItem && mApplications->getApplicationCount() > 0 && mContextItem->parent()) {
//Create an action for the application
int defaultApplicationIndex = mApplications->getDefaultApplication();
if (defaultApplicationIndex < 0)
defaultApplicationIndex = 0;
defaultApplicationIndex = std::max(defaultApplicationIndex, 0);
const Application& app = mApplications->getApplication(defaultApplicationIndex);
auto *start = new QAction(app.getName(), &menu);
if (multipleSelection)
Expand Down
6 changes: 4 additions & 2 deletions gui/statsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "projectfile.h"
#include "showtypes.h"

#include <algorithm>

#include "ui_statsdialog.h"

#include <QApplication>
Expand Down Expand Up @@ -409,8 +411,8 @@ QChartView *createChart(const QString &statsFile, const QString &tool)
s->attachAxis(axisY);
if (const auto *ls = dynamic_cast<const QLineSeries*>(s)) {
for (QPointF p : ls->points()) {
if (p.y() > maxY)
maxY = p.y();
// cppcheck-suppress useStlAlgorithm - this would reduce the readability of the code
maxY = std::max(p.y(), maxY);
}
}
}
Expand Down
6 changes: 2 additions & 4 deletions gui/threadhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "resultsview.h"
#include "settings.h"

#include <algorithm>
#include <string>
#include <unordered_set>
#include <utility>
Expand Down Expand Up @@ -92,10 +93,7 @@ void ThreadHandler::check(const Settings &settings)
setThreadCount(settings.jobs);

mRunningThreadCount = mThreads.size();

if (mResults.getFileCount() < mRunningThreadCount) {
mRunningThreadCount = mResults.getFileCount();
}
mRunningThreadCount = std::min(mResults.getFileCount(), mRunningThreadCount);

QStringList addonsAndTools = mAddonsAndTools;
for (const std::string& addon: settings.addons) {
Expand Down
2 changes: 1 addition & 1 deletion lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ bool isTemporary(const Token* tok, const Library* library, bool unknown)
if (ftok->type())
return true;
if (library) {
std::string returnType = library->returnValueType(ftok);
const std::string& returnType = library->returnValueType(ftok);
return !returnType.empty() && returnType.back() != '&';
}
return unknown;
Expand Down
6 changes: 2 additions & 4 deletions lib/checkbufferoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,11 @@ static int getMinFormatStringOutputLength(const std::vector<const Token*> &param
if (formatString[i] == 's') {
// For strings, the length after the dot "%.2s" will limit
// the length of the string.
if (parameterLength > maxLen)
parameterLength = maxLen;
parameterLength = std::min(parameterLength, maxLen);
} else {
// For integers, the length after the dot "%.2d" can
// increase required length
if (tempDigits < maxLen)
tempDigits = maxLen;
tempDigits = std::max(tempDigits, maxLen);
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/checkersreport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "errortypes.h"
#include "settings.h"

#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_set>
Expand Down Expand Up @@ -151,11 +152,10 @@ std::string CheckersReport::getReport(const std::string& criticalErrors) const
fout << "Open source checkers" << std::endl;
fout << "--------------------" << std::endl;

int maxCheckerSize = 0;
std::size_t maxCheckerSize = 0;
for (const auto& checkReq: checkers::allCheckers) {
const std::string& checker = checkReq.first;
if (checker.size() > maxCheckerSize)
maxCheckerSize = checker.size();
maxCheckerSize = std::max(checker.size(), maxCheckerSize);
}
for (const auto& checkReq: checkers::allCheckers) {
const std::string& checker = checkReq.first;
Expand Down
2 changes: 1 addition & 1 deletion lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1771,7 +1771,7 @@ void CheckOther::constVariableError(const Variable *var, const Function *functio
}

const std::string vartype(var->isArgument() ? "Parameter" : "Variable");
const std::string varname(var->name());
const std::string& varname(var->name());
const std::string ptrRefArray = var->isArray() ? "const array" : (var->isPointer() ? "pointer to const" : "reference to const");

ErrorPath errorPath;
Expand Down
3 changes: 1 addition & 2 deletions lib/library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1438,8 +1438,7 @@ bool Library::matchArguments(const Token *ftok, const std::string &functionName)
int args = 0;
int firstOptionalArg = -1;
for (const std::pair<const int, Library::ArgumentChecks> & argCheck : it->second.argumentChecks) {
if (argCheck.first > args)
args = argCheck.first;
args = std::max(argCheck.first, args);
if (argCheck.second.optional && (firstOptionalArg == -1 || firstOptionalArg > argCheck.first))
firstOptionalArg = argCheck.first;

Expand Down
7 changes: 3 additions & 4 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,8 +1657,7 @@ void SymbolDatabase::createSymbolDatabaseExprIds()
// Find highest varId
nonneg int maximumVarId = 0;
for (const Token* tok = mTokenizer.list.front(); tok; tok = tok->next()) {
if (tok->varId() > maximumVarId)
maximumVarId = tok->varId();
maximumVarId = std::max(tok->varId(), maximumVarId);
}
nonneg int id = maximumVarId + 1;
// Find incomplete vars that are used in constant context
Expand Down Expand Up @@ -6123,7 +6122,7 @@ const Scope *SymbolDatabase::findScopeByName(const std::string& name) const
//---------------------------------------------------------------------------

template<class S, class T, REQUIRES("S must be a Scope class", std::is_convertible<S*, const Scope*> ), REQUIRES("T must be a Type class", std::is_convertible<T*, const Type*> )>
S* findRecordInNestedListImpl(S& thisScope, const std::string& name, bool isC, std::set<const Scope*>& visited)
static S* findRecordInNestedListImpl(S& thisScope, const std::string& name, bool isC, std::set<const Scope*>& visited)
{
for (S* scope: thisScope.nestedList) {
if (scope->className == name && scope->type != Scope::eFunction)
Expand Down Expand Up @@ -6172,7 +6171,7 @@ Scope* Scope::findRecordInNestedList(const std::string & name, bool isC)
//---------------------------------------------------------------------------

template<class S, class T, REQUIRES("S must be a Scope class", std::is_convertible<S*, const Scope*> ), REQUIRES("T must be a Type class", std::is_convertible<T*, const Type*> )>
T* findTypeImpl(S& thisScope, const std::string & name)
static T* findTypeImpl(S& thisScope, const std::string & name)
{
auto it = thisScope.definedTypesMap.find(name);

Expand Down
1 change: 1 addition & 0 deletions lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,7 @@ static bool removeContradiction(std::list<ValueFlow::Value>& values)
using ValueIterator = std::list<ValueFlow::Value>::iterator;

template<class Iterator>
// NOLINTNEXTLINE(performance-unnecessary-value-param) - false positive
static ValueIterator removeAdjacentValues(std::list<ValueFlow::Value>& values, ValueIterator x, Iterator start, Iterator last)
{
if (!isAdjacent(*x, **start))
Expand Down
Loading
Loading