@@ -1612,13 +1612,22 @@ static ExprEngine::ValuePtr executeBinaryOp(const Token *tok, Data &data)
16121612{
16131613 ExprEngine::ValuePtr v1 = executeExpression (tok->astOperand1 (), data);
16141614 ExprEngine::ValuePtr v2;
1615- if (tok->str () == " &&" || tok->str () == " ||" ) {
1615+
1616+ if (tok->str () == " ?" && tok->astOperand1 ()->hasKnownIntValue ()) {
1617+ if (tok->astOperand1 ()->getKnownIntValue ())
1618+ v2 = executeExpression (tok->astOperand2 ()->astOperand1 (), data);
1619+ else
1620+ v2 = executeExpression (tok->astOperand2 ()->astOperand2 (), data);
1621+ call (data.callbacks , tok, v2, &data);
1622+ return v2;
1623+ } else if (tok->str () == " &&" || tok->str () == " ||" ) {
16161624 Data data2 (data);
16171625 data2.addConstraint (v1, tok->str () == " &&" );
16181626 v2 = executeExpression (tok->astOperand2 (), data2);
16191627 } else {
16201628 v2 = executeExpression (tok->astOperand2 (), data);
16211629 }
1630+
16221631 if (v1 && v2) {
16231632 auto result = simplifyValue (std::make_shared<ExprEngine::BinOpResult>(tok->str (), v1, v2));
16241633 call (data.callbacks , tok, result, &data);
@@ -1917,6 +1926,9 @@ static void execute(const Token *start, const Token *end, Data &data)
19171926 if (changedVariables.find (varid) != changedVariables.end ())
19181927 continue ;
19191928 changedVariables.insert (varid);
1929+ auto oldValue = data.getValue (varid, nullptr , nullptr );
1930+ if (oldValue && oldValue->isUninit ())
1931+ call (data.callbacks , tok2->astOperand1 (), oldValue, &data);
19201932 data.assignValue (tok2, varid, getValueRangeFromValueType (data.getNewSymbolName (), tok2->astOperand1 ()->valueType (), *data.settings ));
19211933 } else if (Token::Match (tok2, " ++|--" ) && tok2->astOperand1 () && tok2->astOperand1 ()->variable ()) {
19221934 // give variable "any" value
@@ -1925,6 +1937,9 @@ static void execute(const Token *start, const Token *end, Data &data)
19251937 if (changedVariables.find (varid) != changedVariables.end ())
19261938 continue ;
19271939 changedVariables.insert (varid);
1940+ auto oldValue = data.getValue (varid, nullptr , nullptr );
1941+ if (oldValue && oldValue->type == ExprEngine::ValueType::UninitValue)
1942+ call (data.callbacks , tok2, oldValue, &data);
19281943 data.assignValue (tok2, varid, getValueRangeFromValueType (data.getNewSymbolName (), vartok->valueType (), *data.settings ));
19291944 }
19301945 }
@@ -2068,6 +2083,8 @@ void ExprEngine::executeFunction(const Scope *functionScope, ErrorLogger *errorL
20682083 try {
20692084 execute (functionScope->bodyStart , functionScope->bodyEnd , data);
20702085 } catch (VerifyException &e) {
2086+ if (settings->debugBugHunting )
2087+ report << " VerifyException tok.line:" << e.tok ->linenr () << " what:" << e.what << " \n " ;
20712088 trackExecution.setAbortLine (e.tok ->linenr ());
20722089 auto bailoutValue = std::make_shared<BailoutValue>();
20732090 for (const Token *tok = e.tok ; tok != functionScope->bodyEnd ; tok = tok->next ()) {
0 commit comments