=?utf-8?q?Balázs_Kéri?= <[email protected]>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>
================
@@ -1404,6 +1486,47 @@ void StreamChecker::evalFeofFerror(const FnDescription
*Desc,
}
}
+void StreamChecker::evalFileno(const FnDescription *Desc, const CallEvent
&Call,
+ CheckerContext &C) const {
+ // Fileno should fail only if the passed pointer is invalid.
+ // Some of the preconditions are checked already in preDefault.
+ // Here we can assume that the operation does not fail.
+ // An added failure case causes many unexpected warnings because a file
number
+ // becomes -1 that is not expected by the program.
+ // The stream error states are not modified by 'fileno', and not the 'errno'.
+ // (To ensure that errno is not changed, this evalCall is needed to not
+ // invalidate 'errno' like in a default case.)
+ ProgramStateRef State = C.getState();
+ SymbolRef StreamSym = getStreamArg(Desc, Call).getAsSymbol();
+ if (!StreamSym)
+ return;
+
+ const CallExpr *CE = dyn_cast_or_null<CallExpr>(Call.getOriginExpr());
----------------
benshi001 wrote:
Shall we change to `StreamOperationEvaluator` which is introduced by your
previous simplification patch ?
https://github.com/llvm/llvm-project/pull/81842
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits