1// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=basic -verify %s 2// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify %s 3 4#include <stdarg.h> 5 6//===----------------------------------------------------------------------===// 7// The following code is reduced using delta-debugging from 8// Foundation.h (Mac OS X). 9// 10// It includes the basic definitions for the test cases below. 11// Not directly including Foundation.h directly makes this test case 12// both svelte and portable to non-Mac platforms. 13//===----------------------------------------------------------------------===// 14 15typedef signed char BOOL; 16typedef unsigned int NSUInteger; 17typedef struct _NSZone NSZone; 18@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; 19@protocol NSObject - (BOOL)isEqual:(id)object; 20@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone; 21@end @protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end 22@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end 23@interface NSObject <NSObject> {} @end 24extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone); 25@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding> 26- (NSUInteger)length; 27+ (id)stringWithFormat:(NSString *)format, ...; 28@end 29@interface NSSimpleCString : NSString {} @end 30@interface NSConstantString : NSSimpleCString @end 31extern void *_NSConstantStringClassReference; 32typedef double NSTimeInterval; 33@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate; @end 34@class NSString, NSDictionary, NSArray; 35@interface NSException : NSObject <NSCopying, NSCoding> {} 36+ (NSException *)exceptionWithName:(NSString *)name reason:(NSString *)reason userInfo:(NSDictionary *)userInfo; 37- (void)raise; 38@end 39@interface NSException (NSExceptionRaisingConveniences) 40+ (void)raise:(NSString *)name format:(NSString *)format, ...; 41+ (void)raise:(NSString *)name format:(NSString *)format arguments:(va_list)argList; 42@end 43 44enum {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), }; 45 46//===----------------------------------------------------------------------===// 47// Test cases. 48//===----------------------------------------------------------------------===// 49 50int f1(int *x, NSString* s) { 51 52 if (x) ++x; 53 54 [NSException raise:@"Blah" format:[NSString stringWithFormat:@"Blah %@", s]]; 55 56 return *x; // no-warning 57} 58 59int f2(int *x, ...) { 60 61 if (x) ++x; 62 va_list alist; 63 va_start(alist, x); 64 65 [NSException raise:@"Blah" format:@"Blah %@" arguments:alist]; 66 67 return *x; // no-warning 68} 69 70int f3(int* x) { 71 72 if (x) ++x; 73 74 [[NSException exceptionWithName:@"My Exception" reason:@"Want to test exceptions." userInfo:0] raise]; 75 76 return *x; // no-warning 77} 78 79