================ @@ -105,9 +105,6 @@ void errno_getcwd(char *Buf, size_t Sz) { clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}} clang_analyzer_eval(Path == NULL); // expected-warning{{TRUE}} if (errno) {} // no warning - } else if (Path == NULL) { - clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}} - if (errno) {} // no warning ---------------- balazske wrote:
I think the following tests would be good in the llvm main branch: ```c void errno_getcwd_buf_nonnull(char *Buf, size_t Sz) { if (Buf == NULL) return; char *Path = getcwd(Buf, Sz); if (Sz == 0) { clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}} clang_analyzer_eval(Path == NULL); // expected-warning{{TRUE}} if (errno) {} // no warning } else if (Path == NULL) { clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}} if (errno) {} // no warning } else { clang_analyzer_eval(Path == Buf); // expected-warning{{TRUE}} if (errno) {} // expected-warning{{An undefined value may be read from 'errno'}} } } void errno_getcwd_buf_null() { // POSIX does not mention this case but many implementations (Linux, FreeBSD) work this way. char *Path = getcwd(NULL, 1); if (Path == NULL) { clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}} if (errno) {} // no warning } else { if (errno) {} // expected-warning{{An undefined value may be read from 'errno'}} } } ``` I can add the patch for this in the next few days. https://github.com/llvm/llvm-project/pull/135720 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits