| Daniel Dunbar | a572887 | 2009-12-15 20:14:24 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-constraints=basic -analyzer-store=basic %s -verify | 
 | 2 | // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-constraints=basic -analyzer-store=region %s -verify | 
| Ted Kremenek | 98f1e1c | 2009-02-19 04:07:38 +0000 | [diff] [blame] | 3 |  | 
 | 4 | typedef struct Foo { int x; } Bar; | 
 | 5 |  | 
 | 6 | @interface MyClass {} | 
 | 7 | - (Bar)foo; | 
 | 8 | @end | 
 | 9 | @implementation MyClass | 
 | 10 | - (Bar)foo {  | 
 | 11 |   struct Foo f = { 0 }; | 
 | 12 |   return f; | 
 | 13 | } | 
 | 14 | @end | 
 | 15 |  | 
 | 16 | void createFoo() { | 
 | 17 |   MyClass *obj = 0;   | 
| Ted Kremenek | fee96e0 | 2009-11-24 21:41:28 +0000 | [diff] [blame] | 18 |   Bar f = [obj foo]; // expected-warning{{The receiver of message 'foo' is nil and returns a value of type 'Bar' that will be garbage}} | 
| Ted Kremenek | 98f1e1c | 2009-02-19 04:07:38 +0000 | [diff] [blame] | 19 | } | 
 | 20 |  | 
| Ted Kremenek | b930d7a | 2009-04-01 06:52:48 +0000 | [diff] [blame] | 21 | void createFoo2() { | 
 | 22 |   MyClass *obj = 0;   | 
 | 23 |   [obj foo]; // no-warning | 
| Ted Kremenek | fee96e0 | 2009-11-24 21:41:28 +0000 | [diff] [blame] | 24 |   Bar f = [obj foo]; // expected-warning{{The receiver of message 'foo' is nil and returns a value of type 'Bar' that will be garbage}} | 
| Ted Kremenek | b930d7a | 2009-04-01 06:52:48 +0000 | [diff] [blame] | 25 | } | 
 | 26 |  |