[clang] [clang][analyzer] Update CallDescription of 'tmpfile' & 'fopen' in StreamChecker (PR #70540)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 31 06:35:33 PDT 2023


================
@@ -0,0 +1,16 @@
+// RUN: %clang_analyze_cc1 -fno-builtin -analyzer-checker=core,alpha.unix.Stream -verify %s
+// expected-no-diagnostics
+
+typedef struct _FILE FILE;
+
+// These functions are not standard C library functions.
+FILE *tmpfile(const char *restrict path);
+FILE *fopen(const char *restrict path);
+
+void test_fopen(void) {
+  FILE *fp = fopen("file");
+}
+
+void test_tmpfile(void) {
+  FILE *fp = tmpfile("file");
+}
----------------
steakhal wrote:

```suggestion
void non_posix_fopen(void) {
  FILE *fp = fopen("file"); // no-leak: this isn't the standard POSIX fopen, we don't the semantics of this call.
}

void non_posix_tmpfile(void) {
  FILE *fp = tmpfile("file"); // no-leak: this isn't the standard POSIX tmpfile, we don't the semantics of this call.
}
```

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


More information about the cfe-commits mailing list