]> granicus.if.org Git - clang/commitdiff
[analyzer] Track the count of NSOrderedSet similarly to other fast enumerations.
authorAnna Zaks <ganna@apple.com>
Mon, 4 Nov 2013 19:13:08 +0000 (19:13 +0000)
committerAnna Zaks <ganna@apple.com>
Mon, 4 Nov 2013 19:13:08 +0000 (19:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194005 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/BasicObjCFoundationChecks.cpp
test/Analysis/NSContainers.m

index 96f3f93021c1bf6380ccb1d9f51816d73c7c113e..d6ebbefc193b2f38ea025a2a477d5024910a6dd4 100644 (file)
@@ -1000,7 +1000,8 @@ void ObjCLoopChecker::checkPostObjCMessage(const ObjCMethodCall &M,
   FoundationClass Class = findKnownClass(ClassID);
   if (Class != FC_NSDictionary &&
       Class != FC_NSArray &&
-      Class != FC_NSSet)
+      Class != FC_NSSet &&
+      Class != FC_NSOrderedSet)
     return;
 
   SymbolRef ContainerS = M.getReceiverSVal().getAsSymbol();
index d31c7b1ff0326fbfff9c95080d5cda536b2f06fb..a9e76fbbcaba34fcfa8ed04605cedda8b8d30794 100644 (file)
@@ -90,6 +90,12 @@ typedef struct {
 
 @end
 
+@interface NSOrderedSet : NSObject <NSFastEnumeration>
+@end
+@interface NSOrderedSet (NSOrderedSetCreation)
+- (NSUInteger)count;
+@end
+
 @interface NSString : NSObject <NSCopying, NSMutableCopying, NSSecureCoding>
 
 @end
@@ -260,4 +266,13 @@ void testCollectionIsNotEmptyWhenCountIsGreaterThanZero(NSMutableDictionary *D){
   }
 }
 
+void testCountAwareNSOrderedSet(NSOrderedSet *containers, int *validptr) {
+       int *x = 0;
+  NSUInteger containerCount = [containers count];
+  if (containerCount > 0)    
+               x = validptr;
+       for (id c in containers) {
+               *x = 1; // no warning
+       }
+}