[PATCH] D78289: [analyzer] Stability improvements for IteratorModeling functions
Denys Petrov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 16 03:23:25 PDT 2020
ASDenysPetrov created this revision.
ASDenysPetrov added reviewers: baloghadamsoftware, NoQ.
ASDenysPetrov added a project: clang.
Herald added subscribers: cfe-commits, martong, Charusso, dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun.
Some functions paths may lead to crash.
Fixed ignoring check for nullptr before dereferencing.
Fixed using local variable outside the scope through a pointer.
Fixed minor misspellings.
This patch covers a bug https://bugs.llvm.org/show_bug.cgi?id=41485
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78289
Files:
clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
Index: clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
@@ -402,7 +402,7 @@
if (!Cont)
return;
- // At least one of the iterators have recorded positions. If one of them has
+ // At least one of the iterators has recorded positions. If one of them does
// not then create a new symbol for the offset.
SymbolRef Sym;
if (!LPos || !RPos) {
@@ -422,9 +422,14 @@
RPos = getIteratorPosition(State, RVal);
}
- // We cannot make assumpotions on `UnknownVal`. Let us conjure a symbol
+ if (!LPos || !RPos)
+ return;
+
+ // We cannot make assumptions on `UnknownVal`. Let us conjure a symbol
// instead.
if (RetVal.isUnknown()) {
+ if (!State)
+ return;
auto &SymMgr = C.getSymbolManager();
auto *LCtx = C.getLocationContext();
RetVal = nonloc::SymbolVal(SymMgr.conjureSymbol(
@@ -532,8 +537,9 @@
return;
const auto *value = &RHS;
+ SVal val;
if (auto loc = RHS.getAs<Loc>()) {
- const auto val = State->getRawSVal(*loc);
+ val = State->getRawSVal(*loc);
value = &val;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78289.258001.patch
Type: text/x-patch
Size: 1250 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200416/3fe21729/attachment-0001.bin>
More information about the cfe-commits
mailing list