Fix 10784: False positive: returnDanglingLifetime using std::tie with variadic template parameters (#3805)

This commit is contained in:
Paul Fultz II 2022-02-08 02:03:51 -06:00 committed by GitHub
parent b5ed13c8bc
commit 20a5224d7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 0 deletions

View File

@ -3021,6 +3021,8 @@ static std::vector<LifetimeToken> getLifetimeTokens(const Token* tok,
{
if (!tok)
return std::vector<LifetimeToken> {};
if (Token::simpleMatch(tok, "..."))
return std::vector<LifetimeToken>{};
const Variable *var = tok->variable();
if (pred(tok))
return {{tok, std::move(errorPath)}};

View File

@ -2955,6 +2955,13 @@ private:
ASSERT_EQUALS(
"[test.cpp:11] -> [test.cpp:10] -> [test.cpp:11]: (error) Non-local variable 'mMoreData.data1' will use pointer to local variable 'data'.\n",
errout.str());
// #10784
check("template <class... Ts>\n"
"auto f(int i, Ts&... xs) {\n"
" return std::tie(xs[i]...);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void danglingLifetimeFunction() {