[clang] [clang][Analyzer][NFC] Simplify preDefault/preFseek/preFreadFwrite of StreamChecker (PR #71394)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 6 08:33:33 PST 2023


================
@@ -639,12 +644,7 @@ void StreamChecker::preFreadFwrite(const FnDescription *Desc,
                                    bool IsFread) const {
   ProgramStateRef State = C.getState();
   SVal StreamVal = getStreamArg(Desc, Call);
-  State = ensureStreamNonNull(StreamVal, Call.getArgExpr(Desc->StreamArgNo), C,
-                              State);
-  if (!State)
-    return;
-  State = ensureStreamOpened(StreamVal, C, State);
-  if (!State)
+  if (!basicCheck(Desc, Call, C, State, StreamVal))
----------------
balazske wrote:

The function returns a state that is modified further by the following functions. Otherwise the state changes applied in `basicCheck` are lost.  (`ensureStreamNonNull` does a state change, `ensureStreamOpened` does not, but all return a state to make the usage similar.)

https://github.com/llvm/llvm-project/pull/71394


More information about the cfe-commits mailing list