aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2010-06-16 05:38:05 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2010-06-16 05:38:05 +0000
commitc196095fa0b83d10b2c20fccfcb8198ee66451aa (patch)
treecfe16a1e2645aa77a31454c0c69116b711f562d4 /test/Analysis
parent65161d17cbf8980e24643c65b74a5127dcb7ac22 (diff)
Add StreamChecker. This checker models and checks stream manipulation functions.
This is the start. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106082 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/stream.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/Analysis/stream.c b/test/Analysis/stream.c
new file mode 100644
index 0000000000..17876688dd
--- /dev/null
+++ b/test/Analysis/stream.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-experimental-checks -analyzer-store region -verify %s
+
+typedef __typeof__(sizeof(int)) size_t;
+typedef struct _IO_FILE FILE;
+FILE *fopen(const char *path, const char *mode);
+size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
+
+void f1(void) {
+ FILE *p = fopen("foo", "r");
+ char buf[1024];
+ fread(buf, 1, 1, p); // expected-warning {{Stream pointer might be NULL.}}
+}