Fix issue 9742: FP iterators3 for address of reference to vector in struct (#2668)
This commit is contained in:
parent
9772770226
commit
3109d16b42
|
@ -3596,7 +3596,7 @@ static void valueFlowLifetime(TokenList *tokenlist, SymbolDatabase*, ErrorLogger
|
||||||
value.lifetimeScope = ValueFlow::Value::LifetimeScope::Local;
|
value.lifetimeScope = ValueFlow::Value::LifetimeScope::Local;
|
||||||
value.tokvalue = lt.token;
|
value.tokvalue = lt.token;
|
||||||
value.errorPath = std::move(errorPath);
|
value.errorPath = std::move(errorPath);
|
||||||
if (astIsPointer(lt.token) || !Token::Match(lt.token->astParent(), ".|["))
|
if (lt.addressOf || astIsPointer(lt.token) || !Token::Match(lt.token->astParent(), ".|["))
|
||||||
value.lifetimeKind = ValueFlow::Value::LifetimeKind::Address;
|
value.lifetimeKind = ValueFlow::Value::LifetimeKind::Address;
|
||||||
value.setInconclusive(lt.inconclusive);
|
value.setInconclusive(lt.inconclusive);
|
||||||
setTokenValue(tok, value, tokenlist->getSettings());
|
setTokenValue(tok, value, tokenlist->getSettings());
|
||||||
|
|
|
@ -67,6 +67,7 @@ private:
|
||||||
TEST_CASE(iterator22);
|
TEST_CASE(iterator22);
|
||||||
TEST_CASE(iterator23);
|
TEST_CASE(iterator23);
|
||||||
TEST_CASE(iterator24);
|
TEST_CASE(iterator24);
|
||||||
|
TEST_CASE(iterator25); // #9742
|
||||||
TEST_CASE(iteratorExpression);
|
TEST_CASE(iteratorExpression);
|
||||||
TEST_CASE(iteratorSameExpression);
|
TEST_CASE(iteratorSameExpression);
|
||||||
|
|
||||||
|
@ -1104,6 +1105,19 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void iterator25() {
|
||||||
|
// #9742
|
||||||
|
check("struct S {\n"
|
||||||
|
" std::vector<int>& v;\n"
|
||||||
|
"};\n"
|
||||||
|
"struct T {\n"
|
||||||
|
" bool operator()(const S& lhs, const S& rhs) const {\n"
|
||||||
|
" return &lhs.v != &rhs.v;\n"
|
||||||
|
" }\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void iteratorExpression() {
|
void iteratorExpression() {
|
||||||
check("std::vector<int>& f();\n"
|
check("std::vector<int>& f();\n"
|
||||||
"std::vector<int>& g();\n"
|
"std::vector<int>& g();\n"
|
||||||
|
|
Loading…
Reference in New Issue