Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/checkstl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ static const ValueFlow::Value* getInnerLifetime(const Token* tok,
if (!tok)
return nullptr;
for (const ValueFlow::Value& val : tok->values()) {
if (!val.isLocalLifetimeValue())
if (!val.isLocalLifetimeValue() && !val.isArgumentLifetimeValue())
continue;
if (contains({ValueFlow::Value::LifetimeKind::Address,
ValueFlow::Value::LifetimeKind::SubObject,
Expand Down
2 changes: 1 addition & 1 deletion lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,7 @@ static std::vector<ValueFlow::LifetimeToken> getLifetimeTokens(const Token* tok,
if (Token::Match(tok->tokAt(-2), ". %name% (") && tok->tokAt(-2)->originalName() != "->" && astIsContainer(tok->tokAt(-2)->astOperand1())) {
const Library::Container* library = getLibraryContainer(tok->tokAt(-2)->astOperand1());
const Library::Container::Yield y = library->getYield(tok->strAt(-1));
if (y == Library::Container::Yield::AT_INDEX || y == Library::Container::Yield::ITEM) {
if (contains({Library::Container::Yield::AT_INDEX, Library::Container::Yield::ITEM, Library::Container::Yield::BUFFER, Library::Container::Yield::BUFFER_NT}, y)) {
Comment thread
chrchr-github marked this conversation as resolved.
Outdated
errorPath.emplace_back(tok->previous(), "Accessing container.");
return ValueFlow::LifetimeToken::setAddressOf(
getLifetimeTokens(tok->tokAt(-2)->astOperand1(), escape, std::move(errorPath), pred, settings, depth - 1),
Expand Down
3 changes: 3 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3960,6 +3960,9 @@ class TestOther : public TestFixture {

check("void push(V& v) { v.push_back({ .x = 1 }); }"); // #14010
ASSERT_EQUALS("", errout_str());

check("size_t* f(std::array<uint8_t, 128>& a) { return reinterpret_cast<size_t*>(a.data()); }\n"); // #14074
ASSERT_EQUALS("", errout_str());
}

void constParameterCallback() {
Expand Down