[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

Balázs Kéri via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 14 09:06:47 PST 2023


================
@@ -101,6 +101,23 @@ void error_fwrite(void) {
   Ret = fwrite(0, 1, 10, F); // expected-warning {{Stream might be already closed}}
 }
 
+void error_fputc(void) {
+  FILE *F = tmpfile();
+  if (!F)
+    return;
+  int Ret = fputc('X', F);
+  if (Ret == EOF) {
----------------
balazske wrote:

I would add a line with `clang_analyzer_eval(feof(F));` expected as FALSE to both of the branches of `if`. This test is analogous to `error_fwrite` only with `fputc`.

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


More information about the cfe-commits mailing list