Skip to content

Commit

Permalink
issue a message about analysis of condition expressions ebing disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Feb 23, 2024
1 parent f303757 commit 19b9a0d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 3 additions & 4 deletions lib/forwardanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ namespace {
} else if (tok->isControlFlowKeyword() && Token::Match(tok, "if|while|for (") &&
Token::simpleMatch(tok->next()->link(), ") {")) {
if (settings.checkLevel == Settings::CheckLevel::normal && ++branchCount > 4) {
reportError(Severity::information, "normalCheckLevelMaxBranches", "Limit analysis of branches. Use --check-level=exhaustive to analyze all branches.");
reportError(Severity::information, "normalCheckLevelMaxBranches", "Limiting analysis of branches. Use --check-level=exhaustive to analyze all branches.");
return Break(Analyzer::Terminate::Bail);
}
Token* endCond = tok->next()->link();
Expand Down Expand Up @@ -839,9 +839,8 @@ namespace {

void reportError(Severity severity, const std::string& id, const std::string& msg) {
if (errorLogger) {
const ErrorMessage::FileLocation loc(tokenList.getSourceFilePath(), 1, 1);
const std::list<ErrorMessage::FileLocation> callstack{loc};
const ErrorMessage errmsg(callstack, tokenList.getSourceFilePath(), severity, msg, id, Certainty::normal);
ErrorMessage::FileLocation loc(tokenList.getSourceFilePath(), 1, 1); // TODO: fix location
const ErrorMessage errmsg({std::move(loc)}, tokenList.getSourceFilePath(), severity, msg, id, Certainty::normal);
errorLogger->reportErr(errmsg);
}
}
Expand Down
8 changes: 7 additions & 1 deletion lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5329,8 +5329,14 @@ static const Scope* getLoopScope(const Token* tok)
//
static void valueFlowConditionExpressions(const TokenList &tokenlist, const SymbolDatabase& symboldatabase, ErrorLogger *errorLogger, const Settings &settings)
{
if (settings.checkLevel == Settings::CheckLevel::normal)
if (settings.checkLevel == Settings::CheckLevel::normal) {
if (errorLogger) {
ErrorMessage::FileLocation loc(tokenlist.getSourceFilePath(), 1, 1); // TODO: fix the location
const ErrorMessage errmsg({std::move(loc)}, tokenlist.getSourceFilePath(), Severity::information, "Analysis of condition expressions is disabled. Use --check-level=exhausive to enable it.", "normalCheckLevelConditionExpressions", Certainty::normal);
errorLogger->reportErr(errmsg);
}
return;
}

for (const Scope * scope : symboldatabase.functionScopes) {
if (const Token* incompleteTok = findIncompleteVar(scope->bodyStart, scope->bodyEnd)) {
Expand Down

0 comments on commit 19b9a0d

Please sign in to comment.