xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/PR3991.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 -Wno-incomplete-implementation %s
2*f4a2713aSLionel Sambuc// expected-no-diagnostics
3*f4a2713aSLionel Sambuc
4*f4a2713aSLionel Sambuc//===----------------------------------------------------------------------===//
5*f4a2713aSLionel Sambuc// Delta-debugging produced forward declarations.
6*f4a2713aSLionel Sambuc//===----------------------------------------------------------------------===//
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambuctypedef signed char BOOL;
9*f4a2713aSLionel Sambuctypedef struct _NSZone NSZone;
10*f4a2713aSLionel Sambuc@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
11*f4a2713aSLionel Sambuc@protocol NSObject  - (BOOL)isEqual:(id)object;
12*f4a2713aSLionel Sambuc@end  @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
13*f4a2713aSLionel Sambuc@end  @protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone;
14*f4a2713aSLionel Sambuc@end  @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder;
15*f4a2713aSLionel Sambuc@end    @interface NSObject <NSObject> {
16*f4a2713aSLionel Sambuc}
17*f4a2713aSLionel Sambuc@end    extern id <NSObject> NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone);
18*f4a2713aSLionel Sambuc@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding>  - (unsigned)count;
19*f4a2713aSLionel Sambuc@end   @class NSTimer, NSPort, NSArray;
20*f4a2713aSLionel Sambuc@class NSURLHandle, NSMutableArray, NSMutableData, NSData, NSURL;
21*f4a2713aSLionel Sambuc@interface NSResponder : NSObject <NSCoding> {
22*f4a2713aSLionel Sambuc}
23*f4a2713aSLionel Sambuc@end      @class NSBitmapImageRep, NSCursor, NSGraphicsContext, NSImage, NSPasteboard, NSScrollView, NSWindow, NSAttributedString;
24*f4a2713aSLionel Sambuc@interface NSView : NSResponder {
25*f4a2713aSLionel Sambuc  struct __VFlags2 {
26*f4a2713aSLionel Sambuc  }
27*f4a2713aSLionel Sambuc  _vFlags2;
28*f4a2713aSLionel Sambuc}
29*f4a2713aSLionel Sambuc@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
30*f4a2713aSLionel Sambuc@interface NSBox : NSView {
31*f4a2713aSLionel Sambuc}
32*f4a2713aSLionel Sambuc@end @class GDataFeedDocList, GDataServiceTicket, GDataServiceTicket, IHGoogleDocsAdapter;
33*f4a2713aSLionel Sambuc@protocol IHGoogleDocsAdapterDelegate  - (void)googleDocsAdapter:(IHGoogleDocsAdapter*)inGoogleDocsAdapter accountVerifyIsValid:(BOOL)inIsValid error:(NSError *)inError;
34*f4a2713aSLionel Sambuc@end   @interface IHGoogleDocsAdapter : NSObject {
35*f4a2713aSLionel Sambuc}
36*f4a2713aSLionel Sambuc- (NSArray *)entries;
37*f4a2713aSLionel Sambuc@end extern Class const kGDataUseRegisteredClass ;
38*f4a2713aSLionel Sambuc@interface IHGoogleDocsAdapter ()  - (GDataFeedDocList *)feedDocList;
39*f4a2713aSLionel Sambuc- (NSArray *)directoryPathComponents;
40*f4a2713aSLionel Sambuc- (unsigned int)currentPathComponentIndex;
41*f4a2713aSLionel Sambuc- (void)setCurrentPathComponentIndex:(unsigned int)aCurrentPathComponentIndex;
42*f4a2713aSLionel Sambuc- (NSURL *)folderFeedURL;
43*f4a2713aSLionel Sambuc@end
44*f4a2713aSLionel Sambuc
45*f4a2713aSLionel Sambuc@implementation IHGoogleDocsAdapter    - (id)initWithUsername:(NSString *)inUsername password:(NSString *)inPassword owner:(NSObject <IHGoogleDocsAdapterDelegate> *)owner {
46*f4a2713aSLionel Sambuc  return 0;
47*f4a2713aSLionel Sambuc}
48*f4a2713aSLionel Sambuc
49*f4a2713aSLionel Sambuc//===----------------------------------------------------------------------===//
50*f4a2713aSLionel Sambuc// Actual test case:
51*f4a2713aSLionel Sambuc//
52*f4a2713aSLionel Sambuc// The analyzer currently doesn't reason about ObjCKVCRefExpr.  Have both
53*f4a2713aSLionel Sambuc// GRExprEngine::Visit and GRExprEngine::VisitLValue have such expressions
54*f4a2713aSLionel Sambuc// evaluate to UnknownVal.
55*f4a2713aSLionel Sambuc//===----------------------------------------------------------------------===//
56*f4a2713aSLionel Sambuc
57*f4a2713aSLionel Sambuc- (void)docListListFetchTicket:(GDataServiceTicket *)ticket               finishedWithFeed:(GDataFeedDocList *)feed {
58*f4a2713aSLionel Sambuc  BOOL doGetDir = self.directoryPathComponents != 0 && self.currentPathComponentIndex < [self.directoryPathComponents count];
59*f4a2713aSLionel Sambuc  if (doGetDir)  {
60*f4a2713aSLionel Sambuc    BOOL isDirExisting = [[self.feedDocList entries] count] > 0;
61*f4a2713aSLionel Sambuc    if (isDirExisting)   {
62*f4a2713aSLionel Sambuc      if (self.folderFeedURL != 0)    {
63*f4a2713aSLionel Sambuc        if (++self.currentPathComponentIndex == [self.directoryPathComponents count])     {
64*f4a2713aSLionel Sambuc        }
65*f4a2713aSLionel Sambuc      }
66*f4a2713aSLionel Sambuc    }
67*f4a2713aSLionel Sambuc  }
68*f4a2713aSLionel Sambuc}
69*f4a2713aSLionel Sambuc@end
70