Skip to content

Commit bb980a0

Browse files
committed
valueflow.h: small cleanup
1 parent 5f67cc4 commit bb980a0

2 files changed

Lines changed: 11 additions & 18 deletions

File tree

lib/token.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@
4545
#include <unordered_set>
4646
#include <utility>
4747

48+
struct less {
49+
template<class T, class U>
50+
bool operator()(const T& x, const U& y) const {
51+
return x < y;
52+
}
53+
};
54+
4855
const std::list<ValueFlow::Value> TokenImpl::mEmptyValueList;
4956

5057
Token::Token(TokensFrontBack *tokensFrontBack) :
@@ -1921,7 +1928,7 @@ static bool removeContradiction(std::list<ValueFlow::Value>& values)
19211928
continue;
19221929
if (!x.equalValue(y)) {
19231930
auto compare = [](const ValueFlow::Value& x, const ValueFlow::Value& y) {
1924-
return x.compareValue(y, ValueFlow::less{});
1931+
return x.compareValue(y, less{});
19251932
};
19261933
const ValueFlow::Value& maxValue = std::max(x, y, compare);
19271934
const ValueFlow::Value& minValue = std::min(x, y, compare);
@@ -2012,9 +2019,9 @@ static void mergeAdjacent(std::list<ValueFlow::Value>& values)
20122019
if (y->bound != ValueFlow::Value::Bound::Point)
20132020
continue;
20142021
}
2015-
if (x->bound == ValueFlow::Value::Bound::Lower && !y->compareValue(*x, ValueFlow::less{}))
2022+
if (x->bound == ValueFlow::Value::Bound::Lower && !y->compareValue(*x, less{}))
20162023
continue;
2017-
if (x->bound == ValueFlow::Value::Bound::Upper && !x->compareValue(*y, ValueFlow::less{}))
2024+
if (x->bound == ValueFlow::Value::Bound::Upper && !x->compareValue(*y, less{}))
20182025
continue;
20192026
adjValues.push_back(y);
20202027
}
@@ -2025,7 +2032,7 @@ static void mergeAdjacent(std::list<ValueFlow::Value>& values)
20252032
std::sort(adjValues.begin(), adjValues.end(), [&values](ValueIterator xx, ValueIterator yy) {
20262033
(void)values;
20272034
assert(xx != values.end() && yy != values.end());
2028-
return xx->compareValue(*yy, ValueFlow::less{});
2035+
return xx->compareValue(*yy, less{});
20292036
});
20302037
if (x->bound == ValueFlow::Value::Bound::Lower)
20312038
x = removeAdjacentValues(values, x, adjValues.rbegin(), adjValues.rend());

lib/valueflow.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,6 @@ template<class T>
4646
class ValuePtr;
4747

4848
namespace ValueFlow {
49-
struct less {
50-
template<class T, class U>
51-
bool operator()(const T& x, const U& y) const {
52-
return x < y;
53-
}
54-
};
55-
56-
struct adjacent {
57-
template<class T, class U>
58-
bool operator()(const T& x, const U& y) const {
59-
return std::abs(x - y) == 1;
60-
}
61-
};
62-
6349
/// Constant folding of expression. This can be used before the full ValueFlow has been executed (ValueFlow::setValues).
6450
const ValueFlow::Value * valueFlowConstantFoldAST(Token *expr, const Settings *settings);
6551

0 commit comments

Comments
 (0)