| 1 |
// RUN: %clang_analyze_cc1 %s -o %t |
| 2 |
|
| 3 |
// Tests that some specific checkers are enabled by default. |
| 4 |
|
| 5 |
id 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 |
// 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. |
| 24 |
typedef double CGFloat; |
| 25 |
|
| 26 |
struct CGPoint { |
| 27 |
CGFloat x; |
| 28 |
CGFloat y; |
| 29 |
}; |
| 30 |
typedef struct CGPoint CGPoint; |
| 31 |
|
| 32 |
struct CGSize { |
| 33 |
CGFloat width; |
| 34 |
CGFloat height; |
| 35 |
}; |
| 36 |
typedef struct CGSize CGSize; |
| 37 |
|
| 38 |
struct CGRect { |
| 39 |
CGPoint origin; |
| 40 |
CGSize size; |
| 41 |
}; |
| 42 |
typedef struct CGRect CGRect; |
| 43 |
|
| 44 |
typedef CGRect NSRect; |
| 45 |
typedef CGSize NSSize; |
| 46 |
|
| 47 |
static __inline__ __attribute__((always_inline)) CGFloat NSWidth(NSRect aRect) { |
| 48 |
return (aRect.size.width); |
| 49 |
} |
| 50 |
|
| 51 |
static __inline__ __attribute__((always_inline)) CGFloat NSHeight(NSRect aRect) { |
| 52 |
return (aRect.size.height); |
| 53 |
} |
| 54 |
|
| 55 |
NSSize rdar880566_size(void); |
| 56 |
|
| 57 |
double rdar8808566(void) { |
| 58 |
NSRect myRect; |
| 59 |
myRect.size = rdar880566_size(); |
| 60 |
double x = NSWidth(myRect) + NSHeight(myRect); // no-warning |
| 61 |
return x; |
| 62 |
} |
| 63 |
|