C++: Improve Iterator models #5157
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Improve Iterator.qll models:
Iterator.qll
already models its classes, and uses a special predicategetIteratorArgumentInput
to connect classes to non-member function models. But there were a few opportunities to clean things up for member function models usinggetClassAndName
.operator+=
models, particularly with the non-member version and consistency between the member and non-member versions; I've added some more test cases and attempted to improve matters. But please do say if you think I may have made a mistake!Regarding BSL:
bsl
classes appear to have iterators,begin
methods etc with the normal behaviour.bsl::iterator
,bsl::front_inserter
,bsl::inserter
, andbsl::back_inserter
functions don't appear to be documented but are implemented as references (viausing
declarations) to thestd
versions.bsl:iterator_traits
corresponding tostd::iterator_traits
, or ausing
. I couldn't find documentation for it but it's clearly intended to be the same thing.bsl::List_Iterator
. This example should be caught byIteratorByTypedefs
and modelled correctly.TL;DR:
bsl
iterators work the same asstd
iterators, so I've changed the model to include them, and also fixed a few things.