1// RUN: %clang --analyze %s -o %t
2
3// Tests that some specific checkers are enabled by default.
4
5id foo(int x) {
6  id title;
7  switch (x) {
8  case 1:
9    title = @"foo"; // expected-warning {{never read}}
10  case 2:
11    title = @"bar";
12    break;
13  default:
14    title = @"baz";
15    break;
16  }
17  return title;
18}
19
20// <rdar://problem/8808566> Static analyzer is wrong: NSWidth(imgRect) not understood as unconditional assignment
21//
22// Note: this requires inlining support.  This previously issued a false positive use of
23// uninitialized value when calling NSWidth.
24typedef double CGFloat;
25
26struct CGPoint {
27  CGFloat x;
28  CGFloat y;
29};
30typedef struct CGPoint CGPoint;
31
32struct CGSize {
33  CGFloat width;
34  CGFloat height;
35};
36typedef struct CGSize CGSize;
37
38struct CGRect {
39  CGPoint origin;
40  CGSize size;
41};
42typedef struct CGRect CGRect;
43
44typedef CGRect NSRect;
45typedef CGSize NSSize;
46
47static __inline__ __attribute__((always_inline)) CGFloat NSWidth(NSRect aRect) {
48    return (aRect.size.width);
49}
50
51static __inline__ __attribute__((always_inline)) CGFloat NSHeight(NSRect aRect) {
52    return (aRect.size.height);
53}
54
55NSSize rdar880566_size();
56
57double rdar8808566() {
58  NSRect myRect;
59  myRect.size = rdar880566_size();
60  double x = NSWidth(myRect) + NSHeight(myRect); // no-warning
61  return x;
62}
63
64