[clang] [clang][analyzer] Support `fflush` in the StreamChecker (PR #74296)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 13 07:03:13 PST 2023
================
@@ -299,6 +299,60 @@ void error_fseek_0(void) {
fclose(F);
}
+void error_fflush_0(void) {
+ FILE *F = tmpfile();
+ int Ret;
+ fflush(NULL); // no-warning
+ if (!F) {
+ if ((Ret = fflush(F)) != EOF)
+ clang_analyzer_eval(Ret == 0); // expected-warning {{TRUE}}
+ return;
+ }
+ if ((Ret = fflush(F)) != 0)
+ clang_analyzer_eval(Ret == EOF); // expected-warning {{TRUE}}
+ fclose(F);
+ fflush(F); // expected-warning {{Stream might be already closed}}
+}
+
+void error_fflush_1(void) {
----------------
balazske wrote:
I prefer to have multiple tests (with a name that indicates what is tested) for the different cases.
https://github.com/llvm/llvm-project/pull/74296
More information about the cfe-commits
mailing list