parent
597d0fa35b
commit
b55c587ab2
|
@ -1229,7 +1229,9 @@ bool isVariablesChanged(const Token* start,
|
|||
std::transform(vars.begin(), vars.end(), std::inserter(varids, varids.begin()), [](const Variable* var) {
|
||||
return var->declarationId();
|
||||
});
|
||||
const bool globalvar = std::any_of(vars.begin(), vars.end(), [](const Variable* var) { return var->isGlobal(); });
|
||||
const bool globalvar = std::any_of(vars.begin(), vars.end(), [](const Variable* var) {
|
||||
return var->isGlobal();
|
||||
});
|
||||
for (const Token* tok = start; tok != end; tok = tok->next()) {
|
||||
if (tok->varId() == 0 || varids.count(tok->varId()) == 0) {
|
||||
if (globalvar && Token::Match(tok, "%name% ("))
|
||||
|
|
|
@ -3124,15 +3124,21 @@ const Token* solveExprValues(const Token* expr, std::list<ValueFlow::Value>& val
|
|||
if (binaryTok && expr->str().size() == 1) {
|
||||
switch (expr->str()[0]) {
|
||||
case '+': {
|
||||
transformIntValues(values, [&](MathLib::bigint x) { return x - intval; });
|
||||
transformIntValues(values, [&](MathLib::bigint x) {
|
||||
return x - intval;
|
||||
});
|
||||
return solveExprValues(binaryTok, values);
|
||||
}
|
||||
case '*': {
|
||||
transformIntValues(values, [&](MathLib::bigint x) { return x / intval; });
|
||||
transformIntValues(values, [&](MathLib::bigint x) {
|
||||
return x / intval;
|
||||
});
|
||||
return solveExprValues(binaryTok, values);
|
||||
}
|
||||
case '^': {
|
||||
transformIntValues(values, [&](MathLib::bigint x) { return x ^ intval; });
|
||||
transformIntValues(values, [&](MathLib::bigint x) {
|
||||
return x ^ intval;
|
||||
});
|
||||
return solveExprValues(binaryTok, values);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2309,8 +2309,7 @@ private:
|
|||
ASSERT_EQUALS(true, testValueOfX(code, 6U, 0));
|
||||
}
|
||||
|
||||
void valueFlowAfterConditionExpr()
|
||||
{
|
||||
void valueFlowAfterConditionExpr() {
|
||||
const char* code;
|
||||
|
||||
code = "void f(int* p) {\n"
|
||||
|
|
Loading…
Reference in New Issue