Fix 10595: FN: std::vector() reserve() (#3581)
* Fix 10595: FN: std::vector() reserve() * Format
This commit is contained in:
parent
12e731ad49
commit
143ddf2758
|
@ -6850,12 +6850,12 @@ static bool isContainerSizeChanged(const Token* tok, const Settings* settings, i
|
|||
case Library::Container::Action::CHANGE:
|
||||
case Library::Container::Action::INSERT:
|
||||
case Library::Container::Action::ERASE:
|
||||
case Library::Container::Action::CHANGE_INTERNAL:
|
||||
return true;
|
||||
case Library::Container::Action::NO_ACTION: // might be unknown action
|
||||
return yield == Library::Container::Yield::NO_YIELD;
|
||||
case Library::Container::Action::FIND:
|
||||
case Library::Container::Action::CHANGE_CONTENT:
|
||||
case Library::Container::Action::CHANGE_INTERNAL:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5818,6 +5818,15 @@ private:
|
|||
" return v;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(true, tokenValues(code, "v [ 0 ] != 0 ) { }", ValueFlow::Value::ValueType::CONTAINER_SIZE).empty());
|
||||
|
||||
code = "std::vector<int> f() {\n"
|
||||
" std::vector<int> v;\n"
|
||||
" v.reserve(1);\n"
|
||||
" v[1] = 42;\n"
|
||||
" return v;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(
|
||||
"", isKnownContainerSizeValue(tokenValues(code, "v [", ValueFlow::Value::ValueType::CONTAINER_SIZE), 0));
|
||||
}
|
||||
|
||||
void valueFlowDynamicBufferSize() {
|
||||
|
|
Loading…
Reference in New Issue