aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-03-19 23:01:57 +0000
committerJordan Rose <jordan_rose@apple.com>2013-03-19 23:01:57 +0000
commit4d25b51d582bc7a6a4d83be1642be2f4e812beef (patch)
tree5e3de646ff69f257a53922a646d159150d1fc0a6 /test
parent9f3495aeaa24da4eacf8f6c274adcef65e2f3617 (diff)
[analyzer] Add an integer version of the Circle tests in uninit-vals.m.
A floating-point version is nice for testing unknown values, but it's good to be able to check all parts of the structure as well. Test change only, no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@177455 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Analysis/uninit-vals.m53
1 files changed, 49 insertions, 4 deletions
diff --git a/test/Analysis/uninit-vals.m b/test/Analysis/uninit-vals.m
index 9f611ade69..5a97bef200 100644
--- a/test/Analysis/uninit-vals.m
+++ b/test/Analysis/uninit-vals.m
@@ -73,18 +73,63 @@ void PR14765_test() {
free(testObj);
}
-void PR14765_incorrectBehavior(Circle *testObj) {
+void PR14765_argument(Circle *testObj) {
int oldSize = testObj->size;
-
clang_analyzer_eval(testObj->size == oldSize); // expected-warning{{TRUE}}
testObj->origin = makePoint(0.0, 0.0);
-
clang_analyzer_eval(testObj->size == oldSize); // expected-warning{{TRUE}}
-
+}
+
+
+typedef struct {
+ int x;
+ int y;
+} IntPoint;
+typedef struct {
+ IntPoint origin;
+ int size;
+} IntCircle;
+
+IntPoint makeIntPoint(int x, int y) {
+ IntPoint result;
+ result.x = x;
+ result.y = y;
+ return result;
+}
+
+void PR14765_test_int() {
+ IntCircle *testObj = calloc(sizeof(IntCircle), 1);
+
+ clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(testObj->origin.x == 0); // expected-warning{{TRUE}}
+ clang_analyzer_eval(testObj->origin.y == 0); // expected-warning{{TRUE}}
+
+ testObj->origin = makeIntPoint(1, 2);
+ if (testObj->size > 0) { ; } // warning occurs here
+
+ // FIXME: Assigning to 'testObj->origin' kills the default binding for the
+ // whole region, meaning that we've forgotten that testObj->size should also
+ // default to 0. Tracked by <rdar://problem/12701038>.
+ // This should be TRUE.
+ clang_analyzer_eval(testObj->size == 0); // expected-warning{{UNKNOWN}}
+ clang_analyzer_eval(testObj->origin.x == 1); // expected-warning{{TRUE}}
+ clang_analyzer_eval(testObj->origin.y == 2); // expected-warning{{TRUE}}
+
free(testObj);
}
+void PR14765_argument_int(IntCircle *testObj) {
+ int oldSize = testObj->size;
+ clang_analyzer_eval(testObj->size == oldSize); // expected-warning{{TRUE}}
+
+ testObj->origin = makeIntPoint(1, 2);
+ clang_analyzer_eval(testObj->size == oldSize); // expected-warning{{TRUE}}
+ clang_analyzer_eval(testObj->origin.x == 1); // expected-warning{{TRUE}}
+ clang_analyzer_eval(testObj->origin.y == 2); // expected-warning{{TRUE}}
+}
+
+
void rdar13292559(Circle input) {
extern void useCircle(Circle);