-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang][analyzer] Restrict 'fopen' & 'tmpfile' modeling to POSIX vers…
…ions in StreamChecker (#70540) 'tmpfile' has only one form that it has no argument.
- Loading branch information
Showing
2 changed files
with
18 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 know 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 know the semantics of this call. | ||
} |