summaryrefslogtreecommitdiff
path: root/clang/test/Analysis/iterator-modeling.cpp
AgeCommit message (Collapse)Author
2025-11-04[analyzer] Revert incorrect LazyCoumpoundVal changes (#163461)Marco Borgeaud
Reverts #115917 and its follow up #116840. Fixes #153782 and introduces regression tests. Reopens #114270.
2024-11-29[analyzer] Avoid creating LazyCompoundVal when possible (#116840)Balazs Benics
In #115916 I allowed copying empty structs. Later in #115917 I changed how objects are copied, and basically when we would want to copy a struct (an LCV) of a single symbol (likely coming from an opaque fncall or invalidation), just directly bind that symbol instead of creating an LCV referring to the symbol. This was an optimization to skip a layer of indirection. Now, it turns out I should have apply the same logic in #115916. I should not have just blindly created an LCV by calling `createLazyBinding()`, but rather check if I can apply the shortcut described in #115917 and only create the LCV if the shortcut doesn't apply. In this patch I check if there is a single default binding that the copy would refer to and if so, just return that symbol instead of creating an LCV. There shouldn't be any observable changes besides that we should have fewer LCVs. This change may surface bugs in checkers that were associating some metadata with entities in a wrong way. Notably, STLAlgorithmModeling and DebugIteratorModeling checkers would likely stop working after this change. I didn't investigate them deeply because they were broken even prior to this patch. Let me know if I should migrate these checkers to be just as bugged as they were prior to this patch - thus make the tests pass.
2020-08-04[analyzer] Model iterator random incrementation symmetricallyEndre Fülöp
Summary: In case a pointer iterator is incremented in a binary plus expression (operator+), where the iterator is on the RHS, IteratorModeling should now detect, and track the resulting value. Reviewers: Szelethus, baloghadamsoftware Reviewed By: baloghadamsoftware Subscribers: rnkovacs, whisperity, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, steakhal, martong, ASDenysPetrov, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D83190
2020-07-16[Analyzer] Hotfix for various crashes in iterator checkersAdam Balogh
The patch that introduces handling iterators implemented as pointers may cause crash in some projects because pointer difference is mistakenly handled as pointer decrement. (Similair case for iterators implemented as class instances are already handled correctly.) This patch fixes this issue. The second case that causes crash is comparison of an iterator implemented as pointer and a null-pointer. This patch contains a fix for this issue as well. The third case which causes crash is that the checker mistakenly considers all integers as nonloc::ConcreteInt when handling an increment or decrement of an iterator implemented as pointers. This patch adds a fix for this too. The last case where crashes were detected is when checking for success of an std::advance() operation. Since the modeling of iterators implemented as pointers is still incomplete this may result in an assertion. This patch replaces the assertion with an early exit and adds a FIXME there. Differential Revision: https://reviews.llvm.org/D83295
2020-07-01[Analyzer] Quick fix for broken tests on WindowsAdam Balogh
2020-07-01[Analyzer] Handle pointer implemented as iterators in iterator checkersAdam Balogh
Iterators are an abstraction of pointers and in some data structures iterators may be implemented by pointers. This patch adds support for iterators implemented as pointers in all the iterator checkers (including iterator modeling). Differential Revision: https://reviews.llvm.org/D82185
2020-07-01[Analyzer] Fix errors in iterator modelingAdam Balogh
There is major a bug found in iterator modeling: upon adding a value to or subtracting a value from an iterator the position of the original iterator is also changed beside the result. This patch fixes this bug. To catch such bugs in the future we also changed the tests to look for regular expressions including an end-of-line symbol (`$`) so we can prevent false matches where only the tested prefix matches. Another minor bug is that when printing the state, all the iterator positions are printed in a single line. This patch also fixes this. Differential Revision: https://reviews.llvm.org/D82385
2020-03-30[Analyzer] Rename test `iterator-modelling.cpp` to `iterator-modeling.cpp`Adam Balogh
Typo fix.