From: Ted Kremenek Date: Mon, 16 Jun 2008 21:05:04 +0000 (+0000) Subject: Moved test case NoReturn.m from Analysis-Apple to Analysis (now works on all platforms). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32dc95e1ae09c740a08c364feaffd8c73821fe15;p=clang Moved test case NoReturn.m from Analysis-Apple to Analysis (now works on all platforms). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52359 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Analysis-Apple/NoReturn.m b/test/Analysis-Apple/NoReturn.m deleted file mode 100644 index 3447bfbc94..0000000000 --- a/test/Analysis-Apple/NoReturn.m +++ /dev/null @@ -1,36 +0,0 @@ -// RUN: clang -checker-simple -verify %s -// RUN: clang -checker-cfref -verify %s - - -#include -#include - -int f1(int *x, NSString* s) { - - if (x) ++x; - - [NSException raise:@"Blah" format:[NSString stringWithFormat:@"Blah %@", s]]; - - return *x; // no-warning -} - -int f2(int *x, ...) { - - if (x) ++x; - va_list alist; - va_start(alist, x); - - [NSException raise:@"Blah" format:@"Blah %@" arguments:alist]; - - return *x; // no-warning -} - -int f3(int* x) { - - if (x) ++x; - - [[NSException exceptionWithName:@"My Exception" reason:@"Want to test exceptions." userInfo:nil] raise]; - - return *x; // no-warning -} - diff --git a/test/Analysis/NoReturn.m b/test/Analysis/NoReturn.m new file mode 100644 index 0000000000..580f220c43 --- /dev/null +++ b/test/Analysis/NoReturn.m @@ -0,0 +1,78 @@ +// RUN: clang -checker-simple -verify %s +// RUN: clang -checker-cfref -verify %s + +#include + +//===----------------------------------------------------------------------===// +// 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. +//===----------------------------------------------------------------------===// + +typedef signed char BOOL; +typedef unsigned int NSUInteger; +typedef struct _NSZone NSZone; +@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; +@protocol NSObject - (BOOL)isEqual:(id)object; +@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone; +@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end +@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end +@interface NSObject {} @end +extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); +@interface NSString : NSObject +- (NSUInteger)length; ++ (id)stringWithFormat:(NSString *)format, ...; +@end +@interface NSSimpleCString : NSString {} @end +@interface NSConstantString : NSSimpleCString @end +extern void *_NSConstantStringClassReference; +typedef double NSTimeInterval; +@interface NSDate : NSObject - (NSTimeInterval)timeIntervalSinceReferenceDate; @end +@class NSString, NSDictionary, NSArray; +@interface NSException : NSObject {} ++ (NSException *)exceptionWithName:(NSString *)name reason:(NSString *)reason userInfo:(NSDictionary *)userInfo; +- (void)raise; +@end +@interface NSException (NSExceptionRaisingConveniences) ++ (void)raise:(NSString *)name format:(NSString *)format, ...; ++ (void)raise:(NSString *)name format:(NSString *)format arguments:(va_list)argList; +@end + +enum {NSPointerFunctionsStrongMemory = (0 << 0), NSPointerFunctionsZeroingWeakMemory = (1 << 0), NSPointerFunctionsOpaqueMemory = (2 << 0), NSPointerFunctionsMallocMemory = (3 << 0), NSPointerFunctionsMachVirtualMemory = (4 << 0), NSPointerFunctionsObjectPersonality = (0 << 8), NSPointerFunctionsOpaquePersonality = (1 << 8), NSPointerFunctionsObjectPointerPersonality = (2 << 8), NSPointerFunctionsCStringPersonality = (3 << 8), NSPointerFunctionsStructPersonality = (4 << 8), NSPointerFunctionsIntegerPersonality = (5 << 8), NSPointerFunctionsCopyIn = (1 << 16), }; + +//===----------------------------------------------------------------------===// +// Test cases. +//===----------------------------------------------------------------------===// + +int f1(int *x, NSString* s) { + + if (x) ++x; + + [NSException raise:@"Blah" format:[NSString stringWithFormat:@"Blah %@", s]]; + + return *x; // no-warning +} + +int f2(int *x, ...) { + + if (x) ++x; + va_list alist; + va_start(alist, x); + + [NSException raise:@"Blah" format:@"Blah %@" arguments:alist]; + + return *x; // no-warning +} + +int f3(int* x) { + + if (x) ++x; + + [[NSException exceptionWithName:@"My Exception" reason:@"Want to test exceptions." userInfo:0] raise]; + + return *x; // no-warning +} +