Repository navigation
Conversation
…ntainer member functions Iterator ranges passed to insert(), assign(), append() and replace() of a container were not checked, so 'ints2.insert(it1, it2)' with iterators from two different containers went unreported (TODO in TestStl::iterator6). To support this, library container detection now recognizes nested iterator types of non-template containers and of std::span, e.g. std::string::iterator and std::span<int>::iterator. The stale TODO in CheckStl::iterators() now points at mismatchingContainers(), which performs the check. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed by smart pointer) 'auto it = m->find(i)' where m is a std::shared_ptr<std::map<int, int>> left 'it' without a value type. Member functions called through '->' on a smart pointer that owns a library container now get the container's return type. Iterators to containers owned by smart pointers are now tracked as lifetimes, so invalidContainer, derefInvalidIterator and mismatchingContainers detect bugs with them, including iterator ranges passed to p->insert()/p->assign(). Shared pointers may own the same container, so mixing iterators from two shared pointers is reported as mismatchingContainerExpression (warning). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
auto it = m->find(i)wheremis astd::shared_ptr<std::map<int, int>>now gets an iterator type instead ofautoNoType.invalidContainer,derefInvalidIteratorandmismatchingContainerssee them, including ranges passed top->insert()/p->assign().unique_ptrs can't own the same container, so mixing their iterators is an error (mismatchingContainers). Twoshared_ptrs might, so it's a warning (mismatchingContainerExpression), matching the existing behavior forstd::find.Depends on #9042; the first commit here is that PR.