| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s |
| 2 |
// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify -fobjc-arc %s |
| 3 |
|
| 4 |
#if __has_feature(objc_arc) |
| 5 |
// expected-no-diagnostics |
| 6 |
#endif |
| 7 |
|
| 8 |
@interface SomeClass |
| 9 |
@end |
| 10 |
|
| 11 |
void simpleStrongPointerValue(void) { |
| 12 |
SomeClass *x; |
| 13 |
if (x) {} |
| 14 |
#if !__has_feature(objc_arc) |
| 15 |
// expected-warning@-2{{Branch condition evaluates to a garbage value}} |
| 16 |
#endif |
| 17 |
} |
| 18 |
|
| 19 |
void simpleArray(void) { |
| 20 |
SomeClass *vlaArray[5]; |
| 21 |
|
| 22 |
if (vlaArray[0]) {} |
| 23 |
#if !__has_feature(objc_arc) |
| 24 |
// expected-warning@-2{{Branch condition evaluates to a garbage value}} |
| 25 |
#endif |
| 26 |
} |
| 27 |
|
| 28 |
void variableLengthArray(void) { |
| 29 |
int count = 1; |
| 30 |
SomeClass * vlaArray[count]; |
| 31 |
|
| 32 |
if (vlaArray[0]) {} |
| 33 |
#if !__has_feature(objc_arc) |
| 34 |
// expected-warning@-2{{Branch condition evaluates to a garbage value}} |
| 35 |
#endif |
| 36 |
} |
| 37 |
|
| 38 |
void variableLengthArrayWithExplicitStrongAttribute(void) { |
| 39 |
int count = 1; |
| 40 |
__attribute__((objc_ownership(strong))) SomeClass * vlaArray[count]; |
| 41 |
|
| 42 |
if (vlaArray[0]) {} |
| 43 |
#if !__has_feature(objc_arc) |
| 44 |
// expected-warning@-2{{Branch condition evaluates to a garbage value}} |
| 45 |
#endif |
| 46 |
} |