| 1 |
// RUN: %clang_analyze_cc1 -w -Wno-int-conversion %s -verify \ |
| 2 |
// RUN: -analyzer-checker=core,alpha.core,debug.ExprInspection |
| 3 |
|
| 4 |
#ifdef HEADER // A clever trick to avoid splitting up the test. |
| 5 |
extern void clang_analyzer_eval(int); |
| 6 |
|
| 7 |
@interface NSObject |
| 8 |
@end |
| 9 |
|
| 10 |
@interface HeaderClass : NSObject |
| 11 |
@property NSObject *prop; |
| 12 |
@end |
| 13 |
|
| 14 |
#else |
| 15 |
#define HEADER |
| 16 |
#include "ObjCProperties.m" |
| 17 |
|
| 18 |
@implementation HeaderClass |
| 19 |
- (void)foo { |
| 20 |
if ((self.prop)) { |
| 21 |
} |
| 22 |
|
| 23 |
// This test tests that no dynamic bifurcation is performed on the property. |
| 24 |
// The TRUE/FALSE dilemma correctly arises from eagerly-assume behavior |
| 25 |
// inside the if-statement. The dynamic bifurcation at (self.prop) inside |
| 26 |
// the if-statement was causing an UNKNOWN to show up as well due to |
| 27 |
// extra parentheses being caught inside PseudoObjectExpr. |
| 28 |
// This should not be UNKNOWN. |
| 29 |
clang_analyzer_eval(self.prop); // expected-warning{{TRUE}} |
| 30 |
// expected-warning@-1{{FALSE}} |
| 31 |
} |
| 32 |
@end |
| 33 |
|
| 34 |
|
| 35 |
// The point of this test cases is to exercise properties in the static |
| 36 |
// analyzer |
| 37 |
|
| 38 |
@interface MyClass { |
| 39 |
@private |
| 40 |
id _X; |
| 41 |
} |
| 42 |
- (id)initWithY:(id)Y; |
| 43 |
@property(copy, readwrite) id X; |
| 44 |
@end |
| 45 |
|
| 46 |
@implementation MyClass |
| 47 |
@synthesize X = _X; |
| 48 |
- (id)initWithY:(id)Y { |
| 49 |
self.X = Y; |
| 50 |
return self; |
| 51 |
} |
| 52 |
@end |
| 53 |
#endif |