[cfe-commits] r125424 - /cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
Ted Kremenek
kremenek at apple.com
Fri Feb 11 17:25:04 PST 2011
Author: kremenek
Date: Fri Feb 11 19:25:04 2011
New Revision: 125424
URL: http://llvm.org/viewvc/llvm-project?rev=125424&view=rev
Log:
Add test case for <rdar://problem/6888289>.
Added:
cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
Added: cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m?rev=125424&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m (added)
+++ cfe/trunk/test/Analysis/nil-receiver-undefined-larger-than-voidptr-ret-region.m Fri Feb 11 19:25:04 2011
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-constraints=range -analyzer-store=region -verify %s
+
+// <rdar://problem/6888289> - This test case shows that a nil instance
+// variable can possibly be initialized by a method.
+typedef struct RDar6888289_data {
+ long data[100];
+} RDar6888289_data;
+
+ at interface RDar6888289
+{
+ RDar6888289 *x;
+}
+- (RDar6888289_data) test;
+- (RDar6888289_data) test2;
+- (void) invalidate;
+- (RDar6888289_data) getData;
+ at end
+
+ at implementation RDar6888289
+- (RDar6888289_data) test {
+ if (!x)
+ [self invalidate];
+ return [x getData];
+}
+- (RDar6888289_data) test2 {
+ if (!x) {}
+ return [x getData]; // expected-warning{{The receiver of message 'getData' is nil and returns a value of type 'RDar6888289_data' that will be garbage}}
+}
+
+- (void) invalidate {
+ x = self;
+}
+
+- (RDar6888289_data) getData {
+ return (RDar6888289_data) { 0 };
+}
+ at end
+
More information about the cfe-commits
mailing list