summaryrefslogtreecommitdiff
path: root/test/Analysis/string-fail.c
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2012-08-15 20:02:54 +0000
committerDimitry Andric <dim@FreeBSD.org>2012-08-15 20:02:54 +0000
commit56d91b49b13fe55c918afbda19f6165b5fbff87a (patch)
tree9abb1a658a297776086f4e0dfa6ca533de02104e /test/Analysis/string-fail.c
parent41e20f564abdb05101d6b2b29c59459a966c22cc (diff)
downloadsrc-test2-56d91b49b13fe55c918afbda19f6165b5fbff87a.tar.gz
src-test2-56d91b49b13fe55c918afbda19f6165b5fbff87a.zip
Notes
Diffstat (limited to 'test/Analysis/string-fail.c')
-rw-r--r--test/Analysis/string-fail.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/test/Analysis/string-fail.c b/test/Analysis/string-fail.c
index 3bff6d40dd51..ac5c6d057235 100644
--- a/test/Analysis/string-fail.c
+++ b/test/Analysis/string-fail.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
-// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s
+// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s
// XFAIL: *
// This file is for tests that may eventually go into string.c, or may be
@@ -32,6 +32,7 @@
#define NULL 0
typedef typeof(sizeof(int)) size_t;
+void clang_analyzer_eval(int);
//===----------------------------------------------------------------------===
// strnlen()
@@ -43,8 +44,7 @@ size_t strnlen(const char *s, size_t maxlen);
void strnlen_liveness(const char *x) {
if (strnlen(x, 10) < 5)
return;
- if (strnlen(x, 10) < 5)
- (void)*(char*)0; // no-warning
+ clang_analyzer_eval(strnlen(x, 10) < 5); // expected-warning{{FALSE}}
}
void strnlen_subregion() {
@@ -57,43 +57,43 @@ void strnlen_subregion() {
size_t a = strnlen(z.a, 10);
z.b[0] = 5;
size_t b = strnlen(z.a, 10);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0)
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
use_two_stringsn(&z);
size_t c = strnlen(z.a, 10);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
extern void use_stringn(char *);
void strnlen_argument(char *x) {
size_t a = strnlen(x, 10);
size_t b = strnlen(x, 10);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0)
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
use_stringn(x);
size_t c = strnlen(x, 10);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
extern char global_strn[];
void strnlen_global() {
size_t a = strnlen(global_strn, 10);
size_t b = strnlen(global_strn, 10);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0)
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
// Call a function with unknown effects, which should invalidate globals.
use_stringn(0);
size_t c = strnlen(global_strn, 10);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}
void strnlen_indirect(char *x) {
@@ -101,13 +101,13 @@ void strnlen_indirect(char *x) {
char *p = x;
char **p2 = &p;
size_t b = strnlen(x, 10);
- if (a == 0 && b != 0)
- (void)*(char*)0; // expected-warning{{never executed}}
+ if (a == 0)
+ clang_analyzer_eval(b == 0); // expected-warning{{TRUE}}
extern void use_stringn_ptr(char*const*);
use_stringn_ptr(p2);
size_t c = strnlen(x, 10);
- if (a == 0 && c != 0)
- (void)*(char*)0; // expected-warning{{null}}
+ if (a == 0)
+ clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}}
}