@@ -317,8 +317,8 @@ static void parseCompareEachInt(
317
317
const std::function<void (const Token* varTok, ValueFlow::Value true_value, ValueFlow::Value false_value)>& each)
318
318
{
319
319
parseCompareEachInt (tok, each, [](const Token* t) -> std::vector<ValueFlow::Value> {
320
- if (t->hasKnownIntValue ( ))
321
- return {*t-> getKnownValue (ValueFlow::Value::ValueType::INT) };
320
+ if (const ValueFlow::Value* v = t->getKnownValue (ValueFlow::Value::ValueType::INT ))
321
+ return {*v };
322
322
std::vector<ValueFlow::Value> result;
323
323
std::copy_if (t->values ().cbegin (), t->values ().cend (), std::back_inserter (result), [&](const ValueFlow::Value& v) {
324
324
if (v.path < 1 )
@@ -767,12 +767,12 @@ static void valueFlowArrayElement(TokenList& tokenlist, const Settings& settings
767
767
if (index < 0 || index >= args.size ())
768
768
continue ;
769
769
const Token* arg = args[static_cast <std::size_t >(index)];
770
- if (!arg->hasKnownIntValue ())
771
- continue ;
772
770
const ValueFlow::Value* v = arg->getKnownValue (ValueFlow::Value::ValueType::INT);
773
- result.intvalue = v->intvalue ;
774
- result.errorPath .insert (result.errorPath .end (), v->errorPath .cbegin (), v->errorPath .cend ());
775
- setTokenValue (tok, std::move (result), settings);
771
+ if (v) {
772
+ result.intvalue = v->intvalue ;
773
+ result.errorPath .insert (result.errorPath .end (), v->errorPath .cbegin (), v->errorPath .cend ());
774
+ setTokenValue (tok, std::move (result), settings);
775
+ }
776
776
}
777
777
}
778
778
}
@@ -1065,8 +1065,8 @@ static void valueFlowImpossibleValues(TokenList& tokenList, const Settings& sett
1065
1065
continue ;
1066
1066
std::vector<ValueFlow::Value> values;
1067
1067
for (const Token* tok2 : tokens) {
1068
- if (tok2->hasKnownIntValue ( )) {
1069
- values.emplace_back (*tok2-> getKnownValue (ValueFlow::Value::ValueType::INT) );
1068
+ if (const ValueFlow::Value* v = tok2->getKnownValue (ValueFlow::Value::ValueType::INT )) {
1069
+ values.emplace_back (*v );
1070
1070
} else {
1071
1071
ValueFlow::Value symValue{};
1072
1072
symValue.valueType = ValueFlow::Value::ValueType::SYMBOLIC;
@@ -3606,12 +3606,12 @@ static void valueFlowSymbolicOperators(const SymbolDatabase& symboldatabase, con
3606
3606
continue ;
3607
3607
const ValueFlow::Value* constant = nullptr ;
3608
3608
const Token* vartok = nullptr ;
3609
- if (tok->astOperand1 ()->hasKnownIntValue ( )) {
3610
- constant = tok-> astOperand1 ()-> getKnownValue (ValueFlow::Value::ValueType::INT) ;
3609
+ if (const ValueFlow::Value* v = tok->astOperand1 ()->getKnownValue (ValueFlow::Value::ValueType::INT )) {
3610
+ constant = v ;
3611
3611
vartok = tok->astOperand2 ();
3612
3612
}
3613
- if (tok->astOperand2 ()->hasKnownIntValue ( )) {
3614
- constant = tok-> astOperand2 ()-> getKnownValue (ValueFlow::Value::ValueType::INT) ;
3613
+ if (const ValueFlow::Value* v = tok->astOperand2 ()->getKnownValue (ValueFlow::Value::ValueType::INT )) {
3614
+ constant = v ;
3615
3615
vartok = tok->astOperand1 ();
3616
3616
}
3617
3617
if (!constant)
0 commit comments