balazske marked an inline comment as done.
balazske added inline comments.

================
Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:470
 
-  // Make the return value accordingly to the error.
-  State = State->assume(RetVal, (SS->*IsOfError)());
-  assert(State && "Return value should not be constrained already.");
-  C.addTransition(State);
+  if (SS->isUnknownError()) {
+    llvm::SmallVector<StreamState::ErrorKindTy, 3> NewPossibleErrors;
----------------
NoQ wrote:
> Please explain the high-level idea behind this code. 
The higher level idea is that if a stream function fails we do not create a new 
state for every type of error (EOF and "other" error). Instead there will be an 
"unknown error" state. The description for each stream function contains what 
errors are possible after that function (`PossibleErrors`).

If it is needed to know the exact error (like here, what should `feof` return?) 
we look at the previous function to see what errors are possible after it. If 
EOF is not possible at all, the `feof` returns false. If EOF is possible and 
only one other type of error, we make a state split with EOF error and the 
other error set. If EOF and two possible other errors are possible there is 
state split again but the non-EOF state contains `UnknownError`.

In `PossibleErrors` the `NoError` state is possible. This indicates that the 
function failed (returned an error value) but the stream error flags are not 
set (can happen at `fseek`). There are 3 possible error values (EOF, "other" 
and no error), if after a `feof` there is `UnknownError` we know that the 
remaining 2 error types are possible.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75851/new/

https://reviews.llvm.org/D75851



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to