Ted Kremenek | cd9902b | 2010-02-05 01:52:40 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-dead-stores -verify %s |
Ted Kremenek | bf98c99 | 2009-01-30 21:35:30 +0000 | [diff] [blame] | 2 | // |
| 3 | // This test exercises the live variables analysis (LiveVariables.cpp). |
| 4 | // The case originally identified a non-termination bug. |
| 5 | // |
| 6 | typedef signed char BOOL; |
| 7 | typedef unsigned int NSUInteger; |
| 8 | typedef struct _NSZone NSZone; |
| 9 | @protocol NSObject - (BOOL)isEqual:(id)object; @end |
| 10 | @interface NSObject <NSObject> {} @end |
| 11 | extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); |
| 12 | @class NSArray; |
| 13 | @class NSMutableArray, NSIndexSet, NSView, NSPredicate, NSString, NSViewAnimation, NSTimer; |
| 14 | @interface FooBazController : NSObject {} |
| 15 | @end |
| 16 | typedef struct {} TazVersion; |
| 17 | @class TazNode; |
| 18 | @interface TazGuttenberg : NSObject {} typedef NSUInteger BugsBunnyType; @end |
| 19 | @interface FooBaz : NSObject {} |
| 20 | @property (nonatomic) BugsBunnyType matchType; |
| 21 | @property (nonatomic, retain) NSArray *papyrus; @end |
| 22 | @implementation FooBazController |
| 23 | - (NSArray *)excitingStuff:(FooBaz *)options { |
| 24 | BugsBunnyType matchType = options.matchType; |
Fariborz Jahanian | 9f8f026 | 2009-05-08 23:45:49 +0000 | [diff] [blame] | 25 | NSPredicate *isSearchablePredicate = [NSPredicate predicateWithFormat:@"isSearchable == YES"]; // expected-warning{{receiver 'NSPredicate' is a forward class and corresponding}} // expected-warning{{return type defaults to 'id'}} |
Ted Kremenek | bf98c99 | 2009-01-30 21:35:30 +0000 | [diff] [blame] | 26 | for (TazGuttenberg *Guttenberg in options.papyrus) { |
| 27 | NSArray *GuttenbergNodes = [Guttenberg nodes]; // expected-warning{{return type defaults to 'id'}} |
| 28 | NSArray *searchableNodes = [GuttenbergNodes filteredArrayUsingPredicate:isSearchablePredicate]; // expected-warning{{return type defaults to 'id'}} |
| 29 | for (TazNode *node in searchableNodes) { |
| 30 | switch (matchType) { |
| 31 | default: break; |
| 32 | } |
| 33 | } |
| 34 | } |
Mike Stump | 28b2227 | 2009-07-21 18:56:04 +0000 | [diff] [blame] | 35 | while (1) {} |
Ted Kremenek | bf98c99 | 2009-01-30 21:35:30 +0000 | [diff] [blame] | 36 | } |
| 37 | @end |