Skip to content
Snippets Groups Projects
Commit 9a0b3c2f authored by Jordan Rose's avatar Jordan Rose
Browse files

[analyzer] Tests: move system functions into system header simulator files.

Some checkers ascribe different behavior to functions declared in system
headers, so when working with standard library functions it's probably best
to always have them in a standard location.

Test change only (no functionality change), but necessary for the next commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@179552 91177308-0d34-0410-b5e6-96231b3b80d8
parent 77670f17
No related branches found
No related tags found
No related merge requests found
...@@ -14,8 +14,11 @@ extern FILE *__stdinp; ...@@ -14,8 +14,11 @@ extern FILE *__stdinp;
extern FILE *__stdoutp; extern FILE *__stdoutp;
extern FILE *__stderrp; extern FILE *__stderrp;
int scanf(const char *restrict format, ...);
int fscanf(FILE *restrict, const char *restrict, ...); int fscanf(FILE *restrict, const char *restrict, ...);
int printf(const char *restrict format, ...);
int fprintf(FILE *restrict, const char *restrict, ...);
int getchar(void);
// Note, on some platforms errno macro gets replaced with a function call. // Note, on some platforms errno macro gets replaced with a function call.
extern int errno; extern int errno;
...@@ -37,6 +40,8 @@ typedef __darwin_off_t fpos_t; ...@@ -37,6 +40,8 @@ typedef __darwin_off_t fpos_t;
void setbuf(FILE * restrict, char * restrict); void setbuf(FILE * restrict, char * restrict);
int setvbuf(FILE * restrict, char * restrict, int, size_t); int setvbuf(FILE * restrict, char * restrict, int, size_t);
FILE *fopen(const char * restrict, const char * restrict);
int fclose(FILE *);
FILE *funopen(const void *, FILE *funopen(const void *,
int (*)(void *, char *, int), int (*)(void *, char *, int),
int (*)(void *, const char *, int), int (*)(void *, const char *, int),
......
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete -std=c++11 -verify %s // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete -std=c++11 -verify %s
// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete,alpha.cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s
typedef __typeof(sizeof(int)) size_t; #include "Inputs/system-header-simulator-for-malloc.h"
void *malloc(size_t);
void free(void *);
//-------------------------------------------------- //--------------------------------------------------
// Check that unix.Malloc catches all types of bugs. // Check that unix.Malloc catches all types of bugs.
......
// RUN: %clang_cc1 -Wno-int-to-pointer-cast -analyze -analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify // RUN: %clang_cc1 -Wno-int-to-pointer-cast -analyze -analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify
#include <stdarg.h> #include "Inputs/system-header-simulator.h"
int scanf(const char *restrict format, ...);
int getchar(void);
typedef __typeof(sizeof(int)) size_t;
#define BUFSIZE 10 #define BUFSIZE 10
int Buffer[BUFSIZE]; int Buffer[BUFSIZE];
...@@ -87,15 +83,6 @@ void getenvTest(char *home) { ...@@ -87,15 +83,6 @@ void getenvTest(char *home) {
} }
} }
typedef struct _FILE FILE;
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
int fscanf(FILE *restrict stream, const char *restrict format, ...);
int fprintf(FILE *stream, const char *format, ...);
int fclose(FILE *stream);
FILE *fopen(const char *path, const char *mode);
int fscanfTest(void) { int fscanfTest(void) {
FILE *fp; FILE *fp;
char s[80]; char s[80];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment