Skip to content

Commit e3d2d90

Browse files
authored
vf_settokenvalue.cpp: reduced scope of some variables in setTokenValue() (#7754)
1 parent 98a168b commit e3d2d90

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/vf_settokenvalue.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -486,17 +486,15 @@ namespace ValueFlow
486486
continue;
487487
result.valueType = Value::ValueType::FLOAT;
488488
}
489-
const double floatValue1 = value1.isFloatValue() ? value1.floatValue : static_cast<double>(value1.intvalue);
490-
const double floatValue2 = value2.isFloatValue() ? value2.floatValue : static_cast<double>(value2.intvalue);
491489
const bool isFloat = value1.isFloatValue() || value2.isFloatValue();
490+
if (isFloat && Token::Match(parent, "&|^|%|<<|>>|==|!=|%or%"))
491+
continue;
492492
const auto intValue1 = [&]() -> MathLib::bigint {
493493
return value1.isFloatValue() ? static_cast<MathLib::bigint>(value1.floatValue) : value1.intvalue;
494494
};
495495
const auto intValue2 = [&]() -> MathLib::bigint {
496496
return value2.isFloatValue() ? static_cast<MathLib::bigint>(value2.floatValue) : value2.intvalue;
497497
};
498-
if ((value1.isFloatValue() || value2.isFloatValue()) && Token::Match(parent, "&|^|%|<<|>>|==|!=|%or%"))
499-
continue;
500498
if (Token::Match(parent, "==|!=")) {
501499
if ((value1.isIntValue() && value2.isTokValue()) || (value1.isTokValue() && value2.isIntValue())) {
502500
if (parent->str() == "==")
@@ -551,6 +549,8 @@ namespace ValueFlow
551549
}
552550
bool error = false;
553551
if (isFloat) {
552+
const double floatValue1 = value1.isFloatValue() ? value1.floatValue : static_cast<double>(value1.intvalue);
553+
const double floatValue2 = value2.isFloatValue() ? value2.floatValue : static_cast<double>(value2.intvalue);
554554
auto val = calculate(parent->str(), floatValue1, floatValue2, &error);
555555
if (result.isFloatValue()) {
556556
result.floatValue = val;

0 commit comments

Comments
 (0)