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