================ @@ -975,6 +981,61 @@ void StreamChecker::evalFprintf(const FnDescription *Desc, C.addTransition(StateFailed); } +void StreamChecker::evalFscanf(const FnDescription *Desc, const CallEvent &Call, + CheckerContext &C) const { + ProgramStateRef State = C.getState(); + if (Call.getNumArgs() < 2) + return; + SymbolRef StreamSym = getStreamArg(Desc, Call).getAsSymbol(); + if (!StreamSym) + return; + + const CallExpr *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr()); + if (!CE) + return; + + const StreamState *OldSS = State->get<StreamMap>(StreamSym); + if (!OldSS) + return; + + assertStreamStateOpened(OldSS); + + SValBuilder &SVB = C.getSValBuilder(); + ASTContext &ACtx = C.getASTContext(); + + if (OldSS->ErrorState != ErrorFEof) { ---------------- benshi001 wrote:
Shall we add a comment like ``` 'fscanf' return matched input items, this can be from zero to the total number of input items. If the stream read is successful but match fails, we still think 'fscanf' is success. ``` Something like that. You can reorganize my words. https://github.com/llvm/llvm-project/pull/78180 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits