From 39c118f27b0d485040ea29b41d42e4bb3e2339d9 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 21 Jul 2025 12:53:15 +0200 Subject: [PATCH 1/3] Update forwardanalyzer.cpp --- lib/forwardanalyzer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/forwardanalyzer.cpp b/lib/forwardanalyzer.cpp index 7b33af8d6ba..99d01fc931c 100644 --- a/lib/forwardanalyzer.cpp +++ b/lib/forwardanalyzer.cpp @@ -682,7 +682,7 @@ namespace { } } else if (tok->isControlFlowKeyword() && Token::Match(tok, "if|while|for (") && Token::simpleMatch(tok->linkAt(1), ") {")) { - if ((settings.vfOptions.maxForwardBranches > 0) && (++branchCount > settings.vfOptions.maxForwardBranches)) { + if (settings.severity.isEnabled(Severity::information) && (settings.vfOptions.maxForwardBranches > 0) && (++branchCount > settings.vfOptions.maxForwardBranches)) { // TODO: should be logged on function-level instead of file-level reportError(Severity::information, "normalCheckLevelMaxBranches", "Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches."); return Break(Analyzer::Terminate::Bail); From fbc814a68035f75d461447818d3c6956d6bd292d Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 21 Jul 2025 12:56:14 +0200 Subject: [PATCH 2/3] Update other_test.py --- test/cli/other_test.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/cli/other_test.py b/test/cli/other_test.py index db057dcaf46..f50f8d1f74c 100644 --- a/test/cli/other_test.py +++ b/test/cli/other_test.py @@ -2038,6 +2038,17 @@ def test_builddir_hash_check_level(tmp_path): # #13376 build_dir = tmp_path / 'b1' os.mkdir(build_dir) + args = [ # // #14029 + '--enable=warning', # to execute the code which generates the normalCheckLevelMaxBranches message + '--cppcheck-build-dir={}'.format(build_dir), + '--template=simple', + str(test_file) + ] + + exitcode, stdout, stderr = cppcheck(args) + assert exitcode == 0, stdout + assert stderr == '' + args = [ '--enable=warning', # to execute the code which generates the normalCheckLevelMaxBranches message '--enable=information', # to show the normalCheckLevelMaxBranches message From b1c1ef2aa74db1899665568f8ff93e175802953e Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 21 Jul 2025 13:16:11 +0200 Subject: [PATCH 3/3] Update forwardanalyzer.cpp --- lib/forwardanalyzer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/forwardanalyzer.cpp b/lib/forwardanalyzer.cpp index 99d01fc931c..ebdfc70a50d 100644 --- a/lib/forwardanalyzer.cpp +++ b/lib/forwardanalyzer.cpp @@ -682,9 +682,11 @@ namespace { } } else if (tok->isControlFlowKeyword() && Token::Match(tok, "if|while|for (") && Token::simpleMatch(tok->linkAt(1), ") {")) { - if (settings.severity.isEnabled(Severity::information) && (settings.vfOptions.maxForwardBranches > 0) && (++branchCount > settings.vfOptions.maxForwardBranches)) { + if ((settings.vfOptions.maxForwardBranches > 0) && (++branchCount > settings.vfOptions.maxForwardBranches)) { // TODO: should be logged on function-level instead of file-level - reportError(Severity::information, "normalCheckLevelMaxBranches", "Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches."); + if (settings.severity.isEnabled(Severity::information)) { + reportError(Severity::information, "normalCheckLevelMaxBranches", "Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches."); + } return Break(Analyzer::Terminate::Bail); } Token* endCond = tok->linkAt(1);