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