xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/rdar-6540084.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.core -analyzer-checker=deadcode.DeadStores -verify %s
2*f4a2713aSLionel Sambuc//
3*f4a2713aSLionel Sambuc// This test exercises the live variables analysis (LiveVariables.cpp).
4*f4a2713aSLionel Sambuc// The case originally identified a non-termination bug.
5*f4a2713aSLionel Sambuc//
6*f4a2713aSLionel Sambuctypedef signed char BOOL;
7*f4a2713aSLionel Sambuctypedef unsigned int NSUInteger;
8*f4a2713aSLionel Sambuctypedef struct _NSZone NSZone;
9*f4a2713aSLionel Sambuc@protocol NSObject  - (BOOL)isEqual:(id)object; @end
10*f4a2713aSLionel Sambuc@interface NSObject <NSObject> {} @end
11*f4a2713aSLionel Sambucextern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
12*f4a2713aSLionel Sambuc@class NSArray; // expected-note {{receiver is instance of class declared here}}
13*f4a2713aSLionel Sambuc@class NSMutableArray, NSIndexSet, NSView, NSPredicate, NSString, NSViewAnimation, NSTimer; // expected-note{{forward declaration of class here}}
14*f4a2713aSLionel Sambuc@interface FooBazController : NSObject {}
15*f4a2713aSLionel Sambuc@end
16*f4a2713aSLionel Sambuctypedef struct {} TazVersion;
17*f4a2713aSLionel Sambuc@class TazNode;
18*f4a2713aSLionel Sambuc@interface TazGuttenberg : NSObject {} typedef NSUInteger BugsBunnyType; @end // expected-note {{receiver is instance of class declared here}}
19*f4a2713aSLionel Sambuc@interface FooBaz : NSObject {}
20*f4a2713aSLionel Sambuc@property (nonatomic) BugsBunnyType matchType;
21*f4a2713aSLionel Sambuc@property (nonatomic, retain) NSArray *papyrus; @end
22*f4a2713aSLionel Sambuc@implementation FooBazController
23*f4a2713aSLionel Sambuc- (NSArray *)excitingStuff:(FooBaz *)options {
24*f4a2713aSLionel Sambuc  BugsBunnyType matchType = options.matchType;
25*f4a2713aSLionel Sambuc  NSPredicate *isSearchablePredicate = [NSPredicate predicateWithFormat:@"isSearchable == YES"]; // expected-warning{{receiver 'NSPredicate' is a forward class and corresponding}} // expected-warning{{return type defaults to 'id'}}
26*f4a2713aSLionel Sambuc  for (TazGuttenberg *Guttenberg in options.papyrus) {
27*f4a2713aSLionel Sambuc    NSArray *GuttenbergNodes = [Guttenberg nodes]; // expected-warning{{return type defaults to 'id'}}
28*f4a2713aSLionel Sambuc    NSArray *searchableNodes = [GuttenbergNodes filteredArrayUsingPredicate:isSearchablePredicate]; // expected-warning{{return type defaults to 'id'}}
29*f4a2713aSLionel Sambuc    for (TazNode *node in searchableNodes) {
30*f4a2713aSLionel Sambuc      switch (matchType) {
31*f4a2713aSLionel Sambuc        default: break;
32*f4a2713aSLionel Sambuc      }
33*f4a2713aSLionel Sambuc    }
34*f4a2713aSLionel Sambuc  }
35*f4a2713aSLionel Sambuc  while (1) {}
36*f4a2713aSLionel Sambuc}
37*f4a2713aSLionel Sambuc@end
38