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

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 12 01:36:50 PDT 2020


balazske added a comment.

In D75682#1917257 <https://reviews.llvm.org/D75682#1917257>, @Szelethus wrote:

> Could you please add the warning we discussed? That would be a great demonstration of this patch's capabilities, and wouldn't deserve its own patch.


Was it this warning?

  if (feof(F)) { // note: Assuming the condition is true
                 // note: Stream 'F' has the EOF flag set
    fgets(F); // warning: Illegal stream operation on a stream that has EOF set
  }

The checker does not work by "assuming feof is true" (this can be a later feature, if the `F` is not tracked and a feof call is encountered). Value of `feof` (more precisely: if any error happened) is fixed when the file operation is called that causes the error. The warning above should be get even if the `feof` call is missing because it is still possible that the previous operation resulted in EOF state. Adding a similar warning is not a small change and the "infrastructure" for it is not ready in this revision. And still that warning would not be testable because `FEof` error state is never set in this patch. By the way, a file read is not invalid if any error is there, it simply fails again. But there is many possibility for warnings such as "file read called in EOF state", "feof called when it is proven to be false/true", "invalid file read/write after failed fseek/fread/fwrite" but these belong to next revisions.

Probably it would be better to make a full working prototype first, because the design decisions made now can turn out to be wrong later when the new functionality would be added and we do "not see the full picture" now.


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