]> granicus.if.org Git - clang/commitdiff
[analyzer] Add a test that messages to super invalidate ivars.
authorJordan Rose <jordan_rose@apple.com>
Tue, 31 Jul 2012 02:05:30 +0000 (02:05 +0000)
committerJordan Rose <jordan_rose@apple.com>
Tue, 31 Jul 2012 02:05:30 +0000 (02:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161021 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/ivars.m [new file with mode: 0644]

diff --git a/test/Analysis/ivars.m b/test/Analysis/ivars.m
new file mode 100644 (file)
index 0000000..cd01a28
--- /dev/null
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -fblocks -verify -Wno-objc-root-class %s
+
+void clang_analyzer_eval(int);
+
+@interface Root {
+@public
+  int uniqueID;
+}
+
+- (void)refreshID;
+@end
+
+void testInvalidation(Root *obj) {
+  int savedID = obj->uniqueID;
+  clang_analyzer_eval(savedID == obj->uniqueID); // expected-warning{{TRUE}}
+
+  [obj refreshID];
+  clang_analyzer_eval(savedID == obj->uniqueID); // expected-warning{{UNKNOWN}}
+}
+
+
+@interface Child : Root
+@end
+
+@implementation Child
+- (void)testSuperInvalidation {
+  int savedID = self->uniqueID;
+  clang_analyzer_eval(savedID == self->uniqueID); // expected-warning{{TRUE}}
+
+  [super refreshID];
+  clang_analyzer_eval(savedID == self->uniqueID); // expected-warning{{UNKNOWN}}
+}
+@end