aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/string.c
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-03-20 20:36:01 +0000
committerJordan Rose <jordan_rose@apple.com>2013-03-20 20:36:01 +0000
commitf8e2c06cea1548c437761cb65cfbf97d50a057a7 (patch)
tree0c1705965385e119ef57f931d76739b565772b06 /test/Analysis/string.c
parent74f6982232c25ae723b1cc5abc59665a10867f21 (diff)
[analyzer] Don't invalidate globals when there's no call involved.
This fixes some mistaken condition logic in RegionStore that caused global variables to be invalidated when /any/ region was invalidated, rather than only as part of opaque function calls. This was only being used by CStringChecker, and so users will now see that strcpy() and friends do not invalidate global variables. Also, add a test case we don't handle properly: explicitly-assigned global variables aren't being invalidated by opaque calls. This is being tracked by <rdar://problem/13464044>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177572 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/string.c')
-rw-r--r--test/Analysis/string.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/test/Analysis/string.c b/test/Analysis/string.c
index 17a93ec013..74cf33c4bc 100644
--- a/test/Analysis/string.c
+++ b/test/Analysis/string.c
@@ -279,12 +279,16 @@ void strcpy_fn_const(char *x) {
strcpy(x, (const char*)&strcpy_fn); // expected-warning{{Argument to string copy function is the address of the function 'strcpy_fn', which is not a null-terminated string}}
}
+extern int globalInt;
void strcpy_effects(char *x, char *y) {
char a = x[0];
+ if (globalInt != 42)
+ return;
clang_analyzer_eval(strcpy(x, y) == x); // expected-warning{{TRUE}}
clang_analyzer_eval(strlen(x) == strlen(y)); // expected-warning{{TRUE}}
clang_analyzer_eval(a == x[0]); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(globalInt == 42); // expected-warning{{TRUE}}
}
void strcpy_overflow(char *y) {