ValueFlow: Better errorpath for increment/decrement
This commit is contained in:
parent
bab2b26d10
commit
b1b8e5270a
|
@ -1837,6 +1837,8 @@ static bool valueFlowForward(Token * const startToken,
|
|||
it->intvalue += (inc ? 1 : -1);
|
||||
if (pre)
|
||||
setTokenValue(op, *it, settings);
|
||||
const std::string info(tok2->str() + " is " + std::string(inc ? "incremented" : "decremented") + "', new value is " + it->infoString());
|
||||
it->errorPath.push_back(ErrorPathItem(tok2, info));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1067,6 +1067,9 @@ private:
|
|||
"}";
|
||||
ASSERT_EQUALS(false, testValueOfX(code, 4U, 9));
|
||||
ASSERT_EQUALS(true, testValueOfX(code, 4U, 8));
|
||||
ASSERT_EQUALS("2,Assignment 'x=9', assigned value is 9\n"
|
||||
"3,x is decremented', new value is 8\n",
|
||||
getErrorPathForX(code, 4U));
|
||||
|
||||
code = "void x() {\n"
|
||||
" int x = value ? 6 : 0;\n"
|
||||
|
|
Loading…
Reference in New Issue