Page MenuHomePhabricator

No OneTemporary

File Metadata

Created
Sat, Oct 19, 11:40 PM
This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/clang/test/Analysis/CFContainers-invalid.c b/clang/test/Analysis/CFContainers-invalid.c
index 3268e1e..ce1284f 100644
--- a/clang/test/Analysis/CFContainers-invalid.c
+++ b/clang/test/Analysis/CFContainers-invalid.c
@@ -1,20 +1,20 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues -triple x86_64-apple-darwin -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues -triple x86_64-apple-darwin -verify %s
// expected-no-diagnostics
typedef const struct __CFAllocator * CFAllocatorRef;
typedef const struct __CFArray * CFArrayRef;
typedef const struct __CFDictionary * CFDictionaryRef;
typedef const struct __CFSet * CFSetRef;
extern const CFAllocatorRef kCFAllocatorDefault;
// Unexpected declarations for these:
CFArrayRef CFArrayCreate(CFAllocatorRef);
CFDictionaryRef CFDictionaryCreate(CFAllocatorRef);
CFSetRef CFSetCreate(CFAllocatorRef);
void testNoCrash() {
(void)CFArrayCreate(kCFAllocatorDefault);
(void)CFDictionaryCreate(kCFAllocatorDefault);
(void)CFSetCreate(kCFAllocatorDefault);
}
diff --git a/clang/test/Analysis/CFContainers.mm b/clang/test/Analysis/CFContainers.mm
index f315bc9..0a45bff 100644
--- a/clang/test/Analysis/CFContainers.mm
+++ b/clang/test/Analysis/CFContainers.mm
@@ -1,226 +1,226 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues,osx.coreFoundation.containers.OutOfBounds -analyzer-store=region -triple x86_64-apple-darwin -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=osx.coreFoundation.containers.PointerSizedValues,osx.coreFoundation.containers.OutOfBounds -analyzer-store=region -triple x86_64-apple-darwin -verify %s
typedef const struct __CFAllocator * CFAllocatorRef;
typedef const struct __CFString * CFStringRef;
typedef unsigned char Boolean;
typedef signed long CFIndex;
extern
const CFAllocatorRef kCFAllocatorDefault;
typedef const void * (*CFArrayRetainCallBack)(CFAllocatorRef allocator, const void *value);
typedef void (*CFArrayReleaseCallBack)(CFAllocatorRef allocator, const void *value);
typedef CFStringRef (*CFArrayCopyDescriptionCallBack)(const void *value);
typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2);
typedef struct {
CFIndex version;
CFArrayRetainCallBack retain;
CFArrayReleaseCallBack release;
CFArrayCopyDescriptionCallBack copyDescription;
CFArrayEqualCallBack equal;
} CFArrayCallBacks;
typedef const struct __CFArray * CFArrayRef;
CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFArrayCallBacks *callBacks);
typedef struct __CFArray * CFMutableArrayRef;
typedef const struct __CFString * CFStringRef;
enum {
kCFNumberSInt8Type = 1,
kCFNumberSInt16Type = 2,
kCFNumberSInt32Type = 3,
kCFNumberSInt64Type = 4,
kCFNumberFloat32Type = 5,
kCFNumberFloat64Type = 6,
kCFNumberCharType = 7,
kCFNumberShortType = 8,
kCFNumberIntType = 9,
kCFNumberLongType = 10,
kCFNumberLongLongType = 11,
kCFNumberFloatType = 12,
kCFNumberDoubleType = 13,
kCFNumberCFIndexType = 14,
kCFNumberNSIntegerType = 15,
kCFNumberCGFloatType = 16,
kCFNumberMaxType = 16
};
typedef CFIndex CFNumberType;
typedef const struct __CFNumber * CFNumberRef;
typedef CFIndex CFComparisonResult;
typedef const struct __CFDictionary * CFDictionaryRef;
typedef const void * (*CFDictionaryRetainCallBack)(CFAllocatorRef allocator, const void *value);
typedef void (*CFDictionaryReleaseCallBack)(CFAllocatorRef allocator, const void *value);
typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack)(const void *value);
typedef Boolean (*CFDictionaryEqualCallBack)(const void *value1, const void *value2);
typedef Boolean (*CFArrayEqualCallBack)(const void *value1, const void *value2);
typedef Boolean (*CFSetEqualCallBack)(const void *value1, const void *value2);
typedef const void * (*CFSetRetainCallBack)(CFAllocatorRef allocator, const void *value);
typedef void (*CFSetReleaseCallBack)(CFAllocatorRef allocator, const void *value);
typedef CFStringRef (*CFSetCopyDescriptionCallBack)(const void *value);
typedef struct {
CFIndex version;
CFSetRetainCallBack retain;
CFSetReleaseCallBack release;
CFSetCopyDescriptionCallBack copyDescription;
CFSetEqualCallBack equal;
} CFSetCallBacks;
typedef struct {
CFIndex version;
CFDictionaryRetainCallBack retain;
CFDictionaryReleaseCallBack release;
CFDictionaryCopyDescriptionCallBack copyDescription;
CFDictionaryEqualCallBack equal;
} CFDictionaryKeyCallBacks;
typedef struct {
CFIndex version;
CFDictionaryRetainCallBack retain;
CFDictionaryReleaseCallBack release;
CFDictionaryCopyDescriptionCallBack copyDescription;
CFDictionaryEqualCallBack equal;
} CFDictionaryValueCallBacks;
CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
extern
const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
typedef const struct __CFSet * CFSetRef;
extern
const CFSetCallBacks kCFTypeSetCallBacks;
extern
const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks;
extern
const void *CFArrayGetValueAtIndex(CFArrayRef theArray, CFIndex idx);
extern
CFIndex CFArrayGetCount(CFArrayRef theArray);
CFDictionaryRef CFDictionaryCreate(CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const
CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks);
CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
extern
CFSetRef CFSetCreate(CFAllocatorRef allocator, const void **values, CFIndex numValues, const CFSetCallBacks *callBacks);
#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr ""))
#define NULL __null
// Done with the headers.
// Test alpha.osx.cocoa.ContainerAPI checker.
void testContainers(int **xNoWarn, CFIndex count) {
int x[] = { 1, 2, 3 };
CFArrayRef foo = CFArrayCreate(kCFAllocatorDefault, (const void **) x, sizeof(x) / sizeof(x[0]), 0);// expected-warning {{The second argument to 'CFArrayCreate' must be a C array of pointer-sized}}
CFArrayRef fooNoWarn = CFArrayCreate(kCFAllocatorDefault, (const void **) xNoWarn, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0); // no warning
CFArrayRef fooNoWarn2 = CFArrayCreate(kCFAllocatorDefault, 0, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0);// no warning, passing in 0
CFArrayRef fooNoWarn3 = CFArrayCreate(kCFAllocatorDefault, NULL, sizeof(xNoWarn) / sizeof(xNoWarn[0]), 0);// no warning, passing in NULL
CFSetRef set = CFSetCreate(NULL, (const void **)x, 3, &kCFTypeSetCallBacks); // expected-warning {{The second argument to 'CFSetCreate' must be a C array of pointer-sized values}}
CFArrayRef* pairs = new CFArrayRef[count];
CFSetRef fSet = CFSetCreate(kCFAllocatorDefault, (const void**) pairs, count - 1, &kCFTypeSetCallBacks);// no warning
}
void CreateDict(int *elems) {
const short days28 = 28;
const short days30 = 30;
const short days31 = 31;
CFIndex numValues = 6;
CFStringRef keys[6];
CFNumberRef values[6];
keys[0] = CFSTR("January"); values[0] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
keys[1] = CFSTR("February"); values[1] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days28);
keys[2] = CFSTR("March"); values[2] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
keys[3] = CFSTR("April"); values[3] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days30);
keys[4] = CFSTR("May"); values[4] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days31);
keys[5] = CFSTR("June"); values[5] = CFNumberCreate(kCFAllocatorDefault, kCFNumberShortType, &days30);
const CFDictionaryKeyCallBacks keyCB = kCFCopyStringDictionaryKeyCallBacks;
const CFDictionaryValueCallBacks valCB = kCFTypeDictionaryValueCallBacks;
CFDictionaryRef dict1 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)values, numValues, &keyCB, &valCB); // no warning
CFDictionaryRef dict2 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)elems[0], (const void**)values, numValues, &keyCB, &valCB); //expected-warning {{The second argument to 'CFDictionaryCreate' must be a C array of}} expected-warning {{cast to 'const void **' from smaller integer type 'int'}}
CFDictionaryRef dict3 = CFDictionaryCreate(kCFAllocatorDefault, (const void**)keys, (const void**)elems, numValues, &keyCB, &valCB); // expected-warning {{The third argument to 'CFDictionaryCreate' must be a C array of pointer-sized values}}
}
void OutOfBoundsSymbolicOffByOne(const void ** input, CFIndex S) {
CFArrayRef array;
array = CFArrayCreate(kCFAllocatorDefault, input, S, 0);
const void *s1 = CFArrayGetValueAtIndex(array, 0); // no warning
const void *s2 = CFArrayGetValueAtIndex(array, S-1); // no warning
const void *s3 = CFArrayGetValueAtIndex(array, S); // expected-warning {{Index is out of bounds}}
}
void OutOfBoundsConst(const void ** input, CFIndex S) {
CFArrayRef array;
array = CFArrayCreate(kCFAllocatorDefault, input, 3, 0);
const void *s1 = CFArrayGetValueAtIndex(array, 0); // no warning
const void *s2 = CFArrayGetValueAtIndex(array, 2); // no warning
const void *s3 = CFArrayGetValueAtIndex(array, 5); // expected-warning {{Index is out of bounds}}
// TODO: The solver is probably not strong enough here.
CFIndex sIndex;
for (sIndex = 0 ; sIndex <= 5 ; sIndex += 3 ) {
const void *s = CFArrayGetValueAtIndex(array, sIndex);
}
}
void OutOfBoundsZiro(const void ** input, CFIndex S) {
CFArrayRef array;
// The API allows to set the size to 0. Check that we don't undeflow when the size is 0.
array = CFArrayCreate(kCFAllocatorDefault, 0, 0, 0);
const void *s1 = CFArrayGetValueAtIndex(array, 0); // expected-warning {{Index is out of bounds}}
}
void TestGetCount(CFArrayRef A, CFIndex sIndex) {
CFIndex sCount = CFArrayGetCount(A);
if (sCount > sIndex)
const void *s1 = CFArrayGetValueAtIndex(A, sIndex);
const void *s2 = CFArrayGetValueAtIndex(A, sCount);// expected-warning {{Index is out of bounds}}
}
typedef void* XX[3];
void TestPointerToArray(int *elems, void *p1, void *p2, void *p3, unsigned count, void* fn[], char cp[]) {
void* x[] = { p1, p2, p3 };
CFArrayCreate(0, (const void **) &x, count, 0); // no warning
void* y[] = { p1, p2, p3 };
CFArrayCreate(0, (const void **) y, count, 0); // no warning
XX *z = &x;
CFArrayCreate(0, (const void **) z, count, 0); // no warning
CFArrayCreate(0, (const void **) &fn, count, 0); // false negative
CFArrayCreate(0, (const void **) fn, count, 0); // no warning
CFArrayCreate(0, (const void **) cp, count, 0); // expected-warning {{The second argument to 'CFArrayCreate' must be a C array of pointer-sized}}
char cc[] = { 0, 2, 3 };
CFArrayCreate(0, (const void **) &cc, count, 0); // expected-warning {{The second argument to 'CFArrayCreate' must be a C array of pointer-sized}}
CFArrayCreate(0, (const void **) cc, count, 0); // expected-warning {{The second argument to 'CFArrayCreate' must be a C array of pointer-sized}}
}
void TestUndef(CFArrayRef A, CFIndex sIndex, void* x[]) {
unsigned undefVal;
const void *s1 = CFArrayGetValueAtIndex(A, undefVal);
unsigned undefVal2;
CFArrayRef B = CFArrayCreate(0, (const void **) &x, undefVal2, 0);
const void *s2 = CFArrayGetValueAtIndex(B, 2);
}
void TestConst(CFArrayRef A, CFIndex sIndex, void* x[]) {
CFArrayRef B = CFArrayCreate(0, (const void **) &x, 4, 0);
const void *s1 = CFArrayGetValueAtIndex(B, 2);
}
void TestNullArray() {
CFArrayGetValueAtIndex(0, 0);
}
void ArrayRefMutableEscape(CFMutableArrayRef a);
void ArrayRefEscape(CFArrayRef a);
void TestCFMutableArrayRefEscapeViaMutableArgument(CFMutableArrayRef a) {
CFIndex aLen = CFArrayGetCount(a);
ArrayRefMutableEscape(a);
// ArrayRefMutableEscape could mutate a to make it have
// at least aLen + 1 elements, so do not report an error here.
CFArrayGetValueAtIndex(a, aLen);
}
void TestCFMutableArrayRefEscapeViaImmutableArgument(CFMutableArrayRef a) {
CFIndex aLen = CFArrayGetCount(a);
ArrayRefEscape(a);
// ArrayRefEscape is declared to take a CFArrayRef (i.e, an immutable array)
// so we assume it does not change the length of a.
CFArrayGetValueAtIndex(a, aLen); // expected-warning {{Index is out of bounds}}
}
diff --git a/clang/test/Analysis/CFDateGC.m b/clang/test/Analysis/CFDateGC.m
index fae144f..714e213 100644
--- a/clang/test/Analysis/CFDateGC.m
+++ b/clang/test/Analysis/CFDateGC.m
@@ -1,85 +1,85 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -fobjc-gc %s -Wno-implicit-function-declaration
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -fobjc-gc %s -Wno-implicit-function-declaration
//===----------------------------------------------------------------------===//
// The following code is reduced using delta-debugging from
// Foundation.h and CoreFoundation.h (Mac OS X).
//
// It includes the basic definitions for the test cases below.
// Not directly including [Core]Foundation.h directly makes this test case
// both svelte and portable to non-Mac platforms.
//===----------------------------------------------------------------------===//
typedef const void * CFTypeRef;
void CFRelease(CFTypeRef cf);
CFTypeRef CFRetain(CFTypeRef cf);
CFTypeRef CFMakeCollectable(CFTypeRef cf);
typedef const struct __CFAllocator * CFAllocatorRef;
typedef double CFTimeInterval;
typedef CFTimeInterval CFAbsoluteTime;
typedef const struct __CFDate * CFDateRef;
extern CFDateRef CFDateCreate(CFAllocatorRef allocator, CFAbsoluteTime at);
extern CFAbsoluteTime CFDateGetAbsoluteTime(CFDateRef theDate);
typedef struct objc_object {} *id;
typedef signed char BOOL;
static __inline__ __attribute__((always_inline)) id NSMakeCollectable(CFTypeRef cf) { return 0; }
@protocol NSObject - (BOOL)isEqual:(id)object;
- (oneway void)release;
- (id)retain;
@end
@class NSArray;
//===----------------------------------------------------------------------===//
// Test cases.
//===----------------------------------------------------------------------===//
CFAbsoluteTime CFAbsoluteTimeGetCurrent();
CFAbsoluteTime f1_use_after_release() {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t);
CFRetain(date);
[NSMakeCollectable(date) release];
CFDateGetAbsoluteTime(date); // no-warning
CFRelease(date);
t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
return t;
}
// The following two test cases verifies that CFMakeCollectable is a no-op
// in non-GC mode and a "release" in GC mode.
CFAbsoluteTime f2_use_after_release() {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t);
CFRetain(date);
[(id) CFMakeCollectable(date) release];
CFDateGetAbsoluteTime(date); // no-warning
CFRelease(date);
t = CFDateGetAbsoluteTime(date); // expected-warning{{Reference-counted object is used after it is released}}
return t;
}
CFAbsoluteTime f2_noleak() {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t);
CFRetain(date);
[(id) CFMakeCollectable(date) release];
CFDateGetAbsoluteTime(date); // no-warning
t = CFDateGetAbsoluteTime(date); // no-warning
CFRelease(date); // no-warning
return t;
}
void f3_leak_with_gc() {
CFDateRef date = CFDateCreate(0, CFAbsoluteTimeGetCurrent()); // expected-warning 2 {{leak}}
[[(id) date retain] release];
}
// The following test case verifies that we "stop tracking" a retained object
// when it is passed as an argument to an implicitly defined function.
CFAbsoluteTime f4() {
CFAbsoluteTime t = CFAbsoluteTimeGetCurrent();
CFDateRef date = CFDateCreate(0, t);
CFRetain(date);
some_implicitly_defined_function_stop_tracking(date); // no-warning
return t;
}
diff --git a/clang/test/Analysis/CFNumber.c b/clang/test/Analysis/CFNumber.c
index d7dd951..7ac65cc 100644
--- a/clang/test/Analysis/CFNumber.c
+++ b/clang/test/Analysis/CFNumber.c
@@ -1,47 +1,47 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.coreFoundation.CFNumber,osx.cocoa.RetainCount -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s
typedef signed long CFIndex;
typedef const struct __CFAllocator * CFAllocatorRef;
enum { kCFNumberSInt8Type = 1, kCFNumberSInt16Type = 2,
kCFNumberSInt32Type = 3, kCFNumberSInt64Type = 4,
kCFNumberFloat32Type = 5, kCFNumberFloat64Type = 6,
kCFNumberCharType = 7, kCFNumberShortType = 8,
kCFNumberIntType = 9, kCFNumberLongType = 10,
kCFNumberLongLongType = 11, kCFNumberFloatType = 12,
kCFNumberDoubleType = 13, kCFNumberCFIndexType = 14,
kCFNumberNSIntegerType = 15, kCFNumberCGFloatType = 16,
kCFNumberMaxType = 16 };
typedef CFIndex CFNumberType;
typedef const struct __CFNumber * CFNumberRef;
typedef unsigned char Boolean;
extern CFNumberRef CFNumberCreate(CFAllocatorRef allocator, CFNumberType theType, const void *valuePtr);
Boolean CFNumberGetValue(CFNumberRef number, CFNumberType theType, void *valuePtr);
__attribute__((cf_returns_retained)) CFNumberRef f1(unsigned char x) {
return CFNumberCreate(0, kCFNumberSInt16Type, &x); // expected-warning{{An 8-bit integer is used to initialize a CFNumber object that represents a 16-bit integer; 8 bits of the CFNumber value will be garbage}}
}
__attribute__((cf_returns_retained)) CFNumberRef f2(unsigned short x) {
return CFNumberCreate(0, kCFNumberSInt8Type, &x); // expected-warning{{A 16-bit integer is used to initialize a CFNumber object that represents an 8-bit integer; 8 bits of the integer value will be lost}}
}
// test that the attribute overrides the naming convention.
__attribute__((cf_returns_not_retained)) CFNumberRef CreateNum(unsigned char x) {
return CFNumberCreate(0, kCFNumberSInt8Type, &x); // expected-warning{{leak}}
}
__attribute__((cf_returns_retained)) CFNumberRef f3(unsigned i) {
return CFNumberCreate(0, kCFNumberLongType, &i); // expected-warning{{A 32-bit integer is used to initialize a CFNumber object that represents a 64-bit integer}}
}
unsigned char getValueTest1(CFNumberRef x) {
unsigned char scalar = 0;
CFNumberGetValue(x, kCFNumberSInt16Type, &scalar); // expected-warning{{A CFNumber object that represents a 16-bit integer is used to initialize an 8-bit integer; 8 bits of the CFNumber value will overwrite adjacent storage}}
return scalar;
}
unsigned char getValueTest2(CFNumberRef x) {
unsigned short scalar = 0;
CFNumberGetValue(x, kCFNumberSInt8Type, &scalar); // expected-warning{{A CFNumber object that represents an 8-bit integer is used to initialize a 16-bit integer; 8 bits of the integer value will be garbage}}
return scalar;
}
diff --git a/clang/test/Analysis/CFRetainRelease_NSAssertionHandler.m b/clang/test/Analysis/CFRetainRelease_NSAssertionHandler.m
index be1f20d..f358ee6 100644
--- a/clang/test/Analysis/CFRetainRelease_NSAssertionHandler.m
+++ b/clang/test/Analysis/CFRetainRelease_NSAssertionHandler.m
@@ -1,73 +1,73 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -verify %s -analyzer-store=region
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -verify %s -analyzer-store=region
// expected-no-diagnostics
typedef struct objc_selector *SEL;
typedef signed char BOOL;
typedef int NSInteger;
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 <NSObject> {} - (id)init; @end
extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
- (NSUInteger)length;
+ (id)stringWithUTF8String:(const char *)nullTerminatedCString;
@end extern NSString * const NSBundleDidLoadNotification;
@interface NSAssertionHandler : NSObject {}
+ (NSAssertionHandler *)currentHandler;
- (void)handleFailureInMethod:(SEL)selector object:(id)object file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format,...;
- (void)handleFailureInFunction:(NSString *)functionName file:(NSString *)fileName lineNumber:(NSInteger)line description:(NSString *)format,...;
@end
extern NSString * const NSConnectionReplyMode;
//----------------------------------------------------------------------------//
// The following test case was filed in PR 2593:
// http://llvm.org/bugs/show_bug.cgi?id=2593
//
// There should be no null dereference flagged by the checker because of
// NSParameterAssert and NSAssert.
@interface TestAssert : NSObject {}
@end
@implementation TestAssert
- (id)initWithPointer: (int*)x
{
// Expansion of: NSParameterAssert( x != 0 );
do { if (!((x != 0))) { [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd object:self file:[NSString stringWithUTF8String:"CFRetainRelease_NSAssertionHandler.m"] lineNumber:21 description:(@"Invalid parameter not satisfying: %s"), ("x != 0"), (0), (0), (0), (0)]; } } while(0);
if( (self = [super init]) != 0 )
{
*x = 1; // no-warning
}
return self;
}
- (id)initWithPointer2: (int*)x
{
// Expansion of: NSAssert( x != 0, @"" );
do { if (!((x != 0))) { [[NSAssertionHandler currentHandler] handleFailureInMethod:_cmd object:self file:[NSString stringWithUTF8String:"CFRetainRelease_NSAssertionHandler.m"] lineNumber:33 description:((@"")), (0), (0), (0), (0), (0)]; } } while(0);
if( (self = [super init]) != 0 )
{
*x = 1; // no-warning
}
return self;
}
@end
void pointerFunction (int *x) {
// Manual expansion of NSCAssert( x != 0, @"")
do { if (!((x != 0))) { [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithUTF8String:__PRETTY_FUNCTION__] file:[NSString stringWithUTF8String:__FILE__] lineNumber:__LINE__ description:((@""))]; } } while(0);
*x = 1; // no-warning
}
diff --git a/clang/test/Analysis/CGColorSpace.c b/clang/test/Analysis/CGColorSpace.c
index 8681e15..38f0512 100644
--- a/clang/test/Analysis/CGColorSpace.c
+++ b/clang/test/Analysis/CGColorSpace.c
@@ -1,18 +1,18 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
typedef struct CGColorSpace *CGColorSpaceRef;
extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void);
extern CGColorSpaceRef CGColorSpaceRetain(CGColorSpaceRef space);
extern void CGColorSpaceRelease(CGColorSpaceRef space);
void f() {
CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB(); // expected-warning{{leak}}
CGColorSpaceRetain(X);
}
void fb() {
CGColorSpaceRef X = CGColorSpaceCreateDeviceRGB();
CGColorSpaceRetain(X);
CGColorSpaceRelease(X);
CGColorSpaceRelease(X); // no-warning
}
diff --git a/clang/test/Analysis/CheckNSError.m b/clang/test/Analysis/CheckNSError.m
index d126d29..6de98e8 100644
--- a/clang/test/Analysis/CheckNSError.m
+++ b/clang/test/Analysis/CheckNSError.m
@@ -1,56 +1,56 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -verify -Wno-objc-root-class %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.NSError,osx.coreFoundation.CFError -analyzer-store=region -verify -Wno-objc-root-class %s
typedef signed char BOOL;
typedef int NSInteger;
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 NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
@interface NSObject <NSObject> {} @end
@class NSDictionary;
@interface NSError : NSObject <NSCopying, NSCoding> {}
+ (id)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict;
@end
extern NSString * const NSXMLParserErrorDomain ;
@interface A
- (void)myMethodWhichMayFail:(NSError **)error;
- (BOOL)myMethodWhichMayFail2:(NSError **)error;
@end
@implementation A
- (void)myMethodWhichMayFail:(NSError **)error { // expected-warning {{Method accepting NSError** should have a non-void return value to indicate whether or not an error occurred}}
*error = [NSError errorWithDomain:@"domain" code:1 userInfo:0]; // expected-warning {{Potential null dereference}}
}
- (BOOL)myMethodWhichMayFail2:(NSError **)error { // no-warning
if (error) *error = [NSError errorWithDomain:@"domain" code:1 userInfo:0]; // no-warning
return 0;
}
@end
struct __CFError {};
typedef struct __CFError* CFErrorRef;
void foo(CFErrorRef* error) { // expected-warning {{Function accepting CFErrorRef* should have a non-void return value to indicate whether or not an error occurred}}
*error = 0; // expected-warning {{Potential null dereference}}
}
int f1(CFErrorRef* error) {
if (error) *error = 0; // no-warning
return 0;
}
int f2(CFErrorRef* error) {
if (0 != error) *error = 0; // no-warning
return 0;
}
int f3(CFErrorRef* error) {
if (error != 0) *error = 0; // no-warning
return 0;
}
diff --git a/clang/test/Analysis/DeallocMissingRelease.m b/clang/test/Analysis/DeallocMissingRelease.m
index 651f20a..91af2bd 100644
--- a/clang/test/Analysis/DeallocMissingRelease.m
+++ b/clang/test/Analysis/DeallocMissingRelease.m
@@ -1,925 +1,925 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-ios4.0 -DMACOS=0 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-macosx10.6.0 -DMACOS=1 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-darwin10 -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-ios4.0 -DMACOS=0 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-macosx10.6.0 -DMACOS=1 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -triple x86_64-apple-darwin10 -fobjc-arc -fobjc-runtime-has-weak -verify %s
#include "Inputs/system-header-simulator-for-objc-dealloc.h"
#define NON_ARC !__has_feature(objc_arc)
#if NON_ARC
#define WEAK_ON_ARC
#else
#define WEAK_ON_ARC __weak
#endif
// No diagnostics expected under ARC.
#if !NON_ARC
// expected-no-diagnostics
#endif
// Do not warn about missing release in -dealloc for ivars.
@interface MyIvarClass1 : NSObject {
NSObject *_ivar;
}
@end
@implementation MyIvarClass1
- (instancetype)initWithIvar:(NSObject *)ivar
{
self = [super init];
if (!self)
return nil;
#if NON_ARC
_ivar = [ivar retain];
#endif
return self;
}
- (void)dealloc
{
#if NON_ARC
[super dealloc];
#endif
}
@end
@interface MyIvarClass2 : NSObject {
NSObject *_ivar;
}
- (NSObject *)ivar;
- (void)setIvar:(NSObject *)ivar;
@end
@implementation MyIvarClass2
- (instancetype)init
{
self = [super init];
return self;
}
- (void)dealloc
{
#if NON_ARC
[super dealloc];
#endif
}
- (NSObject *)ivar
{
return _ivar;
}
- (void)setIvar:(NSObject *)ivar
{
#if NON_ARC
[_ivar release];
_ivar = [ivar retain];
#else
_ivar = ivar;
#endif
}
@end
// Warn about missing release in -dealloc for properties.
@interface MyPropertyClass1 : NSObject
@property (copy) NSObject *ivar;
@end
@implementation MyPropertyClass1
- (void)dealloc
{
#if NON_ARC
[super dealloc]; // expected-warning {{The '_ivar' ivar in 'MyPropertyClass1' was copied by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
@interface MyPropertyClass2 : NSObject
@property (retain) NSObject *ivar;
@end
@implementation MyPropertyClass2
- (void)dealloc
{
#if NON_ARC
[super dealloc]; // expected-warning {{The '_ivar' ivar in 'MyPropertyClass2' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
@interface MyPropertyClass3 : NSObject {
NSObject *_ivar;
}
@property (retain) NSObject *ivar;
@end
@implementation MyPropertyClass3
@synthesize ivar = _ivar;
- (void)dealloc
{
#if NON_ARC
[super dealloc]; // expected-warning {{The '_ivar' ivar in 'MyPropertyClass3' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
@interface MyPropertyClass4 : NSObject {
void (^_blockPropertyIvar)(void);
}
@property (copy) void (^blockProperty)(void);
@property (copy) void (^blockProperty2)(void);
@property (copy) void (^blockProperty3)(void);
@end
@implementation MyPropertyClass4
@synthesize blockProperty = _blockPropertyIvar;
- (void)dealloc
{
#if NON_ARC
[_blockProperty2 release];
Block_release(_blockProperty3);
[super dealloc]; // expected-warning {{The '_blockPropertyIvar' ivar in 'MyPropertyClass4' was copied by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
@interface MyPropertyClass5 : NSObject {
WEAK_ON_ARC NSObject *_ivar;
}
@property (weak) NSObject *ivar;
@end
@implementation MyPropertyClass5
@synthesize ivar = _ivar;
- (void)dealloc
{
#if NON_ARC
[super dealloc]; // no-warning because it is a weak property
#endif
}
@end
@interface MyPropertyClassWithReturnInDealloc : NSObject {
NSObject *_ivar;
}
@property (retain) NSObject *ivar;
@end
@implementation MyPropertyClassWithReturnInDealloc
@synthesize ivar = _ivar;
- (void)dealloc
{
return;
#if NON_ARC
// expected-warning@-2{{The '_ivar' ivar in 'MyPropertyClassWithReturnInDealloc' was retained by a synthesized property but not released before '[super dealloc]'}}
[super dealloc];
#endif
}
@end
@interface MyPropertyClassWithReleaseInOtherInstance : NSObject {
NSObject *_ivar;
MyPropertyClassWithReleaseInOtherInstance *_other;
}
@property (retain) NSObject *ivar;
-(void)releaseIvars;
@end
@implementation MyPropertyClassWithReleaseInOtherInstance
@synthesize ivar = _ivar;
-(void)releaseIvars; {
#if NON_ARC
[_ivar release];
#endif
}
- (void)dealloc
{
[_other releaseIvars];
#if NON_ARC
[super dealloc]; // expected-warning {{The '_ivar' ivar in 'MyPropertyClassWithReleaseInOtherInstance' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
@interface MyPropertyClassWithNeitherReturnNorSuperDealloc : NSObject {
NSObject *_ivar;
}
@property (retain) NSObject *ivar;
@end
@implementation MyPropertyClassWithNeitherReturnNorSuperDealloc
@synthesize ivar = _ivar;
- (void)dealloc
{
}
#if NON_ARC
// expected-warning@-2 {{method possibly missing a [super dealloc] call}} (From Sema)
// expected-warning@-3{{The '_ivar' ivar in 'MyPropertyClassWithNeitherReturnNorSuperDealloc' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
@end
// <rdar://problem/6380411>: 'myproperty' has kind 'assign' and thus the
// assignment through the setter does not perform a release.
@interface MyObject : NSObject {
id __unsafe_unretained _myproperty;
}
@property(assign) id myproperty;
@end
@implementation MyObject
@synthesize myproperty=_myproperty; // no-warning
- (void)dealloc {
// Don't claim that myproperty is released since it the property
// has the 'assign' attribute.
self.myproperty = 0; // no-warning
#if NON_ARC
[super dealloc];
#endif
}
@end
@interface ClassWithControlFlowInRelease : NSObject {
BOOL _ivar1;
}
@property (retain) NSObject *ivar2;
@end
@implementation ClassWithControlFlowInRelease
- (void)dealloc; {
if (_ivar1) {
// We really should warn because there is a path through -dealloc on which
// _ivar2 is not released.
#if NON_ARC
[_ivar2 release];
#endif
}
#if NON_ARC
[super dealloc]; // expected-warning {{The '_ivar2' ivar in 'ClassWithControlFlowInRelease' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
// Don't warn when the property is nil'd out in -dealloc
@interface ClassWithNildOutProperty : NSObject
@property (retain) NSObject *ivar;
@property (assign) int *intPtrProp;
@end
@implementation ClassWithNildOutProperty
- (void)dealloc; {
self.ivar = nil;
// Make sure to handle setting a non-retainable property to 0.
self.intPtrProp = 0;
#if NON_ARC
[super dealloc]; // no-warning
#endif
}
@end
// Do warn when the ivar but not the property is nil'd out in -dealloc
@interface ClassWithNildOutIvar : NSObject
@property (retain) NSObject *ivar;
@end
@implementation ClassWithNildOutIvar
- (void)dealloc; {
// Oops. Meant self.ivar = nil
_ivar = nil;
#if NON_ARC
[super dealloc]; // expected-warning {{The '_ivar' ivar in 'ClassWithNildOutIvar' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
// Do warn when the ivar is updated to a different value that is then
// released.
@interface ClassWithUpdatedIvar : NSObject
@property (retain) NSObject *ivar;
@end
@implementation ClassWithUpdatedIvar
- (void)dealloc; {
_ivar = [[NSObject alloc] init];
#if NON_ARC
[_ivar release];
#endif
#if NON_ARC
[super dealloc]; // expected-warning {{The '_ivar' ivar in 'ClassWithUpdatedIvar' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
// Don't warn when the property is nil'd out with a setter in -dealloc
@interface ClassWithNildOutPropertyViaSetter : NSObject
@property (retain) NSObject *ivar;
@end
@implementation ClassWithNildOutPropertyViaSetter
- (void)dealloc; {
[self setIvar:nil];
#if NON_ARC
[super dealloc]; // no-warning
#endif
}
@end
// Don't warn about missing releases when -dealloc helpers are called.
@interface ClassWithDeallocHelpers : NSObject
@property (retain) NSObject *ivarReleasedInMethod;
@property (retain) NSObject *propNilledOutInMethod;
@property (retain) NSObject *ivarReleasedInFunction;
@property (retain) NSObject *propNilledOutInFunction;
@property (retain) NSObject *ivarNeverReleased;
- (void)invalidateInMethod;
@end
void ReleaseValueHelper(NSObject *iv) {
#if NON_ARC
[iv release];
#endif
}
void NilOutPropertyHelper(ClassWithDeallocHelpers *o) {
o.propNilledOutInFunction = nil;
}
@implementation ClassWithDeallocHelpers
- (void)invalidateInMethod {
#if NON_ARC
[_ivarReleasedInMethod release];
#endif
self.propNilledOutInMethod = nil;
}
- (void)dealloc; {
ReleaseValueHelper(_ivarReleasedInFunction);
NilOutPropertyHelper(self);
[self invalidateInMethod];
#if NON_ARC
[super dealloc]; // expected-warning {{The '_ivarNeverReleased' ivar in 'ClassWithDeallocHelpers' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
// Don't warn when self in -dealloc escapes.
@interface ClassWhereSelfEscapesViaMethodCall : NSObject
@property (retain) NSObject *ivar; // no-warning
@end
@interface ClassWhereSelfEscapesViaMethodCall (Other)
- (void)invalidate; // In other translation unit.
@end
@implementation ClassWhereSelfEscapesViaMethodCall
- (void)dealloc; {
[self invalidate];
#if NON_ARC
[super dealloc];
#endif
} // no-warning
@end
@interface ClassWhereSelfEscapesViaPropertyAccess : NSObject
@property (retain) NSObject *ivar;
@end
@interface ClassWhereSelfEscapesViaPropertyAccess (Other)
// The implementation of this property is unknown and therefore could
// release ivar.
@property (retain) NSObject *otherIvar;
@end
@implementation ClassWhereSelfEscapesViaPropertyAccess
- (void)dealloc; {
self.otherIvar = nil;
#if NON_ARC
[super dealloc];
#endif
} // no-warning
@end
// Don't treat self as escaping when setter called on *synthesized*
// property.
@interface ClassWhereSelfEscapesViaSynthesizedPropertyAccess : NSObject
@property (retain) NSObject *ivar;
@property (retain) NSObject *otherIvar;
@end
@implementation ClassWhereSelfEscapesViaSynthesizedPropertyAccess
- (void)dealloc; {
self.otherIvar = nil;
#if NON_ARC
[super dealloc]; // expected-warning {{The '_ivar' ivar in 'ClassWhereSelfEscapesViaSynthesizedPropertyAccess' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
// Don't treat calls to system headers as escapes
@interface ClassWhereSelfEscapesViaCallToSystem : NSObject
@property (retain) NSObject *ivar1;
@property (retain) NSObject *ivar2;
@property (retain) NSObject *ivar3;
@property (retain) NSObject *ivar4;
@property (retain) NSObject *ivar5;
@property (retain) NSObject *ivar6;
@end
@implementation ClassWhereSelfEscapesViaCallToSystem
- (void)dealloc; {
#if NON_ARC
[_ivar2 release];
if (_ivar3) {
[_ivar3 release];
}
#endif
[[NSRunLoop currentRunLoop] cancelPerformSelectorsWithTarget:self];
[[NSNotificationCenter defaultCenter] removeObserver:self];
#if NON_ARC
[_ivar4 release];
if (_ivar5) {
[_ivar5 release];
}
#endif
[[NSNotificationCenter defaultCenter] removeObserver:self];
#if NON_ARC
if (_ivar6) {
[_ivar6 release];
}
[super dealloc]; // expected-warning {{The '_ivar1' ivar in 'ClassWhereSelfEscapesViaCallToSystem' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
// Don't warn when value escapes.
@interface ClassWhereIvarValueEscapes : NSObject
@property (retain) NSObject *ivar;
@end
void ReleaseMe(id arg);
@implementation ClassWhereIvarValueEscapes
- (void)dealloc; {
ReleaseMe(_ivar);
#if NON_ARC
[super dealloc];
#endif
} // no-warning
@end
// Don't warn when value is known to be nil.
@interface ClassWhereIvarIsNil : NSObject
@property (retain) NSObject *ivarIsNil;
@end
@implementation ClassWhereIvarIsNil
- (void)dealloc; {
#if NON_ARC
if (_ivarIsNil)
[_ivarIsNil release];
[super dealloc];
#endif
} // no-warning
@end
// Don't warn for non-retainable properties.
@interface ClassWithNonRetainableProperty : NSObject
@property (assign) int *ivar; // no-warning
@end
@implementation ClassWithNonRetainableProperty
- (void)dealloc; {
#if NON_ARC
[super dealloc];
#endif
} // no-warning
@end
@interface SuperClassOfClassWithInlinedSuperDealloc : NSObject
@property (retain) NSObject *propInSuper;
@end
@implementation SuperClassOfClassWithInlinedSuperDealloc
- (void)dealloc {
#if NON_ARC
[super dealloc]; // expected-warning {{The '_propInSuper' ivar in 'SuperClassOfClassWithInlinedSuperDealloc' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
@interface ClassWithInlinedSuperDealloc : SuperClassOfClassWithInlinedSuperDealloc
@property (retain) NSObject *propInSub;
@end
@implementation ClassWithInlinedSuperDealloc
- (void)dealloc {
#if NON_ARC
[super dealloc]; // expected-warning {{The '_propInSub' ivar in 'ClassWithInlinedSuperDealloc' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
@interface SuperClassOfClassWithInlinedSuperDeallocAndInvalidation : NSObject
@property (retain) NSObject *propInSuper;
- (void)invalidate;
@end
@implementation SuperClassOfClassWithInlinedSuperDeallocAndInvalidation
- (void)invalidate {
#if NON_ARC
[_propInSuper release];
#endif
_propInSuper = nil;
}
- (void)dealloc {
[self invalidate];
#if NON_ARC
[super dealloc]; // no-warning
#endif
}
@end
@interface ClassWithInlinedSuperDeallocAndInvalidation : SuperClassOfClassWithInlinedSuperDeallocAndInvalidation
@property (retain) NSObject *propInSub;
@end
@implementation ClassWithInlinedSuperDeallocAndInvalidation
- (void)invalidate {
#if NON_ARC
[_propInSub release];
#endif
[super invalidate];
}
- (void)dealloc {
#if NON_ARC
[super dealloc]; // no-warning
#endif
}
@end
@interface SuperClassOfClassThatEscapesBeforeInliningSuper : NSObject
@property (retain) NSObject *propInSuper;
@end
@implementation SuperClassOfClassThatEscapesBeforeInliningSuper
- (void)dealloc {
#if NON_ARC
[super dealloc]; // expected-warning {{The '_propInSuper' ivar in 'SuperClassOfClassThatEscapesBeforeInliningSuper' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
@interface ClassThatEscapesBeforeInliningSuper : SuperClassOfClassThatEscapesBeforeInliningSuper
@property (retain) NSObject *propInSub;
@end
@interface ClassThatEscapesBeforeInliningSuper (Other)
- (void)invalidate; // No implementation in translation unit.
@end
@implementation ClassThatEscapesBeforeInliningSuper
- (void)dealloc {
[self invalidate];
#if NON_ARC
[super dealloc]; // no-warning
#endif
}
@end
#if NON_ARC
@interface ReleaseIvarInField : NSObject {
int _tag;
union {
NSObject *field1;
NSObject *field2;
} _someUnion;
struct {
NSObject *field1;
} _someStruct;
}
@end
@implementation ReleaseIvarInField
- (void)dealloc {
if (_tag) {
[_someUnion.field1 release];
} else {
[_someUnion.field2 release];
}
[_someStruct.field1 release];
[super dealloc];
}
@end
#endif
struct SomeStruct {
int f;
};
@interface ZeroOutStructWithSetter : NSObject
@property(assign) struct SomeStruct s;
@end
@implementation ZeroOutStructWithSetter
- (void)dealloc {
struct SomeStruct zeroedS;
zeroedS.f = 0;
self.s = zeroedS;
#if NON_ARC
[super dealloc];
#endif
}
@end
#if NON_ARC
@interface ReleaseIvarInArray : NSObject {
NSObject *_array[3];
}
@end
@implementation ReleaseIvarInArray
- (void)dealloc {
for (int i = 0; i < 3; i++) {
[_array[i] release];
}
[super dealloc];
}
@end
#endif
// Don't warn about missing releases for subclasses of SenTestCase or
// for classes that are not subclasses of NSObject.
@interface SenTestCase : NSObject {}
@end
@interface MyClassTest : SenTestCase
@property (retain) NSObject *ivar;
@end
@implementation MyClassTest
-(void)tearDown {
#if NON_ARC
[_ivar release];
#endif
}
-(void)dealloc; {
#if NON_ARC
[super dealloc]; // no-warning
#endif
}
@end
@interface XCTestCase : NSObject {}
@end
@interface MyClassXCTest : XCTestCase
@property (retain) NSObject *ivar;
@end
@implementation MyClassXCTest
-(void)tearDown {
#if NON_ARC
[_ivar release];
#endif
}
-(void)dealloc; {
#if NON_ARC
[super dealloc]; // no-warning
#endif
}
@end
__attribute__((objc_root_class))
@interface NonNSObjectMissingDealloc
@property (retain) NSObject *ivar;
@end
@implementation NonNSObjectMissingDealloc
-(void)dealloc; {
}
@end
// Warn about calling -dealloc rather than release by mistake.
@interface CallDeallocOnRetainPropIvar : NSObject {
NSObject *okToDeallocDirectly;
}
@property (retain) NSObject *ivar;
@end
@implementation CallDeallocOnRetainPropIvar
- (void)dealloc
{
#if NON_ARC
// Only warn for synthesized ivars.
[okToDeallocDirectly dealloc]; // no-warning
[_ivar dealloc]; // expected-warning {{'_ivar' should be released rather than deallocated}}
[super dealloc];
#endif
}
@end
// CIFilter special cases.
// By design, -[CIFilter dealloc] releases (by calling -setValue: forKey: with
// 'nil') all ivars (even in its *subclasses*) with names starting with
// 'input' or that are backed by properties with names starting with 'input'.
// The Dealloc checker needs to take particular care to not warn about missing
// releases in this case -- if the user adds a release quiet the
// warning it may result in an over release.
@interface ImmediateSubCIFilter : CIFilter {
NSObject *inputIvar;
NSObject *nonInputIvar;
NSObject *notPrefixedButBackingPrefixedProperty;
NSObject *inputPrefixedButBackingNonPrefixedProperty;
}
@property(retain) NSObject *inputIvar;
@property(retain) NSObject *nonInputIvar;
@property(retain) NSObject *inputAutoSynthesizedIvar;
@property(retain) NSObject *inputExplicitlySynthesizedToNonPrefixedIvar;
@property(retain) NSObject *nonPrefixedPropertyBackedByExplicitlySynthesizedPrefixedIvar;
@end
@implementation ImmediateSubCIFilter
@synthesize inputIvar = inputIvar;
@synthesize nonInputIvar = nonInputIvar;
@synthesize inputExplicitlySynthesizedToNonPrefixedIvar = notPrefixedButBackingPrefixedProperty;
@synthesize nonPrefixedPropertyBackedByExplicitlySynthesizedPrefixedIvar = inputPrefixedButBackingNonPrefixedProperty;
- (void)dealloc {
#if NON_ARC
// We don't want warnings here for:
// inputIvar
// inputAutoSynthesizedIvar
// inputExplicitlySynthesizedToNonPrefixedIvar
// inputPrefixedButBackingNonPrefixedProperty
[super dealloc];
// expected-warning@-1 {{The 'nonInputIvar' ivar in 'ImmediateSubCIFilter' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
@interface SubSubCIFilter : CIFilter {
NSObject *inputIvarInSub;
}
@property(retain) NSObject *inputIvarInSub;
@end
@implementation SubSubCIFilter
@synthesize inputIvarInSub = inputIvarInSub;
- (void)dealloc {
// Don't warn about inputIvarInSub.
#if NON_ARC
[super dealloc];
#endif
}
@end
@interface OverreleasingCIFilter : CIFilter {
NSObject *inputIvar;
}
@property(retain) NSObject *inputIvar;
@end
@implementation OverreleasingCIFilter
@synthesize inputIvar = inputIvar;
- (void)dealloc {
#if NON_ARC
// This is an over release because CIFilter's dealloc will also release it.
[inputIvar release]; // expected-warning {{The 'inputIvar' ivar in 'OverreleasingCIFilter' will be released by '-[CIFilter dealloc]' but also released here}}
[super dealloc]; // no-warning
#endif
}
@end
@interface NotMissingDeallocCIFilter : CIFilter {
NSObject *inputIvar;
}
@property(retain) NSObject *inputIvar;
@end
@implementation NotMissingDeallocCIFilter // no-warning
@synthesize inputIvar = inputIvar;
@end
@interface ClassWithRetainPropWithIBOutletIvarButNoSetter : NSObject {
// On macOS, the nib-loading code will set the ivar directly without
// retaining value (unike iOS, where it is retained). This means that
// on macOS we should not warn about a missing release for a property backed
// by an IBOutlet ivar when that property does not have a setter.
IBOutlet NSObject *ivarForOutlet;
}
@property (readonly, retain) NSObject *ivarForOutlet;
@end
@implementation ClassWithRetainPropWithIBOutletIvarButNoSetter
@synthesize ivarForOutlet;
- (void)dealloc {
#if NON_ARC
[super dealloc];
#if !MACOS
// expected-warning@-2{{The 'ivarForOutlet' ivar in 'ClassWithRetainPropWithIBOutletIvarButNoSetter' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
#endif
}
@end
@interface ClassWithRetainPropWithIBOutletIvarAndShadowingReadWrite : NSObject {
IBOutlet NSObject *ivarForOutlet;
}
@property (readonly, retain) NSObject *ivarForOutlet;
@end
@interface ClassWithRetainPropWithIBOutletIvarAndShadowingReadWrite ()
// Since there is a shadowing readwrite property, there will be a retaining
// setter and so the ivar will be retained by nib-loading code even on
// macOS and therefore must be released.
@property (readwrite, retain) NSObject *ivarForOutlet;
@end
@implementation ClassWithRetainPropWithIBOutletIvarAndShadowingReadWrite
@synthesize ivarForOutlet;
- (void)dealloc {
#if NON_ARC
[super dealloc];
// expected-warning@-1{{The 'ivarForOutlet' ivar in 'ClassWithRetainPropWithIBOutletIvarAndShadowingReadWrite' was retained by a synthesized property but not released before '[super dealloc]'}}
#endif
}
@end
diff --git a/clang/test/Analysis/DeallocUseAfterFreeErrors.m b/clang/test/Analysis/DeallocUseAfterFreeErrors.m
index c131e71..2e1bdc4 100644
--- a/clang/test/Analysis/DeallocUseAfterFreeErrors.m
+++ b/clang/test/Analysis/DeallocUseAfterFreeErrors.m
@@ -1,373 +1,373 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.SuperDealloc,debug.ExprInspection -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.SuperDealloc,debug.ExprInspection -analyzer-output=text -verify %s
void clang_analyzer_warnIfReached();
#define nil ((id)0)
typedef unsigned long NSUInteger;
@protocol NSObject
- (instancetype)retain;
- (oneway void)release;
@end
@interface NSObject <NSObject> { }
- (void)dealloc;
- (instancetype)init;
@end
typedef struct objc_selector *SEL;
//===------------------------------------------------------------------------===
// <rdar://problem/6953275>
// Check that 'self' is not referenced after calling '[super dealloc]'.
@interface SuperDeallocThenReleaseIvarClass : NSObject {
NSObject *_ivar;
}
@end
@implementation SuperDeallocThenReleaseIvarClass
- (instancetype)initWithIvar:(NSObject *)ivar {
self = [super init];
if (!self)
return nil;
_ivar = [ivar retain];
return self;
}
- (void)dealloc {
[super dealloc]; // expected-note {{[super dealloc] called here}}
[_ivar release]; // expected-warning {{Use of instance variable '_ivar' after 'self' has been deallocated}}
// expected-note@-1 {{Use of instance variable '_ivar' after 'self' has been deallocated}}
}
@end
@interface SuperDeallocThenAssignNilToIvarClass : NSObject {
NSObject *_delegate;
}
@end
@implementation SuperDeallocThenAssignNilToIvarClass
- (instancetype)initWithDelegate:(NSObject *)delegate {
self = [super init];
if (!self)
return nil;
_delegate = delegate;
return self;
}
- (void)dealloc {
[super dealloc]; // expected-note {{[super dealloc] called here}}
_delegate = nil; // expected-warning {{Use of instance variable '_delegate' after 'self' has been deallocated}}
// expected-note@-1 {{Use of instance variable '_delegate' after 'self' has been deallocated}}
}
@end
struct SomeStruct {
int f;
};
@interface SuperDeallocThenAssignIvarField : NSObject {
struct SomeStruct _s;
}
@end
@implementation SuperDeallocThenAssignIvarField
- (void)dealloc {
[super dealloc]; // expected-note {{[super dealloc] called here}}
_s.f = 7; // expected-warning {{Use of instance variable '_s' after 'self' has been deallocated}}
// expected-note@-1 {{Use of instance variable '_s' after 'self' has been deallocated}}
}
@end
@interface OtherClassWithIvar {
@public
int _otherIvar;
}
@end;
@interface SuperDeallocThenAssignIvarIvar : NSObject {
OtherClassWithIvar *_ivar;
}
@end
@implementation SuperDeallocThenAssignIvarIvar
- (void)dealloc {
[super dealloc]; // expected-note {{[super dealloc] called here}}
_ivar->_otherIvar = 7; // expected-warning {{Use of instance variable '_ivar' after 'self' has been deallocated}}
// expected-note@-1 {{Use of instance variable '_ivar' after 'self' has been deallocated}}
}
@end
@interface SuperDeallocThenAssignSelfIvar : NSObject {
NSObject *_ivar;
}
@end
@implementation SuperDeallocThenAssignSelfIvar
- (void)dealloc {
[super dealloc]; // expected-note {{[super dealloc] called here}}
self->_ivar = nil; // expected-warning {{Use of instance variable '_ivar' after 'self' has been deallocated}}
// expected-note@-1 {{Use of instance variable '_ivar' after 'self' has been deallocated}}
}
@end
@interface SuperDeallocThenReleasePropertyClass : NSObject { }
@property (retain) NSObject *ivar;
@end
@implementation SuperDeallocThenReleasePropertyClass
- (instancetype)initWithProperty:(NSObject *)ivar {
self = [super init];
if (!self)
return nil;
self.ivar = ivar;
return self;
}
- (void)dealloc {
[super dealloc]; // expected-note {{[super dealloc] called here}}
self.ivar = nil; // expected-warning {{Use of 'self' after it has been deallocated}}
// expected-note@-1 {{Use of 'self' after it has been deallocated}}
}
@end
@interface SuperDeallocThenAssignNilToPropertyClass : NSObject { }
@property (assign) NSObject *delegate;
@end
@implementation SuperDeallocThenAssignNilToPropertyClass
- (instancetype)initWithDelegate:(NSObject *)delegate {
self = [super init];
if (!self)
return nil;
self.delegate = delegate;
return self;
}
- (void)dealloc {
[super dealloc]; // expected-note {{[super dealloc] called here}}
self.delegate = nil; // expected-warning {{Use of 'self' after it has been deallocated}}
// expected-note@-1 {{Use of 'self' after it has been deallocated}}
}
@end
@interface SuperDeallocThenCallInstanceMethodClass : NSObject { }
- (void)_invalidate;
@end
@implementation SuperDeallocThenCallInstanceMethodClass
- (void)_invalidate {
}
- (void)dealloc {
[super dealloc]; // expected-note {{[super dealloc] called here}}
[self _invalidate]; // expected-warning {{Use of 'self' after it has been deallocated}}
// expected-note@-1 {{Use of 'self' after it has been deallocated}}
}
@end
@interface SuperDeallocThenCallNonObjectiveCMethodClass : NSObject { }
@end
static void _invalidate(NSObject *object) {
(void)object;
}
@implementation SuperDeallocThenCallNonObjectiveCMethodClass
- (void)dealloc {
[super dealloc]; // expected-note {{[super dealloc] called here}}
_invalidate(self); // expected-warning {{Use of 'self' after it has been deallocated}}
// expected-note@-1 {{Use of 'self' after it has been deallocated}}
}
@end
@interface SuperDeallocThenCallObjectiveClassMethodClass : NSObject { }
@end
@implementation SuperDeallocThenCallObjectiveClassMethodClass
+ (void) invalidate:(id)arg; {
}
- (void)dealloc {
[super dealloc]; // expected-note {{[super dealloc] called here}}
[SuperDeallocThenCallObjectiveClassMethodClass invalidate:self]; // expected-warning {{Use of 'self' after it has been deallocated}}
// expected-note@-1 {{Use of 'self' after it has been deallocated}}
}
@end
@interface TwoSuperDeallocCallsClass : NSObject {
NSObject *_ivar;
}
- (void)_invalidate;
@end
@implementation TwoSuperDeallocCallsClass
- (void)_invalidate {
}
- (void)dealloc {
if (_ivar) { // expected-note {{Assuming the condition is false}} expected-note {{Taking false branch}}
[_ivar release];
[super dealloc];
return;
}
[super dealloc]; // expected-note {{[super dealloc] called here}}
[self _invalidate]; // expected-warning {{Use of 'self' after it has been deallocated}}
// expected-note@-1 {{Use of 'self' after it has been deallocated}}
}
@end
//===------------------------------------------------------------------------===
// Warn about calling [super dealloc] twice due to missing return statement.
@interface MissingReturnCausesDoubleSuperDeallocClass : NSObject {
NSObject *_ivar;
}
@end
@implementation MissingReturnCausesDoubleSuperDeallocClass
- (void)dealloc {
if (_ivar) { // expected-note {{Assuming the condition is true}} expected-note {{Taking true branch}}
[_ivar release];
[super dealloc]; // expected-note {{[super dealloc] called here}}
// return;
}
[super dealloc]; // expected-warning{{[super dealloc] should not be called multiple times}}
// expected-note@-1{{[super dealloc] should not be called multiple times}}
}
@end
//===------------------------------------------------------------------------===
// Warn about calling [super dealloc] twice in two different methods.
@interface SuperDeallocInOtherMethodClass : NSObject {
NSObject *_ivar;
}
- (void)_cleanup;
@end
@implementation SuperDeallocInOtherMethodClass
- (void)_cleanup {
[_ivar release];
[super dealloc]; // expected-note {{[super dealloc] called here}}
}
- (void)dealloc {
[self _cleanup]; // expected-note {{Calling '_cleanup'}}
//expected-note@-1 {{Returning from '_cleanup'}}
[super dealloc]; // expected-warning {{[super dealloc] should not be called multiple times}}
// expected-note@-1 {{[super dealloc] should not be called multiple times}}
}
@end
//===------------------------------------------------------------------------===
// Do not warn about calling [super dealloc] recursively for different objects
// of the same type with custom retain counting.
//
// A class that contains an ivar of itself with custom retain counting (such
// as provided by _OBJC_SUPPORTED_INLINE_REFCNT_WITH_DEALLOC2MAIN) can generate
// a false positive that [super dealloc] is called twice if each object instance
// is not tracked separately by the checker. This test case is just a simple
// approximation to trigger the false positive.
@class ClassWithOwnIvarInstanceClass;
@interface ClassWithOwnIvarInstanceClass : NSObject {
ClassWithOwnIvarInstanceClass *_ivar;
NSUInteger _retainCount;
}
@end
@implementation ClassWithOwnIvarInstanceClass
- (instancetype)retain {
++_retainCount;
return self;
}
- (oneway void)release {
--_retainCount;
if (!_retainCount)
[self dealloc];
}
- (void)dealloc {
[_ivar release];
[super dealloc]; // no warning: different instances of same class
}
@end
//===------------------------------------------------------------------------===
// Do not warn about calling [super dealloc] twice if +dealloc is a class
// method.
@interface SuperDeallocClassMethodIgnoredClass : NSObject { }
+ (void)dealloc;
@end
@implementation SuperDeallocClassMethodIgnoredClass
+ (void)dealloc { }
@end
@interface SuperDeallocClassMethodIgnoredSubClass : NSObject { }
+ (void)dealloc;
@end
@implementation SuperDeallocClassMethodIgnoredSubClass
+ (void)dealloc {
[super dealloc];
[super dealloc]; // no warning: class method
}
@end
//===------------------------------------------------------------------------===
// Do not warn about calling [super dealloc] twice if when the analyzer has
// inlined the call to its super deallocator.
@interface SuperClassCallingSuperDealloc : NSObject {
NSObject *_ivar;
}
@end
@implementation SuperClassCallingSuperDealloc
- (void)dealloc; {
[_ivar release]; // no-warning
[super dealloc];
}
@end
@interface SubclassCallingSuperDealloc : SuperClassCallingSuperDealloc
@end
@implementation SubclassCallingSuperDealloc
- (void)dealloc; {
[super dealloc];
}
@end
//===------------------------------------------------------------------------===
// Treat calling [super dealloc] twice as as a sink.
@interface CallingSuperDeallocTwiceIsSink : NSObject
@end
@implementation CallingSuperDeallocTwiceIsSink
- (void)dealloc; {
[super dealloc]; // expected-note {{[super dealloc] called here}}
[super dealloc]; // expected-warning {{[super dealloc] should not be called multiple times}}
// expected-note@-1 {{[super dealloc] should not be called multiple times}}
clang_analyzer_warnIfReached(); // no-warning
}
@end
//===------------------------------------------------------------------------===
// Test path notes with intervening method call on self.
@interface InterveningMethodCallOnSelf : NSObject
@end
@implementation InterveningMethodCallOnSelf
- (void)anotherMethod {
}
- (void)dealloc; {
[super dealloc]; // expected-note {{[super dealloc] called here}}
[self anotherMethod]; // expected-warning {{Use of 'self' after it has been deallocated}}
// expected-note@-1 {{Use of 'self' after it has been deallocated}}
[super dealloc];
}
@end
diff --git a/clang/test/Analysis/DynamicTypePropagation.m b/clang/test/Analysis/DynamicTypePropagation.m
index 79ef37c..25a0ae3 100644
--- a/clang/test/Analysis/DynamicTypePropagation.m
+++ b/clang/test/Analysis/DynamicTypePropagation.m
@@ -1,57 +1,57 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.ObjCGenerics -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.ObjCGenerics -verify %s
#if !__has_feature(objc_generics)
# error Compiler does not support Objective-C generics?
#endif
#define nil 0
typedef unsigned long NSUInteger;
typedef int BOOL;
@protocol NSCopying
@end
__attribute__((objc_root_class))
@interface NSObject
- (void) myFunction:(int*)p myParam:(int) n;
@end
@interface MyType : NSObject <NSCopying>
- (void) myFunction:(int*)p myParam:(int) n;
@end
@interface NSArray<ObjectType> : NSObject
- (BOOL)contains:(ObjectType)obj;
- (ObjectType)getObjAtIndex:(NSUInteger)idx;
- (ObjectType)objectAtIndexedSubscript:(NSUInteger)idx;
@property(readonly) ObjectType firstObject;
@end
@implementation NSObject
- (void) myFunction:(int*)p myParam:(int) n {
(void)*p;// no warning
}
@end
@implementation MyType
- (void) myFunction:(int*)p myParam:(int) n {
int i = 5/n; // expected-warning {{}}
(void)i;
}
@end
void testReturnType(NSArray<MyType *> *arr) {
NSArray *erased = arr;
NSObject *element = [erased firstObject];
// TODO: myFunction currently dispatches to NSObject. Make it dispatch to
// MyType instead!
[element myFunction:0 myParam:0 ];
}
void testArgument(NSArray<MyType *> *arr, id element) {
NSArray *erased = arr;
[erased contains: element];
// TODO: myFunction currently is not dispatched to MyType. Make it dispatch to
// MyType!
[element myFunction:0 myParam:0 ];
}
diff --git a/clang/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp b/clang/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
index 6fab8bb..b5e47b3 100644
--- a/clang/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
+++ b/clang/test/Analysis/Malloc+MismatchedDeallocator+NewDelete.cpp
@@ -1,107 +1,107 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete -std=c++11 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s
#include "Inputs/system-header-simulator-for-malloc.h"
//--------------------------------------------------
// Check that unix.Malloc catches all types of bugs.
//--------------------------------------------------
void testMallocDoubleFree() {
int *p = (int *)malloc(sizeof(int));
free(p);
free(p); // expected-warning{{Attempt to free released memory}}
}
void testMallocLeak() {
int *p = (int *)malloc(sizeof(int));
} // expected-warning{{Potential leak of memory pointed to by 'p'}}
void testMallocUseAfterFree() {
int *p = (int *)malloc(sizeof(int));
free(p);
int j = *p; // expected-warning{{Use of memory after it is freed}}
}
void testMallocBadFree() {
int i;
free(&i); // expected-warning{{Argument to free() is the address of the local variable 'i', which is not memory allocated by malloc()}}
}
void testMallocOffsetFree() {
int *p = (int *)malloc(sizeof(int));
free(++p); // expected-warning{{Argument to free() is offset by 4 bytes from the start of memory allocated by malloc()}}
}
//-----------------------------------------------------------------
// Check that unix.MismatchedDeallocator catches all types of bugs.
//-----------------------------------------------------------------
void testMismatchedDeallocator() {
int *x = (int *)malloc(sizeof(int));
delete x; // expected-warning{{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
}
//----------------------------------------------------------------
// Check that alpha.cplusplus.NewDelete catches all types of bugs.
//----------------------------------------------------------------
void testNewDoubleFree() {
int *p = new int;
delete p;
delete p; // expected-warning{{Attempt to free released memory}}
}
void testNewLeak() {
int *p = new int;
}
#ifdef LEAKS
// expected-warning@-2 {{Potential leak of memory pointed to by 'p'}}
#endif
void testNewUseAfterFree() {
int *p = (int *)operator new(0);
delete p;
int j = *p; // expected-warning{{Use of memory after it is freed}}
}
void testNewBadFree() {
int i;
delete &i; // expected-warning{{Argument to 'delete' is the address of the local variable 'i', which is not memory allocated by 'new'}}
}
void testNewOffsetFree() {
int *p = new int;
operator delete(++p); // expected-warning{{Argument to operator delete is offset by 4 bytes from the start of memory allocated by 'new'}}
}
//----------------------------------------------------------------
// Test that we check for free errors on escaped pointers.
//----------------------------------------------------------------
void changePtr(int **p);
static int *globalPtr;
void changePointee(int *p);
void testMismatchedChangePtrThroughCall() {
int *p = (int*)malloc(sizeof(int)*4);
changePtr(&p);
delete p; // no-warning the value of the pointer might have changed
}
void testMismatchedChangePointeeThroughCall() {
int *p = (int*)malloc(sizeof(int)*4);
changePointee(p);
delete p; // expected-warning{{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
}
void testShouldReportDoubleFreeNotMismatched() {
int *p = (int*)malloc(sizeof(int)*4);
globalPtr = p;
free(p);
delete globalPtr; // expected-warning {{Attempt to free released memory}}
}
int *allocIntArray(unsigned c) {
return new int[c];
}
void testMismatchedChangePointeeThroughAssignment() {
int *arr = allocIntArray(4);
globalPtr = arr;
delete arr; // expected-warning{{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}}
}
diff --git a/clang/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp b/clang/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp
index bca223b..88435b8 100644
--- a/clang/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp
+++ b/clang/test/Analysis/Malloc+MismatchedDeallocator_intersections.cpp
@@ -1,39 +1,39 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator -analyzer-store region -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,unix.MismatchedDeallocator -analyzer-store region -std=c++11 -verify %s
// expected-no-diagnostics
typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
void free(void *);
//--------------------------------------------------------------------
// Check that unix.Malloc + unix.MismatchedDeallocator does not enable
// warnings produced by the alpha.cplusplus.NewDelete checker.
//--------------------------------------------------------------------
void testNewDeleteNoWarn() {
int i;
delete &i; // no-warning
int *p1 = new int;
delete ++p1; // no-warning
int *p2 = new int;
delete p2;
delete p2; // no-warning
int *p3 = new int; // no-warning
int *p4 = new int;
delete p4;
int j = *p4; // no-warning
}
void testUseZeroAllocNoWarn() {
int *p1 = (int *)operator new(0);
*p1 = 1; // no-warning
int *p2 = (int *)operator new[](0);
p2[0] = 1; // no-warning
int *p3 = new int[0];
p3[0] = 1; // no-warning
}
diff --git a/clang/test/Analysis/Malloc+NewDelete_intersections.cpp b/clang/test/Analysis/Malloc+NewDelete_intersections.cpp
index d10020d..9140e1f 100644
--- a/clang/test/Analysis/Malloc+NewDelete_intersections.cpp
+++ b/clang/test/Analysis/Malloc+NewDelete_intersections.cpp
@@ -1,15 +1,15 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete -std=c++11 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -std=c++11 -verify %s
typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
void free(void *);
//-------------------------------------------------------------------
// Check that unix.Malloc + cplusplus.NewDelete does not enable
// warnings produced by unix.MismatchedDeallocator.
//-------------------------------------------------------------------
void testMismatchedDeallocator() {
int *p = (int *)malloc(sizeof(int));
delete p;
} // expected-warning{{Potential leak of memory pointed to by 'p'}}
diff --git a/clang/test/Analysis/MemRegion.cpp b/clang/test/Analysis/MemRegion.cpp
index 992b7f1..b8f079a 100644
--- a/clang/test/Analysis/MemRegion.cpp
+++ b/clang/test/Analysis/MemRegion.cpp
@@ -1,47 +1,47 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=optin.mpi.MPI-Checker -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=optin.mpi.MPI-Checker -verify %s
#include "MPIMock.h"
// Use MPI-Checker to test 'getDescriptiveName', as the checker uses the
// function for diagnostics.
void testGetDescriptiveName() {
int rank = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Request sendReq1;
MPI_Wait(&sendReq1, MPI_STATUS_IGNORE); // expected-warning{{Request 'sendReq1' has no matching nonblocking call.}}
}
void testGetDescriptiveName2() {
int rank = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Request sendReq1[10][10][10];
MPI_Wait(&sendReq1[1][7][9], MPI_STATUS_IGNORE); // expected-warning{{Request 'sendReq1[1][7][9]' has no matching nonblocking call.}}
}
void testGetDescriptiveName3() {
int rank = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
typedef struct { MPI_Request req; } ReqStruct;
ReqStruct rs;
MPI_Request *r = &rs.req;
MPI_Wait(r, MPI_STATUS_IGNORE); // expected-warning{{Request 'rs.req' has no matching nonblocking call.}}
}
void testGetDescriptiveName4() {
int rank = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
typedef struct { MPI_Request req[2][2]; } ReqStruct;
ReqStruct rs;
MPI_Request *r = &rs.req[0][1];
MPI_Wait(r, MPI_STATUS_IGNORE); // expected-warning{{Request 'rs.req[0][1]' has no matching nonblocking call.}}
}
void testGetDescriptiveName5() {
int rank = 0;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
typedef struct { MPI_Request req; } ReqStructInner;
typedef struct { ReqStructInner req; } ReqStruct;
ReqStruct rs;
MPI_Request *r = &rs.req.req;
MPI_Wait(r, MPI_STATUS_IGNORE); // expected-warning{{Request 'rs.req.req' has no matching nonblocking call.}}
}
diff --git a/clang/test/Analysis/MismatchedDeallocator-checker-test.mm b/clang/test/Analysis/MismatchedDeallocator-checker-test.mm
index 3cc3e18..b80f7df 100644
--- a/clang/test/Analysis/MismatchedDeallocator-checker-test.mm
+++ b/clang/test/Analysis/MismatchedDeallocator-checker-test.mm
@@ -1,232 +1,232 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -fblocks -verify %s
#include "Inputs/system-header-simulator-objc.h"
#include "Inputs/system-header-simulator-cxx.h"
typedef __typeof__(sizeof(int)) size_t;
void *malloc(size_t);
void *realloc(void *ptr, size_t size);
void *calloc(size_t nmemb, size_t size);
char *strdup(const char *s);
void __attribute((ownership_returns(malloc))) *my_malloc(size_t);
void free(void *);
void __attribute((ownership_takes(malloc, 1))) my_free(void *);
//---------------------------------------------------------------
// Test if an allocation function matches deallocation function
//---------------------------------------------------------------
//--------------- test malloc family
void testMalloc1() {
int *p = (int *)malloc(sizeof(int));
delete p; // expected-warning{{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
}
void testMalloc2() {
int *p = (int *)malloc(8);
int *q = (int *)realloc(p, 16);
delete q; // expected-warning{{Memory allocated by realloc() should be deallocated by free(), not 'delete'}}
}
void testMalloc3() {
int *p = (int *)calloc(1, sizeof(int));
delete p; // expected-warning{{Memory allocated by calloc() should be deallocated by free(), not 'delete'}}
}
void testMalloc4(const char *s) {
char *p = strdup(s);
delete p; // expected-warning{{Memory allocated by strdup() should be deallocated by free(), not 'delete'}}
}
void testMalloc5() {
int *p = (int *)my_malloc(sizeof(int));
delete p; // expected-warning{{Memory allocated by my_malloc() should be deallocated by free(), not 'delete'}}
}
void testMalloc6() {
int *p = (int *)malloc(sizeof(int));
operator delete(p); // expected-warning{{Memory allocated by malloc() should be deallocated by free(), not operator delete}}
}
void testMalloc7() {
int *p = (int *)malloc(sizeof(int));
delete[] p; // expected-warning{{Memory allocated by malloc() should be deallocated by free(), not 'delete[]'}}
}
void testMalloc8() {
int *p = (int *)malloc(sizeof(int));
operator delete[](p); // expected-warning{{Memory allocated by malloc() should be deallocated by free(), not operator delete[]}}
}
void testAlloca() {
int *p = (int *)__builtin_alloca(sizeof(int));
delete p; // expected-warning{{Memory allocated by alloca() should not be deallocated}}
}
//--------------- test new family
void testNew1() {
int *p = new int;
free(p); // expected-warning{{Memory allocated by 'new' should be deallocated by 'delete', not free()}}
}
void testNew2() {
int *p = (int *)operator new(0);
free(p); // expected-warning{{Memory allocated by operator new should be deallocated by 'delete', not free()}}
}
void testNew3() {
int *p = new int[1];
free(p); // expected-warning{{Memory allocated by 'new[]' should be deallocated by 'delete[]', not free()}}
}
void testNew4() {
int *p = new int;
realloc(p, sizeof(long)); // expected-warning{{Memory allocated by 'new' should be deallocated by 'delete', not realloc()}}
}
void testNew5() {
int *p = (int *)operator new(0);
realloc(p, sizeof(long)); // expected-warning{{Memory allocated by operator new should be deallocated by 'delete', not realloc()}}
}
void testNew6() {
int *p = new int[1];
realloc(p, sizeof(long)); // expected-warning{{Memory allocated by 'new[]' should be deallocated by 'delete[]', not realloc()}}
}
int *allocInt() {
return new int;
}
void testNew7() {
int *p = allocInt();
delete[] p; // expected-warning{{Memory allocated by 'new' should be deallocated by 'delete', not 'delete[]'}}
}
void testNew8() {
int *p = (int *)operator new(0);
delete[] p; // expected-warning{{Memory allocated by operator new should be deallocated by 'delete', not 'delete[]'}}
}
int *allocIntArray(unsigned c) {
return new int[c];
}
void testNew9() {
int *p = allocIntArray(1);
delete p; // expected-warning{{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}}
}
void testNew10() {
int *p = (int *)operator new[](0);
delete p; // expected-warning{{Memory allocated by operator new[] should be deallocated by 'delete[]', not 'delete'}}
}
void testNew11(NSUInteger dataLength) {
int *p = new int;
NSData *d = [NSData dataWithBytesNoCopy:p length:sizeof(int) freeWhenDone:1]; // expected-warning{{+dataWithBytesNoCopy:length:freeWhenDone: cannot take ownership of memory allocated by 'new'}}
}
//-------------------------------------------------------
// Check for intersection with unix.Malloc bounded with
// unix.MismatchedDeallocator
//-------------------------------------------------------
// new/delete oparators are subjects of cplusplus.NewDelete.
void testNewDeleteNoWarn() {
int i;
delete &i; // no-warning
int *p1 = new int;
delete ++p1; // no-warning
int *p2 = new int;
delete p2;
delete p2; // no-warning
int *p3 = new int; // no-warning
}
void testDeleteOpAfterFree() {
int *p = (int *)malloc(sizeof(int));
free(p);
operator delete(p); // no-warning
}
void testDeleteAfterFree() {
int *p = (int *)malloc(sizeof(int));
free(p);
delete p; // no-warning
}
void testStandardPlacementNewAfterFree() {
int *p = (int *)malloc(sizeof(int));
free(p);
p = new(p) int; // no-warning
}
//---------------------------------------------------------------
// Check for intersection with cplusplus.NewDelete bounded with
// unix.MismatchedDeallocator
//---------------------------------------------------------------
// malloc()/free() are subjects of unix.Malloc and unix.MallocWithAnnotations
void testMallocFreeNoWarn() {
int i;
free(&i); // no-warning
int *p1 = (int *)malloc(sizeof(int));
free(++p1); // no-warning
int *p2 = (int *)malloc(sizeof(int));
free(p2);
free(p2); // no-warning
int *p3 = (int *)malloc(sizeof(int)); // no-warning
}
void testFreeAfterDelete() {
int *p = new int;
delete p;
free(p); // no-warning
}
void testStandardPlacementNewAfterDelete() {
int *p = new int;
delete p;
p = new(p) int; // no-warning
}
// Smart pointer example
template <typename T>
struct SimpleSmartPointer {
T *ptr;
explicit SimpleSmartPointer(T *p = 0) : ptr(p) {}
~SimpleSmartPointer() {
delete ptr;
// expected-warning@-1 {{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}}
// expected-warning@-2 {{Memory allocated by malloc() should be deallocated by free(), not 'delete'}}
}
};
void testSimpleSmartPointerArrayNew() {
{
SimpleSmartPointer<int> a(new int);
} // no-warning
{
SimpleSmartPointer<int> a(new int[4]);
}
}
void testSimpleSmartPointerMalloc() {
{
SimpleSmartPointer<int> a(new int);
} // no-warning
{
SimpleSmartPointer<int> a((int *)malloc(4));
}
}
diff --git a/clang/test/Analysis/MismatchedDeallocator-path-notes.cpp b/clang/test/Analysis/MismatchedDeallocator-path-notes.cpp
index 1c8c80c..118f23b 100644
--- a/clang/test/Analysis/MismatchedDeallocator-path-notes.cpp
+++ b/clang/test/Analysis/MismatchedDeallocator-path-notes.cpp
@@ -1,305 +1,305 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=text -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist
// RUN: FileCheck --input-file=%t.plist %s
void changePointee(int *p);
int *allocIntArray(unsigned c) {
return new int[c]; // expected-note {{Memory is allocated}}
}
void test() {
int *p = allocIntArray(1); // expected-note {{Calling 'allocIntArray'}}
// expected-note@-1 {{Returned allocated memory}}
changePointee(p);
delete p; // expected-warning {{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}}
// expected-note@-1 {{Memory allocated by 'new[]' should be deallocated by 'delete[]', not 'delete'}}
}
// CHECK: <key>diagnostics</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>path</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>control</string>
// CHECK-NEXT: <key>edges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>start</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>5</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>end</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>24</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>ranges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>27</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>0</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Calling &apos;allocIntArray&apos;</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Calling &apos;allocIntArray&apos;</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>1</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>depth</key><integer>1</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Entered call from &apos;test&apos;</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Entered call from &apos;test&apos;</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>control</string>
// CHECK-NEXT: <key>edges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>start</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>1</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>end</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>7</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>7</integer>
// CHECK-NEXT: <key>col</key><integer>8</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>control</string>
// CHECK-NEXT: <key>edges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>start</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>7</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>7</integer>
// CHECK-NEXT: <key>col</key><integer>8</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>end</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>7</integer>
// CHECK-NEXT: <key>col</key><integer>10</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>7</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>7</integer>
// CHECK-NEXT: <key>col</key><integer>10</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>ranges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>7</integer>
// CHECK-NEXT: <key>col</key><integer>10</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>7</integer>
// CHECK-NEXT: <key>col</key><integer>19</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>1</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Memory is allocated</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Memory is allocated</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>ranges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>27</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>0</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Returned allocated memory</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Returned allocated memory</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>control</string>
// CHECK-NEXT: <key>edges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>start</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>24</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>end</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>8</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>ranges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>10</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>10</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>0</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Memory allocated by &apos;new[]&apos; should be deallocated by &apos;delete[]&apos;, not &apos;delete&apos;</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Memory allocated by &apos;new[]&apos; should be deallocated by &apos;delete[]&apos;, not &apos;delete&apos;</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>description</key><string>Memory allocated by &apos;new[]&apos; should be deallocated by &apos;delete[]&apos;, not &apos;delete&apos;</string>
// CHECK-NEXT: <key>category</key><string>Memory Error</string>
// CHECK-NEXT: <key>type</key><string>Bad deallocator</string>
// CHECK-NEXT: <key>check_name</key><string>unix.MismatchedDeallocator</string>
// CHECK-NEXT: <!-- This hash is experimental and going to change! -->
// CHECK-NEXT: <key>issue_hash_content_of_line_in_context</key><string>2009ca1da75217064b6052ba7465dff9</string>
// CHECK-NEXT: <key>issue_context_kind</key><string>function</string>
// CHECK-NEXT: <key>issue_context</key><string>test</string>
// CHECK-NEXT: <key>issue_hash_function_offset</key><string>4</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
diff --git a/clang/test/Analysis/MissingDealloc.m b/clang/test/Analysis/MissingDealloc.m
index 248dc51..bedd1e7 100644
--- a/clang/test/Analysis/MissingDealloc.m
+++ b/clang/test/Analysis/MissingDealloc.m
@@ -1,186 +1,186 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Dealloc -fblocks -verify -triple x86_64-apple-darwin10 -fobjc-arc %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=osx.cocoa.Dealloc -fblocks -verify -triple x86_64-apple-darwin10 -fobjc-arc %s
#define NON_ARC !__has_feature(objc_arc)
// No diagnostics expected under ARC.
#if !NON_ARC
// expected-no-diagnostics
#endif
typedef signed char BOOL;
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (Class)class;
@end
@interface NSObject <NSObject> {}
- (void)dealloc;
- (id)init;
@end
typedef struct objc_selector *SEL;
//===------------------------------------------------------------------------===
// Do not warn about missing -dealloc method. Not enough context to know
// whether the ivar is retained or not.
@interface MissingDeallocWithIvar : NSObject {
NSObject *_ivar;
}
@end
@implementation MissingDeallocWithIvar
@end
//===------------------------------------------------------------------------===
// Do not warn about missing -dealloc method. These properties are not
// retained or synthesized.
@interface MissingDeallocWithIntProperty : NSObject
@property (assign) int ivar;
@end
@implementation MissingDeallocWithIntProperty
@end
@interface MissingDeallocWithSELProperty : NSObject
@property (assign) SEL ivar;
@end
@implementation MissingDeallocWithSELProperty
@end
//===------------------------------------------------------------------------===
// Warn about missing -dealloc method.
@interface MissingDeallocWithCopyProperty : NSObject
@property (copy) NSObject *ivar;
@end
#if NON_ARC
// expected-warning@+2{{'MissingDeallocWithCopyProperty' lacks a 'dealloc' instance method but must release '_ivar'}}
#endif
@implementation MissingDeallocWithCopyProperty
@end
@interface MissingDeallocWithRetainProperty : NSObject
@property (retain) NSObject *ivar;
@end
#if NON_ARC
// expected-warning@+2{{'MissingDeallocWithRetainProperty' lacks a 'dealloc' instance method but must release '_ivar'}}
#endif
@implementation MissingDeallocWithRetainProperty
@end
@interface MissingDeallocWithMultipleProperties : NSObject
@property (retain) NSObject *ivar1;
@property (retain) NSObject *ivar2;
@end
#if NON_ARC
// expected-warning@+2{{'MissingDeallocWithMultipleProperties' lacks a 'dealloc' instance method but must release '_ivar1' and others}}
#endif
@implementation MissingDeallocWithMultipleProperties
@end
@interface MissingDeallocWithIVarAndRetainProperty : NSObject {
NSObject *_ivar2;
}
@property (retain) NSObject *ivar1;
@end
#if NON_ARC
// expected-warning@+2{{'MissingDeallocWithIVarAndRetainProperty' lacks a 'dealloc' instance method but must release '_ivar1'}}
#endif
@implementation MissingDeallocWithIVarAndRetainProperty
@end
@interface MissingDeallocWithReadOnlyRetainedProperty : NSObject
@property (readonly,retain) NSObject *ivar;
@end
#if NON_ARC
// expected-warning@+2{{'MissingDeallocWithReadOnlyRetainedProperty' lacks a 'dealloc' instance method but must release '_ivar'}}
#endif
@implementation MissingDeallocWithReadOnlyRetainedProperty
@end
//===------------------------------------------------------------------------===
// Don't warn about iVars that are selectors.
@interface TestSELs : NSObject {
SEL a;
SEL b;
}
@end
@implementation TestSELs
- (id)init {
if( (self = [super init]) ) {
a = @selector(a);
b = @selector(b);
}
return self;
}
@end
//===------------------------------------------------------------------------===
// Don't warn about iVars that are IBOutlets.
@class NSWindow;
@interface HasOutlet : NSObject {
IBOutlet NSWindow *window;
}
@end
@implementation HasOutlet // no-warning
@end
//===------------------------------------------------------------------------===
// PR 3187: http://llvm.org/bugs/show_bug.cgi?id=3187
// - Disable the missing -dealloc check for classes that subclass SenTestCase
@class NSString;
@interface SenTestCase : NSObject {}
@end
@interface MyClassTest : SenTestCase {
NSString *resourcePath;
}
@property (retain) NSObject *ivar;
@end
@interface NSBundle : NSObject {}
+ (NSBundle *)bundleForClass:(Class)aClass;
- (NSString *)resourcePath;
@end
@implementation MyClassTest
- (void)setUp {
resourcePath = [[NSBundle bundleForClass:[self class]] resourcePath];
}
- (void)testXXX {
// do something which uses resourcepath
}
@end
//===------------------------------------------------------------------------===
// Don't warn for clases that aren't subclasses of NSObject
__attribute__((objc_root_class))
@interface NonNSObjectMissingDealloc
@property (retain) NSObject *ivar;
@end
@implementation NonNSObjectMissingDealloc
@end
// CHECK: 4 warnings generated.
diff --git a/clang/test/Analysis/NSContainers.m b/clang/test/Analysis/NSContainers.m
index c868459..ac33efc 100644
--- a/clang/test/Analysis/NSContainers.m
+++ b/clang/test/Analysis/NSContainers.m
@@ -1,312 +1,312 @@
-// RUN: %clang_cc1 -Wno-objc-literal-conversion -analyze -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg,osx.cocoa.Loops,debug.ExprInspection -verify -Wno-objc-root-class %s
+// RUN: %clang_analyze_cc1 -Wno-objc-literal-conversion -analyzer-checker=core,osx.cocoa.NonNilReturnValue,osx.cocoa.NilArg,osx.cocoa.Loops,debug.ExprInspection -verify -Wno-objc-root-class %s
void clang_analyzer_eval(int);
typedef unsigned long NSUInteger;
typedef signed char BOOL;
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@protocol NSObject
@end
@protocol NSCopying
- (id)copyWithZone:(NSZone *)zone;
@end
@protocol NSMutableCopying
- (id)mutableCopyWithZone:(NSZone *)zone;
@end
@protocol NSCoding
- (void)encodeWithCoder:(NSCoder *)aCoder;
@end
@protocol NSSecureCoding <NSCoding>
@required
+ (BOOL)supportsSecureCoding;
@end
@interface NSObject <NSObject> {}
- (id)init;
+ (id)alloc;
- (id)mutableCopy;
@end
typedef struct {
unsigned long state;
id *itemsPtr;
unsigned long *mutationsPtr;
unsigned long extra[5];
} NSFastEnumerationState;
@protocol NSFastEnumeration
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id [])buffer count:(NSUInteger)len;
@end
@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration>
- (NSUInteger)count;
- (id)objectAtIndex:(NSUInteger)index;
@end
@interface NSArray (NSExtendedArray)
- (NSArray *)arrayByAddingObject:(id)anObject;
- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx __attribute__((availability(macosx,introduced=10.8)));
@end
@interface NSArray (NSArrayCreation)
+ (instancetype)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt;
@end
@interface NSMutableArray : NSArray
- (void)addObject:(id)anObject;
- (void)insertObject:(id)anObject atIndex:(NSUInteger)index;
- (void)removeLastObject;
- (void)removeObjectAtIndex:(NSUInteger)index;
- (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject;
@end
@interface NSDictionary : NSObject <NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration>
- (NSUInteger)count;
- (id)objectForKey:(id)aKey;
- (NSEnumerator *)keyEnumerator;
@end
@interface NSDictionary (NSDictionaryCreation)
+ (id)dictionary;
+ (id)dictionaryWithObject:(id)object forKey:(id <NSCopying>)key;
+ (instancetype)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt;
@end
@interface NSMutableDictionary : NSDictionary
- (void)removeObjectForKey:(id)aKey;
- (void)setObject:(id)anObject forKey:(id <NSCopying>)aKey;
@end
@interface NSMutableDictionary (NSExtendedMutableDictionary)
- (void)addEntriesFromDictionary:(NSDictionary *)otherDictionary;
- (void)removeAllObjects;
- (void)removeObjectsForKeys:(NSArray *)keyArray;
- (void)setDictionary:(NSDictionary *)otherDictionary;
- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key __attribute__((availability(macosx,introduced=10.8)));
@end
@interface NSOrderedSet : NSObject <NSFastEnumeration>
@end
@interface NSOrderedSet (NSOrderedSetCreation)
- (NSUInteger)count;
@end
@interface NSString : NSObject <NSCopying, NSMutableCopying, NSSecureCoding>
@end
@interface NSNull : NSObject <NSCopying, NSSecureCoding>
+ (NSNull *)null;
@end
// NSMutableArray API
void testNilArgNSMutableArray1() {
NSMutableArray *marray = [[NSMutableArray alloc] init];
[marray addObject:0]; // expected-warning {{Argument to 'NSMutableArray' method 'addObject:' cannot be nil}}
}
void testNilArgNSMutableArray2() {
NSMutableArray *marray = [[NSMutableArray alloc] init];
[marray insertObject:0 atIndex:1]; // expected-warning {{Argument to 'NSMutableArray' method 'insertObject:atIndex:' cannot be nil}}
}
void testNilArgNSMutableArray3() {
NSMutableArray *marray = [[NSMutableArray alloc] init];
[marray replaceObjectAtIndex:1 withObject:0]; // expected-warning {{Argument to 'NSMutableArray' method 'replaceObjectAtIndex:withObject:' cannot be nil}}
}
void testNilArgNSMutableArray4() {
NSMutableArray *marray = [[NSMutableArray alloc] init];
[marray setObject:0 atIndexedSubscript:1]; // expected-warning {{Argument to 'NSMutableArray' method 'setObject:atIndexedSubscript:' cannot be nil}}
}
void testNilArgNSMutableArray5() {
NSMutableArray *marray = [[NSMutableArray alloc] init];
marray[1] = 0; // expected-warning {{Array element cannot be nil}}
}
// NSArray API
void testNilArgNSArray1() {
NSArray *array = [[NSArray alloc] init];
NSArray *copyArray = [array arrayByAddingObject:0]; // expected-warning {{Argument to 'NSArray' method 'arrayByAddingObject:' cannot be nil}}
}
// NSMutableDictionary and NSDictionary APIs.
void testNilArgNSMutableDictionary1(NSMutableDictionary *d, NSString* key) {
[d setObject:0 forKey:key]; // expected-warning {{Value argument to 'setObject:forKey:' cannot be nil}}
}
void testNilArgNSMutableDictionary2(NSMutableDictionary *d, NSObject *obj) {
[d setObject:obj forKey:0]; // expected-warning {{Key argument to 'setObject:forKey:' cannot be nil}}
}
void testNilArgNSMutableDictionary3(NSMutableDictionary *d) {
[d removeObjectForKey:0]; // expected-warning {{Value argument to 'removeObjectForKey:' cannot be nil}}
}
void testNilArgNSMutableDictionary5(NSMutableDictionary *d, NSString* key) {
d[key] = 0; // no-warning - removing the mapping for the given key
}
void testNilArgNSMutableDictionary6(NSMutableDictionary *d, NSString *key) {
if (key)
;
d[key] = 0; // expected-warning {{'NSMutableDictionary' key cannot be nil}}
}
NSDictionary *testNilArgNSDictionary1(NSString* key) {
return [NSDictionary dictionaryWithObject:0 forKey:key]; // expected-warning {{Value argument to 'dictionaryWithObject:forKey:' cannot be nil}}
}
NSDictionary *testNilArgNSDictionary2(NSObject *obj) {
return [NSDictionary dictionaryWithObject:obj forKey:0]; // expected-warning {{Key argument to 'dictionaryWithObject:forKey:' cannot be nil}}
}
id testCreateDictionaryLiteralKey(id value, id nilKey) {
if (nilKey)
;
return @{@"abc":value, nilKey:@"abc"}; // expected-warning {{Dictionary key cannot be nil}}
}
id testCreateDictionaryLiteralValue(id nilValue) {
if (nilValue)
;
return @{@"abc":nilValue}; // expected-warning {{Dictionary value cannot be nil}}
}
id testCreateDictionaryLiteral(id nilValue, id nilKey) {
if (nilValue)
;
if (nilKey)
;
return @{@"abc":nilValue, nilKey:@"abc"}; // expected-warning {{Dictionary key cannot be nil}}
// expected-warning@-1 {{Dictionary value cannot be nil}}
}
id testCreateArrayLiteral(id myNil) {
if (myNil)
;
return @[ @"a", myNil, @"c" ]; // expected-warning {{Array element cannot be nil}}
}
// Test inline defensive checks suppression.
void idc(id x) {
if (x)
;
}
void testIDC(NSMutableDictionary *d, NSString *key) {
idc(key);
d[key] = @"abc"; // no-warning
}
@interface Foo {
@public
int x;
}
- (int *)getPtr;
- (int)getInt;
- (NSMutableDictionary *)getDictPtr;
@property (retain, readonly, nonatomic) Foo* data;
- (NSString*) stringForKeyFE: (id<NSCopying>)key;
@end
void idc2(id x) {
if (!x)
return;
}
Foo *retNil() {
return 0;
}
void testIDC2(Foo *obj) {
idc2(obj);
*[obj getPtr] = 1; // no-warning
}
int testIDC3(Foo *obj) {
idc2(obj);
return 1/[obj getInt];
}
void testNilReceiverIDC(Foo *obj, NSString *key) {
NSMutableDictionary *D = [obj getDictPtr];
idc(D);
D[key] = @"abc"; // no-warning
}
void testNilReceiverRetNil2(NSMutableDictionary *D, Foo *FooPtrIn, id value) {
NSString* const kKeyIdentifier = @"key";
Foo *FooPtr = retNil();
NSString *key = [[FooPtr data] stringForKeyFE: kKeyIdentifier];
// key is nil because FooPtr is nil. However, FooPtr is set to nil inside an
// inlined function, so this error report should be suppressed.
[D setObject: value forKey: key]; // no-warning
}
void testAssumeNSNullNullReturnsNonNil(NSMutableDictionary *Table, id Object,
id InValue) {
id Value = Object ? [Table objectForKey:Object] : [NSNull null];
if (!Value) {
Value = InValue;
[Table setObject:Value forKey:Object]; // no warning
}
}
void testCollectionIsNotEmptyWhenCountIsGreaterThanZero(NSMutableDictionary *D){
if ([D count] > 0) { // Count is greater than zero.
NSString *s = 0;
for (NSString *key in D) {
s = key; // Loop is always entered.
}
[D removeObjectForKey:s]; // no warning
}
}
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
}
}
void testLiteralsNonNil() {
clang_analyzer_eval(!!@[]); // expected-warning{{TRUE}}
clang_analyzer_eval(!!@{}); // expected-warning{{TRUE}}
}
@interface NSMutableArray (MySafeAdd)
- (void)addObject:(id)obj safe:(BOOL)safe;
@end
void testArrayCategory(NSMutableArray *arr) {
[arr addObject:0 safe:1]; // no-warning
}
@interface MyView : NSObject
-(NSArray *)subviews;
@end
void testNoReportWhenReceiverNil(NSMutableArray *array, int b) {
// Don't warn about adding nil to a container when the receiver is also
// definitely nil.
if (array == 0) {
[array addObject:0]; // no-warning
}
MyView *view = b ? [[MyView alloc] init] : 0;
NSMutableArray *subviews = [[view subviews] mutableCopy];
// When view is nil, subviews is also nil so there should be no warning
// here either.
[subviews addObject:view]; // no-warning
}
diff --git a/clang/test/Analysis/NSPanel.m b/clang/test/Analysis/NSPanel.m
index 53b18c2..e65b071 100644
--- a/clang/test/Analysis/NSPanel.m
+++ b/clang/test/Analysis/NSPanel.m
@@ -1,88 +1,88 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s
// expected-no-diagnostics
// BEGIN delta-debugging reduced header stuff
typedef struct objc_selector *SEL;
typedef signed char BOOL;
typedef unsigned int NSUInteger;
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (oneway void)release;
@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)alloc;
@end
typedef float CGFloat;
typedef struct _NSPoint {} NSRect;
static __inline__ __attribute__((always_inline)) NSRect NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h) { NSRect r; return r; }
typedef struct {} NSFastEnumerationState;
@protocol NSFastEnumeration
- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
@end
@class NSString;
@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
- (NSUInteger)count;
@end
@interface NSMutableArray : NSArray
- (void)addObject:(id)anObject;
@end @class NSAppleEventDescriptor;
enum { NSBackingStoreRetained = 0, NSBackingStoreNonretained = 1, NSBackingStoreBuffered = 2 };
typedef NSUInteger NSBackingStoreType;
@interface NSResponder : NSObject <NSCoding> {} @end
@protocol NSAnimatablePropertyContainer
- (id)animator;
@end
@protocol NSValidatedUserInterfaceItem
- (SEL)action;
@end
@protocol NSUserInterfaceValidations
- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
@end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
enum { NSBorderlessWindowMask = 0, NSTitledWindowMask = 1 << 0, NSClosableWindowMask = 1 << 1, NSMiniaturizableWindowMask = 1 << 2, NSResizableWindowMask = 1 << 3 };
@interface NSWindow : NSResponder <NSAnimatablePropertyContainer, NSUserInterfaceValidations> {}
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag;
@end
extern NSString *NSWindowDidBecomeKeyNotification;
@interface NSPanel : NSWindow {}
@end
@class NSTableHeaderView;
// END delta-debugging reduced header stuff
@interface MyClass
{
NSMutableArray *panels;
}
- (void)myMethod;
- (void)myMethod2;
@end
@implementation MyClass // no-warning
- (void)myMethod
{
NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:(BOOL)1];
[panels addObject:panel];
[panel release]; // no-warning
}
- (void)myMethod2
{
NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:(BOOL)1]; // no-warning
[panels addObject:panel];
}
@end
diff --git a/clang/test/Analysis/NSString.m b/clang/test/Analysis/NSString.m
index 1123d80..a53fc1e 100644
--- a/clang/test/Analysis/NSString.m
+++ b/clang/test/Analysis/NSString.m
@@ -1,448 +1,448 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s
-// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -analyzer-config mode=shallow -verify -Wno-objc-root-class %s
-// RUN: %clang_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s
-// RUN: %clang_cc1 -DOSATOMIC_USE_INLINED -triple i386-apple-darwin10 -analyze -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s
+// RUN: %clang_analyze_cc1 -triple i386-apple-darwin10 -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -analyzer-config mode=shallow -verify -Wno-objc-root-class %s
+// RUN: %clang_analyze_cc1 -DTEST_64 -triple x86_64-apple-darwin10 -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s
+// RUN: %clang_analyze_cc1 -DOSATOMIC_USE_INLINED -triple i386-apple-darwin10 -analyzer-checker=core,osx.cocoa.NilArg,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -verify -Wno-objc-root-class %s
//===----------------------------------------------------------------------===//
// 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.
//===----------------------------------------------------------------------===//
NSComparisonResult f1(NSString* s) {
NSString *aString = 0;
return [s compare:aString]; // expected-warning {{Argument to 'NSString' method 'compare:' cannot be nil}}
}
NSComparisonResult f2(NSString* s) {
NSString *aString = 0;
return [s caseInsensitiveCompare:aString]; // expected-warning {{Argument to 'NSString' method 'caseInsensitiveCompare:' cannot be nil}}
}
NSComparisonResult f3(NSString* s, NSStringCompareOptions op) {
NSString *aString = 0;
return [s compare:aString options:op]; // expected-warning {{Argument to 'NSString' method 'compare:options:' cannot be nil}}
}
NSComparisonResult f4(NSString* s, NSStringCompareOptions op, NSRange R) {
NSString *aString = 0;
return [s compare:aString options:op range:R]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:' cannot be nil}}
}
NSComparisonResult f5(NSString* s, NSStringCompareOptions op, NSRange R) {
NSString *aString = 0;
return [s compare:aString options:op range:R locale:0]; // expected-warning {{Argument to 'NSString' method 'compare:options:range:locale:' cannot be nil}}
}
NSArray *f6(NSString* s) {
return [s componentsSeparatedByCharactersInSet:0]; // expected-warning {{Argument to 'NSString' method 'componentsSeparatedByCharactersInSet:' cannot be nil}}
}
NSString* f7(NSString* s1, NSString* s2, NSString* s3) {
NSString* s4 = (NSString*)
CFStringCreateWithFormat(kCFAllocatorDefault, 0, // expected-warning{{leak}}
(CFStringRef) __builtin___CFStringMakeConstantString("%@ %@ (%@)"),
s1, s2, s3);
CFRetain(s4);
return s4;
}
NSMutableArray* f8() {
NSString* s = [[NSString alloc] init];
NSMutableArray* a = [[NSMutableArray alloc] initWithCapacity:2];
[a addObject:s];
[s release]; // no-warning
return a;
}
void f9() {
NSString* s = [[NSString alloc] init];
NSString* q = s;
[s release];
[q release]; // expected-warning {{used after it is released}}
}
NSString* f10() {
static NSString* s = 0;
if (!s) s = [[NSString alloc] init];
return s; // no-warning
}
// Test case for regression reported in <rdar://problem/6452745>.
// Essentially 's' should not be considered allocated on the false branch.
// This exercises the 'EvalAssume' logic in GRTransferFuncs (CFRefCount.cpp).
NSString* f11(CFDictionaryRef dict, const char* key) {
NSString* s = (NSString*) CFDictionaryGetValue(dict, key);
[s retain];
if (s) {
[s release];
}
return 0;
}
// Test case for passing a tracked object by-reference to a function we
// don't understand.
void unknown_function_f12(NSString** s);
void f12() {
NSString *string = [[NSString alloc] init];
unknown_function_f12(&string); // no-warning
}
// Test double release of CFString (PR 4014).
void f13(void) {
CFStringRef ref = CFStringCreateWithFormat(kCFAllocatorDefault, ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "%d" "")), 100);
CFRelease(ref);
CFRelease(ref); // expected-warning{{Reference-counted object is used after it is released}}
}
@interface MyString : NSString
@end
void f14(MyString *s) {
[s compare:0]; // expected-warning {{Argument to 'MyString' method 'compare:' cannot be nil}}
}
// Test regular use of -autorelease
@interface TestAutorelease
-(NSString*) getString;
@end
@implementation TestAutorelease
-(NSString*) getString {
NSString *str = [[NSString alloc] init];
return [str autorelease]; // no-warning
}
- (void)m1
{
NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
[s retain];
[s autorelease];
}
- (void)m2
{
NSString *s = [[[NSString alloc] init] autorelease]; // expected-warning{{leak}}
[s retain];
}
- (void)m3
{
NSString *s = [[[NSString alloc] init] autorelease];
[s retain];
[s autorelease];
}
- (void)m4
{
NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
[s retain];
}
- (void)m5
{
NSString *s = [[NSString alloc] init];
[s autorelease];
}
@end
@interface C1 : NSObject {}
- (NSString*) getShared;
+ (C1*) sharedInstance;
@end
@implementation C1 : NSObject {}
- (NSString*) getShared {
static NSString* s = 0;
if (!s) s = [[NSString alloc] init];
return s; // no-warning
}
+ (C1 *)sharedInstance {
static C1 *sharedInstance = 0;
if (!sharedInstance) {
sharedInstance = [[C1 alloc] init];
}
return sharedInstance; // no-warning
}
@end
@interface SharedClass : NSObject
+ (id)sharedInstance;
- (id)notShared;
@end
@implementation SharedClass
- (id)_init {
if ((self = [super init])) {
NSLog(@"Bar");
}
return self;
}
- (id)notShared {
return [[SharedClass alloc] _init]; // expected-warning{{leak}}
}
+ (id)sharedInstance {
static SharedClass *_sharedInstance = 0;
if (!_sharedInstance) {
_sharedInstance = [[SharedClass alloc] _init];
}
return _sharedInstance; // no-warning
}
@end
id testSharedClassFromFunction() {
return [[SharedClass alloc] _init]; // no-warning
}
#if !(defined(OSATOMIC_USE_INLINED) && OSATOMIC_USE_INLINED)
// Test OSCompareAndSwap
_Bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue );
extern BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation);
#else
// Test that the body farm models are still used even when a body is available.
_Bool opaque_OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue );
_Bool OSAtomicCompareAndSwapPtr( void *__oldValue, void *__newValue, void * volatile *__theValue ) {
return opaque_OSAtomicCompareAndSwapPtr(__oldValue, __newValue, __theValue);
}
// Test that the analyzer doesn't crash when the farm model is used.
// The analyzer ignores the autosynthesized code.
_Bool OSAtomicCompareAndSwapEmptyFunction( void *__oldValue, void *__newValue, void * volatile *__theValue ) {
return 0;
}
extern BOOL opaque_objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation);
extern BOOL objc_atomicCompareAndSwapPtr(id predicate, id replacement, volatile id *objectLocation) {
return opaque_objc_atomicCompareAndSwapPtr(predicate, replacement, objectLocation);
}
#endif
void testOSCompareAndSwap() {
NSString *old = 0;
NSString *s = [[NSString alloc] init]; // no-warning
if (!OSAtomicCompareAndSwapPtr(0, s, (void**) &old))
[s release];
else
[old release];
}
void testOSCompareAndSwapXXBarrier_local() {
NSString *old = 0;
NSString *s = [[NSString alloc] init]; // no-warning
if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) &old))
[s release];
else
[old release];
}
void testOSCompareAndSwapXXBarrier_local_no_direct_release() {
NSString *old = 0;
NSString *s = [[NSString alloc] init]; // no-warning
if (!COMPARE_SWAP_BARRIER((intptr_t) 0, (intptr_t) s, (intptr_t*) &old))
return;
else
[old release];
}
int testOSCompareAndSwapXXBarrier_id(Class myclass, id xclass) {
if (COMPARE_SWAP_BARRIER(0, (intptr_t) myclass, (intptr_t*) &xclass))
return 1;
return 0;
}
void test_objc_atomicCompareAndSwap_local() {
NSString *old = 0;
NSString *s = [[NSString alloc] init]; // no-warning
if (!objc_atomicCompareAndSwapPtr(0, s, &old))
[s release];
else
[old release];
}
void test_objc_atomicCompareAndSwap_local_no_direct_release() {
NSString *old = 0;
NSString *s = [[NSString alloc] init]; // no-warning
if (!objc_atomicCompareAndSwapPtr(0, s, &old))
return;
else
[old release];
}
void test_objc_atomicCompareAndSwap_parameter(NSString **old) {
NSString *s = [[NSString alloc] init]; // no-warning
if (!objc_atomicCompareAndSwapPtr(0, s, old))
[s release];
else
[*old release];
}
void test_objc_atomicCompareAndSwap_parameter_no_direct_release(NSString **old) {
NSString *s = [[NSString alloc] init]; // expected-warning{{leak}}
if (!objc_atomicCompareAndSwapPtr(0, s, old))
return;
else
[*old release];
}
// Test stringWithFormat (<rdar://problem/6815234>)
void test_stringWithFormat() {
NSString *string = [[NSString stringWithFormat:@"%ld", (long) 100] retain];
[string release];
[string release]; // expected-warning{{Incorrect decrement of the reference count}}
}
// Test isTrackedObjectType().
typedef NSString* WonkyTypedef;
@interface TestIsTracked
+ (WonkyTypedef)newString;
@end
void test_isTrackedObjectType(void) {
NSString *str = [TestIsTracked newString]; // expected-warning{{Potential leak}}
}
// Test isTrackedCFObjectType().
@interface TestIsCFTracked
+ (CFStringRef) badNewCFString;
+ (CFStringRef) newCFString;
@end
@implementation TestIsCFTracked
+ (CFStringRef) newCFString {
return CFStringCreateWithFormat(kCFAllocatorDefault, ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "%d" "")), 100); // no-warning
}
+ (CFStringRef) badNewCFString {
return CFStringCreateWithFormat(kCFAllocatorDefault, ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "%d" "")), 100); // expected-warning{{leak}}
}
// Test @synchronized
void test_synchronized(id x) {
@synchronized(x) {
NSString *string = [[NSString stringWithFormat:@"%ld", (long) 100] retain]; // expected-warning {{leak}}
}
}
@end
void testOSCompareAndSwapXXBarrier_parameter(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
[*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;
}
@interface AlwaysInlineBodyFarmBodies : NSObject {
NSString *_value;
}
- (NSString *)_value;
- (void)callValue;
@end
@implementation AlwaysInlineBodyFarmBodies
- (NSString *)_value {
if (!_value) {
NSString *s = [[NSString alloc] init];
if (!OSAtomicCompareAndSwapPtr(0, s, (void**)&_value)) {
[s release];
}
}
return _value;
}
- (void)callValue {
[self _value];
}
@end
diff --git a/clang/test/Analysis/NSWindow.m b/clang/test/Analysis/NSWindow.m
index 44a97e4..e247ff1 100644
--- a/clang/test/Analysis/NSWindow.m
+++ b/clang/test/Analysis/NSWindow.m
@@ -1,86 +1,86 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core,deadcode.DeadStores -analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core,deadcode.DeadStores -analyzer-store=region -verify %s
// These declarations were reduced using Delta-Debugging from Foundation.h
// on Mac OS X. The test cases are below.
typedef struct objc_selector *SEL;
typedef signed char BOOL;
typedef unsigned int NSUInteger;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (id)retain;
@end
@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
@end
@interface NSObject <NSObject> {}
+ (id)alloc;
@end
typedef float CGFloat;
typedef struct _NSPoint {} NSRect;
NSRect NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h);
enum { NSBackingStoreRetained = 0, NSBackingStoreNonretained = 1, NSBackingStoreBuffered = 2 };
typedef NSUInteger NSBackingStoreType;
@interface NSResponder : NSObject <NSCoding> {}
@end
@protocol NSAnimatablePropertyContainer
- (id)animator;
@end
extern NSString *NSAnimationTriggerOrderIn ;
@class CIFilter, CALayer, NSDictionary, NSScreen, NSShadow, NSTrackingArea;
@interface NSView : NSResponder <NSAnimatablePropertyContainer> {} @end
@protocol NSValidatedUserInterfaceItem - (SEL)action; @end
@protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem; @end @class NSNotification, NSText, NSView, NSMutableSet, NSSet, NSDate;
enum { NSBorderlessWindowMask = 0, NSTitledWindowMask = 1 << 0, NSClosableWindowMask = 1 << 1, NSMiniaturizableWindowMask = 1 << 2, NSResizableWindowMask = 1 << 3 };
@interface NSWindow : NSResponder <NSAnimatablePropertyContainer, NSUserInterfaceValidations> {
struct __wFlags {} _wFlags;
}
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag;
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag screen:(NSScreen *)screen;
- (void)orderFrontRegardless;
@end
extern NSString *NSWindowDidBecomeKeyNotification;
// Test cases.
void f1() {
NSWindow *window = [[NSWindow alloc]
initWithContentRect:NSMakeRect(0,0,100,100)
styleMask:NSTitledWindowMask|NSClosableWindowMask
backing:NSBackingStoreBuffered
defer:0];
[window orderFrontRegardless]; // no-warning
}
void f2() {
NSWindow *window = [[NSWindow alloc]
initWithContentRect:NSMakeRect(0,0,100,100)
styleMask:NSTitledWindowMask|NSClosableWindowMask
backing:NSBackingStoreBuffered
defer:0
screen:0];
[window orderFrontRegardless]; // no-warning
}
void f2b() {
// FIXME: NSWindow doesn't own itself until it is displayed.
NSWindow *window = [[NSWindow alloc] // no-warning
initWithContentRect:NSMakeRect(0,0,100,100)
styleMask:NSTitledWindowMask|NSClosableWindowMask
backing:NSBackingStoreBuffered
defer:0
screen:0];
[window orderFrontRegardless];
[window retain];
}
void f3() {
// FIXME: For now we don't track NSWindow.
NSWindow *window = [NSWindow alloc]; // expected-warning{{never read}}
}
diff --git a/clang/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp b/clang/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
index 49358f6..987ed6a 100644
--- a/clang/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
+++ b/clang/test/Analysis/NewDelete+MismatchedDeallocator_intersections.cpp
@@ -1,29 +1,29 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,unix.MismatchedDeallocator -std=c++11 -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.MismatchedDeallocator -DLEAKS -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,unix.MismatchedDeallocator -std=c++11 -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.MismatchedDeallocator -DLEAKS -std=c++11 -verify %s
// expected-no-diagnostics
typedef __typeof(sizeof(int)) size_t;
void *malloc(size_t);
void free(void *);
//------------------------------------------------------------------
// Check that alpha.cplusplus.NewDelete + unix.MismatchedDeallocator
// does not enable warnings produced by the unix.Malloc checker.
//------------------------------------------------------------------
void testMallocFreeNoWarn() {
int i;
free(&i); // no warn
int *p1 = (int *)malloc(sizeof(int));
free(++p1); // no warn
int *p2 = (int *)malloc(sizeof(int));
free(p2);
free(p2); // no warn
int *p3 = (int *)malloc(sizeof(int)); // no warn
int *p4 = (int *)malloc(sizeof(int));
free(p4);
int j = *p4; // no warn
}
diff --git a/clang/test/Analysis/NewDelete-checker-test.cpp b/clang/test/Analysis/NewDelete-checker-test.cpp
index 78a0015..37005f0 100644
--- a/clang/test/Analysis/NewDelete-checker-test.cpp
+++ b/clang/test/Analysis/NewDelete-checker-test.cpp
@@ -1,395 +1,395 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -fblocks -verify %s
#include "Inputs/system-header-simulator-cxx.h"
typedef __typeof__(sizeof(int)) size_t;
extern "C" void *malloc(size_t);
extern "C" void free (void* ptr);
int *global;
//------------------
// check for leaks
//------------------
//----- Standard non-placement operators
void testGlobalOpNew() {
void *p = operator new(0);
}
#ifdef LEAKS
// expected-warning@-2{{Potential leak of memory pointed to by 'p'}}
#endif
void testGlobalOpNewArray() {
void *p = operator new[](0);
}
#ifdef LEAKS
// expected-warning@-2{{Potential leak of memory pointed to by 'p'}}
#endif
void testGlobalNewExpr() {
int *p = new int;
}
#ifdef LEAKS
// expected-warning@-2{{Potential leak of memory pointed to by 'p'}}
#endif
void testGlobalNewExprArray() {
int *p = new int[0];
}
#ifdef LEAKS
// expected-warning@-2{{Potential leak of memory pointed to by 'p'}}
#endif
//----- Standard nothrow placement operators
void testGlobalNoThrowPlacementOpNewBeforeOverload() {
void *p = operator new(0, std::nothrow);
}
#ifdef LEAKS
// expected-warning@-2{{Potential leak of memory pointed to by 'p'}}
#endif
void testGlobalNoThrowPlacementExprNewBeforeOverload() {
int *p = new(std::nothrow) int;
}
#ifdef LEAKS
// expected-warning@-2{{Potential leak of memory pointed to by 'p'}}
#endif
//----- Standard pointer placement operators
void testGlobalPointerPlacementNew() {
int i;
void *p1 = operator new(0, &i); // no warn
void *p2 = operator new[](0, &i); // no warn
int *p3 = new(&i) int; // no warn
int *p4 = new(&i) int[0]; // no warn
}
//----- Other cases
void testNewMemoryIsInHeap() {
int *p = new int;
if (global != p) // condition is always true as 'p' wraps a heap region that
// is different from a region wrapped by 'global'
global = p; // pointer escapes
}
struct PtrWrapper {
int *x;
PtrWrapper(int *input) : x(input) {}
};
void testNewInvalidationPlacement(PtrWrapper *w) {
// Ensure that we don't consider this a leak.
new (w) PtrWrapper(new int); // no warn
}
//-----------------------------------------
// check for usage of zero-allocated memory
//-----------------------------------------
void testUseZeroAlloc1() {
int *p = (int *)operator new(0);
*p = 1; // expected-warning {{Use of zero-allocated memory}}
delete p;
}
int testUseZeroAlloc2() {
int *p = (int *)operator new[](0);
return p[0]; // expected-warning {{Use of zero-allocated memory}}
delete[] p;
}
void f(int);
void testUseZeroAlloc3() {
int *p = new int[0];
f(*p); // expected-warning {{Use of zero-allocated memory}}
delete[] p;
}
//---------------
// other checks
//---------------
class SomeClass {
public:
void f(int *p);
};
void f(int *p1, int *p2 = 0, int *p3 = 0);
void g(SomeClass &c, ...);
void testUseFirstArgAfterDelete() {
int *p = new int;
delete p;
f(p); // expected-warning{{Use of memory after it is freed}}
}
void testUseMiddleArgAfterDelete(int *p) {
delete p;
f(0, p); // expected-warning{{Use of memory after it is freed}}
}
void testUseLastArgAfterDelete(int *p) {
delete p;
f(0, 0, p); // expected-warning{{Use of memory after it is freed}}
}
void testUseSeveralArgsAfterDelete(int *p) {
delete p;
f(p, p, p); // expected-warning{{Use of memory after it is freed}}
}
void testUseRefArgAfterDelete(SomeClass &c) {
delete &c;
g(c); // expected-warning{{Use of memory after it is freed}}
}
void testVariadicArgAfterDelete() {
SomeClass c;
int *p = new int;
delete p;
g(c, 0, p); // expected-warning{{Use of memory after it is freed}}
}
void testUseMethodArgAfterDelete(int *p) {
SomeClass *c = new SomeClass;
delete p;
c->f(p); // expected-warning{{Use of memory after it is freed}}
}
void testUseThisAfterDelete() {
SomeClass *c = new SomeClass;
delete c;
c->f(0); // expected-warning{{Use of memory after it is freed}}
}
void testDoubleDelete() {
int *p = new int;
delete p;
delete p; // expected-warning{{Attempt to free released memory}}
}
void testExprDeleteArg() {
int i;
delete &i; // expected-warning{{Argument to 'delete' is the address of the local variable 'i', which is not memory allocated by 'new'}}
}
void testExprDeleteArrArg() {
int i;
delete[] &i; // expected-warning{{Argument to 'delete[]' is the address of the local variable 'i', which is not memory allocated by 'new[]'}}
}
void testAllocDeallocNames() {
int *p = new(std::nothrow) int[1];
delete[] (++p); // expected-warning{{Argument to 'delete[]' is offset by 4 bytes from the start of memory allocated by 'new[]'}}
}
//--------------------------------
// Test escape of newed const pointer. Note, a const pointer can be deleted.
//--------------------------------
struct StWithConstPtr {
const int *memp;
};
void escape(const int &x);
void escapeStruct(const StWithConstPtr &x);
void escapePtr(const StWithConstPtr *x);
void escapeVoidPtr(const void *x);
void testConstEscape() {
int *p = new int(1);
escape(*p);
} // no-warning
void testConstEscapeStruct() {
StWithConstPtr *St = new StWithConstPtr();
escapeStruct(*St);
} // no-warning
void testConstEscapeStructPtr() {
StWithConstPtr *St = new StWithConstPtr();
escapePtr(St);
} // no-warning
void testConstEscapeMember() {
StWithConstPtr St;
St.memp = new int(2);
escapeVoidPtr(St.memp);
} // no-warning
void testConstEscapePlacementNew() {
int *x = (int *)malloc(sizeof(int));
void *y = new (x) int;
escapeVoidPtr(y);
} // no-warning
//============== Test Uninitialized delete delete[]========================
void testUninitDelete() {
int *x;
int * y = new int;
delete y;
delete x; // expected-warning{{Argument to 'delete' is uninitialized}}
}
void testUninitDeleteArray() {
int *x;
int * y = new int[5];
delete[] y;
delete[] x; // expected-warning{{Argument to 'delete[]' is uninitialized}}
}
void testUninitFree() {
int *x;
free(x); // expected-warning{{Function call argument is an uninitialized value}}
}
void testUninitDeleteSink() {
int *x;
delete x; // expected-warning{{Argument to 'delete' is uninitialized}}
(*(volatile int *)0 = 1); // no warn
}
void testUninitDeleteArraySink() {
int *x;
delete[] x; // expected-warning{{Argument to 'delete[]' is uninitialized}}
(*(volatile int *)0 = 1); // no warn
}
namespace reference_count {
class control_block {
unsigned count;
public:
control_block() : count(0) {}
void retain() { ++count; }
int release() { return --count; }
};
template <typename T>
class shared_ptr {
T *p;
control_block *control;
public:
shared_ptr() : p(0), control(0) {}
explicit shared_ptr(T *p) : p(p), control(new control_block) {
control->retain();
}
shared_ptr(shared_ptr &other) : p(other.p), control(other.control) {
if (control)
control->retain();
}
~shared_ptr() {
if (control && control->release() == 0) {
delete p;
delete control;
}
};
T &operator *() {
return *p;
};
void swap(shared_ptr &other) {
T *tmp = p;
p = other.p;
other.p = tmp;
control_block *ctrlTmp = control;
control = other.control;
other.control = ctrlTmp;
}
};
void testSingle() {
shared_ptr<int> a(new int);
*a = 1;
}
void testDouble() {
shared_ptr<int> a(new int);
shared_ptr<int> b = a;
*a = 1;
}
void testInvalidated() {
shared_ptr<int> a(new int);
shared_ptr<int> b = a;
*a = 1;
extern void use(shared_ptr<int> &);
use(b);
}
void testNestedScope() {
shared_ptr<int> a(new int);
{
shared_ptr<int> b = a;
}
*a = 1;
}
void testSwap() {
shared_ptr<int> a(new int);
shared_ptr<int> b;
shared_ptr<int> c = a;
shared_ptr<int>(c).swap(b);
}
void testUseAfterFree() {
int *p = new int;
{
shared_ptr<int> a(p);
shared_ptr<int> b = a;
}
// FIXME: We should get a warning here, but we don't because we've
// conservatively modeled ~shared_ptr.
*p = 1;
}
}
// Test double delete
class DerefClass{
public:
int *x;
DerefClass() {}
~DerefClass() {*x = 1;}
};
void testDoubleDeleteClassInstance() {
DerefClass *foo = new DerefClass();
delete foo;
delete foo; // expected-warning {{Attempt to delete released memory}}
}
class EmptyClass{
public:
EmptyClass() {}
~EmptyClass() {}
};
void testDoubleDeleteEmptyClass() {
EmptyClass *foo = new EmptyClass();
delete foo;
delete foo; // expected-warning {{Attempt to delete released memory}}
}
struct Base {
virtual ~Base() {}
};
struct Derived : Base {
};
Base *allocate() {
return new Derived;
}
void shouldNotReportLeak() {
Derived *p = (Derived *)allocate();
delete p;
}
diff --git a/clang/test/Analysis/NewDelete-custom.cpp b/clang/test/Analysis/NewDelete-custom.cpp
index d368889..f06ff4a 100644
--- a/clang/test/Analysis/NewDelete-custom.cpp
+++ b/clang/test/Analysis/NewDelete-custom.cpp
@@ -1,80 +1,80 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -fblocks -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,unix.Malloc -std=c++11 -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -DLEAKS -fblocks -verify %s
#include "Inputs/system-header-simulator-cxx.h"
#ifndef LEAKS
// expected-no-diagnostics
#endif
void *allocator(std::size_t size);
void *operator new[](std::size_t size) throw() { return allocator(size); }
void *operator new(std::size_t size) throw() { return allocator(size); }
void *operator new(std::size_t size, std::nothrow_t& nothrow) throw() { return allocator(size); }
void *operator new(std::size_t, double d);
class C {
public:
void *operator new(std::size_t);
};
void testNewMethod() {
void *p1 = C::operator new(0); // no warn
C *p2 = new C; // no warn
C *c3 = ::new C;
}
#ifdef LEAKS
// expected-warning@-2{{Potential leak of memory pointed to by 'c3'}}
#endif
void testOpNewArray() {
void *p = operator new[](0); // call is inlined, no warn
}
void testNewExprArray() {
int *p = new int[0];
}
#ifdef LEAKS
// expected-warning@-2{{Potential leak of memory pointed to by 'p'}}
#endif
//----- Custom non-placement operators
void testOpNew() {
void *p = operator new(0); // call is inlined, no warn
}
void testNewExpr() {
int *p = new int;
}
#ifdef LEAKS
// expected-warning@-2{{Potential leak of memory pointed to by 'p'}}
#endif
//----- Custom NoThrow placement operators
void testOpNewNoThrow() {
void *p = operator new(0, std::nothrow);
}
#ifdef LEAKS
// expected-warning@-2{{Potential leak of memory pointed to by 'p'}}
#endif
void testNewExprNoThrow() {
int *p = new(std::nothrow) int;
}
#ifdef LEAKS
// expected-warning@-2{{Potential leak of memory pointed to by 'p'}}
#endif
//----- Custom placement operators
void testOpNewPlacement() {
void *p = operator new(0, 0.1); // no warn
}
void testNewExprPlacement() {
int *p = new(0.1) int; // no warn
}
diff --git a/clang/test/Analysis/NewDelete-intersections.mm b/clang/test/Analysis/NewDelete-intersections.mm
index cde8122..aa52c79 100644
--- a/clang/test/Analysis/NewDelete-intersections.mm
+++ b/clang/test/Analysis/NewDelete-intersections.mm
@@ -1,86 +1,86 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -std=c++11 -DLEAKS -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks -std=c++11 -DLEAKS -fblocks -verify %s
#include "Inputs/system-header-simulator-cxx.h"
#include "Inputs/system-header-simulator-objc.h"
typedef __typeof__(sizeof(int)) size_t;
extern "C" void *malloc(size_t);
extern "C" void *alloca(size_t);
extern "C" void free(void *);
//----------------------------------------------------------------------------
// Check for intersections with unix.Malloc and unix.MallocWithAnnotations
// checkers bounded with cplusplus.NewDelete.
//----------------------------------------------------------------------------
//----- malloc()/free() are subjects of unix.Malloc and unix.MallocWithAnnotations
void testMallocFreeNoWarn() {
int i;
free(&i); // no warn
int *p1 = (int *)malloc(sizeof(int));
free(++p1); // no warn
int *p2 = (int *)malloc(sizeof(int));
free(p2);
free(p2); // no warn
int *p3 = (int *)malloc(sizeof(int)); // no warn
int *p4 = (int *)malloc(sizeof(int));
free(p4);
int j = *p4; // no warn
int *p5 = (int *)alloca(sizeof(int));
free(p5); // no warn
}
void testDeleteMalloced() {
int *p1 = (int *)malloc(sizeof(int));
delete p1; // no warn
int *p2 = (int *)__builtin_alloca(sizeof(int));
delete p2; // no warn
}
void testUseZeroAllocatedMalloced() {
int *p1 = (int *)malloc(0);
*p1 = 1; // no warn
}
//----- Test free standard new
void testFreeOpNew() {
void *p = operator new(0);
free(p);
}
#ifdef LEAKS
// expected-warning@-2 {{Potential leak of memory pointed to by 'p'}}
#endif
void testFreeNewExpr() {
int *p = new int;
free(p);
}
#ifdef LEAKS
// expected-warning@-2 {{Potential leak of memory pointed to by 'p'}}
#endif
void testObjcFreeNewed() {
int *p = new int;
NSData *nsdata = [NSData dataWithBytesNoCopy:p length:sizeof(int) freeWhenDone:1];
#ifdef LEAKS
// expected-warning@-2 {{Potential leak of memory pointed to by 'p'}}
#endif
}
void testFreeAfterDelete() {
int *p = new int;
delete p;
free(p); // expected-warning{{Use of memory after it is freed}}
}
void testStandardPlacementNewAfterDelete() {
int *p = new int;
delete p;
p = new(p) int; // expected-warning{{Use of memory after it is freed}}
}
diff --git a/clang/test/Analysis/NewDelete-path-notes.cpp b/clang/test/Analysis/NewDelete-path-notes.cpp
index 64b15b8..115a4ad 100644
--- a/clang/test/Analysis/NewDelete-path-notes.cpp
+++ b/clang/test/Analysis/NewDelete-path-notes.cpp
@@ -1,493 +1,493 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.NewDelete,unix.Malloc -analyzer-output=text -verify %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=cplusplus.NewDelete,unix.Malloc -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete,unix.Malloc -analyzer-output=text -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.NewDelete,unix.Malloc -analyzer-output=plist -analyzer-config path-diagnostics-alternate=false %s -o %t.plist
// RUN: FileCheck --input-file=%t.plist %s
void test() {
int *p = new int;
// expected-note@-1 {{Memory is allocated}}
if (p)
// expected-note@-1 {{Taking true branch}}
delete p;
// expected-note@-1 {{Memory is released}}
delete p; // expected-warning {{Attempt to free released memory}}
// expected-note@-1 {{Attempt to free released memory}}
}
struct Odd {
void kill() {
delete this; // expected-note {{Memory is released}}
}
};
void test(Odd *odd) {
odd->kill(); // expected-note{{Calling 'Odd::kill'}}
// expected-note@-1 {{Returning; memory was released}}
delete odd; // expected-warning {{Attempt to free released memory}}
// expected-note@-1 {{Attempt to free released memory}}
}
// CHECK: <key>diagnostics</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>path</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>control</string>
// CHECK-NEXT: <key>edges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>start</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>5</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>end</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>14</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>ranges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>18</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>0</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Memory is allocated</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Memory is allocated</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>control</string>
// CHECK-NEXT: <key>edges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>start</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>6</integer>
// CHECK-NEXT: <key>col</key><integer>14</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>end</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>8</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>8</integer>
// CHECK-NEXT: <key>col</key><integer>4</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>control</string>
// CHECK-NEXT: <key>edges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>start</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>8</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>8</integer>
// CHECK-NEXT: <key>col</key><integer>4</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>end</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>5</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>10</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>5</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>ranges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>5</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>0</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Memory is released</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Memory is released</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>control</string>
// CHECK-NEXT: <key>edges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>start</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>5</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>10</integer>
// CHECK-NEXT: <key>col</key><integer>10</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>end</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>8</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>ranges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>10</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>0</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Attempt to free released memory</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Attempt to free released memory</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>description</key><string>Attempt to free released memory</string>
// CHECK-NEXT: <key>category</key><string>Memory Error</string>
// CHECK-NEXT: <key>type</key><string>Double free</string>
// CHECK-NEXT: <key>check_name</key><string>cplusplus.NewDelete</string>
// CHECK-NEXT: <!-- This hash is experimental and going to change! -->
// CHECK-NEXT: <key>issue_hash_content_of_line_in_context</key><string>bd8e324d09c70b9e2be6f824a4942e5a</string>
// CHECK-NEXT: <key>issue_context_kind</key><string>function</string>
// CHECK-NEXT: <key>issue_context</key><string>test</string>
// CHECK-NEXT: <key>issue_hash_function_offset</key><string>8</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>13</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>path</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>24</integer>
// CHECK-NEXT: <key>col</key><integer>2</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>ranges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>24</integer>
// CHECK-NEXT: <key>col</key><integer>2</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>24</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>0</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Calling &apos;Odd::kill&apos;</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Calling &apos;Odd::kill&apos;</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>18</integer>
// CHECK-NEXT: <key>col</key><integer>2</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>depth</key><integer>1</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Entered call from &apos;test&apos;</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Entered call from &apos;test&apos;</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>control</string>
// CHECK-NEXT: <key>edges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>start</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>18</integer>
// CHECK-NEXT: <key>col</key><integer>2</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>18</integer>
// CHECK-NEXT: <key>col</key><integer>5</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>end</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>19</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>19</integer>
// CHECK-NEXT: <key>col</key><integer>8</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>19</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>ranges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>19</integer>
// CHECK-NEXT: <key>col</key><integer>3</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>19</integer>
// CHECK-NEXT: <key>col</key><integer>13</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>1</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Memory is released</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Memory is released</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>24</integer>
// CHECK-NEXT: <key>col</key><integer>2</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>ranges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>24</integer>
// CHECK-NEXT: <key>col</key><integer>2</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>24</integer>
// CHECK-NEXT: <key>col</key><integer>12</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>0</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Returning; memory was released</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Returning; memory was released</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>control</string>
// CHECK-NEXT: <key>edges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>start</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>24</integer>
// CHECK-NEXT: <key>col</key><integer>2</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>24</integer>
// CHECK-NEXT: <key>col</key><integer>4</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>end</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>26</integer>
// CHECK-NEXT: <key>col</key><integer>2</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>26</integer>
// CHECK-NEXT: <key>col</key><integer>7</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>kind</key><string>event</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>26</integer>
// CHECK-NEXT: <key>col</key><integer>2</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <key>ranges</key>
// CHECK-NEXT: <array>
// CHECK-NEXT: <array>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>26</integer>
// CHECK-NEXT: <key>col</key><integer>2</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>26</integer>
// CHECK-NEXT: <key>col</key><integer>11</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>depth</key><integer>0</integer>
// CHECK-NEXT: <key>extended_message</key>
// CHECK-NEXT: <string>Attempt to free released memory</string>
// CHECK-NEXT: <key>message</key>
// CHECK-NEXT: <string>Attempt to free released memory</string>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
// CHECK-NEXT: <key>description</key><string>Attempt to free released memory</string>
// CHECK-NEXT: <key>category</key><string>Memory Error</string>
// CHECK-NEXT: <key>type</key><string>Double free</string>
// CHECK-NEXT: <key>check_name</key><string>cplusplus.NewDelete</string>
// CHECK-NEXT: <!-- This hash is experimental and going to change! -->
// CHECK-NEXT: <key>issue_hash_content_of_line_in_context</key><string>8bf1a5b9fdae9d86780aa6c4cdce2605</string>
// CHECK-NEXT: <key>issue_context_kind</key><string>function</string>
// CHECK-NEXT: <key>issue_context</key><string>test</string>
// CHECK-NEXT: <key>issue_hash_function_offset</key><string>3</string>
// CHECK-NEXT: <key>location</key>
// CHECK-NEXT: <dict>
// CHECK-NEXT: <key>line</key><integer>26</integer>
// CHECK-NEXT: <key>col</key><integer>2</integer>
// CHECK-NEXT: <key>file</key><integer>0</integer>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </dict>
// CHECK-NEXT: </array>
diff --git a/clang/test/Analysis/NewDelete-variadic.cpp b/clang/test/Analysis/NewDelete-variadic.cpp
index f9ef079b..523785a 100644
--- a/clang/test/Analysis/NewDelete-variadic.cpp
+++ b/clang/test/Analysis/NewDelete-variadic.cpp
@@ -1,23 +1,23 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete,cplusplus.NewDeleteLeaks,unix.Malloc -std=c++11 -fblocks -verify %s
// expected-no-diagnostics
namespace std {
typedef __typeof__(sizeof(int)) size_t;
}
struct X {};
void *operator new(std::size_t, X, ...);
void *operator new[](std::size_t, X, ...);
void testGlobalCustomVariadicNew() {
X x;
void *p1 = operator new(0, x); // no warn
void *p2 = operator new[](0, x); // no warn
int *p3 = new (x) int; // no warn
int *p4 = new (x) int[0]; // no warn
}
diff --git a/clang/test/Analysis/NewDeleteLeaks-PR18394.cpp b/clang/test/Analysis/NewDeleteLeaks-PR18394.cpp
index d0d7037..5a5b82c 100644
--- a/clang/test/Analysis/NewDeleteLeaks-PR18394.cpp
+++ b/clang/test/Analysis/NewDeleteLeaks-PR18394.cpp
@@ -1,16 +1,16 @@
-// RUN: %clang_cc1 -analyzer-config graph-trim-interval=1 -analyzer-max-loop 1 -analyze -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-config graph-trim-interval=1 -analyzer-max-loop 1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s
// expected-no-diagnostics
class A {
public:
void f() {};
~A() {
for (int i=0; i<3; i++)
f();
}
};
void error() {
A *a = new A();
delete a;
}
diff --git a/clang/test/Analysis/NewDeleteLeaks-PR19102.cpp b/clang/test/Analysis/NewDeleteLeaks-PR19102.cpp
index b141301..502db61 100644
--- a/clang/test/Analysis/NewDeleteLeaks-PR19102.cpp
+++ b/clang/test/Analysis/NewDeleteLeaks-PR19102.cpp
@@ -1,43 +1,43 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -verify %s
class A0 {};
class A1 {
public:
A1(int);
};
struct S{
int i;
};
class A2 {
public:
A2();
A2(S);
A2(int*);
A2(S*);
A2(S&, int);
A2(int, S**);
};
void test() {
new int; // expected-warning@+1 {{Potential memory leak}}
new A0; // expected-warning@+1 {{Potential memory leak}}
new A1(0); // expected-warning@+1 {{Potential memory leak}}
new A2; // expected-warning@+1 {{Potential memory leak}}
S s;
s.i = 1;
S* ps = new S;
new A2(s); // expected-warning@+1 {{Potential memory leak}}
new A2(&(s.i)); // expected-warning@+1 {{Potential memory leak}}
new A2(ps); // no warning
new A2(*ps, 1); // no warning
new A2(1, &ps); // no warning
// Tests to ensure that leaks are reported for consumed news no matter what the arguments are.
A2 *a2p1 = new A2; // expected-warning@+1 {{Potential leak of memory}}
A2 *a2p2 = new A2(ps); // expected-warning@+1 {{Potential leak of memory}}
A2 *a2p3 = new A2(*ps, 1); // expected-warning@+1 {{Potential leak of memory}}
A2 *a2p4 = new A2(1, &ps); // expected-warning@+1 {{Potential leak of memory}}
}
diff --git a/clang/test/Analysis/NoReturn.m b/clang/test/Analysis/NoReturn.m
index 5ed92df..c08fd0d 100644
--- a/clang/test/Analysis/NoReturn.m
+++ b/clang/test/Analysis/NoReturn.m
@@ -1,145 +1,145 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
#include <stdarg.h>
//===----------------------------------------------------------------------===//
// 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 <NSObject> {} @end
extern id NSAllocateObject(Class aClass, NSUInteger extraBytes, NSZone *zone);
@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
- (NSUInteger)length;
+ (id)stringWithFormat:(NSString *)format, ...;
@end
@interface NSSimpleCString : NSString {} @end
@interface NSConstantString : NSSimpleCString @end
extern void *_NSConstantStringClassReference;
typedef double NSTimeInterval;
@interface NSDate : NSObject <NSCopying, NSCoding> - (NSTimeInterval)timeIntervalSinceReferenceDate; @end
@class NSString, NSDictionary, NSArray;
@interface NSException : NSObject <NSCopying, NSCoding> {}
+ (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
}
@interface CustomException : NSException
@end
int testCustomException(int *x) {
if (x != 0) return 0;
[CustomException raise:@"Blah" format:@"abc"];
return *x; // no-warning
}
// Test that __attribute__((analyzer_noreturn)) has the intended
// effect on Objective-C methods.
@interface Radar11634353
+ (void) doesNotReturn __attribute__((analyzer_noreturn));
- (void) alsoDoesNotReturn __attribute__((analyzer_noreturn));
@end
void test_rdar11634353() {
[Radar11634353 doesNotReturn];
int *p = 0;
*p = 0xDEADBEEF; // no-warning
}
void test_rdar11634352_instance(Radar11634353 *o) {
[o alsoDoesNotReturn];
int *p = 0;
*p = 0xDEADBEEF; // no-warning
}
void test_rdar11634353_positive() {
int *p = 0;
*p = 0xDEADBEEF; // expected-warning {{null pointer}}
}
// Test analyzer_noreturn on category methods.
@interface NSException (OBExtensions)
+ (void)raise:(NSString *)name reason:(NSString *)reason __attribute__((analyzer_noreturn));
@end
void PR11959(int *p) {
if (!p)
[NSException raise:@"Bad Pointer" reason:@"Who knows?"];
*p = 0xDEADBEEF; // no-warning
}
// Test that hard-coded Microsoft _wassert name is recognized as a noreturn
#define assert(_Expression) (void)( (!!(_Expression)) || (_wassert(#_Expression, __FILE__, __LINE__), 0) )
extern void _wassert(const char * _Message, const char *_File, unsigned _Line);
void test_wassert() {
assert(0);
int *p = 0;
*p = 0xDEADBEEF; // no-warning
}
#undef assert
// Test that hard-coded Android __assert2 name is recognized as a noreturn
#define assert(_Expression) ((_Expression) ? (void)0 : __assert2(0, 0, 0, 0));
extern void __assert2(const char *, int, const char *, const char *);
extern void _wassert(const char * _Message, const char *_File, unsigned _Line);
void test___assert2() {
assert(0);
int *p = 0;
*p = 0xDEADBEEF; // no-warning
}
#undef assert
diff --git a/clang/test/Analysis/OSAtomic_mac.cpp b/clang/test/Analysis/OSAtomic_mac.cpp
index f938958..e45f236 100644
--- a/clang/test/Analysis/OSAtomic_mac.cpp
+++ b/clang/test/Analysis/OSAtomic_mac.cpp
@@ -1,20 +1,20 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -analyze -analyzer-checker=core,osx -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin9 -analyzer-checker=core,osx -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks %s
// expected-no-diagnostics
// Test handling of OSAtomicCompareAndSwap when C++ inserts "no-op" casts and we
// do a forced load and binding to the environment on an expression that would regularly
// not have an environment binding. This previously triggered a crash (<rdar://problem/9339920>).
// NOTE: It is critical that the function called is OSAtomicCompareAndSwapIntBarrier.
bool OSAtomicCompareAndSwapIntBarrier( int __oldValue, int __newValue, volatile int *__theValue ) ;
static int _rdar9339920_x = 0;
int rdar9339920_aux();
int rdar9339920_test() {
int rdar9339920_x = rdar9339920_aux();
if (rdar9339920_x != _rdar9339920_x) {
if (OSAtomicCompareAndSwapIntBarrier(_rdar9339920_x, rdar9339920_x, &_rdar9339920_x))
return 1;
}
return 0;
}
diff --git a/clang/test/Analysis/ObjCProperties.m b/clang/test/Analysis/ObjCProperties.m
index 201e3e1..1a112ec 100644
--- a/clang/test/Analysis/ObjCProperties.m
+++ b/clang/test/Analysis/ObjCProperties.m
@@ -1,21 +1,21 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-objc-root-class %s -verify
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -Wno-objc-root-class %s -verify
// expected-no-diagnostics
// The point of this test cases is to exercise properties in the static
// analyzer
@interface MyClass {
@private
id _X;
}
- (id)initWithY:(id)Y;
@property(copy, readwrite) id X;
@end
@implementation MyClass
@synthesize X = _X;
- (id)initWithY:(id)Y {
self.X = Y;
return self;
}
@end
diff --git a/clang/test/Analysis/ObjCPropertiesSyntaxChecks.m b/clang/test/Analysis/ObjCPropertiesSyntaxChecks.m
index 5c642c5..5485467 100644
--- a/clang/test/Analysis/ObjCPropertiesSyntaxChecks.m
+++ b/clang/test/Analysis/ObjCPropertiesSyntaxChecks.m
@@ -1,61 +1,61 @@
-// RUN: %clang_cc1 -w -fblocks -analyze -analyzer-checker=osx.ObjCProperty %s -verify
+// RUN: %clang_analyze_cc1 -w -fblocks -analyzer-checker=osx.ObjCProperty %s -verify
#include "Inputs/system-header-simulator-objc.h"
@interface I : NSObject {
NSMutableString *_mutableExplicitStr;
NSMutableString *_trulyMutableStr;
NSMutableString *_trulyMutableExplicitStr;
}
@property(copy) NSString *str; // no-warning
@property(copy) NSMutableString *mutableStr; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
@property(copy) NSMutableString *mutableExplicitStr; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
@property(copy, readonly) NSMutableString *mutableReadonlyStr; // no-warning
@property(copy, readonly) NSMutableString *mutableReadonlyStrOverriddenInChild; // no-warning
@property(copy, readonly) NSMutableString *mutableReadonlyStrOverriddenInCategory; // no-warning
@property(copy) NSMutableString *trulyMutableStr; // no-warning
@property(copy) NSMutableString *trulyMutableExplicitStr; // no-warning
@property(copy) NSMutableString *trulyMutableStrWithSynthesizedStorage; // no-warning
@end
@interface I () {}
@property(copy) NSMutableString *mutableStrInCategory; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
@property (copy, readwrite) NSMutableString *mutableReadonlyStrOverriddenInCategory; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
@end
@implementation I
@synthesize mutableExplicitStr = _mutableExplicitStr;
- (NSMutableString *)trulyMutableStr {
return _trulyMutableStr;
}
- (void)setTrulyMutableStr: (NSMutableString *) S {
_trulyMutableStr = [S mutableCopy];
}
@dynamic trulyMutableExplicitStr;
- (NSMutableString *)trulyMutableExplicitStr {
return _trulyMutableExplicitStr;
}
- (void)setTrulyMutableExplicitStr: (NSMutableString *) S {
_trulyMutableExplicitStr = [S mutableCopy];
}
@synthesize trulyMutableStrWithSynthesizedStorage;
- (NSMutableString *)trulyMutableStrWithSynthesizedStorage {
return trulyMutableStrWithSynthesizedStorage;
}
- (void)setTrulyMutableStrWithSynthesizedStorage: (NSMutableString *) S {
trulyMutableStrWithSynthesizedStorage = [S mutableCopy];
}
@end
@interface J : I {}
@property (copy, readwrite) NSMutableString *mutableReadonlyStrOverriddenInChild; // expected-warning{{Property of mutable type 'NSMutableString' has 'copy' attribute; an immutable object will be stored instead}}
@end
@implementation J
@end
// If we do not see the implementation then we do not want to warn,
// because we may miss a user-defined setter that works correctly.
@interface IWithoutImpl : NSObject {}
@property(copy) NSMutableString *mutableStr; // no-warning
@end
diff --git a/clang/test/Analysis/ObjCRetSigs.m b/clang/test/Analysis/ObjCRetSigs.m
index 6ee83ec..97d33f9 100644
--- a/clang/test/Analysis/ObjCRetSigs.m
+++ b/clang/test/Analysis/ObjCRetSigs.m
@@ -1,25 +1,25 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -verify -Wno-objc-root-class %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-checker=osx.cocoa.IncompatibleMethodTypes -verify -Wno-objc-root-class %s
int printf(const char *, ...);
@interface MyBase
-(long long)length;
@end
@interface MySub : MyBase{}
-(double)length;
@end
@implementation MyBase
-(long long)length{
printf("Called MyBase -length;\n");
return 3;
}
@end
@implementation MySub
-(double)length{ // expected-warning{{types are incompatible}}
printf("Called MySub -length;\n");
return 3.3;
}
@end
diff --git a/clang/test/Analysis/PR12905.c b/clang/test/Analysis/PR12905.c
index 8f678d1..f36b93a 100644
--- a/clang/test/Analysis/PR12905.c
+++ b/clang/test/Analysis/PR12905.c
@@ -1,8 +1,8 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core %s
// PR12905
void C(void);
void t(void) {
C();
}
diff --git a/clang/test/Analysis/PR24184.cpp b/clang/test/Analysis/PR24184.cpp
index 54eae56..1280334 100644
--- a/clang/test/Analysis/PR24184.cpp
+++ b/clang/test/Analysis/PR24184.cpp
@@ -1,97 +1,97 @@
-// RUN: %clang_cc1 -w -analyze -analyzer-eagerly-assume -fcxx-exceptions -analyzer-checker=core -analyzer-checker=alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 64 -verify %s
-// RUN: %clang_cc1 -w -analyze -analyzer-checker=core -analyzer-checker=cplusplus -fcxx-exceptions -analyzer-checker alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 63 -verify %s
+// RUN: %clang_analyze_cc1 -w -analyzer-eagerly-assume -fcxx-exceptions -analyzer-checker=core -analyzer-checker=alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 64 -verify %s
+// RUN: %clang_analyze_cc1 -w -analyzer-checker=core -analyzer-checker=cplusplus -fcxx-exceptions -analyzer-checker alpha.core.PointerArithm,alpha.core.CastToStruct -analyzer-max-loop 63 -verify %s
// These tests used to hit an assertion in the bug report. Test case from http://llvm.org/PR24184.
typedef struct {
int cbData;
unsigned pbData;
} CRYPT_DATA_BLOB;
typedef enum { DT_NONCE_FIXED } DATA_TYPE;
int a;
typedef int *vcreate_t(int *, DATA_TYPE, int, int);
void fn1(unsigned, unsigned) {
char b = 0;
for (; 1; a++, &b + a * 0)
;
}
vcreate_t fn2;
struct A {
CRYPT_DATA_BLOB value;
int m_fn1() {
int c;
value.pbData == 0;
fn1(0, 0);
}
};
struct B {
A IkeHashAlg;
A IkeGType;
A NoncePhase1_r;
};
class C {
int m_fn2(B *);
void m_fn3(B *, int, int, int);
};
int C::m_fn2(B *p1) {
int *d;
int e = p1->IkeHashAlg.m_fn1();
unsigned f = p1->IkeGType.m_fn1(), h;
int g;
d = fn2(0, DT_NONCE_FIXED, (char)0, p1->NoncePhase1_r.value.cbData);
h = 0 | 0;
m_fn3(p1, 0, 0, 0);
}
// case 2:
typedef struct {
int cbData;
unsigned char *pbData;
} CRYPT_DATA_BLOB_1;
typedef unsigned uint32_t;
void fn1_1(void *p1, const void *p2) { p1 != p2; }
void fn2_1(uint32_t *p1, unsigned char *p2, uint32_t p3) {
unsigned i = 0;
for (0; i < p3; i++)
fn1_1(p1 + i, p2 + i * 0);
}
struct A_1 {
CRYPT_DATA_BLOB_1 value;
uint32_t m_fn1() {
uint32_t a;
if (value.pbData)
fn2_1(&a, value.pbData, value.cbData);
return 0;
}
};
struct {
A_1 HashAlgId;
} *b;
void fn3() {
uint32_t c, d;
d = b->HashAlgId.m_fn1();
d << 0 | 0 | 0;
c = 0;
0 | 1 << 0 | 0 && b;
}
// case 3:
struct ST {
char c;
};
char *p;
int foo1(ST);
int foo2() {
ST *p1 = (ST *)(p); // expected-warning{{Casting a non-structure type to a structure type and accessing a field can lead to memory access errors or data corruption}}
while (p1->c & 0x0F || p1->c & 0x07)
p1 = p1 + foo1(*p1);
}
int foo3(int *node) {
int i = foo2();
if (i)
return foo2();
}
diff --git a/clang/test/Analysis/PR2599.m b/clang/test/Analysis/PR2599.m
index ac552ee..1c2270e 100644
--- a/clang/test/Analysis/PR2599.m
+++ b/clang/test/Analysis/PR2599.m
@@ -1,63 +1,63 @@
-// RUN: %clang_cc1 -triple %itanium_abi_triple -analyze -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -fobjc-gc -verify %s
+// RUN: %clang_analyze_cc1 -triple %itanium_abi_triple -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core -analyzer-store=region -fobjc-gc -verify %s
typedef const void * CFTypeRef;
typedef const struct __CFString * CFStringRef;
typedef const struct __CFAllocator * CFAllocatorRef;
typedef const struct __CFDictionary * CFDictionaryRef;
CFTypeRef CFMakeCollectable(CFTypeRef cf) ;
extern CFStringRef CFStringCreateWithFormat(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...);
typedef signed char BOOL;
typedef unsigned int NSUInteger;
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (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
enum { NSASCIIStringEncoding = 1, NSNEXTSTEPStringEncoding = 2, NSJapaneseEUCStringEncoding = 3, NSUTF8StringEncoding = 4, NSISOLatin1StringEncoding = 5, NSSymbolStringEncoding = 6, NSNonLossyASCIIStringEncoding = 7, NSShiftJISStringEncoding = 8, NSISOLatin2StringEncoding = 9, NSUnicodeStringEncoding = 10, NSWindowsCP1251StringEncoding = 11, NSWindowsCP1252StringEncoding = 12, NSWindowsCP1253StringEncoding = 13, NSWindowsCP1254StringEncoding = 14, NSWindowsCP1250StringEncoding = 15, NSISO2022JPStringEncoding = 21, NSMacOSRomanStringEncoding = 30, NSUTF16StringEncoding = NSUnicodeStringEncoding, NSUTF16BigEndianStringEncoding = 0x90000100, NSUTF16LittleEndianStringEncoding = 0x94000100, NSUTF32StringEncoding = 0x8c000100, NSUTF32BigEndianStringEncoding = 0x98000100, NSUTF32LittleEndianStringEncoding = 0x9c000100 };
typedef NSUInteger NSStringEncoding;
@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
- (NSUInteger)length;
- (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL)freeBuffer;
@end
@interface NSAutoreleasePool : NSObject {}
- (void)drain;
@end
extern NSString * const NSXMLParserErrorDomain ;
// The actual test case. UTIL_AUTORELEASE_CF_AS_ID is a macro that doesn't
// actually do what it was intended to.
#define NSSTRINGWRAPPER(bytes,len) \
[[[NSString alloc] initWithBytesNoCopy: (void*)(bytes) length: (len) encoding: NSUTF8StringEncoding freeWhenDone: (BOOL)0] autorelease]
#define UTIL_AUTORELEASE_CF_AS_ID(cf) ( (((void*)0) == (cf)) ? ((void*)0) : [(id) CFMakeCollectable( (CFTypeRef) cf) autorelease] )
#define UTIL_AUTORELEASE_CF_AS_ID_WITHOUT_TEST(cf) ( [(id) CFMakeCollectable( (CFTypeRef) cf) autorelease] )
static char *lorem = "fooBarBaz";
void NSLog(NSString *, ...);
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString *tmp1 = NSSTRINGWRAPPER(lorem, 6); // no-warning
NSString *tmp2 = UTIL_AUTORELEASE_CF_AS_ID( CFStringCreateWithFormat(((void*)0), ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "lorem: %@" "")), tmp1) ); // expected-warning 2 {{leak}}
NSString *tmp3 = UTIL_AUTORELEASE_CF_AS_ID_WITHOUT_TEST( CFStringCreateWithFormat(((void*)0), ((void*)0), ((CFStringRef) __builtin___CFStringMakeConstantString ("" "lorem: %@" "")), tmp1) );
NSLog(@"tmp2: %@ tmp3: %@", tmp2, tmp3);
[pool drain];
return 0;
}
diff --git a/clang/test/Analysis/PR2978.m b/clang/test/Analysis/PR2978.m
index b609da5..8b7effc 100644
--- a/clang/test/Analysis/PR2978.m
+++ b/clang/test/Analysis/PR2978.m
@@ -1,116 +1,116 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,osx.cocoa.Dealloc %s -verify
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,osx.cocoa.Dealloc %s -verify
// Tests for the checker which checks missing/extra ivar 'release' calls
// in dealloc.
@interface NSObject
- (void)release;
- (void)dealloc;
@end
@interface MyClass : NSObject {
@private
id _X;
id _Y;
id _Z;
id _K;
id _L;
id _N;
id _M;
id _P;
id _Q;
id _R;
id _S;
id _V;
id _W;
MyClass *_other;
id _nonPropertyIvar;
}
@property(retain) id X;
@property(retain) id Y;
@property(assign) id Z;
@property(assign) id K;
@property(weak) id L;
@property(readonly) id N;
@property(retain) id M;
@property(weak) id P;
@property(weak) id Q;
@property(retain) id R;
@property(weak, readonly) id S;
@property(assign, readonly) id T; // Shadowed in class extension
@property(assign) id U;
@property(retain) id V;
@property(retain) id W;
-(id) O;
-(void) setO: (id) arg;
@end
@interface MyClass ()
// Shadows T to make it readwrite internally but readonly externally.
@property(assign, readwrite) id T;
@end
@implementation MyClass
@synthesize X = _X;
@synthesize Y = _Y;
@synthesize Z = _Z;
@synthesize K = _K;
@synthesize L = _L;
@synthesize N = _N;
@synthesize M = _M;
@synthesize Q = _Q;
@synthesize R = _R;
@synthesize V = _V;
@synthesize W = _W;
-(id) O{ return 0; }
-(void) setO:(id)arg { }
-(void) releaseInHelper {
[_R release]; // no-warning
_R = @"Hi";
}
- (void)dealloc
{
[_X release];
[_Z release]; // expected-warning{{The '_Z' ivar in 'MyClass' was synthesized for an assign, readwrite property but was released in 'dealloc'}}
[_T release]; // no-warning
[_other->_Z release]; // no-warning
[_N release];
self.M = 0; // This will release '_M'
[self setV:0]; // This will release '_V'
[self setW:@"newW"]; // This will release '_W', but retain the new value
[_S release]; // expected-warning {{The '_S' ivar in 'MyClass' was synthesized for a weak property but was released in 'dealloc'}}
self.O = 0; // no-warning
[_Q release]; // expected-warning {{The '_Q' ivar in 'MyClass' was synthesized for a weak property but was released in 'dealloc'}}
self.P = 0;
[self releaseInHelper];
[_nonPropertyIvar release]; // no-warning
// Silly, but not an error.
if (!_U)
[_U release];
[super dealloc];
// expected-warning@-1{{The '_Y' ivar in 'MyClass' was retained by a synthesized property but not released before '[super dealloc]'}}
// expected-warning@-2{{The '_W' ivar in 'MyClass' was retained by a synthesized property but not released before '[super dealloc]'}}
}
@end
diff --git a/clang/test/Analysis/PR3991.m b/clang/test/Analysis/PR3991.m
index 68d5660..ffdb7b4 100644
--- a/clang/test/Analysis/PR3991.m
+++ b/clang/test/Analysis/PR3991.m
@@ -1,69 +1,69 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core -analyzer-store=region -verify -triple x86_64-apple-darwin9 -Wno-incomplete-implementation %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-store=region -verify -triple x86_64-apple-darwin9 -Wno-incomplete-implementation %s
// expected-no-diagnostics
//===----------------------------------------------------------------------===//
// Delta-debugging produced forward declarations.
//===----------------------------------------------------------------------===//
typedef signed char BOOL;
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 <NSObject> {
}
@end extern id <NSObject> NSAllocateObject(Class aClass, unsigned extraBytes, NSZone *zone);
@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding> - (unsigned)count;
@end @class NSTimer, NSPort, NSArray;
@class NSURLHandle, NSMutableArray, NSMutableData, NSData, NSURL;
@interface NSResponder : NSObject <NSCoding> {
}
@end @class NSBitmapImageRep, NSCursor, NSGraphicsContext, NSImage, NSPasteboard, NSScrollView, NSWindow, NSAttributedString;
@interface NSView : NSResponder {
struct __VFlags2 {
}
_vFlags2;
}
@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError;
@interface NSBox : NSView {
}
@end @class GDataFeedDocList, GDataServiceTicket, GDataServiceTicket, IHGoogleDocsAdapter;
@protocol IHGoogleDocsAdapterDelegate - (void)googleDocsAdapter:(IHGoogleDocsAdapter*)inGoogleDocsAdapter accountVerifyIsValid:(BOOL)inIsValid error:(NSError *)inError;
@end @interface IHGoogleDocsAdapter : NSObject {
}
- (NSArray *)entries;
@end extern Class const kGDataUseRegisteredClass ;
@interface IHGoogleDocsAdapter () - (GDataFeedDocList *)feedDocList;
- (NSArray *)directoryPathComponents;
- (unsigned int)currentPathComponentIndex;
- (void)setCurrentPathComponentIndex:(unsigned int)aCurrentPathComponentIndex;
- (NSURL *)folderFeedURL;
@end
@implementation IHGoogleDocsAdapter - (id)initWithUsername:(NSString *)inUsername password:(NSString *)inPassword owner:(NSObject <IHGoogleDocsAdapterDelegate> *)owner {
return 0;
}
//===----------------------------------------------------------------------===//
// Actual test case:
//
// The analyzer currently doesn't reason about ObjCKVCRefExpr. Have both
// GRExprEngine::Visit and GRExprEngine::VisitLValue have such expressions
// evaluate to UnknownVal.
//===----------------------------------------------------------------------===//
- (void)docListListFetchTicket:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedDocList *)feed {
BOOL doGetDir = self.directoryPathComponents != 0 && self.currentPathComponentIndex < [self.directoryPathComponents count];
if (doGetDir) {
BOOL isDirExisting = [[self.feedDocList entries] count] > 0;
if (isDirExisting) {
if (self.folderFeedURL != 0) {
if (++self.currentPathComponentIndex == [self.directoryPathComponents count]) {
}
}
}
}
}
@end
diff --git a/clang/test/Analysis/PR7218.c b/clang/test/Analysis/PR7218.c
index 1775e05..10a75c9 100644
--- a/clang/test/Analysis/PR7218.c
+++ b/clang/test/Analysis/PR7218.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-store region -verify %s
char PR7218(char a) {
char buf[2];
buf[0] = a;
return buf[1]; // expected-warning {{Undefined or garbage value returned to caller}}
}
diff --git a/clang/test/Analysis/additive-folding-range-constraints.c b/clang/test/Analysis/additive-folding-range-constraints.c
index 4baada8..87d1b1c 100644
--- a/clang/test/Analysis/additive-folding-range-constraints.c
+++ b/clang/test/Analysis/additive-folding-range-constraints.c
@@ -1,304 +1,304 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify %s
void clang_analyzer_eval(int);
#define UINT_MAX (~0U)
#define INT_MAX (UINT_MAX & (UINT_MAX >> 1))
#define INT_MIN (-INT_MAX - 1)
// Each of these adjusted ranges has an adjustment small enough to split the
// solution range across an overflow boundary (Min for <, Max for >).
// This corresponds to one set of branches in RangeConstraintManager.
void smallAdjustmentGT (unsigned a) {
if (a+2 > 1)
clang_analyzer_eval(a < UINT_MAX-1); // expected-warning{{TRUE}}
else
clang_analyzer_eval(a == UINT_MAX-1 || a == UINT_MAX); // expected-warning{{TRUE}}
}
void smallAdjustmentGE (unsigned a) {
if (a+2 >= 1)
clang_analyzer_eval(a < UINT_MAX-1 || a == UINT_MAX); // expected-warning{{TRUE}}
else
clang_analyzer_eval(a == UINT_MAX-1); // expected-warning{{TRUE}}
}
void smallAdjustmentLT (unsigned a) {
if (a+1 < 2)
clang_analyzer_eval(a == 0 || a == UINT_MAX); // expected-warning{{TRUE}}
}
void smallAdjustmentLE (unsigned a) {
if (a+1 <= 2)
clang_analyzer_eval(a == 0 || a == 1 || a == UINT_MAX); // expected-warning{{TRUE}}
}
// Each of these adjusted ranges has an adjustment large enough to push the
// comparison value over an overflow boundary (Min for <, Max for >).
// This corresponds to one set of branches in RangeConstraintManager.
void largeAdjustmentGT (unsigned a) {
if (a-2 > UINT_MAX-1)
clang_analyzer_eval(a == 1); // expected-warning{{TRUE}}
else
clang_analyzer_eval(a != 1); // expected-warning{{TRUE}}
}
void largeAdjustmentGE (unsigned a) {
if (a-2 >= UINT_MAX-1)
clang_analyzer_eval(a == 1 || a == 0); // expected-warning{{TRUE}}
else
clang_analyzer_eval(a > 1); // expected-warning{{TRUE}}
}
void largeAdjustmentLT (unsigned a) {
if (a+2 < 1)
clang_analyzer_eval(a == UINT_MAX-1); // expected-warning{{TRUE}}
else
clang_analyzer_eval(a != UINT_MAX-1); // expected-warning{{TRUE}}
}
void largeAdjustmentLE (unsigned a) {
if (a+2 <= 1)
clang_analyzer_eval(a == UINT_MAX-1 || a == UINT_MAX); // expected-warning{{TRUE}}
else
clang_analyzer_eval(a < UINT_MAX-1); // expected-warning{{TRUE}}
}
// Test the nine cases in RangeConstraintManager's pinning logic.
// For out-of-range tautologies, it may be the negation that actually
// triggers the case in question.
void mixedComparisons1(signed char a) {
// Case 1: The range is entirely below the symbol's range.
int min = INT_MIN;
clang_analyzer_eval((a - 2) >= (min + 5LL)); // expected-warning{{TRUE}}
clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
void mixedComparisons2(signed char a) {
// Case 2: Only the lower end of the range is outside.
clang_analyzer_eval((a - 5) < (-0x81LL)); // expected-warning{{UNKNOWN}}
if ((a - 5) < (-0x81LL)) {
clang_analyzer_eval(a == 0); // expected-warning{{FALSE}}
clang_analyzer_eval(a == 0x7F); // expected-warning{{FALSE}}
clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
}
void mixedComparisons3(signed char a) {
// Case 3: The entire symbol range is covered.
clang_analyzer_eval((a - 0x200) < -0x100LL); // expected-warning{{TRUE}}
clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
void mixedComparisons4(signed char a) {
// Case 4: The range wraps around, but the lower wrap is out-of-range.
clang_analyzer_eval((a - 5) > 0LL); // expected-warning{{UNKNOWN}}
if ((a - 5) > 0LL) {
clang_analyzer_eval(a == 0); // expected-warning{{FALSE}}
clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == -0x80); // expected-warning{{FALSE}}
}
}
void mixedComparisons5(signed char a) {
// Case 5: The range is inside and may or may not wrap.
clang_analyzer_eval((a + 5) == 0LL); // expected-warning{{UNKNOWN}}
if ((a + 5) == 0LL) {
clang_analyzer_eval(a == 0); // expected-warning{{FALSE}}
clang_analyzer_eval(a == 0x7F); // expected-warning{{FALSE}}
clang_analyzer_eval(a == -0x80); // expected-warning{{FALSE}}
} else {
clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
}
void mixedComparisons6(signed char a) {
// Case 6: Only the upper end of the range is outside.
clang_analyzer_eval((a + 5) > 0x81LL); // expected-warning{{UNKNOWN}}
if ((a + 5) > 0x81LL) {
clang_analyzer_eval(a == 0); // expected-warning{{FALSE}}
clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == -0x80); // expected-warning{{FALSE}}
}
}
void mixedComparisons7(signed char a) {
// Case 7: The range wraps around but is entirely outside the symbol's range.
int min = INT_MIN;
clang_analyzer_eval((a + 2) >= (min + 5LL)); // expected-warning{{TRUE}}
clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
void mixedComparisons8(signed char a) {
// Case 8: The range wraps, but the upper wrap is out of range.
clang_analyzer_eval((a + 5) < 0LL); // expected-warning{{UNKNOWN}}
if ((a + 5) < 0LL) {
clang_analyzer_eval(a == 0); // expected-warning{{FALSE}}
clang_analyzer_eval(a == 0x7F); // expected-warning{{FALSE}}
clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
}
void mixedComparisons9(signed char a) {
// Case 9: The range is entirely above the symbol's range.
int max = INT_MAX;
clang_analyzer_eval((a + 2) <= (max - 5LL)); // expected-warning{{TRUE}}
clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == 0x7F); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == -0x80); // expected-warning{{UNKNOWN}}
}
void mixedSignedness1(int a) {
unsigned max = UINT_MAX;
clang_analyzer_eval(a < max); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) < max); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) < max); // expected-warning{{UNKNOWN}}
}
void mixedSignedness2(int a) {
unsigned max = UINT_MAX;
clang_analyzer_eval(a <= max); // expected-warning{{TRUE}}
clang_analyzer_eval((a + 2) <= max); // expected-warning{{TRUE}}
clang_analyzer_eval((a + 2U) <= max); // expected-warning{{TRUE}}
}
void mixedSignedness3(unsigned a) {
int max = INT_MAX;
clang_analyzer_eval(a < max); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) < max); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) < max); // expected-warning{{UNKNOWN}}
}
void mixedSignedness4(unsigned a) {
int max = INT_MAX;
clang_analyzer_eval(a <= max); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) <= max); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) <= max); // expected-warning{{UNKNOWN}}
}
void mixedSignedness5(unsigned a) {
int min = INT_MIN;
clang_analyzer_eval(a < min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) < min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) < min); // expected-warning{{UNKNOWN}}
}
void mixedSignedness6(unsigned a) {
int min = INT_MIN;
clang_analyzer_eval(a <= min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) <= min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) <= min); // expected-warning{{UNKNOWN}}
}
void mixedSignedness7(unsigned a) {
unsigned min = 0;
clang_analyzer_eval(a < min); // expected-warning{{FALSE}}
clang_analyzer_eval((a + 2) < min); // expected-warning{{FALSE}}
clang_analyzer_eval((a + 2U) < min); // expected-warning{{FALSE}}
}
void mixedSignedness8(unsigned a) {
unsigned min = 0;
clang_analyzer_eval(a <= min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) <= min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) <= min); // expected-warning{{UNKNOWN}}
}
void mixedSignedness9(unsigned a) {
int min = 0;
clang_analyzer_eval(a < min); // expected-warning{{FALSE}}
clang_analyzer_eval((a + 2) < min); // expected-warning{{FALSE}}
clang_analyzer_eval((a + 2U) < min); // expected-warning{{FALSE}}
}
void mixedSignedness10(unsigned a) {
int min = 0;
clang_analyzer_eval(a <= min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) <= min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) <= min); // expected-warning{{UNKNOWN}}
}
void mixedSignedness11(int a) {
int min = 0;
clang_analyzer_eval(a < min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) < min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) < min); // expected-warning{{FALSE}}
}
void mixedSignedness12(int a) {
int min = 0;
clang_analyzer_eval(a <= min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) <= min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) <= min); // expected-warning{{UNKNOWN}}
}
void mixedSignedness13(int a) {
unsigned max = INT_MAX;
clang_analyzer_eval(a < max); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) < max); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) < max); // expected-warning{{UNKNOWN}}
}
void mixedSignedness14(int a) {
unsigned max = INT_MAX;
clang_analyzer_eval(a <= max); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) <= max); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) <= max); // expected-warning{{UNKNOWN}}
}
void mixedSignedness15(int a) {
unsigned min = INT_MIN;
clang_analyzer_eval(a < min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) < min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) < min); // expected-warning{{UNKNOWN}}
}
void mixedSignedness16(int a) {
unsigned min = INT_MIN;
clang_analyzer_eval(a <= min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2) <= min); // expected-warning{{UNKNOWN}}
clang_analyzer_eval((a + 2U) <= min); // expected-warning{{UNKNOWN}}
}
void mixedSignedness17(int a) {
unsigned max = INT_MAX;
if (a < max)
return;
clang_analyzer_eval(a < 0); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == 0); // expected-warning{{FALSE}}
clang_analyzer_eval(a == INT_MAX); // expected-warning{{UNKNOWN}}
}
void mixedSignedness18(int a) {
if (a >= 0)
return;
clang_analyzer_eval(a < 0); // expected-warning{{TRUE}}
clang_analyzer_eval(a == (unsigned)INT_MIN); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(a == UINT_MAX); // expected-warning{{UNKNOWN}}
}
diff --git a/clang/test/Analysis/additive-folding.cpp b/clang/test/Analysis/additive-folding.cpp
index 6ae025b..52056d4 100644
--- a/clang/test/Analysis/additive-folding.cpp
+++ b/clang/test/Analysis/additive-folding.cpp
@@ -1,207 +1,207 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -Wno-tautological-compare %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,debug.ExprInspection -verify -Wno-tautological-compare %s
void clang_analyzer_eval(bool);
#define UINT_MAX (~0U)
#define INT_MAX (UINT_MAX & (UINT_MAX >> 1))
#define INT_MIN (-INT_MAX - 1)
//---------------
// Plus/minus
//---------------
void separateExpressions (int a) {
int b = a + 1;
--b;
clang_analyzer_eval(a != 0 && b == 0); // expected-warning{{FALSE}}
}
void oneLongExpression (int a) {
// Expression canonicalization should still allow this to work, even though
// the first term is on the left.
int b = 15 + a + 15 - 10 - 20;
clang_analyzer_eval(a != 0 && b == 0); // expected-warning{{FALSE}}
}
void mixedTypes (int a) {
// Different additive types should not cause crashes when constant-folding.
// This is part of PR7406.
int b = a + 1LL;
clang_analyzer_eval(a != 0 && (b-1) == 0); // not crash, expected-warning{{FALSE}}
int c = a + 1U;
clang_analyzer_eval(a != 0 && (c-1) == 0); // not crash, expected-warning{{FALSE}}
}
//---------------
// Comparisons
//---------------
// Equality and inequality only
void eq_ne (unsigned a) {
if (a == UINT_MAX) {
clang_analyzer_eval(a+1 == 0); // expected-warning{{TRUE}}
clang_analyzer_eval(a-1 == UINT_MAX-1); // expected-warning{{TRUE}}
} else {
clang_analyzer_eval(a+1 != 0); // expected-warning{{TRUE}}
clang_analyzer_eval(a-1 != UINT_MAX-1); // expected-warning{{TRUE}}
}
}
// Mixed typed inequalities (part of PR7406)
// These should not crash.
void mixed_eq_ne (int a) {
if (a == 1) {
clang_analyzer_eval(a+1U == 2); // expected-warning{{TRUE}}
clang_analyzer_eval(a-1U == 0); // expected-warning{{TRUE}}
} else {
clang_analyzer_eval(a+1U != 2); // expected-warning{{TRUE}}
clang_analyzer_eval(a-1U != 0); // expected-warning{{TRUE}}
}
}
// Simple order comparisons with no adjustment
void baselineGT (unsigned a) {
if (a > 0)
clang_analyzer_eval(a != 0); // expected-warning{{TRUE}}
else
clang_analyzer_eval(a == 0); // expected-warning{{TRUE}}
}
void baselineGE (unsigned a) {
if (a >= UINT_MAX)
clang_analyzer_eval(a == UINT_MAX); // expected-warning{{TRUE}}
else
clang_analyzer_eval(a != UINT_MAX); // expected-warning{{TRUE}}
}
void baselineLT (unsigned a) {
if (a < UINT_MAX)
clang_analyzer_eval(a != UINT_MAX); // expected-warning{{TRUE}}
else
clang_analyzer_eval(a == UINT_MAX); // expected-warning{{TRUE}}
}
void baselineLE (unsigned a) {
if (a <= 0)
clang_analyzer_eval(a == 0); // expected-warning{{TRUE}}
else
clang_analyzer_eval(a != 0); // expected-warning{{TRUE}}
}
// Adjustment gives each of these an extra solution!
void adjustedGT (unsigned a) {
clang_analyzer_eval(a-1 > UINT_MAX-1); // expected-warning{{UNKNOWN}}
}
void adjustedGE (unsigned a) {
clang_analyzer_eval(a-1 > UINT_MAX-1); // expected-warning{{UNKNOWN}}
if (a-1 >= UINT_MAX-1)
clang_analyzer_eval(a == UINT_MAX); // expected-warning{{UNKNOWN}}
}
void adjustedLT (unsigned a) {
clang_analyzer_eval(a+1 < 1); // expected-warning{{UNKNOWN}}
}
void adjustedLE (unsigned a) {
clang_analyzer_eval(a+1 <= 1); // expected-warning{{UNKNOWN}}
if (a+1 <= 1)
clang_analyzer_eval(a == 0); // expected-warning{{UNKNOWN}}
}
// Tautologies
// The negative forms are exercised as well
// because clang_analyzer_eval tests both possibilities.
void tautologies(unsigned a) {
clang_analyzer_eval(a <= UINT_MAX); // expected-warning{{TRUE}}
clang_analyzer_eval(a >= 0); // expected-warning{{TRUE}}
}
// Tautologies from outside the range of the symbol
void tautologiesOutside(unsigned char a) {
clang_analyzer_eval(a <= 0x100); // expected-warning{{TRUE}}
clang_analyzer_eval(a < 0x100); // expected-warning{{TRUE}}
clang_analyzer_eval(a != 0x100); // expected-warning{{TRUE}}
clang_analyzer_eval(a != -1); // expected-warning{{TRUE}}
clang_analyzer_eval(a > -1); // expected-warning{{TRUE}}
clang_analyzer_eval(a >= -1); // expected-warning{{TRUE}}
}
// Wraparound with mixed types. Note that the analyzer assumes
// -fwrapv semantics.
void mixedWraparoundSanityCheck(int a) {
int max = INT_MAX;
int min = INT_MIN;
int b = a + 1;
clang_analyzer_eval(a == max && b != min); // expected-warning{{FALSE}}
}
void mixedWraparoundLE_GT(int a) {
int max = INT_MAX;
int min = INT_MIN;
clang_analyzer_eval((a + 2) <= (max + 1LL)); // expected-warning{{TRUE}}
clang_analyzer_eval((a - 2) > (min - 1LL)); // expected-warning{{TRUE}}
clang_analyzer_eval((a + 2LL) <= max); // expected-warning{{UNKNOWN}}
}
void mixedWraparoundGE_LT(int a) {
int max = INT_MAX;
int min = INT_MIN;
clang_analyzer_eval((a + 2) < (max + 1LL)); // expected-warning{{TRUE}}
clang_analyzer_eval((a - 2) >= (min - 1LL)); // expected-warning{{TRUE}}
clang_analyzer_eval((a - 2LL) >= min); // expected-warning{{UNKNOWN}}
}
void mixedWraparoundEQ_NE(int a) {
int max = INT_MAX;
clang_analyzer_eval((a + 2) != (max + 1LL)); // expected-warning{{TRUE}}
clang_analyzer_eval((a + 2LL) == (max + 1LL)); // expected-warning{{UNKNOWN}}
}
// Mixed-signedness comparisons.
void mixedSignedness(int a, unsigned b) {
int sMin = INT_MIN;
unsigned uMin = INT_MIN;
clang_analyzer_eval(a == sMin && a != uMin); // expected-warning{{FALSE}}
clang_analyzer_eval(b == uMin && b != sMin); // expected-warning{{FALSE}}
}
void mixedSignedness2(int a) {
if (a != -1)
return;
clang_analyzer_eval(a == UINT_MAX); // expected-warning{{TRUE}}
}
void mixedSignedness3(unsigned a) {
if (a != UINT_MAX)
return;
clang_analyzer_eval(a == -1); // expected-warning{{TRUE}}
}
void multiplicativeSanityTest(int x) {
// At one point we were ignoring the *4 completely -- the constraint manager
// would see x < 8 and then declare the assertion to be known false.
if (x*4 < 8)
return;
clang_analyzer_eval(x == 3); // expected-warning{{UNKNOWN}}
}
diff --git a/clang/test/Analysis/analyzeOneFunction.m b/clang/test/Analysis/analyzeOneFunction.m
index e70b2d7..a77abe1 100644
--- a/clang/test/Analysis/analyzeOneFunction.m
+++ b/clang/test/Analysis/analyzeOneFunction.m
@@ -1,56 +1,56 @@
-// RUN: %clang_cc1 -analyze -analyze-function="-[Test1 myMethodWithY:withX:]" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
+// RUN: %clang_analyze_cc1 -analyze-function="-[Test1 myMethodWithY:withX:]" -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s
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 NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
@protocol NSMutableCopying - (id)mutableCopyWithZone:(NSZone *)zone; @end
@interface NSObject <NSObject> {}
+(id)alloc;
-(id)init;
-(id)autorelease;
-(id)copy;
-(id)retain;
@end
@interface NSString : NSObject <NSCopying, NSMutableCopying, NSCoding>
- (NSUInteger)length;
-(id)initWithFormat:(NSString *)f,...;
-(BOOL)isEqualToString:(NSString *)s;
+ (id)string;
@end
@interface Test1 : NSObject {
NSString *text;
}
-(id)myMethod;
-(id)myMethodWithY:(int)Y withX:(int)X;
@property (nonatomic, assign) NSString *text;
@end
@implementation Test1
@synthesize text;
-(id)myMethod {
Test1 *cell = [[[Test1 alloc] init] autorelease];
NSString *string1 = [[NSString alloc] initWithFormat:@"test %f", 0.0]; // No warning: this function is not analized.
cell.text = string1;
return cell;
}
-(id)myMethodWithY:(int)Y withX:(int)X {
Test1 *cell = [[[Test1 alloc] init] autorelease];
NSString *string1 = [[NSString alloc] initWithFormat:@"test %f %d", 0.0, X+Y]; // expected-warning {{Potential leak}}
cell.text = string1;
return cell;
}
@end
diff --git a/clang/test/Analysis/analyzer-checker-config.c b/clang/test/Analysis/analyzer-checker-config.c
index 642c96c..34e3399 100644
--- a/clang/test/Analysis/analyzer-checker-config.c
+++ b/clang/test/Analysis/analyzer-checker-config.c
@@ -1,12 +1,12 @@
-// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config unix.mallo:Optimistic=true 2>&1 | FileCheck %s
-// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config uni:Optimistic=true 2>&1 | FileCheck %s
-// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config uni.:Optimistic=true 2>&1 | FileCheck %s
-// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config ..:Optimistic=true 2>&1 | FileCheck %s
-// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config unix.:Optimistic=true 2>&1 | FileCheck %s
-// RUN: not %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config unrelated:Optimistic=true 2>&1 | FileCheck %s
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-config unix.Malloc:Optimistic=true
+// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.mallo:Optimistic=true 2>&1 | FileCheck %s
+// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config uni:Optimistic=true 2>&1 | FileCheck %s
+// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config uni.:Optimistic=true 2>&1 | FileCheck %s
+// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config ..:Optimistic=true 2>&1 | FileCheck %s
+// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.:Optimistic=true 2>&1 | FileCheck %s
+// RUN: not %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unrelated:Optimistic=true 2>&1 | FileCheck %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc -analyzer-config unix.Malloc:Optimistic=true
// Just to test clang is working.
# foo
// CHECK: error:
diff --git a/clang/test/Analysis/analyzer-config.c b/clang/test/Analysis/analyzer-config.c
index 6faeeb3..c0153a5 100644
--- a/clang/test/Analysis/analyzer-config.c
+++ b/clang/test/Analysis/analyzer-config.c
@@ -1,31 +1,31 @@
-// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper -Xclang -analyzer-max-loop -Xclang 34 > %t 2>&1
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 %s -o /dev/null -analyzer-checker=core,osx.cocoa,debug.ConfigDumper -analyzer-max-loop 34 > %t 2>&1
// RUN: FileCheck --input-file=%t %s
void bar() {}
void foo() {
// Call bar 33 times so max-times-inline-large is met and
// min-blocks-for-inline-large is checked
for (int i = 0; i < 34; ++i) {
bar();
}
}
// CHECK: [config]
// CHECK-NEXT: cfg-conditional-static-initializers = true
// CHECK-NEXT: cfg-temporary-dtors = false
// CHECK-NEXT: faux-bodies = true
// CHECK-NEXT: graph-trim-interval = 1000
// CHECK-NEXT: inline-lambdas = true
// CHECK-NEXT: ipa = dynamic-bifurcate
// CHECK-NEXT: ipa-always-inline-size = 3
// CHECK-NEXT: leak-diagnostics-reference-allocation = false
// CHECK-NEXT: max-inlinable-size = 50
// CHECK-NEXT: max-nodes = 150000
// CHECK-NEXT: max-times-inline-large = 32
// CHECK-NEXT: min-cfg-size-treat-functions-as-large = 14
// CHECK-NEXT: mode = deep
// CHECK-NEXT: region-store-small-struct-limit = 2
// CHECK-NEXT: widen-loops = false
// CHECK-NEXT: [stats]
// CHECK-NEXT: num-entries = 15
diff --git a/clang/test/Analysis/analyzer-config.cpp b/clang/test/Analysis/analyzer-config.cpp
index 23f0828..f84be17 100644
--- a/clang/test/Analysis/analyzer-config.cpp
+++ b/clang/test/Analysis/analyzer-config.cpp
@@ -1,41 +1,41 @@
-// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=debug.ConfigDumper -Xclang -analyzer-max-loop -Xclang 34 > %t 2>&1
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 %s -o /dev/null -analyzer-checker=core,osx.cocoa,debug.ConfigDumper -analyzer-max-loop 34 > %t 2>&1
// RUN: FileCheck --input-file=%t %s
void bar() {}
void foo() {
// Call bar 33 times so max-times-inline-large is met and
// min-blocks-for-inline-large is checked
for (int i = 0; i < 34; ++i) {
bar();
}
}
class Foo {
public:
void bar() {}
void foo() { bar(); }
};
// CHECK: [config]
// CHECK-NEXT: c++-container-inlining = false
// CHECK-NEXT: c++-inlining = destructors
// CHECK-NEXT: c++-shared_ptr-inlining = false
// CHECK-NEXT: c++-stdlib-inlining = true
// CHECK-NEXT: c++-template-inlining = true
// CHECK-NEXT: cfg-conditional-static-initializers = true
// CHECK-NEXT: cfg-temporary-dtors = false
// CHECK-NEXT: faux-bodies = true
// CHECK-NEXT: graph-trim-interval = 1000
// CHECK-NEXT: inline-lambdas = true
// CHECK-NEXT: ipa = dynamic-bifurcate
// CHECK-NEXT: ipa-always-inline-size = 3
// CHECK-NEXT: leak-diagnostics-reference-allocation = false
// CHECK-NEXT: max-inlinable-size = 50
// CHECK-NEXT: max-nodes = 150000
// CHECK-NEXT: max-times-inline-large = 32
// CHECK-NEXT: min-cfg-size-treat-functions-as-large = 14
// CHECK-NEXT: mode = deep
// CHECK-NEXT: region-store-small-struct-limit = 2
// CHECK-NEXT: widen-loops = false
// CHECK-NEXT: [stats]
// CHECK-NEXT: num-entries = 20
diff --git a/clang/test/Analysis/analyzer-display-progress.cpp b/clang/test/Analysis/analyzer-display-progress.cpp
index 5d9f5e5..b54044a 100644
--- a/clang/test/Analysis/analyzer-display-progress.cpp
+++ b/clang/test/Analysis/analyzer-display-progress.cpp
@@ -1,30 +1,30 @@
-// RUN: %clang_cc1 -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s
+// RUN: %clang_analyze_cc1 -analyzer-display-progress %s 2>&1 | FileCheck %s
void f() {};
void g() {};
void h() {}
struct SomeStruct {
void f() {}
};
struct SomeOtherStruct {
void f() {}
};
namespace ns {
struct SomeStruct {
void f(int) {}
void f(float, ::SomeStruct) {}
void f(float, SomeStruct) {}
};
}
// CHECK: analyzer-display-progress.cpp f()
// CHECK: analyzer-display-progress.cpp g()
// CHECK: analyzer-display-progress.cpp h()
// CHECK: analyzer-display-progress.cpp SomeStruct::f()
// CHECK: analyzer-display-progress.cpp SomeOtherStruct::f()
// CHECK: analyzer-display-progress.cpp ns::SomeStruct::f(int)
// CHECK: analyzer-display-progress.cpp ns::SomeStruct::f(float, ::SomeStruct)
// CHECK: analyzer-display-progress.cpp ns::SomeStruct::f(float, struct ns::SomeStruct)
diff --git a/clang/test/Analysis/analyzer-display-progress.m b/clang/test/Analysis/analyzer-display-progress.m
index cc43cf3..8d0b3d6 100644
--- a/clang/test/Analysis/analyzer-display-progress.m
+++ b/clang/test/Analysis/analyzer-display-progress.m
@@ -1,30 +1,30 @@
-// RUN: %clang_cc1 -fblocks -analyze -analyzer-display-progress %s 2>&1 | FileCheck %s
+// RUN: %clang_analyze_cc1 -fblocks -analyzer-display-progress %s 2>&1 | FileCheck %s
#include "Inputs/system-header-simulator-objc.h"
static void f() {}
@interface I: NSObject
-(void)instanceMethod:(int)arg1 with:(int)arg2;
+(void)classMethod;
@end
@implementation I
-(void)instanceMethod:(int)arg1 with:(int)arg2 {}
+(void)classMethod {}
@end
void g(I *i, int x, int y) {
[I classMethod];
[i instanceMethod: x with: y];
void (^block)(void);
block = ^{};
block();
}
// CHECK: analyzer-display-progress.m f
// CHECK: analyzer-display-progress.m -[I instanceMethod:with:]
// CHECK: analyzer-display-progress.m +[I classMethod]
// CHECK: analyzer-display-progress.m g
// CHECK: analyzer-display-progress.m block (line: 22, col: 11)
diff --git a/clang/test/Analysis/analyzer-enabled-checkers.c b/clang/test/Analysis/analyzer-enabled-checkers.c
index e60de05..0ea01a0 100644
--- a/clang/test/Analysis/analyzer-enabled-checkers.c
+++ b/clang/test/Analysis/analyzer-enabled-checkers.c
@@ -1,20 +1,20 @@
-// RUN: %clang -target x86_64-apple-darwin10 --analyze %s -o /dev/null -Xclang -analyzer-checker=core -Xclang -analyzer-list-enabled-checkers > %t 2>&1
+// RUN: %clang_analyze_cc1 -triple x86_64-apple-darwin10 %s -o /dev/null -analyzer-checker=core -analyzer-list-enabled-checkers > %t 2>&1
// RUN: FileCheck --input-file=%t %s
// CHECK: OVERVIEW: Clang Static Analyzer Enabled Checkers List
// CHECK: core.CallAndMessage
// CHECK: core.DivideZero
// CHECK: core.DynamicTypePropagation
// CHECK: core.NonNullParamChecker
// CHECK: core.NullDereference
// CHECK: core.StackAddressEscape
// CHECK: core.UndefinedBinaryOperatorResult
// CHECK: core.VLASize
// CHECK: core.builtin.BuiltinFunctions
// CHECK: core.builtin.NoReturnFunctions
// CHECK: core.uninitialized.ArraySubscript
// CHECK: core.uninitialized.Assign
// CHECK: core.uninitialized.Branch
// CHECK: core.uninitialized.CapturedBlockVariable
// CHECK: core.uninitialized.UndefReturn
diff --git a/clang/test/Analysis/analyzer-stats.c b/clang/test/Analysis/analyzer-stats.c
index a0a50cb..5a40d19 100644
--- a/clang/test/Analysis/analyzer-stats.c
+++ b/clang/test/Analysis/analyzer-stats.c
@@ -1,14 +1,14 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,deadcode.DeadStores,debug.Stats -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,deadcode.DeadStores,debug.Stats -verify -Wno-unreachable-code -analyzer-opt-analyze-nested-blocks %s
int foo();
int test() { // expected-warning-re{{test -> Total CFGBlocks: {{[0-9]+}} | Unreachable CFGBlocks: 0 | Exhausted Block: no | Empty WorkList: yes}}
int a = 1;
a = 34 / 12;
if (foo())
return a;
a /= 4;
return a;
}
diff --git a/clang/test/Analysis/array-struct-region.c b/clang/test/Analysis/array-struct-region.c
index a41d040..cdfec45 100644
--- a/clang/test/Analysis/array-struct-region.c
+++ b/clang/test/Analysis/array-struct-region.c
@@ -1,355 +1,355 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core,alpha.core,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core,debug.ExprInspection -verify %s
void clang_analyzer_eval(int);
int string_literal_init() {
char a[] = "abc";
char b[2] = "abc"; // expected-warning{{too long}}
char c[5] = "abc";
clang_analyzer_eval(a[1] == 'b'); // expected-warning{{TRUE}}
clang_analyzer_eval(b[1] == 'b'); // expected-warning{{TRUE}}
clang_analyzer_eval(c[1] == 'b'); // expected-warning{{TRUE}}
clang_analyzer_eval(a[3] == 0); // expected-warning{{TRUE}}
clang_analyzer_eval(c[3] == 0); // expected-warning{{TRUE}}
clang_analyzer_eval(c[4] == 0); // expected-warning{{TRUE}}
return 42;
}
void nested_compound_literals(int rad) {
int vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169}, // expected-warning 6 {{implicit conversion from 'double' to 'int' changes value from}}
{0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; // expected-warning 6 {{implicit conversion from 'double' to 'int' changes value from}}
int a;
for (a = 0; a < 6; ++a) {
vec[a][0] *= rad; // no-warning
vec[a][1] *= rad; // no-warning
}
}
void nested_compound_literals_float(float rad) {
float vec[6][2] = {{0.195, 0.02}, {0.383, 0.067}, {0.55, 0.169},
{0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}};
int a;
for (a = 0; a < 6; ++a) {
vec[a][0] *= rad; // no-warning
vec[a][1] *= rad; // no-warning
}
}
void struct_as_array() {
struct simple { int x; int y; };
struct simple a;
struct simple *p = &a;
p->x = 5;
clang_analyzer_eval(a.x == 5); // expected-warning{{TRUE}}
clang_analyzer_eval(p[0].x == 5); // expected-warning{{TRUE}}
p[0].y = 5;
clang_analyzer_eval(a.y == 5); // expected-warning{{TRUE}}
clang_analyzer_eval(p->y == 5); // expected-warning{{TRUE}}
}
// PR13264 / <rdar://problem/11802440>
struct point { int x; int y; };
struct circle { struct point o; int r; };
struct circle get_circle() {
struct circle result;
result.r = 5;
result.o = (struct point){0, 0};
return result;
}
void struct_in_struct() {
struct circle c;
c = get_circle();
// This used to think c.r was undefined because c.o is a LazyCompoundVal.
clang_analyzer_eval(c.r == 5); // expected-warning{{TRUE}}
}
// We also test with floats because we don't model floats right now,
// and the original bug report used a float.
struct circle_f { struct point o; float r; };
struct circle_f get_circle_f() {
struct circle_f result;
result.r = 5.0;
result.o = (struct point){0, 0};
return result;
}
float struct_in_struct_f() {
struct circle_f c;
c = get_circle_f();
return c.r; // no-warning
}
int randomInt();
int testSymbolicInvalidation(int index) {
int vals[10];
vals[0] = 42;
clang_analyzer_eval(vals[0] == 42); // expected-warning{{TRUE}}
vals[index] = randomInt();
clang_analyzer_eval(vals[0] == 42); // expected-warning{{UNKNOWN}}
return vals[index]; // no-warning
}
int testConcreteInvalidation(int index) {
int vals[10];
vals[index] = 42;
clang_analyzer_eval(vals[index] == 42); // expected-warning{{TRUE}}
vals[0] = randomInt();
clang_analyzer_eval(vals[index] == 42); // expected-warning{{UNKNOWN}}
return vals[0]; // no-warning
}
typedef struct {
int x, y, z;
} S;
S makeS();
int testSymbolicInvalidationStruct(int index) {
S vals[10];
vals[0].x = 42;
clang_analyzer_eval(vals[0].x == 42); // expected-warning{{TRUE}}
vals[index] = makeS();
clang_analyzer_eval(vals[0].x == 42); // expected-warning{{UNKNOWN}}
return vals[index].x; // no-warning
}
int testConcreteInvalidationStruct(int index) {
S vals[10];
vals[index].x = 42;
clang_analyzer_eval(vals[index].x == 42); // expected-warning{{TRUE}}
vals[0] = makeS();
clang_analyzer_eval(vals[index].x == 42); // expected-warning{{UNKNOWN}}
return vals[0].x; // no-warning
}
typedef struct {
S a[5];
S b[5];
} SS;
int testSymbolicInvalidationDoubleStruct(int index) {
SS vals;
vals.a[0].x = 42;
vals.b[0].x = 42;
clang_analyzer_eval(vals.a[0].x == 42); // expected-warning{{TRUE}}
clang_analyzer_eval(vals.b[0].x == 42); // expected-warning{{TRUE}}
vals.a[index] = makeS();
clang_analyzer_eval(vals.a[0].x == 42); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(vals.b[0].x == 42); // expected-warning{{TRUE}}
return vals.b[index].x; // no-warning
}
int testConcreteInvalidationDoubleStruct(int index) {
SS vals;
vals.a[index].x = 42;
vals.b[index].x = 42;
clang_analyzer_eval(vals.a[index].x == 42); // expected-warning{{TRUE}}
clang_analyzer_eval(vals.b[index].x == 42); // expected-warning{{TRUE}}
vals.a[0] = makeS();
clang_analyzer_eval(vals.a[index].x == 42); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(vals.b[index].x == 42); // expected-warning{{TRUE}}
return vals.b[0].x; // no-warning
}
int testNonOverlappingStructFieldsSimple() {
S val;
val.x = 1;
val.y = 2;
clang_analyzer_eval(val.x == 1); // expected-warning{{TRUE}}
clang_analyzer_eval(val.y == 2); // expected-warning{{TRUE}}
return val.z; // expected-warning{{garbage}}
}
int testNonOverlappingStructFieldsSymbolicBase(int index, int anotherIndex) {
SS vals;
vals.a[index].x = 42;
vals.a[index].y = 42;
clang_analyzer_eval(vals.a[index].x == 42); // expected-warning{{TRUE}}
clang_analyzer_eval(vals.a[index].y == 42); // expected-warning{{TRUE}}
vals.a[anotherIndex].x = 42;
clang_analyzer_eval(vals.a[index].x == 42); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(vals.a[index].y == 42); // expected-warning{{TRUE}}
// FIXME: False negative. No bind ever set a field 'z'.
return vals.a[index].z; // no-warning
}
int testStructFieldChains(int index, int anotherIndex) {
SS vals[4];
vals[index].a[0].x = 42;
vals[anotherIndex].a[1].y = 42;
clang_analyzer_eval(vals[index].a[0].x == 42); // expected-warning{{TRUE}}
clang_analyzer_eval(vals[anotherIndex].a[1].y == 42); // expected-warning{{TRUE}}
// This doesn't affect anything in the 'a' array field.
vals[anotherIndex].b[1].x = 42;
clang_analyzer_eval(vals[index].a[0].x == 42); // expected-warning{{TRUE}}
clang_analyzer_eval(vals[anotherIndex].a[1].y == 42); // expected-warning{{TRUE}}
clang_analyzer_eval(vals[anotherIndex].b[1].x == 42); // expected-warning{{TRUE}}
// This doesn't affect anything in the 'b' array field.
vals[index].a[anotherIndex].x = 42;
clang_analyzer_eval(vals[index].a[0].x == 42); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(vals[anotherIndex].a[0].x == 42); // expected-warning{{UNKNOWN}}
clang_analyzer_eval(vals[anotherIndex].a[1].y == 42); // expected-warning{{TRUE}}
clang_analyzer_eval(vals[anotherIndex].b[1].x == 42); // expected-warning{{TRUE}}
// FIXME: False negative. No bind ever set a field 'z'.
return vals[index].a[0].z; // no-warning
}
int testStructFieldChainsNested(int index, int anotherIndex) {
SS vals[4];
vals[index].a[0].x = 42;
clang_analyzer_eval(vals[index].a[0].x == 42); // expected-warning{{TRUE}}
vals[index].b[0] = makeS();
clang_analyzer_eval(vals[index].a[0].x == 42); // expected-warning{{TRUE}}
vals[index].a[0] = makeS();
clang_analyzer_eval(vals[index].a[0].x == 42); // expected-warning{{UNKNOWN}}
vals[index].a[0].x = 42;
clang_analyzer_eval(vals[index].a[0].x == 42); // expected-warning{{TRUE}}
return 0;
}
typedef struct {
int zoomLevel;
struct point center;
} Outer;
extern int test13116945(struct point x);
static void radar13116945(struct point centerCoordinate) {
Outer zoomRegion;
zoomRegion.zoomLevel = 0;
zoomRegion.center = centerCoordinate;
Outer r = zoomRegion;
test13116945(r.center); // no-warning
}
typedef struct {
char data[4];
} ShortString;
typedef struct {
ShortString str;
int length;
} ShortStringWrapper;
void testArrayStructCopy() {
ShortString s = { "abc" };
ShortString s2 = s;
ShortString s3 = s2;
clang_analyzer_eval(s3.data[0] == 'a'); // expected-warning{{TRUE}}
clang_analyzer_eval(s3.data[1] == 'b'); // expected-warning{{TRUE}}
clang_analyzer_eval(s3.data[2] == 'c'); // expected-warning{{TRUE}}
s3.data[0] = 'z';
ShortString s4 = s3;
clang_analyzer_eval(s4.data[0] == 'z'); // expected-warning{{TRUE}}
clang_analyzer_eval(s4.data[1] == 'b'); // expected-warning{{TRUE}}
clang_analyzer_eval(s4.data[2] == 'c'); // expected-warning{{TRUE}}
}
void testArrayStructCopyNested() {
ShortString s = { "abc" };
ShortString s2 = s;
ShortStringWrapper w = { s2, 0 };
clang_analyzer_eval(w.str.data[0] == 'a'); // expected-warning{{TRUE}}
clang_analyzer_eval(w.str.data[1] == 'b'); // expected-warning{{TRUE}}
clang_analyzer_eval(w.str.data[2] == 'c'); // expected-warning{{TRUE}}
clang_analyzer_eval(w.length == 0); // expected-warning{{TRUE}}
ShortStringWrapper w2 = w;
clang_analyzer_eval(w2.str.data[0] == 'a'); // expected-warning{{TRUE}}
clang_analyzer_eval(w2.str.data[1] == 'b'); // expected-warning{{TRUE}}
clang_analyzer_eval(w2.str.data[2] == 'c'); // expected-warning{{TRUE}}
clang_analyzer_eval(w2.length == 0); // expected-warning{{TRUE}}
ShortStringWrapper w3 = w2;
clang_analyzer_eval(w3.str.data[0] == &