[PATCH] D53701: [Analyzer] Instead of recording comparisons in interator checkers do an eager state split
Bjorn Pettersson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 23 02:19:42 PDT 2019
bjope added inline comments.
================
Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:825
+ // not then create a new symbol for the offset.
+ SymbolRef Sym;
+ if (!LPos || !RPos) {
----------------
This is an uninitialized version of `Sym` that will be used on line 835 and line 839.
The `Sym` variable assigned on line 828 is local to the scope starting at line 826.
Not really sure, but was perhaps the idea to use the `Sym` value from line 828 on line 835 and 839.
Then I guess the you can rewrite this as:
```
// At least one of the iterators have recorded positions. If one of them has
// not then create a new symbol for the offset.
if (!LPos || !RPos) {
auto &SymMgr = C.getSymbolManager();
auto Sym = SymMgr.conjureSymbol(CE, C.getLocationContext(),
C.getASTContext().LongTy, C.blockCount());
State = assumeNoOverflow(State, Sym, 4);
if (!LPos) {
State = setIteratorPosition(State, LVal,
IteratorPosition::getPosition(Cont, Sym));
LPos = getIteratorPosition(State, LVal);
} else if (!RPos) {
State = setIteratorPosition(State, RVal,
IteratorPosition::getPosition(Cont, Sym));
RPos = getIteratorPosition(State, RVal);
}
}
```
As it is right now I get complaint about using an uninitialized value for `Sym` (so this patch still doesn't build with -Werror after the earlier fixup).
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D53701/new/
https://reviews.llvm.org/D53701
More information about the cfe-commits
mailing list