File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1649,11 +1649,20 @@ void CheckCondition::alwaysTrueFalse()
16491649 }
16501650}
16511651
1652+ static std::string getConditionString (const Token* condition)
1653+ {
1654+ if (Token::simpleMatch (condition, " return" ))
1655+ return " Return value" ;
1656+ if (Token::simpleMatch (condition, " (" ) && Token::Match (condition->astParent (), " %assign" ))
1657+ return " Assigned value" ;
1658+ return " Condition" ;
1659+ }
1660+
16521661void CheckCondition::alwaysTrueFalseError (const Token* tok, const Token* condition, const ValueFlow::Value* value)
16531662{
16541663 const bool alwaysTrue = value && (value->intvalue != 0 || value->isImpossible ());
16551664 const std::string expr = tok ? tok->expressionString () : std::string (" x" );
1656- const std::string conditionStr = ( Token::simpleMatch ( condition, " return " ) ? " Return value " : " Condition " );
1665+ const std::string conditionStr = getConditionString ( condition);
16571666 const std::string errmsg = conditionStr + " '" + expr + " ' is always " + bool_to_string (alwaysTrue);
16581667 ErrorPath errorPath = getErrorPath (tok, value, errmsg);
16591668 reportError (std::move (errorPath),
You can’t perform that action at this time.
0 commit comments