From e20fd30a8b0c99d02ddef9a510bec347c340c3ee Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 2 May 2025 11:19:26 +0200 Subject: [PATCH 1/2] CppCheck: small ID mapping cleanup in `analyseClangTidy()` --- lib/cppcheck.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index e514c9dc409..dec5bd54cd1 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1985,11 +1985,11 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings) for (const auto& id : splitString(errorString.substr(1, errorString.length() - 2), ',')) { errmsg.id = "clang-tidy-" + id; - if (errmsg.id.find("performance") != std::string::npos) + if (startsWith(id, "performance-")) errmsg.severity = Severity::performance; - else if (errmsg.id.find("portability") != std::string::npos) + else if (startsWith(id, "portability-")) errmsg.severity = Severity::portability; - else if (errmsg.id.find("cert") != std::string::npos || errmsg.id.find("misc") != std::string::npos || errmsg.id.find("unused") != std::string::npos) + else if (startsWith(id, "cert-") || startsWith(id, "misc-") || startsWith(id, "unused-")) errmsg.severity = Severity::warning; else errmsg.severity = Severity::style; From 6ad7f3e787b6df531f3482aecb56fcdd590a44b9 Mon Sep 17 00:00:00 2001 From: firewave Date: Fri, 2 May 2025 11:21:13 +0200 Subject: [PATCH 2/2] fixed #13829 - mapped `bugprone-*` clang-tidy findings to `warning` --- lib/cppcheck.cpp | 2 +- test/cli/other_test.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index dec5bd54cd1..d8be7be309d 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -1989,7 +1989,7 @@ void CppCheck::analyseClangTidy(const FileSettings &fileSettings) errmsg.severity = Severity::performance; else if (startsWith(id, "portability-")) errmsg.severity = Severity::portability; - else if (startsWith(id, "cert-") || startsWith(id, "misc-") || startsWith(id, "unused-")) + else if (startsWith(id, "cert-") || startsWith(id, "misc-") || startsWith(id, "bugprone-") || (id.find("-unused-") != std::string::npos)) errmsg.severity = Severity::warning; else errmsg.severity = Severity::style; diff --git a/test/cli/other_test.py b/test/cli/other_test.py index 31b1e27b97c..dd0f803f8e5 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -3464,7 +3464,7 @@ def test_clang_tidy_project(tmpdir): @pytest.mark.skipif(not has_clang_tidy, reason='clang-tidy is not available') -def test_clang_tidy_error_exit(tmp_path): # #13828 +def test_clang_tidy_error_exit(tmp_path): # #13828 / #13829 test_file = tmp_path / 'test.cpp' with open(test_file, 'wt') as f: f.write( @@ -3495,7 +3495,7 @@ def test_clang_tidy_error_exit(tmp_path): # #13828 exitcode, stdout, stderr = cppcheck(args) assert stdout.splitlines() == [] assert stderr.splitlines() == [ - "{}:10:12: style: 'str' used after it was moved [clang-tidy-bugprone-use-after-move]".format(test_file), + "{}:10:12: warning: 'str' used after it was moved [clang-tidy-bugprone-use-after-move]".format(test_file), "{}:10:12: style: 'str' used after it was moved [clang-tidy-hicpp-invalid-access-moved]".format(test_file) ] assert exitcode == 0, stdout