[clang] [NFC][analyzer] Add regression tests from bisection commits to the CSA's test suite (PR #241058)

Benedek Kaibas via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 11 05:03:03 PST 2026


================
@@ -175,3 +176,40 @@ void errno_realpath(char *Path, char *Buf) {
     if (errno) {} // expected-warning{{An undefined value may be read from 'errno'}}
   }
 }
+
+#define PATH_MAX 4096
+#define AF_UNIX 1
+#define SOCK_SEQPACKET 5
+#define SOCK_CLOEXEC 02000000
+
+void *malloc(size_t);
+void free(void *);
+int dosomething(char *);
+
+int GH43015_connect_socket(char **mname) {
+  int ret;
+  *mname = (char *)malloc(PATH_MAX);
+
+  int fd = socket(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0);
+  if (fd < 0) {
+    ret = errno;
+    free(*mname);
+    return ret;
+  }
+
+  {
+    ret = recv(fd, *mname, PATH_MAX, 0);
+    if (ret > 0) return 0;
+  }
+  close(fd);
+  return ret;
+}
+
+int GH43015(void) {
+  char *mname;
+  int ret = GH43015_connect_socket(&mname);
+  if (ret)
+    return ret;
+
+  return dosomething(mname); // no-warning
+}
----------------
benedekaibas wrote:

I reduced this test case with `creduce` then did some polishing and I figured out that the reduced case is already covered:
```c
int errno_lseek(int fildes, off_t offset) {
  off_t result = lseek(fildes, offset, 0);
  if (result == (off_t)-1) {
    // Failure path.
    // check if the function is modeled
    clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
    return 2;
  }
```

I'd drop this test then and make a comment on the issue why I don't add this test case to the lit tests.

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


More information about the cfe-commits mailing list