[PATCH] D104925: [Analyzer] Improve report of file read at end-of-file condition.

Balázs Kéri via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 30 09:31:37 PDT 2021


balazske marked an inline comment as done.
balazske added a comment.

Updated to use `NoteTag`.
Note "End-of-file status is discovered here" is removed.



================
Comment at: clang/test/Analysis/stream-note.c:141
+  int RRet = fread(Buf, 1, 1, F); // expected-note {{Assuming that stream reaches end-of-file here}}
+  if (ferror(F)) {                // expected-note {{End-of-file status is discovered here}} expected-note {{Taking false branch}}
+  } else {
----------------
martong wrote:
> Strictly speaking it is not necessarily and end-of-file status, `ferror` indicates if there was an error.
Exacly the `ferror(F)` is false here. If it is false we may have successful read or EOF after read. So the message about "Assuming that stream reaches end-of-file here" is really an assumption here (pick one from the two possible results). And if EOF happens and `ferror` is false the `feof` must be true, this is revealed when we know that `ferror` is false.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104925



More information about the cfe-commits mailing list