diff --git a/.clang-tidy b/.clang-tidy
index b0f8a59348f..0b130f31de0 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -39,7 +39,6 @@ Checks: >
-misc-use-anonymous-namespace,
-modernize-avoid-c-arrays,
-modernize-deprecated-ios-base-aliases,
- -modernize-use-nullptr,
-misc-include-cleaner,
-misc-unused-using-decls,
-modernize-loop-convert,
@@ -52,12 +51,14 @@ Checks: >
-modernize-use-nodiscard,
-modernize-use-trailing-return-type,
-performance-avoid-endl,
+ -performance-enum-size,
-performance-inefficient-string-concatenation,
-performance-no-automatic-move,
-performance-noexcept-swap,
-portability-simd-intrinsics,
-portability-std-allocator-const,
-readability-avoid-const-params-in-decls,
+ -readability-avoid-nested-conditional-operator,
-readability-braces-around-statements,
-readability-container-data-pointer,
-readability-function-cognitive-complexity,
diff --git a/.github/workflows/asan.yml b/.github/workflows/asan.yml
index a1210b9b94e..19a3c802736 100644
--- a/.github/workflows/asan.yml
+++ b/.github/workflows/asan.yml
@@ -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 17
+ sudo ./llvm.sh 18
- name: Install Qt ${{ env.QT_VERSION }}
if: false
@@ -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_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:
- CC: clang-17
- CXX: clang++-17
+ CC: clang-18
+ CXX: clang++-18
- name: Build cppcheck
run: |
diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml
index 59d40952009..90d04acd10f 100644
--- a/.github/workflows/clang-tidy.yml
+++ b/.github/workflows/clang-tidy.yml
@@ -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 17
- sudo apt-get install -y clang-tidy-17
+ sudo ./llvm.sh 18
+ sudo apt-get install -y clang-tidy-18
- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v3
@@ -49,14 +49,14 @@ jobs:
- name: Verify clang-tidy configuration
run: |
- clang-tidy-17 --verify-config
+ clang-tidy-18 --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-17
- CXX: clang++-17
+ CC: clang-18
+ CXX: clang++-18
- name: Prepare CMake dependencies
run: |
diff --git a/.github/workflows/iwyu.yml b/.github/workflows/iwyu.yml
index f52895e6f48..ac672d70d7e 100644
--- a/.github/workflows/iwyu.yml
+++ b/.github/workflows/iwyu.yml
@@ -128,8 +128,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 17
- sudo apt-get install -y clang-tools-17
+ sudo ./llvm.sh 18
+ sudo apt-get install -y clang-tools-18
- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v3
@@ -142,8 +142,8 @@ jobs:
run: |
cmake -S . -B cmake.output -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DHAVE_RULES=On -DBUILD_TESTS=On -DBUILD_GUI=On -DBUILD_TESTS=On -DBUILD_GUI=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-17
- CXX: clang++-17
+ CC: clang-18
+ CXX: clang++-18
- name: Prepare CMake dependencies
run: |
@@ -160,7 +160,7 @@ jobs:
- name: clang-include-cleaner
run: |
# TODO: run multi-threaded
- find $PWD/cli $PWD/lib $PWD/test -maxdepth 1 -name "*.cpp" | xargs -t -n 1 clang-include-cleaner-17 --print=changes --extra-arg=-w -p cmake.output > clang-include-cleaner.log 2>&1
+ find $PWD/cli $PWD/lib $PWD/test -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
- uses: actions/upload-artifact@v3
with:
diff --git a/.github/workflows/tsan.yml b/.github/workflows/tsan.yml
index 949fd7b7552..19cb99bf78f 100644
--- a/.github/workflows/tsan.yml
+++ b/.github/workflows/tsan.yml
@@ -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 17
+ sudo ./llvm.sh 18
- name: Install Qt ${{ env.QT_VERSION }}
if: false
@@ -69,8 +69,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 -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:
- CC: clang-17
- CXX: clang++-17
+ CC: clang-18
+ CXX: clang++-18
- name: Build cppcheck
run: |
diff --git a/.github/workflows/ubsan.yml b/.github/workflows/ubsan.yml
index 8dbae3238da..ef22f9a2ba2 100644
--- a/.github/workflows/ubsan.yml
+++ b/.github/workflows/ubsan.yml
@@ -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 17
+ sudo ./llvm.sh 18
- name: Install Qt ${{ env.QT_VERSION }}
uses: jurplel/install-qt-action@v3
@@ -69,8 +69,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 -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
env:
- CC: clang-17
- CXX: clang++-17
+ CC: clang-18
+ CXX: clang++-18
- name: Build cppcheck
run: |
diff --git a/clang-tidy.md b/clang-tidy.md
index a1abd9a5f5c..108af31a354 100644
--- a/clang-tidy.md
+++ b/clang-tidy.md
@@ -129,6 +129,8 @@ We run this separately via `clang-include-cleaner` in the `iwyu.yml` workflow as
`performance-noexcept-swap`
`bugprone-switch-missing-default-case`
`bugprone-empty-catch`
+`performance-enum-size`
+`readability-avoid-nested-conditional-operator`
To be evaluated (need to remove exclusion).
@@ -185,10 +187,6 @@ It does not seem to produce any warnings for us (needs to be investigated) and i
This is the most expensive check for several files and it is providing much in terms of code quality. Reported upstream as https://github.com/llvm/llvm-project/issues/72300.
-`modernize-use-nullptr`
-
-This is already covered by the `-Wzero-as-null-pointer-constant` compiler warning so there is no need for an additional check.
-
### Disabled for GUI only
`readability-convert-member-functions-to-static`
diff --git a/cli/stacktrace.cpp b/cli/stacktrace.cpp
index d58045e308b..40a350d28fc 100644
--- a/cli/stacktrace.cpp
+++ b/cli/stacktrace.cpp
@@ -85,6 +85,7 @@ void print_stacktrace(FILE* output, bool demangling, int maxdepth, bool lowMem)
(int)(firstBracketAddress-symbolString), symbolString);
}
}
+ // NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion) - code matches the documented usage
free(symbolStringList);
} else {
fputs("Callstack could not be obtained\n", output);
diff --git a/cmake/clang_tidy.cmake b/cmake/clang_tidy.cmake
index ec86c11c169..34f0bb422e1 100644
--- a/cmake/clang_tidy.cmake
+++ b/cmake/clang_tidy.cmake
@@ -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-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-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)
diff --git a/cmake/compilerDefinitions.cmake b/cmake/compilerDefinitions.cmake
index 7369554e91d..8ff3ba1d432 100644
--- a/cmake/compilerDefinitions.cmake
+++ b/cmake/compilerDefinitions.cmake
@@ -10,11 +10,17 @@ if (MSVC)
add_definitions(-D_WIN64)
endif()
-# TODO: this should probably apply to the compiler and not the platform
+# TODO: this should probably apply to the compiler and not the platform - I think it is only "broken" with MinGW
+# TODO: AppleClang only has libc++
+# TODO: what about clang-cl and native Win32 clang?
if (CPPCHK_GLIBCXX_DEBUG AND UNIX AND CMAKE_BUILD_TYPE STREQUAL "Debug")
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (USE_LIBCXX)
- add_definitions(-D_LIBCPP_ENABLE_ASSERTIONS=1)
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 18 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 18)
+ add_definitions(-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG)
+ else()
+ add_definitions(-D_LIBCPP_ENABLE_ASSERTIONS=1)
+ endif()
# TODO: also add _LIBCPP_ENABLE_THREAD_SAFETY_ANNOTATIONS?
endif()
else()
diff --git a/cmake/compileroptions.cmake b/cmake/compileroptions.cmake
index e0a4011ca36..960016d43e3 100644
--- a/cmake/compileroptions.cmake
+++ b/cmake/compileroptions.cmake
@@ -107,6 +107,7 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options_safe(-Wno-date-time)
add_compile_options(-Wno-disabled-macro-expansion)
add_compile_options_safe(-Wno-bitwise-instead-of-logical)
+ add_compile_options_safe(-Wno-switch-default)
# these cannot be fixed properly without adopting later C++ standards
add_compile_options_safe(-Wno-unsafe-buffer-usage)
diff --git a/lib/clangimport.cpp b/lib/clangimport.cpp
index ea44d5e6699..0f83af6d697 100644
--- a/lib/clangimport.cpp
+++ b/lib/clangimport.cpp
@@ -1466,7 +1466,7 @@ void clangimport::AstNode::createTokensForCXXRecord(TokenList &tokenList)
const_cast(classToken->scope())->definedTypesMap[className] = scope->definedType;
}
addtoken(tokenList, ";");
- const_cast(tokenList.back())->scope(classToken->scope());
+ tokenList.back()->scope(classToken->scope());
}
Token * clangimport::AstNode::createTokensVarDecl(TokenList &tokenList)
diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp
index a454d5c0951..474f6ef45bb 100644
--- a/lib/symboldatabase.cpp
+++ b/lib/symboldatabase.cpp
@@ -1196,7 +1196,7 @@ void SymbolDatabase::fixVarId(VarIdMap & varIds, const Token * vartok, Token * m
if (varId == varIds.end()) {
MemberIdMap memberId;
if (membertok->varId() == 0) {
- memberId[membervar->nameToken()->varId()] = const_cast(mTokenizer).newVarId();
+ memberId[membervar->nameToken()->varId()] = mTokenizer.newVarId();
mVariableList.push_back(membervar);
} else
mVariableList[membertok->varId()] = membervar;
@@ -1206,7 +1206,7 @@ void SymbolDatabase::fixVarId(VarIdMap & varIds, const Token * vartok, Token * m
MemberIdMap::iterator memberId = varId->second.find(membervar->nameToken()->varId());
if (memberId == varId->second.end()) {
if (membertok->varId() == 0) {
- varId->second.insert(std::make_pair(membervar->nameToken()->varId(), const_cast(mTokenizer).newVarId()));
+ varId->second.insert(std::make_pair(membervar->nameToken()->varId(), mTokenizer.newVarId()));
mVariableList.push_back(membervar);
memberId = varId->second.find(membervar->nameToken()->varId());
} else
@@ -1766,7 +1766,7 @@ void SymbolDatabase::createSymbolDatabaseExprIds()
// Mark expressions that are unique
std::vector> uniqueExprId(id);
- for (Token* tok = const_cast(mTokenizer.list.front()); tok; tok = tok->next()) {
+ for (Token* tok = mTokenizer.list.front(); tok; tok = tok->next()) {
const auto id2 = tok->exprId();
if (id2 == 0 || id2 <= maximumVarId)
continue;
@@ -2982,7 +2982,7 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
if (Token::simpleMatch(second->next(), param.c_str(), param.size())) {
// check for redundant qualification before skipping it
if (!Token::simpleMatch(first->next(), param.c_str(), param.size())) {
- second = second->tokAt(int(arg_path_length));
+ second = second->tokAt(arg_path_length);
arg_path_length = 0;
}
}
@@ -7263,7 +7263,7 @@ static const Function* getFunction(const Token* tok) {
void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *tokens)
{
if (!tokens)
- tokens = const_cast(mTokenizer).list.front();
+ tokens = mTokenizer.list.front();
for (Token *tok = tokens; tok; tok = tok->next())
tok->setValueType(nullptr);
diff --git a/lib/symboldatabase.h b/lib/symboldatabase.h
index e1ef8d0051c..5d9234bd237 100644
--- a/lib/symboldatabase.h
+++ b/lib/symboldatabase.h
@@ -1003,7 +1003,7 @@ class CPPCHECKLIB Function {
setFlag(fIsVolatile, state);
}
void hasTrailingReturnType(bool state) {
- return setFlag(fHasTrailingReturnType, state);
+ setFlag(fHasTrailingReturnType, state);
}
void isInlineKeyword(bool state) {
setFlag(fIsInlineKeyword, state);
diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp
index b7865d78b1c..e425095d28c 100644
--- a/lib/valueflow.cpp
+++ b/lib/valueflow.cpp
@@ -6302,7 +6302,7 @@ struct ConditionHandler {
const Settings& settings,
SourceLocation loc = SourceLocation::current()) const
{
- return valueFlowReverse(start, endToken, exprTok, values, tokenlist, errorLogger, settings, loc);
+ valueFlowReverse(start, endToken, exprTok, values, tokenlist, errorLogger, settings, loc);
}
void traverseCondition(const TokenList& tokenlist,