[clang] Improve modeling of two functions in StdLibraryFunctionsChecker (PR #78079)
Balázs Kéri via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 16 00:47:21 PST 2024
================
@@ -248,3 +248,25 @@ void check_fflush_all(void) {
if (errno) {} // no-warning
}
}
+
+void check_opendir(const char *Path) {
+ DIR *Dir = opendir(Path);
+ if (Dir == 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'}}
+ closedir(Dir);
+ }
+}
+
+void check_fdopendir(int Fd) {
+ DIR *Dir = fdopendir(Fd);
+ if (Dir == 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'}}
+ closedir(Dir);
+ }
+}
----------------
balazske wrote:
I think for now it is not necessary to add tests for these functions. These functions are the same type as all other functions in `StdLibraryFunctionsChecker` that have currently no test. And it is questionable if these functions belong to stream handling functions or to `StreamChecker`.
https://github.com/llvm/llvm-project/pull/78079
More information about the cfe-commits
mailing list