=?utf-8?q?Balázs_Kéri?= <balazs.k...@ericsson.com> Message-ID: In-Reply-To: <llvm.org/llvm/llvm-project/pull/147...@github.com>
================ @@ -519,14 +519,53 @@ void reopen_std_stream(void) { if (!fp) return; stdout = fp; // Let's make them alias. - clang_analyzer_eval(fp == oldStdout); // expected-warning {{UNKNOWN}} - clang_analyzer_eval(fp == stdout); // expected-warning {{TRUE}} no-FALSE - clang_analyzer_eval(oldStdout == stdout); // expected-warning {{UNKNOWN}} + clang_analyzer_eval(fp == oldStdout); // expected-warning {{FALSE}} + clang_analyzer_eval(fp == stdout); // expected-warning {{TRUE}} + clang_analyzer_eval(oldStdout == stdout); // expected-warning {{FALSE}} } void only_success_path_does_not_alias_with_stdout(void) { if (stdout) return; FILE *f = fopen("/tmp/foof", "r"); // no-crash + clang_analyzer_eval(f == 0);// expected-warning {{TRUE}} expected-warning {{FALSE}} if (!f) return; fclose(f); } + +extern void do_something(); + +void test_no_invalidate_at_system_call(int use_std) { + FILE *fd; + char *buf; + + if (use_std) { + fd = stdin; + } else { + if ((fd = fopen("x/y/z", "r")) == NULL) + return; + + clang_analyzer_eval(fd == stdin); // expected-warning{{FALSE}} + buf = (char *)malloc(100); + clang_analyzer_eval(fd == stdin); // expected-warning{{FALSE}} + } + + if (fd != stdin) + fclose(fd); +} ---------------- steakhal wrote: If I read this correctly, the test intends to check if the `stdin` system global would not get invalidated after calling `malloc()` (or for that matter any other opaque system header fn), right? Could we simplify this into: ```c++ auto orig_stdin = stdin; free(malloc(10)); // calling some opaque system fns clang_analyzer_eval(stdin == orig_stdin); // TRUE ``` Same suggestion goes to the next example too. https://github.com/llvm/llvm-project/pull/147766 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits