[clang] [clang][analyzer] Support 'tello' and 'fseeko' in the StreamChecker (PR #77580)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 10 09:06:16 PST 2024
================
@@ -324,6 +355,57 @@ void error_fseek_0(void) {
fclose(F);
}
+void error_fseeko_0(void) {
+ FILE *F = fopen("file", "r");
+ if (!F)
+ return;
+ int rc = fseeko(F, 0, SEEK_SET);
+ if (rc) {
+ int IsFEof = feof(F), IsFError = ferror(F);
+ // Get ferror or no error, but not feof.
+ clang_analyzer_eval(IsFError);
+ // expected-warning at -1 {{FALSE}}
+ // expected-warning at -2 {{TRUE}}
+ clang_analyzer_eval(IsFEof);
+ // expected-warning at -1 {{FALSE}}
+ // Error flags should not change.
+ clang_analyzer_eval(feof(F)); // expected-warning {{FALSE}}
+ if (IsFError)
+ clang_analyzer_eval(ferror(F)); // expected-warning {{TRUE}}
+ else
+ clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+ } else {
+ clang_analyzer_eval(feof(F)); // expected-warning {{FALSE}}
+ clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+ // Error flags should not change.
+ clang_analyzer_eval(feof(F)); // expected-warning {{FALSE}}
+ clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
----------------
balazske wrote:
```suggestion
```
https://github.com/llvm/llvm-project/pull/77580
More information about the cfe-commits
mailing list