Fixed #8191 (False positive iterators regression)
This commit is contained in:
parent
61767d4932
commit
83b87b54b4
|
@ -241,7 +241,7 @@ void CheckStl::iterators()
|
||||||
Token::Match(skipMembers(tok2->tokAt(2)), "begin|rbegin|cbegin|crbegin|find (")) {
|
Token::Match(skipMembers(tok2->tokAt(2)), "begin|rbegin|cbegin|crbegin|find (")) {
|
||||||
validatingToken = skipMembers(tok2->tokAt(2))->linkAt(1);
|
validatingToken = skipMembers(tok2->tokAt(2))->linkAt(1);
|
||||||
containerToken = skipMembers(tok2->tokAt(2))->tokAt(-2);
|
containerToken = skipMembers(tok2->tokAt(2))->tokAt(-2);
|
||||||
if (containerToken->varId() == 0)
|
if (containerToken->varId() == 0 || Token::simpleMatch(validatingToken, ") ."))
|
||||||
containerToken = nullptr;
|
containerToken = nullptr;
|
||||||
containerAssignScope = tok2->scope();
|
containerAssignScope = tok2->scope();
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ private:
|
||||||
TEST_CASE(iterator11);
|
TEST_CASE(iterator11);
|
||||||
TEST_CASE(iterator12);
|
TEST_CASE(iterator12);
|
||||||
TEST_CASE(iterator13);
|
TEST_CASE(iterator13);
|
||||||
|
TEST_CASE(iterator14); // #8191
|
||||||
|
|
||||||
TEST_CASE(dereference);
|
TEST_CASE(dereference);
|
||||||
TEST_CASE(dereference_break); // #3644 - handle "break"
|
TEST_CASE(dereference_break); // #3644 - handle "break"
|
||||||
|
@ -521,6 +522,15 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void iterator14() {
|
||||||
|
check("void f() {\n"
|
||||||
|
" std::map<int,Foo> x;\n"
|
||||||
|
" std::map<int,Foo>::const_iterator it;\n"
|
||||||
|
" for (it = x.find(0)->second.begin(); it != x.find(0)->second.end(); ++it) {}\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
// Dereferencing invalid pointer
|
// Dereferencing invalid pointer
|
||||||
void dereference() {
|
void dereference() {
|
||||||
check("void f()\n"
|
check("void f()\n"
|
||||||
|
|
Loading…
Reference in New Issue