[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 06:53:41 PST 2023


================
@@ -299,6 +299,15 @@ void error_fseek_0(void) {
   fclose(F);
 }
 
+void error_fflush(void) {
+  FILE *F = tmpfile();
+  if (!F)
+    return;
+  fclose(F);
+  fflush(F);    // expected-warning {{Stream might be already closed}}
+  fflush(NULL); // no-warning
----------------
balazske wrote:

The `fflush(NULL)` should be before `fflush(F)` (probably at the start of the function) because analysis may stop when a warning is emitted (and following code is not reachable).

https://github.com/llvm/llvm-project/pull/74296


More information about the cfe-commits mailing list