[clang] Improve modeling of two functions in StdLibraryFunctionsChecker (PR #78079)

Ben Shi via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 16 01:04:11 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);
+  }
+}
----------------
benshi001 wrote:

I have removed those tests. Do you mean all type `DIR` related functions are controversial now, so they need tests? Or there are some more functions are so?

https://github.com/llvm/llvm-project/pull/78079


More information about the cfe-commits mailing list