Skip to content

Commit

Permalink
Fix isVariableChanged()
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github committed Aug 6, 2023
1 parent 50ec8f5 commit 3dc13dc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/astutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2837,6 +2837,8 @@ bool isExpressionChanged(const Token* expr, const Token* start, const Token* end
if (vt->type == ValueType::ITERATOR)
++indirect;
}
if (Token::Match(tok->astParent(), "%cop%") && tok2->astParent() && tok2->astParent()->isIncDecOp())
indirect = 0;
if (isExpressionChangedAt(tok, tok2, indirect, global, settings, cpp, depth))
return true;
}
Expand Down
3 changes: 1 addition & 2 deletions test/teststl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3033,8 +3033,7 @@ class TestStl : public TestFixture {
" }\n"
"}");
ASSERT_EQUALS(
"[test.cpp:4] -> [test.cpp:6] -> [test.cpp:3] -> [test.cpp:9]: (error, inconclusive) Using iterator to local container 'vec' that may be invalid.\n"
"[test.cpp:4] -> [test.cpp:9]: (warning) Either the condition 'it!=vec.end()' is redundant or there is possible dereference of an invalid iterator: it.\n",
"[test.cpp:4] -> [test.cpp:6] -> [test.cpp:3] -> [test.cpp:9]: (error, inconclusive) Using iterator to local container 'vec' that may be invalid.\n",
errout.str());
}

Expand Down

0 comments on commit 3dc13dc

Please sign in to comment.