aboutsummaryrefslogtreecommitdiff
path: root/clang/test/Analysis/objc-for.m
AgeCommit message (Collapse)AuthorFilesLines
2013-11-08[analyzer] Track whether an ObjC for-in loop had zero iterations.Jordan Rose1-6/+131
An Objective-C for-in loop will have zero iterations if the collection is empty. Previously, we could only detect this case if the program asked for the collection's -count /before/ the for-in loop. Now, the analyzer distinguishes for-in loops that had zero iterations from those with at least one, and can use this information to constrain the result of calling -count after the loop. In order to make this actually useful, teach the checker that methods on NSArray, NSDictionary, and the other immutable collection classes don't change the count. <rdar://problem/14992886> llvm-svn: 194235
2013-06-22[analyzer] Use output form collections’ count to decide if ObjC for loop ↵Anna Zaks1-0/+131
should be entered This fixes false positives by allowing us to know that a loop is always entered if the collection count method returns a positive value and vice versa. Addresses radar://14169391. llvm-svn: 184618
2013-04-26[analyzer] An ObjC for-in loop runs 0 times if the collection is nil.Jordan Rose1-1/+13
In an Objective-C for-in loop "for (id element in collection) {}", the loop will run 0 times if the collection is nil. This is because the for-in loop is implemented using a protocol method that returns 0 when there are no elements to iterate, and messages to nil will result in a 0 return value. At some point we may want to actually model this message send, but for now we may as well get the nil case correct, and avoid the false positives that would come with this case. <rdar://problem/13744632> llvm-svn: 180639
2012-09-26Fix two more tests that didn't do anything.Nico Weber1-1/+1
Found with find test -type f | xargs grep RUN: | grep '%clang' | grep -iv '%s' | grep -v '%t' | grep -v '\\$' llvm-svn: 164678
2012-06-11[analyzer] Add ObjCLoopChecker: objects from NSArray et al are non-nil.Jordan Rose1-0/+58
While collections containing nil elements can still be iterated over in an Objective-C for-in loop, the most common Cocoa collections -- NSArray, NSDictionary, and NSSet -- cannot contain nil elements. This checker adds that assumption to the analyzer state. This was the cause of some minor false positives concerning CFRelease calls on objects in an NSArray. llvm-svn: 158319