[cfe-commits] r69754 - in /cfe/trunk: lib/Analysis/GRExprEngine.cpp test/Analysis/PR3991.m

Ted Kremenek kremenek at apple.com
Tue Apr 21 16:53:32 PDT 2009


Author: kremenek
Date: Tue Apr 21 18:53:32 2009
New Revision: 69754

URL: http://llvm.org/viewvc/llvm-project?rev=69754&view=rev
Log:
Fix crash reported in PR 3991.  The analyzer doesn't reason about ObjCKVCExpr.

Added:
    cfe/trunk/test/Analysis/PR3991.m
Modified:
    cfe/trunk/lib/Analysis/GRExprEngine.cpp

Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=69754&r1=69753&r2=69754&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Tue Apr 21 18:53:32 2009
@@ -486,6 +486,7 @@
       return;
       
     case Stmt::ObjCPropertyRefExprClass:
+    case Stmt::ObjCKVCRefExprClass:
       // FIXME: Property assignments are lvalues, but not really "locations".
       //  e.g.:  self.x = something;
       //  Here the "self.x" really can translate to a method call (setter) when

Added: cfe/trunk/test/Analysis/PR3991.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/PR3991.m?rev=69754&view=auto

==============================================================================
--- cfe/trunk/test/Analysis/PR3991.m (added)
+++ cfe/trunk/test/Analysis/PR3991.m Tue Apr 21 18:53:32 2009
@@ -0,0 +1,67 @@
+// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s &&
+// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s &&
+// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify -triple x86_64-apple-darwin9 %s &&
+// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify -triple x86_64-apple-darwin9 %s
+
+//===----------------------------------------------------------------------===//
+// Delta-debugging produced forward declarations.
+//===----------------------------------------------------------------------===//
+
+typedef signed char BOOL;
+typedef struct _NSZone NSZone;
+ at class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
+ at protocol NSObject  - (BOOL)isEqual:(id)object;
+ at end  @protocol NSCopying  - (id)copyWithZone:(NSZone *)zone;
+ at end  @protocol NSMutableCopying  - (id)mutableCopyWithZone:(NSZone *)zone;
+ at end  @protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder;
+ at end    @interface NSObject <NSObject> {
+}
+ at end    extern id <NSObject> NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone);
+ at interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding>  - (unsigned)count;
+ at end   @class NSTimer, NSPort, NSArray;
+ at class NSURLHandle, NSMutableArray, NSMutableData, NSData, NSURL;
+ at interface NSResponder : NSObject <NSCoding> {
+}
+ at end      @class NSBitmapImageRep, NSCursor, NSGraphicsContext, NSImage, NSPasteboard, NSScrollView, NSWindow, NSAttributedString;
+ at interface NSView : NSResponder {
+  struct __VFlags2 {
+  }
+  _vFlags2;
+}
+ at end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
+ at interface NSBox : NSView {
+}
+ at end @class GDataFeedDocList, GDataServiceTicket, GDataServiceTicket, IHGoogleDocsAdapter;
+ at protocol IHGoogleDocsAdapterDelegate  - (void)googleDocsAdapter:(IHGoogleDocsAdapter*)inGoogleDocsAdapter accountVerifyIsValid:(BOOL)inIsValid error:(NSError *)inError;
+ at end   @interface IHGoogleDocsAdapter : NSObject {
+}
+- (NSArray *)entries;
+ at end extern Class const kGDataUseRegisteredClass ;
+ at interface IHGoogleDocsAdapter ()  - (GDataFeedDocList *)feedDocList;
+- (NSArray *)directoryPathComponents;
+- (unsigned int)currentPathComponentIndex;
+- (void)setCurrentPathComponentIndex:(unsigned int)aCurrentPathComponentIndex;
+- (NSURL *)folderFeedURL;
+ at end  @implementation IHGoogleDocsAdapter    - (id)initWithUsername:(NSString *)inUsername password:(NSString *)inPassword owner:(NSObject <IHGoogleDocsAdapterDelegate> *)owner {
+}
+
+//===----------------------------------------------------------------------===//
+// Actual test case:
+//
+// The analyzer currently doesn't reason about ObjCKVCRefExpr.  Have both
+// GRExprEngine::Visit and GRExprEngine::VisitLValue have such expressions
+// evaluate to UnknownVal.
+//===----------------------------------------------------------------------===//
+
+- (void)docListListFetchTicket:(GDataServiceTicket *)ticket               finishedWithFeed:(GDataFeedDocList *)feed {
+  BOOL doGetDir = self.directoryPathComponents != 0 && self.currentPathComponentIndex < [self.directoryPathComponents count];
+  if (doGetDir)  {
+    BOOL isDirExisting = [[self.feedDocList entries] count] > 0;
+    if (isDirExisting)   {
+      if (self.folderFeedURL != 0)    {
+        if (++self.currentPathComponentIndex == [self.directoryPathComponents count])     {
+        }
+      }
+    }
+  }
+}





More information about the cfe-commits mailing list