Skip to content

Commit b2d34bf

Browse files
committed
Set flow direction
1 parent 2129a66 commit b2d34bf

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

lib/valueflow.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5861,9 +5861,9 @@ static void valueFlowSubFunction(const TokenList& tokenlist,
58615861
continue;
58625862
}
58635863

5864-
if (argvar->isReference() && isVariableChanged(argvar, settings)) {
5864+
if (argvar->isReference()) {
58655865
argvalues.remove_if([](const ValueFlow::Value& v) {
5866-
return !v.isUninitValue();
5866+
return v.isReverse();
58675867
});
58685868
}
58695869

lib/vf_analyzers.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1606,6 +1606,7 @@ ValuePtr<Analyzer> makeAnalyzer(const Token* exprTok, ValueFlow::Value value, co
16061606

16071607
ValuePtr<Analyzer> makeReverseAnalyzer(const Token* exprTok, ValueFlow::Value value, const Settings& settings)
16081608
{
1609+
value.setFlow(ValueFlow::Value::Flow::REVERSE);
16091610
if (value.isContainerSizeValue())
16101611
return ContainerExpressionAnalyzer(exprTok, std::move(value), settings);
16111612
return ExpressionAnalyzer(exprTok, std::move(value), settings);

lib/vfvalue.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828
namespace ValueFlow {
2929
Value::Value(const Token *c, MathLib::bigint val, Bound b)
30-
: bound(b),
30+
: valueType(ValueType::INT),
31+
bound(b),
32+
flow(Flow::UNKNOWN),
3133
safe(false),
3234
conditional(false),
3335
macro(false),

lib/vfvalue.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ namespace ValueFlow
4545
enum class Bound : std::uint8_t { Upper, Lower, Point };
4646

4747
explicit Value(MathLib::bigint val = 0, Bound b = Bound::Point) :
48+
valueType(ValueType::INT),
4849
bound(b),
50+
flow(Flow::UNKNOWN),
4951
safe(false),
5052
conditional(false),
5153
macro(false),
@@ -212,7 +214,7 @@ namespace ValueFlow
212214
ITERATOR_START,
213215
ITERATOR_END,
214216
SYMBOLIC
215-
} valueType = ValueType::INT;
217+
} valueType : 4;
216218
bool isIntValue() const {
217219
return valueType == ValueType::INT;
218220
}
@@ -267,7 +269,15 @@ namespace ValueFlow
267269
}
268270

269271
/** The value bound */
270-
Bound bound = Bound::Point;
272+
Bound bound : 2;
273+
274+
enum class Flow : std::uint8_t {
275+
UNKNOWN,
276+
FORWARD,
277+
REVERSE
278+
} flow : 2;
279+
bool isReverse() const { return flow == Flow::REVERSE; }
280+
void setFlow(Flow f) { flow = f; }
271281

272282
/** value relies on safe checking */
273283
// cppcheck-suppress premium-misra-cpp-2023-12.2.1

0 commit comments

Comments
 (0)