[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

Kristóf Umann via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 17 08:32:28 PDT 2020


Szelethus added a comment.

Riiiight I think I finally get it. You don't want to state split on `feof()` and `ferror()`, but rather on the stream operations! This is why you only want to tell the analyzer what the return value of these functions are going to be, because the state of the stream should be set by the time we reach these functions, right?

How about untracked streams? What if we call `feof()` on a stream we got from a parameter, wouldn't that suggest that the stream is probably non-null and could either be EOF or non-EOF?



================
Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:88
 struct FnDescription;
 using FnCheck = std::function<void(const StreamChecker *, const FnDescription *,
                                    const CallEvent &, CheckerContext &)>;
----------------
balazske wrote:
> NoQ wrote:
> > balazske wrote:
> > > NoQ wrote:
> > > > `llvm::function_ref`?
> > > `function_ref`'s documentation says:
> > > > This class does not own the callable, so it is not in general safe to store a function_ref.
> > > The `FnDescription` stores these functions so it is not safe to use `llvm::function_ref`?
> > > 
> > > 
> > > 
> > I think you're using it only for global function pointers, no?
> Probably can work but I tried it and got compile errors.
It doesn't matter a whole lot, we could leave this as-is :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682





More information about the cfe-commits mailing list