| 1 | // RUN: %clang_analyze_cc1 -triple i386-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s |
| 2 | // RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s |
| 3 | // expected-no-diagnostics |
| 4 | |
| 5 | //===------------------------------------------------------------------------------------------===// |
| 6 | // This files tests our path-sensitive handling of Objective-c++ files. |
| 7 | //===------------------------------------------------------------------------------------------===// |
| 8 | |
| 9 | // Test basic handling of references. |
| 10 | char &test1_aux(); |
| 11 | char *test1() { |
| 12 | return &test1_aux(); |
| 13 | } |
| 14 | |
| 15 | // Test test1_aux() evaluates to char &. |
| 16 | char test1_as_rvalue() { |
| 17 | return test1_aux(); |
| 18 | } |
| 19 | |
| 20 | // Test basic handling of references with Objective-C classes. |
| 21 | @interface Test1 |
| 22 | - (char&) foo; |
| 23 | @end |
| 24 | |
| 25 | char* Test1_harness(Test1 *p) { |
| 26 | return &[p foo]; |
| 27 | } |
| 28 | |
| 29 | char Test1_harness_b(Test1 *p) { |
| 30 | return [p foo]; |
| 31 | } |
| 32 | |
| 33 | // Basic test of C++ references with Objective-C pointers. |
| 34 | @interface RDar10569024 |
| 35 | @property(readonly) int x; |
| 36 | @end |
| 37 | |
| 38 | typedef RDar10569024* RDar10569024Ref; |
| 39 | |
| 40 | void rdar10569024_aux(RDar10569024Ref o); |
| 41 | |
| 42 | int rdar10569024(id p, id collection) { |
| 43 | for (id elem in collection) { |
| 44 | const RDar10569024Ref &o = (RDar10569024Ref) elem; |
| 45 | rdar10569024_aux(o); // no-warning |
| 46 | return o.x; // no-warning |
| 47 | } |
| 48 | return 0; |
| 49 | } |
| 50 | |