Fix FP when inserting a range into a container (#3108)
This commit is contained in:
parent
dc63dd6ada
commit
913dbeb8d8
|
@ -5736,8 +5736,11 @@ struct ContainerVariableAnalyzer : VariableAnalyzer {
|
||||||
}
|
}
|
||||||
} else if (Token::Match(tok, "%name% . %name% (")) {
|
} else if (Token::Match(tok, "%name% . %name% (")) {
|
||||||
Library::Container::Action action = tok->valueType()->container->getAction(tok->strAt(2));
|
Library::Container::Action action = tok->valueType()->container->getAction(tok->strAt(2));
|
||||||
if (action == Library::Container::Action::PUSH || action == Library::Container::Action::POP)
|
if (action == Library::Container::Action::PUSH || action == Library::Container::Action::POP) {
|
||||||
return Action::Read | Action::Write | Action::Incremental;
|
std::vector<const Token*> args = getArguments(tok->tokAt(3));
|
||||||
|
if (args.size() < 2)
|
||||||
|
return Action::Read | Action::Write | Action::Incremental;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Action::None;
|
return Action::None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5025,6 +5025,15 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
"}\n";
|
"}\n";
|
||||||
ASSERT_EQUALS(true, testValueOfXKnown(code, 4U, 0));
|
ASSERT_EQUALS(true, testValueOfXKnown(code, 4U, 0));
|
||||||
|
|
||||||
|
code = "std::vector<int> g();\n"
|
||||||
|
"int f(bool b) {\n"
|
||||||
|
" std::set<int> a;\n"
|
||||||
|
" std::vector<int> c = g();\n"
|
||||||
|
" a.insert(c.begin(), c.end());\n"
|
||||||
|
" return a.size();\n"
|
||||||
|
"}\n";
|
||||||
|
ASSERT_EQUALS(true, tokenValues(code, "a . size", ValueFlow::Value::ValueType::CONTAINER_SIZE).empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowDynamicBufferSize() {
|
void valueFlowDynamicBufferSize() {
|
||||||
|
|
Loading…
Reference in New Issue