diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-01-11 07:40:00 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2010-01-11 07:40:00 +0000 |
commit | 951b334069f77c0af424e5ea15b75f4ee17b4583 (patch) | |
tree | 5015ec45c58a4b3a6cb17e35ee580e7b73d9f694 | |
parent | 604848a49d2a9c0985225bbe3a39fca223e961bb (diff) |
Enhance ScanReachableSymbols::scan(). Now another OSAtomic test case passes.
The old test case has a little mistake.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93148 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/GRState.cpp | 3 | ||||
-rw-r--r-- | test/Analysis/NSString-failed-cases.m | 106 | ||||
-rw-r--r-- | test/Analysis/NSString.m | 8 |
3 files changed, 11 insertions, 106 deletions
diff --git a/lib/Analysis/GRState.cpp b/lib/Analysis/GRState.cpp index 7415fa5f67..051d465f41 100644 --- a/lib/Analysis/GRState.cpp +++ b/lib/Analysis/GRState.cpp @@ -267,6 +267,9 @@ bool ScanReachableSymbols::scan(SVal val) { if (loc::MemRegionVal *X = dyn_cast<loc::MemRegionVal>(&val)) return scan(X->getRegion()); + if (nonloc::LocAsInteger *X = dyn_cast<nonloc::LocAsInteger>(&val)) + return scan(X->getLoc()); + if (SymbolRef Sym = val.getAsSymbol()) return visitor.VisitSymbol(Sym); diff --git a/test/Analysis/NSString-failed-cases.m b/test/Analysis/NSString-failed-cases.m deleted file mode 100644 index 699d142eec..0000000000 --- a/test/Analysis/NSString-failed-cases.m +++ /dev/null @@ -1,106 +0,0 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s -// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s -// XFAIL: * - -//===----------------------------------------------------------------------===// -// The following code is reduced using delta-debugging from -// Foundation.h (Mac OS X). -// -// It includes the basic definitions for the test cases below. -// Not directly including Foundation.h directly makes this test case -// both svelte and portable to non-Mac platforms. -//===----------------------------------------------------------------------===// - -#ifdef TEST_64 -typedef long long int64_t; -_Bool OSAtomicCompareAndSwap64Barrier( int64_t __oldValue, int64_t __newValue, volatile int64_t *__theValue ); -#define COMPARE_SWAP_BARRIER OSAtomicCompareAndSwap64Barrier -typedef int64_t intptr_t; -#else -typedef int int32_t; -_Bool OSAtomicCompareAndSwap32Barrier( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue ); -#define COMPARE_SWAP_BARRIER OSAtomicCompareAndSwap32Barrier -typedef int32_t intptr_t; -#endif - -typedef const void * CFTypeRef; -typedef const struct __CFString * CFStringRef; -typedef const struct __CFAllocator * CFAllocatorRef; -extern const CFAllocatorRef kCFAllocatorDefault; -extern CFTypeRef CFRetain(CFTypeRef cf); -void CFRelease(CFTypeRef cf); -typedef const struct __CFDictionary * CFDictionaryRef; -const void *CFDictionaryGetValue(CFDictionaryRef theDict, const void *key); -extern CFStringRef CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...); -typedef signed char BOOL; -typedef int NSInteger; -typedef unsigned int NSUInteger; -@class NSString, Protocol; -extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 1, 2))); -typedef NSInteger NSComparisonResult; -typedef struct _NSZone NSZone; -@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; -@protocol NSObject -- (BOOL)isEqual:(id)object; -- (oneway void)release; -- (id)retain; -- (id)autorelease; -@end -@protocol NSCopying -- (id)copyWithZone:(NSZone *)zone; -@end -@protocol NSMutableCopying -- (id)mutableCopyWithZone:(NSZone *)zone; -@end -@protocol NSCoding -- (void)encodeWithCoder:(NSCoder *)aCoder; -@end -@interface NSObject <NSObject> {} -- (id)init; -+ (id)alloc; -@end -extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); -typedef struct {} NSFastEnumerationState; -@protocol NSFastEnumeration -- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; -@end -@class NSString; -typedef struct _NSRange {} NSRange; -@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> -- (NSUInteger)count; -@end -@interface NSMutableArray : NSArray -- (void)addObject:(id)anObject; -- (id)initWithCapacity:(NSUInteger)numItems; -@end -typedef unsigned short unichar; -@class NSData, NSArray, NSDictionary, NSCharacterSet, NSData, NSURL, NSError, NSLocale; -typedef NSUInteger NSStringCompareOptions; -@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length; -- (NSComparisonResult)compare:(NSString *)string; -- (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask; -- (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask range:(NSRange)compareRange; -- (NSComparisonResult)compare:(NSString *)string options:(NSStringCompareOptions)mask range:(NSRange)compareRange locale:(id)locale; -- (NSComparisonResult)caseInsensitiveCompare:(NSString *)string; -- (NSArray *)componentsSeparatedByCharactersInSet:(NSCharacterSet *)separator; -+ (id)stringWithFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2))); -@end -@interface NSSimpleCString : NSString {} @end -@interface NSConstantString : NSSimpleCString @end -extern void *_NSConstantStringClassReference; - -//===----------------------------------------------------------------------===// -// Test cases. These should all be merged into NSString.m once these tests -// stop reporting leaks. -//===----------------------------------------------------------------------===// - -// FIXME: THIS TEST CASE INCORRECTLY REPORTS A LEAK. -void testOSCompareAndSwapXXBarrier_parameter_no_direct_release(NSString **old) { - NSString *s = [[NSString alloc] init]; // no-warning - if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) old)) - return; - else - [*old release]; -} diff --git a/test/Analysis/NSString.m b/test/Analysis/NSString.m index b5d510a5ed..515b9f7f3d 100644 --- a/test/Analysis/NSString.m +++ b/test/Analysis/NSString.m @@ -396,3 +396,11 @@ void testOSCompareAndSwapXXBarrier_parameter(NSString **old) { else [*old release]; } + +void testOSCompareAndSwapXXBarrier_parameter_no_direct_release(NSString **old) { + NSString *s = [[NSString alloc] init]; // no-warning + if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) old)) + [s release]; + else + return; +} |