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

Jordan Rose jordan_rose at apple.com
Mon Apr 15 13:39:38 PDT 2013


Author: jrose
Date: Mon Apr 15 15:39:37 2013
New Revision: 179552

URL: http://llvm.org/viewvc/llvm-project?rev=179552&view=rev
Log:
[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.

Modified:
    cfe/trunk/test/Analysis/Inputs/system-header-simulator.h
    cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
    cfe/trunk/test/Analysis/taint-tester.c

Modified: cfe/trunk/test/Analysis/Inputs/system-header-simulator.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/system-header-simulator.h?rev=179552&r1=179551&r2=179552&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/Inputs/system-header-simulator.h (original)
+++ cfe/trunk/test/Analysis/Inputs/system-header-simulator.h Mon Apr 15 15:39:37 2013
@@ -14,8 +14,11 @@ extern FILE *__stdinp;
 extern FILE *__stdoutp;
 extern FILE *__stderrp;
 
-
+int scanf(const char *restrict format, ...);
 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.
 extern int errno;
@@ -37,6 +40,8 @@ typedef __darwin_off_t fpos_t;
 void setbuf(FILE * restrict, char * restrict);
 int setvbuf(FILE * restrict, char * restrict, int, size_t);
 
+FILE *fopen(const char * restrict, const char * restrict);
+int fclose(FILE *);
 FILE *funopen(const void *,
                  int (*)(void *, char *, int),
                  int (*)(void *, const char *, int),

Modified: cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Malloc%2BMismatchedDeallocator%2BNewDelete.cpp?rev=179552&r1=179551&r2=179552&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp (original)
+++ cfe/trunk/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp Mon Apr 15 15:39:37 2013
@@ -1,9 +1,7 @@
 // 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
 
-typedef __typeof(sizeof(int)) size_t;
-void *malloc(size_t);
-void free(void *);
+#include "Inputs/system-header-simulator-for-malloc.h"
 
 //--------------------------------------------------
 // Check that unix.Malloc catches all types of bugs.

Modified: cfe/trunk/test/Analysis/taint-tester.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/taint-tester.c?rev=179552&r1=179551&r2=179552&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/taint-tester.c (original)
+++ cfe/trunk/test/Analysis/taint-tester.c Mon Apr 15 15:39:37 2013
@@ -1,10 +1,6 @@
 // RUN: %clang_cc1 -Wno-int-to-pointer-cast -analyze -analyzer-checker=alpha.security.taint,debug.TaintTest %s -verify
 
-#include <stdarg.h>
-
-int scanf(const char *restrict format, ...);
-int getchar(void);
-typedef __typeof(sizeof(int)) size_t;
+#include "Inputs/system-header-simulator.h"
 
 #define BUFSIZE 10
 int Buffer[BUFSIZE];
@@ -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) {
   FILE *fp;
   char s[80];





More information about the cfe-commits mailing list