[clang] [clang][analyzer] Restrict 'fopen' & 'tmpfile' modeling to POSIX versions in StreamChecker (PR #70540)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 2 01:34:45 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); // Real 'tmpfile' should have exactly 0 formal parameters.
+FILE *fopen(const char *restrict path); // Real 'fopen' should have exactly 2 formal parameters.
+
+void test_fopen_non_posix(void) {
+ FILE *fp = fopen("file"); // no-leak: this isn't the standard POSIX fopen, we don't the semantics of this call.
+}
+
+void test_tmpfile_non_posix(void) {
+ FILE *fp = tmpfile("file"); // no-leak: this isn't the standard POSIX tmpfile, we don't the semantics of this call.
----------------
steakhal wrote:
I think the verb was missing. Probably the "we don't [know] the semantics..."
https://github.com/llvm/llvm-project/pull/70540
More information about the cfe-commits
mailing list