1 // RUN: %clang_cc1 -analyze -analyzer-checker=alpha.core -analyzer-checker=deadcode.DeadStores -verify %s 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; // expected-note{{forward declaration of class here}} 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; 25 NSPredicate *isSearchablePredicate = [NSPredicate predicateWithFormat:@"isSearchable == YES"]; // expected-warning{{receiver 'NSPredicate' is a forward class and corresponding}} // expected-warning{{return type defaults to 'id'}} 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 } 35 while (1) {} 36 } 37 @end 38