Fix 11162: FP: knownConditionTrueFalse (#4254)
* Fix 11162: FP: knownConditionTrueFalse * Format
This commit is contained in:
parent
b51aea5531
commit
0b63e7273d
|
@ -684,7 +684,7 @@ static void setTokenValue(Token* tok,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value.isContainerSizeValue()) {
|
if (value.isContainerSizeValue() && astIsContainer(tok)) {
|
||||||
// .empty, .size, +"abc", +'a'
|
// .empty, .size, +"abc", +'a'
|
||||||
if (Token::Match(parent, "+|==|!=") && parent->astOperand1() && parent->astOperand2()) {
|
if (Token::Match(parent, "+|==|!=") && parent->astOperand1() && parent->astOperand2()) {
|
||||||
for (const ValueFlow::Value &value1 : parent->astOperand1()->values()) {
|
for (const ValueFlow::Value &value1 : parent->astOperand1()->values()) {
|
||||||
|
|
|
@ -6266,6 +6266,14 @@ private:
|
||||||
" v.size();\n"
|
" v.size();\n"
|
||||||
"}";
|
"}";
|
||||||
ASSERT_EQUALS("", isKnownContainerSizeValue(tokenValues(code, "v . size"), 3));
|
ASSERT_EQUALS("", isKnownContainerSizeValue(tokenValues(code, "v . size"), 3));
|
||||||
|
|
||||||
|
code = "int f() {\n"
|
||||||
|
" std::vector<std::vector<int>> v;\n"
|
||||||
|
" auto it = v.begin();\n"
|
||||||
|
" auto x = it->size();\n"
|
||||||
|
" return x;\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS(false, testValueOfX(code, 5U, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowDynamicBufferSize() {
|
void valueFlowDynamicBufferSize() {
|
||||||
|
|
Loading…
Reference in New Issue