[PATCH] D73350: [analyzer] Small StreamChecker refactoring (NFC).
Balázs Kéri via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 7 00:11:01 PST 2020
balazske updated this revision to Diff 243092.
balazske added a comment.
Reformat.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73350/new/
https://reviews.llvm.org/D73350
Files:
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===================================================================
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -135,31 +135,32 @@
}
void StreamChecker::evalFopen(const CallEvent &Call, CheckerContext &C) const {
- ProgramStateRef state = C.getState();
- SValBuilder &svalBuilder = C.getSValBuilder();
+ ProgramStateRef State = C.getState();
+ SValBuilder &SVB = C.getSValBuilder();
const LocationContext *LCtx = C.getPredecessor()->getLocationContext();
+
auto *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr());
if (!CE)
return;
- DefinedSVal RetVal =
- svalBuilder.conjureSymbolVal(nullptr, CE, LCtx, C.blockCount())
- .castAs<DefinedSVal>();
- state = state->BindExpr(CE, C.getLocationContext(), RetVal);
+ DefinedSVal RetVal = SVB.conjureSymbolVal(nullptr, CE, LCtx, C.blockCount())
+ .castAs<DefinedSVal>();
+ SymbolRef RetSym = RetVal.getAsSymbol();
+ assert(RetSym && "RetVal must be a symbol here.");
+
+ State = State->BindExpr(CE, C.getLocationContext(), RetVal);
- ConstraintManager &CM = C.getConstraintManager();
// Bifurcate the state into two: one with a valid FILE* pointer, the other
// with a NULL.
- ProgramStateRef stateNotNull, stateNull;
- std::tie(stateNotNull, stateNull) = CM.assumeDual(state, RetVal);
+ ProgramStateRef StateNotNull, StateNull;
+ std::tie(StateNotNull, StateNull) =
+ C.getConstraintManager().assumeDual(State, RetVal);
- SymbolRef Sym = RetVal.getAsSymbol();
- assert(Sym && "RetVal must be a symbol here.");
- stateNotNull = stateNotNull->set<StreamMap>(Sym, StreamState::getOpened());
- stateNull = stateNull->set<StreamMap>(Sym, StreamState::getOpenFailed());
+ StateNotNull = StateNotNull->set<StreamMap>(RetSym, StreamState::getOpened());
+ StateNull = StateNull->set<StreamMap>(RetSym, StreamState::getOpenFailed());
- C.addTransition(stateNotNull);
- C.addTransition(stateNull);
+ C.addTransition(StateNotNull);
+ C.addTransition(StateNull);
}
void StreamChecker::evalFreopen(const CallEvent &Call,
@@ -228,8 +229,6 @@
if (!C.isDifferent() && StateChanged)
C.addTransition(State);
-
- return;
}
void StreamChecker::checkArgNullStream(const CallEvent &Call, CheckerContext &C,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73350.243092.patch
Type: text/x-patch
Size: 2383 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200207/68a8d7c4/attachment-0001.bin>
More information about the cfe-commits
mailing list