diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2012-08-15 20:02:54 +0000 |
commit | 56d91b49b13fe55c918afbda19f6165b5fbff87a (patch) | |
tree | 9abb1a658a297776086f4e0dfa6ca533de02104e /test | |
parent | 41e20f564abdb05101d6b2b29c59459a966c22cc (diff) | |
download | src-56d91b49b13fe55c918afbda19f6165b5fbff87a.tar.gz src-56d91b49b13fe55c918afbda19f6165b5fbff87a.zip |
Vendor import of clang trunk r161861:vendor/clang/clang-trunk-r161861
Notes
Notes:
svn path=/vendor/clang/dist/; revision=239313
svn path=/vendor/clang/clang-trunk-r161861/; revision=239314; tag=vendor/clang/clang-trunk-r161861
Diffstat (limited to 'test')
1149 files changed, 37646 insertions, 3944 deletions
diff --git a/test/ARCMT/Common.h b/test/ARCMT/Common.h index 16856ed1b444..ed4894970247 100644 --- a/test/ARCMT/Common.h +++ b/test/ARCMT/Common.h @@ -6,6 +6,7 @@ #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) #define CF_CONSUMED __attribute__((cf_consumed)) +#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) #define NS_INLINE static __inline__ __attribute__((always_inline)) #define nil ((void*) 0) @@ -21,7 +22,7 @@ typedef struct _NSZone NSZone; typedef const void * CFTypeRef; CFTypeRef CFRetain(CFTypeRef cf); -id CFBridgingRelease(CFTypeRef CF_CONSUMED X); +CFTypeRef CFMakeCollectable(CFTypeRef cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE; NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE; @@ -68,3 +69,36 @@ typedef const void* objc_objectptr_t; extern __attribute__((ns_returns_retained)) id objc_retainedObject(objc_objectptr_t __attribute__((cf_consumed)) pointer); extern __attribute__((ns_returns_not_retained)) id objc_unretainedObject(objc_objectptr_t pointer); extern objc_objectptr_t objc_unretainedPointer(id object); + +#define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; }) +#define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; }) +#define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; }) +#define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; }) + +typedef id dispatch_object_t; +typedef id xpc_object_t; + +void _dispatch_object_validate(dispatch_object_t object); +void _xpc_object_validate(xpc_object_t object); + +#if __has_feature(objc_arc) + +NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) { + return (__bridge_retained CFTypeRef)X; +} + +NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) { + return (__bridge_transfer id)X; +} + +#else + +NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) { + return X ? CFRetain((CFTypeRef)X) : NULL; +} + +NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) { + return [(id)CFMakeCollectable(X) autorelease]; +} + +#endif diff --git a/test/ARCMT/autoreleases.m b/test/ARCMT/autoreleases.m index 3acddb71e7c8..a131bc53391d 100644 --- a/test/ARCMT/autoreleases.m +++ b/test/ARCMT/autoreleases.m @@ -3,29 +3,21 @@ // RUN: diff %t %s.result // DISABLE: mingw32 -typedef unsigned char BOOL; +#include "Common.h" -@interface NSObject { - id isa; -} -+new; -+alloc; --init; --autorelease; -@end - -@interface NSAutoreleasePool : NSObject -- drain; -@end - @interface A : NSObject { @package id object; } @end -@interface B : NSObject +@interface B : NSObject { + id _prop; + xpc_object_t _xpc_prop; +} - (BOOL)containsSelf:(A*)a; +@property (retain) id prop; +@property (retain) xpc_object_t xpc_prop; @end @implementation A @@ -35,6 +27,26 @@ typedef unsigned char BOOL; - (BOOL)containsSelf:(A*)a { return a->object == self; } + +-(id) prop { + return _prop; +} +-(void) setProp:(id) newVal { + [_prop autorelease]; + _prop = [newVal retain]; +} +-(void) setProp2:(CFTypeRef) newVal { + [_prop autorelease]; + _prop = (id)CFRetain(newVal); +} + +-(id) xpc_prop { + return _xpc_prop; +} +-(void) setXpc_prop:(xpc_object_t) newVal { + [_xpc_prop autorelease]; + _xpc_prop = xpc_retain(newVal); +} @end void NSLog(id, ...); @@ -47,3 +59,8 @@ int main (int argc, const char * argv[]) { [pool drain]; return 0; } + +void test(A *prevVal, A *newVal) { + [prevVal autorelease]; + prevVal = [newVal retain]; +} diff --git a/test/ARCMT/autoreleases.m.result b/test/ARCMT/autoreleases.m.result index 49bc32141ec5..6593fc9199a0 100644 --- a/test/ARCMT/autoreleases.m.result +++ b/test/ARCMT/autoreleases.m.result @@ -3,29 +3,21 @@ // RUN: diff %t %s.result // DISABLE: mingw32 -typedef unsigned char BOOL; +#include "Common.h" -@interface NSObject { - id isa; -} -+new; -+alloc; --init; --autorelease; -@end - -@interface NSAutoreleasePool : NSObject -- drain; -@end - @interface A : NSObject { @package id object; } @end -@interface B : NSObject +@interface B : NSObject { + id _prop; + xpc_object_t _xpc_prop; +} - (BOOL)containsSelf:(A*)a; +@property (strong) id prop; +@property (strong) xpc_object_t xpc_prop; @end @implementation A @@ -35,6 +27,23 @@ typedef unsigned char BOOL; - (BOOL)containsSelf:(A*)a { return a->object == self; } + +-(id) prop { + return _prop; +} +-(void) setProp:(id) newVal { + _prop = newVal; +} +-(void) setProp2:(CFTypeRef) newVal { + _prop = (id)CFBridgingRelease(CFRetain(newVal)); +} + +-(id) xpc_prop { + return _xpc_prop; +} +-(void) setXpc_prop:(xpc_object_t) newVal { + _xpc_prop = newVal; +} @end void NSLog(id, ...); @@ -47,3 +56,7 @@ int main (int argc, const char * argv[]) { } return 0; } + +void test(A *prevVal, A *newVal) { + prevVal = newVal; +} diff --git a/test/ARCMT/checking.m b/test/ARCMT/checking.m index cf7161187fb1..3ad911e10a8f 100644 --- a/test/ARCMT/checking.m +++ b/test/ARCMT/checking.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 %s +// RUN: %clang_cc1 -arcmt-check -verify -triple x86_64-apple-darwin10 -fblocks -Werror %s // DISABLE: mingw32 #if __has_feature(objc_arc) @@ -45,9 +45,9 @@ struct UnsafeS { }; @interface A : NSObject -- (id)retain; -- (id)retainCount; -- (id)autorelease; +- (id)retain; // expected-note {{declaration has been explicitly marked unavailable here}} +- (id)retainCount; // expected-note {{declaration has been explicitly marked unavailable here}} +- (id)autorelease; // expected-note 2 {{declaration has been explicitly marked unavailable here}} - (id)init; - (oneway void)release; - (void)dealloc; @@ -79,7 +79,8 @@ void test1(A *a, BOOL b, struct UnsafeS *unsafeS) { [a.delegate release]; // expected-error {{it is not safe to remove 'retain' message on the result of a 'delegate' message; the object that was passed to 'setDelegate:' may not be properly retained}} \ // expected-error {{ARC forbids explicit message send}} [unsafeS->unsafeObj retain]; // expected-error {{it is not safe to remove 'retain' message on an __unsafe_unretained type}} \ - // expected-error {{ARC forbids explicit message send}} + // expected-error {{ARC forbids explicit message send}} \ + // expected-error {{'retain' is unavailable}} id foo = [unsafeS->unsafeObj retain]; // no warning. [global_foo retain]; // expected-error {{it is not safe to remove 'retain' message on a global variable}} \ // expected-error {{ARC forbids explicit message send}} @@ -87,10 +88,16 @@ void test1(A *a, BOOL b, struct UnsafeS *unsafeS) { // expected-error {{ARC forbids explicit message send}} [a dealloc]; [a retain]; - [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} + [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} \ + // expected-error {{'retainCount' is unavailable}} [a release]; [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \ - // expected-error {{ARC forbids explicit message send}} + // expected-error {{ARC forbids explicit message send}} \ + // expected-error {{'autorelease' is unavailable}} + [a autorelease]; // expected-error {{it is not safe to remove an unused 'autorelease' message; its receiver may be destroyed immediately}} \ + // expected-error {{ARC forbids explicit message send}} \ + // expected-error {{'autorelease' is unavailable}} + a = 0; CFStringRef cfstr; NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ @@ -135,7 +142,7 @@ void rdar8861761() { - (void) noninit { self = 0; // expected-error {{cannot assign to 'self' outside of a method in the init family}} - for (id x in collection) { // expected-error {{use of undeclared identifier 'collection'}} + for (__strong id x in collection) { // expected-error {{use of undeclared identifier 'collection'}} x = 0; } } @@ -325,3 +332,13 @@ void rdar9504750(id p) { self->x = [NSObject new]; // expected-error {{assigning retained object}} } @end + +@interface Test10 : NSObject +@property (retain) id prop; +-(void)foo; +@end + +void test(Test10 *x) { + x.prop = ^{ [x foo]; }; // expected-warning {{likely to lead to a retain cycle}} \ + // expected-note {{retained by the captured object}} +} diff --git a/test/ARCMT/cxx-rewrite.mm.result b/test/ARCMT/cxx-rewrite.mm.result index a2dc9a51f006..7c944d5f240a 100644 --- a/test/ARCMT/cxx-rewrite.mm.result +++ b/test/ARCMT/cxx-rewrite.mm.result @@ -16,7 +16,7 @@ struct foo { [NSString string]; } } - ~foo(){ s; } + ~foo(){ } private: foo(foo const &); foo &operator=(foo const &); diff --git a/test/ARCMT/dispatch.m b/test/ARCMT/dispatch.m index 75c4a83459c7..58c7769638cb 100644 --- a/test/ARCMT/dispatch.m +++ b/test/ARCMT/dispatch.m @@ -4,17 +4,6 @@ #include "Common.h" -#define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; }) -#define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; }) -#define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; }) -#define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; }) - -typedef id dispatch_object_t; -typedef id xpc_object_t; - -void _dispatch_object_validate(dispatch_object_t object); -void _xpc_object_validate(xpc_object_t object); - dispatch_object_t getme(void); void func(dispatch_object_t o) { diff --git a/test/ARCMT/dispatch.m.result b/test/ARCMT/dispatch.m.result index e897672a264b..55b65585e4f6 100644 --- a/test/ARCMT/dispatch.m.result +++ b/test/ARCMT/dispatch.m.result @@ -4,17 +4,6 @@ #include "Common.h" -#define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; }) -#define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; }) -#define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; }) -#define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; }) - -typedef id dispatch_object_t; -typedef id xpc_object_t; - -void _dispatch_object_validate(dispatch_object_t object); -void _xpc_object_validate(xpc_object_t object); - dispatch_object_t getme(void); void func(dispatch_object_t o) { diff --git a/test/ARCMT/nonobjc-to-objc-cast-2.m b/test/ARCMT/nonobjc-to-objc-cast-2.m index 1ec0089f08e8..80d694e58680 100644 --- a/test/ARCMT/nonobjc-to-objc-cast-2.m +++ b/test/ARCMT/nonobjc-to-objc-cast-2.m @@ -3,16 +3,37 @@ #include "Common.h" -@interface NSString : NSObject --(id)string; --(id)newString; -@end - typedef const struct __CFString * CFStringRef; typedef const void * CFTypeRef; CFTypeRef CFBridgingRetain(id X); id CFBridgingRelease(CFTypeRef); +struct StrS { + CFStringRef sref_member; +}; + +@interface NSString : NSObject { + CFStringRef sref; + struct StrS *strS; +} +-(id)string; +-(id)newString; +@end + +@implementation NSString +-(id)string { + if (0) + return sref; + else + return strS->sref_member; +} +-(id)newString { + return sref; // expected-error {{implicit conversion of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'id' requires a bridged cast}} \ + // expected-note{{use __bridge to convert directly (no change in ownership)}} \ + // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} +} +@end + void f(BOOL b) { CFStringRef cfstr; NSString *str = (NSString *)cfstr; // expected-error {{cast of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ diff --git a/test/ARCMT/nonobjc-to-objc-cast.m b/test/ARCMT/nonobjc-to-objc-cast.m index fcdcd89c9c83..55b6655fa404 100644 --- a/test/ARCMT/nonobjc-to-objc-cast.m +++ b/test/ARCMT/nonobjc-to-objc-cast.m @@ -5,11 +5,6 @@ #include "Common.h" -@interface NSString : NSObject --(id)string; --(id)newString; -@end - typedef const struct __CFString * CFStringRef; extern const CFStringRef kUTTypePlainText; extern const CFStringRef kUTTypeRTF; @@ -21,6 +16,18 @@ extern const CFAllocatorRef kCFAllocatorDefault; extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); +struct StrS { + CFStringRef sref_member; +}; + +@interface NSString : NSObject { + CFStringRef sref; + struct StrS *strS; +} +-(id)string; +-(id)newString; +@end + void f(BOOL b, id p) { NSString *str = (NSString *)kUTTypePlainText; str = b ? kUTTypeRTF : kUTTypePlainText; @@ -41,6 +48,16 @@ void f(BOOL b, id p) { } @end +@implementation NSString +-(id)string { + if (0) + return sref; + else + return strS->sref_member; +} +-(id)newString { return 0; } +@end + extern void consumeParam(CFStringRef CF_CONSUMED p); void f2(NSString *s) { diff --git a/test/ARCMT/nonobjc-to-objc-cast.m.result b/test/ARCMT/nonobjc-to-objc-cast.m.result index b50a948e27ca..4f508f6adfb6 100644 --- a/test/ARCMT/nonobjc-to-objc-cast.m.result +++ b/test/ARCMT/nonobjc-to-objc-cast.m.result @@ -5,11 +5,6 @@ #include "Common.h" -@interface NSString : NSObject --(id)string; --(id)newString; -@end - typedef const struct __CFString * CFStringRef; extern const CFStringRef kUTTypePlainText; extern const CFStringRef kUTTypeRTF; @@ -21,6 +16,18 @@ extern const CFAllocatorRef kCFAllocatorDefault; extern CFStringRef CFUUIDCreateString(CFAllocatorRef alloc, CFUUIDRef uuid); +struct StrS { + CFStringRef sref_member; +}; + +@interface NSString : NSObject { + CFStringRef sref; + struct StrS *strS; +} +-(id)string; +-(id)newString; +@end + void f(BOOL b, id p) { NSString *str = (__bridge NSString *)kUTTypePlainText; str = (__bridge NSString *)(b ? kUTTypeRTF : kUTTypePlainText); @@ -28,9 +35,9 @@ void f(BOOL b, id p) { str = (NSString *)p; // no change. CFUUIDRef _uuid; - NSString *_uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid); - _uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, _uuid); - _uuidString = (__bridge_transfer NSString *)(CFRetain(_uuid)); + NSString *_uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid)); + _uuidString = (NSString *)CFBridgingRelease(CFUUIDCreateString(kCFAllocatorDefault, _uuid)); + _uuidString = CFBridgingRelease(CFRetain(_uuid)); } @implementation NSString (StrExt) @@ -41,22 +48,32 @@ void f(BOOL b, id p) { } @end +@implementation NSString +-(id)string { + if (0) + return (__bridge id)(sref); + else + return (__bridge id)(strS->sref_member); +} +-(id)newString { return 0; } +@end + extern void consumeParam(CFStringRef CF_CONSUMED p); void f2(NSString *s) { CFStringRef ref = (__bridge CFStringRef)([s string]); ref = (__bridge CFStringRef)[s string]; ref = (__bridge CFStringRef)(s.string); - ref = (__bridge_retained CFStringRef)([NSString new]); - ref = (__bridge_retained CFStringRef)([s newString]); - ref = (__bridge_retained CFStringRef)[NSString new]; - ref = (__bridge_retained CFStringRef)([[NSString alloc] init]); - ref = (__bridge_retained CFStringRef)([s string]); - ref = (__bridge_retained CFStringRef)[s string]; - ref = (__bridge_retained CFTypeRef)([s string]); - ref = (__bridge_retained CFTypeRef)(s); - ref = (__bridge_retained CFStringRef)(s); - - consumeParam((__bridge_retained CFStringRef)s); - consumeParam((__bridge_retained CFStringRef)(s)); + ref = CFBridgingRetain([NSString new]); + ref = CFBridgingRetain([s newString]); + ref = (CFStringRef)CFBridgingRetain([NSString new]); + ref = CFBridgingRetain([[NSString alloc] init]); + ref = CFBridgingRetain([s string]); + ref = (CFStringRef)CFBridgingRetain([s string]); + ref = CFBridgingRetain([s string]); + ref = CFBridgingRetain(s); + ref = CFBridgingRetain(s); + + consumeParam((CFStringRef)CFBridgingRetain(s)); + consumeParam(CFBridgingRetain(s)); } diff --git a/test/ARCMT/objcmt-boxing.m b/test/ARCMT/objcmt-boxing.m new file mode 100644 index 000000000000..2ad65a1399db --- /dev/null +++ b/test/ARCMT/objcmt-boxing.m @@ -0,0 +1,102 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result + +#define YES __objc_yes +#define NO __objc_no + +typedef long NSInteger; +typedef unsigned long NSUInteger; +typedef signed char BOOL; +#define nil ((void*) 0) + +#define INT_MIN (-__INT_MAX__ -1) + +@interface NSObject ++ (id)alloc; +@end + +@interface NSNumber : NSObject +@end + +@interface NSNumber (NSNumberCreation) +- (id)initWithChar:(char)value; +- (id)initWithUnsignedChar:(unsigned char)value; +- (id)initWithShort:(short)value; +- (id)initWithUnsignedShort:(unsigned short)value; +- (id)initWithInt:(int)value; +- (id)initWithUnsignedInt:(unsigned int)value; +- (id)initWithLong:(long)value; +- (id)initWithUnsignedLong:(unsigned long)value; +- (id)initWithLongLong:(long long)value; +- (id)initWithUnsignedLongLong:(unsigned long long)value; +- (id)initWithFloat:(float)value; +- (id)initWithDouble:(double)value; +- (id)initWithBool:(BOOL)value; +- (id)initWithInteger:(NSInteger)value; +- (id)initWithUnsignedInteger:(NSUInteger)value; + ++ (NSNumber *)numberWithChar:(char)value; ++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; ++ (NSNumber *)numberWithShort:(short)value; ++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; ++ (NSNumber *)numberWithInt:(int)value; ++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; ++ (NSNumber *)numberWithLong:(long)value; ++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; ++ (NSNumber *)numberWithLongLong:(long long)value; ++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; ++ (NSNumber *)numberWithFloat:(float)value; ++ (NSNumber *)numberWithDouble:(double)value; ++ (NSNumber *)numberWithBool:(BOOL)value; ++ (NSNumber *)numberWithInteger:(NSInteger)value; ++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; +@end + +enum { + NSASCIIStringEncoding = 1, + NSUTF8StringEncoding = 4, + NSUnicodeStringEncoding = 10 +}; +typedef NSUInteger NSStringEncoding; + +@interface NSString : NSObject +@end + +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; ++ (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc; ++ (id)stringWithCString:(const char *)bytes; +@end + +enum MyEnm { + ME_foo +}; + +void foo() { + [NSNumber numberWithInt:INT_MIN]; + bool cppb; + [NSNumber numberWithBool:cppb]; + MyEnm myenum; + [NSNumber numberWithInteger:myenum]; + [NSNumber numberWithInteger:ME_foo]; + [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires casting 'bool' to 'double'}} +} + +void boxString() { + NSString *s = [NSString stringWithUTF8String:"box"]; + const char *cstr1; + char *cstr2; + s = [NSString stringWithUTF8String:cstr1]; + s = [NSString stringWithUTF8String:cstr2]; + s = [NSString stringWithCString:cstr1 encoding:NSASCIIStringEncoding]; + s = [NSString stringWithCString:cstr1 encoding:NSUTF8StringEncoding]; + s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding]; + NSStringEncoding encode; + s = [NSString stringWithCString:cstr1 encoding:encode]; + s = [NSString stringWithCString:cstr1]; + + static const char strarr[] = "coolbox"; + s = [NSString stringWithUTF8String:strarr]; +} diff --git a/test/ARCMT/objcmt-boxing.m.result b/test/ARCMT/objcmt-boxing.m.result new file mode 100644 index 000000000000..f1019892ff37 --- /dev/null +++ b/test/ARCMT/objcmt-boxing.m.result @@ -0,0 +1,102 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ -verify +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result + +#define YES __objc_yes +#define NO __objc_no + +typedef long NSInteger; +typedef unsigned long NSUInteger; +typedef signed char BOOL; +#define nil ((void*) 0) + +#define INT_MIN (-__INT_MAX__ -1) + +@interface NSObject ++ (id)alloc; +@end + +@interface NSNumber : NSObject +@end + +@interface NSNumber (NSNumberCreation) +- (id)initWithChar:(char)value; +- (id)initWithUnsignedChar:(unsigned char)value; +- (id)initWithShort:(short)value; +- (id)initWithUnsignedShort:(unsigned short)value; +- (id)initWithInt:(int)value; +- (id)initWithUnsignedInt:(unsigned int)value; +- (id)initWithLong:(long)value; +- (id)initWithUnsignedLong:(unsigned long)value; +- (id)initWithLongLong:(long long)value; +- (id)initWithUnsignedLongLong:(unsigned long long)value; +- (id)initWithFloat:(float)value; +- (id)initWithDouble:(double)value; +- (id)initWithBool:(BOOL)value; +- (id)initWithInteger:(NSInteger)value; +- (id)initWithUnsignedInteger:(NSUInteger)value; + ++ (NSNumber *)numberWithChar:(char)value; ++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; ++ (NSNumber *)numberWithShort:(short)value; ++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; ++ (NSNumber *)numberWithInt:(int)value; ++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; ++ (NSNumber *)numberWithLong:(long)value; ++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; ++ (NSNumber *)numberWithLongLong:(long long)value; ++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; ++ (NSNumber *)numberWithFloat:(float)value; ++ (NSNumber *)numberWithDouble:(double)value; ++ (NSNumber *)numberWithBool:(BOOL)value; ++ (NSNumber *)numberWithInteger:(NSInteger)value; ++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; +@end + +enum { + NSASCIIStringEncoding = 1, + NSUTF8StringEncoding = 4, + NSUnicodeStringEncoding = 10 +}; +typedef NSUInteger NSStringEncoding; + +@interface NSString : NSObject +@end + +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; ++ (id)stringWithCString:(const char *)cString encoding:(NSStringEncoding)enc; ++ (id)stringWithCString:(const char *)bytes; +@end + +enum MyEnm { + ME_foo +}; + +void foo() { + @INT_MIN; + bool cppb; + @(cppb); + MyEnm myenum; + @(myenum); + @(ME_foo); + [NSNumber numberWithDouble:cppb]; // expected-warning {{converting to boxing syntax requires casting 'bool' to 'double'}} +} + +void boxString() { + NSString *s = @"box"; + const char *cstr1; + char *cstr2; + s = @(cstr1); + s = @(cstr2); + s = @(cstr1); + s = @(cstr1); + s = [NSString stringWithCString:cstr1 encoding: NSUnicodeStringEncoding]; + NSStringEncoding encode; + s = [NSString stringWithCString:cstr1 encoding:encode]; + s = @(cstr1); + + static const char strarr[] = "coolbox"; + s = @(strarr); +} diff --git a/test/ARCMT/objcmt-numeric-literals.m b/test/ARCMT/objcmt-numeric-literals.m index b86af4d056a1..7f33dc27997e 100644 --- a/test/ARCMT/objcmt-numeric-literals.m +++ b/test/ARCMT/objcmt-numeric-literals.m @@ -1,6 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result #define YES __objc_yes #define NO __objc_no diff --git a/test/ARCMT/objcmt-numeric-literals.m.result b/test/ARCMT/objcmt-numeric-literals.m.result index 1c4187aaef5c..bb7b515566d0 100644 --- a/test/ARCMT/objcmt-numeric-literals.m.result +++ b/test/ARCMT/objcmt-numeric-literals.m.result @@ -1,6 +1,7 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c++ // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c++ %s.result #define YES __objc_yes #define NO __objc_no @@ -467,7 +468,7 @@ void foo() { [NSNumber numberWithInteger:NO]; [NSNumber numberWithInteger:true]; [NSNumber numberWithInteger:false]; - [NSNumber numberWithInteger:VAL_INT]; + @VAL_INT; [NSNumber numberWithInteger:VAL_UINT]; [NSNumber numberWithUnsignedInteger:'a']; @@ -497,5 +498,5 @@ void foo() { [NSNumber numberWithUnsignedInteger:true]; [NSNumber numberWithUnsignedInteger:false]; [NSNumber numberWithUnsignedInteger:VAL_INT]; - [NSNumber numberWithUnsignedInteger:VAL_UINT]; + @VAL_UINT; } diff --git a/test/ARCMT/objcmt-subscripting-literals-in-arc.m b/test/ARCMT/objcmt-subscripting-literals-in-arc.m new file mode 100644 index 000000000000..4d941626c0d0 --- /dev/null +++ b/test/ARCMT/objcmt-subscripting-literals-in-arc.m @@ -0,0 +1,106 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -fobjc-arc -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result + +typedef signed char BOOL; +#define nil ((void*) 0) + +typedef const struct __CFString * CFStringRef; + +@interface NSObject ++ (id)alloc; +@end + +@protocol NSCopying +@end + +@interface NSString : NSObject ++ (id)stringWithString:(NSString *)string; +- (id)initWithString:(NSString *)aString; +@end + +@interface NSArray : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; +@end + +@interface NSArray (NSArrayCreation) ++ (id)array; ++ (id)arrayWithObject:(id)anObject; ++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; ++ (id)arrayWithObjects:(id)firstObj, ...; ++ (id)arrayWithArray:(NSArray *)array; + +- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; +- (id)initWithObjects:(id)firstObj, ...; +- (id)initWithArray:(NSArray *)array; +@end + +@interface NSMutableArray : NSArray +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; +@end + +@interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) +- (id)objectForKeyedSubscript:(id)key; +@end + +@interface NSDictionary (NSDictionaryCreation) ++ (id)dictionary; ++ (id)dictionaryWithObject:(id)object forKey:(id)key; ++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; ++ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; ++ (id)dictionaryWithDictionary:(NSDictionary *)dict; ++ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; + +- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; +- (id)initWithObjectsAndKeys:(id)firstObject, ...; +- (id)initWithDictionary:(NSDictionary *)otherDictionary; +- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; +@end + +@interface NSMutableDictionary : NSDictionary +- (void)setObject:(id)anObject forKey:(id)aKey; +@end + +@interface NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; +@end + +@interface NSNumber : NSObject +@end + +@interface NSNumber (NSNumberCreation) ++ (NSNumber *)numberWithInt:(int)value; +- (id)initWithInt:(int)value; +@end + +@interface I { + NSArray *ivarArr; +} +@end +@implementation I +-(void) foo { + NSString *str; + NSArray *arr; + NSDictionary *dict; + + arr = [NSArray arrayWithObjects:str, str, nil]; + arr = [[NSArray alloc] initWithObjects:str, str, nil]; + dict = [NSDictionary dictionaryWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil]; + dict = [[NSDictionary alloc] initWithObjectsAndKeys: @"value1", @"key1", @"value2", @"key2", nil]; + + NSNumber *n = [[NSNumber alloc] initWithInt:2]; +} +@end diff --git a/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result b/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result new file mode 100644 index 000000000000..6f7a723bc473 --- /dev/null +++ b/test/ARCMT/objcmt-subscripting-literals-in-arc.m.result @@ -0,0 +1,106 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fobjc-arc -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -fobjc-arc -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result + +typedef signed char BOOL; +#define nil ((void*) 0) + +typedef const struct __CFString * CFStringRef; + +@interface NSObject ++ (id)alloc; +@end + +@protocol NSCopying +@end + +@interface NSString : NSObject ++ (id)stringWithString:(NSString *)string; +- (id)initWithString:(NSString *)aString; +@end + +@interface NSArray : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; +@end + +@interface NSArray (NSArrayCreation) ++ (id)array; ++ (id)arrayWithObject:(id)anObject; ++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; ++ (id)arrayWithObjects:(id)firstObj, ...; ++ (id)arrayWithArray:(NSArray *)array; + +- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; +- (id)initWithObjects:(id)firstObj, ...; +- (id)initWithArray:(NSArray *)array; +@end + +@interface NSMutableArray : NSArray +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; +@end + +@interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) +- (id)objectForKeyedSubscript:(id)key; +@end + +@interface NSDictionary (NSDictionaryCreation) ++ (id)dictionary; ++ (id)dictionaryWithObject:(id)object forKey:(id)key; ++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; ++ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; ++ (id)dictionaryWithDictionary:(NSDictionary *)dict; ++ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; + +- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; +- (id)initWithObjectsAndKeys:(id)firstObject, ...; +- (id)initWithDictionary:(NSDictionary *)otherDictionary; +- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; +@end + +@interface NSMutableDictionary : NSDictionary +- (void)setObject:(id)anObject forKey:(id)aKey; +@end + +@interface NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; +@end + +@interface NSNumber : NSObject +@end + +@interface NSNumber (NSNumberCreation) ++ (NSNumber *)numberWithInt:(int)value; +- (id)initWithInt:(int)value; +@end + +@interface I { + NSArray *ivarArr; +} +@end +@implementation I +-(void) foo { + NSString *str; + NSArray *arr; + NSDictionary *dict; + + arr = @[str, str]; + arr = @[str, str]; + dict = @{@"key1": @"value1", @"key2": @"value2"}; + dict = @{@"key1": @"value1", @"key2": @"value2"}; + + NSNumber *n = @2; +} +@end diff --git a/test/ARCMT/objcmt-subscripting-literals.m b/test/ARCMT/objcmt-subscripting-literals.m index 3d26efefda82..0174fcf060e9 100644 --- a/test/ARCMT/objcmt-subscripting-literals.m +++ b/test/ARCMT/objcmt-subscripting-literals.m @@ -1,14 +1,20 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result typedef signed char BOOL; #define nil ((void*) 0) +typedef const struct __CFString * CFStringRef; + @interface NSObject + (id)alloc; @end +@protocol NSCopying +@end + @interface NSString : NSObject + (id)stringWithString:(NSString *)string; - (id)initWithString:(NSString *)aString; @@ -16,7 +22,10 @@ typedef signed char BOOL; @interface NSArray : NSObject - (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; @end @interface NSArray (NSArrayCreation) @@ -29,16 +38,21 @@ typedef signed char BOOL; - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; - (id)initWithObjects:(id)firstObj, ...; - (id)initWithArray:(NSArray *)array; - -- (id)objectAtIndex:(unsigned long)index; @end @interface NSMutableArray : NSArray - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -- (void)setObject:(id)object atIndexedSubscript:(int)index; +@end + +@interface NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; @end @interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) - (id)objectForKeyedSubscript:(id)key; @end @@ -54,13 +68,14 @@ typedef signed char BOOL; - (id)initWithObjectsAndKeys:(id)firstObject, ...; - (id)initWithDictionary:(NSDictionary *)otherDictionary; - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; @end @interface NSMutableDictionary : NSDictionary - (void)setObject:(id)anObject forKey:(id)aKey; -- (void)setObject:(id)object forKeyedSubscript:(id)key; +@end + +@interface NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; @end @interface NSNumber : NSObject @@ -74,7 +89,9 @@ typedef signed char BOOL; #define PAIR(x) @#x, [NSNumber numberWithInt:(x)] #define TWO(x) ((x), (x)) -@interface I +@interface I { + NSArray *ivarArr; +} @end @implementation I -(void) foo { @@ -133,5 +150,74 @@ typedef signed char BOOL; [mdict setObject:[dict objectForKey:@"key1"] forKey:[dict objectForKey:[NSArray arrayWithObject:@"arrkey"]]]; __strong NSArray **parr = 0; o = [*parr objectAtIndex:2]; + void *hd; + o = [(NSArray*)hd objectAtIndex:2]; + o = [ivarArr objectAtIndex:2]; +} +@end + +extern const CFStringRef globStr; + +void test1(NSString *str) { + NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: str, globStr, nil]; + dict = [NSDictionary dictionaryWithObjectsAndKeys: globStr, str, nil]; + dict = [NSDictionary dictionaryWithObject:str forKey:globStr]; + dict = [NSDictionary dictionaryWithObject:globStr forKey:str]; + + NSArray *arr = [NSArray arrayWithObjects: globStr, globStr, nil]; + arr = [NSArray arrayWithObjects: str, globStr, nil]; + arr = [NSArray arrayWithObjects: globStr, str, nil]; + arr = [NSArray arrayWithObject:globStr]; +} + +@interface Custom : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface Custom (Extended) +- (id)objectAtIndexedSubscript:(unsigned)idx; +@end + +@interface MutableCustom : Custom +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface MutableCustom (Extended) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; +@end + +@interface CustomUnavail : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface CustomUnavail (Extended) +- (id)objectAtIndexedSubscript:(unsigned)idx __attribute__((unavailable)); +@end + +@interface MutableCustomUnavail : CustomUnavail +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface MutableCustomUnavail (Extended) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx __attribute__((unavailable)); +@end + +void test2() { + MutableCustom *mutc; + id o = [mutc objectAtIndex:4]; + [mutc replaceObjectAtIndex:2 withObject:@"val"]; + + MutableCustomUnavail *mutcunaval; + o = [mutcunaval objectAtIndex:4]; + [mutcunaval replaceObjectAtIndex:2 withObject:@"val"]; } + +@interface NSLocale : NSObject ++ (id)systemLocale; ++ (id)currentLocale; +- (id)objectForKey:(id)key; @end + +void test3(id key) { + id o = [[NSLocale currentLocale] objectForKey:key]; +} diff --git a/test/ARCMT/objcmt-subscripting-literals.m.result b/test/ARCMT/objcmt-subscripting-literals.m.result index 8ac6dcc20751..9975996524bd 100644 --- a/test/ARCMT/objcmt-subscripting-literals.m.result +++ b/test/ARCMT/objcmt-subscripting-literals.m.result @@ -1,14 +1,20 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 // RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result typedef signed char BOOL; #define nil ((void*) 0) +typedef const struct __CFString * CFStringRef; + @interface NSObject + (id)alloc; @end +@protocol NSCopying +@end + @interface NSString : NSObject + (id)stringWithString:(NSString *)string; - (id)initWithString:(NSString *)aString; @@ -16,7 +22,10 @@ typedef signed char BOOL; @interface NSArray : NSObject - (id)objectAtIndex:(unsigned long)index; -- (id)objectAtIndexedSubscript:(int)index; +@end + +@interface NSArray (NSExtendedArray) +- (id)objectAtIndexedSubscript:(unsigned)idx; @end @interface NSArray (NSArrayCreation) @@ -29,16 +38,21 @@ typedef signed char BOOL; - (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; - (id)initWithObjects:(id)firstObj, ...; - (id)initWithArray:(NSArray *)array; - -- (id)objectAtIndex:(unsigned long)index; @end @interface NSMutableArray : NSArray - (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; -- (void)setObject:(id)object atIndexedSubscript:(int)index; +@end + +@interface NSMutableArray (NSExtendedMutableArray) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; @end @interface NSDictionary : NSObject +- (id)objectForKey:(id)aKey; +@end + +@interface NSDictionary (NSExtendedDictionary) - (id)objectForKeyedSubscript:(id)key; @end @@ -54,13 +68,14 @@ typedef signed char BOOL; - (id)initWithObjectsAndKeys:(id)firstObject, ...; - (id)initWithDictionary:(NSDictionary *)otherDictionary; - (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; - -- (id)objectForKey:(id)aKey; @end @interface NSMutableDictionary : NSDictionary - (void)setObject:(id)anObject forKey:(id)aKey; -- (void)setObject:(id)object forKeyedSubscript:(id)key; +@end + +@interface NSMutableDictionary (NSExtendedMutableDictionary) +- (void)setObject:(id)obj forKeyedSubscript:(id <NSCopying>)key; @end @interface NSNumber : NSObject @@ -74,7 +89,9 @@ typedef signed char BOOL; #define PAIR(x) @#x, [NSNumber numberWithInt:(x)] #define TWO(x) ((x), (x)) -@interface I +@interface I { + NSArray *ivarArr; +} @end @implementation I -(void) foo { @@ -133,5 +150,74 @@ typedef signed char BOOL; mdict[dict[@[@"arrkey"]]] = dict[@"key1"]; __strong NSArray **parr = 0; o = (*parr)[2]; + void *hd; + o = ((NSArray*)hd)[2]; + o = ivarArr[2]; +} +@end + +extern const CFStringRef globStr; + +void test1(NSString *str) { + NSDictionary *dict = @{(id)globStr: str}; + dict = @{str: (id)globStr}; + dict = @{(id)globStr: str}; + dict = @{str: (id)globStr}; + + NSArray *arr = @[(id)globStr, (id)globStr]; + arr = @[str, (id)globStr]; + arr = @[(id)globStr, str]; + arr = @[(id)globStr]; +} + +@interface Custom : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface Custom (Extended) +- (id)objectAtIndexedSubscript:(unsigned)idx; +@end + +@interface MutableCustom : Custom +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface MutableCustom (Extended) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx; +@end + +@interface CustomUnavail : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface CustomUnavail (Extended) +- (id)objectAtIndexedSubscript:(unsigned)idx __attribute__((unavailable)); +@end + +@interface MutableCustomUnavail : CustomUnavail +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface MutableCustomUnavail (Extended) +- (void)setObject:(id)obj atIndexedSubscript:(unsigned)idx __attribute__((unavailable)); +@end + +void test2() { + MutableCustom *mutc; + id o = mutc[4]; + mutc[2] = @"val"; + + MutableCustomUnavail *mutcunaval; + o = [mutcunaval objectAtIndex:4]; + [mutcunaval replaceObjectAtIndex:2 withObject:@"val"]; } + +@interface NSLocale : NSObject ++ (id)systemLocale; ++ (id)currentLocale; +- (id)objectForKey:(id)key; @end + +void test3(id key) { + id o = [[NSLocale currentLocale] objectForKey:key]; +} diff --git a/test/ARCMT/objcmt-subscripting-unavailable.m b/test/ARCMT/objcmt-subscripting-unavailable.m new file mode 100644 index 000000000000..d72c362e30f4 --- /dev/null +++ b/test/ARCMT/objcmt-subscripting-unavailable.m @@ -0,0 +1,79 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result + +typedef signed char BOOL; +#define nil ((void*) 0) + +@interface NSObject ++ (id)alloc; +@end + +@interface NSArray : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface NSArray (NSArrayCreation) ++ (id)array; ++ (id)arrayWithObject:(id)anObject; ++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; ++ (id)arrayWithObjects:(id)firstObj, ...; ++ (id)arrayWithArray:(NSArray *)array; + +- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; +- (id)initWithObjects:(id)firstObj, ...; +- (id)initWithArray:(NSArray *)array; +@end + +@interface NSMutableArray : NSArray +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface NSDictionary : NSObject +@end + +@interface NSDictionary (NSDictionaryCreation) ++ (id)dictionary; ++ (id)dictionaryWithObject:(id)object forKey:(id)key; ++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; ++ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; ++ (id)dictionaryWithDictionary:(NSDictionary *)dict; ++ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; + +- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; +- (id)initWithObjectsAndKeys:(id)firstObject, ...; +- (id)initWithDictionary:(NSDictionary *)otherDictionary; +- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; + +- (id)objectForKey:(id)aKey; +@end + +@interface NSMutableDictionary : NSDictionary +- (void)setObject:(id)anObject forKey:(id)aKey; +@end + +@interface I +@end +@implementation I +-(void) foo { + id str; + NSArray *arr; + NSDictionary *dict; + + arr = [NSArray array]; + arr = [NSArray arrayWithObject:str]; + arr = [NSArray arrayWithObjects:str, str, nil]; + dict = [NSDictionary dictionary]; + dict = [NSDictionary dictionaryWithObject:arr forKey:str]; + + id o = [arr objectAtIndex:2]; + o = [dict objectForKey:@"key"]; + NSMutableArray *marr = 0; + NSMutableDictionary *mdict = 0; + [marr replaceObjectAtIndex:2 withObject:@"val"]; + [mdict setObject:@"value" forKey:@"key"]; + [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]]; + [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"]; +} +@end diff --git a/test/ARCMT/objcmt-subscripting-unavailable.m.result b/test/ARCMT/objcmt-subscripting-unavailable.m.result new file mode 100644 index 000000000000..bd74d5583860 --- /dev/null +++ b/test/ARCMT/objcmt-subscripting-unavailable.m.result @@ -0,0 +1,79 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -objcmt-migrate-literals -objcmt-migrate-subscripting -mt-migrate-directory %t %s -x objective-c -triple x86_64-apple-darwin11 +// RUN: c-arcmt-test -mt-migrate-directory %t | arcmt-test -verify-transformed-files %s.result +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c %s.result + +typedef signed char BOOL; +#define nil ((void*) 0) + +@interface NSObject ++ (id)alloc; +@end + +@interface NSArray : NSObject +- (id)objectAtIndex:(unsigned long)index; +@end + +@interface NSArray (NSArrayCreation) ++ (id)array; ++ (id)arrayWithObject:(id)anObject; ++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; ++ (id)arrayWithObjects:(id)firstObj, ...; ++ (id)arrayWithArray:(NSArray *)array; + +- (id)initWithObjects:(const id [])objects count:(unsigned long)cnt; +- (id)initWithObjects:(id)firstObj, ...; +- (id)initWithArray:(NSArray *)array; +@end + +@interface NSMutableArray : NSArray +- (void)replaceObjectAtIndex:(unsigned long)index withObject:(id)anObject; +@end + +@interface NSDictionary : NSObject +@end + +@interface NSDictionary (NSDictionaryCreation) ++ (id)dictionary; ++ (id)dictionaryWithObject:(id)object forKey:(id)key; ++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; ++ (id)dictionaryWithObjectsAndKeys:(id)firstObject, ...; ++ (id)dictionaryWithDictionary:(NSDictionary *)dict; ++ (id)dictionaryWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; + +- (id)initWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; +- (id)initWithObjectsAndKeys:(id)firstObject, ...; +- (id)initWithDictionary:(NSDictionary *)otherDictionary; +- (id)initWithObjects:(NSArray *)objects forKeys:(NSArray *)keys; + +- (id)objectForKey:(id)aKey; +@end + +@interface NSMutableDictionary : NSDictionary +- (void)setObject:(id)anObject forKey:(id)aKey; +@end + +@interface I +@end +@implementation I +-(void) foo { + id str; + NSArray *arr; + NSDictionary *dict; + + arr = @[]; + arr = @[str]; + arr = @[str, str]; + dict = @{}; + dict = @{str: arr}; + + id o = [arr objectAtIndex:2]; + o = [dict objectForKey:@"key"]; + NSMutableArray *marr = 0; + NSMutableDictionary *mdict = 0; + [marr replaceObjectAtIndex:2 withObject:@"val"]; + [mdict setObject:@"value" forKey:@"key"]; + [marr replaceObjectAtIndex:2 withObject:[arr objectAtIndex:4]]; + [mdict setObject:[dict objectForKey:@"key2"] forKey:@"key"]; +} +@end diff --git a/test/ARCMT/releases-driver.m b/test/ARCMT/releases-driver.m index b75432ac2318..7b1d2fb8e5b2 100644 --- a/test/ARCMT/releases-driver.m +++ b/test/ARCMT/releases-driver.m @@ -53,9 +53,8 @@ void func(Foo *p) { @end @implementation Baz -- dealloc { +- (void) dealloc { [_foo release]; - return 0; } @end diff --git a/test/ARCMT/releases-driver.m.result b/test/ARCMT/releases-driver.m.result index 70c0aecaf475..4c864bd2a874 100644 --- a/test/ARCMT/releases-driver.m.result +++ b/test/ARCMT/releases-driver.m.result @@ -49,9 +49,6 @@ void func(Foo *p) { @end @implementation Baz -- dealloc { - return 0; -} @end #define RELEASE_MACRO(x) [x release] diff --git a/test/ARCMT/releases.m b/test/ARCMT/releases.m index 867fab9cec74..55008959efc4 100644 --- a/test/ARCMT/releases.m +++ b/test/ARCMT/releases.m @@ -58,9 +58,8 @@ void func(Foo *p) { @end @implementation Baz -- dealloc { +- (void) dealloc { [_foo release]; - return 0; } @end diff --git a/test/ARCMT/releases.m.result b/test/ARCMT/releases.m.result index 556610ab2a53..473750e4e899 100644 --- a/test/ARCMT/releases.m.result +++ b/test/ARCMT/releases.m.result @@ -54,9 +54,6 @@ void func(Foo *p) { @end @implementation Baz -- dealloc { - return 0; -} @end void block_test(Foo *p) { diff --git a/test/ARCMT/verify.m b/test/ARCMT/verify.m new file mode 100644 index 000000000000..9110fe6efae2 --- /dev/null +++ b/test/ARCMT/verify.m @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -arcmt-check -verify %s +// RUN: %clang_cc1 -arcmt-check -verify %t.invalid 2>&1 | FileCheck %s + +#if 0 +// expected-error {{should be ignored}} +#endif + +#error should not be ignored +// expected-error@-1 {{should not be ignored}} + +// CHECK: error: 'error' diagnostics seen but not expected: +// CHECK-NEXT: (frontend): error reading '{{.*}}verify.m.tmp.invalid' +// CHECK-NEXT: 1 error generated. diff --git a/test/ASTMerge/function.c b/test/ASTMerge/function.c index f97eceed9866..320bca2a36f1 100644 --- a/test/ASTMerge/function.c +++ b/test/ASTMerge/function.c @@ -1,9 +1,15 @@ // RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/function1.c // RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/function2.c // RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only -verify %s // CHECK: function2.c:3:6: error: external function 'f1' declared with incompatible types in different translation units ('void (Int, double)' vs. 'void (int, float)') // CHECK: function1.c:2:6: note: declared here with type 'void (int, float)' // CHECK: function2.c:5:6: error: external function 'f3' declared with incompatible types in different translation units ('void (int)' vs. 'void (void)') // CHECK: function1.c:4:6: note: declared here with type 'void (void)' // CHECK: 2 errors generated + +// expected-error@3 {{external function 'f1' declared with incompatible types}} +// expected-note@2 {{declared here}} +// expected-error@5 {{external function 'f3' declared with incompatible types}} +// expected-note@4 {{declared here}} diff --git a/test/Analysis/MissingDealloc.m b/test/Analysis/MissingDealloc.m index 51a5912d4443..589fcf57f40c 100644 --- a/test/Analysis/MissingDealloc.m +++ b/test/Analysis/MissingDealloc.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.osx.cocoa.Dealloc '-DIBOutlet=__attribute__((iboutlet))' %s -verify +// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.osx.cocoa.Dealloc %s -verify typedef signed char BOOL; @protocol NSObject - (BOOL)isEqual:(id)object; @@ -53,10 +53,6 @@ typedef struct objc_selector *SEL; //===------------------------------------------------------------------------=== // Don't warn about iVars that are IBOutlets. -#ifndef IBOutlet -#define IBOutlet -#endif - @class NSWindow; @interface HasOutlet : NSObject { diff --git a/test/Analysis/NoReturn.m b/test/Analysis/NoReturn.m index ea2efd061711..1d948fa66f6d 100644 --- a/test/Analysis/NoReturn.m +++ b/test/Analysis/NoReturn.m @@ -76,3 +76,15 @@ int f3(int* x) { 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 +} + diff --git a/test/Analysis/PR12905.c b/test/Analysis/PR12905.c new file mode 100644 index 000000000000..8f678d114472 --- /dev/null +++ b/test/Analysis/PR12905.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core %s +// PR12905 + +void C(void); + +void t(void) { + C(); +} diff --git a/test/Analysis/additive-folding-range-constraints.c b/test/Analysis/additive-folding-range-constraints.c index 32e0cfe142ad..7eb55ab1e125 100644 --- a/test/Analysis/additive-folding-range-constraints.c +++ b/test/Analysis/additive-folding-range-constraints.c @@ -1,53 +1,37 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -verify -analyzer-constraints=range %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -analyzer-constraints=range %s + +void clang_analyzer_eval(int); + +#define UINT_MAX (~0U) +#define INT_MAX (UINT_MAX & (UINT_MAX >> 1)) +#define INT_MIN (-INT_MAX - 1) -// These are used to trigger warnings. -typedef typeof(sizeof(int)) size_t; -void *malloc(size_t); -void free(void *); -#define NULL ((void*)0) -#define UINT_MAX (__INT_MAX__ *2U +1U) // 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) { - char* b = NULL; if (a+2 > 1) - b = malloc(1); - if (a == UINT_MAX-1 || a == UINT_MAX) - return; // no-warning - else if (a < UINT_MAX-1) - free(b); - return; // no-warning + 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) { - char* b = NULL; if (a+2 >= 1) - b = malloc(1); - if (a == UINT_MAX-1) - return; // no-warning - else if (a < UINT_MAX-1 || a == UINT_MAX) - free(b); - return; // no-warning + 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) { - char* b = NULL; if (a+1 < 2) - b = malloc(1); - if (a == 0 || a == UINT_MAX) - free(b); - return; // no-warning + clang_analyzer_eval(a == 0 || a == UINT_MAX); // expected-warning{{TRUE}} } void smallAdjustmentLE (unsigned a) { - char* b = NULL; if (a+1 <= 2) - b = malloc(1); - if (a == 0 || a == 1 || a == UINT_MAX) - free(b); - return; // no-warning + clang_analyzer_eval(a == 0 || a == 1 || a == UINT_MAX); // expected-warning{{TRUE}} } @@ -55,45 +39,134 @@ void smallAdjustmentLE (unsigned a) { // comparison value over an overflow boundary (Min for <, Max for >). // This corresponds to one set of branches in RangeConstraintManager. void largeAdjustmentGT (unsigned a) { - char* b = NULL; if (a-2 > UINT_MAX-1) - b = malloc(1); - if (a == 1 || a == 0) - free(b); - else if (a > 1) - free(b); - return; // no-warning + clang_analyzer_eval(a == 1); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a != 1); // expected-warning{{TRUE}} } void largeAdjustmentGE (unsigned a) { - char* b = NULL; if (a-2 >= UINT_MAX-1) - b = malloc(1); - if (a > 1) - return; // no-warning - else if (a == 1 || a == 0) - free(b); - return; // no-warning + clang_analyzer_eval(a == 1 || a == 0); // expected-warning{{TRUE}} + else + clang_analyzer_eval(a > 1); // expected-warning{{TRUE}} } void largeAdjustmentLT (unsigned a) { - char* b = NULL; if (a+2 < 1) - b = malloc(1); - if (a == UINT_MAX-1 || a == UINT_MAX) - free(b); - else if (a < UINT_MAX-1) - return; // no-warning - return; // no-warning + 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) { - char* b = NULL; if (a+2 <= 1) - b = malloc(1); - if (a < UINT_MAX-1) - return; // no-warning - else if (a == UINT_MAX-1 || a == UINT_MAX) - free(b); - return; // no-warning + 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}} } diff --git a/test/Analysis/additive-folding.c b/test/Analysis/additive-folding.c deleted file mode 100644 index beb08aa59c2f..000000000000 --- a/test/Analysis/additive-folding.c +++ /dev/null @@ -1,203 +0,0 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=basic %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,unix.Malloc -verify -analyzer-constraints=range %s - -// These are used to trigger warnings. -typedef typeof(sizeof(int)) size_t; -void *malloc(size_t); -void free(void *); -#define NULL ((void*)0) -#define UINT_MAX -1U - -//--------------- -// Plus/minus -//--------------- - -void separateExpressions (int a) { - int b = a + 1; - --b; - - char* buf = malloc(1); - if (a != 0 && b == 0) - return; // expected-warning{{never executed}} - free(buf); -} - -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; - - char* buf = malloc(1); - if (a != 0 && b == 0) - return; // expected-warning{{never executed}} - free(buf); -} - -void mixedTypes (int a) { - char* buf = malloc(1); - - // Different additive types should not cause crashes when constant-folding. - // This is part of PR7406. - int b = a + 1LL; - if (a != 0 && (b-1) == 0) // not crash - return; // expected-warning{{never executed}} - - int c = a + 1U; - if (a != 0 && (c-1) == 0) // not crash - return; // expected-warning{{never executed}} - - free(buf); -} - -//--------------- -// Comparisons -//--------------- - -// Equality and inequality only -void eq_ne (unsigned a) { - char* b = NULL; - if (a == UINT_MAX) - b = malloc(1); - if (a+1 != 0) - return; // no-warning - if (a-1 != UINT_MAX-1) - return; // no-warning - free(b); -} - -void ne_eq (unsigned a) { - char* b = NULL; - if (a != UINT_MAX) - b = malloc(1); - if (a+1 == 0) - return; // no-warning - if (a-1 == UINT_MAX-1) - return; // no-warning - free(b); -} - -// Mixed typed inequalities (part of PR7406) -// These should not crash. -void mixed_eq_ne (int a) { - char* b = NULL; - if (a == 1) - b = malloc(1); - if (a+1U != 2) - return; // no-warning - if (a-1U != 0) - return; // expected-warning{{never executed}} - free(b); -} - -void mixed_ne_eq (int a) { - char* b = NULL; - if (a != 1) - b = malloc(1); - if (a+1U == 2) - return; // no-warning - if (a-1U == 0) - return; // expected-warning{{never executed}} - free(b); -} - - -// Simple order comparisons with no adjustment -void baselineGT (unsigned a) { - char* b = NULL; - if (a > 0) - b = malloc(1); - if (a == 0) - return; // no-warning - free(b); -} - -void baselineGE (unsigned a) { - char* b = NULL; - if (a >= UINT_MAX) - b = malloc(1); - if (a == UINT_MAX) - free(b); - return; // no-warning -} - -void baselineLT (unsigned a) { - char* b = NULL; - if (a < UINT_MAX) - b = malloc(1); - if (a == UINT_MAX) - return; // no-warning - free(b); -} - -void baselineLE (unsigned a) { - char* b = NULL; - if (a <= 0) - b = malloc(1); - if (a == 0) - free(b); - return; // no-warning -} - - -// Adjustment gives each of these an extra solution! -void adjustedGT (unsigned a) { - char* b = NULL; - if (a-1 > UINT_MAX-1) - b = malloc(1); - return; // expected-warning{{leak}} -} - -void adjustedGE (unsigned a) { - char* b = NULL; - if (a-1 >= UINT_MAX-1) - b = malloc(1); - if (a == UINT_MAX) - free(b); - return; // expected-warning{{leak}} -} - -void adjustedLT (unsigned a) { - char* b = NULL; - if (a+1 < 1) - b = malloc(1); - return; // expected-warning{{leak}} -} - -void adjustedLE (unsigned a) { - char* b = NULL; - if (a+1 <= 1) - b = malloc(1); - if (a == 0) - free(b); - return; // expected-warning{{leak}} -} - - -// Tautologies -void tautologyGT (unsigned a) { - char* b = malloc(1); - if (a > UINT_MAX) - return; // no-warning - free(b); -} - -void tautologyGE (unsigned a) { - char* b = malloc(1); - if (a >= 0) // expected-warning{{always true}} - free(b); - return; // no-warning -} - -void tautologyLT (unsigned a) { - char* b = malloc(1); - if (a < 0) // expected-warning{{always false}} - return; // expected-warning{{never executed}} - free(b); -} - -void tautologyLE (unsigned a) { - char* b = malloc(1); - if (a <= UINT_MAX) - free(b); - return; // no-warning -} diff --git a/test/Analysis/additive-folding.cpp b/test/Analysis/additive-folding.cpp new file mode 100644 index 000000000000..0d749ec3cbaf --- /dev/null +++ b/test/Analysis/additive-folding.cpp @@ -0,0 +1,196 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -analyzer-constraints=basic -Wno-tautological-compare %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify -analyzer-constraints=range -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 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/test/Analysis/array-struct-region.c b/test/Analysis/array-struct-region.c index 4b085c8d7002..244bc977b511 100644 --- a/test/Analysis/array-struct-region.c +++ b/test/Analysis/array-struct-region.c @@ -1,32 +1,28 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,experimental.deadcode.UnreachableCode -analyzer-store=region -analyzer-constraints=basic -verify %s -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,experimental.deadcode.UnreachableCode -analyzer-store=region -analyzer-constraints=range -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,debug.ExprInspection -analyzer-store=region -analyzer-constraints=basic -analyzer-ipa=inlining -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,debug.ExprInspection -analyzer-store=region -analyzer-constraints=range -analyzer-ipa=inlining -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"; - if (a[1] != 'b') - return 0; // expected-warning{{never executed}} - if (b[1] != 'b') - return 0; // expected-warning{{never executed}} - if (c[1] != 'b') - return 0; // expected-warning{{never executed}} + 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}} - if (a[3] != 0) - return 0; // expected-warning{{never executed}} - if (c[3] != 0) - return 0; // expected-warning{{never executed}} + clang_analyzer_eval(a[3] == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(c[3] == 0); // expected-warning{{TRUE}} - if (c[4] != 0) - return 0; // expected-warning{{never executed}} + 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 turns literal floating-point number into integer}} - {0.831, 0.45}, {0.924, 0.617}, {0.98, 0.805}}; // expected-warning 6 {{implicit conversion turns literal floating-point number into integer}} + 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) { @@ -45,3 +41,146 @@ void nested_compound_literals_float(float rad) { 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 +} + + diff --git a/test/Analysis/auto-obj-dtors-cfg-output.cpp b/test/Analysis/auto-obj-dtors-cfg-output.cpp index 67a8f2e555bd..566e6caed60d 100644 --- a/test/Analysis/auto-obj-dtors-cfg-output.cpp +++ b/test/Analysis/auto-obj-dtors-cfg-output.cpp @@ -416,121 +416,121 @@ void test_catch_copy() { // CHECK: [B6 (ENTRY)] // CHECK: Succs (1): B5 // CHECK: [B1] -// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 1: [B4.4].~A() (Implicit destructor) // CHECK: 2: [B5.2].~A() (Implicit destructor) -// CHECK: Preds (1): B2 +// CHECK: Preds (1): B4 // CHECK: Succs (1): B0 // CHECK: [B2] -// CHECK: 1: a -// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A) -// CHECK: 3: [B2.2] (CXXConstructExpr, class A) -// CHECK: 4: A b = a; -// CHECK: 5: b -// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A) -// CHECK: 7: [B2.6].operator int -// CHECK: 8: [B2.7]() -// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int) -// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) -// CHECK: T: while [B2.10] -// CHECK: Preds (2): B3 B5 -// CHECK: Succs (2): B4 B1 +// CHECK: Preds (1): B3 +// CHECK: Succs (1): B4 // CHECK: [B3] +// CHECK: 1: (CXXConstructExpr, class A) +// CHECK: 2: A c; +// CHECK: 3: [B3.2].~A() (Implicit destructor) +// CHECK: 4: [B4.4].~A() (Implicit destructor) // CHECK: Preds (1): B4 // CHECK: Succs (1): B2 // CHECK: [B4] -// CHECK: 1: (CXXConstructExpr, class A) -// CHECK: 2: A c; -// CHECK: 3: [B4.2].~A() (Implicit destructor) -// CHECK: 4: [B2.4].~A() (Implicit destructor) -// CHECK: Preds (1): B2 -// CHECK: Succs (1): B3 +// CHECK: 1: a +// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 3: [B4.2] (CXXConstructExpr, class A) +// CHECK: 4: A b = a; +// CHECK: 5: b +// CHECK: 6: [B4.5] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 7: [B4.6].operator int +// CHECK: 8: [B4.7]() +// CHECK: 9: [B4.8] (ImplicitCastExpr, UserDefinedConversion, int) +// CHECK: 10: [B4.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) +// CHECK: T: while [B4.10] +// CHECK: Preds (2): B2 B5 +// CHECK: Succs (2): B3 B1 // CHECK: [B5] // CHECK: 1: (CXXConstructExpr, class A) // CHECK: 2: A a; // CHECK: Preds (1): B6 -// CHECK: Succs (1): B2 +// CHECK: Succs (1): B4 // CHECK: [B0 (EXIT)] // CHECK: Preds (1): B1 // CHECK: [B12 (ENTRY)] // CHECK: Succs (1): B11 // CHECK: [B1] -// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 1: [B10.4].~A() (Implicit destructor) // CHECK: 2: (CXXConstructExpr, class A) // CHECK: 3: A e; // CHECK: 4: [B1.3].~A() (Implicit destructor) // CHECK: 5: [B11.2].~A() (Implicit destructor) -// CHECK: Preds (2): B9 B2 +// CHECK: Preds (2): B8 B10 // CHECK: Succs (1): B0 // CHECK: [B2] -// CHECK: 1: a -// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A) -// CHECK: 3: [B2.2] (CXXConstructExpr, class A) -// CHECK: 4: A b = a; -// CHECK: 5: b -// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A) -// CHECK: 7: [B2.6].operator int -// CHECK: 8: [B2.7]() -// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int) -// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) -// CHECK: T: while [B2.10] -// CHECK: Preds (2): B3 B11 -// CHECK: Succs (2): B10 B1 +// CHECK: Preds (2): B3 B6 +// CHECK: Succs (1): B10 // CHECK: [B3] -// CHECK: Preds (2): B4 B7 -// CHECK: Succs (1): B2 -// CHECK: [B4] // CHECK: 1: (CXXConstructExpr, class A) // CHECK: 2: A d; -// CHECK: 3: [B4.2].~A() (Implicit destructor) -// CHECK: 4: [B10.2].~A() (Implicit destructor) -// CHECK: 5: [B2.4].~A() (Implicit destructor) -// CHECK: Preds (1): B6 -// CHECK: Succs (1): B3 -// CHECK: [B5] +// CHECK: 3: [B3.2].~A() (Implicit destructor) +// CHECK: 4: [B9.2].~A() (Implicit destructor) +// CHECK: 5: [B10.4].~A() (Implicit destructor) +// CHECK: Preds (1): B5 +// CHECK: Succs (1): B2 +// CHECK: [B4] // CHECK: 1: return; -// CHECK: 2: [B10.2].~A() (Implicit destructor) -// CHECK: 3: [B2.4].~A() (Implicit destructor) +// CHECK: 2: [B9.2].~A() (Implicit destructor) +// CHECK: 3: [B10.4].~A() (Implicit destructor) // CHECK: 4: [B11.2].~A() (Implicit destructor) -// CHECK: Preds (1): B6 +// CHECK: Preds (1): B5 // CHECK: Succs (1): B0 -// CHECK: [B6] +// CHECK: [B5] // CHECK: 1: UV -// CHECK: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool) -// CHECK: T: if [B6.2] -// CHECK: Preds (1): B8 -// CHECK: Succs (2): B5 B4 -// CHECK: [B7] -// CHECK: 1: [B10.2].~A() (Implicit destructor) -// CHECK: 2: [B2.4].~A() (Implicit destructor) +// CHECK: 2: [B5.1] (ImplicitCastExpr, LValueToRValue, _Bool) +// CHECK: T: if [B5.2] +// CHECK: Preds (1): B7 +// CHECK: Succs (2): B4 B3 +// CHECK: [B6] +// CHECK: 1: [B9.2].~A() (Implicit destructor) +// CHECK: 2: [B10.4].~A() (Implicit destructor) // CHECK: T: continue; -// CHECK: Preds (1): B8 -// CHECK: Succs (1): B3 -// CHECK: [B8] +// CHECK: Preds (1): B7 +// CHECK: Succs (1): B2 +// CHECK: [B7] // CHECK: 1: UV -// CHECK: 2: [B8.1] (ImplicitCastExpr, LValueToRValue, _Bool) -// CHECK: T: if [B8.2] -// CHECK: Preds (1): B10 -// CHECK: Succs (2): B7 B6 -// CHECK: [B9] -// CHECK: 1: [B10.2].~A() (Implicit destructor) +// CHECK: 2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool) +// CHECK: T: if [B7.2] +// CHECK: Preds (1): B9 +// CHECK: Succs (2): B6 B5 +// CHECK: [B8] +// CHECK: 1: [B9.2].~A() (Implicit destructor) // CHECK: T: break; -// CHECK: Preds (1): B10 +// CHECK: Preds (1): B9 // CHECK: Succs (1): B1 -// CHECK: [B10] +// CHECK: [B9] // CHECK: 1: (CXXConstructExpr, class A) // CHECK: 2: A c; // CHECK: 3: UV -// CHECK: 4: [B10.3] (ImplicitCastExpr, LValueToRValue, _Bool) -// CHECK: T: if [B10.4] -// CHECK: Preds (1): B2 -// CHECK: Succs (2): B9 B8 +// CHECK: 4: [B9.3] (ImplicitCastExpr, LValueToRValue, _Bool) +// CHECK: T: if [B9.4] +// CHECK: Preds (1): B10 +// CHECK: Succs (2): B8 B7 +// CHECK: [B10] +// CHECK: 1: a +// CHECK: 2: [B10.1] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 3: [B10.2] (CXXConstructExpr, class A) +// CHECK: 4: A b = a; +// CHECK: 5: b +// CHECK: 6: [B10.5] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 7: [B10.6].operator int +// CHECK: 8: [B10.7]() +// CHECK: 9: [B10.8] (ImplicitCastExpr, UserDefinedConversion, int) +// CHECK: 10: [B10.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) +// CHECK: T: while [B10.10] +// CHECK: Preds (2): B2 B11 +// CHECK: Succs (2): B9 B1 // CHECK: [B11] // CHECK: 1: (CXXConstructExpr, class A) // CHECK: 2: A a; // CHECK: Preds (1): B12 -// CHECK: Succs (1): B2 +// CHECK: Succs (1): B10 // CHECK: [B0 (EXIT)] -// CHECK: Preds (2): B1 B5 +// CHECK: Preds (2): B1 B4 // CHECK: [B4 (ENTRY)] // CHECK: Succs (1): B2 // CHECK: [B1] @@ -717,124 +717,124 @@ void test_catch_copy() { // CHECK: [B6 (ENTRY)] // CHECK: Succs (1): B5 // CHECK: [B1] -// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 1: [B4.4].~A() (Implicit destructor) // CHECK: 2: [B5.2].~A() (Implicit destructor) -// CHECK: Preds (1): B2 +// CHECK: Preds (1): B4 // CHECK: Succs (1): B0 // CHECK: [B2] -// CHECK: 1: a -// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A) -// CHECK: 3: [B2.2] (CXXConstructExpr, class A) -// CHECK: 4: A b = a; -// CHECK: 5: b -// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A) -// CHECK: 7: [B2.6].operator int -// CHECK: 8: [B2.7]() -// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int) -// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) -// CHECK: T: for (...; [B2.10]; ) -// CHECK: Preds (2): B3 B5 -// CHECK: Succs (2): B4 B1 +// CHECK: Preds (1): B3 +// CHECK: Succs (1): B4 // CHECK: [B3] -// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 1: (CXXConstructExpr, class A) +// CHECK: 2: A c; +// CHECK: 3: [B3.2].~A() (Implicit destructor) +// CHECK: 4: [B4.4].~A() (Implicit destructor) // CHECK: Preds (1): B4 // CHECK: Succs (1): B2 // CHECK: [B4] -// CHECK: 1: (CXXConstructExpr, class A) -// CHECK: 2: A c; -// CHECK: 3: [B4.2].~A() (Implicit destructor) -// CHECK: Preds (1): B2 -// CHECK: Succs (1): B3 +// CHECK: 1: a +// CHECK: 2: [B4.1] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 3: [B4.2] (CXXConstructExpr, class A) +// CHECK: 4: A b = a; +// CHECK: 5: b +// CHECK: 6: [B4.5] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 7: [B4.6].operator int +// CHECK: 8: [B4.7]() +// CHECK: 9: [B4.8] (ImplicitCastExpr, UserDefinedConversion, int) +// CHECK: 10: [B4.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) +// CHECK: T: for (...; [B4.10]; ) +// CHECK: Preds (2): B2 B5 +// CHECK: Succs (2): B3 B1 // CHECK: [B5] // CHECK: 1: (CXXConstructExpr, class A) // CHECK: 2: A a; // CHECK: Preds (1): B6 -// CHECK: Succs (1): B2 +// CHECK: Succs (1): B4 // CHECK: [B0 (EXIT)] // CHECK: Preds (1): B1 // CHECK: [B12 (ENTRY)] // CHECK: Succs (1): B11 // CHECK: [B1] -// CHECK: 1: [B2.4].~A() (Implicit destructor) +// CHECK: 1: [B10.4].~A() (Implicit destructor) // CHECK: 2: [B11.4].~A() (Implicit destructor) // CHECK: 3: (CXXConstructExpr, class A) // CHECK: 4: A f; // CHECK: 5: [B1.4].~A() (Implicit destructor) // CHECK: 6: [B11.2].~A() (Implicit destructor) -// CHECK: Preds (2): B9 B2 +// CHECK: Preds (2): B8 B10 // CHECK: Succs (1): B0 // CHECK: [B2] -// CHECK: 1: b -// CHECK: 2: [B2.1] (ImplicitCastExpr, NoOp, const class A) -// CHECK: 3: [B2.2] (CXXConstructExpr, class A) -// CHECK: 4: A c = b; -// CHECK: 5: c -// CHECK: 6: [B2.5] (ImplicitCastExpr, NoOp, const class A) -// CHECK: 7: [B2.6].operator int -// CHECK: 8: [B2.7]() -// CHECK: 9: [B2.8] (ImplicitCastExpr, UserDefinedConversion, int) -// CHECK: 10: [B2.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) -// CHECK: T: for (...; [B2.10]; ) -// CHECK: Preds (2): B3 B11 -// CHECK: Succs (2): B10 B1 +// CHECK: Preds (2): B3 B6 +// CHECK: Succs (1): B10 // CHECK: [B3] -// CHECK: 1: [B2.4].~A() (Implicit destructor) -// CHECK: Preds (2): B4 B7 -// CHECK: Succs (1): B2 -// CHECK: [B4] // CHECK: 1: (CXXConstructExpr, class A) // CHECK: 2: A e; -// CHECK: 3: [B4.2].~A() (Implicit destructor) -// CHECK: 4: [B10.2].~A() (Implicit destructor) -// CHECK: Preds (1): B6 -// CHECK: Succs (1): B3 -// CHECK: [B5] +// CHECK: 3: [B3.2].~A() (Implicit destructor) +// CHECK: 4: [B9.2].~A() (Implicit destructor) +// CHECK: 5: [B10.4].~A() (Implicit destructor) +// CHECK: Preds (1): B5 +// CHECK: Succs (1): B2 +// CHECK: [B4] // CHECK: 1: return; -// CHECK: 2: [B10.2].~A() (Implicit destructor) -// CHECK: 3: [B2.4].~A() (Implicit destructor) +// CHECK: 2: [B9.2].~A() (Implicit destructor) +// CHECK: 3: [B10.4].~A() (Implicit destructor) // CHECK: 4: [B11.4].~A() (Implicit destructor) // CHECK: 5: [B11.2].~A() (Implicit destructor) -// CHECK: Preds (1): B6 +// CHECK: Preds (1): B5 // CHECK: Succs (1): B0 -// CHECK: [B6] +// CHECK: [B5] // CHECK: 1: UV -// CHECK: 2: [B6.1] (ImplicitCastExpr, LValueToRValue, _Bool) -// CHECK: T: if [B6.2] -// CHECK: Preds (1): B8 -// CHECK: Succs (2): B5 B4 -// CHECK: [B7] -// CHECK: 1: [B10.2].~A() (Implicit destructor) +// CHECK: 2: [B5.1] (ImplicitCastExpr, LValueToRValue, _Bool) +// CHECK: T: if [B5.2] +// CHECK: Preds (1): B7 +// CHECK: Succs (2): B4 B3 +// CHECK: [B6] +// CHECK: 1: [B9.2].~A() (Implicit destructor) // CHECK: T: continue; -// CHECK: Preds (1): B8 -// CHECK: Succs (1): B3 -// CHECK: [B8] +// CHECK: Preds (1): B7 +// CHECK: Succs (1): B2 +// CHECK: [B7] // CHECK: 1: UV -// CHECK: 2: [B8.1] (ImplicitCastExpr, LValueToRValue, _Bool) -// CHECK: T: if [B8.2] -// CHECK: Preds (1): B10 -// CHECK: Succs (2): B7 B6 -// CHECK: [B9] -// CHECK: 1: [B10.2].~A() (Implicit destructor) +// CHECK: 2: [B7.1] (ImplicitCastExpr, LValueToRValue, _Bool) +// CHECK: T: if [B7.2] +// CHECK: Preds (1): B9 +// CHECK: Succs (2): B6 B5 +// CHECK: [B8] +// CHECK: 1: [B9.2].~A() (Implicit destructor) // CHECK: T: break; -// CHECK: Preds (1): B10 +// CHECK: Preds (1): B9 // CHECK: Succs (1): B1 -// CHECK: [B10] +// CHECK: [B9] // CHECK: 1: (CXXConstructExpr, class A) // CHECK: 2: A d; // CHECK: 3: UV -// CHECK: 4: [B10.3] (ImplicitCastExpr, LValueToRValue, _Bool) -// CHECK: T: if [B10.4] -// CHECK: Preds (1): B2 -// CHECK: Succs (2): B9 B8 +// CHECK: 4: [B9.3] (ImplicitCastExpr, LValueToRValue, _Bool) +// CHECK: T: if [B9.4] +// CHECK: Preds (1): B10 +// CHECK: Succs (2): B8 B7 +// CHECK: [B10] +// CHECK: 1: b +// CHECK: 2: [B10.1] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 3: [B10.2] (CXXConstructExpr, class A) +// CHECK: 4: A c = b; +// CHECK: 5: c +// CHECK: 6: [B10.5] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 7: [B10.6].operator int +// CHECK: 8: [B10.7]() +// CHECK: 9: [B10.8] (ImplicitCastExpr, UserDefinedConversion, int) +// CHECK: 10: [B10.9] (ImplicitCastExpr, IntegralToBoolean, _Bool) +// CHECK: T: for (...; [B10.10]; ) +// CHECK: Preds (2): B2 B11 +// CHECK: Succs (2): B9 B1 // CHECK: [B11] // CHECK: 1: (CXXConstructExpr, class A) // CHECK: 2: A a; // CHECK: 3: (CXXConstructExpr, class A) // CHECK: 4: A b; // CHECK: Preds (1): B12 -// CHECK: Succs (1): B2 +// CHECK: Succs (1): B10 // CHECK: [B0 (EXIT)] -// CHECK: Preds (2): B1 B5 +// CHECK: Preds (2): B1 B4 // CHECK: [B3 (ENTRY)] // CHECK: Succs (1): B0 // CHECK: [B1] @@ -862,3 +862,4 @@ void test_catch_copy() { // CHECK: Succs (1): B0 // CHECK: [B0 (EXIT)] // CHECK: Preds (3): B2 B1 B3 + diff --git a/test/Analysis/base-init.cpp b/test/Analysis/base-init.cpp index 8fd7abcc3778..e63d50855e10 100644 --- a/test/Analysis/base-init.cpp +++ b/test/Analysis/base-init.cpp @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -analyzer-inline-call -cfg-add-initializers -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -analyzer-ipa=inlining -verify %s // XFAIL: * +void clang_analyzer_eval(bool); + class A { int x; public: @@ -24,8 +26,5 @@ B::B() { void f() { B b; - if (b.getx() != 0) { - int *p = 0; - *p = 0; // no-warning - } + clang_analyzer_eval(b.getx() == 0); // expected-warning{{TRUE}} } diff --git a/test/Analysis/blocks-no-inline.c b/test/Analysis/blocks-no-inline.c new file mode 100644 index 000000000000..1ec14e820b0e --- /dev/null +++ b/test/Analysis/blocks-no-inline.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=none -fblocks -verify %s + +void clang_analyzer_eval(int); + +void testInvalidation() { + __block int i = 0; + ^{ + ++i; + }(); + + // Under inlining, we will know that i == 1. + clang_analyzer_eval(i == 0); // expected-warning{{UNKNOWN}} +} diff --git a/test/Analysis/blocks.m b/test/Analysis/blocks.m index 7a604ddb4d91..ff376d17a1a1 100644 --- a/test/Analysis/blocks.m +++ b/test/Analysis/blocks.m @@ -79,9 +79,7 @@ void test2() { void test2_b() { static int y = 0; __block int x; - // This is also a bug, but should be found not by checking the value - // 'x' is bound at block creation. - ^{ y = x + 1; }(); // no-warning + ^{ y = x + 1; }(); // expected-warning {{left operand of '+' is a garbage value}} } void test2_c() { diff --git a/test/Analysis/bstring.c b/test/Analysis/bstring.c index 833c917613ed..d383d421d444 100644 --- a/test/Analysis/bstring.c +++ b/test/Analysis/bstring.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s -// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring -analyzer-store=region -Wno-null-dereference -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,unix.cstring.NullArg,experimental.unix.cstring.OutOfBounds,experimental.unix.cstring.BufferOverlap,experimental.unix.cstring.NotNullTerminated -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s //===----------------------------------------------------------------------=== // Declarations @@ -26,6 +26,8 @@ typedef typeof(sizeof(int)) size_t; +void clang_analyzer_eval(int); + //===----------------------------------------------------------------------=== // memcpy() //===----------------------------------------------------------------------=== @@ -52,12 +54,11 @@ void memcpy0 () { memcpy(dst, src, 4); // no-warning - if (memcpy(dst, src, 4) != dst) { - (void)*(char*)0; // no-warning - } + clang_analyzer_eval(memcpy(dst, src, 4) == dst); // expected-warning{{TRUE}} - if (dst[0] != 0) - (void)*(char*)0; // expected-warning{{null}} + // If we actually model the copy, we can make this known. + // The important thing for now is that the old value has been invalidated. + clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}} } void memcpy1 () { @@ -138,14 +139,13 @@ void memcpy13() { void memcpy_unknown_size (size_t n) { char a[4], b[4] = {1}; - if (memcpy(a, b, n) != a) - (void)*(char*)0; // no-warning + clang_analyzer_eval(memcpy(a, b, n) == a); // expected-warning{{TRUE}} } void memcpy_unknown_size_warn (size_t n) { char a[4]; - if (memcpy(a, 0, n) != a) // expected-warning{{Null pointer argument in call to memory copy function}} - (void)*(char*)0; // no-warning + void *result = memcpy(a, 0, n); // expected-warning{{Null pointer argument in call to memory copy function}} + clang_analyzer_eval(result == a); // no-warning (above is fatal) } //===----------------------------------------------------------------------=== @@ -174,12 +174,11 @@ void mempcpy0 () { mempcpy(dst, src, 4); // no-warning - if (mempcpy(dst, src, 4) != &dst[4]) { - (void)*(char*)0; // no-warning - } + clang_analyzer_eval(mempcpy(dst, src, 4) == &dst[4]); // expected-warning{{TRUE}} - if (dst[0] != 0) - (void)*(char*)0; // expected-warning{{null}} + // If we actually model the copy, we can make this known. + // The important thing for now is that the old value has been invalidated. + clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}} } void mempcpy1 () { @@ -260,8 +259,8 @@ void mempcpy13() { void mempcpy_unknown_size_warn (size_t n) { char a[4]; - if (mempcpy(a, 0, n) != a) // expected-warning{{Null pointer argument in call to memory copy function}} - (void)*(char*)0; // no-warning + void *result = mempcpy(a, 0, n); // expected-warning{{Null pointer argument in call to memory copy function}} + clang_analyzer_eval(result == a); // no-warning (above is fatal) } void mempcpy_unknownable_size (char *src, float n) { @@ -295,12 +294,11 @@ void memmove0 () { memmove(dst, src, 4); // no-warning - if (memmove(dst, src, 4) != dst) { - (void)*(char*)0; // no-warning - } + clang_analyzer_eval(memmove(dst, src, 4) == dst); // expected-warning{{TRUE}} - if (dst[0] != 0) - (void)*(char*)0; // expected-warning{{null}} + // If we actually model the copy, we can make this known. + // The important thing for now is that the old value has been invalidated. + clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}} } void memmove1 () { @@ -327,7 +325,7 @@ void memmove2 () { // __builtin_bcmp is not defined with const in Builtins.def. int bcmp(/*const*/ void *s1, /*const*/ void *s2, size_t n); #define memcmp bcmp - +// #else /* VARIANT */ #define memcmp BUILTIN(memcmp) @@ -360,34 +358,32 @@ void memcmp2 () { void memcmp3 () { char a[] = {1, 2, 3, 4}; - if (memcmp(a, a, 4)) - (void)*(char*)0; // no-warning + clang_analyzer_eval(memcmp(a, a, 4) == 0); // expected-warning{{TRUE}} } void memcmp4 (char *input) { char a[] = {1, 2, 3, 4}; - if (memcmp(a, input, 4)) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(memcmp(a, input, 4) == 0); // expected-warning{{UNKNOWN}} } void memcmp5 (char *input) { char a[] = {1, 2, 3, 4}; - if (memcmp(a, 0, 0)) // no-warning - (void)*(char*)0; // no-warning - if (memcmp(0, a, 0)) // no-warning - (void)*(char*)0; // no-warning - if (memcmp(a, input, 0)) // no-warning - (void)*(char*)0; // no-warning + clang_analyzer_eval(memcmp(a, 0, 0) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(memcmp(0, a, 0) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(memcmp(a, input, 0) == 0); // expected-warning{{TRUE}} } void memcmp6 (char *a, char *b, size_t n) { int result = memcmp(a, b, n); if (result != 0) - return; - if (n == 0) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(n != 0); // expected-warning{{TRUE}} + // else + // analyzer_assert_unknown(n == 0); + + // We can't do the above comparison because n has already been constrained. + // On one path n == 0, on the other n != 0. } int memcmp7 (char *a, size_t x, size_t y, size_t n) { @@ -411,8 +407,9 @@ void bcopy0 () { bcopy(src, dst, 4); // no-warning - if (dst[0] != 0) - (void)*(char*)0; // expected-warning{{null}} + // If we actually model the copy, we can make this known. + // The important thing for now is that the old value has been invalidated. + clang_analyzer_eval(dst[0] != 0); // expected-warning{{UNKNOWN}} } void bcopy1 () { @@ -428,3 +425,13 @@ void bcopy2 () { bcopy(src, dst, 4); // expected-warning{{overflow}} } + +void *malloc(size_t); +void free(void *); +char radar_11125445_memcopythenlogfirstbyte(const char *input, size_t length) { + char *bytes = malloc(sizeof(char) * (length + 1)); + memcpy(bytes, input, length); + char x = bytes[0]; // no warning + free(bytes); + return x; +} diff --git a/test/Analysis/casts.c b/test/Analysis/casts.c index 8b88a2db432e..f862ddf57315 100644 --- a/test/Analysis/casts.c +++ b/test/Analysis/casts.c @@ -65,3 +65,11 @@ void pr6013_6035_test(void *p) { foo = ((long)(p)); (void) foo; } + +// PR12511 and radar://11215362 - Test that we support SymCastExpr, which represents symbolic int to float cast. +char ttt(int intSeconds) { + double seconds = intSeconds; + if (seconds) + return 0; + return 0; +} diff --git a/test/Analysis/comparison-implicit-casts.cpp b/test/Analysis/comparison-implicit-casts.cpp new file mode 100644 index 000000000000..df9d8700099e --- /dev/null +++ b/test/Analysis/comparison-implicit-casts.cpp @@ -0,0 +1,98 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=basic -triple i386-apple-darwin9 -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=basic -triple x86_64-apple-darwin9 -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=range -triple i386-apple-darwin9 -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-constraints=range -triple x86_64-apple-darwin9 -verify %s + +// This file runs in C++ mode so that the comparison type is 'bool', not 'int'. +void clang_analyzer_eval(int); +typedef typeof(sizeof(int)) size_t; + +// PR12206/12510 - When SimpleSValBuilder figures out that a symbol is fully +// constrained, it should cast the value to the result type in a binary +// operation...unless the binary operation is a comparison, in which case the +// two arguments should be the same type, but won't match the result type. +// +// This is not directly related to additive folding, but we use SValBuilder's +// additive folding to tickle the bug. ExprEngine will simplify fully-constrained +// symbols, so SValBuilder will only see them if they are (a) part of an evaluated +// SymExpr (e.g. with additive folding) or (b) generated by a checker (e.g. +// unix.cstring's strlen() modelling). +void PR12206(int x) { + size_t comparisonSize = sizeof(1 == 1); + + // Sanity check. This test is useless if size_t isn't bigger than bool. + clang_analyzer_eval(sizeof(size_t) > comparisonSize); // expected-warning{{TRUE}} + + // Build a SymIntExpr, dependent on x. + int local = x - 1; + + // Create a value that requires more bits to store than a comparison result. + int value = 1; + value <<= 8 * comparisonSize; + value += 1; + + // Constrain the value of x. + if (x != value) return; + + // Constant-folding will turn (local+1) back into the symbol for x. + // The point of this dance is to make SValBuilder be responsible for + // turning the symbol into a ConcreteInt, rather than ExprEngine. + + // Test relational operators. + clang_analyzer_eval((local + 1) >= 2); // expected-warning{{TRUE}} + clang_analyzer_eval(2 <= (local + 1)); // expected-warning{{TRUE}} + + // Test equality operators. + clang_analyzer_eval((local + 1) != 1); // expected-warning{{TRUE}} + clang_analyzer_eval(1 != (local + 1)); // expected-warning{{TRUE}} +} + +void PR12206_truncation(signed char x) { + // Build a SymIntExpr, dependent on x. + signed char local = x - 1; + + // Constrain the value of x. + if (x != 1) return; + + // Constant-folding will turn (local+1) back into the symbol for x. + // The point of this dance is to make SValBuilder be responsible for + // turning the symbol into a ConcreteInt, rather than ExprEngine. + + // Construct a value that cannot be represented by 'char', + // but that has the same lower bits as x. + signed int value = 1 + (1 << 8); + + // Test relational operators. + clang_analyzer_eval((local + 1) < value); // expected-warning{{TRUE}} + clang_analyzer_eval(value > (local + 1)); // expected-warning{{TRUE}} + + // Test equality operators. + clang_analyzer_eval((local + 1) != value); // expected-warning{{TRUE}} + clang_analyzer_eval(value != (local + 1)); // expected-warning{{TRUE}} +} + +// This test is insurance in case we significantly change how SymExprs are +// evaluated. +size_t strlen(const char *s); +void PR12206_strlen(const char *x) { + size_t comparisonSize = sizeof(1 == 1); + + // Sanity check. This test is useless if size_t isn't bigger than bool. + clang_analyzer_eval(sizeof(size_t) > comparisonSize); // expected-warning{{TRUE}} + + // Create a value that requires more bits to store than a comparison result. + size_t value = 1UL; + value <<= 8 * comparisonSize; + value += 1; + + // Constrain the length of x. + if (strlen(x) != value) return; + + // Test relational operators. + clang_analyzer_eval(strlen(x) >= 2); // expected-warning{{TRUE}} + clang_analyzer_eval(2 <= strlen(x)); // expected-warning{{TRUE}} + + // Test equality operators. + clang_analyzer_eval(strlen(x) != 1); // expected-warning{{TRUE}} + clang_analyzer_eval(1 != strlen(x)); // expected-warning{{TRUE}} +} diff --git a/test/Analysis/constant-folding.c b/test/Analysis/constant-folding.c index e7a5705fa59a..81d119392658 100644 --- a/test/Analysis/constant-folding.c +++ b/test/Analysis/constant-folding.c @@ -1,7 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode -Wno-null-dereference -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s -// Trigger a warning if the analyzer reaches this point in the control flow. -#define WARN ((void)*(char*)0) +void clang_analyzer_eval(int); // There should be no warnings unless otherwise indicated. @@ -9,64 +8,71 @@ void testComparisons (int a) { // Sema can already catch the simple comparison a==a, // since that's usually a logic error (and not path-dependent). int b = a; - if (!(b==a)) WARN; // expected-warning{{never executed}} - if (!(b>=a)) WARN; // expected-warning{{never executed}} - if (!(b<=a)) WARN; // expected-warning{{never executed}} - if (b!=a) WARN; // expected-warning{{never executed}} - if (b>a) WARN; // expected-warning{{never executed}} - if (b<a) WARN; // expected-warning{{never executed}} + clang_analyzer_eval(b == a); // expected-warning{{TRUE}} + clang_analyzer_eval(b >= a); // expected-warning{{TRUE}} + clang_analyzer_eval(b <= a); // expected-warning{{TRUE}} + clang_analyzer_eval(b != a); // expected-warning{{FALSE}} + clang_analyzer_eval(b > a); // expected-warning{{FALSE}} + clang_analyzer_eval(b < a); // expected-warning{{FALSE}} } void testSelfOperations (int a) { - if ((a|a) != a) WARN; // expected-warning{{never executed}} - if ((a&a) != a) WARN; // expected-warning{{never executed}} - if ((a^a) != 0) WARN; // expected-warning{{never executed}} - if ((a-a) != 0) WARN; // expected-warning{{never executed}} + clang_analyzer_eval((a|a) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a&a) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a^a) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval((a-a) == 0); // expected-warning{{TRUE}} } void testIdempotent (int a) { - if ((a*1) != a) WARN; // expected-warning{{never executed}} - if ((a/1) != a) WARN; // expected-warning{{never executed}} - if ((a+0) != a) WARN; // expected-warning{{never executed}} - if ((a-0) != a) WARN; // expected-warning{{never executed}} - if ((a<<0) != a) WARN; // expected-warning{{never executed}} - if ((a>>0) != a) WARN; // expected-warning{{never executed}} - if ((a^0) != a) WARN; // expected-warning{{never executed}} - if ((a&(~0)) != a) WARN; // expected-warning{{never executed}} - if ((a|0) != a) WARN; // expected-warning{{never executed}} + clang_analyzer_eval((a*1) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a/1) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a+0) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a-0) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a<<0) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a>>0) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a^0) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a&(~0)) == a); // expected-warning{{TRUE}} + clang_analyzer_eval((a|0) == a); // expected-warning{{TRUE}} } void testReductionToConstant (int a) { - if ((a*0) != 0) WARN; // expected-warning{{never executed}} - if ((a&0) != 0) WARN; // expected-warning{{never executed}} - if ((a|(~0)) != (~0)) WARN; // expected-warning{{never executed}} + clang_analyzer_eval((a*0) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval((a&0) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval((a|(~0)) == (~0)); // expected-warning{{TRUE}} } void testSymmetricIntSymOperations (int a) { - if ((2+a) != (a+2)) WARN; // expected-warning{{never executed}} - if ((2*a) != (a*2)) WARN; // expected-warning{{never executed}} - if ((2&a) != (a&2)) WARN; // expected-warning{{never executed}} - if ((2^a) != (a^2)) WARN; // expected-warning{{never executed}} - if ((2|a) != (a|2)) WARN; // expected-warning{{never executed}} + clang_analyzer_eval((2+a) == (a+2)); // expected-warning{{TRUE}} + clang_analyzer_eval((2*a) == (a*2)); // expected-warning{{TRUE}} + clang_analyzer_eval((2&a) == (a&2)); // expected-warning{{TRUE}} + clang_analyzer_eval((2^a) == (a^2)); // expected-warning{{TRUE}} + clang_analyzer_eval((2|a) == (a|2)); // expected-warning{{TRUE}} } void testAsymmetricIntSymOperations (int a) { - if (((~0) >> a) != (~0)) WARN; // expected-warning{{never executed}} - if ((0 >> a) != 0) WARN; // expected-warning{{never executed}} - if ((0 << a) != 0) WARN; // expected-warning{{never executed}} + clang_analyzer_eval(((~0) >> a) == (~0)); // expected-warning{{TRUE}} + clang_analyzer_eval((0 >> a) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval((0 << a) == 0); // expected-warning{{TRUE}} // Unsigned right shift shifts in zeroes. - if ((((unsigned)(~0)) >> ((unsigned) a)) != ((unsigned)(~0))) - WARN; // expected-warning{{}} + clang_analyzer_eval(((~0U) >> a) != (~0U)); // expected-warning{{UNKNOWN}} } void testLocations (char *a) { char *b = a; - if (!(b==a)) WARN; // expected-warning{{never executed}} - if (!(b>=a)) WARN; // expected-warning{{never executed}} - if (!(b<=a)) WARN; // expected-warning{{never executed}} - if (b!=a) WARN; // expected-warning{{never executed}} - if (b>a) WARN; // expected-warning{{never executed}} - if (b<a) WARN; // expected-warning{{never executed}} - if (b-a) WARN; // expected-warning{{never executed}} + clang_analyzer_eval(b == a); // expected-warning{{TRUE}} + clang_analyzer_eval(b >= a); // expected-warning{{TRUE}} + clang_analyzer_eval(b <= a); // expected-warning{{TRUE}} + clang_analyzer_eval(b != a); // expected-warning{{FALSE}} + clang_analyzer_eval(b > a); // expected-warning{{FALSE}} + clang_analyzer_eval(b < a); // expected-warning{{FALSE}} +} + +void testMixedTypeComparisons (char a, unsigned long b) { + if (a != 0) return; + if (b != 0x100) return; + + clang_analyzer_eval(a <= b); // expected-warning{{TRUE}} + clang_analyzer_eval(b >= a); // expected-warning{{TRUE}} + clang_analyzer_eval(a != b); // expected-warning{{TRUE}} } diff --git a/test/Analysis/coverage.c b/test/Analysis/coverage.c index 73d78da18644..811691391eb1 100644 --- a/test/Analysis/coverage.c +++ b/test/Analysis/coverage.c @@ -92,3 +92,11 @@ void coverage9(int *x) { function_which_gives_up_settonull(&x); y = (*x); // no warning } + +static void empty_function(){ +} +int use_empty_function(int x) { + x = 0; + empty_function(); + return 5/x; //expected-warning {{Division by zero}} +} diff --git a/test/Analysis/cstring-syntax.c b/test/Analysis/cstring-syntax.c index 64ecb67008f8..4aa88ed3b7ed 100644 --- a/test/Analysis/cstring-syntax.c +++ b/test/Analysis/cstring-syntax.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=unix.cstring.BadSizeArg -analyzer-store=region -Wno-strncat-size -Wno-strlcpy-strlcat-size -Wno-sizeof-array-argument -Wno-sizeof-pointer-memaccess -verify %s typedef __SIZE_TYPE__ size_t; char *strncat(char *, const char *, size_t); diff --git a/test/Analysis/ctor-inlining.mm b/test/Analysis/ctor-inlining.mm new file mode 100644 index 000000000000..54d51b46dc5e --- /dev/null +++ b/test/Analysis/ctor-inlining.mm @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -fobjc-arc -cfg-add-implicit-dtors -Wno-null-dereference -verify %s + +void clang_analyzer_eval(bool); + +struct Wrapper { + __strong id obj; +}; + +void test() { + Wrapper w; + // force a diagnostic + *(char *)0 = 1; // expected-warning{{Dereference of null pointer}} +} + + +struct IntWrapper { + int x; +}; + +void testCopyConstructor() { + IntWrapper a; + a.x = 42; + + IntWrapper b(a); + clang_analyzer_eval(b.x == 42); // expected-warning{{TRUE}} +} + +struct NonPODIntWrapper { + int x; + + virtual int get(); +}; + +void testNonPODCopyConstructor() { + NonPODIntWrapper a; + a.x = 42; + + NonPODIntWrapper b(a); + clang_analyzer_eval(b.x == 42); // expected-warning{{TRUE}} +} + diff --git a/test/Analysis/cxx-crashes.cpp b/test/Analysis/cxx-crashes.cpp index 17fc74d06f46..8912bf68de3f 100644 --- a/test/Analysis/cxx-crashes.cpp +++ b/test/Analysis/cxx-crashes.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -verify %s + +void clang_analyzer_eval(bool); int f1(char *dst) { char *p = dst + 4; @@ -54,3 +56,22 @@ struct C { void C::f() { } } + + +void vla(int n) { + int nums[n]; + nums[0] = 1; + clang_analyzer_eval(nums[0] == 1); // expected-warning{{TRUE}} + + // This used to fail with MallocChecker on, and /only/ in C++ mode. + // This struct is POD, though, so it should be fine to put it in a VLA. + struct { int x; } structs[n]; + structs[0].x = 1; + clang_analyzer_eval(structs[0].x == 1); // expected-warning{{TRUE}} +} + +void useIntArray(int []); +void testIntArrayLiteral() { + useIntArray((int []){ 1, 2, 3 }); +} + diff --git a/test/Analysis/cxx-for-range-cfg.cpp b/test/Analysis/cxx-for-range-cfg.cpp new file mode 100644 index 000000000000..e258c7a1e208 --- /dev/null +++ b/test/Analysis/cxx-for-range-cfg.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -Wall -fsyntax-only %s -std=c++11 -verify + +// The rdar11671507_vector<int *>[]> would previously crash CFG construction +// because of the temporary array of vectors. +template <typename T> +class rdar11671507_vector { +public: + rdar11671507_vector(); + ~rdar11671507_vector(); + T *Base; + T *End; +}; + +void rdar11671507(rdar11671507_vector<int*> v, rdar11671507_vector<int*> w) { + for (auto &vec : (rdar11671507_vector<int *>[]){ v, w }) {} // expected-warning {{unused}} +} diff --git a/test/Analysis/cxx-method-names.cpp b/test/Analysis/cxx-method-names.cpp new file mode 100644 index 000000000000..8afbb85c1730 --- /dev/null +++ b/test/Analysis/cxx-method-names.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix,osx,experimental.unix,experimental.security.taint -analyzer-store region -verify %s + +class Evil { +public: + void system(int); // taint checker + void malloc(void *); // taint checker, malloc checker + void free(); // malloc checker, keychain checker + void fopen(); // stream checker + void feof(int, int); // stream checker + void open(); // unix api checker +}; + +void test(Evil &E) { + // no warnings, no crashes + E.system(0); + E.malloc(0); + E.free(); + E.fopen(); + E.feof(0,1); + E.open(); +} diff --git a/test/Analysis/cxx11-crashes.cpp b/test/Analysis/cxx11-crashes.cpp new file mode 100644 index 000000000000..16bfc891000f --- /dev/null +++ b/test/Analysis/cxx11-crashes.cpp @@ -0,0 +1,66 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -std=c++11 -verify %s + +// radar://11485149, PR12871 +class PlotPoint { + bool valid; +}; + +PlotPoint limitedFit () { + PlotPoint fit0; + fit0 = limitedFit (); + return fit0; +} + +// radar://11487541, NamespaceAlias +namespace boost {namespace filesystem3 { +class path { +public: + path(){} +}; + +}} +namespace boost +{ + namespace filesystem + { + using filesystem3::path; + } +} + +void radar11487541() { + namespace fs = boost::filesystem; + fs::path p; +} + +// PR12873 radar://11499139 +void testFloatInitializer() { + const float ysize={0.015}, xsize={0.01}; +} + + +// PR12874, radar://11487525 +template<class T> struct addr_impl_ref { + T & v_; + inline addr_impl_ref( T & v ): v_( v ) { + } + inline operator T& () const {return v_;} +}; +template<class T> struct addressof_impl { + static inline T * f( T & v, long ) { + return reinterpret_cast<T*>(&const_cast<char&>(reinterpret_cast<const volatile char &>(v))); + } +}; +template<class T> T * addressof( T & v ) { + return addressof_impl<T>::f( addr_impl_ref<T>( v ), 0 ); +} +void testRadar11487525_1(){ + bool s[25]; + addressof(s); +} + +// radar://11487525 Don't crash on CK_LValueBitCast. +bool begin(double *it) { + typedef bool type[25]; + bool *a = reinterpret_cast<type &>(*( reinterpret_cast<char *>( it ))); + return *a; +} diff --git a/test/Analysis/dead-stores.m b/test/Analysis/dead-stores.m index 083427478d7e..fe565547e12a 100644 --- a/test/Analysis/dead-stores.m +++ b/test/Analysis/dead-stores.m @@ -88,3 +88,23 @@ void rdar10591355() { RDar10591355 *p = rdar10591355_aux(); ^{ (void) p.x; }(); } + +@interface Radar11059352_1 { +@private + int *_pathString; +} +@property int *pathString; +@end +@interface Radar11059352 { +@private +Radar11059352_1 *_Path; +} +@end +@implementation Radar11059352 + +- (int*)usePath { + Radar11059352_1 *xxxxx = _Path; // no warning + int *wp = xxxxx.pathString; + return wp; +} +@end diff --git a/test/Analysis/delegates.m b/test/Analysis/delegates.m index 8f42b83b0eeb..7fc4f2bb9616 100644 --- a/test/Analysis/delegates.m +++ b/test/Analysis/delegates.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -Wno-objc-root-class -verify %s //===----------------------------------------------------------------------===// @@ -96,13 +96,12 @@ extern void *_NSConstantStringClassReference; @implementation test_6062730 - (void) foo { - NSString *str = [[NSString alloc] init]; + NSString *str = [[NSString alloc] init]; // no-warning [test_6062730 performSelectorOnMainThread:@selector(postNotification:) withObject:str waitUntilDone:1]; } - (void) bar { - NSString *str = [[NSString alloc] init]; // expected-warning{{leak}} - // FIXME: We need to resolve [self class] to 'test_6062730'. + NSString *str = [[NSString alloc] init]; // no-warning [[self class] performSelectorOnMainThread:@selector(postNotification:) withObject:str waitUntilDone:1]; } @@ -111,3 +110,21 @@ extern void *_NSConstantStringClassReference; } @end + +@interface ObjectThatRequiresDelegate : NSObject +- (id)initWithDelegate:(id)delegate; +- (id)initWithNumber:(int)num delegate:(id)delegate; +@end + + +@interface DelegateRequirerTest +@end +@implementation DelegateRequirerTest + +- (void)test { + (void)[[ObjectThatRequiresDelegate alloc] initWithDelegate:self]; + (void)[[ObjectThatRequiresDelegate alloc] initWithNumber:0 delegate:self]; + // no leak warnings -- these objects could be released in callback methods +} + +@end diff --git a/test/Analysis/derived-to-base.cpp b/test/Analysis/derived-to-base.cpp index f65b9db17b65..f8336785de8f 100644 --- a/test/Analysis/derived-to-base.cpp +++ b/test/Analysis/derived-to-base.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -verify %s + +void clang_analyzer_eval(bool); class A { protected: @@ -13,3 +15,123 @@ public: void B::f() { x = 3; } + + +class C : public B { +public: + void g() { + // This used to crash because we are upcasting through two bases. + x = 5; + } +}; + + +namespace VirtualBaseClasses { + class A { + protected: + int x; + }; + + class B : public virtual A { + public: + int getX() { return x; } + }; + + class C : public virtual A { + public: + void setX() { x = 42; } + }; + + class D : public B, public C {}; + class DV : virtual public B, public C {}; + class DV2 : public B, virtual public C {}; + + void test() { + D d; + d.setX(); + clang_analyzer_eval(d.getX() == 42); // expected-warning{{TRUE}} + + DV dv; + dv.setX(); + clang_analyzer_eval(dv.getX() == 42); // expected-warning{{TRUE}} + + DV2 dv2; + dv2.setX(); + clang_analyzer_eval(dv2.getX() == 42); // expected-warning{{TRUE}} + } + + + // Make sure we're consistent about the offset of the A subobject within an + // Intermediate virtual base class. + class Padding1 { int unused; }; + class Padding2 { int unused; }; + class Intermediate : public Padding1, public A, public Padding2 {}; + + class BI : public virtual Intermediate { + public: + int getX() { return x; } + }; + + class CI : public virtual Intermediate { + public: + void setX() { x = 42; } + }; + + class DI : public BI, public CI {}; + + void testIntermediate() { + DI d; + d.setX(); + clang_analyzer_eval(d.getX() == 42); // expected-warning{{TRUE}} + } +} + + +namespace DynamicVirtualUpcast { + class A { + public: + virtual ~A(); + }; + + class B : virtual public A {}; + class C : virtual public B {}; + class D : virtual public C {}; + + bool testCast(A *a) { + return dynamic_cast<B*>(a) && dynamic_cast<C*>(a); + } + + void test() { + D d; + clang_analyzer_eval(testCast(&d)); // expected-warning{{TRUE}} + } +} + +namespace DynamicMultipleInheritanceUpcast { + class B { + public: + virtual ~B(); + }; + class C { + public: + virtual ~C(); + }; + class D : public B, public C {}; + + bool testCast(B *a) { + return dynamic_cast<C*>(a); + } + + void test() { + D d; + clang_analyzer_eval(testCast(&d)); // expected-warning{{TRUE}} + } + + + class DV : virtual public B, virtual public C {}; + + void testVirtual() { + DV d; + clang_analyzer_eval(testCast(&d)); // expected-warning{{TRUE}} + } +} diff --git a/test/Analysis/diagnostics/undef-value-callee.h b/test/Analysis/diagnostics/undef-value-callee.h new file mode 100644 index 000000000000..ea48c46a62c1 --- /dev/null +++ b/test/Analysis/diagnostics/undef-value-callee.h @@ -0,0 +1,4 @@ + +void callee() { + ; +} diff --git a/test/Analysis/diagnostics/undef-value-caller.c b/test/Analysis/diagnostics/undef-value-caller.c new file mode 100644 index 000000000000..928839d0404d --- /dev/null +++ b/test/Analysis/diagnostics/undef-value-caller.c @@ -0,0 +1,238 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist -o %t %s +// RUN: FileCheck --input-file %t %s + +#include "undef-value-callee.h" + +// This code used to cause a crash since we were not adding fileID of the header to the plist diagnostic. +// Note, in the future, we do not even need to step into this callee since it does not influence the result. +int test_calling_unimportant_callee(int argc, char *argv[]) { + int x; + callee(); + return x; // expected-warning {{Undefined or garbage value returned to caller}} +} + +// CHECK: <?xml version="1.0" encoding="UTF-8"?> +// CHECK: <plist version="1.0"> +// CHECK: <dict> +// CHECK: <key>files</key> +// CHECK: <array> +// CHECK: </array> +// CHECK: <key>diagnostics</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>9</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>9</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>9</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Variable 'x' declared without an initial value</string> +// CHECK: <key>message</key> +// CHECK: <string>Variable 'x' declared without an initial value</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>9</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>9</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'callee'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'callee'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>2</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>1</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'test_calling_unimportant_callee'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'test_calling_unimportant_callee'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Returning from 'callee'</string> +// CHECK: <key>message</key> +// CHECK: <string>Returning from 'callee'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>11</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>11</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>11</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>11</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>11</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Undefined or garbage value returned to caller</string> +// CHECK: <key>message</key> +// CHECK: <string>Undefined or garbage value returned to caller</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Undefined or garbage value returned to caller</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Garbage return value</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>test_calling_unimportant_callee</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>11</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </plist> diff --git a/test/Analysis/domtest.c b/test/Analysis/domtest.c index 245186a1c239..0f370db5c132 100644 --- a/test/Analysis/domtest.c +++ b/test/Analysis/domtest.c @@ -1,4 +1,6 @@ -// RUN: %clang -cc1 -analyze -analyzer-checker=debug.DumpDominators %s 2>&1 | FileCheck %s +// RUN: rm -f %t +// RUN: %clang -cc1 -analyze -analyzer-checker=debug.DumpDominators %s > %t 2>&1 +// RUN: FileCheck --input-file=%t %s // Test the DominatorsTree implementation with various control flows int test1() @@ -24,13 +26,13 @@ int test1() // CHECK: Immediate dominance tree (Node#,IDom#): // CHECK: (0,1) -// CHECK: (1,2) -// CHECK: (2,8) -// CHECK: (3,4) -// CHECK: (4,7) -// CHECK: (5,7) +// CHECK: (1,7) +// CHECK: (2,3) +// CHECK: (3,6) +// CHECK: (4,6) +// CHECK: (5,6) // CHECK: (6,7) -// CHECK: (7,2) +// CHECK: (7,8) // CHECK: (8,9) // CHECK: (9,9) @@ -55,9 +57,9 @@ int test2() // CHECK: Immediate dominance tree (Node#,IDom#): // CHECK: (0,1) // CHECK: (1,6) -// CHECK: (2,6) +// CHECK: (2,3) // CHECK: (3,4) -// CHECK: (4,2) +// CHECK: (4,6) // CHECK: (5,6) // CHECK: (6,7) // CHECK: (7,7) @@ -83,11 +85,11 @@ int test3() // CHECK: Immediate dominance tree (Node#,IDom#): // CHECK: (0,1) // CHECK: (1,7) -// CHECK: (2,7) +// CHECK: (2,5) // CHECK: (3,4) -// CHECK: (4,2) +// CHECK: (4,5) // CHECK: (5,6) -// CHECK: (6,4) +// CHECK: (6,7) // CHECK: (7,8) // CHECK: (8,8) @@ -108,16 +110,16 @@ int test4() // CHECK: Immediate dominance tree (Node#,IDom#): // CHECK: (0,1) -// CHECK: (1,2) -// CHECK: (2,11) -// CHECK: (3,10) -// CHECK: (4,10) -// CHECK: (5,6) -// CHECK: (6,4) -// CHECK: (7,10) +// CHECK: (1,10) +// CHECK: (2,9) +// CHECK: (3,4) +// CHECK: (4,5) +// CHECK: (5,9) +// CHECK: (6,7) +// CHECK: (7,8) // CHECK: (8,9) -// CHECK: (9,7) -// CHECK: (10,2) +// CHECK: (9,10) +// CHECK: (10,11) // CHECK: (11,12) // CHECK: (12,12) @@ -163,3 +165,4 @@ int test5() // CHECK: (10,11) // CHECK: (11,11) + diff --git a/test/Analysis/dtor.cpp b/test/Analysis/dtor.cpp index 8d63cc47bed4..620994858c7c 100644 --- a/test/Analysis/dtor.cpp +++ b/test/Analysis/dtor.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -analyzer-ipa=inlining -cfg-add-implicit-dtors -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store region -analyzer-ipa=inlining -cfg-add-implicit-dtors -Wno-null-dereference -verify %s + +void clang_analyzer_eval(bool); class A { public: @@ -11,3 +13,163 @@ public: int main() { A a; } + + +typedef __typeof(sizeof(int)) size_t; +void *malloc(size_t); +void free(void *); + +class SmartPointer { + void *X; +public: + SmartPointer(void *x) : X(x) {} + ~SmartPointer() { + free(X); + } +}; + +void testSmartPointer() { + char *mem = (char*)malloc(4); + { + SmartPointer Deleter(mem); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + + +void doSomething(); +void testSmartPointer2() { + char *mem = (char*)malloc(4); + { + SmartPointer Deleter(mem); + // Remove dead bindings... + doSomething(); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + + +class Subclass : public SmartPointer { +public: + Subclass(void *x) : SmartPointer(x) {} +}; + +void testSubclassSmartPointer() { + char *mem = (char*)malloc(4); + { + Subclass Deleter(mem); + // Remove dead bindings... + doSomething(); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + + +class MultipleInheritance : public Subclass, public SmartPointer { +public: + MultipleInheritance(void *a, void *b) : Subclass(a), SmartPointer(b) {} +}; + +void testMultipleInheritance1() { + char *mem = (char*)malloc(4); + { + MultipleInheritance Deleter(mem, 0); + // Remove dead bindings... + doSomething(); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + +void testMultipleInheritance2() { + char *mem = (char*)malloc(4); + { + MultipleInheritance Deleter(0, mem); + // Remove dead bindings... + doSomething(); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + +void testMultipleInheritance3() { + char *mem = (char*)malloc(4); + { + MultipleInheritance Deleter(mem, mem); + // Remove dead bindings... + doSomething(); + // destructor called here + // expected-warning@27 {{Attempt to free released memory}} + } +} + + +class SmartPointerMember { + SmartPointer P; +public: + SmartPointerMember(void *x) : P(x) {} +}; + +void testSmartPointerMember() { + char *mem = (char*)malloc(4); + { + SmartPointerMember Deleter(mem); + // Remove dead bindings... + doSomething(); + // destructor called here + } + *mem = 0; // expected-warning{{Use of memory after it is freed}} +} + + +struct IntWrapper { + IntWrapper() : x(0) {} + ~IntWrapper(); + int *x; +}; + +void testArrayInvalidation() { + int i = 42; + int j = 42; + + { + IntWrapper arr[2]; + + // There should be no undefined value warnings here. + // Eventually these should be TRUE as well, but right now + // we can't handle array constructors. + clang_analyzer_eval(arr[0].x == 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(arr[1].x == 0); // expected-warning{{UNKNOWN}} + + arr[0].x = &i; + arr[1].x = &j; + clang_analyzer_eval(*arr[0].x == 42); // expected-warning{{TRUE}} + clang_analyzer_eval(*arr[1].x == 42); // expected-warning{{TRUE}} + } + + // The destructors should have invalidated i and j. + clang_analyzer_eval(i == 42); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(j == 42); // expected-warning{{UNKNOWN}} +} + + + +// Don't crash on a default argument inside an initializer. +struct DefaultArg { + DefaultArg(int x = 0) {} + ~DefaultArg(); +}; + +struct InheritsDefaultArg : DefaultArg { + InheritsDefaultArg() {} + virtual ~InheritsDefaultArg(); +}; + +void testDefaultArg() { + InheritsDefaultArg a; + // Force a bug to be emitted. + *(char *)0 = 1; // expected-warning{{Dereference of null pointer}} +} diff --git a/test/Analysis/dynamic-cast.cpp b/test/Analysis/dynamic-cast.cpp index 8e63b2bcb363..b1133ac2bee5 100644 --- a/test/Analysis/dynamic-cast.cpp +++ b/test/Analysis/dynamic-cast.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core -verify %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=none -verify %s + +void clang_analyzer_eval(bool); class A { public: @@ -196,6 +198,9 @@ int testDynCastMostLikelyWillFail(C *c) { } else { res = 0; } + + // Note: IPA is turned off for this test because the code below shows how the + // dynamic_cast could succeed. return *res; // expected-warning{{Dereference of null pointer}} } @@ -205,7 +210,25 @@ void callTestDynCastMostLikelyWillFail() { testDynCastMostLikelyWillFail(&m); } + +void testDynCastToMiddleClass () { + class BBB : public BB {}; + BBB obj; + A &ref = obj; + + // These didn't always correctly layer base regions. + B *ptr = dynamic_cast<B*>(&ref); + clang_analyzer_eval(ptr != 0); // expected-warning{{TRUE}} + + // This is actually statically resolved to be a DerivedToBase cast. + ptr = dynamic_cast<B*>(&obj); + clang_analyzer_eval(ptr != 0); // expected-warning{{TRUE}} +} + + +// ----------------------------- // False positives/negatives. +// ----------------------------- // Due to symbolic regions not being typed. int testDynCastFalsePositive(BB *c) { diff --git a/test/Analysis/engine/replay-without-inlining.c b/test/Analysis/engine/replay-without-inlining.c new file mode 100644 index 000000000000..9ec2d08f3993 --- /dev/null +++ b/test/Analysis/engine/replay-without-inlining.c @@ -0,0 +1,57 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -verify %s + +typedef struct { + char I[4]; + int S; +} Hdr; +typedef struct { + short w; +} Hdr2; +typedef struct { + Hdr2 usedtobeundef; +} Info; +typedef struct { + const unsigned char *ib; + int cur; + int end; +} IB; +inline unsigned long gl(IB *input); +inline void gbs(IB *input, unsigned char *buf, int count); +void getB(IB *st, Hdr2 *usedtobeundef); +inline unsigned char gb(IB *input) { + if (input->cur + 1 > input->end) + ; + return input->ib[(input->cur)++]; +} +static void getID(IB *st, char str[4]) { + str[0] = gb(st); + str[1] = gb(st); + str[2] = gb(st); + str[3] = gb(st); +} +static void getH(IB *st, Hdr *header) { + getID (st, header->I); + header->S = gl(st); +} +static void readILBM(IB *st, Info *pic) { + // Initialize field; + pic->usedtobeundef.w = 5; + + // Time out in the function so that we will be forced to retry with no inlining. + Hdr header; + getH (st, &header); + getID(st, header.I); + int i = 0; + while (st->cur < st->end && i < 4) { + i++; + getH (st, &header); + } +} +int bitmapImageRepFromIFF(IB st, const unsigned char *ib, int il) { + Info pic; + st.ib = ib; + st.cur = 0; + st.end = il; + readILBM(&st,&pic); + return pic.usedtobeundef.w; // No undefined value warning here. +} diff --git a/test/Analysis/global-region-invalidation.c b/test/Analysis/global-region-invalidation.c index 184ffb870fb8..71a7285e1f1d 100644 --- a/test/Analysis/global-region-invalidation.c +++ b/test/Analysis/global-region-invalidation.c @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,experimental.security.taint,debug.TaintTest -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -disable-free -analyzer-eagerly-assume -analyzer-checker=core,deadcode,experimental.security.taint,debug.TaintTest,debug.ExprInspection -verify %s + +void clang_analyzer_eval(int); // Note, we do need to include headers here, since the analyzer checks if the function declaration is located in a system header. #include "system-header-simulator.h" @@ -73,3 +75,12 @@ int constIntGlobExtern() { } return 0; } + +void testAnalyzerEvalIsPure() { + extern int someGlobal; + if (someGlobal == 0) { + clang_analyzer_eval(someGlobal == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(someGlobal == 0); // expected-warning{{TRUE}} + } +} + diff --git a/test/Analysis/html-diags.c b/test/Analysis/html-diags.c index 59d81a56a4e9..b9361f72c64c 100644 --- a/test/Analysis/html-diags.c +++ b/test/Analysis/html-diags.c @@ -1,5 +1,5 @@ // RUN: mkdir %t.dir -// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %T.dir %s +// RUN: %clang_cc1 -analyze -analyzer-output=html -analyzer-checker=core -o %t.dir %s // RUN: rm -fR %t.dir // Currently this test mainly checks that the HTML diagnostics doesn't crash diff --git a/test/Analysis/initializer.cpp b/test/Analysis/initializer.cpp index 656a8bf8eed8..d43c8cfd9a0a 100644 --- a/test/Analysis/initializer.cpp +++ b/test/Analysis/initializer.cpp @@ -1,4 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -cfg-add-initializers -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store region -cfg-add-implicit-dtors -std=c++11 -verify %s + +// We don't inline constructors unless we have destructors turned on. + +void clang_analyzer_eval(bool); class A { int x; @@ -7,8 +11,68 @@ public: }; A::A() : x(0) { - if (x != 0) { - int *p = 0; - *p = 0; // no-warning - } + clang_analyzer_eval(x == 0); // expected-warning{{TRUE}} +} + + +class DirectMember { + int x; +public: + DirectMember(int value) : x(value) {} + + int getX() { return x; } +}; + +void testDirectMember() { + DirectMember obj(3); + clang_analyzer_eval(obj.getX() == 3); // expected-warning{{TRUE}} +} + + +class IndirectMember { + struct { + int x; + }; +public: + IndirectMember(int value) : x(value) {} + + int getX() { return x; } +}; + +void testIndirectMember() { + IndirectMember obj(3); + clang_analyzer_eval(obj.getX() == 3); // expected-warning{{TRUE}} +} + + +struct DelegatingConstructor { + int x; + DelegatingConstructor(int y) { x = y; } + DelegatingConstructor() : DelegatingConstructor(42) {} +}; + +void testDelegatingConstructor() { + DelegatingConstructor obj; + clang_analyzer_eval(obj.x == 42); // expected-warning{{TRUE}} +} + + +// ------------------------------------ +// False negatives +// ------------------------------------ + +struct RefWrapper { + RefWrapper(int *p) : x(*p) {} + RefWrapper(int &r) : x(r) {} + int &x; +}; + +void testReferenceMember() { + int *p = 0; + RefWrapper X(p); // should warn in the constructor +} + +void testReferenceMember2() { + int *p = 0; + RefWrapper X(*p); // should warn here } diff --git a/test/Analysis/initializers-cfg-output.cpp b/test/Analysis/initializers-cfg-output.cpp index 8a7a3f5d013d..8aaa94cd84c7 100644 --- a/test/Analysis/initializers-cfg-output.cpp +++ b/test/Analysis/initializers-cfg-output.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-initializers %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s // XPASS: * class A { diff --git a/test/Analysis/inline-plist.c b/test/Analysis/inline-plist.c index 549082dc9ca2..1523e82cc2ea 100644 --- a/test/Analysis/inline-plist.c +++ b/test/Analysis/inline-plist.c @@ -1,4 +1,4 @@ -// RUN: %clang --analyze %s -Xclang -analyzer-ipa=inlining -o %t +// RUN: %clang --analyze %s -Xclang -analyzer-ipa=inlining -fblocks -o %t // RUN: FileCheck -input-file %t %s // <rdar://problem/10967815> @@ -23,6 +23,45 @@ void test_has_bug() { has_bug(0); } +void triggers_bug(int *p) { + *p = 0xDEADBEEF; +} + +// This function triggers a bug by calling triggers_bug(). The diagnostics +// should show when p is assumed to be null. +void bar(int *p) { + if (!!p) + return; + + if (p == 0) + triggers_bug(p); +} + +// ========================================================================== // +// Test inlining of blocks. +// ========================================================================== // + +void test_block__capture_null() { + int *p = 0; + ^(){ *p = 1; }(); +} + +void test_block_ret() { + int *p = ^(){ int *q = 0; return q; }(); + *p = 1; +} + +void test_block_blockvar() { + __block int *p; + ^(){ p = 0; }(); + *p = 1; +} + +void test_block_arg() { + int *p; + ^(int **q){ *q = 0; }(&p); + *p = 1; +} // CHECK: <?xml version="1.0" encoding="UTF-8"?> // CHECK: <plist version="1.0"> @@ -49,7 +88,7 @@ void test_has_bug() { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>11</integer> -// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -62,7 +101,7 @@ void test_has_bug() { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>12</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -83,7 +122,7 @@ void test_has_bug() { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>12</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -159,7 +198,7 @@ void test_has_bug() { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>14</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -180,7 +219,7 @@ void test_has_bug() { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>14</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -235,6 +274,7 @@ void test_has_bug() { // CHECK: <key>type</key><string>Division by zero</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>foo</string> +// CHECK: <key>issue_hash</key><integer>4</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>14</integer> @@ -302,7 +342,7 @@ void test_has_bug() { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>18</integer> -// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -357,6 +397,7 @@ void test_has_bug() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>has_bug</string> +// CHECK: <key>issue_hash</key><integer>1</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>19</integer> @@ -364,6 +405,785 @@ void test_has_bug() { // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Assuming 'p' is null</string> +// CHECK: <key>message</key> +// CHECK: <string>Assuming 'p' is null</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>36</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>36</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>36</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>36</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>37</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>37</integer> +// CHECK: <key>col</key><integer>16</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>37</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>37</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>37</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'triggers_bug'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'triggers_bug'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>26</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'bar'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'bar'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>26</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>26</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>27</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>27</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>27</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>27</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>27</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: <key>message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Dereference of null pointer</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>triggers_bug</string> +// CHECK: <key>issue_hash</key><integer>1</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>27</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: <key>message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling anonymous block</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling anonymous block</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'test_block__capture_null'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'test_block__capture_null'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: <key>message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Dereference of null pointer</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: <key>message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Dereference of null pointer</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>test_block_ret</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: <key>message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Dereference of null pointer</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>test_block_blockvar</string> +// CHECK: <key>issue_hash</key><integer>3</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>61</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>61</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>62</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>62</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>62</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>62</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: <key>message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'p')</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Dereference of null pointer</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>test_block_arg</string> +// CHECK: <key>issue_hash</key><integer>3</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> // CHECK: </array> // CHECK: </dict> // CHECK: </plist> diff --git a/test/Analysis/inline-unique-reports.c b/test/Analysis/inline-unique-reports.c index ae94267d2c25..9248ad2632f5 100644 --- a/test/Analysis/inline-unique-reports.c +++ b/test/Analysis/inline-unique-reports.c @@ -34,26 +34,26 @@ void test_bug_2() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>9</integer> +// CHECK: <key>line</key><integer>14</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>9</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>14</integer> +// CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>line</key><integer>15</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>15</integer> +// CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -64,7 +64,7 @@ void test_bug_2() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>line</key><integer>15</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -72,12 +72,12 @@ void test_bug_2() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>line</key><integer>15</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>line</key><integer>15</integer> // CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -99,9 +99,9 @@ void test_bug_2() { // CHECK: </dict> // CHECK: <key>depth</key><integer>1</integer> // CHECK: <key>extended_message</key> -// CHECK: <string>Entered call from 'test_bug_1'</string> +// CHECK: <string>Entered call from 'test_bug_2'</string> // CHECK: <key>message</key> -// CHECK: <string>Entered call from 'test_bug_1'</string> +// CHECK: <string>Entered call from 'test_bug_2'</string> // CHECK: </dict> // CHECK: <dict> // CHECK: <key>kind</key><string>control</string> @@ -117,7 +117,7 @@ void test_bug_2() { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>4</integer> -// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -172,6 +172,7 @@ void test_bug_2() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>bug</string> +// CHECK: <key>issue_hash</key><integer>1</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>5</integer> @@ -182,3 +183,4 @@ void test_bug_2() { // CHECK: </array> // CHECK: </dict> // CHECK: </plist> + diff --git a/test/Analysis/inline.c b/test/Analysis/inline.c index 0827d934614a..944e1e2985f1 100644 --- a/test/Analysis/inline.c +++ b/test/Analysis/inline.c @@ -1,8 +1,12 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -analyzer-store region -verify %s + +void clang_analyzer_eval(int); +void clang_analyzer_checkInlined(int); int test1_f1() { int y = 1; y++; + clang_analyzer_checkInlined(1); // expected-warning{{TRUE}} return y; } @@ -90,3 +94,19 @@ int test_rdar10977037() { } +// Test inlining a forward-declared function. +// This regressed when CallEvent was first introduced. +int plus1(int x); +void test() { + clang_analyzer_eval(plus1(2) == 3); // expected-warning{{TRUE}} +} + +int plus1(int x) { + return x + 1; +} + + +void never_called_by_anyone() { + clang_analyzer_checkInlined(0); // no-warning +} + diff --git a/test/Analysis/inline.cpp b/test/Analysis/inline.cpp new file mode 100644 index 000000000000..4eaed9fed13c --- /dev/null +++ b/test/Analysis/inline.cpp @@ -0,0 +1,168 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -verify %s + +void clang_analyzer_eval(bool); +void clang_analyzer_checkInlined(bool); + +class A { +public: + int getZero() { return 0; } + virtual int getNum() { return 0; } +}; + +void test(A &a) { + clang_analyzer_eval(a.getZero() == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(a.getNum() == 0); // expected-warning{{UNKNOWN}} + + A copy(a); + clang_analyzer_eval(copy.getZero() == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(copy.getNum() == 0); // expected-warning{{TRUE}} +} + + +class One : public A { +public: + virtual int getNum() { return 1; } +}; + +void testPathSensitivity(int x) { + A a; + One b; + + A *ptr; + switch (x) { + case 0: + ptr = &a; + break; + case 1: + ptr = &b; + break; + default: + return; + } + + // This should be true on both branches. + clang_analyzer_eval(ptr->getNum() == x); // expected-warning {{TRUE}} +} + + +namespace PureVirtualParent { + class Parent { + public: + virtual int pureVirtual() const = 0; + int callVirtual() const { + return pureVirtual(); + } + }; + + class Child : public Parent { + public: + virtual int pureVirtual() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return 42; + } + }; + + void testVirtual() { + Child x; + + clang_analyzer_eval(x.pureVirtual() == 42); // expected-warning{{TRUE}} + clang_analyzer_eval(x.callVirtual() == 42); // expected-warning{{TRUE}} + } +} + + +namespace PR13569 { + class Parent { + protected: + int m_parent; + virtual int impl() const = 0; + + Parent() : m_parent(0) {} + + public: + int interface() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return impl(); + } + }; + + class Child : public Parent { + protected: + virtual int impl() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return m_parent + m_child; + } + + public: + Child() : m_child(0) {} + + int m_child; + }; + + void testVirtual() { + Child x; + x.m_child = 42; + + // Don't crash when inlining and devirtualizing. + x.interface(); + } + + + class Grandchild : public Child {}; + + void testDevirtualizeToMiddle() { + Grandchild x; + x.m_child = 42; + + // Don't crash when inlining and devirtualizing. + x.interface(); + } +} + +namespace PR13569_virtual { + class Parent { + protected: + int m_parent; + virtual int impl() const = 0; + + Parent() : m_parent(0) {} + + public: + int interface() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return impl(); + } + }; + + class Child : virtual public Parent { + protected: + virtual int impl() const { + clang_analyzer_checkInlined(true); // expected-warning{{TRUE}} + return m_parent + m_child; + } + + public: + Child() : m_child(0) {} + + int m_child; + }; + + void testVirtual() { + Child x; + x.m_child = 42; + + // Don't crash when inlining and devirtualizing. + x.interface(); + } + + + class Grandchild : virtual public Child {}; + + void testDevirtualizeToMiddle() { + Grandchild x; + x.m_child = 42; + + // Don't crash when inlining and devirtualizing. + x.interface(); + } +} diff --git a/test/Analysis/inlining/DynDispatchBifurcate.m b/test/Analysis/inlining/DynDispatchBifurcate.m new file mode 100644 index 000000000000..e78b90bb8c1f --- /dev/null +++ b/test/Analysis/inlining/DynDispatchBifurcate.m @@ -0,0 +1,181 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=dynamic-bifurcate -verify %s + +#include "InlineObjCInstanceMethod.h" + +@interface MyParent : NSObject +- (int)getZero; +@end +@implementation MyParent +- (int)getZero { + return 0; +} +@end + +@interface PublicClass () { + int value2; +} +@property (readwrite) int value1; +- (void)setValue2:(int)newValue2; +@end + +@implementation PublicClass + +- (int)getZeroPublic { + return 0; +} + +@synthesize value1; + +- (int)value2 { + return value2; +} +- (void)setValue2:(int)newValue { + value2 = newValue; +} + +- (int)value3 { + return value3; +} +- (void)setValue3:(int)newValue { + value3 = newValue; +} + +@end + +@interface MyClassWithPublicParent : PublicClass +- (int)getZeroPublic; +@end +@implementation MyClassWithPublicParent +- (int)getZeroPublic { + return 0; +} +@end + +// Category overrides a public method. +@interface PublicSubClass (PrvateCat) + - (int) getZeroPublic; +@end +@implementation PublicSubClass (PrvateCat) +- (int)getZeroPublic { + return 0; +} +@end + + +@interface MyClass : MyParent { + int value; +} +- (int)getZero; +@property int value; +@end + +// Since class is private, we assume that it cannot be subclassed. +// False negative: this class is "privately subclassed". this is very rare +// in practice. +@implementation MyClass ++ (int) testTypeFromParam:(MyParent*) p { + int m = 0; + int z = [p getZero]; + if (z) + return 5/m; // false negative + return 5/[p getZero];// expected-warning {{Division by zero}} +} + +// Here only one definition is possible, since the declaration is not visible +// from outside. ++ (int) testTypeFromParamPrivateChild:(MyClass*) c { + int m = 0; + int z = [c getZero]; // MyClass overrides getZero to return '1'. + if (z) + return 5/m; // expected-warning {{Division by zero}} + return 5/[c getZero];//no warning +} + +- (int)getZero { + return 1; +} + +- (int)value { + return value; +} + +- (void)setValue:(int)newValue { + value = newValue; +} + +// Test ivar access. +- (int) testIvarInSelf { + value = 0; + return 5/value; // expected-warning {{Division by zero}} +} + ++ (int) testIvar: (MyClass*) p { + p.value = 0; + return 5/p.value; // expected-warning {{Division by zero}} +} + +// Test simple property access. ++ (int) testProperty: (MyClass*) p { + int x= 0; + [p setValue:0]; + return 5/[p value]; // expected-warning {{Division by zero}} +} + +@end + +// The class is prvate and is not subclassed. +int testCallToPublicAPIInParent(MyClassWithPublicParent *p) { + int m = 0; + int z = [p getZeroPublic]; + if (z) + return 5/m; // no warning + return 5/[p getZeroPublic];// expected-warning {{Division by zero}} +} + +// When the called method is public (due to it being defined outside of main file), +// split the path and analyze both branches. +// In this case, p can be either the object of type MyParent* or MyClass*: +// - If it's MyParent*, getZero returns 0. +// - If it's MyClass*, getZero returns 1 and 'return 5/m' is reachable. +// Declaration is provate, but p can be a subclass (MyClass*). +int testCallToPublicAPI(PublicClass *p) { + int m = 0; + int z = [p getZeroPublic]; + if (z) + return 5/m; // expected-warning {{Division by zero}} + return 5/[p getZeroPublic];// expected-warning {{Division by zero}} +} + +// Even though the method is privately declared in the category, the parent +// declares the method as public. Assume the instance can be subclassed. +int testCallToPublicAPICat(PublicSubClass *p) { + int m = 0; + int z = [p getZeroPublic]; + if (z) + return 5/m; // expected-warning {{Division by zero}} + return 5/[p getZeroPublic];// expected-warning {{Division by zero}} +} + +// Test public property - properties should always be inlined, regardless +// weither they are "public" or private. +int testPublicProperty(PublicClass *p) { + int x = 0; + [p setValue3:0]; + if ([p value3] != 0) + return 5/x; // expected-warning {{Division by zero}} // TODO: no warning, we should always inline the property. + return 5/[p value3];// expected-warning {{Division by zero}} +} + +int testExtension(PublicClass *p) { + int x = 0; + [p setValue2:0]; + if ([p value2] != 0) + return 5/x; // expected-warning {{Division by zero}} // TODO: no warning, we should always inline the property. + return 5/[p value2]; // expected-warning {{Division by zero}} +} + +// TODO: we do not handle synthesized properties yet. +int testPropertySynthesized(PublicClass *p) { + [p setValue1:0]; + return 5/[p value1]; +} diff --git a/test/Analysis/inlining/InlineObjCClassMethod.m b/test/Analysis/inlining/InlineObjCClassMethod.m new file mode 100644 index 000000000000..7e8b51fe0be0 --- /dev/null +++ b/test/Analysis/inlining/InlineObjCClassMethod.m @@ -0,0 +1,181 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=dynamic-bifurcate -verify %s + +// Test inlining of ObjC class methods. + +typedef signed char BOOL; +typedef struct objc_class *Class; +typedef struct objc_object { + Class isa; +} *id; +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@interface NSObject <NSObject> {} ++(id)alloc; +-(id)init; +-(id)autorelease; +-(id)copy; +- (Class)class; +-(id)retain; +@end + +// Vanila: ObjC class method is called by name. +@interface MyParent : NSObject ++ (int)getInt; +@end +@interface MyClass : MyParent ++ (int)getInt; +@end +@implementation MyClass ++ (int)testClassMethodByName { + int y = [MyClass getInt]; + return 5/y; // expected-warning {{Division by zero}} +} ++ (int)getInt { + return 0; +} +@end + +// The definition is defined by the parent. Make sure we find it and inline. +@interface MyParentDIP : NSObject ++ (int)getInt; +@end +@interface MyClassDIP : MyParentDIP +@end +@implementation MyClassDIP ++ (int)testClassMethodByName { + int y = [MyClassDIP getInt]; + return 5/y; // expected-warning {{Division by zero}} +} +@end +@implementation MyParentDIP ++ (int)getInt { + return 0; +} +@end + +// ObjC class method is called by name. Definition is in the category. +@interface AAA : NSObject +@end +@interface AAA (MyCat) ++ (int)getInt; +@end +int foo() { + int y = [AAA getInt]; + return 5/y; // expected-warning {{Division by zero}} +} +@implementation AAA +@end +@implementation AAA (MyCat) ++ (int)getInt { + return 0; +} +@end + +// ObjC class method is called by name. Definition is in the parent category. +@interface PPP : NSObject +@end +@interface PPP (MyCat) ++ (int)getInt; +@end +@interface CCC : PPP +@end +int foo4() { + int y = [CCC getInt]; + return 5/y; // expected-warning {{Division by zero}} +} +@implementation PPP +@end +@implementation PPP (MyCat) ++ (int)getInt { + return 0; +} +@end + +// There is no declaration in the class but there is one in the parent. Make +// sure we pick the definition from the class and not the parent. +@interface MyParentTricky : NSObject ++ (int)getInt; +@end +@interface MyClassTricky : MyParentTricky +@end +@implementation MyParentTricky ++ (int)getInt { + return 0; +} +@end +@implementation MyClassTricky ++ (int)getInt { + return 1; +} ++ (int)testClassMethodByName { + int y = [MyClassTricky getInt]; + return 5/y; // no-warning +} +@end + +// ObjC class method is called by unknown class declaration (passed in as a +// parameter). We should not inline in such case. +@interface MyParentUnknown : NSObject ++ (int)getInt; +@end +@interface MyClassUnknown : MyParentUnknown ++ (int)getInt; +@end +@implementation MyClassUnknown ++ (int)testClassVariableByUnknownVarDecl: (Class)cl { + int y = [cl getInt]; + return 3/y; // no-warning +} ++ (int)getInt { + return 0; +} +@end + + +// False negative. +// ObjC class method call through a decl with a known type. +// We should be able to track the type of currentClass and inline this call. +// Note, [self class] could be a subclass. Do we still want to inline here? +@interface MyClassKT : NSObject +@end +@interface MyClassKT (MyCatKT) ++ (int)getInt; +@end +@implementation MyClassKT (MyCatKT) ++ (int)getInt { + return 0; +} +@end +@implementation MyClassKT +- (int)testClassMethodByKnownVarDecl { + Class currentClass = [self class]; + int y = [currentClass getInt]; + return 5/y; // Would be great to get a warning here. +} +@end + +// Another false negative due to us not reasoning about self, which in this +// case points to the object of the class in the call site and should be equal +// to [MyParent class]. +@interface MyParentSelf : NSObject ++ (int)testSelf; +@end +@implementation MyParentSelf ++ (int)testSelf { + if (self == [MyParentSelf class]) + return 0; + else + return 1; +} +@end +@interface MyClassSelf : MyParentSelf +@end +@implementation MyClassSelf ++ (int)testClassMethodByKnownVarDecl { + int y = [MyParentSelf testSelf]; + return 5/y; // Should warn here. +} +@end +int foo2() { + int y = [MyParentSelf testSelf]; + return 5/y; // Should warn here. +} diff --git a/test/Analysis/inlining/InlineObjCInstanceMethod.h b/test/Analysis/inlining/InlineObjCInstanceMethod.h new file mode 100644 index 000000000000..bb0da280c8ef --- /dev/null +++ b/test/Analysis/inlining/InlineObjCInstanceMethod.h @@ -0,0 +1,46 @@ + +// Define a public header for the ObjC methods that are "visible" externally +// and, thus, could be sub-classed. We should explore the path on which these +// are sub-classed with unknown class by not inlining them. + +typedef signed char BOOL; +typedef struct objc_class *Class; +typedef struct objc_object { + Class isa; +} *id; +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@interface NSObject <NSObject> {} ++(id)alloc; ++(id)new; +-(id)init; +-(id)autorelease; +-(id)copy; +- (Class)class; +-(id)retain; +@end + +@interface PublicClass : NSObject { + int value3; +} +- (int)getZeroPublic; + +- (int) value2; + +@property (readonly) int value1; + +@property int value3; +- (int)value3; +- (void)setValue3:(int)newValue; +@end + +@interface PublicSubClass : PublicClass +@end + +@interface PublicParent : NSObject +- (int)getZeroOverridden; +@end + +@interface PublicSubClass2 : PublicParent +- (int) getZeroOverridden; +@end + diff --git a/test/Analysis/inlining/InlineObjCInstanceMethod.m b/test/Analysis/inlining/InlineObjCInstanceMethod.m new file mode 100644 index 000000000000..31b6d5baa6f8 --- /dev/null +++ b/test/Analysis/inlining/InlineObjCInstanceMethod.m @@ -0,0 +1,86 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=dynamic-bifurcate -verify %s + +#include "InlineObjCInstanceMethod.h" + +// Method is defined in the parent; called through self. +@interface MyParent : NSObject +- (int)getInt; +@end +@implementation MyParent +- (int)getInt { + return 0; +} +@end + +@interface MyClass : MyParent +@end +@implementation MyClass +- (int)testDynDispatchSelf { + int y = [self getInt]; + return 5/y; // expected-warning {{Division by zero}} +} + +// Get the dynamic type info from a cast (from id to MyClass*). ++ (int)testAllocInit { + MyClass *a = [[self alloc] init]; + return 5/[a getInt]; // expected-warning {{Division by zero}} +} + +// Method is called on inited object. ++ (int)testAllocInit2 { + MyClass *a = [[MyClass alloc] init]; + return 5/[a getInt]; // expected-warning {{Division by zero}} +} + +// Method is called on a parameter. ++ (int)testParam: (MyClass*) a { + return 5/[a getInt]; // expected-warning {{Division by zero}} +} + +// Method is called on a parameter of unnown type. ++ (int)testParamUnknownType: (id) a { + return 5/[a getInt]; // no warning +} + +@end + +// TODO: When method is inlined, the attribute reset should be visible. +@interface TestSettingAnAttributeInCallee : NSObject { + int _attribute; +} + - (void) method2; +@end + +@implementation TestSettingAnAttributeInCallee +- (int) method1 { + [self method2]; + return 5/_attribute; // expected-warning {{Division by zero}} +} + +- (void) method2 { + _attribute = 0; +} +@end + +@interface TestSettingAnAttributeInCaller : NSObject { + int _attribute; +} + - (int) method2; +@end + +@implementation TestSettingAnAttributeInCaller +- (void) method1 { + _attribute = 0; + [self method2]; +} + +- (int) method2 { + return 5/_attribute; // expected-warning {{Division by zero}} +} +@end + + +// Don't crash if we don't know the receiver's region. +void randomlyMessageAnObject(MyClass *arr[], int i) { + (void)[arr[i] getInt]; +}
\ No newline at end of file diff --git a/test/Analysis/inlining/ObjCDynTypePopagation.m b/test/Analysis/inlining/ObjCDynTypePopagation.m new file mode 100644 index 000000000000..4faaa2cb3033 --- /dev/null +++ b/test/Analysis/inlining/ObjCDynTypePopagation.m @@ -0,0 +1,84 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=dynamic-bifurcate -verify %s + +#include "InlineObjCInstanceMethod.h" + +void clang_analyzer_eval(int); + +PublicSubClass2 *getObj(); + +@implementation PublicParent +- (int) getZeroOverridden { + return 1; +} +- (int) getZero { + return 0; +} +@end + +@implementation PublicSubClass2 +- (int) getZeroOverridden { + return 0; +} + +/* Test that we get the right type from call to alloc. */ ++ (void) testAllocSelf { + id a = [self alloc]; + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + + ++ (void) testAllocClass { + id a = [PublicSubClass2 alloc]; + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + ++ (void) testAllocSuperOverriden { + id a = [super alloc]; + // Evaluates to 1 in the parent. + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{FALSE}} +} + ++ (void) testAllocSuper { + id a = [super alloc]; + clang_analyzer_eval([a getZero] == 0); // expected-warning{{TRUE}} +} + ++ (void) testAllocInit { + id a = [[self alloc] init]; + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + ++ (void) testNewSelf { + id a = [self new]; + clang_analyzer_eval([a getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + +// Casting to parent should not pessimize the dynamic type. ++ (void) testCastToParent { + id a = [[self alloc] init]; + PublicParent *p = a; + clang_analyzer_eval([p getZeroOverridden] == 0); // expected-warning{{TRUE}} +} + +// The type of parameter gets used. ++ (void)testTypeFromParam:(PublicParent*) p { + clang_analyzer_eval([p getZero] == 0); // expected-warning{{TRUE}} +} + +// Test implicit cast. +// Note, in this case, p could also be a subclass of MyParent. ++ (void) testCastFromId:(id) a { + PublicParent *p = a; + clang_analyzer_eval([p getZero] == 0); // expected-warning{{TRUE}} +} +@end + +// TODO: Would be nice to handle the case of dynamically obtained class info +// as well. We need a MemRegion for class types for this. +int testDynamicClass(BOOL coin) { + Class AllocClass = (coin ? [NSObject class] : [PublicSubClass2 class]); + id x = [[AllocClass alloc] init]; + if (coin) + return [x getZero]; + return 1; +} diff --git a/test/Analysis/inlining/ObjCImproperDynamictallyDetectableCast.m b/test/Analysis/inlining/ObjCImproperDynamictallyDetectableCast.m new file mode 100644 index 000000000000..739e10f2a5f9 --- /dev/null +++ b/test/Analysis/inlining/ObjCImproperDynamictallyDetectableCast.m @@ -0,0 +1,37 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=dynamic-bifurcate -verify %s + +typedef signed char BOOL; +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@interface NSObject <NSObject> {} ++(id)alloc; +-(id)init; ++(id)new; +-(id)autorelease; +-(id)copy; +- (Class)class; +-(id)retain; +@end +void clang_analyzer_eval(BOOL); + +@interface SomeOtherClass : NSObject +- (int)getZero; +@end +@implementation SomeOtherClass +- (int)getZero { return 0; } +@end + +@interface MyClass : NSObject +- (int)getZero; +@end + +@implementation MyClass +- (int)getZero { return 1; } + +// TODO: Not only we should correctly determine that the type of o at runtime +// is MyClass, but we should also warn about it. ++ (void) testCastToParent { + id a = [[self alloc] init]; + SomeOtherClass *o = a; + clang_analyzer_eval([o getZero] == 0); // expected-warning{{FALSE}} +} +@end diff --git a/test/Analysis/inlining/RetainCountExamples.m b/test/Analysis/inlining/RetainCountExamples.m new file mode 100644 index 000000000000..2b682c2b4bf0 --- /dev/null +++ b/test/Analysis/inlining/RetainCountExamples.m @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-ipa=dynamic-bifurcate -verify %s + +typedef signed char BOOL; +typedef struct objc_class *Class; +typedef struct objc_object { + Class isa; +} *id; +@protocol NSObject - (BOOL)isEqual:(id)object; @end +@interface NSObject <NSObject> {} ++(id)alloc; ++(id)new; +- (oneway void)release; +-(id)init; +-(id)autorelease; +-(id)copy; +- (Class)class; +-(id)retain; +@end + +@interface SelfStaysLive : NSObject +- (id)init; +@end + +@implementation SelfStaysLive +- (id)init { + return [super init]; +} +@end + +void selfStaysLive() { + SelfStaysLive *foo = [[SelfStaysLive alloc] init]; + [foo release]; +}
\ No newline at end of file diff --git a/test/Analysis/inlining/path-notes.c b/test/Analysis/inlining/path-notes.c new file mode 100644 index 000000000000..0885eafa5b93 --- /dev/null +++ b/test/Analysis/inlining/path-notes.c @@ -0,0 +1,1291 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-output=text -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-output=plist-multi-file %s -o - | FileCheck %s + +void zero(int **p) { + *p = 0; + // expected-note@-1 {{Null pointer value stored to 'a'}} +} + +void testZero(int *a) { + zero(&a); + // expected-note@-1 {{Calling 'zero'}} + // expected-note@-2 {{Returning from 'zero'}} + *a = 1; // expected-warning{{Dereference of null pointer}} + // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} +} + + +void check(int *p) { + if (p) { + // expected-note@-1 + {{Assuming 'p' is null}} + // expected-note@-2 + {{Assuming pointer value is null}} + // expected-note@-3 + {{Taking false branch}} + return; + } + return; +} + +void testCheck(int *a) { + check(a); + // expected-note@-1 {{Calling 'check'}} + // expected-note@-2 {{Returning from 'check'}} + *a = 1; // expected-warning{{Dereference of null pointer}} + // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} +} + + +int *getPointer(); + +void testInitCheck() { + int *a = getPointer(); + // expected-note@-1 {{Variable 'a' initialized here}} + check(a); + // expected-note@-1 {{Calling 'check'}} + // expected-note@-2 {{Returning from 'check'}} + *a = 1; // expected-warning{{Dereference of null pointer}} + // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} +} + +void testStoreCheck(int *a) { + a = getPointer(); + // expected-note@-1 {{Value assigned to 'a'}} + check(a); + // expected-note@-1 {{Calling 'check'}} + // expected-note@-2 {{Returning from 'check'}} + *a = 1; // expected-warning{{Dereference of null pointer}} + // expected-note@-1 {{Dereference of null pointer (loaded from variable 'a')}} +} + + +// CHECK: <?xml version="1.0" encoding="UTF-8"?> +// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +// CHECK: <plist version="1.0"> +// CHECK: <dict> +// CHECK: <key>files</key> +// CHECK: <array> +// CHECK: <string>{{.*}}path-notes.c</string> +// CHECK: </array> +// CHECK: <key>diagnostics</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'zero'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'zero'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>4</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'testZero'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'testZero'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>4</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>4</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>5</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>5</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>5</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>5</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>5</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Null pointer value stored to 'a'</string> +// CHECK: <key>message</key> +// CHECK: <string>Null pointer value stored to 'a'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Returning from 'zero'</string> +// CHECK: <key>message</key> +// CHECK: <string>Returning from 'zero'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: <key>message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Dereference of null pointer</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>testZero</string> +// CHECK: <key>issue_hash</key><integer>4</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'check'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'check'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'testCheck'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'testCheck'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Assuming 'p' is null</string> +// CHECK: <key>message</key> +// CHECK: <string>Assuming 'p' is null</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Assuming pointer value is null</string> +// CHECK: <key>message</key> +// CHECK: <string>Assuming pointer value is null</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>25</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>25</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Returning from 'check'</string> +// CHECK: <key>message</key> +// CHECK: <string>Returning from 'check'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: <key>message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Dereference of null pointer</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>testCheck</string> +// CHECK: <key>issue_hash</key><integer>4</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>40</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>40</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>40</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Variable 'a' initialized here</string> +// CHECK: <key>message</key> +// CHECK: <string>Variable 'a' initialized here</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>40</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>40</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'check'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'check'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'testInitCheck'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'testInitCheck'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Assuming 'p' is null</string> +// CHECK: <key>message</key> +// CHECK: <string>Assuming 'p' is null</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>25</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>25</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Returning from 'check'</string> +// CHECK: <key>message</key> +// CHECK: <string>Returning from 'check'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: <key>message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Dereference of null pointer</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>testInitCheck</string> +// CHECK: <key>issue_hash</key><integer>6</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Value assigned to 'a'</string> +// CHECK: <key>message</key> +// CHECK: <string>Value assigned to 'a'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'check'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'check'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'testStoreCheck'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'testStoreCheck'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Assuming 'p' is null</string> +// CHECK: <key>message</key> +// CHECK: <string>Assuming 'p' is null</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>25</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>25</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Returning from 'check'</string> +// CHECK: <key>message</key> +// CHECK: <string>Returning from 'check'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: <key>message</key> +// CHECK: <string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Dereference of null pointer (loaded from variable 'a')</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Dereference of null pointer</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>testStoreCheck</string> +// CHECK: <key>issue_hash</key><integer>6</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </plist> diff --git a/test/Analysis/iterators.cpp b/test/Analysis/iterators.cpp deleted file mode 100644 index 1b6340b2af28..000000000000 --- a/test/Analysis/iterators.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// RUN: %clang --analyze -Xclang -analyzer-checker=core,experimental.cplusplus.Iterators -Xclang -verify %s -// XFAIL: win32 - -#include <vector> - -void fum(std::vector<int>::iterator t); - -void foo1() -{ - // iterators that are defined but not initialized - std::vector<int>::iterator it2; - fum(it2); // expected-warning{{Use of iterator that is not defined}} - *it2; // expected-warning{{Use of iterator that is not defined}} - - std::vector<int> v, vv; - std::vector<int>::iterator it = v.begin(); - fum(it); // no-warning - *it; // no-warning - // a valid iterator plus an integer is still valid - std::vector<int>::iterator et = it + 3; - while(it != et) { // no-warning - if (*it == 0) // no-warning - *it = 1; // no-warning - } - // iterators from different instances Cannot be compared - et = vv.end(); - while(it != et) // expected-warning{{Cannot compare iterators from different containers}} - ; - - for( std::vector<int>::iterator it = v.begin(); it != v.end(); it++ ) { // no-warning - if (*it == 1) // no-warning - *it = 0; // no-warning - } - - // copying a valid iterator results in a valid iterator - et = it; // no-warning - *et; // no-warning - - // any combo of valid iterator plus a constant is still valid - et = it + 2; // no-warning - *et; // no-warning - et = 2 + it; // no-warning - *et; // no-warning - et = 2 + 4 + it; // no-warning - *et; // no-warning - - // calling insert invalidates unless assigned to as result, but still - // invalidates other iterators on the same instance - it = v.insert( it, 1 ); // no-warning - *et; // expected-warning{{Attempt to use an iterator made invalid by call to 'insert'}} - ++it; // no-warning - - // calling erase invalidates the iterator - v.erase(it); // no-warning - et = it + 2; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}} - et = 2 + it + 2; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}} - et = 2 + it; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}} - ++it; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}} - it++; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}} - *it; // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}} - it = v.insert( it, 1 ); // expected-warning{{Attempt to use an iterator made invalid by call to 'erase'}} - // now valid after return from insert - *it; // no-warning -} - -// work with using namespace -void foo2() -{ - using namespace std; - - vector<int> v; - vector<int>::iterator it = v.begin(); - *it; // no-warning - v.insert( it, 1 ); // no-warning - *it; // expected-warning{{Attempt to use an iterator made invalid by call to 'insert'}} - it = v.insert( it, 1 ); // expected-warning{{Attempt to use an iterator made invalid by call to 'insert'}} - *it; // no-warning -} - -// using reserve eliminates some warnings -void foo3() -{ - std::vector<long> v; - std::vector<long>::iterator b = v.begin(); - v.reserve( 100 ); - - // iterator assigned before the reserve is still invalidated - *b; // expected-warning{{Attempt to use an iterator made invalid by call to 'reserve'}} - b = v.begin(); - v.insert( b, 1 ); // no-warning - - // iterator after assignment is still valid (probably) - *b; // no-warning -} - -// check on copying one iterator to another -void foo4() -{ - std::vector<float> v, vv; - std::vector<float>::iterator it = v.begin(); - *it; // no-warning - v = vv; - *it; // expected-warning{{Attempt to use an iterator made invalid by copying another container to its container}} -} - diff --git a/test/Analysis/ivars.m b/test/Analysis/ivars.m new file mode 100644 index 000000000000..42e92d259a9f --- /dev/null +++ b/test/Analysis/ivars.m @@ -0,0 +1,132 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-store=region -fblocks -verify -Wno-objc-root-class %s + +void clang_analyzer_eval(int); + +@interface Root { +@public + int uniqueID; +} + +- (void)refreshID; +@end + +void testInvalidation(Root *obj) { + int savedID = obj->uniqueID; + clang_analyzer_eval(savedID == obj->uniqueID); // expected-warning{{TRUE}} + + [obj refreshID]; + clang_analyzer_eval(savedID == obj->uniqueID); // expected-warning{{UNKNOWN}} +} + + +@interface Child : Root +@end + +@implementation Child +- (void)testSuperInvalidation { + int savedID = self->uniqueID; + clang_analyzer_eval(savedID == self->uniqueID); // expected-warning{{TRUE}} + + [super refreshID]; + clang_analyzer_eval(savedID == self->uniqueID); // expected-warning{{UNKNOWN}} +} +@end + + +@interface ManyIvars { + struct S { int a, b; } s; + int c; + int d; +} +@end + +struct S makeS(); + +@implementation ManyIvars + +- (void)testMultipleIvarInvalidation:(int)useConstraints { + if (useConstraints) { + if (s.a != 1) return; + if (s.b != 2) return; + if (c != 3) return; + if (d != 4) return; + return; + } else { + s.a = 1; + s.b = 2; + c = 3; + d = 4; + } + + clang_analyzer_eval(s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(s.b == 2); // expected-warning{{TRUE}} + clang_analyzer_eval(c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(d == 4); // expected-warning{{TRUE}} + + d = 0; + + clang_analyzer_eval(s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(s.b == 2); // expected-warning{{TRUE}} + clang_analyzer_eval(c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(d == 0); // expected-warning{{TRUE}} + + d = 4; + s = makeS(); + + clang_analyzer_eval(s.a == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(s.b == 2); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(d == 4); // expected-warning{{TRUE}} + + s.a = 1; + + clang_analyzer_eval(s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(s.b == 2); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(d == 4); // expected-warning{{TRUE}} +} + ++ (void)testMultipleIvarInvalidation:(int)useConstraints + forObject:(ManyIvars *)obj { + if (useConstraints) { + if (obj->s.a != 1) return; + if (obj->s.b != 2) return; + if (obj->c != 3) return; + if (obj->d != 4) return; + return; + } else { + obj->s.a = 1; + obj->s.b = 2; + obj->c = 3; + obj->d = 4; + } + + clang_analyzer_eval(obj->s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->s.b == 2); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->d == 4); // expected-warning{{TRUE}} + + obj->d = 0; + + clang_analyzer_eval(obj->s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->s.b == 2); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->d == 0); // expected-warning{{TRUE}} + + obj->d = 4; + obj->s = makeS(); + + clang_analyzer_eval(obj->s.a == 1); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(obj->s.b == 2); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(obj->c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->d == 4); // expected-warning{{TRUE}} + + obj->s.a = 1; + + clang_analyzer_eval(obj->s.a == 1); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->s.b == 2); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(obj->c == 3); // expected-warning{{TRUE}} + clang_analyzer_eval(obj->d == 4); // expected-warning{{TRUE}} +} + +@end diff --git a/test/Analysis/malloc-annotations.c b/test/Analysis/malloc-annotations.c index a0c145279d92..1dc0f7837bad 100644 --- a/test/Analysis/malloc-annotations.c +++ b/test/Analysis/malloc-annotations.c @@ -70,10 +70,9 @@ void af1_c() { myglobalpointer = my_malloc(12); // no-warning } -// TODO: We will be able to handle this after we add support for tracking allocations stored in struct fields. void af1_d() { struct stuff mystuff; - mystuff.somefield = my_malloc(12); // false negative + mystuff.somefield = my_malloc(12); // expected-warning{{Memory is never released; potential leak}} } // Test that we can pass out allocated memory via pointer-to-pointer. @@ -123,12 +122,11 @@ void af2e() { free(p); // no-warning } -// This case would inflict a double-free elsewhere. -// However, this case is considered an analyzer bug since it causes false-positives. +// This case inflicts a possible double-free. void af3() { int *p = my_malloc(12); my_hold(p); - free(p); // no-warning + free(p); // expected-warning{{Attempt to free non-owned memory}} } int * af4() { diff --git a/test/Analysis/malloc-plist.c b/test/Analysis/malloc-plist.c index db2e0f01e73b..11eef3e14006 100644 --- a/test/Analysis/malloc-plist.c +++ b/test/Analysis/malloc-plist.c @@ -97,6 +97,77 @@ void LeakedSymbol(int in) { in++; } +// Tests that exercise running remove dead bindings at Call exit. +static void function_with_leak1() { + char *x = (char*)malloc(12); +} +void use_function_with_leak1() { + function_with_leak1(); + int y = 0; +} + +static void function_with_leak2() { + char *x = (char*)malloc(12); + int m = 0; +} +void use_function_with_leak2() { + function_with_leak2(); +} + +static void function_with_leak3(int y) { + char *x = (char*)malloc(12); + if (y) + y++; +} +void use_function_with_leak3(int y) { + function_with_leak3(y); +} + +static void function_with_leak4(int y) { + char *x = (char*)malloc(12); + if (y) + y++; + else + y--; +} +void use_function_with_leak4(int y) { + function_with_leak4(y); +} + +int anotherFunction5() { + return 5; +} +static int function_with_leak5() { + char *x = (char*)malloc(12); + return anotherFunction5(); +} +void use_function_with_leak5() { + function_with_leak5(); +} + +void anotherFunction6(int m) { + m++; +} +static void function_with_leak6() { + char *x = (char*)malloc(12); + anotherFunction6(3); +} +void use_function_with_leak6() { + function_with_leak6(); +} + +static void empty_function(){ +} +void use_empty_function() { + empty_function(); +} +static char *function_with_leak7() { + return (char*)malloc(12); +} +void use_function_with_leak7() { + function_with_leak7(); +} + // CHECK: <?xml version="1.0" encoding="UTF-8"?> // CHECK: <plist version="1.0"> // CHECK: <dict> @@ -122,7 +193,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -135,7 +206,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -156,7 +227,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -169,7 +240,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>11</integer> -// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>col</key><integer>11</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -190,7 +261,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>11</integer> -// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>col</key><integer>11</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -203,7 +274,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>11</integer> -// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>col</key><integer>23</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -253,7 +324,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>11</integer> -// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>col</key><integer>23</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -281,21 +352,6 @@ void LeakedSymbol(int in) { // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> -// CHECK: <key>ranges</key> -// CHECK: <array> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>line</key><integer>14</integer> -// CHECK: <key>col</key><integer>5</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: <dict> -// CHECK: <key>line</key><integer>14</integer> -// CHECK: <key>col</key><integer>6</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: </array> -// CHECK: </array> // CHECK: <key>depth</key><integer>0</integer> // CHECK: <key>extended_message</key> // CHECK: <string>Memory is never released; potential leak of memory pointed to by 'p'</string> @@ -308,6 +364,7 @@ void LeakedSymbol(int in) { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>diagnosticTest</string> +// CHECK: <key>issue_hash</key><integer>5</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>14</integer> @@ -332,7 +389,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>18</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -379,7 +436,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>19</integer> -// CHECK: <key>col</key><integer>30</integer> +// CHECK: <key>col</key><integer>14</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -429,7 +486,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>19</integer> -// CHECK: <key>col</key><integer>30</integer> +// CHECK: <key>col</key><integer>14</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -469,6 +526,7 @@ void LeakedSymbol(int in) { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>myArrayAllocation</string> +// CHECK: <key>issue_hash</key><integer>4</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>21</integer> @@ -493,7 +551,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>24</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -506,7 +564,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>24</integer> -// CHECK: <key>col</key><integer>28</integer> +// CHECK: <key>col</key><integer>23</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -556,7 +614,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>24</integer> -// CHECK: <key>col</key><integer>28</integer> +// CHECK: <key>col</key><integer>23</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -569,7 +627,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>26</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -590,7 +648,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>26</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -603,7 +661,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>26</integer> -// CHECK: <key>col</key><integer>40</integer> +// CHECK: <key>col</key><integer>24</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -653,7 +711,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>26</integer> -// CHECK: <key>col</key><integer>40</integer> +// CHECK: <key>col</key><integer>24</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -666,7 +724,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>27</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -687,7 +745,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>27</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -700,7 +758,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>27</integer> -// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>col</key><integer>9</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -750,7 +808,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>27</integer> -// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>col</key><integer>9</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -841,21 +899,6 @@ void LeakedSymbol(int in) { // CHECK: <key>col</key><integer>9</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> -// CHECK: <key>ranges</key> -// CHECK: <array> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>line</key><integer>28</integer> -// CHECK: <key>col</key><integer>9</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: <dict> -// CHECK: <key>line</key><integer>28</integer> -// CHECK: <key>col</key><integer>14</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: </array> -// CHECK: </array> // CHECK: <key>depth</key><integer>0</integer> // CHECK: <key>extended_message</key> // CHECK: <string>Memory is never released; potential leak of memory pointed to by 'buf'</string> @@ -868,6 +911,7 @@ void LeakedSymbol(int in) { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>reallocDiagnostics</string> +// CHECK: <key>issue_hash</key><integer>5</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>28</integer> @@ -892,7 +936,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>43</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -905,7 +949,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>43</integer> -// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>col</key><integer>21</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -969,7 +1013,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>34</integer> -// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -982,7 +1026,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>35</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1003,7 +1047,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>35</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1016,7 +1060,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>35</integer> -// CHECK: <key>col</key><integer>23</integer> +// CHECK: <key>col</key><integer>18</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1066,7 +1110,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>35</integer> -// CHECK: <key>col</key><integer>23</integer> +// CHECK: <key>col</key><integer>18</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1079,7 +1123,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>37</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1100,7 +1144,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>37</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1176,7 +1220,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>38</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1226,7 +1270,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>43</integer> -// CHECK: <key>col</key><integer>23</integer> +// CHECK: <key>col</key><integer>21</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1266,6 +1310,7 @@ void LeakedSymbol(int in) { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_wrapper</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>45</integer> @@ -1290,7 +1335,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>59</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1303,7 +1348,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>60</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>22</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1367,7 +1412,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>52</integer> -// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1414,7 +1459,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>53</integer> -// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>col</key><integer>15</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1464,7 +1509,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>53</integer> -// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>col</key><integer>15</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1477,7 +1522,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>54</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1498,7 +1543,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>54</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1511,7 +1556,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>55</integer> -// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>col</key><integer>13</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1575,7 +1620,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>49</integer> -// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1588,7 +1633,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>50</integer> -// CHECK: <key>col</key><integer>11</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1667,7 +1712,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>55</integer> -// CHECK: <key>col</key><integer>17</integer> +// CHECK: <key>col</key><integer>13</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1680,7 +1725,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>56</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1730,7 +1775,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>60</integer> -// CHECK: <key>col</key><integer>28</integer> +// CHECK: <key>col</key><integer>22</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1743,7 +1788,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>61</integer> -// CHECK: <key>col</key><integer>14</integer> +// CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1785,6 +1830,7 @@ void LeakedSymbol(int in) { // CHECK: <key>type</key><string>Use-after-free</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_double_action_call</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>61</integer> @@ -1809,7 +1855,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>74</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1822,7 +1868,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>74</integer> -// CHECK: <key>col</key><integer>35</integer> +// CHECK: <key>col</key><integer>30</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1872,7 +1918,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>74</integer> -// CHECK: <key>col</key><integer>35</integer> +// CHECK: <key>col</key><integer>30</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1885,7 +1931,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>75</integer> -// CHECK: <key>col</key><integer>11</integer> +// CHECK: <key>col</key><integer>20</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1949,7 +1995,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>65</integer> -// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1962,7 +2008,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>66</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1983,7 +2029,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>66</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1996,7 +2042,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>67</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2017,7 +2063,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>67</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2030,7 +2076,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>67</integer> -// CHECK: <key>col</key><integer>40</integer> +// CHECK: <key>col</key><integer>24</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2080,7 +2126,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>67</integer> -// CHECK: <key>col</key><integer>40</integer> +// CHECK: <key>col</key><integer>24</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2093,7 +2139,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>68</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2114,7 +2160,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>68</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2127,7 +2173,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>68</integer> -// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>col</key><integer>9</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2177,7 +2223,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>68</integer> -// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>col</key><integer>9</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2253,7 +2299,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>69</integer> -// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>col</key><integer>14</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2303,7 +2349,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>75</integer> -// CHECK: <key>col</key><integer>25</integer> +// CHECK: <key>col</key><integer>20</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2316,7 +2362,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>76</integer> -// CHECK: <key>col</key><integer>13</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2331,21 +2377,6 @@ void LeakedSymbol(int in) { // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> -// CHECK: <key>ranges</key> -// CHECK: <array> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> -// CHECK: <key>col</key><integer>5</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> -// CHECK: <key>col</key><integer>13</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: </array> -// CHECK: </array> // CHECK: <key>depth</key><integer>0</integer> // CHECK: <key>extended_message</key> // CHECK: <string>Memory is never released; potential leak of memory pointed to by 'buf'</string> @@ -2358,6 +2389,7 @@ void LeakedSymbol(int in) { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>reallocIntra</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>76</integer> @@ -2382,7 +2414,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>84</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2395,7 +2427,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>85</integer> -// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>col</key><integer>26</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2459,7 +2491,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>80</integer> -// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2472,7 +2504,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>81</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2493,7 +2525,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>81</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2506,7 +2538,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>81</integer> -// CHECK: <key>col</key><integer>28</integer> +// CHECK: <key>col</key><integer>24</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2585,7 +2617,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>85</integer> -// CHECK: <key>col</key><integer>28</integer> +// CHECK: <key>col</key><integer>26</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2625,6 +2657,7 @@ void LeakedSymbol(int in) { // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>use_ret</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>86</integer> @@ -2649,7 +2682,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>90</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2696,7 +2729,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>92</integer> -// CHECK: <key>col</key><integer>24</integer> +// CHECK: <key>col</key><integer>20</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2746,7 +2779,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>92</integer> -// CHECK: <key>col</key><integer>24</integer> +// CHECK: <key>col</key><integer>20</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2759,7 +2792,7 @@ void LeakedSymbol(int in) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>97</integer> -// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -2774,41 +2807,1626 @@ void LeakedSymbol(int in) { // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'm'</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'm'</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'm'</string> +// CHECK: <key>category</key><string>Memory Error</string> +// CHECK: <key>type</key><string>Memory leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>LeakedSymbol</string> +// CHECK: <key>issue_hash</key><integer>8</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>97</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>105</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> // CHECK: <key>ranges</key> // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>97</integer> +// CHECK: <key>line</key><integer>105</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>97</integer> -// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>line</key><integer>105</integer> +// CHECK: <key>col</key><integer>25</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: </array> // CHECK: <key>depth</key><integer>0</integer> // CHECK: <key>extended_message</key> -// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'm'</string> +// CHECK: <string>Calling 'function_with_leak1'</string> // CHECK: <key>message</key> -// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'm'</string> +// CHECK: <string>Calling 'function_with_leak1'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'use_function_with_leak1'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'use_function_with_leak1'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> // CHECK: </dict> // CHECK: </array> -// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'm'</string> +// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'x'</string> // CHECK: <key>category</key><string>Memory Error</string> // CHECK: <key>type</key><string>Memory leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> -// CHECK: <key>issue_context</key><string>LeakedSymbol</string> +// CHECK: <key>issue_context</key><string>function_with_leak1</string> +// CHECK: <key>issue_hash</key><integer>1</integer> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>97</integer> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>114</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>114</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>114</integer> +// CHECK: <key>col</key><integer>25</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'function_with_leak2'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'function_with_leak2'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>109</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'use_function_with_leak2'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'use_function_with_leak2'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>109</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>109</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>110</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>110</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>110</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>110</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>110</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>110</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>110</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>110</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>110</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>110</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>110</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>111</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>111</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>111</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: <key>category</key><string>Memory Error</string> +// CHECK: <key>type</key><string>Memory leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>function_with_leak2</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>111</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>26</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'function_with_leak3'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'function_with_leak3'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>117</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'use_function_with_leak3'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'use_function_with_leak3'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>117</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>117</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>120</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>120</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>120</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: <key>category</key><string>Memory Error</string> +// CHECK: <key>type</key><string>Memory leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>function_with_leak3</string> +// CHECK: <key>issue_hash</key><integer>3</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>120</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>26</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'function_with_leak4'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'function_with_leak4'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>126</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'use_function_with_leak4'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'use_function_with_leak4'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>126</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>126</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>127</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>127</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>127</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>127</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>127</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>127</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>127</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>127</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>127</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>127</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>127</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>131</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>131</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>131</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: <key>category</key><string>Memory Error</string> +// CHECK: <key>type</key><string>Memory leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>function_with_leak4</string> +// CHECK: <key>issue_hash</key><integer>5</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>131</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>145</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>145</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>145</integer> +// CHECK: <key>col</key><integer>25</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'function_with_leak5'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'function_with_leak5'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'use_function_with_leak5'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'use_function_with_leak5'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>141</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>141</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>141</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>141</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>141</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>141</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>141</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>141</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>141</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>141</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>141</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>142</integer> +// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>142</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>142</integer> +// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: <key>category</key><string>Memory Error</string> +// CHECK: <key>type</key><string>Memory leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>function_with_leak5</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>142</integer> +// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>156</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>156</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>156</integer> +// CHECK: <key>col</key><integer>25</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'function_with_leak6'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'function_with_leak6'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>151</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'use_function_with_leak6'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'use_function_with_leak6'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>151</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>151</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>152</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>152</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>152</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>152</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>152</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>152</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>152</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>152</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>152</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>152</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>152</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>153</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>153</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>153</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Memory is never released; potential leak of memory pointed to by 'x'</string> +// CHECK: <key>category</key><string>Memory Error</string> +// CHECK: <key>type</key><string>Memory leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>function_with_leak6</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>153</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>25</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Calling 'function_with_leak7'</string> +// CHECK: <key>message</key> +// CHECK: <string>Calling 'function_with_leak7'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>164</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Entered call from 'use_function_with_leak7'</string> +// CHECK: <key>message</key> +// CHECK: <string>Entered call from 'use_function_with_leak7'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>164</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>164</integer> +// CHECK: <key>col</key><integer>6</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>165</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>165</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>165</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>165</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>165</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>165</integer> +// CHECK: <key>col</key><integer>24</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>165</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>165</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>165</integer> +// CHECK: <key>col</key><integer>28</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is allocated</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>25</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>1</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Returned allocated memory</string> +// CHECK: <key>message</key> +// CHECK: <string>Returned allocated memory</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>23</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>169</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>169</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>169</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Memory is never released; potential leak</string> +// CHECK: <key>message</key> +// CHECK: <string>Memory is never released; potential leak</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Memory is never released; potential leak</string> +// CHECK: <key>category</key><string>Memory Error</string> +// CHECK: <key>type</key><string>Memory leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>use_function_with_leak7</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>169</integer> +// CHECK: <key>col</key><integer>1</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> // CHECK: </array> // CHECK: </dict> // CHECK: </plist> - diff --git a/test/Analysis/malloc-sizeof.c b/test/Analysis/malloc-sizeof.c index d2b3bcf3c84d..6eb466ac6a11 100644 --- a/test/Analysis/malloc-sizeof.c +++ b/test/Analysis/malloc-sizeof.c @@ -1,27 +1,36 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.unix.MallocSizeof -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=unix.MallocSizeof -verify %s #include <stddef.h> void *malloc(size_t size); void *calloc(size_t nmemb, size_t size); void *realloc(void *ptr, size_t size); +void free(void *ptr); struct A {}; struct B {}; -void foo() { +void foo(unsigned int unsignedInt, unsigned int readSize) { int *ip1 = malloc(sizeof(1)); int *ip2 = malloc(4 * sizeof(int)); - long *lp1 = malloc(sizeof(short)); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'short'}} - long *lp2 = malloc(5 * sizeof(double)); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'double'}} - long *lp3 = malloc(5 * sizeof(char) + 2); // expected-warning {{Result of 'malloc' is converted to type 'long *', whose pointee type 'long' is incompatible with sizeof operand type 'char'}} + long *lp1 = malloc(sizeof(short)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'long', which is incompatible with sizeof operand type 'short'}} + long *lp2 = malloc(5 * sizeof(double)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'long', which is incompatible with sizeof operand type 'double'}} + char *cp3 = malloc(5 * sizeof(char) + 2); // no warning + unsigned char *buf = malloc(readSize + sizeof(unsignedInt)); // no warning struct A *ap1 = calloc(1, sizeof(struct A)); struct A *ap2 = calloc(2, sizeof(*ap1)); - struct A *ap3 = calloc(2, sizeof(ap1)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct A *'}} - struct A *ap4 = calloc(3, sizeof(struct A*)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct A *'}} - struct A *ap5 = calloc(4, sizeof(struct B)); // expected-warning {{Result of 'calloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct B'}} + struct A *ap3 = calloc(2, sizeof(ap1)); // expected-warning {{Result of 'calloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'struct A *'}} + struct A *ap4 = calloc(3, sizeof(struct A*)); // expected-warning {{Result of 'calloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'struct A *'}} + struct A *ap5 = calloc(4, sizeof(struct B)); // expected-warning {{Result of 'calloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'struct B'}} struct A *ap6 = realloc(ap5, sizeof(struct A)); - struct A *ap7 = realloc(ap5, sizeof(struct B)); // expected-warning {{Result of 'realloc' is converted to type 'struct A *', whose pointee type 'struct A' is incompatible with sizeof operand type 'struct B'}} + struct A *ap7 = realloc(ap5, sizeof(struct B)); // expected-warning {{Result of 'realloc' is converted to a pointer of type 'struct A', which is incompatible with sizeof operand type 'struct B'}} +} + +// Don't warn when the types differ only by constness. +void ignore_const() { + const char **x = (const char **)malloc(1 * sizeof(char *)); // no-warning + const char ***y = (const char ***)malloc(1 * sizeof(char *)); // expected-warning {{Result of 'malloc' is converted to a pointer of type 'const char **', which is incompatible with sizeof operand type 'char *'}} + free(x); } diff --git a/test/Analysis/malloc.c b/test/Analysis/malloc.c index 3b4712320b72..f60271f39f4c 100644 --- a/test/Analysis/malloc.c +++ b/test/Analysis/malloc.c @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.deadcode.UnreachableCode,experimental.core.CastSize,unix.Malloc,debug.ExprInspection -analyzer-store=region -verify %s #include "system-header-simulator.h" +void clang_analyzer_eval(int); + typedef __typeof(sizeof(int)) size_t; void *malloc(size_t); void *valloc(size_t); @@ -8,6 +10,8 @@ void free(void *); void *realloc(void *ptr, size_t size); void *reallocf(void *ptr, size_t size); void *calloc(size_t nmemb, size_t size); +char *strdup(const char *s); +char *strndup(const char *s, size_t n); void myfoo(int *p); void myfooint(int p); @@ -15,7 +19,7 @@ char *fooRetPtr(); void f1() { int *p = malloc(12); - return; // expected-warning{{Memory is never released; potential leak}} + return; // expected-warning{{Memory is never released; potential leak of memory pointed to by 'p'}} } void f2() { @@ -40,7 +44,7 @@ void reallocNotNullPtr(unsigned sizeIn) { char *p = (char*)malloc(size); if (p) { char *q = (char*)realloc(p, sizeIn); - char x = *q; // expected-warning {{Memory is never released; potential leak}} + char x = *q; // expected-warning {{Memory is never released; potential leak of memory pointed to by 'q'}} } } @@ -65,7 +69,7 @@ void reallocSizeZero1() { char *p = malloc(12); char *r = realloc(p, 0); if (!r) { - free(p); + free(p); // expected-warning {{Attempt to free released memory}} } else { free(r); } @@ -75,7 +79,7 @@ void reallocSizeZero2() { char *p = malloc(12); char *r = realloc(p, 0); if (!r) { - free(p); + free(p); // expected-warning {{Attempt to free released memory}} } else { free(r); } @@ -98,7 +102,7 @@ void reallocSizeZero5() { } void reallocPtrZero1() { - char *r = realloc(0, 12); // expected-warning {{Memory is never released; potential leak}} + char *r = realloc(0, 12); // expected-warning {{Memory is never released; potential leak of memory pointed to by 'r'}} } void reallocPtrZero2() { @@ -243,6 +247,12 @@ void f7() { x[0] = 'a'; // expected-warning{{Use of memory after it is freed}} } +void f8() { + char *x = (char*) malloc(4); + free(x); + char *y = strndup(x, 4); // expected-warning{{Use of memory after it is freed}} +} + void f7_realloc() { char *x = (char*) malloc(4); realloc(x,0); @@ -311,7 +321,7 @@ void nullFree() { void paramFree(int *p) { myfoo(p); free(p); // no warning - myfoo(p); // TODO: This should be a warning. + myfoo(p); // expected-warning {{Use of memory after it is freed}} } int* mallocEscapeRet() { @@ -503,20 +513,26 @@ void testMalloc() { int *x = malloc(12); StructWithPtr St; St.memP = x; - arrOfStructs[0] = St; + arrOfStructs[0] = St; // no-warning } StructWithPtr testMalloc2() { int *x = malloc(12); StructWithPtr St; St.memP = x; - return St; + return St; // no-warning } int *testMalloc3() { int *x = malloc(12); int *y = x; - return y; + return y; // no-warning +} + +void testStructLeak() { + StructWithPtr St; + St.memP = malloc(12); + return; // expected-warning {{Memory is never released; potential leak of memory pointed to by 'St.memP'}} } void testElemRegion1() { @@ -653,10 +669,6 @@ int *specialMallocWithStruct() { } // Test various allocation/deallocation functions. - -char *strdup(const char *s); -char *strndup(const char *s, size_t n); - void testStrdup(const char *s, unsigned validIndex) { char *s2 = strdup(s); s2[validIndex + 1] = 'b';// expected-warning {{Memory is never released; potential leak}} @@ -711,6 +723,18 @@ FILE *useFunOpenNoReleaseFunction() { return f; // expected-warning{{leak}} } +static int readNothing(void *_ctx, char *buf, int size) { + return 0; +} +FILE *useFunOpenReadNoRelease() { + void *ctx = malloc(sizeof(int)); + FILE *f = funopen(ctx, readNothing, 0, 0, 0); + if (f == 0) { + free(ctx); + } + return f; // expected-warning{{leak}} +} + // Test setbuf, setvbuf. int my_main_no_warning() { char *p = malloc(100); @@ -760,10 +784,83 @@ void radar10978247_positive(int myValueSize) { return; } -// ---------------------------------------------------------------------------- -// Below are the known false positives. +// <rdar://problem/11269741> Previously this triggered a false positive +// because malloc() is known to return uninitialized memory and the binding +// of 'o' to 'p->n' was not getting propertly handled. Now we report a leak. +struct rdar11269741_a_t { + struct rdar11269741_b_t { + int m; + } n; +}; + +int rdar11269741(struct rdar11269741_b_t o) +{ + struct rdar11269741_a_t *p = (struct rdar11269741_a_t *) malloc(sizeof(*p)); + p->n = o; + return p->n.m; // expected-warning {{leak}} +} + +// Pointer arithmetic, returning an ElementRegion. +void *radar11329382(unsigned bl) { + void *ptr = malloc (16); + ptr = ptr + (2 - bl); + return ptr; // no warning +} + +void __assert_rtn(const char *, const char *, int, const char *) __attribute__((__noreturn__)); +int strcmp(const char *, const char *); +char *a (void); +void radar11270219(void) { + char *x = a(), *y = a(); + (__builtin_expect(!(x && y), 0) ? __assert_rtn(__func__, "/Users/zaks/tmp/ex.c", 24, "x && y") : (void)0); + strcmp(x, y); // no warning +} + +void radar_11358224_test_double_assign_ints_positive_2() +{ + void *ptr = malloc(16); + ptr = ptr; // expected-warning {{leak}} +} + +// Assume that functions which take a function pointer can free memory even if +// they are defined in system headers and take the const pointer to the +// allocated memory. (radar://11160612) +int const_ptr_and_callback(int, const char*, int n, void(*)(void*)); +void r11160612_1() { + char *x = malloc(12); + const_ptr_and_callback(0, x, 12, free); // no - warning +} + +// Null is passed as callback. +void r11160612_2() { + char *x = malloc(12); + const_ptr_and_callback(0, x, 12, 0); // expected-warning {{leak}} +} + +// Callback is passed to a function defined in a system header. +void r11160612_4() { + char *x = malloc(12); + sqlite3_bind_text_my(0, x, 12, free); // no - warning +} + +// Passing callbacks in a struct. +void r11160612_5(StWithCallback St) { + void *x = malloc(12); + dealocateMemWhenDoneByVal(x, St); +} +void r11160612_6(StWithCallback St) { + void *x = malloc(12); + dealocateMemWhenDoneByRef(&St, x); +} + +int mySub(int, int); +int myAdd(int, int); +int fPtr(unsigned cond, int x) { + return (cond ? mySub : myAdd)(x, x); +} + +// Test anti-aliasing. -// TODO: There should be no warning here. This one might be difficult to get rid of. void dependsOnValueOfPtr(int *g, unsigned f) { int *p; @@ -776,20 +873,147 @@ void dependsOnValueOfPtr(int *g, unsigned f) { if (p != g) free(p); else - return; // expected-warning{{Memory is never released; potential leak}} + return; // no warning return; } -// ---------------------------------------------------------------------------- -// False negatives. +int CMPRegionHeapToStack() { + int x = 0; + int *x1 = malloc(8); + int *x2 = &x; + clang_analyzer_eval(x1 == x2); // expected-warning{{FALSE}} + free(x1); + return x; +} + +int CMPRegionHeapToHeap2() { + int x = 0; + int *x1 = malloc(8); + int *x2 = malloc(8); + int *x4 = x1; + int *x5 = x2; + clang_analyzer_eval(x4 == x5); // expected-warning{{FALSE}} + free(x1); + free(x2); + return x; +} + +int CMPRegionHeapToHeap() { + int x = 0; + int *x1 = malloc(8); + int *x4 = x1; + if (x1 == x4) { + free(x1); + return 5/x; // expected-warning{{Division by zero}} + } + return x;// expected-warning{{This statement is never executed}} +} -// TODO: This requires tracking symbols stored inside the structs/arrays. -void testMalloc5() { +int HeapAssignment() { + int m = 0; + int *x = malloc(4); + int *y = x; + *x = 5; + clang_analyzer_eval(*x != *y); // expected-warning{{FALSE}} + free(x); + return 0; +} + +int *retPtr(); +int *retPtrMightAlias(int *x); +int cmpHeapAllocationToUnknown() { + int zero = 0; + int *yBefore = retPtr(); + int *m = malloc(8); + int *yAfter = retPtrMightAlias(m); + clang_analyzer_eval(yBefore == m); // expected-warning{{FALSE}} + clang_analyzer_eval(yAfter == m); // expected-warning{{FALSE}} + free(m); + return 0; +} + +void localArrayTest() { + char *p = (char*)malloc(12); + char *ArrayL[12]; + ArrayL[0] = p; // expected-warning {{leak}} +} + +void localStructTest() { StructWithPtr St; StructWithPtr *pSt = &St; - pSt->memP = malloc(12); + pSt->memP = malloc(12); // expected-warning{{Memory is never released; potential leak}} } +// Test double assignment through integers. +static long glob; +void test_double_assign_ints() +{ + void *ptr = malloc (16); // no-warning + glob = (long)(unsigned long)ptr; +} + +void test_double_assign_ints_positive() +{ + void *ptr = malloc(16); + (void*)(long)(unsigned long)ptr; // expected-warning {{unused}} expected-warning {{leak}} +} + + +void testCGContextNoLeak() +{ + void *ptr = malloc(16); + CGContextRef context = CGBitmapContextCreate(ptr); + + // Because you can get the data back out like this, even much later, + // CGBitmapContextCreate is one of our "stop-tracking" exceptions. + free(CGBitmapContextGetData(context)); +} + +void testCGContextLeak() +{ + void *ptr = malloc(16); + CGContextRef context = CGBitmapContextCreate(ptr); + // However, this time we're just leaking the data, because the context + // object doesn't escape and it hasn't been freed in this function. +} + +// Allow xpc context to escape. radar://11635258 +// TODO: Would be great if we checked that the finalize_connection_context actually releases it. +static void finalize_connection_context(void *ctx) { + int *context = ctx; + free(context); +} +void foo (xpc_connection_t peer) { + int *ctx = calloc(1, sizeof(int)); + xpc_connection_set_context(peer, ctx); + xpc_connection_set_finalizer_f(peer, finalize_connection_context); + xpc_connection_resume(peer); +} + +// Make sure we catch errors when we free in a function which does not allocate memory. +void freeButNoMalloc(int *p, int x){ + if (x) { + free(p); + //user forgot a return here. + } + free(p); // expected-warning {{Attempt to free released memory}} +} + +struct HasPtr { + int *p; +}; + +int* reallocButNoMalloc(struct HasPtr *a, int c, int size) { + int *s; + a->p = (int *)realloc(a->p, size); + if (a->p == 0) + return 0; // expected-warning{{Memory is never released; potential leak}} + return a->p; +} + +// ---------------------------------------------------------------------------- +// False negatives. + // TODO: This is another false negative. void testMallocWithParam(int **p) { *p = (int*) malloc(sizeof(int)); @@ -799,11 +1023,3 @@ void testMallocWithParam(int **p) { void testMallocWithParam_2(int **p) { *p = (int*) malloc(sizeof(int)); } - -// TODO: This should produce a warning, similar to the previous issue. -void localArrayTest() { - char *p = (char*)malloc(12); - char *ArrayL[12]; - ArrayL[0] = p; -} - diff --git a/test/Analysis/malloc.cpp b/test/Analysis/malloc.cpp index 8f80b2b76f29..72b92722133b 100644 --- a/test/Analysis/malloc.cpp +++ b/test/Analysis/malloc.cpp @@ -14,3 +14,24 @@ struct Foo { Foo aFunction() { return malloc(10); } + +// Assume that functions which take a function pointer can free memory even if +// they are defined in system headers and take the const pointer to the +// allocated memory. (radar://11160612) +// Test default parameter. +int const_ptr_and_callback_def_param(int, const char*, int n, void(*)(void*) = 0); +void r11160612_3() { + char *x = (char*)malloc(12); + const_ptr_and_callback_def_param(0, x, 12); +} + +// Test member function pointer. +struct CanFreeMemory { + static void myFree(void*); +}; +//This is handled because we look at the type of the parameter(not argument). +void r11160612_3(CanFreeMemory* p) { + char *x = (char*)malloc(12); + const_ptr_and_callback_def_param(0, x, 12, p->myFree); +} + diff --git a/test/Analysis/malloc.m b/test/Analysis/malloc.m index 6c94118286ab..08206f3bf14c 100644 --- a/test/Analysis/malloc.m +++ b/test/Analysis/malloc.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify -Wno-objc-root-class -fblocks %s #include "system-header-simulator-objc.h" @class NSString; diff --git a/test/Analysis/malloc.mm b/test/Analysis/malloc.mm index 3515a4f99af0..7a9d881b1518 100644 --- a/test/Analysis/malloc.mm +++ b/test/Analysis/malloc.mm @@ -9,7 +9,6 @@ void free(void *); void testNSDatafFreeWhenDoneNoError(NSUInteger dataLength) { unsigned char *data = (unsigned char *)malloc(42); NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength]; - free(data); // no warning } void testNSDataFreeWhenDoneYES(NSUInteger dataLength) { @@ -22,6 +21,16 @@ void testNSDataFreeWhenDoneYES2(NSUInteger dataLength) { NSData *nsdata = [[NSData alloc] initWithBytesNoCopy:data length:dataLength freeWhenDone:1]; // no-warning } +void testNSStringFreeWhenDoneYES3(NSUInteger dataLength) { + unsigned char *data = (unsigned char *)malloc(42); + NSString *nsstr = [[NSString alloc] initWithBytesNoCopy:data length:dataLength encoding:NSUTF8StringEncoding freeWhenDone:1]; +} + +void testNSStringFreeWhenDoneYES4(NSUInteger dataLength) { + unichar *data = (unichar*)malloc(42); + NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data length:dataLength freeWhenDone:1]; + free(data); //expected-warning {{Attempt to free non-owned memory}} +} void testNSStringFreeWhenDoneYES(NSUInteger dataLength) { unsigned char *data = (unsigned char *)malloc(42); @@ -55,11 +64,17 @@ void testNSStringFreeWhenDoneNO2(NSUInteger dataLength) { NSString *nsstr = [[NSString alloc] initWithCharactersNoCopy:data length:dataLength freeWhenDone:0]; // expected-warning{{leak}} } -// TODO: False Negative. -void testNSDatafFreeWhenDoneFN(NSUInteger dataLength) { - unsigned char *data = (unsigned char *)malloc(42); - NSData *nsdata = [NSData dataWithBytesNoCopy:data length:dataLength freeWhenDone:1]; - free(data); // false negative +void testRelinquished1() { + void *data = malloc(42); + NSData *nsdata = [NSData dataWithBytesNoCopy:data length:42 freeWhenDone:1]; + free(data); // expected-warning {{Attempt to free non-owned memory}} +} + +void testRelinquished2() { + void *data = malloc(42); + NSData *nsdata; + free(data); + [NSData dataWithBytesNoCopy:data length:42]; // expected-warning {{Attempt to free released memory}} } // Test CF/NS...NoCopy. PR12100: Pointers can escape when custom deallocators are provided. @@ -153,4 +168,57 @@ static void releaseDataCallback (void *info, const void *data, size_t size) { void testCGDataProviderCreateWithData() { void* b = calloc(8, 8); CGDataProviderRef p = CGDataProviderCreateWithData(0, b, 8*8, releaseDataCallback); +} + +// Assume that functions which take a function pointer can free memory even if +// they are defined in system headers and take the const pointer to the +// allocated memory. (radar://11160612) +extern CGDataProviderRef UnknownFunWithCallback(void *info, + const void *data, size_t size, + CGDataProviderReleaseDataCallback releaseData) + __attribute__((visibility("default"))); +void testUnknownFunWithCallBack() { + void* b = calloc(8, 8); + CGDataProviderRef p = UnknownFunWithCallback(0, b, 8*8, releaseDataCallback); +} + +// Test blocks. +void acceptBlockParam(void *, void (^block)(void *), unsigned); +void testCallWithBlockCallback() { + void *l = malloc(12); + acceptBlockParam(l, ^(void *i) { free(i); }, sizeof(char *)); +} + +// Test blocks in system headers. +void testCallWithBlockCallbackInSystem() { + void *l = malloc(12); + SystemHeaderFunctionWithBlockParam(l, ^(void *i) { free(i); }, sizeof(char *)); +} + +// Test escape into NSPointerArray. radar://11691035, PR13140 +void foo(NSPointerArray* pointerArray) { + + void* p1 = malloc (1024); + if (p1) { + [pointerArray addPointer:p1]; + } + + void* p2 = malloc (1024); + if (p2) { + [pointerArray insertPointer:p2 atIndex:1]; + } + + void* p3 = malloc (1024); + if (p3) { + [pointerArray replacePointerAtIndex:1 withPointer:p3]; + } + + // Freeing the buffer is allowed. + void* buffer = [pointerArray pointerAtIndex:0]; + free(buffer); +} + +void noCrashOnVariableArgumentSelector() { + NSMutableString *myString = [NSMutableString stringWithString:@"some text"]; + [myString appendFormat:@"some text = %d", 3]; }
\ No newline at end of file diff --git a/test/Analysis/method-call-path-notes.cpp b/test/Analysis/method-call-path-notes.cpp new file mode 100644 index 000000000000..fbf0cae7d8a6 --- /dev/null +++ b/test/Analysis/method-call-path-notes.cpp @@ -0,0 +1,664 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-output=text -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-output=plist-multi-file %s -o - | FileCheck %s + +// Test warning about null or uninitialized pointer values used as instance member +// calls. +class TestInstanceCall { +public: + void foo() {} +}; + +void test_ic() { + TestInstanceCall *p; // expected-note {{Variable 'p' declared without an initial value}} + p->foo(); // expected-warning {{Called C++ object pointer is uninitialized}} expected-note {{Called C++ object pointer is uninitialized}} +} + +void test_ic_null() { + TestInstanceCall *p = 0; // expected-note {{Variable 'p' initialized to a null pointer value}} + p->foo(); // expected-warning {{Called C++ object pointer is null}} expected-note {{Called C++ object pointer is null}} +} + +void test_ic_set_to_null() { + TestInstanceCall *p; + p = 0; // expected-note {{Null pointer value stored to 'p'}} + p->foo(); // expected-warning {{Called C++ object pointer is null}} expected-note {{Called C++ object pointer is null}} +} + +void test_ic_null(TestInstanceCall *p) { + if (!p) // expected-note {{Assuming pointer value is null}} expected-note {{Taking true branch}} + p->foo(); // expected-warning {{Called C++ object pointer is null}} expected-note{{Called C++ object pointer is null}} +} + +void test_ic_member_ptr() { + TestInstanceCall *p = 0; // expected-note {{Variable 'p' initialized to a null pointer value}} + typedef void (TestInstanceCall::*IC_Ptr)(); + IC_Ptr bar = &TestInstanceCall::foo; + (p->*bar)(); // expected-warning {{Called C++ object pointer is null}} expected-note{{Called C++ object pointer is null}} +} + +// CHECK: <?xml version="1.0" encoding="UTF-8"?> +// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +// CHECK: <plist version="1.0"> +// CHECK: <dict> +// CHECK: <key>files</key> +// CHECK: <array> +// CHECK: <string>{{.*}}method-call-path-notes.cpp</string> +// CHECK: </array> +// CHECK: <key>diagnostics</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>12</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>12</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>12</integer> +// CHECK: <key>col</key><integer>21</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Variable 'p' declared without an initial value</string> +// CHECK: <key>message</key> +// CHECK: <string>Variable 'p' declared without an initial value</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>12</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>12</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Called C++ object pointer is uninitialized</string> +// CHECK: <key>message</key> +// CHECK: <string>Called C++ object pointer is uninitialized</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Called C++ object pointer is uninitialized</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Called C++ object pointer is uninitialized</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>test_ic</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>13</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> +// CHECK: <key>col</key><integer>21</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: <key>message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Called C++ object pointer is null</string> +// CHECK: <key>message</key> +// CHECK: <string>Called C++ object pointer is null</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Called C++ object pointer is null</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Called C++ object pointer is null</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>test_ic_null</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>18</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>22</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>22</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Null pointer value stored to 'p'</string> +// CHECK: <key>message</key> +// CHECK: <string>Null pointer value stored to 'p'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Called C++ object pointer is null</string> +// CHECK: <key>message</key> +// CHECK: <string>Called C++ object pointer is null</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Called C++ object pointer is null</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Called C++ object pointer is null</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>test_ic_set_to_null</string> +// CHECK: <key>issue_hash</key><integer>3</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Assuming pointer value is null</string> +// CHECK: <key>message</key> +// CHECK: <string>Assuming pointer value is null</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Called C++ object pointer is null</string> +// CHECK: <key>message</key> +// CHECK: <string>Called C++ object pointer is null</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Called C++ object pointer is null</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Called C++ object pointer is null</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>test_ic_null</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>21</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: <key>message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>33</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>36</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>36</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>36</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>36</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>36</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Called C++ object pointer is null</string> +// CHECK: <key>message</key> +// CHECK: <string>Called C++ object pointer is null</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Called C++ object pointer is null</string> +// CHECK: <key>category</key><string>Logic error</string> +// CHECK: <key>type</key><string>Called C++ object pointer is null</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>test_ic_member_ptr</string> +// CHECK: <key>issue_hash</key><integer>4</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>36</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </plist> diff --git a/test/Analysis/method-call.cpp b/test/Analysis/method-call.cpp index 323fffebcdbe..91da532456d7 100644 --- a/test/Analysis/method-call.cpp +++ b/test/Analysis/method-call.cpp @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-inline-call -analyzer-store region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -analyzer-store region -verify %s // XFAIL: * +void clang_analyzer_eval(bool); + struct A { int x; A(int a) { x = a; } @@ -9,33 +11,15 @@ struct A { void f1() { A x(3); - if (x.getx() == 3) { - int *p = 0; - *p = 3; // expected-warning{{Dereference of null pointer}} - } else { - int *p = 0; - *p = 3; // no-warning - } + clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}} } void f2() { const A &x = A(3); - if (x.getx() == 3) { - int *p = 0; - *p = 3; // expected-warning{{Dereference of null pointer}} - } else { - int *p = 0; - *p = 3; // no-warning - } + clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}} } void f3() { const A &x = (A)3; - if (x.getx() == 3) { - int *p = 0; - *p = 3; // expected-warning{{Dereference of null pointer}} - } else { - int *p = 0; - *p = 3; // no-warning - } + clang_analyzer_eval(x.getx() == 3); // expected-warning{{TRUE}} } diff --git a/test/Analysis/misc-ps-arm.m b/test/Analysis/misc-ps-arm.m new file mode 100644 index 000000000000..a909ef13d0f8 --- /dev/null +++ b/test/Analysis/misc-ps-arm.m @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -triple thumbv7-apple-ios0.0.0 -analyze -analyzer-checker=core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s + +// <rdar://problem/11405978> - Handle casts of vectors to structs, and loading +// a value. +typedef float float32_t; +typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t; + +typedef struct +{ + float x, y; +} Rdar11405978Vec; + +float32x2_t rdar11405978_bar(); +float32_t rdar11405978() { + float32x2_t v = rdar11405978_bar(); + Rdar11405978Vec w = *(Rdar11405978Vec *)&v; + return w.x; // no-warning +} diff --git a/test/Analysis/misc-ps-cxx0x.cpp b/test/Analysis/misc-ps-cxx0x.cpp index b4dee3122e2c..164af5dc3dfe 100644 --- a/test/Analysis/misc-ps-cxx0x.cpp +++ b/test/Analysis/misc-ps-cxx0x.cpp @@ -73,3 +73,17 @@ void test2() { struct RDar11178609 { ~RDar11178609() = delete; }; + +// Tests that dynamic_cast handles references to C++ classes. Previously +// this crashed. +class rdar11817693_BaseBase {}; +class rdar11817693_BaseInterface {}; +class rdar11817693_Base : public rdar11817693_BaseBase, public rdar11817693_BaseInterface {}; +class rdar11817693 : public rdar11817693_Base { + virtual void operator=(const rdar11817693_BaseBase& src); + void operator=(const rdar11817693& src); +}; +void rdar11817693::operator=(const rdar11817693& src) { + operator=(dynamic_cast<const rdar11817693_BaseBase&>(src)); +} + diff --git a/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp index 8d75fb8ef350..e30cedb91189 100644 --- a/test/Analysis/misc-ps-region-store.cpp +++ b/test/Analysis/misc-ps-region-store.cpp @@ -271,13 +271,27 @@ class Rdar9212495_A : public Rdar9212495_B {}; const Rdar9212495_A& rdar9212495(const Rdar9212495_C* ptr) { const Rdar9212495_A& val = dynamic_cast<const Rdar9212495_A&>(*ptr); + // This is not valid C++; dynamic_cast with a reference type will throw an + // exception if the pointer does not match the expected type. However, our + // implementation of dynamic_cast will pass through a null pointer...or a + // "null reference"! So this branch is actually possible. if (&val == 0) { - val.bar(); // FIXME: This should eventually be a null dereference. + val.bar(); // expected-warning{{Called C++ object pointer is null}} } return val; } +const Rdar9212495_A* rdar9212495_ptr(const Rdar9212495_C* ptr) { + const Rdar9212495_A* val = dynamic_cast<const Rdar9212495_A*>(ptr); + + if (val == 0) { + val->bar(); // expected-warning{{Called C++ object pointer is null}} + } + + return val; +} + // Test constructors invalidating arguments. Previously this raised // an uninitialized value warning. extern "C" void __attribute__((noreturn)) PR9645_exit(int i); @@ -578,3 +592,37 @@ void rdar10924675(unsigned short x[], int index, int index2) { if (y == 0) return; } + +// Test handling CXXScalarValueInitExprs. +void rdar11401827() { + int x = int(); + if (!x) { + int *p = 0; + *p = 0xDEADBEEF; // expected-warning {{null pointer}} + } + else { + int *p = 0; + *p = 0xDEADBEEF; + } +} + +//===---------------------------------------------------------------------===// +// Handle inlining of C++ method calls. +//===---------------------------------------------------------------------===// + +struct A { + int *p; + void foo(int *q) { + p = q; + } + void bar() { + *p = 0; // expected-warning {{null pointer}} + } +}; + +void test_inline() { + A a; + a.foo(0); + a.bar(); +} + diff --git a/test/Analysis/misc-ps-region-store.m b/test/Analysis/misc-ps-region-store.m index d263d4da30cc..88860bbe10d3 100644 --- a/test/Analysis/misc-ps-region-store.m +++ b/test/Analysis/misc-ps-region-store.m @@ -673,7 +673,7 @@ typedef void (^RDar_7462324_Callback)(id obj); builder = ^(id object) { id x; if (object) { - builder(x); // expected-warning{{Function call argument is an uninitialized value}} + builder(x); // expected-warning{{Block call argument is an uninitialized value}} } }; builder(target); @@ -1341,3 +1341,23 @@ static unsigned rdar_11127008(void) { return values[index].value; } +// Test handling invalidating arrays passed to a block via captured +// pointer value (not a __block variable). +typedef void (^radar11125868_cb)(int *, unsigned); + +void rdar11125868_aux(radar11125868_cb cb); + +int rdar11125868() { + int integersStackArray[1]; + int *integers = integersStackArray; + rdar11125868_aux(^(int *integerValue, unsigned index) { + integers[index] = integerValue[index]; + }); + return integers[0] == 0; // no-warning +} + +int rdar11125868_positive() { + int integersStackArray[1]; + int *integers = integersStackArray; + return integers[0] == 0; // expected-warning {{he left operand of '==' is a}} +} diff --git a/test/Analysis/misc-ps.c b/test/Analysis/misc-ps.c index f81b0ddc68d2..8ff710b12f56 100644 --- a/test/Analysis/misc-ps.c +++ b/test/Analysis/misc-ps.c @@ -126,3 +126,10 @@ void rdar10686586() { } } +// This example tests CFG handling of '||' nested in a ternary expression, +// and seeing that the analyzer doesn't crash. +int isctype(char c, unsigned long f) +{ + return (c < 1 || c > 10) ? 0 : !!(c & f); +} + diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 9d2ff5b6ea37..bcc0472984e9 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -1,8 +1,8 @@ // NOTE: Use '-fobjc-gc' to test the analysis being run twice, and multiple reports are not issued. -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s -// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync,osx.AtomicCAS -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync,osx.AtomicCAS -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync,osx.AtomicCAS -analyzer-store=region -analyzer-constraints=basic -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,experimental.deadcode.IdempotentOperations,experimental.core,osx.cocoa.AtSync,osx.AtomicCAS -analyzer-store=region -analyzer-constraints=range -verify -fblocks -Wno-unreachable-code -Wno-null-dereference -Wno-objc-root-class %s #ifndef __clang_analyzer__ #error __clang_analyzer__ not defined @@ -494,6 +494,17 @@ int OSAtomicCompareAndSwap32Barrier(); } @end +// Do not crash when performing compare and swap on symbolic values. +typedef int int32_t; +typedef int int32; +typedef int32 Atomic32; +int OSAtomicCompareAndSwap32( int32_t __oldValue, int32_t __newValue, volatile int32_t *__theValue); +void radar11390991_NoBarrier_CompareAndSwap(volatile Atomic32 *ptr, + Atomic32 old_value, + Atomic32 new_value) { + OSAtomicCompareAndSwap32(old_value, new_value, ptr); +} + // PR 4594 - This was a crash when handling casts in SimpleSValuator. void PR4594() { char *buf[1]; @@ -1345,3 +1356,20 @@ void radar9414427() { } @end +// Don't crash when a ?: is only preceded by a statement (not an expression) +// in the CFG. +void __assert_fail(); + +enum rdar1196620_e { E_A, E_B, E_C, E_D }; +struct rdar1196620_s { int ints[E_D+1]; }; + +static void rdar1196620_call_assert(struct rdar1196620_s* s) { + int i = 0; + s?(void)0:__assert_fail(); +} + +static void rdar1196620(struct rdar1196620_s* s) { + rdar1196620_call_assert(s); +} + + diff --git a/test/Analysis/new.cpp b/test/Analysis/new.cpp index 5ca8c462bdf5..fb77de22f127 100644 --- a/test/Analysis/new.cpp +++ b/test/Analysis/new.cpp @@ -1,15 +1,100 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-store region -verify %s -// XFAIL: * +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-store region -std=c++11 -verify %s -void f1() { - int *n = new int; - if (*n) { // expected-warning {{Branch condition evaluates to a garbage value}} - } +void clang_analyzer_eval(bool); + +typedef __typeof__(sizeof(int)) size_t; +extern "C" void *malloc(size_t); + +int someGlobal; +void testImplicitlyDeclaredGlobalNew() { + if (someGlobal != 0) + return; + + // This used to crash because the global operator new is being implicitly + // declared and it does not have a valid source location. (PR13090) + void *x = ::operator new(0); + ::operator delete(x); + + // Check that the new/delete did not invalidate someGlobal; + clang_analyzer_eval(someGlobal == 0); // expected-warning{{TRUE}} +} + + +// This is the standard placement new. +inline void* operator new(size_t, void* __p) throw() +{ + return __p; +} + +void *testPlacementNew() { + int *x = (int *)malloc(sizeof(int)); + *x = 1; + clang_analyzer_eval(*x == 1); // expected-warning{{TRUE}}; + + void *y = new (x) int; + clang_analyzer_eval(x == y); // expected-warning{{TRUE}}; + clang_analyzer_eval(*x == 1); // expected-warning{{UNKNOWN}}; + + return y; +} + +void *operator new(size_t, size_t, int *); +void *testCustomNew() { + int x[1] = {1}; + clang_analyzer_eval(*x == 1); // expected-warning{{TRUE}}; + + void *y = new (0, x) int; + clang_analyzer_eval(*x == 1); // expected-warning{{UNKNOWN}}; + + return y; // no-warning } -void f2() { +void *operator new(size_t, void *, void *); +void *testCustomNewMalloc() { + int *x = (int *)malloc(sizeof(int)); + + // Should be no-warning (the custom allocator could have freed x). + void *y = new (0, x) int; // no-warning + + return y; +} + +void testScalarInitialization() { int *n = new int(3); + clang_analyzer_eval(*n == 3); // expected-warning{{TRUE}} + + new (n) int(); + clang_analyzer_eval(*n == 0); // expected-warning{{TRUE}} + + new (n) int{3}; + clang_analyzer_eval(*n == 3); // expected-warning{{TRUE}} + + new (n) int{}; + clang_analyzer_eval(*n == 0); // expected-warning{{TRUE}} +} + + +//-------------------------------- +// Incorrectly-modelled behavior +//-------------------------------- + +int testNoInitialization() { + int *n = new int; + + // Should warn that *n is uninitialized. if (*n) { // no-warning + return 0; } + return 1; } +int testNoInitializationPlacement() { + int n; + new (&n) int; + + // Should warn that n is uninitialized. + if (n) { // no-warning + return 0; + } + return 1; +} diff --git a/test/Analysis/nonnull.m b/test/Analysis/nonnull.m new file mode 100644 index 000000000000..c32a7f780ece --- /dev/null +++ b/test/Analysis/nonnull.m @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s + +@interface MyObject +- (void)takePointer:(void *)ptr __attribute__((nonnull(1))); +@end + +void testNonNullMethod(int *p, MyObject *obj) { + if (p) + return; + [obj takePointer:p]; // expected-warning{{nonnull}} +} + + +@interface Subclass : MyObject +// [[nonnull]] is an inherited attribute. +- (void)takePointer:(void *)ptr; +@end + +void testSubclass(int *p, Subclass *obj) { + if (p) + return; + [obj takePointer:p]; // expected-warning{{nonnull}} +} diff --git a/test/Analysis/nullptr.cpp b/test/Analysis/nullptr.cpp index 3119b4fc390c..050c3f8dc56a 100644 --- a/test/Analysis/nullptr.cpp +++ b/test/Analysis/nullptr.cpp @@ -55,7 +55,7 @@ void zoo2() { int **a = 0; int **b = 0; asm ("nop" - :"=a"(*a) + :"=r"(*a) :"0"(*b) // expected-warning{{Dereference of null pointer}} ); } diff --git a/test/Analysis/objc-boxing.m b/test/Analysis/objc-boxing.m new file mode 100644 index 000000000000..16915788d63a --- /dev/null +++ b/test/Analysis/objc-boxing.m @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc -analyzer-store=region -verify %s + +typedef signed char BOOL; +typedef long NSInteger; +typedef unsigned long NSUInteger; +@interface NSString @end +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end + +@interface NSNumber ++ (NSNumber *)numberWithChar:(char)value; ++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; ++ (NSNumber *)numberWithShort:(short)value; ++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; ++ (NSNumber *)numberWithInt:(int)value; ++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; ++ (NSNumber *)numberWithLong:(long)value; ++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; ++ (NSNumber *)numberWithLongLong:(long long)value; ++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; ++ (NSNumber *)numberWithFloat:(float)value; ++ (NSNumber *)numberWithDouble:(double)value; ++ (NSNumber *)numberWithBool:(BOOL)value; ++ (NSNumber *)numberWithInteger:(NSInteger)value ; ++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ; +@end + + +extern char *strdup(const char *str); + +id constant_string() { + return @("boxed constant string."); +} + +id dynamic_string() { + return @(strdup("boxed dynamic string")); // expected-warning{{Memory is never released; potential leak}} +} + +id const_char_pointer(int *x) { + if (x) + return @(3); + return @(*x); // expected-warning {{Dereference of null pointer (loaded from variable 'x')}} +}
\ No newline at end of file diff --git a/test/Analysis/objc-for.m b/test/Analysis/objc-for.m new file mode 100644 index 000000000000..52a55b07db5d --- /dev/null +++ b/test/Analysis/objc-for.m @@ -0,0 +1,58 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.Loops,debug.ExprInspection -verify + +void clang_analyzer_eval(int); + +#define nil ((id)0) + +@protocol NSFastEnumeration +- (int)countByEnumeratingWithState:(void *)state objects:(id *)objects count:(unsigned)count; +@end + +@interface NSObject ++ (instancetype)testObject; +@end + +@interface NSEnumerator <NSFastEnumeration> +@end + +@interface NSArray : NSObject <NSFastEnumeration> +- (NSEnumerator *)objectEnumerator; +@end + +@interface NSDictionary : NSObject <NSFastEnumeration> +@end + +@interface NSMutableDictionary : NSDictionary +@end + +@interface NSSet : NSObject <NSFastEnumeration> +@end + +@interface NSPointerArray : NSObject <NSFastEnumeration> +@end + +void test() { + id x; + for (x in [NSArray testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{TRUE}} + + for (x in [NSMutableDictionary testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{TRUE}} + + for (x in [NSSet testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{TRUE}} + + for (x in [[NSArray testObject] objectEnumerator]) + clang_analyzer_eval(x != nil); // expected-warning{{TRUE}} + + for (x in [NSPointerArray testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{UNKNOWN}} +} + +void testWithVarInFor() { + for (id x in [NSArray testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{TRUE}} + for (id x in [NSPointerArray testObject]) + clang_analyzer_eval(x != nil); // expected-warning{{UNKNOWN}} +} + diff --git a/test/Analysis/objc-subscript.m b/test/Analysis/objc-subscript.m new file mode 100644 index 000000000000..324bf1c785c1 --- /dev/null +++ b/test/Analysis/objc-subscript.m @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount -analyzer-store=region -verify -Wno-objc-root-class %s + +typedef signed char BOOL; +typedef unsigned int NSUInteger; + +@interface NSObject ++(id)alloc; +-(id)init; +-(id)autorelease; +-(id)copy; +-(id)retain; +@end + +@interface Subscriptable : NSObject +- (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)index; +- (id)objectAtIndexedSubscript:(NSUInteger)index; + +- (void)setObject:(id)obj forKeyedSubscript:(id)key; +- (id)objectForKeyedSubscript:(id)key; +@end + +@interface Test : Subscriptable +@end + +@implementation Test + +// <rdar://problem/6946338> for subscripting +- (id)storeDoesNotRetain { + Test *cell = [[[Test alloc] init] autorelease]; + + NSObject *string1 = [[NSObject alloc] init]; // expected-warning {{Potential leak}} + cell[0] = string1; + cell[self] = string1; + cell[string1] = self; + + return cell; +} + +// <rdar://problem/8824416> for subscripting +- (id)getDoesNotRetain:(BOOL)keyed { + if (keyed) + return [self[self] autorelease]; // expected-warning{{Object sent -autorelease too many times}} + else + return [self[0] autorelease]; // expected-warning{{Object sent -autorelease too many times}} +} + +// <rdar://problem/9241180> for subscripting +- (id)testUninitializedObject:(BOOL)keyed { + Test *o; + if (keyed) { + if (o[self]) // expected-warning {{Subscript access on an uninitialized object pointer}} + return o; // no-warning (sink) + } else { + if (o[0]) // expected-warning {{Subscript access on an uninitialized object pointer}} + return o; // no-warning (sink) + } + return self; +} + +- (void)testUninitializedArgument:(id)input testCase:(unsigned)testCase { + NSUInteger i; + id o; + + switch (testCase) { + case 0: + self[0] = o; // expected-warning {{Argument for subscript setter is an uninitialized value}} + break; + case 1: + self[i] = input; // expected-warning {{Subscript index is an uninitialized value}} + break; + case 2: + (void)self[i]; // expected-warning {{Subscript index is an uninitialized value}} + break; + case 3: + self[input] = o; // expected-warning {{Argument for subscript setter is an uninitialized value}} + break; + case 4: + self[o] = input; // expected-warning {{Subscript index is an uninitialized value}} + break; + case 5: + (void)self[o]; // expected-warning {{Subscript index is an uninitialized value}} + break; + default: + break; + } + +} + +@end diff --git a/test/Analysis/operator-calls.cpp b/test/Analysis/operator-calls.cpp index 73cd28ac0d56..dbc63bc4bed8 100644 --- a/test/Analysis/operator-calls.cpp +++ b/test/Analysis/operator-calls.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,debug.ExprInspection -analyzer-ipa=inlining -verify %s +void clang_analyzer_eval(bool); + struct X0 { }; bool operator==(const X0&, const X0&); @@ -14,3 +16,17 @@ void t2() { bool PR7287(X0 a, X0 b) { return operator==(a, b); } + + +// Inlining non-static member operators mistakenly treated 'this' as the first +// argument for a while. + +struct IntComparable { + bool operator==(int x) const { + return x == 0; + } +}; + +void testMemberOperator(IntComparable B) { + clang_analyzer_eval(B == 0); // expected-warning{{TRUE}} +} diff --git a/test/Analysis/out-of-bounds.c b/test/Analysis/out-of-bounds.c index a97bba5bb3b8..c1721703fb86 100644 --- a/test/Analysis/out-of-bounds.c +++ b/test/Analysis/out-of-bounds.c @@ -128,11 +128,13 @@ void test2_multi_ok(int x) { buf[0][0] = 1; // no-warning } -// Testing if solver handles (symbol * constant) < constant +// *** FIXME *** +// We don't get a warning here yet because our symbolic constraint solving +// doesn't handle: (symbol * constant) < constant void test3(int x) { int buf[100]; if (x < 0) - buf[x] = 1; // expected-warning {{Out of bound memory access (accessed memory precedes memory block)}} + buf[x] = 1; } // *** FIXME *** diff --git a/test/Analysis/outofbound-notwork.c b/test/Analysis/outofbound-notwork.c index 45e713b6880a..c1fa2d7148e8 100644 --- a/test/Analysis/outofbound-notwork.c +++ b/test/Analysis/outofbound-notwork.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,experimental.unix,experimental.security.ArrayBound -analyzer-store=region -verify %s +// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,experimental.security.ArrayBound -analyzer-store=region -verify %s // XFAIL: * // Once we better handle modeling of sizes of VLAs, we can pull this back diff --git a/test/Analysis/outofbound.c b/test/Analysis/outofbound.c index 2e7a7d30d67f..2783ac28313c 100644 --- a/test/Analysis/outofbound.c +++ b/test/Analysis/outofbound.c @@ -86,3 +86,39 @@ int symbolic_index2(int a) { } return 0; } + +int overflow_binary_search(double in) { + int eee = 16; + if (in < 1e-8 || in > 1e23) { + return 0; + } else { + static const double ins[] = {1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, + 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, + 1e16, 1e17, 1e18, 1e19, 1e20, 1e21, 1e22}; + if (in < ins[eee]) { + eee -= 8; + } else { + eee += 8; + } + if (in < ins[eee]) { + eee -= 4; + } else { + eee += 4; + } + if (in < ins[eee]) { + eee -= 2; + } else { + eee += 2; + } + if (in < ins[eee]) { + eee -= 1; + } else { + eee += 1; + } + if (in < ins[eee]) { // expected-warning {{Access out-of-bound array element (buffer overflow)}} + eee -= 1; + } + } + return eee; +} diff --git a/test/Analysis/plist-output-alternate.m b/test/Analysis/plist-output-alternate.m index 83100dc20944..a338a79491fd 100644 --- a/test/Analysis/plist-output-alternate.m +++ b/test/Analysis/plist-output-alternate.m @@ -82,7 +82,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>5</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -137,6 +137,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_init</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>6</integer> @@ -161,7 +162,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>10</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -216,6 +217,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_assign</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>12</integer> @@ -240,7 +242,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>16</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -295,6 +297,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_assign_transitive</string> +// CHECK: <key>issue_hash</key><integer>4</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>19</integer> @@ -319,7 +322,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>23</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -332,7 +335,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>23</integer> -// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -382,7 +385,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>23</integer> -// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -437,6 +440,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_cond</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>24</integer> @@ -461,7 +465,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>29</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -474,7 +478,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>29</integer> -// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -495,7 +499,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>29</integer> -// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -508,7 +512,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>30</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -529,7 +533,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>30</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -584,6 +588,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_cond_transitive</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>31</integer> @@ -608,7 +613,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>36</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -697,6 +702,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_field</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>38</integer> @@ -721,7 +727,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>53</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -734,7 +740,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>54</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>13</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -755,7 +761,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>54</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>13</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -768,7 +774,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>54</integer> -// CHECK: <key>col</key><integer>82</integer> +// CHECK: <key>col</key><integer>36</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -818,7 +824,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>54</integer> -// CHECK: <key>col</key><integer>82</integer> +// CHECK: <key>col</key><integer>36</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -831,7 +837,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>55</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -852,7 +858,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>55</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -899,7 +905,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>57</integer> -// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>col</key><integer>14</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -920,7 +926,7 @@ void rdar8331641(int x) { // CHECK: </dict> // CHECK: <dict> // CHECK: <key>line</key><integer>57</integer> -// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>col</key><integer>14</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -960,6 +966,7 @@ void rdar8331641(int x) { // CHECK: <key>type</key><string>Leak</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>rdar8331641</string> +// CHECK: <key>issue_hash</key><integer>6</integer> // CHECK: <key>location</key> // CHECK: <dict> // CHECK: <key>line</key><integer>58</integer> diff --git a/test/Analysis/plist-output.m b/test/Analysis/plist-output.m index 72e8f8d0aa66..769c1bc60247 100644 --- a/test/Analysis/plist-output.m +++ b/test/Analysis/plist-output.m @@ -1,5 +1,4 @@ -// RUN: %clang --analyze %s -o %t > /dev/null 2>&1 -// RUN: FileCheck -input-file %t %s +// RUN: %clang --analyze %s -o - 2>/dev/null | FileCheck %s void test_null_init(void) { int *p = 0; @@ -27,7 +26,6 @@ void test_null_cond(int *p) { void test_null_cond_transitive(int *q) { if (!q) { - // FIXME: we need a diagnostic saying that p is initialized to 0 int *p = q; *p = 0xDEADBEEF; } @@ -81,10 +79,12 @@ int test_cond_assign() { @end // CHECK: <?xml version="1.0" encoding="UTF-8"?> +// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> // CHECK: <plist version="1.0"> // CHECK: <dict> // CHECK: <key>files</key> // CHECK: <array> +// CHECK: <string>{{.*}}plist-output.m</string> // CHECK: </array> // CHECK: <key>diagnostics</key> // CHECK: <array> @@ -92,6 +92,35 @@ int test_cond_assign() { // CHECK: <key>path</key> // CHECK: <array> // CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>4</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>4</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>4</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: <key>message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: </dict> +// CHECK: <dict> // CHECK: <key>kind</key><string>control</string> // CHECK: <key>edges</key> // CHECK: <array> @@ -99,25 +128,25 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>5</integer> +// CHECK: <key>line</key><integer>4</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>5</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>4</integer> +// CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>6</integer> +// CHECK: <key>line</key><integer>5</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>6</integer> +// CHECK: <key>line</key><integer>5</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -129,7 +158,7 @@ int test_cond_assign() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>6</integer> +// CHECK: <key>line</key><integer>5</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -137,12 +166,12 @@ int test_cond_assign() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>6</integer> +// CHECK: <key>line</key><integer>5</integer> // CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>6</integer> +// CHECK: <key>line</key><integer>5</integer> // CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -160,9 +189,10 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_init</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>6</integer> +// CHECK: <key>line</key><integer>5</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -178,6 +208,69 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> +// CHECK: <key>line</key><integer>9</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>9</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>10</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Null pointer value stored to 'p'</string> +// CHECK: <key>message</key> +// CHECK: <string>Null pointer value stored to 'p'</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> // CHECK: <key>line</key><integer>10</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> @@ -191,12 +284,12 @@ int test_cond_assign() { // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>12</integer> +// CHECK: <key>line</key><integer>11</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>12</integer> +// CHECK: <key>line</key><integer>11</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -208,7 +301,7 @@ int test_cond_assign() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>12</integer> +// CHECK: <key>line</key><integer>11</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -216,12 +309,12 @@ int test_cond_assign() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>12</integer> +// CHECK: <key>line</key><integer>11</integer> // CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>12</integer> +// CHECK: <key>line</key><integer>11</integer> // CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -239,9 +332,10 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_assign</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>12</integer> +// CHECK: <key>line</key><integer>11</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -257,25 +351,88 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>16</integer> +// CHECK: <key>line</key><integer>15</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>16</integer> +// CHECK: <key>line</key><integer>15</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Variable 'q' initialized to a null pointer value</string> +// CHECK: <key>message</key> +// CHECK: <string>Variable 'q' initialized to a null pointer value</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>17</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>line</key><integer>18</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>line</key><integer>18</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -287,7 +444,7 @@ int test_cond_assign() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>line</key><integer>18</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -295,12 +452,12 @@ int test_cond_assign() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>line</key><integer>18</integer> // CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>line</key><integer>18</integer> // CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -318,9 +475,10 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_assign_transitive</string> +// CHECK: <key>issue_hash</key><integer>4</integer> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>19</integer> +// CHECK: <key>line</key><integer>18</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -336,26 +494,26 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>line</key><integer>22</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>23</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>22</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>line</key><integer>22</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>23</integer> -// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>line</key><integer>22</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -366,7 +524,7 @@ int test_cond_assign() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>line</key><integer>22</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -374,12 +532,12 @@ int test_cond_assign() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>line</key><integer>22</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>line</key><integer>22</integer> // CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -392,6 +550,35 @@ int test_cond_assign() { // CHECK: <string>Assuming 'p' is null</string> // CHECK: </dict> // CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>22</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>22</integer> +// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>22</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Assuming pointer value is null</string> +// CHECK: <key>message</key> +// CHECK: <string>Assuming pointer value is null</string> +// CHECK: </dict> +// CHECK: <dict> // CHECK: <key>kind</key><string>control</string> // CHECK: <key>edges</key> // CHECK: <array> @@ -399,25 +586,25 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>23</integer> +// CHECK: <key>line</key><integer>22</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>23</integer> -// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>line</key><integer>22</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>line</key><integer>23</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>line</key><integer>23</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -429,7 +616,7 @@ int test_cond_assign() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>line</key><integer>23</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -437,12 +624,12 @@ int test_cond_assign() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>line</key><integer>23</integer> // CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>line</key><integer>23</integer> // CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -460,9 +647,10 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_cond</string> +// CHECK: <key>issue_hash</key><integer>2</integer> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>24</integer> +// CHECK: <key>line</key><integer>23</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -478,26 +666,26 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>line</key><integer>28</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>29</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>line</key><integer>28</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>29</integer> -// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -512,26 +700,26 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>line</key><integer>28</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>29</integer> -// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>line</key><integer>28</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>31</integer> +// CHECK: <key>line</key><integer>29</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>31</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -539,6 +727,35 @@ int test_cond_assign() { // CHECK: </array> // CHECK: </dict> // CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: <key>message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: </dict> +// CHECK: <dict> // CHECK: <key>kind</key><string>control</string> // CHECK: <key>edges</key> // CHECK: <array> @@ -546,25 +763,25 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>31</integer> +// CHECK: <key>line</key><integer>29</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>31</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>line</key><integer>29</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>line</key><integer>30</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>line</key><integer>30</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -576,7 +793,7 @@ int test_cond_assign() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>line</key><integer>30</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -584,12 +801,12 @@ int test_cond_assign() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>line</key><integer>30</integer> // CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>line</key><integer>30</integer> // CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -607,9 +824,10 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_cond_transitive</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>32</integer> +// CHECK: <key>line</key><integer>30</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -625,25 +843,25 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>37</integer> +// CHECK: <key>line</key><integer>35</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>37</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>35</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>37</integer> +// CHECK: <key>line</key><integer>35</integer> // CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>37</integer> +// CHECK: <key>line</key><integer>35</integer> // CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -659,12 +877,12 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>37</integer> +// CHECK: <key>line</key><integer>35</integer> // CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>37</integer> +// CHECK: <key>line</key><integer>35</integer> // CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -672,12 +890,12 @@ int test_cond_assign() { // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>39</integer> +// CHECK: <key>line</key><integer>37</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>39</integer> +// CHECK: <key>line</key><integer>37</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -689,7 +907,7 @@ int test_cond_assign() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>39</integer> +// CHECK: <key>line</key><integer>37</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -697,12 +915,12 @@ int test_cond_assign() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>39</integer> +// CHECK: <key>line</key><integer>37</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>39</integer> +// CHECK: <key>line</key><integer>37</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -720,9 +938,10 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_null_field</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>39</integer> +// CHECK: <key>line</key><integer>37</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -738,25 +957,25 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>44</integer> +// CHECK: <key>line</key><integer>42</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>44</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>44</integer> +// CHECK: <key>line</key><integer>42</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>44</integer> +// CHECK: <key>line</key><integer>42</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -772,12 +991,12 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>44</integer> +// CHECK: <key>line</key><integer>42</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>44</integer> +// CHECK: <key>line</key><integer>42</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -785,13 +1004,13 @@ int test_cond_assign() { // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>line</key><integer>45</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>47</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -806,25 +1025,25 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>line</key><integer>45</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>47</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>line</key><integer>45</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>line</key><integer>45</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -840,12 +1059,12 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>line</key><integer>45</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>line</key><integer>45</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -853,13 +1072,13 @@ int test_cond_assign() { // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>line</key><integer>48</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>50</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -867,6 +1086,35 @@ int test_cond_assign() { // CHECK: </array> // CHECK: </dict> // CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: <key>message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: </dict> +// CHECK: <dict> // CHECK: <key>kind</key><string>control</string> // CHECK: <key>edges</key> // CHECK: <array> @@ -874,25 +1122,25 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>line</key><integer>48</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>50</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>line</key><integer>49</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>line</key><integer>49</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -904,7 +1152,7 @@ int test_cond_assign() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>line</key><integer>49</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -912,12 +1160,12 @@ int test_cond_assign() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>line</key><integer>49</integer> // CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>line</key><integer>49</integer> // CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -935,9 +1183,10 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_assumptions</string> +// CHECK: <key>issue_hash</key><integer>8</integer> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>line</key><integer>49</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -953,26 +1202,26 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>line</key><integer>54</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>56</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>54</integer> +// CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>line</key><integer>55</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>57</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -987,25 +1236,25 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>line</key><integer>55</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>57</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>line</key><integer>55</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>line</key><integer>55</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -1017,7 +1266,7 @@ int test_cond_assign() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>line</key><integer>55</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -1025,12 +1274,12 @@ int test_cond_assign() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>line</key><integer>55</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>line</key><integer>55</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -1050,12 +1299,12 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>line</key><integer>55</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>line</key><integer>55</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -1063,13 +1312,13 @@ int test_cond_assign() { // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>line</key><integer>57</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>59</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1084,26 +1333,26 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>line</key><integer>57</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>59</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>8</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>line</key><integer>57</integer> // CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>59</integer> -// CHECK: <key>col</key><integer>11</integer> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> @@ -1114,7 +1363,7 @@ int test_cond_assign() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>line</key><integer>57</integer> // CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -1122,12 +1371,12 @@ int test_cond_assign() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>line</key><integer>57</integer> // CHECK: <key>col</key><integer>11</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>line</key><integer>57</integer> // CHECK: <key>col</key><integer>11</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -1145,9 +1394,10 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>function</string> // CHECK: <key>issue_context</key><string>test_cond_assign</string> +// CHECK: <key>issue_hash</key><integer>4</integer> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>line</key><integer>57</integer> // CHECK: <key>col</key><integer>10</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -1163,99 +1413,60 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> +// CHECK: <key>line</key><integer>74</integer> // CHECK: <key>col</key><integer>3</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> -// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>line</key><integer>74</integer> +// CHECK: <key>col</key><integer>4</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> -// CHECK: <key>col</key><integer>7</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> -// CHECK: <key>col</key><integer>7</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: </array> -// CHECK: </dict> -// CHECK: </array> -// CHECK: </dict> -// CHECK: <dict> -// CHECK: <key>kind</key><string>control</string> -// CHECK: <key>edges</key> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>start</key> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> -// CHECK: <key>col</key><integer>7</integer> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> +// CHECK: <key>line</key><integer>75</integer> // CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> -// CHECK: <key>end</key> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> -// CHECK: <key>col</key><integer>3</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> -// CHECK: <key>col</key><integer>3</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: </array> // CHECK: </dict> // CHECK: </array> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>kind</key><string>control</string> -// CHECK: <key>edges</key> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>start</key> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> -// CHECK: <key>col</key><integer>3</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: <dict> -// CHECK: <key>line</key><integer>76</integer> -// CHECK: <key>col</key><integer>3</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: </array> -// CHECK: <key>end</key> -// CHECK: <array> -// CHECK: <dict> -// CHECK: <key>line</key><integer>77</integer> -// CHECK: <key>col</key><integer>5</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: <dict> -// CHECK: <key>line</key><integer>77</integer> -// CHECK: <key>col</key><integer>5</integer> -// CHECK: <key>file</key><integer>0</integer> -// CHECK: </dict> -// CHECK: </array> -// CHECK: </dict> -// CHECK: </array> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> +// CHECK: <key>message</key> +// CHECK: <string>Variable 'p' initialized to a null pointer value</string> // CHECK: </dict> // CHECK: <dict> // CHECK: <key>kind</key><string>control</string> @@ -1265,25 +1476,25 @@ int test_cond_assign() { // CHECK: <key>start</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>77</integer> +// CHECK: <key>line</key><integer>75</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>77</integer> -// CHECK: <key>col</key><integer>5</integer> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>7</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: </array> // CHECK: <key>end</key> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>78</integer> +// CHECK: <key>line</key><integer>76</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>78</integer> +// CHECK: <key>line</key><integer>76</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -1295,7 +1506,7 @@ int test_cond_assign() { // CHECK: <key>kind</key><string>event</string> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>78</integer> +// CHECK: <key>line</key><integer>76</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -1303,12 +1514,12 @@ int test_cond_assign() { // CHECK: <array> // CHECK: <array> // CHECK: <dict> -// CHECK: <key>line</key><integer>78</integer> +// CHECK: <key>line</key><integer>76</integer> // CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> // CHECK: <dict> -// CHECK: <key>line</key><integer>78</integer> +// CHECK: <key>line</key><integer>76</integer> // CHECK: <key>col</key><integer>6</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -1326,9 +1537,10 @@ int test_cond_assign() { // CHECK: <key>type</key><string>Dereference of null pointer</string> // CHECK: <key>issue_context_kind</key><string>Objective-C method</string> // CHECK: <key>issue_context</key><string>test</string> +// CHECK: <key>issue_hash</key><integer>3</integer> // CHECK: <key>location</key> // CHECK: <dict> -// CHECK: <key>line</key><integer>78</integer> +// CHECK: <key>line</key><integer>76</integer> // CHECK: <key>col</key><integer>5</integer> // CHECK: <key>file</key><integer>0</integer> // CHECK: </dict> @@ -1336,4 +1548,3 @@ int test_cond_assign() { // CHECK: </array> // CHECK: </dict> // CHECK: </plist> - diff --git a/test/Analysis/ptr-arith.c b/test/Analysis/ptr-arith.c index fb37f1c791a3..6567000c735f 100644 --- a/test/Analysis/ptr-arith.c +++ b/test/Analysis/ptr-arith.c @@ -1,8 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.FixedAddr,experimental.core.PointerArithm,experimental.core.PointerSub -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s -// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.FixedAddr,experimental.core.PointerArithm,experimental.core.PointerSub -analyzer-store=region -verify -triple i686-apple-darwin9 %s +// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.FixedAddr,experimental.core.PointerArithm,experimental.core.PointerSub,debug.ExprInspection -analyzer-store=region -verify -triple x86_64-apple-darwin9 %s +// RUN: %clang_cc1 -analyze -analyzer-checker=experimental.core.FixedAddr,experimental.core.PointerArithm,experimental.core.PointerSub,debug.ExprInspection -analyzer-store=region -verify -triple i686-apple-darwin9 %s -// Used to trigger warnings for unreachable paths. -#define WARN do { int a, b; int c = &b-&a; } while (0) +void clang_analyzer_eval(int); void f1() { int a[10]; @@ -67,111 +66,48 @@ void f6(int *p, int *q) { void null_operand(int *a) { start: // LHS is a label, RHS is NULL - if (&&start == 0) - WARN; // no-warning - if (&&start < 0) - WARN; // no-warning - if (&&start <= 0) - WARN; // no-warning - if (!(&&start != 0)) - WARN; // no-warning - if (!(&&start > 0)) - WARN; // no-warning - if (!(&&start >= 0)) - WARN; // no-warning - if (!(&&start - 0)) - WARN; // no-warning + clang_analyzer_eval(&&start != 0); // expected-warning{{TRUE}} + clang_analyzer_eval(&&start >= 0); // expected-warning{{TRUE}} + clang_analyzer_eval(&&start > 0); // expected-warning{{TRUE}} + clang_analyzer_eval((&&start - 0) != 0); // expected-warning{{TRUE}} // LHS is a non-symbolic value, RHS is NULL - if (&a == 0) - WARN; // no-warning - if (&a < 0) - WARN; // no-warning - if (&a <= 0) - WARN; // no-warning - if (!(&a != 0)) - WARN; // no-warning - if (!(&a > 0)) - WARN; // no-warning - if (!(&a >= 0)) - WARN; // no-warning - - if (!(&a - 0)) // expected-warning{{Pointer arithmetic done on non-array variables}} - WARN; // no-warning + clang_analyzer_eval(&a != 0); // expected-warning{{TRUE}} + clang_analyzer_eval(&a >= 0); // expected-warning{{TRUE}} + clang_analyzer_eval(&a > 0); // expected-warning{{TRUE}} + clang_analyzer_eval((&a - 0) != 0); // expected-warning{{TRUE}} expected-warning{{Pointer arithmetic done on non-array variables}} // LHS is NULL, RHS is non-symbolic // The same code is used for labels and non-symbolic values. - if (0 == &a) - WARN; // no-warning - if (0 > &a) - WARN; // no-warning - if (0 >= &a) - WARN; // no-warning - if (!(0 != &a)) - WARN; // no-warning - if (!(0 < &a)) - WARN; // no-warning - if (!(0 <= &a)) - WARN; // no-warning + clang_analyzer_eval(0 != &a); // expected-warning{{TRUE}} + clang_analyzer_eval(0 <= &a); // expected-warning{{TRUE}} + clang_analyzer_eval(0 < &a); // expected-warning{{TRUE}} // LHS is a symbolic value, RHS is NULL - if (a == 0) - WARN; // expected-warning{{}} - if (a < 0) - WARN; // no-warning - if (a <= 0) - WARN; // expected-warning{{}} - if (!(a != 0)) - WARN; // expected-warning{{}} - if (!(a > 0)) - WARN; // expected-warning{{}} - if (!(a >= 0)) - WARN; // no-warning - if (!(a - 0)) - WARN; // expected-warning{{}} + clang_analyzer_eval(a != 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a >= 0); // expected-warning{{TRUE}} + clang_analyzer_eval(a <= 0); // expected-warning{{UNKNOWN}} + clang_analyzer_eval((a - 0) != 0); // expected-warning{{UNKNOWN}} // LHS is NULL, RHS is a symbolic value - if (0 == a) - WARN; // expected-warning{{}} - if (0 > a) - WARN; // no-warning - if (0 >= a) - WARN; // expected-warning{{}} - if (!(0 != a)) - WARN; // expected-warning{{}} - if (!(0 < a)) - WARN; // expected-warning{{}} - if (!(0 <= a)) - WARN; // no-warning + clang_analyzer_eval(0 != a); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(0 <= a); // expected-warning{{TRUE}} + clang_analyzer_eval(0 < a); // expected-warning{{UNKNOWN}} } void const_locs() { char *a = (char*)0x1000; char *b = (char*)0x1100; start: - if (a==b) - WARN; // no-warning - if (!(a!=b)) - WARN; // no-warning - if (a>b) - WARN; // no-warning - if (b<a) - WARN; // no-warning - if (a>=b) - WARN; // no-warning - if (b<=a) - WARN; // no-warning - if (b-a != 0x100) - WARN; // no-warning - - if (&&start == a) - WARN; // expected-warning{{}} - if (a == &&start) - WARN; // expected-warning{{}} - if (&a == (char**)a) - WARN; // expected-warning{{}} - if ((char**)a == &a) - WARN; // expected-warning{{}} + clang_analyzer_eval(a != b); // expected-warning{{TRUE}} + clang_analyzer_eval(a < b); // expected-warning{{TRUE}} + clang_analyzer_eval(a <= b); // expected-warning{{TRUE}} + clang_analyzer_eval((b-a) == 0x100); // expected-warning{{TRUE}} + + clang_analyzer_eval(&&start == a); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == &&start); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(&a == (char**)a); // expected-warning{{UNKNOWN}} + clang_analyzer_eval((char**)a == &a); // expected-warning{{UNKNOWN}} } void array_matching_types() { @@ -179,20 +115,10 @@ void array_matching_types() { int *a = &array[2]; int *b = &array[5]; - if (a==b) - WARN; // no-warning - if (!(a!=b)) - WARN; // no-warning - if (a>b) - WARN; // no-warning - if (b<a) - WARN; // no-warning - if (a>=b) - WARN; // no-warning - if (b<=a) - WARN; // no-warning - if ((b-a) == 0) - WARN; // no-warning + clang_analyzer_eval(a != b); // expected-warning{{TRUE}} + clang_analyzer_eval(a < b); // expected-warning{{TRUE}} + clang_analyzer_eval(a <= b); // expected-warning{{TRUE}} + clang_analyzer_eval((b-a) != 0); // expected-warning{{TRUE}} } // This takes a different code path than array_matching_types() @@ -201,49 +127,22 @@ void array_different_types() { int *a = &array[2]; char *b = (char*)&array[5]; - if (a==b) // expected-warning{{comparison of distinct pointer types}} - WARN; // no-warning - if (!(a!=b)) // expected-warning{{comparison of distinct pointer types}} - WARN; // no-warning - if (a>b) // expected-warning{{comparison of distinct pointer types}} - WARN; // no-warning - if (b<a) // expected-warning{{comparison of distinct pointer types}} - WARN; // no-warning - if (a>=b) // expected-warning{{comparison of distinct pointer types}} - WARN; // no-warning - if (b<=a) // expected-warning{{comparison of distinct pointer types}} - WARN; // no-warning + clang_analyzer_eval(a != b); // expected-warning{{TRUE}} expected-warning{{comparison of distinct pointer types}} + clang_analyzer_eval(a < b); // expected-warning{{TRUE}} expected-warning{{comparison of distinct pointer types}} + clang_analyzer_eval(a <= b); // expected-warning{{TRUE}} expected-warning{{comparison of distinct pointer types}} } struct test { int x; int y; }; void struct_fields() { struct test a, b; - if (&a.x == &a.y) - WARN; // no-warning - if (!(&a.x != &a.y)) - WARN; // no-warning - if (&a.x > &a.y) - WARN; // no-warning - if (&a.y < &a.x) - WARN; // no-warning - if (&a.x >= &a.y) - WARN; // no-warning - if (&a.y <= &a.x) - WARN; // no-warning + clang_analyzer_eval(&a.x != &a.y); // expected-warning{{TRUE}} + clang_analyzer_eval(&a.x < &a.y); // expected-warning{{TRUE}} + clang_analyzer_eval(&a.x <= &a.y); // expected-warning{{TRUE}} - if (&a.x == &b.x) - WARN; // no-warning - if (!(&a.x != &b.x)) - WARN; // no-warning - if (&a.x > &b.x) - WARN; // expected-warning{{}} - if (&b.x < &a.x) - WARN; // expected-warning{{}} - if (&a.x >= &b.x) - WARN; // expected-warning{{}} - if (&b.x <= &a.x) - WARN; // expected-warning{{}} + clang_analyzer_eval(&a.x != &b.x); // expected-warning{{TRUE}} + clang_analyzer_eval(&a.x > &b.x); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(&a.x >= &b.x); // expected-warning{{UNKNOWN}} } void mixed_region_types() { @@ -251,35 +150,17 @@ void mixed_region_types() { int array[2]; void *a = &array, *b = &s; - if (&a == &b) - WARN; // no-warning - if (!(&a != &b)) - WARN; // no-warning - if (&a > &b) - WARN; // expected-warning{{}} - if (&b < &a) - WARN; // expected-warning{{}} - if (&a >= &b) - WARN; // expected-warning{{}} - if (&b <= &a) - WARN; // expected-warning{{}} + clang_analyzer_eval(&a != &b); // expected-warning{{TRUE}} + clang_analyzer_eval(&a > &b); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(&a >= &b); // expected-warning{{UNKNOWN}} } void symbolic_region(int *p) { int a; - if (&a == p) - WARN; // no-warning - if (&a != p) - WARN; // expected-warning{{}} - if (&a > p) - WARN; // expected-warning{{}} - if (&a < p) - WARN; // expected-warning{{}} - if (&a >= p) - WARN; // expected-warning{{}} - if (&a <= p) - WARN; // expected-warning{{}} + clang_analyzer_eval(&a != p); // expected-warning{{TRUE}} + clang_analyzer_eval(&a > p); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(&a >= p); // expected-warning{{UNKNOWN}} } void PR7527 (int *p) { diff --git a/test/Analysis/rdar-7168531.m b/test/Analysis/rdar-7168531.m index 151625569ca7..4ccc7d7a2b34 100644 --- a/test/Analysis/rdar-7168531.m +++ b/test/Analysis/rdar-7168531.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -triple i386-apple-darwin10 -fobjc-fragile-abi -analyzer-store=region %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -analyzer-store=region %s // Note that the target triple is important for this test case. It specifies that we use the // fragile Objective-C ABI. diff --git a/test/Analysis/refcnt_naming.m b/test/Analysis/refcnt_naming.m index aff713be49f2..1d3a9b7589e3 100644 --- a/test/Analysis/refcnt_naming.m +++ b/test/Analysis/refcnt_naming.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,osx.cocoa.RetainCount,experimental.core -analyzer-ipa=none -analyzer-store=region -verify %s typedef const struct __CFString * CFStringRef; typedef const struct __CFAllocator * CFAllocatorRef; diff --git a/test/Analysis/reference.cpp b/test/Analysis/reference.cpp index 5897e682884c..06e4a50e44cc 100644 --- a/test/Analysis/reference.cpp +++ b/test/Analysis/reference.cpp @@ -1,11 +1,12 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core -analyzer-store=region -analyzer-constraints=range -verify -Wno-null-dereference %s -// XFAIL +// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.core,debug.ExprInspection -analyzer-store=region -analyzer-constraints=range -verify -Wno-null-dereference %s + +void clang_analyzer_eval(bool); typedef typeof(sizeof(int)) size_t; void malloc (size_t); void f1() { - int const &i = 3; // <--- **FIXME** This is currently not being modeled correctly. + int const &i = 3; int b = i; int *p = 0; @@ -56,3 +57,75 @@ char t6 (char* p) { if (*p) return *p; return *(char*)0; // no-warning } + + +// PR13440 / <rdar://problem/11977113> +// Test that the array-to-pointer decay works for array references as well. +// More generally, when we want an lvalue for a reference field, we still need +// to do one level of load. +namespace PR13440 { + typedef int T[1]; + struct S { + T &x; + + int *m() { return x; } + }; + + struct S2 { + int (&x)[1]; + + int *m() { return x; } + }; + + void test() { + int a[1]; + S s = { a }; + S2 s2 = { a }; + + if (s.x != a) return; + if (s2.x != a) return; + + a[0] = 42; + clang_analyzer_eval(s.x[0] == 42); // expected-warning{{TRUE}} + clang_analyzer_eval(s2.x[0] == 42); // expected-warning{{TRUE}} + } +} + +void testNullReference() { + int *x = 0; + int &y = *x; // expected-warning{{Dereference of null pointer}} + y = 5; +} + +void testRetroactiveNullReference(int *x) { + // According to the C++ standard, there is no such thing as a + // "null reference". So the 'if' statement ought to be dead code. + // However, Clang (and other compilers) don't actually check that a pointer + // value is non-null in the implementation of references, so it is possible + // to produce a supposed "null reference" at runtime. The analyzer shoeuld + // still warn when it can prove such errors. + int &y = *x; + if (x != 0) + return; + y = 5; // expected-warning{{Dereference of null pointer}} +} + + +// ------------------------------------ +// False negatives +// ------------------------------------ + +namespace rdar11212286 { + class B{}; + + B test() { + B *x = 0; + return *x; // should warn here! + } + + B &testRef() { + B *x = 0; + return *x; // should warn here! + } + +} diff --git a/test/Analysis/region-store.c b/test/Analysis/region-store.c new file mode 100644 index 000000000000..09c3f102e3ad --- /dev/null +++ b/test/Analysis/region-store.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix -verify %s + +int printf(const char *restrict,...); + +// Testing core functionality of the region store. +// radar://10127782 +int compoundLiteralTest() { + int index = 0; + for (index = 0; index < 2; index++) { + int thing = (int []){0, 1}[index]; + printf("thing: %i\n", thing); + } + return 0; +} + +int compoundLiteralTest2() { + int index = 0; + for (index = 0; index < 3; index++) { + int thing = (int [][3]){{0,0,0}, {1,1,1}, {2,2,2}}[index][index]; + printf("thing: %i\n", thing); + } + return 0; +} diff --git a/test/Analysis/retain-release-path-notes-gc.m b/test/Analysis/retain-release-path-notes-gc.m index 1e74f003e1a7..feee525b85a3 100644 --- a/test/Analysis/retain-release-path-notes-gc.m +++ b/test/Analysis/retain-release-path-notes-gc.m @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -analyzer-output=text -fobjc-gc-only -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fobjc-gc-only -analyzer-output=text -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -fobjc-gc-only -analyzer-output=plist-multi-file %s -o - | FileCheck %s /*** This file is for testing the path-sensitive notes for retain/release errors. @@ -71,3 +72,1339 @@ void retainReleaseIgnored () { } @end + +// CHECK: <?xml version="1.0" encoding="UTF-8"?> +// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +// CHECK: <plist version="1.0"> +// CHECK: <dict> +// CHECK: <key>files</key> +// CHECK: <array> +// CHECK: <string>{{.*}}retain-release-path-notes-gc.m</string> +// CHECK: </array> +// CHECK: <key>diagnostics</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>11</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>40</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected</string> +// CHECK: <key>message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>42</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>43</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>43</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>43</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>43</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>43</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak (when using garbage collection) of an object stored into 'leaked'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak of object when using garbage collection</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>creationViaCFCreate</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>43</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>col</key><integer>11</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>col</key><integer>40</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected</string> +// CHECK: <key>message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>47</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>17</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Reference count incremented. The object now has a +2 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Reference count incremented. The object now has a +2 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>48</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>49</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>49</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>49</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>49</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>49</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>49</integer> +// CHECK: <key>col</key><integer>21</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>49</integer> +// CHECK: <key>col</key><integer>26</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1</string> +// CHECK: <key>message</key> +// CHECK: <string>In GC mode a call to 'CFMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. An object must have a 0 retain count to be garbage collected. After this call its retain count is +1</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>49</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>49</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>21</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>26</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector</string> +// CHECK: <key>message</key> +// CHECK: <string>In GC mode a call to 'NSMakeCollectable' decrements an object's retain count and registers the object with the garbage collector. Since it now has a 0 retain count the object can be automatically collected by the garbage collector</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>17</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again</string> +// CHECK: <key>message</key> +// CHECK: <string>Reference count incremented. The object now has a +1 retain count. The object is not eligible for garbage collection until the retain count reaches 0 again</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak (when using garbage collection) of an object stored into 'leaked'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak of object when using garbage collection</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>makeCollectable</string> +// CHECK: <key>issue_hash</key><integer>6</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>52</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>37</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Method returns an Objective-C object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Method returns an Objective-C object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>17</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>In GC mode the 'retain' message has no effect</string> +// CHECK: <key>message</key> +// CHECK: <string>In GC mode the 'retain' message has no effect</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>In GC mode the 'release' message has no effect</string> +// CHECK: <key>message</key> +// CHECK: <string>In GC mode the 'release' message has no effect</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>In GC mode an 'autorelease' has no effect</string> +// CHECK: <key>message</key> +// CHECK: <string>In GC mode an 'autorelease' has no effect</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>60</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>60</integer> +// CHECK: <key>col</key><integer>11</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>60</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>60</integer> +// CHECK: <key>col</key><integer>13</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>60</integer> +// CHECK: <key>col</key><integer>29</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Bad release</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>retainReleaseIgnored</string> +// CHECK: <key>issue_hash</key><integer>5</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>60</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>36</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected</string> +// CHECK: <key>message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>36</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>66</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>66</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>66</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>66</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>66</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>66</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>66</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object returned to caller as an owning reference (single retain count transferred to caller)</string> +// CHECK: <key>message</key> +// CHECK: <string>Object returned to caller as an owning reference (single retain count transferred to caller)</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>66</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>66</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>66</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'object' and returned from method 'getViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak (when using garbage collection) of an object stored into 'object'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak of returned object when using garbage collection</string> +// CHECK: <key>issue_context_kind</key><string>Objective-C method</string> +// CHECK: <key>issue_context</key><string>getViolation</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>66</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>36</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected</string> +// CHECK: <key>message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count. Core Foundation objects are not automatically garbage collected</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>36</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object returned to caller as an owning reference (single retain count transferred to caller)</string> +// CHECK: <key>message</key> +// CHECK: <string>Object returned to caller as an owning reference (single retain count transferred to caller)</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'object' and returned from method 'copyViolation' is potentially leaked when using garbage collection. Callers of this method do not expect a returned object with a +1 retain count since they expect the object to be managed by the garbage collector</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak (when using garbage collection) of an object stored into 'object'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak of returned object when using garbage collection</string> +// CHECK: <key>issue_context_kind</key><string>Objective-C method</string> +// CHECK: <key>issue_context</key><string>copyViolation</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </plist> diff --git a/test/Analysis/retain-release-path-notes.m b/test/Analysis/retain-release-path-notes.m index c3f5fcda4442..ebcfd6adf5d4 100644 --- a/test/Analysis/retain-release-path-notes.m +++ b/test/Analysis/retain-release-path-notes.m @@ -1,8 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -analyzer-output=text -verify %s - -// This actually still works after the pseudo-object refactor, it just -// uses messages that say 'method' instead of 'property'. Ted wanted -// this xfailed and filed as a bug. rdar://problem/10402993 +// RN: %clang_cc1 -triple x86_64-apple-darwin10 -analyze -analyzer-checker=core,osx.coreFoundation.CFRetainRelease,osx.cocoa.ClassRelease,osx.cocoa.RetainCount -analyzer-store=region -analyzer-output=plist-multi-file %s -o - | FileCheck %s /*** This file is for testing the path-sensitive notes for retain/release errors. @@ -28,6 +25,9 @@ GC-specific notes should go in retain-release-path-notes-gc.m. @interface Foo : NSObject - (id)methodWithValue; @property(retain) id propertyValue; + +- (id)objectAtIndexedSubscript:(unsigned)index; +- (id)objectForKeyedSubscript:(id)key; @end typedef struct CFType *CFTypeRef; @@ -119,6 +119,16 @@ CFTypeRef CFGetRuleViolation () { return result; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} } +- (id)copyViolationIndexedSubscript { + id result = self[0]; // expected-note{{Subscript returns an Objective-C object with a +0 retain count}} + return result; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} +} + +- (id)copyViolationKeyedSubscript { + id result = self[self]; // expected-note{{Subscript returns an Objective-C object with a +0 retain count}} + return result; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} +} + - (id)getViolation { id result = [[Foo alloc] init]; // expected-warning{{leak}} expected-note{{Method returns an Objective-C object with a +1 retain count}} return result; // expected-note{{Object returned to caller as an owning reference (single retain count transferred to caller)}} expected-note{{Object leaked: object allocated and stored into 'result' is returned from a method whose name ('getViolation') does not start with 'copy', 'mutableCopy', 'alloc' or 'new'. This violates the naming convention rules given in the Memory Management Guide for Cocoa}} @@ -130,3 +140,4474 @@ CFTypeRef CFGetRuleViolation () { return result; // expected-warning{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} expected-note{{Object returned to caller with a +0 retain count}} expected-note{{Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected}} } @end + + +typedef unsigned long NSUInteger; + +@interface NSValue : NSObject +@end + +@interface NSNumber : NSValue ++ (NSNumber *)numberWithInt:(int)i; +@end + +@interface NSString : NSObject ++ (NSString *)stringWithUTF8String:(const char *)str; +@end + +@interface NSArray : NSObject ++ (NSArray *)arrayWithObjects:(const id [])objects count:(NSUInteger)count; +@end + +@interface NSDictionary : NSObject ++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id /* <NSCopying> */ [])keys count:(NSUInteger)count; +@end + + +void testNumericLiteral() { + id result = @1; // expected-note{{NSNumber literal is an object with a +0 retain count}} + [result release]; // expected-warning{{decrement}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +} + +void testBoxedInt(int x) { + id result = @(x); // expected-note{{NSNumber boxed expression produces an object with a +0 retain count}} + [result release]; // expected-warning{{decrement}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +} + +void testBoxedString(const char *str) { + id result = @(str); // expected-note{{NSString boxed expression produces an object with a +0 retain count}} + [result release]; // expected-warning{{decrement}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +} + +void testArray(id obj) { + id result = @[obj]; // expected-note{{NSArray literal is an object with a +0 retain count}} + [result release]; // expected-warning{{decrement}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +} + +void testDictionary(id key, id value) { + id result = @{key: value}; // expected-note{{NSDictionary literal is an object with a +0 retain count}} + [result release]; // expected-warning{{decrement}} expected-note{{Incorrect decrement of the reference count of an object that is not owned at this point by the caller}} +} + + +// CHECK: <?xml version="1.0" encoding="UTF-8"?> +// CHECK: <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +// CHECK: <plist version="1.0"> +// CHECK: <dict> +// CHECK: <key>files</key> +// CHECK: <array> +// CHECK: <string>{{.*}}retain-release-path-notes.m</string> +// CHECK: </array> +// CHECK: <key>diagnostics</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>37</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>45</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak of an object stored into 'leaked'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>creationViaAlloc</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>46</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>11</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>40</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>50</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak of an object stored into 'leaked'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>creationViaCFCreate</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>51</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>35</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Method returns an Objective-C object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Method returns an Objective-C object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>55</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>17</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Reference count incremented. The object now has a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Reference count incremented. The object now has a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>56</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>17</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Reference count incremented. The object now has a +2 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Reference count incremented. The object now has a +2 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>57</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Reference count decremented. The object now has a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Reference count decremented. The object now has a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>58</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak of an object stored into 'leaked'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>acquisitionViaMethod</string> +// CHECK: <key>issue_hash</key><integer>5</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>59</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Property returns an Objective-C object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Property returns an Objective-C object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>63</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>64</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>64</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>64</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>64</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>64</integer> +// CHECK: <key>col</key><integer>17</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>64</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>64</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Reference count incremented. The object now has a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Reference count incremented. The object now has a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>64</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>64</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak of an object stored into 'leaked'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>acquisitionViaProperty</string> +// CHECK: <key>issue_hash</key><integer>3</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>65</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>69</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>69</integer> +// CHECK: <key>col</key><integer>11</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>69</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>69</integer> +// CHECK: <key>col</key><integer>35</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>69</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>69</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>69</integer> +// CHECK: <key>col</key><integer>37</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>69</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>69</integer> +// CHECK: <key>col</key><integer>35</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>12</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>17</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Reference count incremented. The object now has a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Reference count incremented. The object now has a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>70</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak of an object stored into 'leaked'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>acquisitionViaCFFunction</string> +// CHECK: <key>issue_hash</key><integer>3</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>71</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>37</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>75</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>76</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>76</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>76</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>76</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>76</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>76</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>76</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object released by directly sending the '-dealloc' message</string> +// CHECK: <key>message</key> +// CHECK: <string>Object released by directly sending the '-dealloc' message</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>76</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>76</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>77</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>77</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>77</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>77</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>77</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Reference-counted object is used after it is released</string> +// CHECK: <key>message</key> +// CHECK: <string>Reference-counted object is used after it is released</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Reference-counted object is used after it is released</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Use-after-release</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>explicitDealloc</string> +// CHECK: <key>issue_hash</key><integer>3</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>77</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>81</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>81</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>81</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>81</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>81</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>81</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>81</integer> +// CHECK: <key>col</key><integer>37</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>81</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>81</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>82</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>82</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>82</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>82</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>82</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>82</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>82</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object released</string> +// CHECK: <key>message</key> +// CHECK: <string>Object released</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>82</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>82</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>83</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>83</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>83</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>83</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>83</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Reference-counted object is used after it is released</string> +// CHECK: <key>message</key> +// CHECK: <string>Reference-counted object is used after it is released</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Reference-counted object is used after it is released</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Use-after-release</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>implicitDealloc</string> +// CHECK: <key>issue_hash</key><integer>3</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>83</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>87</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>87</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>87</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>87</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>87</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>87</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>87</integer> +// CHECK: <key>col</key><integer>37</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>87</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>87</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>88</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>88</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>88</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>88</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>88</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>88</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>88</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object sent -autorelease message</string> +// CHECK: <key>message</key> +// CHECK: <string>Object sent -autorelease message</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>88</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>88</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>89</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>89</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>89</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>89</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>89</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>89</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>89</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object sent -autorelease message</string> +// CHECK: <key>message</key> +// CHECK: <string>Object sent -autorelease message</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>89</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>89</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>90</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>90</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>90</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>90</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>90</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object over-autoreleased: object was sent -autorelease 2 times but the object has a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Object over-autoreleased: object was sent -autorelease 2 times but the object has a +1 retain count</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Object sent -autorelease too many times</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Object sent -autorelease too many times</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>overAutorelease</string> +// CHECK: <key>issue_hash</key><integer>4</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>90</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>94</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>94</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>94</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>94</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>94</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>94</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>94</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Property returns an Objective-C object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Property returns an Objective-C object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>94</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>94</integer> +// CHECK: <key>col</key><integer>31</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>95</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>95</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>95</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>95</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>95</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>95</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>95</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object sent -autorelease message</string> +// CHECK: <key>message</key> +// CHECK: <string>Object sent -autorelease message</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>95</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>95</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>96</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>96</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>96</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>96</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>96</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object over-autoreleased: object was sent -autorelease but the object has a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Object over-autoreleased: object was sent -autorelease but the object has a +0 retain count</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Object sent -autorelease too many times</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Object sent -autorelease too many times</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>autoreleaseUnowned</string> +// CHECK: <key>issue_hash</key><integer>3</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>96</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>100</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>100</integer> +// CHECK: <key>col</key><integer>11</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>100</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>100</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>100</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>100</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>100</integer> +// CHECK: <key>col</key><integer>40</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>100</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>100</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>21</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>26</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>When GC is not enabled a call to 'CFMakeCollectable' has no effect on its argument</string> +// CHECK: <key>message</key> +// CHECK: <string>When GC is not enabled a call to 'CFMakeCollectable' has no effect on its argument</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>101</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>21</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>26</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>When GC is not enabled a call to 'NSMakeCollectable' has no effect on its argument</string> +// CHECK: <key>message</key> +// CHECK: <string>When GC is not enabled a call to 'NSMakeCollectable' has no effect on its argument</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>102</integer> +// CHECK: <key>col</key><integer>19</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>103</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>103</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>103</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>103</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>103</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'leaked' is not referenced later in this execution path and has a retain count of +1</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak of an object stored into 'leaked'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>makeCollectableIgnored</string> +// CHECK: <key>issue_hash</key><integer>4</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>103</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>107</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>107</integer> +// CHECK: <key>col</key><integer>11</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>107</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>107</integer> +// CHECK: <key>col</key><integer>35</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>107</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>107</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>107</integer> +// CHECK: <key>col</key><integer>37</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Call to function 'CFGetSomething' returns a Core Foundation object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>107</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>107</integer> +// CHECK: <key>col</key><integer>35</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>108</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>108</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>108</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>108</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>108</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>108</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>108</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object returned to caller with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Object returned to caller with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>108</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>108</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>108</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: <key>message</key> +// CHECK: <string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Method should return an owned object</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>CFCopyRuleViolation</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>108</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>112</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>112</integer> +// CHECK: <key>col</key><integer>11</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>112</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>112</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>112</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>112</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>112</integer> +// CHECK: <key>col</key><integer>40</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Call to function 'CFCreateSomething' returns a Core Foundation object with a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>112</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>112</integer> +// CHECK: <key>col</key><integer>38</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>113</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>113</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>113</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>113</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>113</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>113</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>113</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object returned to caller as an owning reference (single retain count transferred to caller)</string> +// CHECK: <key>message</key> +// CHECK: <string>Object returned to caller as an owning reference (single retain count transferred to caller)</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>113</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>113</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>113</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'object' is returned from a function whose name ('CFGetRuleViolation') does not contain 'Copy' or 'Create'. This violates the naming convention rules given in the Memory Management Guide for Core Foundation</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'object' is returned from a function whose name ('CFGetRuleViolation') does not contain 'Copy' or 'Create'. This violates the naming convention rules given in the Memory Management Guide for Core Foundation</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak of an object stored into 'object'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak of returned object</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>CFGetRuleViolation</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>113</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>32</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>32</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Property returns an Objective-C object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Property returns an Objective-C object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>118</integer> +// CHECK: <key>col</key><integer>32</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object returned to caller with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Object returned to caller with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: <key>message</key> +// CHECK: <string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Method should return an owned object</string> +// CHECK: <key>issue_context_kind</key><string>Objective-C method</string> +// CHECK: <key>issue_context</key><string>copyViolation</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>119</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Subscript returns an Objective-C object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Subscript returns an Objective-C object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>123</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>124</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>124</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>124</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>124</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>124</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>124</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>124</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object returned to caller with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Object returned to caller with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>124</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>124</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>124</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: <key>message</key> +// CHECK: <string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Method should return an owned object</string> +// CHECK: <key>issue_context_kind</key><string>Objective-C method</string> +// CHECK: <key>issue_context</key><string>copyViolationIndexedSubscript</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>124</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Subscript returns an Objective-C object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Subscript returns an Objective-C object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>128</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>129</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>129</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>129</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>129</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>129</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>129</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>129</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object returned to caller with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Object returned to caller with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>129</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>129</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>129</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: <key>message</key> +// CHECK: <string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Method should return an owned object</string> +// CHECK: <key>issue_context_kind</key><string>Objective-C method</string> +// CHECK: <key>issue_context</key><string>copyViolationKeyedSubscript</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>129</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>133</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>133</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>133</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>133</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>133</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>133</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>133</integer> +// CHECK: <key>col</key><integer>32</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>133</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>133</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object returned to caller as an owning reference (single retain count transferred to caller)</string> +// CHECK: <key>message</key> +// CHECK: <string>Object returned to caller as an owning reference (single retain count transferred to caller)</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'result' is returned from a method whose name ('getViolation') does not start with 'copy', 'mutableCopy', 'alloc' or 'new'. This violates the naming convention rules given in the Memory Management Guide for Cocoa</string> +// CHECK: <key>message</key> +// CHECK: <string>Object leaked: object allocated and stored into 'result' is returned from a method whose name ('getViolation') does not start with 'copy', 'mutableCopy', 'alloc' or 'new'. This violates the naming convention rules given in the Memory Management Guide for Cocoa</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Potential leak of an object stored into 'result'</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Leak of returned object</string> +// CHECK: <key>issue_context_kind</key><string>Objective-C method</string> +// CHECK: <key>issue_context</key><string>getViolation</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>134</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>138</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>138</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>138</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>138</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>138</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>138</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>138</integer> +// CHECK: <key>col</key><integer>32</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Method returns an Objective-C object with a +1 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>138</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>138</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>139</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>139</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>139</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>139</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>139</integer> +// CHECK: <key>col</key><integer>22</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>139</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>139</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object sent -autorelease message</string> +// CHECK: <key>message</key> +// CHECK: <string>Object sent -autorelease message</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>139</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>139</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>8</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>10</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object returned to caller with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>Object returned to caller with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: <key>message</key> +// CHECK: <string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Object with a +0 retain count returned to caller where a +1 (owning) retain count is expected</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Method should return an owned object</string> +// CHECK: <key>issue_context_kind</key><string>Objective-C method</string> +// CHECK: <key>issue_context</key><string>copyAutorelease</string> +// CHECK: <key>issue_hash</key><integer>3</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>140</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>16</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>NSNumber literal is an object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>NSNumber literal is an object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>168</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>169</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>169</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>169</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>169</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>169</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Bad release</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>testNumericLiteral</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>169</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>173</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>173</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>173</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>173</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>173</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>173</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>173</integer> +// CHECK: <key>col</key><integer>18</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>NSNumber boxed expression produces an object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>NSNumber boxed expression produces an object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>173</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>173</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>174</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>174</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>174</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>174</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>174</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Bad release</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>testBoxedInt</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>174</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>178</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>178</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>178</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>178</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>178</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>178</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>178</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>NSString boxed expression produces an object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>NSString boxed expression produces an object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>178</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>178</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>179</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>179</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>179</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>179</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>179</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Bad release</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>testBoxedString</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>179</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>183</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>183</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>183</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>183</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>183</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>183</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>183</integer> +// CHECK: <key>col</key><integer>20</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>NSArray literal is an object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>NSArray literal is an object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>183</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>183</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>184</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>184</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>184</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>184</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>184</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Bad release</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>testArray</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>184</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>path</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>188</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>188</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>188</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>188</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>188</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>188</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>188</integer> +// CHECK: <key>col</key><integer>27</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>NSDictionary literal is an object with a +0 retain count</string> +// CHECK: <key>message</key> +// CHECK: <string>NSDictionary literal is an object with a +0 retain count</string> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>control</string> +// CHECK: <key>edges</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>start</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>188</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>188</integer> +// CHECK: <key>col</key><integer>15</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>end</key> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>189</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>189</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>kind</key><string>event</string> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>189</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <key>ranges</key> +// CHECK: <array> +// CHECK: <array> +// CHECK: <dict> +// CHECK: <key>line</key><integer>189</integer> +// CHECK: <key>col</key><integer>4</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: <dict> +// CHECK: <key>line</key><integer>189</integer> +// CHECK: <key>col</key><integer>9</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </array> +// CHECK: <key>depth</key><integer>0</integer> +// CHECK: <key>extended_message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>message</key> +// CHECK: <string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: </dict> +// CHECK: </array> +// CHECK: <key>description</key><string>Incorrect decrement of the reference count of an object that is not owned at this point by the caller</string> +// CHECK: <key>category</key><string>Memory (Core Foundation/Objective-C)</string> +// CHECK: <key>type</key><string>Bad release</string> +// CHECK: <key>issue_context_kind</key><string>function</string> +// CHECK: <key>issue_context</key><string>testDictionary</string> +// CHECK: <key>issue_hash</key><integer>2</integer> +// CHECK: <key>location</key> +// CHECK: <dict> +// CHECK: <key>line</key><integer>189</integer> +// CHECK: <key>col</key><integer>3</integer> +// CHECK: <key>file</key><integer>0</integer> +// CHECK: </dict> +// CHECK: </dict> +// CHECK: </array> +// CHECK: </dict> +// CHECK: </plist> diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index 06c510e5dd3e..ba492b7b19a7 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -142,9 +142,13 @@ NSFastEnumerationState; @end @class NSString, NSDictionary; @interface NSValue : NSObject <NSCopying, NSCoding> - (void)getValue:(void *)value; -@end @interface NSNumber : NSValue - (char)charValue; +@end +@interface NSNumber : NSValue +- (char)charValue; - (id)initWithInt:(int)value; -@end @class NSString; ++ (NSNumber *)numberWithInt:(int)value; +@end +@class NSString; @interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> - (NSUInteger)count; - (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt; @@ -195,7 +199,7 @@ typedef struct IONotificationPort * IONotificationPortRef; typedef void (*IOServiceMatchingCallback)( void * refcon, io_iterator_t iterator ); io_service_t IOServiceGetMatchingService( mach_port_t masterPort, CFDictionaryRef matching ); kern_return_t IOServiceGetMatchingServices( mach_port_t masterPort, CFDictionaryRef matching, io_iterator_t * existing ); -kern_return_t IOServiceAddNotification( mach_port_t masterPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated)); +kern_return_t IOServiceAddNotification( mach_port_t masterPort, const io_name_t notificationType, CFDictionaryRef matching, mach_port_t wakePort, uintptr_t reference, io_iterator_t * notification ) __attribute__((deprecated)); // expected-note {{'IOServiceAddNotification' declared here}} kern_return_t IOServiceAddMatchingNotification( IONotificationPortRef notifyPort, const io_name_t notificationType, CFDictionaryRef matching, IOServiceMatchingCallback callback, void * refCon, io_iterator_t * notification ); CFMutableDictionaryRef IOServiceMatching( const char * name ); CFMutableDictionaryRef IOServiceNameMatching( const char * name ); @@ -222,8 +226,10 @@ typedef struct CGLayer *CGLayerRef; @end @protocol NSValidatedUserInterfaceItem - (SEL)action; @end @protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem; @end @class NSDate, NSDictionary, NSError, NSException, NSNotification; +@class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; @interface NSApplication : NSResponder <NSUserInterfaceValidations> { } +- (void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)docWindow modalDelegate:(id)modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo; @end enum { NSTerminateCancel = 0, NSTerminateNow = 1, NSTerminateLater = 2 }; typedef NSUInteger NSApplicationTerminateReply; @@ -231,7 +237,7 @@ typedef NSUInteger NSApplicationTerminateReply; @end @class NSAttributedString, NSEvent, NSFont, NSFormatter, NSImage, NSMenu, NSText, NSView, NSTextView; @interface NSCell : NSObject <NSCopying, NSCoding> { } -@end @class NSTextField, NSPanel, NSArray, NSWindow, NSImage, NSButton, NSError; +@end typedef struct { } CVTimeStamp; @@ -294,6 +300,9 @@ extern CGColorSpaceRef CGColorSpaceCreateDeviceRGB(void); + (id)array; @end +// This is how NSMakeCollectable is declared in the OS X 10.8 headers. +id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained)); + //===----------------------------------------------------------------------===// // Test cases. @@ -747,7 +756,7 @@ typedef CFTypeRef OtherRef; @end //===----------------------------------------------------------------------===// -//<rdar://problem/6320065> false positive - init method returns an object +// <rdar://problem/6320065> false positive - init method returns an object // owned by caller //===----------------------------------------------------------------------===// @@ -1055,10 +1064,14 @@ typedef struct _opaque_pthread_t *__darwin_pthread_t; typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t; typedef __darwin_pthread_t pthread_t; typedef __darwin_pthread_attr_t pthread_attr_t; +typedef unsigned long __darwin_pthread_key_t; +typedef __darwin_pthread_key_t pthread_key_t; int pthread_create(pthread_t *, const pthread_attr_t *, void *(*)(void *), void *); +int pthread_setspecific(pthread_key_t key, const void *value); + void *rdar_7299394_start_routine(void *p) { [((id) p) release]; return 0; @@ -1072,6 +1085,16 @@ void rdar_7299394_positive(pthread_attr_t *attr, pthread_t *thread) { } //===----------------------------------------------------------------------===// +// <rdar://problem/11282706> false positive with not understanding thread +// local storage +//===----------------------------------------------------------------------===// + +void rdar11282706(pthread_key_t key) { + NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning + pthread_setspecific(key, (void*) number); +} + +//===----------------------------------------------------------------------===// // <rdar://problem/7283567> False leak associated with call to // CVPixelBufferCreateWithBytes () // @@ -1291,6 +1314,11 @@ void testattr2_b() { TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // expected-warning{{leak}} } +void testattr2_b_11358224_self_assign_looses_the_leak() { + TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit];// expected-warning{{leak}} + x = x; +} + void testattr2_c() { TestOwnershipAttr *x = [[TestOwnershipAttr alloc] pseudoInit]; // no-warning [x release]; @@ -1427,8 +1455,7 @@ void test_blocks_1_indirect_release_via_call(void) { } void test_blocks_1_indirect_retain_via_call(void) { - // Eventually this should be reported as a leak. - NSNumber *number = [[NSNumber alloc] initWithInt:5]; // no-warning + NSNumber *number = [[NSNumber alloc] initWithInt:5]; // expected-warning {{leak}} ^(NSObject *o){ [o retain]; }(number); } @@ -1667,6 +1694,58 @@ void rdar_10824732() { } } +// Stop tracking objects passed to functions, which take callbacks as parameters. +// radar://10973977 +typedef int (*CloseCallback) (void *); +void ReaderForIO(CloseCallback ioclose, void *ioctx); +int IOClose(void *context); + +@protocol SInS <NSObject> +@end + +@interface radar10973977 : NSObject +- (id<SInS>)inputS; +- (void)reader; +@end + +@implementation radar10973977 +- (void)reader +{ + id<SInS> inputS = [[self inputS] retain]; + ReaderForIO(IOClose, inputS); +} +- (id<SInS>)inputS +{ + return 0; +} +@end + +// Object escapes through a selector callback: radar://11398514 +extern id NSApp; +@interface MySheetController +- (id<SInS>)inputS; +- (void)showDoSomethingSheetAction:(id)action; +- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo; +@end + +@implementation MySheetController +- (id<SInS>)inputS { + return 0; +} +- (void)showDoSomethingSheetAction:(id)action { + id<SInS> inputS = [[self inputS] retain]; + [NSApp beginSheet:0 + modalForWindow:0 + modalDelegate:0 + didEndSelector:@selector(sheetDidEnd:returnCode:contextInfo:) + contextInfo:(void *)inputS]; // no - warning +} +- (void)sheetDidEnd:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo { + + id contextObject = (id)contextInfo; + [contextObject release]; +} +@end //===----------------------------------------------------------------------===// // Test returning allocated memory in a struct. // @@ -1739,3 +1818,40 @@ void test_objc_arrays() { } } +void test_objc_integer_literals() { + id value = [@1 retain]; // expected-warning {{leak}} + [value description]; +} + +void test_objc_boxed_expressions(int x, const char *y) { + id value = [@(x) retain]; // expected-warning {{leak}} + [value description]; + + value = [@(y) retain]; // expected-warning {{leak}} + [value description]; +} + +// Test NSLog doesn't escape tracked objects. +void rdar11400885(int y) +{ + @autoreleasepool { + NSString *printString; + if(y > 2) + printString = [[NSString alloc] init]; + else + printString = [[NSString alloc] init]; + NSLog(@"Once %@", printString); + [printString release]; + NSLog(@"Again: %@", printString); // expected-warning {{Reference-counted object is used after it is released}} + } +} + +id makeCollectableNonLeak() { + extern CFTypeRef CFCreateSomething(); + + CFTypeRef object = CFCreateSomething(); // +1 + CFRetain(object); // +2 + id objCObject = NSMakeCollectable(object); // +2 + [objCObject release]; // +1 + return [objCObject autorelease]; // +0 +} diff --git a/test/Analysis/self-init.m b/test/Analysis/self-init.m index d5151733430d..b0c51a2b37e1 100644 --- a/test/Analysis/self-init.m +++ b/test/Analysis/self-init.m @@ -1,7 +1,9 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties %s -verify +// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties -analyzer-ipa=dynamic -fno-builtin %s -verify +// RUN: %clang_cc1 -analyze -analyzer-checker=osx.cocoa.SelfInit -fobjc-default-synthesize-properties -fno-builtin %s -verify @class NSZone, NSCoder; -@protocol NSObject- (id)self; +@protocol NSObject +- (id)self; @end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end @@ -254,3 +256,28 @@ extern id _commonInit(MyObj *self); return self; } @end + +// Test for radar://11125870: init constructing a special instance. +typedef signed char BOOL; +@interface MyClass : NSObject +@end +@implementation MyClass ++ (id)specialInstance { + return [[MyClass alloc] init]; +} +- (id)initSpecially:(BOOL)handleSpecially { + if ((self = [super init])) { + if (handleSpecially) { + self = [MyClass specialInstance]; + } + } + return self; +} +- (id)initSelfSelf { + if ((self = [super init])) { + self = self; + } + return self; +} +@end + diff --git a/test/Analysis/stack-addr-ps.cpp b/test/Analysis/stack-addr-ps.cpp index b09e43560830..b21a03dc38a4 100644 --- a/test/Analysis/stack-addr-ps.cpp +++ b/test/Analysis/stack-addr-ps.cpp @@ -84,3 +84,9 @@ struct TS { return x; } }; + +// rdar://11345441 +int* f5() { + int& i = i; // expected-warning {{Assigned value is garbage or undefined}} expected-note {{binding reference variable 'i' here}} + return &i; // expected-warning {{address of stack memory associated with local variable 'i' returned}} +} diff --git a/test/Analysis/string-fail.c b/test/Analysis/string-fail.c index 3bff6d40dd51..ac5c6d057235 100644 --- a/test/Analysis/string-fail.c +++ b/test/Analysis/string-fail.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,experimental.unix.CString,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,debug.ExprInspection -analyzer-store=region -verify %s // XFAIL: * // This file is for tests that may eventually go into string.c, or may be @@ -32,6 +32,7 @@ #define NULL 0 typedef typeof(sizeof(int)) size_t; +void clang_analyzer_eval(int); //===----------------------------------------------------------------------=== // strnlen() @@ -43,8 +44,7 @@ size_t strnlen(const char *s, size_t maxlen); void strnlen_liveness(const char *x) { if (strnlen(x, 10) < 5) return; - if (strnlen(x, 10) < 5) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strnlen(x, 10) < 5); // expected-warning{{FALSE}} } void strnlen_subregion() { @@ -57,43 +57,43 @@ void strnlen_subregion() { size_t a = strnlen(z.a, 10); z.b[0] = 5; size_t b = strnlen(z.a, 10); - if (a == 0 && b != 0) - (void)*(char*)0; // expected-warning{{never executed}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} use_two_stringsn(&z); size_t c = strnlen(z.a, 10); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } extern void use_stringn(char *); void strnlen_argument(char *x) { size_t a = strnlen(x, 10); size_t b = strnlen(x, 10); - if (a == 0 && b != 0) - (void)*(char*)0; // expected-warning{{never executed}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} use_stringn(x); size_t c = strnlen(x, 10); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } extern char global_strn[]; void strnlen_global() { size_t a = strnlen(global_strn, 10); size_t b = strnlen(global_strn, 10); - if (a == 0 && b != 0) - (void)*(char*)0; // expected-warning{{never executed}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} // Call a function with unknown effects, which should invalidate globals. use_stringn(0); size_t c = strnlen(global_strn, 10); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } void strnlen_indirect(char *x) { @@ -101,13 +101,13 @@ void strnlen_indirect(char *x) { char *p = x; char **p2 = &p; size_t b = strnlen(x, 10); - if (a == 0 && b != 0) - (void)*(char*)0; // expected-warning{{never executed}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} extern void use_stringn_ptr(char*const*); use_stringn_ptr(p2); size_t c = strnlen(x, 10); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } diff --git a/test/Analysis/string.c b/test/Analysis/string.c index c0814b89c17c..32f5db3a9a43 100644 --- a/test/Analysis/string.c +++ b/test/Analysis/string.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s -// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s -// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=experimental.security.taint,core,unix.cstring,experimental.unix.cstring,experimental.deadcode.UnreachableCode -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_cc1 -analyze -DVARIANT -analyzer-checker=core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s +// RUN: %clang_cc1 -analyze -DUSE_BUILTINS -DVARIANT -analyzer-checker=experimental.security.taint,core,unix.cstring,experimental.unix.cstring,debug.ExprInspection -analyzer-store=region -Wno-null-dereference -verify %s //===----------------------------------------------------------------------=== // Declarations @@ -26,6 +26,9 @@ #define NULL 0 typedef typeof(sizeof(int)) size_t; + +void clang_analyzer_eval(int); + int scanf(const char *restrict format, ...); //===----------------------------------------------------------------------=== @@ -36,23 +39,20 @@ int scanf(const char *restrict format, ...); size_t strlen(const char *s); void strlen_constant0() { - if (strlen("123") != 3) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen("123") == 3); // expected-warning{{TRUE}} } void strlen_constant1() { const char *a = "123"; - if (strlen(a) != 3) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(a) == 3); // expected-warning{{TRUE}} } void strlen_constant2(char x) { char a[] = "123"; - if (strlen(a) != 3) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(a) == 3); // expected-warning{{TRUE}} + a[0] = x; - if (strlen(a) != 3) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(strlen(a) == 3); // expected-warning{{UNKNOWN}} } size_t strlen_null() { @@ -78,43 +78,46 @@ void strlen_subregion() { size_t a = strlen(z.a); z.b[0] = 5; size_t b = strlen(z.a); - if (a == 0 && b != 0) - (void)*(char*)0; // expected-warning{{never executed}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} use_two_strings(&z); size_t c = strlen(z.a); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } extern void use_string(char *); void strlen_argument(char *x) { size_t a = strlen(x); size_t b = strlen(x); - if (a == 0 && b != 0) - (void)*(char*)0; // expected-warning{{never executed}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} use_string(x); size_t c = strlen(x); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } extern char global_str[]; void strlen_global() { size_t a = strlen(global_str); size_t b = strlen(global_str); - if (a == 0 && b != 0) - (void)*(char*)0; // expected-warning{{never executed}} + if (a == 0) { + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} + // Make sure clang_analyzer_eval does not invalidate globals. + clang_analyzer_eval(strlen(global_str) == 0); // expected-warning{{TRUE}} + } // Call a function with unknown effects, which should invalidate globals. use_string(0); size_t c = strlen(global_str); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } void strlen_indirect(char *x) { @@ -122,15 +125,15 @@ void strlen_indirect(char *x) { char *p = x; char **p2 = &p; size_t b = strlen(x); - if (a == 0 && b != 0) - (void)*(char*)0; // expected-warning{{never executed}} + if (a == 0) + clang_analyzer_eval(b == 0); // expected-warning{{TRUE}} extern void use_string_ptr(char*const*); use_string_ptr(p2); size_t c = strlen(x); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } void strlen_indirect2(char *x) { @@ -141,15 +144,14 @@ void strlen_indirect2(char *x) { use_string_ptr2(p2); size_t c = strlen(x); - if (a == 0 && c != 0) - (void)*(char*)0; // expected-warning{{null}} + if (a == 0) + clang_analyzer_eval(c == 0); // expected-warning{{UNKNOWN}} } void strlen_liveness(const char *x) { if (strlen(x) < 5) return; - if (strlen(x) < 5) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(x) < 5); // expected-warning{{FALSE}} } //===----------------------------------------------------------------------=== @@ -159,43 +161,35 @@ void strlen_liveness(const char *x) { size_t strnlen(const char *s, size_t maxlen); void strnlen_constant0() { - if (strnlen("123", 10) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen("123", 10) == 3); // expected-warning{{TRUE}} } void strnlen_constant1() { const char *a = "123"; - if (strnlen(a, 10) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen(a, 10) == 3); // expected-warning{{TRUE}} } void strnlen_constant2(char x) { char a[] = "123"; - if (strnlen(a, 10) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen(a, 10) == 3); // expected-warning{{TRUE}} a[0] = x; - if (strnlen(a, 10) != 3) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(strnlen(a, 10) == 3); // expected-warning{{UNKNOWN}} } void strnlen_constant4() { - if (strnlen("123456", 3) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen("123456", 3) == 3); // expected-warning{{TRUE}} } void strnlen_constant5() { const char *a = "123456"; - if (strnlen(a, 3) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen(a, 3) == 3); // expected-warning{{TRUE}} } void strnlen_constant6(char x) { char a[] = "123456"; - if (strnlen(a, 3) != 3) - (void)*(char*)0; // expected-warning{{never executed}} + clang_analyzer_eval(strnlen(a, 3) == 3); // expected-warning{{TRUE}} a[0] = x; - if (strnlen(a, 3) != 3) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(strnlen(a, 3) == 3); // expected-warning{{UNKNOWN}} } size_t strnlen_null() { @@ -212,10 +206,8 @@ label: } void strnlen_zero() { - if (strnlen("abc", 0) != 0) - (void)*(char*)0; // expected-warning{{never executed}} - if (strnlen(NULL, 0) != 0) // no-warning - (void)*(char*)0; // no-warning + clang_analyzer_eval(strnlen("abc", 0) == 0); // expected-warning{{TRUE}} + clang_analyzer_eval(strnlen(NULL, 0) == 0); // expected-warning{{TRUE}} } size_t strnlen_compound_literal() { @@ -230,40 +222,26 @@ size_t strnlen_unknown_limit(float f) { } void strnlen_is_not_strlen(char *x) { - if (strnlen(x, 10) != strlen(x)) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(strnlen(x, 10) == strlen(x)); // expected-warning{{UNKNOWN}} } void strnlen_at_limit(char *x) { size_t len = strnlen(x, 10); - if (len > 10) - (void)*(char*)0; // expected-warning{{never executed}} - if (len == 10) - (void)*(char*)0; // expected-warning{{null}} -} - -void strnlen_less_than_limit(char *x) { - size_t len = strnlen(x, 10); - if (len > 10) - (void)*(char*)0; // expected-warning{{never executed}} - if (len < 10) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(len <= 10); // expected-warning{{TRUE}} + clang_analyzer_eval(len == 10); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(len < 10); // expected-warning{{UNKNOWN}} } void strnlen_at_actual(size_t limit) { size_t len = strnlen("abc", limit); - if (len > 3) - (void)*(char*)0; // expected-warning{{never executed}} - if (len == 3) - (void)*(char*)0; // expected-warning{{null}} -} - -void strnlen_less_than_actual(size_t limit) { - size_t len = strnlen("abc", limit); - if (len > 3) - (void)*(char*)0; // expected-warning{{never executed}} - if (len < 3) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(len <= 3); // expected-warning{{TRUE}} + // This is due to eager assertion in strnlen. + if (limit == 0) { + clang_analyzer_eval(len == 0); // expected-warning{{TRUE}} + } else { + clang_analyzer_eval(len == 3); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(len < 3); // expected-warning{{UNKNOWN}} + } } //===----------------------------------------------------------------------=== @@ -304,14 +282,9 @@ void strcpy_fn_const(char *x) { void strcpy_effects(char *x, char *y) { char a = x[0]; - if (strcpy(x, y) != x) - (void)*(char*)0; // no-warning - - if (strlen(x) != strlen(y)) - (void)*(char*)0; // no-warning - - if (a != x[0]) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(strcpy(x, y) == x); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(x) == strlen(y)); // expected-warning{{TRUE}} + clang_analyzer_eval(a == x[0]); // expected-warning{{UNKNOWN}} } void strcpy_overflow(char *y) { @@ -348,14 +321,9 @@ char *stpcpy(char *restrict s1, const char *restrict s2); void stpcpy_effect(char *x, char *y) { char a = x[0]; - if (stpcpy(x, y) != &x[strlen(y)]) - (void)*(char*)0; // no-warning - - if (strlen(x) != strlen(y)) - (void)*(char*)0; // no-warning - - if (a != x[0]) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(stpcpy(x, y) == &x[strlen(y)]); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(x) == strlen(y)); // expected-warning{{TRUE}} + clang_analyzer_eval(a == x[0]); // expected-warning{{UNKNOWN}} } void stpcpy_overflow(char *y) { @@ -409,11 +377,8 @@ void strcat_effects(char *y) { if (strlen(y) != 4) return; - if (strcat(x, y) != x) - (void)*(char*)0; // no-warning - - if ((int)strlen(x) != (orig_len + strlen(y))) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcat(x, y) == x); // expected-warning{{TRUE}} + clang_analyzer_eval((int)strlen(x) == (orig_len + strlen(y))); // expected-warning{{TRUE}} } void strcat_overflow_0(char *y) { @@ -442,29 +407,25 @@ void strcat_no_overflow(char *y) { void strcat_symbolic_dst_length(char *dst) { strcat(dst, "1234"); - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} } void strcat_symbolic_src_length(char *src) { char dst[8] = "1234"; strcat(dst, src); - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} } void strcat_symbolic_dst_length_taint(char *dst) { scanf("%s", dst); // Taint data. strcat(dst, "1234"); - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} } void strcat_unknown_src_length(char *src, int offset) { char dst[8] = "1234"; strcat(dst, &src[offset]); - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} } // There is no strcat_unknown_dst_length because if we can't get a symbolic @@ -513,14 +474,9 @@ void strncpy_fn(char *x) { void strncpy_effects(char *x, char *y) { char a = x[0]; - if (strncpy(x, y, 5) != x) - (void)*(char*)0; // no-warning - - if (strlen(x) != strlen(y)) - (void)*(char*)0; // expected-warning{{null}} - - if (a != x[0]) - (void)*(char*)0; // expected-warning{{null}} + clang_analyzer_eval(strncpy(x, y, 5) == x); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(x) == strlen(y)); // expected-warning{{UNKNOWN}} + clang_analyzer_eval(a == x[0]); // expected-warning{{UNKNOWN}} } void strncpy_overflow(char *y) { @@ -562,8 +518,7 @@ void strncpy_exactly_matching_buffer(char *y) { // strncpy does not null-terminate, so we have no idea what the strlen is // after this. - if (strlen(x) > 4) - (void)*(int*)0; // expected-warning{{null}} + clang_analyzer_eval(strlen(x) > 4); // expected-warning{{UNKNOWN}} } void strncpy_exactly_matching_buffer2(char *y) { @@ -574,8 +529,18 @@ void strncpy_exactly_matching_buffer2(char *y) { strncpy(x, y, 4); // no-warning // This time, we know that y fits in x anyway. - if (strlen(x) > 3) - (void)*(int*)0; // no-warning + clang_analyzer_eval(strlen(x) <= 3); // expected-warning{{TRUE}} +} + +void strncpy_zero(char *src) { + char dst[] = "123"; + strncpy(dst, src, 0); // no-warning +} + +void strncpy_empty() { + char dst[] = "123"; + char src[] = ""; + strncpy(dst, src, 4); // no-warning } //===----------------------------------------------------------------------=== @@ -617,11 +582,8 @@ void strncat_effects(char *y) { if (strlen(y) != 4) return; - if (strncat(x, y, strlen(y)) != x) - (void)*(char*)0; // no-warning - - if (strlen(x) != orig_len + strlen(y)) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncat(x, y, strlen(y)) == x); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(x) == (orig_len + strlen(y))); // expected-warning{{TRUE}} } void strncat_overflow_0(char *y) { @@ -661,15 +623,13 @@ void strncat_no_overflow_2(char *y) { void strncat_symbolic_dst_length(char *dst) { strncat(dst, "1234", 5); - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} } void strncat_symbolic_src_length(char *src) { char dst[8] = "1234"; strncat(dst, src, 3); - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} char dst2[8] = "1234"; strncat(dst2, src, 4); // expected-warning{{Size argument is greater than the free space in the destination buffer}} @@ -678,8 +638,7 @@ void strncat_symbolic_src_length(char *src) { void strncat_unknown_src_length(char *src, int offset) { char dst[8] = "1234"; strncat(dst, &src[offset], 3); - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} char dst2[8] = "1234"; strncat(dst2, &src[offset], 4); // expected-warning{{Size argument is greater than the free space in the destination buffer}} @@ -692,20 +651,18 @@ void strncat_symbolic_limit(unsigned limit) { char dst[6] = "1234"; char src[] = "567"; strncat(dst, src, limit); // no-warning - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning - if (strlen(dst) == 4) - (void)*(char*)0; // expected-warning{{null}} + + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(dst) == 4); // expected-warning{{UNKNOWN}} } void strncat_unknown_limit(float limit) { char dst[6] = "1234"; char src[] = "567"; strncat(dst, src, (size_t)limit); // no-warning - if (strlen(dst) < 4) - (void)*(char*)0; // no-warning - if (strlen(dst) == 4) - (void)*(char*)0; // expected-warning{{null}} + + clang_analyzer_eval(strlen(dst) >= 4); // expected-warning{{TRUE}} + clang_analyzer_eval(strlen(dst) == 4); // expected-warning{{UNKNOWN}} } void strncat_too_big(char *dst, char *src) { @@ -716,6 +673,17 @@ void strncat_too_big(char *dst, char *src) { strncat(dst, src, 2); // expected-warning{{This expression will create a string whose length is too big to be represented as a size_t}} } +void strncat_zero(char *src) { + char dst[] = "123"; + strncat(dst, src, 0); // no-warning +} + +void strncat_empty() { + char dst[8] = "123"; + char src[] = ""; + strncat(dst, src, 4); // no-warning +} + //===----------------------------------------------------------------------=== // strcmp() //===----------------------------------------------------------------------=== @@ -724,41 +692,35 @@ void strncat_too_big(char *dst, char *src) { int strcmp(const char * s1, const char * s2); void strcmp_constant0() { - if (strcmp("123", "123") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp("123", "123") == 0); // expected-warning{{TRUE}} } void strcmp_constant_and_var_0() { char *x = "123"; - if (strcmp(x, "123") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, "123") == 0); // expected-warning{{TRUE}} } void strcmp_constant_and_var_1() { char *x = "123"; - if (strcmp("123", x) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp("123", x) == 0); // expected-warning{{TRUE}} } void strcmp_0() { char *x = "123"; char *y = "123"; - if (strcmp(x, y) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == 0); // expected-warning{{TRUE}} } void strcmp_1() { char *x = "234"; char *y = "123"; - if (strcmp(x, y) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == 1); // expected-warning{{TRUE}} } void strcmp_2() { char *x = "123"; char *y = "234"; - if (strcmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}} } void strcmp_null_0() { @@ -776,39 +738,33 @@ void strcmp_null_1() { void strcmp_diff_length_0() { char *x = "12345"; char *y = "234"; - if (strcmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}} } void strcmp_diff_length_1() { char *x = "123"; char *y = "23456"; - if (strcmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}} } void strcmp_diff_length_2() { char *x = "12345"; char *y = "123"; - if (strcmp(x, y) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == 1); // expected-warning{{TRUE}} } void strcmp_diff_length_3() { char *x = "123"; char *y = "12345"; - if (strcmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(x, y) == -1); // expected-warning{{TRUE}} } void strcmp_embedded_null () { - if (strcmp("\0z", "\0y") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp("\0z", "\0y") == 0); // expected-warning{{TRUE}} } void strcmp_unknown_arg (char *unknown) { - if (strcmp(unknown, unknown) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcmp(unknown, unknown) == 0); // expected-warning{{TRUE}} } //===----------------------------------------------------------------------=== @@ -819,41 +775,35 @@ void strcmp_unknown_arg (char *unknown) { int strncmp(const char *s1, const char *s2, size_t n); void strncmp_constant0() { - if (strncmp("123", "123", 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp("123", "123", 3) == 0); // expected-warning{{TRUE}} } void strncmp_constant_and_var_0() { char *x = "123"; - if (strncmp(x, "123", 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, "123", 3) == 0); // expected-warning{{TRUE}} } void strncmp_constant_and_var_1() { char *x = "123"; - if (strncmp("123", x, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp("123", x, 3) == 0); // expected-warning{{TRUE}} } void strncmp_0() { char *x = "123"; char *y = "123"; - if (strncmp(x, y, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == 0); // expected-warning{{TRUE}} } void strncmp_1() { char *x = "234"; char *y = "123"; - if (strncmp(x, y, 3) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == 1); // expected-warning{{TRUE}} } void strncmp_2() { char *x = "123"; char *y = "234"; - if (strncmp(x, y, 3) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == -1); // expected-warning{{TRUE}} } void strncmp_null_0() { @@ -871,55 +821,47 @@ void strncmp_null_1() { void strncmp_diff_length_0() { char *x = "12345"; char *y = "234"; - if (strncmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncmp_diff_length_1() { char *x = "123"; char *y = "23456"; - if (strncmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncmp_diff_length_2() { char *x = "12345"; char *y = "123"; - if (strncmp(x, y, 5) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 5) == 1); // expected-warning{{TRUE}} } void strncmp_diff_length_3() { char *x = "123"; char *y = "12345"; - if (strncmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncmp_diff_length_4() { char *x = "123"; char *y = "12345"; - if (strncmp(x, y, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == 0); // expected-warning{{TRUE}} } void strncmp_diff_length_5() { char *x = "012"; char *y = "12345"; - if (strncmp(x, y, 3) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == -1); // expected-warning{{TRUE}} } void strncmp_diff_length_6() { char *x = "234"; char *y = "12345"; - if (strncmp(x, y, 3) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp(x, y, 3) == 1); // expected-warning{{TRUE}} } void strncmp_embedded_null () { - if (strncmp("ab\0zz", "ab\0yy", 4) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncmp("ab\0zz", "ab\0yy", 4) == 0); // expected-warning{{TRUE}} } //===----------------------------------------------------------------------=== @@ -930,41 +872,35 @@ void strncmp_embedded_null () { int strcasecmp(const char *s1, const char *s2); void strcasecmp_constant0() { - if (strcasecmp("abc", "Abc") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp("abc", "Abc") == 0); // expected-warning{{TRUE}} } void strcasecmp_constant_and_var_0() { char *x = "abc"; - if (strcasecmp(x, "Abc") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, "Abc") == 0); // expected-warning{{TRUE}} } void strcasecmp_constant_and_var_1() { char *x = "abc"; - if (strcasecmp("Abc", x) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp("Abc", x) == 0); // expected-warning{{TRUE}} } void strcasecmp_0() { char *x = "abc"; char *y = "Abc"; - if (strcasecmp(x, y) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == 0); // expected-warning{{TRUE}} } void strcasecmp_1() { char *x = "Bcd"; char *y = "abc"; - if (strcasecmp(x, y) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == 1); // expected-warning{{TRUE}} } void strcasecmp_2() { char *x = "abc"; char *y = "Bcd"; - if (strcasecmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}} } void strcasecmp_null_0() { @@ -982,34 +918,29 @@ void strcasecmp_null_1() { void strcasecmp_diff_length_0() { char *x = "abcde"; char *y = "aBd"; - if (strcasecmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}} } void strcasecmp_diff_length_1() { char *x = "abc"; char *y = "aBdef"; - if (strcasecmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}} } void strcasecmp_diff_length_2() { char *x = "aBcDe"; char *y = "abc"; - if (strcasecmp(x, y) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == 1); // expected-warning{{TRUE}} } void strcasecmp_diff_length_3() { char *x = "aBc"; char *y = "abcde"; - if (strcasecmp(x, y) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp(x, y) == -1); // expected-warning{{TRUE}} } void strcasecmp_embedded_null () { - if (strcasecmp("ab\0zz", "ab\0yy") != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strcasecmp("ab\0zz", "ab\0yy") == 0); // expected-warning{{TRUE}} } //===----------------------------------------------------------------------=== @@ -1020,41 +951,35 @@ void strcasecmp_embedded_null () { int strncasecmp(const char *s1, const char *s2, size_t n); void strncasecmp_constant0() { - if (strncasecmp("abc", "Abc", 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp("abc", "Abc", 3) == 0); // expected-warning{{TRUE}} } void strncasecmp_constant_and_var_0() { char *x = "abc"; - if (strncasecmp(x, "Abc", 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, "Abc", 3) == 0); // expected-warning{{TRUE}} } void strncasecmp_constant_and_var_1() { char *x = "abc"; - if (strncasecmp("Abc", x, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp("Abc", x, 3) == 0); // expected-warning{{TRUE}} } void strncasecmp_0() { char *x = "abc"; char *y = "Abc"; - if (strncasecmp(x, y, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == 0); // expected-warning{{TRUE}} } void strncasecmp_1() { char *x = "Bcd"; char *y = "abc"; - if (strncasecmp(x, y, 3) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == 1); // expected-warning{{TRUE}} } void strncasecmp_2() { char *x = "abc"; char *y = "Bcd"; - if (strncasecmp(x, y, 3) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == -1); // expected-warning{{TRUE}} } void strncasecmp_null_0() { @@ -1072,53 +997,45 @@ void strncasecmp_null_1() { void strncasecmp_diff_length_0() { char *x = "abcde"; char *y = "aBd"; - if (strncasecmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncasecmp_diff_length_1() { char *x = "abc"; char *y = "aBdef"; - if (strncasecmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncasecmp_diff_length_2() { char *x = "aBcDe"; char *y = "abc"; - if (strncasecmp(x, y, 5) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 5) == 1); // expected-warning{{TRUE}} } void strncasecmp_diff_length_3() { char *x = "aBc"; char *y = "abcde"; - if (strncasecmp(x, y, 5) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 5) == -1); // expected-warning{{TRUE}} } void strncasecmp_diff_length_4() { char *x = "abcde"; char *y = "aBc"; - if (strncasecmp(x, y, 3) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == 0); // expected-warning{{TRUE}} } void strncasecmp_diff_length_5() { char *x = "abcde"; char *y = "aBd"; - if (strncasecmp(x, y, 3) != -1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == -1); // expected-warning{{TRUE}} } void strncasecmp_diff_length_6() { char *x = "aBDe"; char *y = "abc"; - if (strncasecmp(x, y, 3) != 1) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp(x, y, 3) == 1); // expected-warning{{TRUE}} } void strncasecmp_embedded_null () { - if (strncasecmp("ab\0zz", "ab\0yy", 4) != 0) - (void)*(char*)0; // no-warning + clang_analyzer_eval(strncasecmp("ab\0zz", "ab\0yy", 4) == 0); // expected-warning{{TRUE}} } diff --git a/test/Analysis/svalbuilder-logic.c b/test/Analysis/svalbuilder-logic.c new file mode 100644 index 000000000000..bc79f859053c --- /dev/null +++ b/test/Analysis/svalbuilder-logic.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix -verify %s + +// Testing core functionality of the SValBuilder. + +int SValBuilderLogicNoCrash(int *x) { + return 3 - (int)(x +3); +} diff --git a/test/Analysis/system-header-simulator-objc.h b/test/Analysis/system-header-simulator-objc.h index 92d5899abf8d..a647b3740406 100644 --- a/test/Analysis/system-header-simulator-objc.h +++ b/test/Analysis/system-header-simulator-objc.h @@ -85,7 +85,13 @@ typedef double NSTimeInterval; - (id)initWithBytes:(const void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding; - (id)initWithBytesNoCopy:(void *)bytes length:(NSUInteger)len encoding:(NSStringEncoding)encoding freeWhenDone:(BOOL)freeBuffer; + (id)stringWithUTF8String:(const char *)nullTerminatedCString; ++ (id)stringWithString:(NSString *)string; @end @class NSString, NSURL, NSError; + +@interface NSMutableString : NSString +- (void)appendFormat:(NSString *)format, ... __attribute__((format(__NSString__, 1, 2))); +@end + @interface NSData : NSObject <NSCopying, NSMutableCopying, NSCoding> - (NSUInteger)length; + (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length; + (id)dataWithBytesNoCopy:(void *)bytes length:(NSUInteger)length freeWhenDone:(BOOL)b; @@ -112,3 +118,13 @@ extern void CFRelease(CFTypeRef cf); extern CFMutableStringRef CFStringCreateMutableWithExternalCharactersNoCopy(CFAllocatorRef alloc, UniChar *chars, CFIndex numChars, CFIndex capacity, CFAllocatorRef externalCharactersAllocator); extern CFStringRef CFStringCreateWithCStringNoCopy(CFAllocatorRef alloc, const char *cStr, CFStringEncoding encoding, CFAllocatorRef contentsDeallocator); extern void CFStringAppend(CFMutableStringRef theString, CFStringRef appendedString); + +void SystemHeaderFunctionWithBlockParam(void *, void (^block)(void *), unsigned); + +@interface NSPointerArray : NSObject <NSFastEnumeration, NSCopying, NSCoding> +- (void)addPointer:(void *)pointer; +- (void)insertPointer:(void *)item atIndex:(NSUInteger)index; +- (void)replacePointerAtIndex:(NSUInteger)index withPointer:(void *)item; +- (void *)pointerAtIndex:(NSUInteger)index; +@end + diff --git a/test/Analysis/system-header-simulator.h b/test/Analysis/system-header-simulator.h index 6212131071de..5790fb9cff4a 100644 --- a/test/Analysis/system-header-simulator.h +++ b/test/Analysis/system-header-simulator.h @@ -36,3 +36,27 @@ FILE *funopen(const void *, fpos_t (*)(void *, fpos_t, int), int (*)(void *)); +int sqlite3_bind_text_my(int, const char*, int n, void(*)(void*)); + +typedef void (*freeCallback) (void*); +typedef struct { + int i; + freeCallback fc; +} StWithCallback; + +int dealocateMemWhenDoneByVal(void*, StWithCallback); +int dealocateMemWhenDoneByRef(StWithCallback*, const void*); + +typedef struct CGContext *CGContextRef; +CGContextRef CGBitmapContextCreate(void *data/*, size_t width, size_t height, + size_t bitsPerComponent, size_t bytesPerRow, + CGColorSpaceRef space, + CGBitmapInfo bitmapInfo*/); +void *CGBitmapContextGetData(CGContextRef context); + +// Include xpc. +typedef struct _xpc_connection_s * xpc_connection_t; +typedef void (*xpc_finalizer_t)(void *value); +void xpc_connection_set_context(xpc_connection_t connection, void *context); +void xpc_connection_set_finalizer_f(xpc_connection_t connection, xpc_finalizer_t finalizer); +void xpc_connection_resume(xpc_connection_t connection); diff --git a/test/Analysis/taint-generic.c b/test/Analysis/taint-generic.c index b00372a3ffbd..8ee1896e96e9 100644 --- a/test/Analysis/taint-generic.c +++ b/test/Analysis/taint-generic.c @@ -183,3 +183,32 @@ void testTaintedVLASize() { scanf("%d", &x); int vla[x]; // expected-warning{{Declared variable-length array (VLA) has tainted size}} } + +// This computation used to take a very long time. +#define longcmp(a,b,c) { \ + a -= c; a ^= c; c += b; b -= a; b ^= (a<<6) | (a >> (32-b)); a += c; c -= b; c ^= b; b += a; \ + a -= c; a ^= c; c += b; b -= a; b ^= a; a += c; c -= b; c ^= b; b += a; } + +unsigned radar11369570_hanging(const unsigned char *arr, int l) { + unsigned a, b, c; + a = b = c = 0x9899e3 + l; + while (l >= 6) { + unsigned t; + scanf("%d", &t); + a += b; + a ^= a; + a += (arr[3] + ((unsigned) arr[2] << 8) + ((unsigned) arr[1] << 16) + ((unsigned) arr[0] << 24)); + longcmp(a, t, c); + l -= 12; + } + return 5/a; // expected-warning {{Division by a tainted value, possibly zero}} +} + +// Check that we do not assert of the following code. +int SymSymExprWithDiffTypes(void* p) { + int i; + scanf("%d", &i); + int j = (i % (int)(long)p); + return 5/j; // expected-warning {{Division by a tainted value, possibly zero}} +} + diff --git a/test/Analysis/taint-tester.c b/test/Analysis/taint-tester.c index 377333505e18..a83ee32baca8 100644 --- a/test/Analysis/taint-tester.c +++ b/test/Analysis/taint-tester.c @@ -40,7 +40,7 @@ void taintTracking(int x) { // FIXME: We fail to propagate the taint here because RegionStore does not // handle ElementRegions with symbolic indexes. int addrDeref = *addr; // expected-warning + {{tainted}} - int _addrDeref = addrDeref; + int _addrDeref = addrDeref; // expected-warning + {{tainted}} // Tainted struct address, casts. struct XYStruct *xyPtr = 0; diff --git a/test/Analysis/temp-obj-dtors-cfg-output.cpp b/test/Analysis/temp-obj-dtors-cfg-output.cpp index 53ab211615c3..6dbbc821bbbb 100644 --- a/test/Analysis/temp-obj-dtors-cfg-output.cpp +++ b/test/Analysis/temp-obj-dtors-cfg-output.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors -cfg-add-initializers %s 2>&1 | FileCheck %s +// RUN: rm -f %t +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG -cfg-add-implicit-dtors %s > %t 2>&1 +// RUN: FileCheck --input-file=%t %s // XPASS: * class A { @@ -106,9 +108,88 @@ TestCtorInits::TestCtorInits() : a(int(A()) + int(B())) , b() {} +// CHECK: [B1 (ENTRY)] +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 +// CHECK: [B1 (ENTRY)] +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 +// CHECK: [B2 (ENTRY)] +// CHECK: Succs (1): B1 +// CHECK: [B1] +// CHECK: 1: A() (CXXConstructExpr, class A) +// CHECK: 2: [B1.1] (BindTemporary) +// CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 4: [B1.3] +// CHECK: 5: [B1.4] (CXXConstructExpr, class A) +// CHECK: 6: ~A() (Temporary object destructor) +// CHECK: 7: return [B1.5]; +// CHECK: Preds (1): B2 +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 +// CHECK: [B2 (ENTRY)] +// CHECK: Succs (1): B1 +// CHECK: [B1] +// CHECK: 1: false +// CHECK: 2: return [B1.1]; +// CHECK: Preds (1): B2 +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 +// CHECK: [B2 (ENTRY)] +// CHECK: Succs (1): B1 +// CHECK: [B1] +// CHECK: 1: 0 +// CHECK: 2: return [B1.1]; +// CHECK: Preds (1): B2 +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 +// CHECK: [B1 (ENTRY)] +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 +// CHECK: [B1 (ENTRY)] +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 +// CHECK: [B2 (ENTRY)] +// CHECK: Succs (1): B1 +// CHECK: [B1] +// CHECK: 1: true +// CHECK: 2: return [B1.1]; +// CHECK: Preds (1): B2 +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 +// CHECK: [B2 (ENTRY)] +// CHECK: Succs (1): B1 +// CHECK: [B1] +// CHECK: 1: 1 +// CHECK: 2: return [B1.1]; +// CHECK: Preds (1): B2 +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 +// CHECK: [B2 (ENTRY)] +// CHECK: Succs (1): B1 +// CHECK: [B1] +// CHECK: 1: A() (CXXConstructExpr, class A) +// CHECK: 2: [B1.1] (BindTemporary) +// CHECK: 3: [B1.2] (ImplicitCastExpr, NoOp, const class A) +// CHECK: 4: [B1.3] +// CHECK: 5: [B1.4] (CXXConstructExpr, class A) +// CHECK: 6: ~A() (Temporary object destructor) +// CHECK: 7: return [B1.5]; +// CHECK: Preds (1): B2 +// CHECK: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK: Preds (1): B1 // CHECK: [B2 (ENTRY)] // CHECK: Succs (1): B1 - // CHECK: [B1] // CHECK: 1: A() (CXXConstructExpr, class A) // CHECK: 2: [B1.1] (BindTemporary) @@ -150,7 +231,7 @@ TestCtorInits::TestCtorInits() // CHECK: [B0 (EXIT)] // CHECK: Preds (1): B1 // CHECK: [B10 (ENTRY)] -// CHECK: Succs (1): B8 +// CHECK: Succs (1): B9 // CHECK: [B1] // CHECK: 1: ~A() (Temporary object destructor) // CHECK: 2: int b; @@ -161,62 +242,62 @@ TestCtorInits::TestCtorInits() // CHECK: Preds (1): B3 // CHECK: Succs (1): B1 // CHECK: [B3] -// CHECK: 1: [B4.6] && [B5.5] +// CHECK: 1: [B5.6] && [B4.5] // CHECK: 2: foo // CHECK: 3: [B3.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(_Bool)) // CHECK: 4: [B3.3]([B3.1]) -// CHECK: T: [B4.6] && ... -// CHECK: Preds (2): B5 B4 +// CHECK: T: [B5.6] && ... +// CHECK: Preds (2): B4 B5 // CHECK: Succs (2): B2 B1 // CHECK: [B4] +// CHECK: 1: B() (CXXConstructExpr, class B) +// CHECK: 2: [B4.1] (BindTemporary) +// CHECK: 3: [B4.2].operator _Bool +// CHECK: 4: [B4.3]() +// CHECK: 5: [B4.4] (ImplicitCastExpr, UserDefinedConversion, _Bool) +// CHECK: Preds (1): B5 +// CHECK: Succs (1): B3 +// CHECK: [B5] // CHECK: 1: ~A() (Temporary object destructor) // CHECK: 2: A() (CXXConstructExpr, class A) -// CHECK: 3: [B4.2] (BindTemporary) -// CHECK: 4: [B4.3].operator _Bool -// CHECK: 5: [B4.4]() -// CHECK: 6: [B4.5] (ImplicitCastExpr, UserDefinedConversion, _Bool) -// CHECK: T: [B4.6] && ... +// CHECK: 3: [B5.2] (BindTemporary) +// CHECK: 4: [B5.3].operator _Bool +// CHECK: 5: [B5.4]() +// CHECK: 6: [B5.5] (ImplicitCastExpr, UserDefinedConversion, _Bool) +// CHECK: T: [B5.6] && ... // CHECK: Preds (2): B6 B7 -// CHECK: Succs (2): B5 B3 -// CHECK: [B5] -// CHECK: 1: B() (CXXConstructExpr, class B) -// CHECK: 2: [B5.1] (BindTemporary) -// CHECK: 3: [B5.2].operator _Bool -// CHECK: 4: [B5.3]() -// CHECK: 5: [B5.4] (ImplicitCastExpr, UserDefinedConversion, _Bool) -// CHECK: Preds (1): B4 -// CHECK: Succs (1): B3 +// CHECK: Succs (2): B4 B3 // CHECK: [B6] // CHECK: 1: ~B() (Temporary object destructor) // CHECK: Preds (1): B7 -// CHECK: Succs (1): B4 +// CHECK: Succs (1): B5 // CHECK: [B7] -// CHECK: 1: [B8.5] && [B9.5] +// CHECK: 1: [B9.5] && [B8.5] // CHECK: 2: bool a = A().operator _Bool() && B().operator _Bool(); -// CHECK: T: [B8.5] && ... -// CHECK: Preds (2): B9 B8 -// CHECK: Succs (2): B6 B4 +// CHECK: T: [B9.5] && ... +// CHECK: Preds (2): B8 B9 +// CHECK: Succs (2): B6 B5 // CHECK: [B8] -// CHECK: 1: A() (CXXConstructExpr, class A) +// CHECK: 1: B() (CXXConstructExpr, class B) // CHECK: 2: [B8.1] (BindTemporary) // CHECK: 3: [B8.2].operator _Bool // CHECK: 4: [B8.3]() // CHECK: 5: [B8.4] (ImplicitCastExpr, UserDefinedConversion, _Bool) -// CHECK: T: [B8.5] && ... -// CHECK: Preds (1): B10 -// CHECK: Succs (2): B9 B7 +// CHECK: Preds (1): B9 +// CHECK: Succs (1): B7 // CHECK: [B9] -// CHECK: 1: B() (CXXConstructExpr, class B) +// CHECK: 1: A() (CXXConstructExpr, class A) // CHECK: 2: [B9.1] (BindTemporary) // CHECK: 3: [B9.2].operator _Bool // CHECK: 4: [B9.3]() // CHECK: 5: [B9.4] (ImplicitCastExpr, UserDefinedConversion, _Bool) -// CHECK: Preds (1): B8 -// CHECK: Succs (1): B7 +// CHECK: T: [B9.5] && ... +// CHECK: Preds (1): B10 +// CHECK: Succs (2): B8 B7 // CHECK: [B0 (EXIT)] // CHECK: Preds (1): B1 // CHECK: [B10 (ENTRY)] -// CHECK: Succs (1): B8 +// CHECK: Succs (1): B9 // CHECK: [B1] // CHECK: 1: ~A() (Temporary object destructor) // CHECK: 2: int b; @@ -227,58 +308,58 @@ TestCtorInits::TestCtorInits() // CHECK: Preds (1): B3 // CHECK: Succs (1): B1 // CHECK: [B3] -// CHECK: 1: [B4.6] || [B5.5] +// CHECK: 1: [B5.6] || [B4.5] // CHECK: 2: foo // CHECK: 3: [B3.2] (ImplicitCastExpr, FunctionToPointerDecay, void (*)(_Bool)) // CHECK: 4: [B3.3]([B3.1]) -// CHECK: T: [B4.6] || ... -// CHECK: Preds (2): B5 B4 +// CHECK: T: [B5.6] || ... +// CHECK: Preds (2): B4 B5 // CHECK: Succs (2): B1 B2 // CHECK: [B4] +// CHECK: 1: B() (CXXConstructExpr, class B) +// CHECK: 2: [B4.1] (BindTemporary) +// CHECK: 3: [B4.2].operator _Bool +// CHECK: 4: [B4.3]() +// CHECK: 5: [B4.4] (ImplicitCastExpr, UserDefinedConversion, _Bool) +// CHECK: Preds (1): B5 +// CHECK: Succs (1): B3 +// CHECK: [B5] // CHECK: 1: ~A() (Temporary object destructor) // CHECK: 2: A() (CXXConstructExpr, class A) -// CHECK: 3: [B4.2] (BindTemporary) -// CHECK: 4: [B4.3].operator _Bool -// CHECK: 5: [B4.4]() -// CHECK: 6: [B4.5] (ImplicitCastExpr, UserDefinedConversion, _Bool) -// CHECK: T: [B4.6] || ... +// CHECK: 3: [B5.2] (BindTemporary) +// CHECK: 4: [B5.3].operator _Bool +// CHECK: 5: [B5.4]() +// CHECK: 6: [B5.5] (ImplicitCastExpr, UserDefinedConversion, _Bool) +// CHECK: T: [B5.6] || ... // CHECK: Preds (2): B6 B7 -// CHECK: Succs (2): B3 B5 -// CHECK: [B5] -// CHECK: 1: B() (CXXConstructExpr, class B) -// CHECK: 2: [B5.1] (BindTemporary) -// CHECK: 3: [B5.2].operator _Bool -// CHECK: 4: [B5.3]() -// CHECK: 5: [B5.4] (ImplicitCastExpr, UserDefinedConversion, _Bool) -// CHECK: Preds (1): B4 -// CHECK: Succs (1): B3 +// CHECK: Succs (2): B3 B4 // CHECK: [B6] // CHECK: 1: ~B() (Temporary object destructor) // CHECK: Preds (1): B7 -// CHECK: Succs (1): B4 +// CHECK: Succs (1): B5 // CHECK: [B7] -// CHECK: 1: [B8.5] || [B9.5] +// CHECK: 1: [B9.5] || [B8.5] // CHECK: 2: bool a = A().operator _Bool() || B().operator _Bool(); -// CHECK: T: [B8.5] || ... -// CHECK: Preds (2): B9 B8 -// CHECK: Succs (2): B4 B6 +// CHECK: T: [B9.5] || ... +// CHECK: Preds (2): B8 B9 +// CHECK: Succs (2): B5 B6 // CHECK: [B8] -// CHECK: 1: A() (CXXConstructExpr, class A) +// CHECK: 1: B() (CXXConstructExpr, class B) // CHECK: 2: [B8.1] (BindTemporary) // CHECK: 3: [B8.2].operator _Bool // CHECK: 4: [B8.3]() // CHECK: 5: [B8.4] (ImplicitCastExpr, UserDefinedConversion, _Bool) -// CHECK: T: [B8.5] || ... -// CHECK: Preds (1): B10 -// CHECK: Succs (2): B7 B9 +// CHECK: Preds (1): B9 +// CHECK: Succs (1): B7 // CHECK: [B9] -// CHECK: 1: B() (CXXConstructExpr, class B) +// CHECK: 1: A() (CXXConstructExpr, class A) // CHECK: 2: [B9.1] (BindTemporary) // CHECK: 3: [B9.2].operator _Bool // CHECK: 4: [B9.3]() // CHECK: 5: [B9.4] (ImplicitCastExpr, UserDefinedConversion, _Bool) -// CHECK: Preds (1): B8 -// CHECK: Succs (1): B7 +// CHECK: T: [B9.5] || ... +// CHECK: Preds (1): B10 +// CHECK: Succs (2): B7 B8 // CHECK: [B0 (EXIT)] // CHECK: Preds (1): B1 // CHECK: [B11 (ENTRY)] diff --git a/test/Analysis/templates.cpp b/test/Analysis/templates.cpp new file mode 100644 index 000000000000..671aa7858204 --- /dev/null +++ b/test/Analysis/templates.cpp @@ -0,0 +1,44 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -fblocks -verify %s + +void clang_analyzer_eval(bool); + +// Do not crash on this templated code which uses a block. +typedef void (^my_block)(void); +static void useBlock(my_block block){} +template<class T> class MyClass; +typedef MyClass<float> Mf; + +template<class T> +class MyClass +{ +public: + MyClass() {} + MyClass(T a); + void I(); +private: + static const T one; +}; + +template<class T> const T MyClass<T>::one = static_cast<T>(1); +template<class T> inline MyClass<T>::MyClass(T a){} +template<class T> void MyClass<T>::I() { + static MyClass<T>* mPtr = 0; + useBlock(^{ mPtr = new MyClass<T> (MyClass<T>::one); }); +}; +int main(){ + Mf m; + m.I(); +} + + +// <rdar://problem/11949235> +template<class T, unsigned N> +inline unsigned array_lengthof(T (&)[N]) { + return N; +} + +void testNonTypeTemplateInstantiation() { + const char *S[] = { "a", "b" }; + clang_analyzer_eval(array_lengthof(S) == 2); // expected-warning{{TRUE}} +} + diff --git a/test/Analysis/test-variably-modified-types.c b/test/Analysis/test-variably-modified-types.c new file mode 100644 index 000000000000..a833434228d1 --- /dev/null +++ b/test/Analysis/test-variably-modified-types.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyze-function=testVariablyModifiedTypes -verify %s + +// Test that we process variably modified type correctly - the call graph construction should pick up function_with_bug while recursively visiting test_variably_modifiable_types. +unsigned getArraySize(int *x) { + if (!x) + return *x; // expected-warning {{Dereference of null pointer}} + return 1; +} + +int testVariablyModifiedTypes(int *x) { + int mytype[getArraySize(x)]; + return 0; +} diff --git a/test/Analysis/traversal-algorithm.mm b/test/Analysis/traversal-algorithm.mm new file mode 100644 index 000000000000..8a3dc8b3a222 --- /dev/null +++ b/test/Analysis/traversal-algorithm.mm @@ -0,0 +1,213 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpTraversal -analyzer-max-loop 4 -std=c++11 %s | FileCheck -check-prefix=DFS %s + +int a(); +int b(); +int c(); + +int work(); + +void test(id input) { + if (a()) { + if (a()) + b(); + else + c(); + } else { + if (b()) + a(); + else + c(); + } + + if (a()) + work(); +} + +void testLoops(id input) { + while (a()) { + work(); + work(); + work(); + } + + for (int i = 0; i != b(); ++i) { + work(); + } + + for (id x in input) { + work(); + work(); + work(); + } + + int z[] = {1,2,3}; + for (int y : z) { + work(); + work(); + work(); + } +} + +// This ordering assumes that false cases happen before the true cases. + +// DFS:27 WhileStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:27 WhileStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:27 WhileStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:27 WhileStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:33 ForStmt +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:44 CXXForRangeStmt +// DFS-next:--END PATH-- +// DFS-next:37 ObjCForCollectionStmt +// DFS-next:10 IfStmt +// DFS-next:16 IfStmt +// DFS-next:22 IfStmt +// DFS-next:--END PATH-- +// DFS-next:--END PATH-- +// DFS-next:22 IfStmt +// DFS-next:--END PATH-- +// DFS-next:--END PATH-- +// DFS-next:11 IfStmt +// DFS-next:22 IfStmt +// DFS-next:--END PATH-- +// DFS-next:--END PATH-- +// DFS-next:22 IfStmt +// DFS-next:--END PATH-- +// DFS-next:--END PATH-- + diff --git a/test/Analysis/uninit-sometimes.cpp b/test/Analysis/uninit-sometimes.cpp new file mode 100644 index 000000000000..7825e8734616 --- /dev/null +++ b/test/Analysis/uninit-sometimes.cpp @@ -0,0 +1,387 @@ +// RUN: %clang_cc1 -std=gnu++11 -Wsometimes-uninitialized -verify %s +// RUN: %clang_cc1 -std=gnu++11 -Wsometimes-uninitialized -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s + +bool maybe(); + +int test_if_false(bool b) { + int x; // expected-note {{variable}} + if (b) // expected-warning {{whenever 'if' condition is false}} \ + // expected-note {{remove the 'if' if its condition is always true}} + x = 1; + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{8:3-10:5}:"" +// CHECK: fix-it:"{{.*}}":{7:8-7:8}:" = 0" + + +int test_if_true(bool b) { + int x; // expected-note {{variable}} + if (b) {} // expected-warning {{whenever 'if' condition is true}} \ + // expected-note {{remove the 'if' if its condition is always false}} + else x = 1; + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{20:3-22:8}:"" +// CHECK: fix-it:"{{.*}}":{19:8-19:8}:" = 0" + + +int test_while_false(bool b) { + int x; // expected-note {{variable}} + while (b) { // expected-warning {{whenever 'while' loop exits because its condition is false}} \ + // expected-note {{remove the condition if it is always true}} + if (maybe()) { + x = 1; + break; + } + }; + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{32:10-32:11}:"true" +// CHECK: fix-it:"{{.*}}":{31:8-31:8}:" = 0" + + +int test_while_true(bool b) { + int x; // expected-note {{variable}} + while (b) { // expected-warning {{whenever 'while' loop is entered}} \ + // expected-note {{remove the condition if it is always false}} +label: + return x; // expected-note {{uninitialized use}} + } + x = 0; + goto label; +} + +// CHECK: fix-it:"{{.*}}":{48:10-48:11}:"false" +// CHECK: fix-it:"{{.*}}":{47:8-47:8}:" = 0" + + +int test_do_while_false(bool b) { + int x; // expected-note {{variable}} + do { + if (maybe()) { + x = 1; + break; + } + } while (b); // expected-warning {{whenever 'do' loop exits because its condition is false}} \ + // expected-note {{remove the condition if it is always true}} + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{68:12-68:13}:"true" +// CHECK: fix-it:"{{.*}}":{62:8-62:8}:" = 0" + + +int test_do_while_true(bool b) { + int x; // expected-note {{variable}} +goto label2; + do { +label1: + return x; // expected-note {{uninitialized use}} +label2: ; + } while (b); // expected-warning {{whenever 'do' loop condition is true}} \ + // expected-note {{remove the condition if it is always false}} + x = 0; + goto label1; +} + +// CHECK: fix-it:"{{.*}}":{84:12-84:13}:"false" +// CHECK: fix-it:"{{.*}}":{78:8-78:8}:" = 0" + + +int test_for_false(int k) { + int x; // expected-note {{variable}} + for (int n = 0; + n < k; // expected-warning {{whenever 'for' loop exits because its condition is false}} \ + // expected-note {{remove the condition if it is always true}} + ++n) { + if (maybe()) { + x = n; + break; + } + } + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{97:8-97:13}:"" +// CHECK: fix-it:"{{.*}}":{95:8-95:8}:" = 0" + + +int test_for_true(int k) { + int x; // expected-note {{variable}} + int n = 0; + for (; + n < k; // expected-warning {{whenever 'for' loop is entered}} \ + // expected-note {{remove the condition if it is always false}} + ++n) { +label: + return x; // expected-note {{uninitialized use}} + } + x = 1; + goto label; +} + +// CHECK: fix-it:"{{.*}}":{116:8-116:13}:"false" +// CHECK: fix-it:"{{.*}}":{113:8-113:8}:" = 0" + + +int test_for_range_false(int k) { + int arr[3] = { 1, 2, 3 }; + int x; + for (int &a : arr) { // no-warning, condition was not explicitly specified + if (a == k) { + x = &a - arr; + break; + } + } + return x; +} + + + + + +int test_for_range_true(int k) { + int arr[3] = { 1, 2, 3 }; + int x; + for (int &a : arr) { // no-warning + goto label; + } + x = 0; +label: + return x; +} + + + + + +int test_conditional_false(int k) { + int x; // expected-note {{variable}} + (void)( + maybe() // expected-warning {{whenever '?:' condition is false}} \ + // expected-note {{remove the '?:' if its condition is always true}} + ? x = 1 : 0); + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{164:7-166:9}:"" +// CHECK: fix-it:"{{.*}}":{166:14-166:18}:"" +// CHECK: fix-it:"{{.*}}":{162:8-162:8}:" = 0" + +int test_conditional_true(int k) { + int x; // expected-note {{variable}} + (void)( + maybe() // expected-warning {{whenever '?:' condition is true}} \ + // expected-note {{remove the '?:' if its condition is always false}} + ? 0 : x = 1); + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{177:7-179:13}:"" +// CHECK: fix-it:"{{.*}}":{175:8-175:8}:" = 0" + + +int test_logical_and_false(int k) { + int x; // expected-note {{variable}} + maybe() // expected-warning {{whenever '&&' condition is false}} \ + // expected-note {{remove the '&&' if its condition is always true}} + && (x = 1); + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{189:3-191:9}:"" +// CHECK: fix-it:"{{.*}}":{188:8-188:8}:" = 0" + + +int test_logical_and_true(int k) { + int x; // expected-note {{variable}} + maybe() // expected-warning {{whenever '&&' condition is true}} \ + // expected-note {{remove the '&&' if its condition is always false}} + && ({ goto skip_init; 0; }); + x = 1; +skip_init: + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{201:3-203:34}:"false" +// CHECK: fix-it:"{{.*}}":{200:8-200:8}:" = 0" + + +int test_logical_or_false(int k) { + int x; // expected-note {{variable}} + maybe() // expected-warning {{whenever '||' condition is false}} \ + // expected-note {{remove the '||' if its condition is always true}} + || ({ goto skip_init; 0; }); + x = 1; +skip_init: + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{215:3-217:34}:"true" +// CHECK: fix-it:"{{.*}}":{214:8-214:8}:" = 0" + + +int test_logical_or_true(int k) { + int x; // expected-note {{variable}} + maybe() // expected-warning {{whenever '||' condition is true}} \ + // expected-note {{remove the '||' if its condition is always false}} + || (x = 1); + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{229:3-231:9}:"" +// CHECK: fix-it:"{{.*}}":{228:8-228:8}:" = 0" + + +int test_switch_case(int k) { + int x; // expected-note {{variable}} + switch (k) { + case 0: + x = 0; + break; + case 1: // expected-warning {{whenever switch case is taken}} + break; + } + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{240:8-240:8}:" = 0" + + + +int test_switch_default(int k) { + int x; // expected-note {{variable}} + switch (k) { + case 0: + x = 0; + break; + case 1: + x = 1; + break; + default: // expected-warning {{whenever switch default is taken}} + break; + } + return x; // expected-note {{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{256:8-256:8}:" = 0" + + + +int test_switch_suppress_1(int k) { + int x; + switch (k) { + case 0: + x = 0; + break; + case 1: + x = 1; + break; + } + return x; // no-warning +} + + + + + +int test_switch_suppress_2(int k) { + int x; + switch (k) { + case 0: + case 1: + switch (k) { + case 0: + return 0; + case 1: + return 1; + } + case 2: + case 3: + x = 1; + } + return x; // no-warning +} + + + + + +int test_multiple_notes(int k) { + int x; // expected-note {{variable}} + if (k > 0) { + if (k == 5) + x = 1; + else if (k == 2) // expected-warning {{whenever 'if' condition is false}} \ + // expected-note {{remove the 'if' if its condition is always true}} + x = 2; + } else { + if (k == -5) + x = 3; + else if (k == -2) // expected-warning {{whenever 'if' condition is false}} \ + // expected-note {{remove the 'if' if its condition is always true}} + x = 4; + } + return x; // expected-note 2{{uninitialized use}} +} + +// CHECK: fix-it:"{{.*}}":{324:10-326:7}:"" +// CHECK: fix-it:"{{.*}}":{318:10-320:7}:"" +// CHECK: fix-it:"{{.*}}":{314:8-314:8}:" = 0" + +int test_no_false_positive_1(int k) { + int x; + if (k) + x = 5; + while (!k) + maybe(); + return x; +} + + + + + +int test_no_false_positive_2() { + int x; + bool b = false; + if (maybe()) { + x = 5; + b = true; + } + return b ? x : 0; +} + + +// FIXME: In this case, the variable is used uninitialized whenever the +// function's entry block is reached. Produce a diagnostic saying that +// the variable is uninitialized the first time it is used. +void test_null_pred_succ() { + int x; + if (0) + foo: x = 0; + if (x) + goto foo; +} + + + + +void foo(); +int PR13360(bool b) { + int x; // expected-note {{variable}} + if (b) { // expected-warning {{variable 'x' is used uninitialized whenever 'if' condition is true}} expected-note {{remove}} + do { + foo(); + } while (0); + } else { + x = 1; + } + return x; // expected-note {{uninitialized use occurs here}} +} + +// CHECK: fix-it:"{{.*}}":{376:3-380:10}:"" +// CHECK: fix-it:"{{.*}}":{375:8-375:8}:" = 0" diff --git a/test/Analysis/unused-ivars.m b/test/Analysis/unused-ivars.m index 894184078039..f04132ba4570 100644 --- a/test/Analysis/unused-ivars.m +++ b/test/Analysis/unused-ivars.m @@ -108,3 +108,24 @@ int radar_7254495(RDar7254495 *a) { @implementation RDar8481311 @end + +@class NSString; +@interface Radar11059352_1 { +@private + NSString *_pathString; +} +@property (readonly, strong) NSString *pathString; +@end + +@interface Radar11059352 { +@private +Radar11059352_1 *_workspacePath; +} +@end + +@implementation Radar11059352 + +- (void)useWorkspace { + NSString *workspacePathString = _workspacePath.pathString; +} +@end
\ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ae9de78d19ad..8184c3d3638a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,117 +1,93 @@ -set(CLANG_TEST_DIRECTORIES - "Analysis" - "CodeCompletion" - "CodeGen" - "CodeGenCUDA" - "CodeGenCXX" - "CodeGenObjC" - "CodeGenOpenCL" - "Coverage" - "CXX" - "Driver" - "FixIt" - "Frontend" - "Headers" - "Index" - "Lexer" - "Misc" - "PCH" - "Parser" - "Preprocessor" - "Rewriter" - "Sema" - "SemaCUDA" - "SemaCXX" - "SemaObjC" - "SemaObjCXX" - "SemaOpenCL" - "SemaTemplate") +# Test runner infrastructure for Clang. This configures the Clang test trees +# for use by Lit, and delegates to LLVM's lit test handlers. +# +# If this is a stand-alone Clang build, we fake up our own Lit support here +# rather than relying on LLVM's. -set(LLVM_SOURCE_DIR "${LLVM_MAIN_SRC_DIR}") -set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}") -set(LLVM_BUILD_MODE "%(build_mode)s") -set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}/%(build_config)s") -set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib/%(build_config)s") set(CLANG_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/..") set(CLANG_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/..") -if(BUILD_SHARED_LIBS) - set(ENABLE_SHARED 1) -else() - set(ENABLE_SHARED 0) -endif(BUILD_SHARED_LIBS) -configure_file( +configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ) -configure_file( +configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg - @ONLY) + ) -include(FindPythonInterp) -if(PYTHONINTERP_FOUND) - if( LLVM_MAIN_SRC_DIR ) - set(LIT "${LLVM_SOURCE_DIR}/utils/lit/lit.py") - else() - set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit") - # Installed LLVM does not contain ${CMAKE_CFG_INTDIR} in paths. - if( NOT EXISTS ${LIT} ) - set(LIT "${PATH_TO_LLVM_BUILD}/bin/llvm-lit") - endif() - endif() +if( PATH_TO_LLVM_BUILD ) + set(CLANG_TEST_EXTRA_ARGS "--path=${CLANG_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}") +endif() - if( PATH_TO_LLVM_BUILD ) - set(CLANG_TEST_EXTRA_ARGS "--path=${CLANG_BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}") - endif() +option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF) +if(CLANG_TEST_USE_VG) + set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg") +endif () + +if( NOT CLANG_BUILT_STANDALONE ) - option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF) - if(CLANG_TEST_USE_VG) - set(CLANG_TEST_EXTRA_ARGS ${CLANG_TEST_EXTRA_ARGS} "--vg") - endif () + set(CLANG_TEST_DEPS + clang clang-headers + c-index-test diagtool arcmt-test c-arcmt-test + clang-check + llvm-dis llc opt FileCheck count not + ) + set(CLANG_TEST_PARAMS + clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + ) - set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}") - separate_arguments(LIT_ARGS) + if(LLVM_INCLUDE_TESTS) + list(APPEND CLANG_TEST_DEPS ClangUnitTests) + list(APPEND CLANG_TEST_PARAMS + clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg + ) + endif() + add_lit_testsuite(check-clang "Running the Clang regression tests" + ${CMAKE_CURRENT_BINARY_DIR} + PARAMS ${CLANG_TEST_PARAMS} + DEPENDS ${CLANG_TEST_DEPS} + ARGS ${CLANG_TEST_EXTRA_ARGS} + ) + set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") + +else() - add_custom_target(clang-test.deps) - set_target_properties(clang-test.deps PROPERTIES FOLDER "Clang tests") + include(FindPythonInterp) + if(PYTHONINTERP_FOUND) + if( LLVM_MAIN_SRC_DIR ) + set(LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py") + else() + set(LIT "${PATH_TO_LLVM_BUILD}/bin/${CMAKE_CFG_INTDIR}/llvm-lit") + # Installed LLVM does not contain ${CMAKE_CFG_INTDIR} in paths. + if( NOT EXISTS ${LIT} ) + set(LIT "${PATH_TO_LLVM_BUILD}/bin/llvm-lit") + endif() + endif() - add_custom_target(clang-test - COMMAND ${PYTHON_EXECUTABLE} - ${LIT} - --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg - --param clang_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg - --param build_config=${CMAKE_CFG_INTDIR} - --param build_mode=${RUNTIME_BUILD_MODE} - ${LIT_ARGS} - ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Running Clang regression tests") + set(LIT_ARGS "${CLANG_TEST_EXTRA_ARGS} ${LLVM_LIT_ARGS}") + separate_arguments(LIT_ARGS) - if( NOT CLANG_BUILT_STANDALONE ) - add_custom_target(check-all + add_custom_target(check-clang COMMAND ${PYTHON_EXECUTABLE} - ${LIT} - --param build_config=${CMAKE_CFG_INTDIR} - --param build_mode=${RUNTIME_BUILD_MODE} - ${LIT_ARGS} - ${LLVM_BINARY_DIR}/test - ${CMAKE_CURRENT_BINARY_DIR} - COMMENT "Running Clang and LLVM regression tests") - add_dependencies(check-all clang-test.deps) - if ( LLVM_INCLUDE_TESTS ) - add_dependencies(clang-test.deps ClangUnitTests) - add_dependencies(check-all check.deps) - endif ( LLVM_INCLUDE_TESTS ) - add_dependencies(clang-test.deps - llvm-dis llc opt - FileCheck count not - ) + ${LIT} + --param clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg + --param build_config=${CMAKE_CFG_INTDIR} + --param build_mode=${RUNTIME_BUILD_MODE} + ${LIT_ARGS} + ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Running Clang regression tests" + DEPENDS clang clang-headers + c-index-test diagtool arcmt-test c-arcmt-test + clang-check + ) + set_target_properties(check-clang PROPERTIES FOLDER "Clang tests") endif() - add_dependencies(clang-test clang-test.deps) - add_dependencies(clang-test.deps - clang clang-headers c-index-test diagtool arcmt-test c-arcmt-test - clang-check - ) - endif() + +# Add a legacy target spelling: clang-test +add_custom_target(clang-test) +add_dependencies(clang-test check-clang) +set_target_properties(clang-test PROPERTIES FOLDER "Clang tests") diff --git a/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp b/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp new file mode 100644 index 000000000000..f812ea1bd8be --- /dev/null +++ b/test/CXX/basic/basic.lookup/basic.lookup.classref/p1-cxx11.cpp @@ -0,0 +1,69 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fdiagnostics-show-option -verify %s + +template<typename T> +struct set{}; +struct Value { + template<typename T> + void set(T value) {} + + void resolves_to_same() { + Value v; + v.set<double>(3.2); + } +}; +void resolves_to_different() { + { + Value v; + // The fact that the next line is a warning rather than an error is an + // extension. + v.set<double>(3.2); + } + { + int set; // Non-template. + Value v; + v.set<double>(3.2); + } +} + +namespace rdar9915664 { + struct A { + template<typename T> void a(); + }; + + struct B : A { }; + + struct C : A { }; + + struct D : B, C { + A &getA() { return static_cast<B&>(*this); } + + void test_a() { + getA().a<int>(); + } + }; +} + +namespace PR11856 { + template<typename T> T end(T); + + template <typename T> + void Foo() { + T it1; + if (it1->end < it1->end) { + } + } + + template<typename T> T *end(T*); + + class X { }; + template <typename T> + void Foo2() { + T it1; + if (it1->end < it1->end) { + } + + X *x; + if (x->end < 7) { // expected-error{{no member named 'end' in 'PR11856::X'}} + } + } +} diff --git a/test/CXX/basic/basic.lookup/basic.lookup.classref/p4-cxx11.cpp b/test/CXX/basic/basic.lookup/basic.lookup.classref/p4-cxx11.cpp new file mode 100644 index 000000000000..792545453e73 --- /dev/null +++ b/test/CXX/basic/basic.lookup/basic.lookup.classref/p4-cxx11.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +struct A { void f(); }; +struct C { void f(); }; +struct B : A { typedef A X; }; +struct D : C { typedef C X; void g(); }; + +void D::g() +{ + B * b = new B; + b->X::f(); // lookup for X finds B::X +} + +typedef int X; +void h(void) +{ + B * b = new B; + b->X::f(); // lookup for X finds B::X +} + + diff --git a/test/CXX/basic/basic.types/p10.cpp b/test/CXX/basic/basic.types/p10.cpp index 83b910b60640..191d42bebd83 100644 --- a/test/CXX/basic/basic.types/p10.cpp +++ b/test/CXX/basic/basic.types/p10.cpp @@ -22,11 +22,11 @@ struct BeingDefined { // (implied) - it is complete -struct Incomplete; +struct Incomplete; // expected-note 2{{forward declaration of 'Incomplete'}} template<class T> struct ClassTemp {}; -constexpr Incomplete incomplete = {}; // expected-error {{constexpr variable cannot have non-literal type 'const Incomplete'}} -constexpr Incomplete incomplete2[] = {}; // expected-error {{constexpr variable cannot have non-literal type 'Incomplete const[]'}} +constexpr Incomplete incomplete = {}; // expected-error {{constexpr variable cannot have non-literal type 'const Incomplete'}} expected-note {{incomplete type 'const Incomplete' is not a literal type}} +constexpr Incomplete incomplete2[] = {}; // expected-error {{constexpr variable cannot have non-literal type 'Incomplete const[]'}} expected-note {{incomplete type 'Incomplete const[]' is not a literal type}} constexpr ClassTemp<int> classtemplate = {}; constexpr ClassTemp<int> classtemplate2[] = {}; diff --git a/test/CXX/class.access/class.friend/p1.cpp b/test/CXX/class.access/class.friend/p1.cpp index 68ff83fee83c..7cb192b5a1f3 100644 --- a/test/CXX/class.access/class.friend/p1.cpp +++ b/test/CXX/class.access/class.friend/p1.cpp @@ -64,6 +64,7 @@ namespace test0 { }; class MemberFriend { + public: void test(); }; @@ -309,6 +310,7 @@ namespace test10 { // PR8705 namespace test11 { class A { + public: void test0(int); void test1(int); void test2(int); diff --git a/test/CXX/class.access/class.friend/p9-cxx0x.cpp b/test/CXX/class.access/class.friend/p9-cxx0x.cpp new file mode 100644 index 000000000000..f748a2bb3ba6 --- /dev/null +++ b/test/CXX/class.access/class.friend/p9-cxx0x.cpp @@ -0,0 +1,117 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +// C++98 [class.friend]p7: +// C++11 [class.friend]p9: +// A name nominated by a friend declaration shall be accessible in +// the scope of the class containing the friend declaration. + +// PR12328 +// Simple, non-templated case. +namespace test0 { + class X { + void f(); // expected-note {{implicitly declared private here}} + }; + + class Y { + friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test0::X'}} + }; +} + +// Templated but non-dependent. +namespace test1 { + class X { + void f(); // expected-note {{implicitly declared private here}} + }; + + template <class T> class Y { + friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test1::X'}} + }; +} + +// Dependent but instantiated at the right type. +namespace test2 { + template <class T> class Y; + + class X { + void f(); + friend class Y<int>; + }; + + template <class T> class Y { + friend void X::f(); + }; + + template class Y<int>; +} + +// Dependent and instantiated at the wrong type. +namespace test3 { + template <class T> class Y; + + class X { + void f(); // expected-note {{implicitly declared private here}} + friend class Y<int>; + }; + + template <class T> class Y { + friend void X::f(); // expected-error {{friend function 'f' is a private member of 'test3::X'}} + }; + + template class Y<float>; // expected-note {{in instantiation}} +} + +// Dependent because dependently-scoped. +namespace test4 { + template <class T> class X { + void f(); + }; + + template <class T> class Y { + friend void X<T>::f(); + }; +} + +// Dependently-scoped, no friends. +namespace test5 { + template <class T> class X { + void f(); // expected-note {{implicitly declared private here}} + }; + + template <class T> class Y { + friend void X<T>::f(); // expected-error {{friend function 'f' is a private member of 'test5::X<int>'}} + }; + + template class Y<int>; // expected-note {{in instantiation}} +} + +// Dependently-scoped, wrong friend. +namespace test6 { + template <class T> class Y; + + template <class T> class X { + void f(); // expected-note {{implicitly declared private here}} + friend class Y<float>; + }; + + template <class T> class Y { + friend void X<T>::f(); // expected-error {{friend function 'f' is a private member of 'test6::X<int>'}} + }; + + template class Y<int>; // expected-note {{in instantiation}} +} + +// Dependently-scoped, right friend. +namespace test7 { + template <class T> class Y; + + template <class T> class X { + void f(); + friend class Y<int>; + }; + + template <class T> class Y { + friend void X<T>::f(); + }; + + template class Y<int>; +} diff --git a/test/CXX/class.derived/class.virtual/p3-0x.cpp b/test/CXX/class.derived/class.virtual/p3-0x.cpp index c4a401bb27c5..16f98280ed87 100644 --- a/test/CXX/class.derived/class.virtual/p3-0x.cpp +++ b/test/CXX/class.derived/class.virtual/p3-0x.cpp @@ -20,9 +20,15 @@ struct A { template<typename T> struct B : A { + // FIXME: Diagnose this. virtual void f(T) override; }; +template<typename T> +struct C : A { + virtual void f(int) override; // expected-error {{does not override}} +}; + } namespace Test3 { @@ -51,3 +57,46 @@ struct D : B { }; } + +namespace PR13499 { + struct X { + virtual void f(); + virtual void h(); + }; + template<typename T> struct A : X { + void f() override; + void h() final; + }; + template<typename T> struct B : X { + void g() override; // expected-error {{only virtual member functions can be marked 'override'}} + void i() final; // expected-error {{only virtual member functions can be marked 'final'}} + }; + B<int> b; // no-note + template<typename T> struct C : T { + void g() override; + void i() final; + }; + template<typename T> struct D : X { + virtual void g() override; // expected-error {{does not override}} + virtual void i() final; + }; + template<typename...T> struct E : X { + void f(T...) override; + void g(T...) override; // expected-error {{only virtual member functions can be marked 'override'}} + void h(T...) final; + void i(T...) final; // expected-error {{only virtual member functions can be marked 'final'}} + }; + // FIXME: Diagnose these in the template definition, not in the instantiation. + E<> e; // expected-note {{in instantiation of}} + + template<typename T> struct Y : T { + void f() override; + void h() final; + }; + template<typename T> struct Z : T { + void g() override; // expected-error {{only virtual member functions can be marked 'override'}} + void i() final; // expected-error {{only virtual member functions can be marked 'final'}} + }; + Y<X> y; + Z<X> z; // expected-note {{in instantiation of}} +} diff --git a/test/CXX/class/class.mem/p14.cpp b/test/CXX/class/class.mem/p14.cpp index 72b232e8f715..3f14099ef896 100644 --- a/test/CXX/class/class.mem/p14.cpp +++ b/test/CXX/class/class.mem/p14.cpp @@ -9,8 +9,9 @@ struct X0 { }; struct X1 { - int X1; - X1(); // expected-error{{declarator requires an identifier}} + int X1; // expected-note{{hidden by a non-type declaration of 'X1' here}} + X1(); // expected-error{{must use 'struct' tag to refer to type 'X1' in this scope}} \ + // expected-error{{expected member name or ';' after declaration specifiers}} }; struct X2 { diff --git a/test/CXX/class/class.union/p1.cpp b/test/CXX/class/class.union/p1.cpp index f344ae5b01fb..ee97410aebfe 100644 --- a/test/CXX/class/class.union/p1.cpp +++ b/test/CXX/class/class.union/p1.cpp @@ -27,9 +27,8 @@ class CopyCtor { CopyCtor(CopyCtor &cc) { abort(); } // expected-note 4 {{because type 'CopyCtor' has a user-declared copy constructor}} }; -// FIXME: this should eventually trigger on the operator's declaration line -class CopyAssign { // expected-note 4 {{because type 'CopyAssign' has a user-declared copy assignment operator}} - CopyAssign& operator=(CopyAssign& CA) { abort(); } +class CopyAssign { + CopyAssign& operator=(CopyAssign& CA) { abort(); } // expected-note 4 {{because type 'CopyAssign' has a user-declared copy assignment operator}} }; class Dtor { diff --git a/test/CXX/class/p6-0x.cpp b/test/CXX/class/p6-0x.cpp index f2cf48282112..e153b4daaf3c 100644 --- a/test/CXX/class/p6-0x.cpp +++ b/test/CXX/class/p6-0x.cpp @@ -19,7 +19,7 @@ struct Trivial2 { Trivial2(const Trivial2 &) = default; Trivial2(Trivial2 &&) = default; Trivial2 &operator=(const Trivial2 &) = default; - Trivial2 &operator=(Trivial2 &) = default; + Trivial2 &operator=(Trivial2 &&) = default; ~Trivial2() = default; }; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp index 65573c753362..dfc1d3d04bf9 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p4.cpp @@ -209,7 +209,7 @@ struct ConstexprBaseMemberCtors : Literal { {} }; -// - every assignment-expression that is an initializer-caluse appearing +// - every assignment-expression that is an initializer-clause appearing // directly or indirectly within a brace-or-equal-initializer for a non-static // data member that is not named by a mem-initializer-id shall be a constant // expression; and @@ -224,6 +224,25 @@ struct X { constexpr X(int c) : a(c) {} // ok, b initialized by 2 * c + 1 }; +union XU1 { int a; constexpr XU1() = default; }; // expected-error{{not constexpr}} +union XU2 { int a = 1; constexpr XU2() = default; }; + +struct XU3 { + union { + int a; + }; + constexpr XU3() = default; // expected-error{{not constexpr}} +}; +struct XU4 { + union { + int a = 1; + }; + constexpr XU4() = default; +}; + +static_assert(XU2().a == 1, ""); +static_assert(XU4().a == 1, ""); + // - every implicit conversion used in converting a constructor argument to the // corresponding parameter type and converting a full-expression to the // corresponding member type shall be one of those allowed in a constant @@ -247,3 +266,30 @@ namespace StdExample { int val; }; } + +namespace CtorLookup { + // Ensure that we look up which constructor will actually be used. + struct A { + constexpr A(const A&) {} + A(A&) {} + constexpr A(int); // expected-note {{previous}} + }; + constexpr A::A(int = 0) {} // expected-warning {{default constructor}} + + struct B : A { + B() = default; + constexpr B(const B&); + constexpr B(B&); + }; + constexpr B::B(const B&) = default; + constexpr B::B(B&) = default; // expected-error {{not constexpr}} + + struct C { + A a; + C() = default; + constexpr C(const C&); + constexpr C(C&); + }; + constexpr C::C(const C&) = default; + constexpr C::C(C&) = default; // expected-error {{not constexpr}} +} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp index 1daf02f6ea51..f732255a8a4f 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp @@ -49,3 +49,40 @@ void p3example() { same<__typeof(u), const int> uHasTypeConstInt; same<__typeof(y), double> yHasTypeDouble; } + +#if __cplusplus >= 201103L +namespace PR13293 { + // Ensure that dependent declarators have their deduction delayed. + int f(char); + double f(short); + template<typename T> struct S { + static constexpr auto (*p)(T) = &f; + }; + + constexpr int (*f1)(char) = &f; + constexpr double (*f2)(short) = &f; + static_assert(S<char>::p == f1, ""); + static_assert(S<short>::p == f2, ""); + + struct K { int n; }; + template<typename T> struct U { + static constexpr auto (T::*p) = &K::n; + }; + static_assert(U<K>::p == &K::n, ""); + + template<typename T> + using X = auto(int) -> auto(*)(T) -> auto(*)(char) -> long; + X<double> x; + template<typename T> struct V { + //static constexpr auto (*p)(int) -> auto(*)(T) -> auto(*)(char) = &x; // ill-formed + static constexpr auto (*(*(*p)(int))(T))(char) = &x; // ok + }; + V<double> v; + + int *g(double); + template<typename T> void h() { + new (auto(*)(T)) (&g); + } + template void h<double>(); +} +#endif diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp index 71f57dcc66e7..7499829185eb 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp @@ -64,5 +64,4 @@ template<typename T = auto> struct G { }; // expected-error{{'auto' not allowed using A = auto; // expected-error{{'auto' not allowed in type alias}} -// FIXME: don't issue the second diagnostic for this error. -auto k() -> auto; // expected-error{{'auto' not allowed in function return type}} unexpected-error{{without trailing return type}} +auto k() -> auto; // expected-error{{'auto' not allowed in function return type}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp index 2bd5d234ce7f..093bc14d47f1 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.simple/p5-cxx0x.cpp @@ -21,7 +21,7 @@ void r() { class PD { friend struct A; - ~PD(); // expected-note 4{{here}} + ~PD(); // expected-note 5{{here}} public: typedef int n; }; @@ -37,8 +37,14 @@ struct A { }; // Two errors here: one for the decltype, one for the variable. -decltype(PD(), PD()) pd1; // expected-error 2{{private destructor}} -decltype(DD(), DD()) dd1; // expected-error 2{{deleted function}} +decltype( + PD(), // expected-error {{private destructor}} + PD()) pd1; // expected-error {{private destructor}} +decltype(DD(), // expected-error {{deleted function}} + DD()) dd1; // expected-error {{deleted function}} +decltype( + PD(), // expected-error {{temporary of type 'PD' has private destructor}} + 0) pd2; decltype(((13, ((DD())))))::n dd_parens; // ok decltype(((((42)), PD())))::n pd_parens_comma; // ok diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp index b06eb01a7fb5..89a28adcc65c 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.typedef/p2-0x.cpp @@ -124,9 +124,7 @@ namespace TagName { } namespace CWG1044 { - // FIXME: this diagnostic isn't ideal. one diagnostic is enough. - using T = T; // expected-error {{type name requires a specifier}} \ - expected-error {{expected ';' after alias declaration}} + using T = T; // expected-error {{unknown type name 'T'}} } namespace StdExample { diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp index 06dd1bb05560..783aba182319 100644 --- a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp +++ b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p2.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -fcxx-exceptions %s // An explicitly-defaulted function may be declared constexpr only if it would // have been implicitly declared as constexpr. @@ -27,7 +27,7 @@ struct S2 { // -- it is implicitly considered to be constexpr if the implicit declaration // would be struct S3 { - S3() = default; // expected-note {{here}} + S3() = default; S3(const S3&) = default; S3(S3&&) = default; constexpr S3(int n) : n(n) {} @@ -36,7 +36,7 @@ struct S3 { constexpr S3 s3a = S3(0); constexpr S3 s3b = s3a; constexpr S3 s3c = S3(); -constexpr S3 s3d; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}} +constexpr S3 s3d; // expected-error {{default initialization of an object of const type 'const S3' requires a user-provided default constructor}} struct S4 { S4() = default; @@ -44,7 +44,7 @@ struct S4 { S4(S4&&) = default; // expected-note {{here}} NoCopyMove ncm; }; -constexpr S4 s4a; // ok +constexpr S4 s4a{}; // ok constexpr S4 s4b = S4(); // expected-error {{constant expression}} expected-note {{non-constexpr constructor}} constexpr S4 s4c = s4a; // expected-error {{constant expression}} expected-note {{non-constexpr constructor}} @@ -54,3 +54,71 @@ struct S5 { }; constexpr S5::S5() = default; static_assert(S5().m == 4, ""); + + +// An explicitly-defaulted function may have an exception specification only if +// it is compatible with the exception specification on an implicit declaration. +struct E1 { + E1() noexcept = default; + E1(const E1&) noexcept = default; + E1(E1&&) noexcept = default; + E1 &operator=(const E1&) noexcept = default; + E1 &operator=(E1&&) noexcept = default; + ~E1() noexcept = default; +}; +struct E2 { + E2() noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted default constructor does not match the calculated one}} + E2(const E2&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted copy constructor does not match the calculated one}} + E2(E2&&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted move constructor does not match the calculated one}} + E2 &operator=(const E2&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted copy assignment operator does not match the calculated one}} + E2 &operator=(E2&&) noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted move assignment operator does not match the calculated one}} + ~E2() noexcept(false) = default; // expected-error {{exception specification of explicitly defaulted destructor does not match the calculated one}} +}; + +// If a function is explicitly defaulted on its first declaration +// -- it is implicitly considered to have the same exception-specification as +// if it had been implicitly declared +struct E3 { + E3() = default; + E3(const E3&) = default; + E3(E3&&) = default; + E3 &operator=(const E3&) = default; + E3 &operator=(E3&&) = default; + ~E3() = default; +}; +E3 e3; +static_assert(noexcept(E3(), E3(E3()), E3(e3), e3 = E3(), e3 = e3), ""); +struct E4 { + E4() noexcept(false); + E4(const E4&) noexcept(false); + E4(E4&&) noexcept(false); + E4 &operator=(const E4&) noexcept(false); + E4 &operator=(E4&&) noexcept(false); + ~E4() noexcept(false); +}; +struct E5 { + E5() = default; + E5(const E5&) = default; + E5(E5&&) = default; + E5 &operator=(const E5&) = default; + E5 &operator=(E5&&) = default; + ~E5() = default; + + E4 e4; +}; +E5 e5; +static_assert(!noexcept(E5()), ""); +static_assert(!noexcept(E5(static_cast<E5&&>(e5))), ""); +static_assert(!noexcept(E5(e5)), ""); +static_assert(!noexcept(e5 = E5()), ""); +static_assert(!noexcept(e5 = e5), ""); + +namespace PR13492 { + struct B { + B() = default; + }; + + void f() { + const B b; // expected-error {{default initialization of an object of const type 'const PR13492::B' requires a user-provided default constructor}} + } +} diff --git a/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.delete/p4.cpp b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.delete/p4.cpp new file mode 100644 index 000000000000..16fd5e6dbda1 --- /dev/null +++ b/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.delete/p4.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +template<typename> void func(); +template<> void func<int>() = delete; + +template<typename> void func2(); +template<> void func2<int>(); // expected-note {{previous declaration is here}} +template<> void func2<int>() = delete; // expected-error {{deleted definition must be first declaration}} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp index 7764980e34f7..fef3692609fa 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.aggr/p1-0x.cpp @@ -72,7 +72,7 @@ struct DefaultedAggr { DefaultedAggr(const DefaultedAggr &) = default; DefaultedAggr(DefaultedAggr &&) = default; DefaultedAggr &operator=(const DefaultedAggr &) = default; - DefaultedAggr &operator=(DefaultedAggr &) = default; + DefaultedAggr &operator=(DefaultedAggr &&) = default; ~DefaultedAggr() = default; }; DefaultedAggr da = { 42 } ; diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp new file mode 100644 index 000000000000..3450003a6e2d --- /dev/null +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3-0x.cpp @@ -0,0 +1,113 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s + +namespace std { + typedef decltype(sizeof(int)) size_t; + + template <typename E> + struct initializer_list + { + const E *p; + size_t n; + initializer_list(const E *p, size_t n) : p(p), n(n) {} + }; + + struct string { + string(const char *); + }; + + template<typename A, typename B> + struct pair { + pair(const A&, const B&); + }; +} + +namespace bullet2 { + double ad[] = { 1, 2.0 }; + int ai[] = { 1, 2.0 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} + + struct S2 { + int m1; + double m2, m3; + }; + + S2 s21 = { 1, 2, 3.0 }; + S2 s22 { 1.0, 2, 3 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} + S2 s23 { }; +} + +namespace bullet4_example1 { + struct S { + S(std::initializer_list<double> d) {} + S(std::initializer_list<int> i) {} + S() {} + }; + + S s1 = { 1.0, 2.0, 3.0 }; + S s2 = { 1, 2, 3 }; + S s3 = { }; +} + +namespace bullet4_example2 { + struct Map { + Map(std::initializer_list<std::pair<std::string,int>>) {} + }; + + Map ship = {{"Sophie",14}, {"Surprise",28}}; +} + +namespace bullet4_example3 { + struct S { + S(int, double, double) {} + S() {} + }; + + S s1 = { 1, 2, 3.0 }; + // FIXME: This is an ill-formed narrowing initialization. + S s2 { 1.0, 2, 3 }; + S s3 {}; +} + +namespace bullet5 { + struct S { + S(std::initializer_list<double>) {} + S(const std::string &) {} + }; + + const S& r1 = { 1, 2, 3.0 }; + const S& r2 = { "Spinach" }; + S& r3 = { 1, 2, 3 }; // expected-error {{non-const lvalue reference to type 'bullet5::S' cannot bind to an initializer list temporary}} + const int& i1 = { 1 }; + const int& i2 = { 1.1 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} expected-warning {{implicit conversion}} + const int (&iar)[2] = { 1, 2 }; +} + +namespace bullet6 { + int x1 {2}; + int x2 {2.0}; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} +} + +namespace bullet7 { + int** pp {}; +} + +namespace bullet8 { + struct A { int i; int j; }; + A a1 { 1, 2 }; + A a2 { 1.2 }; // expected-error {{type 'double' cannot be narrowed to 'int' in initializer list}} expected-note {{override}} expected-warning {{implicit conversion}} + + struct B { + B(std::initializer_list<int> i) {} + }; + B b1 { 1, 2 }; + B b2 { 1, 2.0 }; + + struct C { + C(int i, double j) {} + }; + C c1 = { 1, 2.2 }; + // FIXME: This is an ill-formed narrowing initialization. + C c2 = { 1.1, 2 }; // expected-warning {{implicit conversion}} + + int j { 1 }; + int k { }; +} diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp index db20ea6426e0..9b1727fd04af 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp @@ -167,6 +167,20 @@ void shrink_int() { Agg<short> ce1 = { Convert<int>(100000) }; // expected-error {{constant expression evaluates to 100000 which cannot be narrowed to type 'short'}} expected-note {{override}} expected-warning {{changes value from 100000 to -31072}} Agg<char> ce2 = { ConvertVar<short>() }; // expected-error {{non-constant-expression cannot be narrowed from type 'short' to 'char'}} expected-note {{override}} + + // Negative -> larger unsigned type. + unsigned long long ll1 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}} + unsigned long long ll2 = { 1 }; // OK + unsigned long long ll3 = { s }; // expected-error {{cannot be narrowed from type 'short'}} expected-note {{override}} + unsigned long long ll4 = { us }; // OK + unsigned long long ll5 = { ll }; // expected-error {{cannot be narrowed from type 'long long'}} expected-note {{override}} + Agg<unsigned long long> ll6 = { -1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}} + Agg<unsigned long long> ll7 = { 18446744073709551615ULL }; // OK + Agg<unsigned long long> ll8 = { __int128(18446744073709551615ULL) + 1 }; // expected-error {{ 18446744073709551616 which cannot be narrowed}} expected-note {{override}} expected-warning {{changes value}} + signed char c = 'x'; + unsigned short usc1 = { c }; // expected-error {{non-constant-expression cannot be narrowed from type 'signed char'}} expected-note {{override}} + unsigned short usc2 = { (signed char)'x' }; // OK + unsigned short usc3 = { (signed char)-1 }; // expected-error {{ -1 which cannot be narrowed}} expected-note {{override}} } // Be sure that type- and value-dependent expressions in templates get the error diff --git a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp index d58a12953e0d..4ba75efebbb3 100644 --- a/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp +++ b/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p5-cxx03-extra-copy.cpp @@ -22,7 +22,7 @@ struct X3 { X3(); private: - X3(X3&); // expected-note{{candidate constructor not viable: no known conversion from 'X3' to 'X3 &' for 1st argument}} + X3(X3&); // expected-note{{candidate constructor not viable: expects an l-value for 1st argument}} }; // Check for instantiation of default arguments diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp new file mode 100644 index 000000000000..21f71f05419c --- /dev/null +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p1.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -std=c++11 -verify %s + +// A function that is explicitly defaulted shall +// [...] +// -- not have default arguments +struct DefArg { + static DefArg &&make(); + DefArg(int n = 5) = default; // expected-error {{an explicitly-defaulted constructor cannot have default arguments}} + DefArg(const DefArg &DA = make()) = default; // expected-error {{an explicitly-defaulted constructor cannot have default arguments}} + DefArg(const DefArg &DA, int k = 3) = default; // expected-error {{an explicitly-defaulted copy constructor cannot have default arguments}} + DefArg(DefArg &&DA = make()) = default; // expected-error {{an explicitly-defaulted constructor cannot have default arguments}} + DefArg(DefArg &&DA, int k = 3) = default; // expected-error {{an explicitly-defaulted move constructor cannot have default arguments}} + DefArg &operator=(const DefArg&, int k = 4) = default; // expected-error {{parameter of overloaded 'operator=' cannot have a default argument}} + DefArg &operator=(DefArg&&, int k = 4) = default; // expected-error {{parameter of overloaded 'operator=' cannot have a default argument}} + ~DefArg(int k = 5) = default; // expected-error {{destructor cannot have any parameters}} +}; diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp index a87982906631..9b5ef788974e 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/dcl.fct.def.default/p2.cpp @@ -14,11 +14,11 @@ namespace move { }; struct AssignmentRet1 { - AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}} + AssignmentRet1&& operator=(AssignmentRet1&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet1 &'}} }; struct AssignmentRet2 { - const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{an explicitly-defaulted move assignment operator must return an unqualified lvalue reference to its class type}} + const AssignmentRet2& operator=(AssignmentRet2&&) = default; // expected-error {{explicitly-defaulted move assignment operator must return 'move::AssignmentRet2 &'}} }; struct ConstAssignment { @@ -38,22 +38,35 @@ namespace copy { }; struct NonConst { - NonConst(NonConst&) = default; - NonConst& operator=(NonConst&) = default; + NonConst(NonConst&) = default; // expected-error {{must be defaulted outside the class}} + NonConst& operator=(NonConst&) = default; // expected-error {{must be defaulted outside the class}} + }; + + struct NonConst2 { + NonConst2(NonConst2&); + NonConst2& operator=(NonConst2&); + }; + NonConst2::NonConst2(NonConst2&) = default; + NonConst2 &NonConst2::operator=(NonConst2&) = default; + + struct NonConst3 { + NonConst3(NonConst3&) = default; + NonConst3& operator=(NonConst3&) = default; + NonConst nc; }; struct BadConst { - NonConst nc; // makes implicit copy non-const BadConst(const BadConst&) = default; // expected-error {{is const, but}} BadConst& operator=(const BadConst&) = default; // expected-error {{is const, but}} + NonConst nc; // makes implicit copy non-const }; struct AssignmentRet1 { - AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}} + AssignmentRet1&& operator=(const AssignmentRet1&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet1 &'}} }; struct AssignmentRet2 { - const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{an explicitly-defaulted copy assignment operator must return an unqualified lvalue reference to its class type}} + const AssignmentRet2& operator=(const AssignmentRet2&) = default; // expected-error {{explicitly-defaulted copy assignment operator must return 'copy::AssignmentRet2 &'}} }; struct ConstAssignment { diff --git a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp index 574a3e7a7934..719aeeddebcc 100644 --- a/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp +++ b/test/CXX/dcl.decl/dcl.meaning/dcl.fct/p9-0x.cpp @@ -1,3 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -auto j() -> enum { e3 }; // expected-error{{unnamed enumeration must be a definition}} expected-error {{requires a specifier or qualifier}} expected-error {{without trailing return type}} +// FIXME: We should catch the case of tag with an incomplete type here (which +// will necessarily be ill-formed as a trailing return type for a function +// definition), and recover with a "type cannot be defined in a trailing return +// type" error. +auto j() -> enum { e3 }; // expected-error{{unnamed enumeration must be a definition}} expected-error {{expected a type}} diff --git a/test/CXX/except/except.spec/p14.cpp b/test/CXX/except/except.spec/p14.cpp index 8763a7028195..4f50afb54887 100644 --- a/test/CXX/except/except.spec/p14.cpp +++ b/test/CXX/except/except.spec/p14.cpp @@ -39,3 +39,27 @@ struct IC1 { // we cannot currently compute the set of thrown types. static_assert(noexcept(IC0()), "IC0() does not throw"); static_assert(!noexcept(IC1()), "IC1() throws"); + +namespace PR13381 { + struct NoThrowMove { + NoThrowMove(const NoThrowMove &); + NoThrowMove(NoThrowMove &&) noexcept; + NoThrowMove &operator=(const NoThrowMove &); + NoThrowMove &operator=(NoThrowMove &&) noexcept; + }; + struct NoThrowMoveOnly { + NoThrowMoveOnly(NoThrowMoveOnly &&) noexcept; + NoThrowMoveOnly &operator=(NoThrowMoveOnly &&) noexcept; + }; + struct X { + const NoThrowMove a; + NoThrowMoveOnly b; + + static X val(); + static X &ref(); + }; + // These both perform a move, but that copy might throw, because it calls + // NoThrowMove's copy constructor (because PR13381::a is const). + static_assert(!noexcept(X(X::val())), ""); + static_assert(!noexcept(X::ref() = X::val()), ""); +} diff --git a/test/CXX/except/except.spec/p5-pointers.cpp b/test/CXX/except/except.spec/p5-pointers.cpp index dd3c0600ce92..f855520aa24d 100644 --- a/test/CXX/except/except.spec/p5-pointers.cpp +++ b/test/CXX/except/except.spec/p5-pointers.cpp @@ -65,9 +65,9 @@ void fnptrs() void (*(*t7)())() throw(B1) = &s8; // valid void (*(*t8)())() throw(A) = &s8; // expected-error {{return types differ}} void (*(*t9)())() throw(D) = &s8; // expected-error {{return types differ}} - void (*t10)(void (*)() throw(B1)) = &s9; // valid expected-warning{{disambiguated}} - void (*t11)(void (*)() throw(A)) = &s9; // expected-error {{argument types differ}} expected-warning{{disambiguated}} - void (*t12)(void (*)() throw(D)) = &s9; // expected-error {{argument types differ}} expected-warning{{disambiguated}} + void (*t10)(void (*)() throw(B1)) = &s9; // valid + void (*t11)(void (*)() throw(A)) = &s9; // expected-error {{argument types differ}} + void (*t12)(void (*)() throw(D)) = &s9; // expected-error {{argument types differ}} } // Member function stuff diff --git a/test/CXX/expr/expr.const/p2-0x.cpp b/test/CXX/expr/expr.const/p2-0x.cpp index 054669ef788d..9e6716d0b8ec 100644 --- a/test/CXX/expr/expr.const/p2-0x.cpp +++ b/test/CXX/expr/expr.const/p2-0x.cpp @@ -131,14 +131,14 @@ namespace IncompleteClassTypeAddr { namespace UndefinedBehavior { void f(int n) { switch (n) { - case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}} + case (int)4.4e9: // expected-error {{constant expression}} expected-note {{value 4.4E+9 is outside the range of representable values of type 'int'}} expected-note {{previous case defined here}} case (int)0x80000000u: // ok case (int)10000000000ll: // expected-note {{here}} case (unsigned int)10000000000ll: // expected-error {{duplicate case value}} case (int)(unsigned)(long long)4.4e9: // ok - case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}} + case (int)(float)1e300: // expected-error {{constant expression}} expected-note {{value 1.0E+300 is outside the range of representable values of type 'float'}} expected-error {{duplicate case value '2147483647'}} expected-note {{previous case defined here}} case (int)((float)1e37 / 1e30): // ok - case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type 'half'}} + case (int)(__fp16)65536: // expected-error {{constant expression}} expected-note {{value 65536 is outside the range of representable values of type 'half'}} expected-error {{duplicate case value '2147483647'}} break; } } diff --git a/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp b/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp index 22892a63ab16..212adc8c2bd4 100644 --- a/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp +++ b/test/CXX/expr/expr.post/expr.reinterpret.cast/p1-0x.cpp @@ -10,7 +10,10 @@ template<typename T> T&& xvalue(); void test_classification(char *ptr) { int (&fr0)(int) = reinterpret_cast<int (&&)(int)>(f); int &&ir0 = reinterpret_cast<int &&>(*ptr); - int &&ir1 = reinterpret_cast<int &&>(0); - int &&ir2 = reinterpret_cast<int &&>('a'); + int &&ir1 = reinterpret_cast<int &&>(0); // expected-error {{rvalue to reference type}} + int &&ir2 = reinterpret_cast<int &&>('a'); // expected-error {{rvalue to reference type}} int &&ir3 = reinterpret_cast<int &&>(xvalue<char>()); + // Per DR1268, reinterpret_cast can convert between lvalues and xvalues. + int &ir4 = reinterpret_cast<int &>(xvalue<char>()); + int &&ir5 = reinterpret_cast<int &&>(*ptr); } diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm new file mode 100644 index 000000000000..9f9867106930 --- /dev/null +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks-irgen.mm @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 -std=c++11 -fblocks -emit-llvm -o - -triple x86_64-apple-darwin11.3 %s | FileCheck %s + +namespace PR12746 { + // CHECK: define zeroext i1 @_ZN7PR127462f1EPi + bool f1(int *x) { + // CHECK: store i8* bitcast (i1 (i8*)* @___ZN7PR127462f1EPi_block_invoke to i8*) + bool (^outer)() = ^ { + auto inner = [&]() -> bool { + return x == 0; + }; + return inner(); + }; + return outer(); + } + + // CHECK: define internal zeroext i1 @___ZN7PR127462f1EPi_block_invoke + // CHECK: call zeroext i1 @"_ZNK7PR127462f132___ZN7PR127462f1EPi_block_invoke3$_0clEv" + + bool f2(int *x) { + auto outer = [&]() -> bool { + bool (^inner)() = ^ { + return x == 0; + }; + return inner(); + }; + return outer(); + } +} + diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm index 0c3fdb2d80eb..0db2bf5646ff 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/blocks.mm @@ -86,3 +86,41 @@ namespace overloading { int &ir = accept_lambda_conv([](int x) { return x + 1; }); } } + +namespace PR13117 { + struct A { + template<typename ... Args> static void f(Args...); + + template<typename ... Args> static void f1() + { + (void)^(Args args) { // expected-error{{block contains unexpanded parameter pack 'Args'}} + }; + } + + template<typename ... Args> static void f2() + { + // FIXME: Allow this. + f( + ^(Args args) // expected-error{{block contains unexpanded parameter pack 'Args'}} + { } + ... // expected-error{{pack expansion does not contain any unexpanded parameter packs}} + ); + } + + template<typename ... Args> static void f3() + { + (void)[](Args args) { // expected-error{{expression contains unexpanded parameter pack 'Args'}} + }; + } + + template<typename ... Args> static void f4() + { + f([](Args args) { } ...); + } + }; + + void g() { + A::f1<int, int>(); + A::f2<int, int>(); + } +} diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp index 174db257c891..82fc04a48fb6 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p23.cpp @@ -9,8 +9,8 @@ void print(T first, Ts... rest) { } template<typename... Ts> -void unsupported(Ts ...values) { - auto unsup = [values] {}; // expected-error{{unexpanded function parameter pack capture is unsupported}} +void unexpanded_capture(Ts ...values) { + auto unexp = [values] {}; // expected-error{{initializer contains unexpanded parameter pack 'values'}} } template<typename... Ts> diff --git a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp index d816e1702a6d..f580e7e4c46f 100644 --- a/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp +++ b/test/CXX/expr/expr.prim/expr.prim.lambda/p4.cpp @@ -25,7 +25,7 @@ void infer_void_return_type(int i) { struct X { }; X infer_X_return_type(X x) { - return [&x](int y) { // expected-warning{{omitted result type}} + return [&x](int y) { if (y > 0) return X(); else @@ -33,11 +33,11 @@ X infer_X_return_type(X x) { }(5); } -X infer_X_return_type_fail(X x) { - return [x](int y) { // expected-warning{{omitted result type}} +X infer_X_return_type_fail(X x) { + return [x](int y) { if (y > 0) return X(); - else + else return x; // expected-error{{return type 'const X' must match previous return type 'X' when lambda expression has unspecified explicit return type}} }(5); } diff --git a/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp b/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp index ac11940c80da..2646264273eb 100644 --- a/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp +++ b/test/CXX/expr/expr.unary/expr.unary.op/p6.cpp @@ -4,7 +4,7 @@ bool b = !0; -bool b2 = !1.2; +bool b2 = !1.2; //expected-warning{{implicit conversion from 'double' to 'bool' changes value from 1.2 to true}} bool b3 = !4; diff --git a/test/CXX/expr/p10-0x.cpp b/test/CXX/expr/p10-0x.cpp new file mode 100644 index 000000000000..564df8843a57 --- /dev/null +++ b/test/CXX/expr/p10-0x.cpp @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -emit-llvm -triple x86_64-pc-linux-gnu %s -o - -std=c++11 | FileCheck %s + +volatile int g1; +struct S { + volatile int a; +} g2; + +volatile int& refcall(); + +// CHECK: define void @_Z2f1PViPV1S +void f1(volatile int *x, volatile S* s) { + // We should perform the load in these cases. + // CHECK: load volatile i32* + (*x); + // CHECK: load volatile i32* + __extension__ g1; + // CHECK: load volatile i32* + s->a; + // CHECK: load volatile i32* + g2.a; + // CHECK: load volatile i32* + s->*(&S::a); + // CHECK: load volatile i32* + // CHECK: load volatile i32* + x[0], 1 ? x[0] : *x; + + // CHECK: load volatile i32* + // CHECK: load volatile i32* + // CHECK: load volatile i32* + *x ?: *x; + + // CHECK: load volatile i32* + ({ *x; }); + + // CHECK-NOT: load volatile + // CHECK: ret +} + +// CHECK: define void @_Z2f2PVi +// CHECK-NOT: load volatile +// CHECK: ret +void f2(volatile int *x) { + // We shouldn't perform the load in these cases. + refcall(); + 1 ? refcall() : *x; +} diff --git a/test/CXX/special/class.conv/class.conv.ctor/p1.cpp b/test/CXX/special/class.conv/class.conv.ctor/p1.cpp new file mode 100644 index 000000000000..d2add82f420f --- /dev/null +++ b/test/CXX/special/class.conv/class.conv.ctor/p1.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +namespace PR13003 { + struct void_type + { + template <typename Arg0, typename... Args> + void_type(Arg0&&, Args&&...) { } + }; + + struct void_type2 + { + template <typename... Args> + void_type2(Args&&...) { } + }; + + struct atom { }; + + void_type v1 = atom(); + void_type2 v2 = atom(); +} + diff --git a/test/CXX/special/class.copy/implicit-move.cpp b/test/CXX/special/class.copy/implicit-move.cpp index 3e9accfbf6a7..597e327a414d 100644 --- a/test/CXX/special/class.copy/implicit-move.cpp +++ b/test/CXX/special/class.copy/implicit-move.cpp @@ -234,3 +234,10 @@ namespace DR1402 { friend NoMove11 &NoMove11::operator=(NoMove11 &&); // expected-error {{no matching function}} }; } + +namespace PR12625 { + struct X; // expected-note {{forward decl}} + struct Y { + X x; // expected-error {{incomplete}} + } y = Y(); +} diff --git a/test/CXX/special/class.copy/p11.0x.copy.cpp b/test/CXX/special/class.copy/p11.0x.copy.cpp index b2b4f6a87f7c..fab3b9dd7bf1 100644 --- a/test/CXX/special/class.copy/p11.0x.copy.cpp +++ b/test/CXX/special/class.copy/p11.0x.copy.cpp @@ -8,7 +8,7 @@ struct NonTrivial { // -- a variant member with a non-trivial corresponding constructor union DeletedNTVariant { - NonTrivial NT; // expected-note{{copy constructor of union 'DeletedNTVariant' is implicitly deleted because field 'NT' has a non-trivial copy constructor}} + NonTrivial NT; // expected-note{{copy constructor of 'DeletedNTVariant' is implicitly deleted because variant field 'NT' has a non-trivial copy constructor}} DeletedNTVariant(); }; DeletedNTVariant DVa; @@ -16,7 +16,7 @@ DeletedNTVariant DVb(DVa); // expected-error{{call to implicitly-deleted copy co struct DeletedNTVariant2 { union { - NonTrivial NT; // expected-note{{copy constructor of union 'DeletedNTVariant2' is implicitly deleted because field 'NT' has a non-trivial copy constructor}} + NonTrivial NT; // expected-note{{copy constructor of 'DeletedNTVariant2' is implicitly deleted because variant field 'NT' has a non-trivial copy constructor}} }; DeletedNTVariant2(); }; @@ -119,3 +119,15 @@ struct RValue { }; RValue RVa; RValue RVb(RVa); // expected-error{{call to implicitly-deleted copy constructor}} + +namespace PR13381 { + struct S { + S(const S&); + S(const volatile S&) = delete; // expected-note{{deleted here}} + }; + struct T { + volatile S s; // expected-note{{field 's' has a deleted copy constructor}} + }; + T &f(); + T t = f(); // expected-error{{call to implicitly-deleted copy constructor}} +} diff --git a/test/CXX/special/class.copy/p13-0x.cpp b/test/CXX/special/class.copy/p13-0x.cpp index 0a9aa6214594..5d436016a056 100644 --- a/test/CXX/special/class.copy/p13-0x.cpp +++ b/test/CXX/special/class.copy/p13-0x.cpp @@ -58,3 +58,59 @@ struct Constexpr5Base {}; struct Constexpr5 : Constexpr5Base { constexpr Constexpr5() {} }; constexpr Constexpr5 ce5move = Constexpr5(); constexpr Constexpr5 ce5copy = ce5move; + +// An explicitly-defaulted constructor doesn't become constexpr until the end of +// its class. Make sure we note that the class has a constexpr constructor when +// that happens. +namespace PR13052 { + template<typename T> struct S { + S() = default; // expected-note 2{{here}} + S(S&&) = default; + S(const S&) = default; + T t; + }; + + struct U { + U() = default; + U(U&&) = default; + U(const U&) = default; + }; + + struct V { + V(); // expected-note {{here}} + V(V&&) = default; + V(const V&) = default; + }; + + struct W { + W(); // expected-note {{here}} + }; + + static_assert(__is_literal_type(U), ""); + static_assert(!__is_literal_type(V), ""); + static_assert(!__is_literal_type(W), ""); + static_assert(__is_literal_type(S<U>), ""); + static_assert(!__is_literal_type(S<V>), ""); + static_assert(!__is_literal_type(S<W>), ""); + + struct X { + friend constexpr U::U() noexcept; + friend constexpr U::U(U&&) noexcept; + friend constexpr U::U(const U&) noexcept; + friend constexpr V::V(); // expected-error {{follows non-constexpr declaration}} + friend constexpr V::V(V&&) noexcept; + friend constexpr V::V(const V&) noexcept; + friend constexpr W::W(); // expected-error {{follows non-constexpr declaration}} + friend constexpr W::W(W&&) noexcept; + friend constexpr W::W(const W&) noexcept; + friend constexpr S<U>::S() noexcept; + friend constexpr S<U>::S(S<U>&&) noexcept; + friend constexpr S<U>::S(const S<U>&) noexcept; + friend constexpr S<V>::S(); // expected-error {{follows non-constexpr declaration}} + friend constexpr S<V>::S(S<V>&&) noexcept; + friend constexpr S<V>::S(const S<V>&) noexcept; + friend constexpr S<W>::S(); // expected-error {{follows non-constexpr declaration}} + friend constexpr S<W>::S(S<W>&&) noexcept; + friend constexpr S<W>::S(const S<W>&) noexcept; + }; +} diff --git a/test/CXX/special/class.copy/p15-inclass.cpp b/test/CXX/special/class.copy/p15-inclass.cpp index c4f8eafd937c..6cfa94fafad5 100644 --- a/test/CXX/special/class.copy/p15-inclass.cpp +++ b/test/CXX/special/class.copy/p15-inclass.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -std=c++11 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm -o - %s | FileCheck %s namespace PR11418 { struct NonPOD { diff --git a/test/CXX/special/class.copy/p23-cxx11.cpp b/test/CXX/special/class.copy/p23-cxx11.cpp new file mode 100644 index 000000000000..7c04a8201804 --- /dev/null +++ b/test/CXX/special/class.copy/p23-cxx11.cpp @@ -0,0 +1,148 @@ +// RUN: %clang_cc1 -verify %s -std=c++11 + +template<typename T> struct CopyAssign { + static T t; + void test() { + t = t; // expected-error +{{deleted}} + } +}; +template<typename T> struct MoveAssign { + static T t; + void test() { + t = static_cast<T&&>(t); // expected-error +{{deleted}} + } +}; + +struct NonTrivialCopyAssign { + NonTrivialCopyAssign &operator=(const NonTrivialCopyAssign &); +}; +struct NonTrivialMoveAssign { + NonTrivialMoveAssign &operator=(NonTrivialMoveAssign &&); +}; +struct AmbiguousCopyAssign { + AmbiguousCopyAssign &operator=(const AmbiguousCopyAssign &); + AmbiguousCopyAssign &operator=(volatile AmbiguousCopyAssign &); +}; +struct AmbiguousMoveAssign { + AmbiguousMoveAssign &operator=(const AmbiguousMoveAssign &&); + AmbiguousMoveAssign &operator=(volatile AmbiguousMoveAssign &&); +}; +struct DeletedCopyAssign { + DeletedCopyAssign &operator=(const DeletedCopyAssign &) = delete; // expected-note 2{{deleted}} +}; +struct DeletedMoveAssign { + DeletedMoveAssign &operator=(DeletedMoveAssign &&) = delete; // expected-note 2{{deleted}} +}; +class InaccessibleCopyAssign { + InaccessibleCopyAssign &operator=(const InaccessibleCopyAssign &); +}; +class InaccessibleMoveAssign { + InaccessibleMoveAssign &operator=(InaccessibleMoveAssign &&); +}; + +// A defaulted copy/move assignment operator for class X is defined as deleted +// if X has: + +// -- a variant member with a non-trivial corresponding assignment operator +// and X is a union-like class +struct A1 { + union { + NonTrivialCopyAssign x; // expected-note {{variant field 'x' has a non-trivial copy assign}} + }; +}; +template struct CopyAssign<A1>; // expected-note {{here}} + +struct A2 { + A2 &operator=(A2 &&) = default; // expected-note {{here}} + union { + NonTrivialMoveAssign x; // expected-note {{variant field 'x' has a non-trivial move assign}} + }; +}; +template struct MoveAssign<A2>; // expected-note {{here}} + +// -- a non-static const data member of (array of) non-class type +struct B1 { + const int a; // expected-note 2{{field 'a' is of const-qualified type}} +}; +struct B2 { + const void *const a[3][9][2]; // expected-note 2{{field 'a' is of const-qualified type 'const void *const [3][9][2]'}} +}; +struct B3 { + const void *a[3]; +}; +template struct CopyAssign<B1>; // expected-note {{here}} +template struct MoveAssign<B1>; // expected-note {{here}} +template struct CopyAssign<B2>; // expected-note {{here}} +template struct MoveAssign<B2>; // expected-note {{here}} +template struct CopyAssign<B3>; +template struct MoveAssign<B3>; + +// -- a non-static data member of reference type +struct C1 { + int &a; // expected-note 2{{field 'a' is of reference type 'int &'}} +}; +template struct CopyAssign<C1>; // expected-note {{here}} +template struct MoveAssign<C1>; // expected-note {{here}} + +// -- a non-static data member of class type M that cannot be copied/moved +struct D1 { + AmbiguousCopyAssign a; // expected-note {{field 'a' has multiple copy}} +}; +struct D2 { + D2 &operator=(D2 &&) = default; // expected-note {{here}} + AmbiguousMoveAssign a; // expected-note {{field 'a' has multiple move}} +}; +struct D3 { + DeletedCopyAssign a; // expected-note {{field 'a' has a deleted copy}} +}; +struct D4 { + D4 &operator=(D4 &&) = default; // expected-note {{here}} + DeletedMoveAssign a; // expected-note {{field 'a' has a deleted move}} +}; +struct D5 { + InaccessibleCopyAssign a; // expected-note {{field 'a' has an inaccessible copy}} +}; +struct D6 { + D6 &operator=(D6 &&) = default; // expected-note {{here}} + InaccessibleMoveAssign a; // expected-note {{field 'a' has an inaccessible move}} +}; +template struct CopyAssign<D1>; // expected-note {{here}} +template struct MoveAssign<D2>; // expected-note {{here}} +template struct CopyAssign<D3>; // expected-note {{here}} +template struct MoveAssign<D4>; // expected-note {{here}} +template struct CopyAssign<D5>; // expected-note {{here}} +template struct MoveAssign<D6>; // expected-note {{here}} + +// -- a direct or virtual base that cannot be copied/moved +struct E1 : AmbiguousCopyAssign {}; // expected-note {{base class 'AmbiguousCopyAssign' has multiple copy}} +struct E2 : AmbiguousMoveAssign { // expected-note {{base class 'AmbiguousMoveAssign' has multiple move}} + E2 &operator=(E2 &&) = default; // expected-note {{here}} +}; +struct E3 : DeletedCopyAssign {}; // expected-note {{base class 'DeletedCopyAssign' has a deleted copy}} +struct E4 : DeletedMoveAssign { // expected-note {{base class 'DeletedMoveAssign' has a deleted move}} + E4 &operator=(E4 &&) = default; // expected-note {{here}} +}; +struct E5 : InaccessibleCopyAssign {}; // expected-note {{base class 'InaccessibleCopyAssign' has an inaccessible copy}} +struct E6 : InaccessibleMoveAssign { // expected-note {{base class 'InaccessibleMoveAssign' has an inaccessible move}} + E6 &operator=(E6 &&) = default; // expected-note {{here}} +}; +template struct CopyAssign<E1>; // expected-note {{here}} +template struct MoveAssign<E2>; // expected-note {{here}} +template struct CopyAssign<E3>; // expected-note {{here}} +template struct MoveAssign<E4>; // expected-note {{here}} +template struct CopyAssign<E5>; // expected-note {{here}} +template struct MoveAssign<E6>; // expected-note {{here}} + +namespace PR13381 { + struct S { + S &operator=(const S&); + S &operator=(const volatile S&) = delete; // expected-note{{deleted here}} + }; + struct T { + volatile S s; // expected-note{{field 's' has a deleted copy assignment}} + }; + void g() { + T t; + t = T(); // expected-error{{implicitly-deleted copy assignment}} + } +} diff --git a/test/CXX/special/class.copy/p8-cxx11.cpp b/test/CXX/special/class.copy/p8-cxx11.cpp index 02e6cd1c9ab6..a2613f461298 100644 --- a/test/CXX/special/class.copy/p8-cxx11.cpp +++ b/test/CXX/special/class.copy/p8-cxx11.cpp @@ -43,6 +43,6 @@ struct Test { friend C::C(C &); friend D::D(const D &); friend E::E(E &); - friend F::F(const F &); + constexpr friend F::F(const F &); friend G::G(G &); }; diff --git a/test/CXX/special/class.ctor/p5-0x.cpp b/test/CXX/special/class.ctor/p5-0x.cpp index 694ab5b17535..1aaeef282ae7 100644 --- a/test/CXX/special/class.ctor/p5-0x.cpp +++ b/test/CXX/special/class.ctor/p5-0x.cpp @@ -21,7 +21,7 @@ int n; // - X is a union-like class that has a variant member with a non-trivial // default constructor, -union Deleted1a { UserProvidedDefCtor u; }; // expected-note {{default constructor of union 'Deleted1a' is implicitly deleted because field 'u' has a non-trivial default constructor}} +union Deleted1a { UserProvidedDefCtor u; }; // expected-note {{default constructor of 'Deleted1a' is implicitly deleted because variant field 'u' has a non-trivial default constructor}} Deleted1a d1a; // expected-error {{implicitly-deleted default constructor}} union NotDeleted1a { DefaultedDefCtor1 nu; }; NotDeleted1a nd1a; @@ -53,7 +53,7 @@ class Deleted3a { const int a; }; // expected-note {{because field 'a' of const- expected-warning {{does not declare any constructor}} \ expected-note {{will never be initialized}} Deleted3a d3a; // expected-error {{implicitly-deleted default constructor}} -class Deleted3b { const DefaultedDefCtor1 a[42]; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor1' would not be initialized}} +class Deleted3b { const DefaultedDefCtor1 a[42]; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor1 [42]' would not be initialized}} Deleted3b d3b; // expected-error {{implicitly-deleted default constructor}} class Deleted3c { const DefaultedDefCtor2 a; }; // expected-note {{because field 'a' of const-qualified type 'const DefaultedDefCtor2' would not be initialized}} Deleted3c d3c; // expected-error {{implicitly-deleted default constructor}} @@ -77,7 +77,7 @@ NotDeleted3g nd3g; union Deleted4a { const int a; const int b; - const UserProvidedDefCtor c; // expected-note {{because field 'c' has a non-trivial default constructor}} + const UserProvidedDefCtor c; // expected-note {{because variant field 'c' has a non-trivial default constructor}} }; Deleted4a d4a; // expected-error {{implicitly-deleted default constructor}} union NotDeleted4a { const int a; int b; }; diff --git a/test/CXX/special/class.ctor/p6-0x.cpp b/test/CXX/special/class.ctor/p6-0x.cpp index 8c8800f2de45..9860317aa122 100644 --- a/test/CXX/special/class.ctor/p6-0x.cpp +++ b/test/CXX/special/class.ctor/p6-0x.cpp @@ -55,3 +55,42 @@ struct A {}; // expected-note {{here}} struct B { friend A::A(); // expected-error {{non-constexpr declaration of 'A' follows constexpr declaration}} }; + +namespace UnionCtors { + union A { // expected-note {{here}} + int a; + int b; + }; + union B { + int a; + int b = 5; + }; + union C { + int a = 5; + int b; + }; + struct D { + union { + int a = 5; + int b; + }; + union { + int c; + int d = 5; + }; + }; + struct E { // expected-note {{here}} + union { + int a; + int b; + }; + }; + + struct Test { + friend constexpr A::A() noexcept; // expected-error {{follows non-constexpr declaration}} + friend constexpr B::B() noexcept; + friend constexpr C::C() noexcept; + friend constexpr D::D() noexcept; + friend constexpr E::E() noexcept; // expected-error {{follows non-constexpr declaration}} + }; +} diff --git a/test/CXX/special/class.dtor/p5-0x.cpp b/test/CXX/special/class.dtor/p5-0x.cpp index dbfa00444075..0d073cea529e 100644 --- a/test/CXX/special/class.dtor/p5-0x.cpp +++ b/test/CXX/special/class.dtor/p5-0x.cpp @@ -16,25 +16,25 @@ class InaccessibleDtor { // destructor. union A1 { A1(); - NonTrivDtor n; // expected-note {{destructor of union 'A1' is implicitly deleted because field 'n' has a non-trivial destructor}} + NonTrivDtor n; // expected-note {{destructor of 'A1' is implicitly deleted because variant field 'n' has a non-trivial destructor}} }; A1 a1; // expected-error {{deleted function}} struct A2 { A2(); union { - NonTrivDtor n; // expected-note {{because field 'n' has a non-trivial destructor}} + NonTrivDtor n; // expected-note {{because variant field 'n' has a non-trivial destructor}} }; }; A2 a2; // expected-error {{deleted function}} union A3 { A3(); - NonTrivDtor n[3]; // expected-note {{because field 'n' has a non-trivial destructor}} + NonTrivDtor n[3]; // expected-note {{because variant field 'n' has a non-trivial destructor}} }; A3 a3; // expected-error {{deleted function}} struct A4 { A4(); union { - NonTrivDtor n[3]; // expected-note {{because field 'n' has a non-trivial destructor}} + NonTrivDtor n[3]; // expected-note {{because variant field 'n' has a non-trivial destructor}} }; }; A4 a4; // expected-error {{deleted function}} diff --git a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp index a45b35f71592..96bb47212274 100644 --- a/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp +++ b/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp @@ -1,5 +1,13 @@ // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s +struct pr12960 { + int begin; + void foo(int x) { + for (int& it : x) { // expected-error {{use of undeclared identifier 'begin'}} expected-note {{range has type 'int'}} + } + } +}; + namespace std { template<typename T> auto begin(T &&t) -> decltype(t.begin()) { return t.begin(); } // expected-note 4{{ignored: substitution failure}} @@ -207,3 +215,4 @@ void example() { for (int &x : array) x *= 2; } + diff --git a/test/CXX/temp/temp.decls/temp.friend/p1.cpp b/test/CXX/temp/temp.decls/temp.friend/p1.cpp index 63f569be0861..640d03d4c96f 100644 --- a/test/CXX/temp/temp.decls/temp.friend/p1.cpp +++ b/test/CXX/temp/temp.decls/temp.friend/p1.cpp @@ -302,6 +302,7 @@ namespace test14 { }; template <class T> class B { + public: void foo() { return A<long>::foo(); } // expected-error {{'foo' is a private member of 'test14::A<long>'}} }; @@ -320,10 +321,12 @@ namespace test15 { }; template <class T> class B { + public: void foo() { return A<long>::foo(); } // expected-error {{'foo' is a private member of 'test15::A<long>'}} }; template <> class B<float> { + public: void foo() { return A<float>::foo(); } template <class U> void bar(U u) { (void) A<float>::foo(); diff --git a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp index 21aa24fb522d..485068e6486a 100644 --- a/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp +++ b/test/CXX/temp/temp.decls/temp.variadic/multi-level-substitution.cpp @@ -249,3 +249,46 @@ namespace PR10230 { int (&ir3)[3] = s<int>().f<int, float, double>(); } } + +namespace PR13386 { + template<typename...> struct tuple {}; + template<typename...T> + struct S { + template<typename...U> + void f(T &&...t, U &&...u) {} // expected-note {{candidate}} + template<typename...U> + void g(U &&...u, T &&...t) {} // expected-note {{candidate}} + template<typename...U> + void h(tuple<T, U> &&...) {} // expected-note 2{{candidate}} + + template<typename...U> + struct X { + template<typename...V> + void x(tuple<T, U, V> &&...); // expected-error {{different lengths}} + }; + }; + + void test() { + S<>().f(); + S<>().f(0); + S<int>().f(0); + S<int>().f(0, 1); + S<int, int>().f(0); // expected-error {{no matching member function for call}} + + S<>().g(); + S<>().g(0); + S<int>().g(0); + S<int>().g(0, 1); // expected-error {{no matching member function for call}} + S<int>().g<int>(0, 1); + S<int, int>().g(0, 1); + + S<>().h(); + S<>().h(0); // expected-error {{no matching member function for call}} + S<int>().h({}); // expected-error {{no matching member function for call}} + S<int>().h<int>({}); + S<int>().h(tuple<int,int>{}); + S<int, int>().h(tuple<int,int>{}, tuple<int,int>{}); + + S<int, int>::X<char>(); // expected-note {{here}} + } +} diff --git a/test/CXX/temp/temp.names/p3-0x.cpp b/test/CXX/temp/temp.names/p3-0x.cpp new file mode 100644 index 000000000000..85dc75e30199 --- /dev/null +++ b/test/CXX/temp/temp.names/p3-0x.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +template<int i> class X { /* ... */ }; +X< 1>2 > x1; // expected-error{{expected unqualified-id}} +X<(1>2)> x2; // OK +template<class T> class Y { /* ... */ }; +Y<X<1>> x3; // OK, same as Y<X<1> > x3; +Y<X<6>>1>> x4; // expected-error{{expected unqualified-id}} +Y<X<(6>>1)>> x5; + +int a, b; +Y<decltype(a < b)> x6; diff --git a/test/CXX/temp/temp.spec/p5.cpp b/test/CXX/temp/temp.spec/p5.cpp index 0e69a26b04e2..ba92d41e3e8e 100644 --- a/test/CXX/temp/temp.spec/p5.cpp +++ b/test/CXX/temp/temp.spec/p5.cpp @@ -14,7 +14,7 @@ struct X0 { }; template<typename T> -T X0<T>::value = 3.14; // expected-warning{{implicit conversion turns literal floating-point number into integer}} +T X0<T>::value = 3.14; // expected-warning{{implicit conversion from 'double' to 'int' changes value from 3.14 to 3}} template struct X0<int>; // expected-note{{previous explicit instantiation}} \ expected-note{{requested here}} diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp index 121cb8eedf2f..aba9d3640801 100644 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp +++ b/test/CXX/temp/temp.spec/temp.expl.spec/p14.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s template<class T> void f(T) { /* ... */ } template<class T> inline void g(T) { /* ... */ } diff --git a/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp b/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp index 84841cb60f4d..c8b7def5a448 100644 --- a/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp +++ b/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp @@ -1,10 +1,14 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s namespace N { - template<class T> class X; + template<class T> class X; // expected-note {{'N::X' declared here}} \ + // expected-note {{explicitly specialized declaration is here}} } -template<> class X<int> { /* ... */ }; // expected-error {{non-template class 'X'}} +// TODO: Don't add a namespace qualifier to the template if it would trigger +// the warning about the specialization being outside of the namespace. +template<> class X<int> { /* ... */ }; // expected-error {{no template named 'X'; did you mean 'N::X'?}} \ + // expected-warning {{first declaration of class template specialization of 'X' outside namespace 'N' is a C++11 extension}} namespace N { diff --git a/test/CXX/temp/temp.spec/temp.explicit/p12.cpp b/test/CXX/temp/temp.spec/temp.explicit/p12.cpp index c7564868f8ad..9518a0b077b7 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p12.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p12.cpp @@ -1,6 +1,49 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -char* p = 0; -template<class T> T g(T x = &p) { return x; } -template int g<int>(int); // OK even though &p isn't an int. +namespace test0 { + char* p = 0; + template<class T> T g(T x = &p) { return x; } + template int g<int>(int); // OK even though &p isn't an int. +} +// Don't impose access restrictions on explicit instantiations. +namespace test1 { + class A { + class Private {}; + public: + typedef Private Public; + }; + + template <class T> class Temp { + static Temp<A::Public> make() { return Temp<A::Public>(); } + }; + template class Temp<A::Private>; + + // FIXME: this ought to be an error, but it isn't because Sema is + // silently failing to create a declaration for the explicit + // instantiation. + template class Temp<A::Private> Temp<int>::make(); +} + +// Don't impose access restrictions on explicit specializations, +// either. This goes here because it's an extension of the rule for +// explicit instantiations and doesn't have any independent support. +namespace test2 { + class A { + class Private {}; // expected-note {{implicitly declared private here}} + public: + typedef Private Public; + }; + + template <class T> class Temp { + static Temp<A::Public> make(); + }; + template <> class Temp<A::Private> { + public: + Temp(int x) {} + }; + + template <> class Temp<A::Private> Temp<int>::make() { // expected-error {{'Private' is a private member of 'test2::A'}} + return Temp<A::Public>(0); + } +} diff --git a/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp b/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp index 04e7df5741e2..ff24ad997dfd 100644 --- a/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp +++ b/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -O1 -emit-llvm -std=c++11 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -emit-llvm -std=c++11 -o - %s | FileCheck %s template<typename T> struct X0 { diff --git a/test/CodeCompletion/auto.cpp b/test/CodeCompletion/auto.cpp new file mode 100644 index 000000000000..1fc9fb035d47 --- /dev/null +++ b/test/CodeCompletion/auto.cpp @@ -0,0 +1,2 @@ +// RUN: %clang_cc1 -std=c++11 -code-completion-at=%s:2:9 %s +auto i = diff --git a/test/CodeCompletion/documentation.cpp b/test/CodeCompletion/documentation.cpp new file mode 100644 index 000000000000..c049ae3733b5 --- /dev/null +++ b/test/CodeCompletion/documentation.cpp @@ -0,0 +1,33 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +/// Aaa. +void T1(float x, float y); + +/// Bbb. +class T2 { +public: + /// Ccc. + void T3(); + + int T4; ///< Ddd. +}; + +/// Eee. +namespace T5 { +} + +void test() { + + T2 t2; + t2. +} + +// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:21:1 %s -o - | FileCheck -check-prefix=CC1 %s +// CHECK-CC1: COMPLETION: T1 : [#void#]T1(<#float x#>, <#float y#>) : Aaa. +// CHECK-CC1: COMPLETION: T2 : T2 : Bbb. +// CHECK-CC1: COMPLETION: T5 : T5:: : Eee. + +// RUN: %clang_cc1 -fsyntax-only -code-completion-brief-comments -code-completion-at=%s:23:6 %s -o - | FileCheck -check-prefix=CC2 %s +// CHECK-CC2: COMPLETION: T3 : [#void#]T3() : Ccc. +// CHECK-CC2: COMPLETION: T4 : [#int#]T4 : Ddd. diff --git a/test/CodeCompletion/objc-expr.m b/test/CodeCompletion/objc-expr.m new file mode 100644 index 000000000000..b59586ab96cf --- /dev/null +++ b/test/CodeCompletion/objc-expr.m @@ -0,0 +1,17 @@ +// Note: the run lines follow all tests, since line/column matter here + +id testCompleteAfterAtSign() { + return @""; +} + +// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:4:11 %s -fno-const-strings -o - | FileCheck -check-prefix=AT %s +// CHECK-AT: COMPLETION: Pattern : [#NSString *#]"<#string#>" +// CHECK-AT: COMPLETION: Pattern : [#id#](<#expression#>) +// CHECK-AT: COMPLETION: Pattern : [#NSArray *#][<#objects, ...#>] +// CHECK-AT: COMPLETION: Pattern : [#char[]#]encode(<#type-name#>) +// CHECK-AT: COMPLETION: Pattern : [#Protocol *#]protocol(<#protocol-name#>) +// CHECK-AT: COMPLETION: Pattern : [#SEL#]selector(<#selector#>) +// CHECK-AT: COMPLETION: Pattern : [#NSDictionary *#]{<#key#> : <#object, ...#>} + +// RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:4:11 %s -fconst-strings -o - | FileCheck -check-prefix=CONST-STRINGS %s +// CHECK-CONST-STRINGS: COMPLETION: Pattern : [#const char[]#]encode(<#type-name#>) diff --git a/test/CodeGen/2005-07-20-SqrtNoErrno.c b/test/CodeGen/2005-07-20-SqrtNoErrno.c index f40f61d27f31..96761e4cfb2e 100644 --- a/test/CodeGen/2005-07-20-SqrtNoErrno.c +++ b/test/CodeGen/2005-07-20-SqrtNoErrno.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s // llvm.sqrt has undefined behavior on negative inputs, so it is // inappropriate to translate C/C++ sqrt to this. float sqrtf(float x); diff --git a/test/CodeGen/2007-02-25-C-DotDotDot.c b/test/CodeGen/2007-02-25-C-DotDotDot.c index 7b2e418f4918..abc46683cee9 100644 --- a/test/CodeGen/2007-02-25-C-DotDotDot.c +++ b/test/CodeGen/2007-02-25-C-DotDotDot.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -O0 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -O0 %s -emit-llvm -o - | FileCheck %s // Make sure the call to foo is compiled as: // call float @foo() diff --git a/test/CodeGen/2008-01-25-ByValReadNone.c b/test/CodeGen/2008-01-25-ByValReadNone.c index 06ad1eef00f1..d977139b2120 100644 --- a/test/CodeGen/2008-01-25-ByValReadNone.c +++ b/test/CodeGen/2008-01-25-ByValReadNone.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -emit-llvm -o - %s | not grep readonly // RUN: %clang_cc1 -emit-llvm -o - %s | not grep readnone -// XFAIL: arm +// XFAIL: arm,mips // The struct being passed byval means that we cannot mark the // function readnone. Readnone would allow stores to the arg to diff --git a/test/CodeGen/2008-03-05-syncPtr.c b/test/CodeGen/2008-03-05-syncPtr.c index 784295ce6890..93f328a57949 100644 --- a/test/CodeGen/2008-03-05-syncPtr.c +++ b/test/CodeGen/2008-03-05-syncPtr.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s int* foo(int** a, int* b, int* c) { return __sync_val_compare_and_swap (a, b, c); diff --git a/test/CodeGen/2008-04-08-NoExceptions.c b/test/CodeGen/2008-04-08-NoExceptions.c index 6d5d20ff8541..ab2781b58b9c 100644 --- a/test/CodeGen/2008-04-08-NoExceptions.c +++ b/test/CodeGen/2008-04-08-NoExceptions.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s void f(void); void g(void) { diff --git a/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c b/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c index 8787bd453e65..2bcc7c3933ff 100644 --- a/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c +++ b/test/CodeGen/2009-02-13-zerosize-union-field-ppc.c @@ -1,3 +1,4 @@ +// REQUIRES: ppc32-registered-target // RUN: %clang_cc1 %s -triple powerpc-pc-linux -emit-llvm -o - | grep {i32 32} | count 3 // XFAIL: * // Every printf has 'i32 0' for the GEP of the string; no point counting those. diff --git a/test/CodeGen/2009-09-24-SqrtErrno.c b/test/CodeGen/2009-09-24-SqrtErrno.c index b4a04ff6b6ab..6a3396791fac 100644 --- a/test/CodeGen/2009-09-24-SqrtErrno.c +++ b/test/CodeGen/2009-09-24-SqrtErrno.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - -fmath-errno | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fmath-errno | FileCheck %s // llvm.sqrt has undefined behavior on negative inputs, so it is // inappropriate to translate C/C++ sqrt to this. diff --git a/test/CodeGen/2009-10-20-GlobalDebug.c b/test/CodeGen/2009-10-20-GlobalDebug.c index 8828eef40d65..8a9dfdde685f 100644 --- a/test/CodeGen/2009-10-20-GlobalDebug.c +++ b/test/CodeGen/2009-10-20-GlobalDebug.c @@ -6,5 +6,5 @@ int main() { return 0; } -// CHECK: !14 = metadata !{i32 {{.*}}, i32 0, metadata !5, metadata !"localstatic", metadata !"localstatic", metadata !"", metadata !6, i32 5, metadata !9, i32 1, i32 1, i32* @main.localstatic} ; [ DW_TAG_variable ] -// CHECK: !15 = metadata !{i32 {{.*}}, i32 0, null, metadata !"global", metadata !"global", metadata !"", metadata !6, i32 3, metadata !9, i32 0, i32 1, i32* @global} ; [ DW_TAG_variable ] +// CHECK: metadata !{i32 {{.*}}, i32 0, metadata !5, metadata !"localstatic", metadata !"localstatic", metadata !"", metadata !6, i32 5, metadata !9, i32 1, i32 1, i32* @main.localstatic} ; [ DW_TAG_variable ] +// CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"global", metadata !"global", metadata !"", metadata !6, i32 3, metadata !9, i32 0, i32 1, i32* @global} ; [ DW_TAG_variable ] diff --git a/test/CodeGen/2010-02-10-PointerName.c b/test/CodeGen/2010-02-10-PointerName.c index 910dd30fc603..2837de4b8b44 100644 --- a/test/CodeGen/2010-02-10-PointerName.c +++ b/test/CodeGen/2010-02-10-PointerName.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -g -o - | grep DW_TAG_pointer_type | grep -v char +// RUN: %clang_cc1 %s -emit-llvm -g -o - | grep DW_TAG_pointer_type | grep -v {"char"} char i = 1; void foo() { diff --git a/test/CodeGen/2010-05-26-AsmSideEffect.c b/test/CodeGen/2010-05-26-AsmSideEffect.c index 7dd86aeb54d7..8ae7cb535408 100644 --- a/test/CodeGen/2010-05-26-AsmSideEffect.c +++ b/test/CodeGen/2010-05-26-AsmSideEffect.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 %s -emit-llvm -triple arm-apple-darwin -o - | FileCheck %s // Radar 8026855 diff --git a/test/CodeGen/Atomics.c b/test/CodeGen/Atomics.c index c440b6c1909e..2bb38fd749c2 100644 --- a/test/CodeGen/Atomics.c +++ b/test/CodeGen/Atomics.c @@ -1,6 +1,6 @@ // Test frontend handling of __sync builtins. // Modified from a gcc testcase. -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s signed char sc; unsigned char uc; diff --git a/test/CodeGen/address-safety-attr.cpp b/test/CodeGen/address-safety-attr.cpp index 9d0fb9596330..da68b1d703fa 100644 --- a/test/CodeGen/address-safety-attr.cpp +++ b/test/CodeGen/address-safety-attr.cpp @@ -33,3 +33,9 @@ int TemplateAddressSafetyOk() { return i; } int force_instance = TemplateAddressSafetyOk<42>() + TemplateNoAddressSafety<42>(); + +// Check that __cxx_global_var_init* get the address_safety attribute. +int global1 = 0; +int global2 = *(int*)((char*)&global1+1); +// CHECK-NOT: @__cxx_global_var_init{{.*}}address_safety +// ASAN: @__cxx_global_var_init{{.*}}address_safety diff --git a/test/CodeGen/address-space.c b/test/CodeGen/address-space.c index 04f88dc20a1a..9de0670b1024 100644 --- a/test/CodeGen/address-space.c +++ b/test/CodeGen/address-space.c @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s -// RUN: %clang_cc1 -emit-llvm < %s | grep 'load.*addrspace(2).. @A' -// RUN: %clang_cc1 -emit-llvm < %s | grep 'load.*addrspace(2).. @B' +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | grep 'load.*addrspace(2).. @A' +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm < %s | grep 'load.*addrspace(2).. @B' // CHECK: @foo = common addrspace(1) global diff --git a/test/CodeGen/2002-05-24-Alloca.c b/test/CodeGen/alloca.c index 30ba8bb8e218..30ba8bb8e218 100644 --- a/test/CodeGen/2002-05-24-Alloca.c +++ b/test/CodeGen/alloca.c diff --git a/test/CodeGen/altivec.c b/test/CodeGen/altivec.c index 29823031b56a..6c924a7fe36f 100644 --- a/test/CodeGen/altivec.c +++ b/test/CodeGen/altivec.c @@ -1,3 +1,4 @@ +// REQUIRES: ppc32-registered-target // RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s // Check initialization diff --git a/test/CodeGen/annotations-builtin.c b/test/CodeGen/annotations-builtin.c index 42421a0a5200..7938e49aa646 100644 --- a/test/CodeGen/annotations-builtin.c +++ b/test/CodeGen/annotations-builtin.c @@ -25,9 +25,7 @@ int main(int argc, char **argv) { // CHECK: call i32 @llvm.annotation.i32 long long lla = __builtin_annotation(llfoo, "annotation_a"); -// CHECK: trunc i64 {{.*}} to i32 -// CHECK-NEXT: call i32 @llvm.annotation.i32 -// CHECK-NEXT: zext i32 {{.*}} to i64 +// CHECK: call i64 @llvm.annotation.i64 int inta = __builtin_annotation(intfoo, "annotation_a"); // CHECK: load i32* @intfoo @@ -35,15 +33,11 @@ int main(int argc, char **argv) { // CHECK-NEXT: store short shorta = __builtin_annotation(shortfoo, "annotation_a"); -// CHECK: sext i16 {{.*}} to i32 -// CHECK-NEXT: call i32 @llvm.annotation.i32 -// CHECK-NEXT: trunc i32 {{.*}} to i16 +// CHECK: call i16 @llvm.annotation.i16 char chara = __builtin_annotation(charfoo, "annotation_a"); -// CHECK: sext i8 {{.*}} to i32 -// CHECK-NEXT: call i32 @llvm.annotation.i32 -// CHECK-NEXT: trunc i32 {{.*}} to i8 -// +// CHECK: call i8 @llvm.annotation.i8 + char **arg = (char**) __builtin_annotation((int) argv, "annotation_a"); // CHECK: ptrtoint i8** {{.*}} to // CHECK: call i32 @llvm.annotation.i32 diff --git a/test/CodeGen/arm-aapcs-vfp.c b/test/CodeGen/arm-aapcs-vfp.c index 017c14524e97..614b52dad576 100644 --- a/test/CodeGen/arm-aapcs-vfp.c +++ b/test/CodeGen/arm-aapcs-vfp.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple thumbv7-apple-darwin9 \ // RUN: -target-abi aapcs \ // RUN: -target-cpu cortex-a8 \ @@ -33,6 +34,13 @@ void test_complex(__complex__ double cd) { complex_callee(cd); } +// Long double is the same as double on AAPCS, it should be homogeneous. +extern void complex_long_callee(__complex__ long double); +// CHECK: define arm_aapcs_vfpcc void @test_complex_long(double %{{.*}}, double %{{.*}}) +void test_complex_long(__complex__ long double cd) { + complex_callee(cd); +} + // Structs with more than 4 elements of the base type are not treated // as homogeneous aggregates. Test that. @@ -80,3 +88,7 @@ extern void neon_callee(struct neon_struct); void test_neon(struct neon_struct arg) { neon_callee(arg); } + +// CHECK: define arm_aapcs_vfpcc void @f33(%struct.s33* byval %s) +struct s33 { char buf[32*32]; }; +void f33(struct s33 s) { } diff --git a/test/CodeGen/arm-aapcs-zerolength-bitfield.c b/test/CodeGen/arm-aapcs-zerolength-bitfield.c index 9fece197fa82..140ff6c42436 100644 --- a/test/CodeGen/arm-aapcs-zerolength-bitfield.c +++ b/test/CodeGen/arm-aapcs-zerolength-bitfield.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -target-abi aapcs -triple armv7-apple-darwin10 %s -verify #include <stddef.h> diff --git a/test/CodeGen/arm-apcs-zerolength-bitfield.c b/test/CodeGen/arm-apcs-zerolength-bitfield.c index 3f9452539408..049ffae4dc6f 100644 --- a/test/CodeGen/arm-apcs-zerolength-bitfield.c +++ b/test/CodeGen/arm-apcs-zerolength-bitfield.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -target-abi apcs-gnu -triple armv7-apple-darwin10 %s -verify // // Note: gcc forces the alignment to 4 bytes, regardless of the type of the diff --git a/test/CodeGen/arm-arguments.c b/test/CodeGen/arm-arguments.c index 4686d4ab9593..2ec729eb9b3d 100644 --- a/test/CodeGen/arm-arguments.c +++ b/test/CodeGen/arm-arguments.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=APCS-GNU %s // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=AAPCS %s @@ -165,3 +166,15 @@ void f31(struct s31 s) { } // APCS-GNU: %s = alloca %struct.s31, align 4 // APCS-GNU: alloca [1 x i32] // APCS-GNU: store [1 x i32] %s.coerce, [1 x i32]* + +// PR13562 +struct s32 { double x; }; +void f32(struct s32 s) { } +// AAPCS: @f32([1 x i64] %s.coerce) +// APCS-GNU: @f32([2 x i32] %s.coerce) + +// PR13350 +struct s33 { char buf[32*32]; }; +void f33(struct s33 s) { } +// APCS-GNU: define void @f33(%struct.s33* byval %s) +// AAPCS: define arm_aapcscc void @f33(%struct.s33* byval %s) diff --git a/test/CodeGen/arm-asm-variable.c b/test/CodeGen/arm-asm-variable.c index 865d1971e8b9..f874269b0a01 100644 --- a/test/CodeGen/arm-asm-variable.c +++ b/test/CodeGen/arm-asm-variable.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s typedef long long int64_t; diff --git a/test/CodeGen/arm-asm.c b/test/CodeGen/arm-asm.c index 9b1082a198e3..bd2fe1199369 100644 --- a/test/CodeGen/arm-asm.c +++ b/test/CodeGen/arm-asm.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple thumb %s -emit-llvm -o - | FileCheck %s int t1() { static float k = 1.0f; diff --git a/test/CodeGen/arm-cc.c b/test/CodeGen/arm-cc.c index 74eecc755f75..80ebe687c11b 100644 --- a/test/CodeGen/arm-cc.c +++ b/test/CodeGen/arm-cc.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=DARWIN-APCS %s // RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=DARWIN-AAPCS %s // RUN: %clang_cc1 -triple arm-none-linux-gnueabi -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=LINUX-APCS %s diff --git a/test/CodeGen/arm-clear.c b/test/CodeGen/arm-clear.c index eda64ce99ee4..51506dfed10d 100644 --- a/test/CodeGen/arm-clear.c +++ b/test/CodeGen/arm-clear.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s void clear0(void *ptr) { diff --git a/test/CodeGen/arm-homogenous.c b/test/CodeGen/arm-homogenous.c index eb3d5a6bd631..b8d046af9722 100644 --- a/test/CodeGen/arm-homogenous.c +++ b/test/CodeGen/arm-homogenous.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7---eabi -target-abi aapcs -mfloat-abi hard -emit-llvm %s -o - | FileCheck %s typedef long long int64_t; @@ -157,4 +158,4 @@ void test_return_union_with_struct_with_fundamental_elems(void) { // FIXME: Tests necessary: // - Vectors -// - C++ stuff
\ No newline at end of file +// - C++ stuff diff --git a/test/CodeGen/arm-inline-asm.c b/test/CodeGen/arm-inline-asm.c index 0152b050fd7f..95bb507c2798 100644 --- a/test/CodeGen/arm-inline-asm.c +++ b/test/CodeGen/arm-inline-asm.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7-apple-darwin9 -emit-llvm -w -o - %s | FileCheck %s void t1 (void *f, int g) { diff --git a/test/CodeGen/arm-pcs.c b/test/CodeGen/arm-pcs.c index d722f84cebd7..fc658c3bef6f 100644 --- a/test/CodeGen/arm-pcs.c +++ b/test/CodeGen/arm-pcs.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple arm-none-linux-gnueabi -emit-llvm -w -o - < %s | FileCheck %s typedef int __attribute__((pcs("aapcs"))) (*aapcs_fn)(void); typedef int __attribute__((pcs("aapcs-vfp"))) (*aapcs_vfp_fn)(void); diff --git a/test/CodeGen/arm-vaarg-align.c b/test/CodeGen/arm-vaarg-align.c index 1187c022914f..2270c8b4f971 100644 --- a/test/CodeGen/arm-vaarg-align.c +++ b/test/CodeGen/arm-vaarg-align.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple arm -target-abi aapcs %s -emit-llvm -o - | FileCheck -check-prefix=AAPCS %s // RUN: %clang_cc1 -triple arm -target-abi apcs-gnu %s -emit-llvm -o - | FileCheck -check-prefix=APCS-GNU %s /* diff --git a/test/CodeGen/arm-vector-align.c b/test/CodeGen/arm-vector-align.c index b481a0c97f8f..9e1ae5da11e2 100644 --- a/test/CodeGen/arm-vector-align.c +++ b/test/CodeGen/arm-vector-align.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple thumbv7-apple-darwin \ // RUN: -target-abi apcs-gnu \ // RUN: -target-cpu cortex-a8 \ diff --git a/test/CodeGen/arm-vector-arguments.c b/test/CodeGen/arm-vector-arguments.c index 6bfb2f48a7f1..9bdddb72696e 100644 --- a/test/CodeGen/arm-vector-arguments.c +++ b/test/CodeGen/arm-vector-arguments.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple thumbv7-apple-darwin9 \ // RUN: -target-abi apcs-gnu \ // RUN: -target-cpu cortex-a8 \ diff --git a/test/CodeGen/asm.c b/test/CodeGen/asm.c index 84f26e1013c1..b0097368ec28 100644 --- a/test/CodeGen/asm.c +++ b/test/CodeGen/asm.c @@ -220,3 +220,13 @@ typedef long long __m256i __attribute__((__vector_size__(32))); void t26 (__m256i *p) { __asm__ volatile("vmovaps %0, %%ymm0" :: "m" (*(__m256i*)p) : "ymm0"); } + +// Check to make sure the inline asm non-standard dialect attribute _not_ is +// emitted. +void t27(void) { + asm volatile("nop"); +// CHECK: @t27 +// CHECK: call void asm sideeffect "nop" +// CHECK-NOT: ia_nsdialect +// CHECK: ret void +} diff --git a/test/CodeGen/asm_arm.c b/test/CodeGen/asm_arm.c index 633bf5569dd6..4b764b7d3663 100644 --- a/test/CodeGen/asm_arm.c +++ b/test/CodeGen/asm_arm.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv6-unknown-unknown -emit-llvm -o - %s | FileCheck %s void test0(void) { diff --git a/test/CodeGen/atomic_ops.c b/test/CodeGen/atomic_ops.c index 9a18c9e94492..481d1e06fbd5 100644 --- a/test/CodeGen/atomic_ops.c +++ b/test/CodeGen/atomic_ops.c @@ -1,11 +1,20 @@ // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s -void foo(void) +void foo(int x) { _Atomic(int) i = 0; + _Atomic(short) j = 0; // Check that multiply / divides on atomics produce a cmpxchg loop - i *= 2; // CHECK: cmpxchg - i /= 2; // CHECK: cmpxchg + i *= 2; + // CHECK: mul nsw i32 + // CHECK: cmpxchg i32* + i /= 2; + // CHECK: sdiv i32 + // CHECK: cmpxchg i32* + j /= x; + // CHECK: sdiv i32 + // CHECK: cmpxchg i16* + // These should be emitting atomicrmw instructions, but they aren't yet i += 2; // CHECK: cmpxchg i -= 2; // CHECK: cmpxchg diff --git a/test/CodeGen/attr-coldhot.c b/test/CodeGen/attr-coldhot.c new file mode 100644 index 000000000000..b9bb299b5e49 --- /dev/null +++ b/test/CodeGen/attr-coldhot.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s + +int test1() __attribute__((__cold__)) { + return 42; + +// Check that we set the optsize attribute on the function. +// CHECK: @test1{{.*}}optsize +// CHECK: ret +} diff --git a/test/CodeGen/attributes.c b/test/CodeGen/attributes.c index 4e73af60439d..e971a793473a 100644 --- a/test/CodeGen/attributes.c +++ b/test/CodeGen/attributes.c @@ -81,3 +81,11 @@ void t21(void) { } // CHECK: [[FPTRVAR:%[a-z0-9]+]] = load void (i32)** @fptr // CHECK-NEXT: call x86_fastcallcc void [[FPTRVAR]](i32 10) + + +// PR9356: We might want to err on this, but for now at least make sure we +// use the section in the definition. +void __attribute__((section(".foo"))) t22(void); +void __attribute__((section(".bar"))) t22(void) {} + +// CHECK: define void @t22() nounwind section ".bar" diff --git a/test/CodeGen/avx-builtins.c b/test/CodeGen/avx-builtins.c index b963c97cc18a..0e5a741bcf67 100644 --- a/test/CodeGen/avx-builtins.c +++ b/test/CodeGen/avx-builtins.c @@ -23,3 +23,73 @@ __m256i test__mm256_loadu_si256(void* p) { // CHECK: load <4 x i64>* %{{.+}}, align 1 return _mm256_loadu_si256(p); } + +__m128i test_mm_cmpestrm(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestrm128 + return _mm_cmpestrm(A, LA, B, LB, 7); +} + +int test_mm_cmpestri(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestri128 + return _mm_cmpestri(A, LA, B, LB, 7); +} + +int test_mm_cmpestra(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestria128 + return _mm_cmpestra(A, LA, B, LB, 7); +} + +int test_mm_cmpestrc(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestric128 + return _mm_cmpestrc(A, LA, B, LB, 7); +} + +int test_mm_cmpestro(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestrio128 + return _mm_cmpestro(A, LA, B, LB, 7); +} + +int test_mm_cmpestrs(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestris128 + return _mm_cmpestrs(A, LA, B, LB, 7); +} + +int test_mm_cmpestrz(__m128i A, int LA, __m128i B, int LB) { + // CHECK: @llvm.x86.sse42.pcmpestriz128 + return _mm_cmpestrz(A, LA, B, LB, 7); +} + +__m128i test_mm_cmpistrm(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistrm128 + return _mm_cmpistrm(A, B, 7); +} + +int test_mm_cmpistri(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistri128 + return _mm_cmpistri(A, B, 7); +} + +int test_mm_cmpistra(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistria128 + return _mm_cmpistra(A, B, 7); +} + +int test_mm_cmpistrc(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistric128 + return _mm_cmpistrc(A, B, 7); +} + +int test_mm_cmpistro(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistrio128 + return _mm_cmpistro(A, B, 7); +} + +int test_mm_cmpistrs(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistris128 + return _mm_cmpistrs(A, B, 7); +} + +int test_mm_cmpistrz(__m128i A, __m128i B) { + // CHECK: @llvm.x86.sse42.pcmpistriz128 + return _mm_cmpistrz(A, B, 7); +} diff --git a/test/CodeGen/avx2-builtins.c b/test/CodeGen/avx2-builtins.c index 7d166b562638..b5bc60503173 100644 --- a/test/CodeGen/avx2-builtins.c +++ b/test/CodeGen/avx2-builtins.c @@ -10,6 +10,11 @@ __m256i test_mm256_mpsadbw_epu8(__m256i x, __m256i y) { return _mm256_mpsadbw_epu8(x, y, 3); } +__m256i test_mm256_sad_epu8(__m256i x, __m256i y) { + // CHECK: @llvm.x86.avx2.psad.bw + return _mm256_sad_epu8(x, y); +} + __m256i test_mm256_abs_epi8(__m256i a) { // CHECK: @llvm.x86.avx2.pabs.b return _mm256_abs_epi8(a); @@ -780,3 +785,154 @@ __m128i test_mm_srlv_epi64(__m128i a, __m128i b) { // CHECK: @llvm.x86.avx2.psrlv.q return _mm_srlv_epi64(a, b); } + +__m128d test_mm_mask_i32gather_pd(__m128d a, double const *b, __m128i c, + __m128d d) { + // CHECK: @llvm.x86.avx2.gather.d.pd + return _mm_mask_i32gather_pd(a, b, c, d, 2); +} + +__m256d test_mm256_mask_i32gather_pd(__m256d a, double const *b, __m128i c, + __m256d d) { + // CHECK: @llvm.x86.avx2.gather.d.pd.256 + return _mm256_mask_i32gather_pd(a, b, c, d, 2); +} +__m128d test_mm_mask_i64gather_pd(__m128d a, double const *b, __m128i c, + __m128d d) { + // CHECK: @llvm.x86.avx2.gather.q.pd + return _mm_mask_i64gather_pd(a, b, c, d, 2); +} +__m256d test_mm256_mask_i64gather_pd(__m256d a, double const *b, __m256i c, + __m256d d) { + // CHECK: @llvm.x86.avx2.gather.q.pd.256 + return _mm256_mask_i64gather_pd(a, b, c, d, 2); +} + +__m128 test_mm_mask_i32gather_ps(__m128 a, float const *b, __m128i c, + __m128 d) { + // CHECK: @llvm.x86.avx2.gather.d.ps + return _mm_mask_i32gather_ps(a, b, c, d, 2); +} +__m256 test_mm256_mask_i32gather_ps(__m256 a, float const *b, __m256i c, + __m256 d) { + // CHECK: @llvm.x86.avx2.gather.d.ps.256 + return _mm256_mask_i32gather_ps(a, b, c, d, 2); +} +__m128 test_mm_mask_i64gather_ps(__m128 a, float const *b, __m128i c, + __m128 d) { + // CHECK: @llvm.x86.avx2.gather.q.ps + return _mm_mask_i64gather_ps(a, b, c, d, 2); +} +__m128 test_mm256_mask_i64gather_ps(__m128 a, float const *b, __m256i c, + __m128 d) { + // CHECK: @llvm.x86.avx2.gather.q.ps.256 + return _mm256_mask_i64gather_ps(a, b, c, d, 2); +} + +__m128i test_mm_mask_i32gather_epi32(__m128i a, int const *b, __m128i c, + __m128i d) { + // CHECK: @llvm.x86.avx2.gather.d.d + return _mm_mask_i32gather_epi32(a, b, c, d, 2); +} +__m256i test_mm256_mask_i32gather_epi32(__m256i a, int const *b, __m256i c, + __m256i d) { + // CHECK: @llvm.x86.avx2.gather.d.d.256 + return _mm256_mask_i32gather_epi32(a, b, c, d, 2); +} +__m128i test_mm_mask_i64gather_epi32(__m128i a, int const *b, __m128i c, + __m128i d) { + // CHECK: @llvm.x86.avx2.gather.q.d + return _mm_mask_i64gather_epi32(a, b, c, d, 2); +} +__m128i test_mm256_mask_i64gather_epi32(__m128i a, int const *b, __m256i c, + __m128i d) { + // CHECK: @llvm.x86.avx2.gather.q.d.256 + return _mm256_mask_i64gather_epi32(a, b, c, d, 2); +} + +__m128i test_mm_mask_i32gather_epi64(__m128i a, int const *b, __m128i c, + __m128i d) { + // CHECK: @llvm.x86.avx2.gather.d.q + return _mm_mask_i32gather_epi64(a, b, c, d, 2); +} +__m256i test_mm256_mask_i32gather_epi64(__m256i a, int const *b, __m128i c, + __m256i d) { + // CHECK: @llvm.x86.avx2.gather.d.q.256 + return _mm256_mask_i32gather_epi64(a, b, c, d, 2); +} +__m128i test_mm_mask_i64gather_epi64(__m128i a, int const *b, __m128i c, + __m128i d) { + // CHECK: @llvm.x86.avx2.gather.q.q + return _mm_mask_i64gather_epi64(a, b, c, d, 2); +} +__m256i test_mm256_mask_i64gather_epi64(__m256i a, int const *b, __m256i c, + __m256i d) { + // CHECK: @llvm.x86.avx2.gather.q.q.256 + return _mm256_mask_i64gather_epi64(a, b, c, d, 2); +} + +__m128d test_mm_i32gather_pd(double const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.pd + return _mm_i32gather_pd(b, c, 2); +} +__m256d test_mm256_i32gather_pd(double const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.pd.256 + return _mm256_i32gather_pd(b, c, 2); +} +__m128d test_mm_i64gather_pd(double const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.q.pd + return _mm_i64gather_pd(b, c, 2); +} +__m256d test_mm256_i64gather_pd(double const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.q.pd.256 + return _mm256_i64gather_pd(b, c, 2); +} +__m128 test_mm_i32gather_ps(float const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.ps + return _mm_i32gather_ps(b, c, 2); +} +__m256 test_mm256_i32gather_ps(float const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.d.ps.256 + return _mm256_i32gather_ps(b, c, 2); +} +__m128 test_mm_i64gather_ps(float const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.q.ps + return _mm_i64gather_ps(b, c, 2); +} +__m128 test_mm256_i64gather_ps(float const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.q.ps.256 + return _mm256_i64gather_ps(b, c, 2); +} + +__m128i test_mm_i32gather_epi32(int const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.d + return _mm_i32gather_epi32(b, c, 2); +} +__m256i test_mm256_i32gather_epi32(int const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.d.d.256 + return _mm256_i32gather_epi32(b, c, 2); +} +__m128i test_mm_i64gather_epi32(int const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.q.d + return _mm_i64gather_epi32(b, c, 2); +} +__m128i test_mm256_i64gather_epi32(int const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.q.d.256 + return _mm256_i64gather_epi32(b, c, 2); +} +__m128i test_mm_i32gather_epi64(int const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.q + return _mm_i32gather_epi64(b, c, 2); +} +__m256i test_mm256_i32gather_epi64(int const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.d.q.256 + return _mm256_i32gather_epi64(b, c, 2); +} +__m128i test_mm_i64gather_epi64(int const *b, __m128i c) { + // CHECK: @llvm.x86.avx2.gather.q.q + return _mm_i64gather_epi64(b, c, 2); +} +__m256i test_mm256_i64gather_epi64(int const *b, __m256i c) { + // CHECK: @llvm.x86.avx2.gather.q.q.256 + return _mm256_i64gather_epi64(b, c, 2); +} diff --git a/test/CodeGen/block-3.c b/test/CodeGen/block-3.c index 95cb6a735c73..29c1bb5803c7 100644 --- a/test/CodeGen/block-3.c +++ b/test/CodeGen/block-3.c @@ -6,3 +6,15 @@ int main() { __attribute__((__blocks__(byref))) int index = ({ int __a; int __b; __a < __b ? __b : __a; }); }; } + +// PR13229 +// rdar://11777609 +typedef struct {} Z; + +typedef int (^B)(Z); + +void testPR13229() { + Z z1; + B b1 = ^(Z z1) { return 1; }; + b1(z1); +} diff --git a/test/CodeGen/block-byref-aggr.c b/test/CodeGen/block-byref-aggr.c index 3027df04861c..eb342b856e4f 100644 --- a/test/CodeGen/block-byref-aggr.c +++ b/test/CodeGen/block-byref-aggr.c @@ -1,17 +1,66 @@ // RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 | FileCheck %s -// rdar://9309454 -typedef struct { int v; } RetType; +// CHECK: [[AGG:%.*]] = type { i32 } +typedef struct { int v; } Agg; +Agg makeAgg(void); -RetType func(); +// When assigning into a __block variable, ensure that we compute that +// address *after* evaluating the RHS when the RHS has the capacity to +// cause a block copy. rdar://9309454 +void test0() { + __block Agg a = {100}; -int main () { - __attribute__((__blocks__(byref))) RetType a = {100}; + a = makeAgg(); +} +// CHECK: define void @test0() +// CHECK: [[A:%.*]] = alloca [[BYREF:%.*]], align 8 +// CHECK-NEXT: [[TEMP:%.*]] = alloca [[AGG]], align 4 +// CHECK: [[RESULT:%.*]] = call i32 @makeAgg() +// CHECK-NEXT: [[T0:%.*]] = getelementptr [[AGG]]* [[TEMP]], i32 0, i32 0 +// CHECK-NEXT: store i32 [[RESULT]], i32* [[T0]] +// Check that we properly assign into the forwarding pointer. +// CHECK-NEXT: [[A_FORWARDING:%.*]] = getelementptr inbounds [[BYREF]]* [[A]], i32 0, i32 1 +// CHECK-NEXT: [[T0:%.*]] = load [[BYREF]]** [[A_FORWARDING]] +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[BYREF]]* [[T0]], i32 0, i32 4 +// CHECK-NEXT: [[T2:%.*]] = bitcast [[AGG]]* [[T1]] to i8* +// CHECK-NEXT: [[T3:%.*]] = bitcast [[AGG]]* [[TEMP]] to i8* +// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T2]], i8* [[T3]], i64 4, i32 4, i1 false) +// Verify that there's nothing else significant in the function. +// CHECK-NEXT: [[T0:%.*]] = bitcast [[BYREF]]* [[A]] to i8* +// CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8) +// CHECK-NEXT: ret void - a = func(); +// When chaining assignments into __block variables, make sure we +// propagate the actual value into the outer variable. +// rdar://11757470 +void test1() { + __block Agg a, b; + a = b = makeAgg(); } -// CHECK: [[C1:%.*]] = call i32 (...)* @func() -// CHECK-NEXT: [[CO:%.*]] = getelementptr -// CHECK-NEXT: store i32 [[C1]], i32* [[CO]] -// CHECK-NEXT: [[FORWARDING:%.*]] = getelementptr inbounds [[BR:%.*]]* [[A:%.*]], i32 0, i32 1 -// CHECK-NEXT: [[O:%.*]] = load [[BR]]** [[FORWARDING]] +// CHECK: define void @test1() +// CHECK: [[A:%.*]] = alloca [[A_BYREF:%.*]], align 8 +// CHECK-NEXT: [[B:%.*]] = alloca [[B_BYREF:%.*]], align 8 +// CHECK-NEXT: [[TEMP:%.*]] = alloca [[AGG]], align 4 +// CHECK: [[RESULT:%.*]] = call i32 @makeAgg() +// CHECK-NEXT: [[T0:%.*]] = getelementptr [[AGG]]* [[TEMP]], i32 0, i32 0 +// CHECK-NEXT: store i32 [[RESULT]], i32* [[T0]] +// Check that we properly assign into the forwarding pointer, first for b: +// CHECK-NEXT: [[B_FORWARDING:%.*]] = getelementptr inbounds [[B_BYREF]]* [[B]], i32 0, i32 1 +// CHECK-NEXT: [[T0:%.*]] = load [[B_BYREF]]** [[B_FORWARDING]] +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[B_BYREF]]* [[T0]], i32 0, i32 4 +// CHECK-NEXT: [[T2:%.*]] = bitcast [[AGG]]* [[T1]] to i8* +// CHECK-NEXT: [[T3:%.*]] = bitcast [[AGG]]* [[TEMP]] to i8* +// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T2]], i8* [[T3]], i64 4, i32 4, i1 false) +// Then for 'a': +// CHECK-NEXT: [[A_FORWARDING:%.*]] = getelementptr inbounds [[A_BYREF]]* [[A]], i32 0, i32 1 +// CHECK-NEXT: [[T0:%.*]] = load [[A_BYREF]]** [[A_FORWARDING]] +// CHECK-NEXT: [[T1:%.*]] = getelementptr inbounds [[A_BYREF]]* [[T0]], i32 0, i32 4 +// CHECK-NEXT: [[T2:%.*]] = bitcast [[AGG]]* [[T1]] to i8* +// CHECK-NEXT: [[T3:%.*]] = bitcast [[AGG]]* [[TEMP]] to i8* +// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T2]], i8* [[T3]], i64 4, i32 4, i1 false) +// Verify that there's nothing else significant in the function. +// CHECK-NEXT: [[T0:%.*]] = bitcast [[B_BYREF]]* [[B]] to i8* +// CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8) +// CHECK-NEXT: [[T0:%.*]] = bitcast [[A_BYREF]]* [[A]] to i8* +// CHECK-NEXT: call void @_Block_object_dispose(i8* [[T0]], i32 8) +// CHECK-NEXT: ret void diff --git a/test/CodeGen/blocks.c b/test/CodeGen/blocks.c index bef44c369015..71f7171c7181 100644 --- a/test/CodeGen/blocks.c +++ b/test/CodeGen/blocks.c @@ -12,7 +12,7 @@ struct s0 { int a[64]; }; -// CHECK: define internal void @__f2_block_invoke_0(%struct.s0* noalias sret {{%.*}}, i8* {{%.*}}, %struct.s0* byval align 4 {{.*}}) +// CHECK: define internal void @__f2_block_invoke(%struct.s0* noalias sret {{%.*}}, i8* {{%.*}}, %struct.s0* byval align 4 {{.*}}) struct s0 f2(struct s0 a0) { return ^(struct s0 a1){ return a1; }(a0); } @@ -40,3 +40,29 @@ void f3() { _Bool b = 0; f3_helper(^{ if (b) {} }); } + +// rdar://problem/11322251 +// The bool can fill in between the header and the long long. +// Add the appropriate amount of padding between them. +void f4_helper(long long (^)(void)); +// CHECK: define void @f4() +void f4(void) { + _Bool b = 0; + long long ll = 0; + // CHECK: alloca <{ i8*, i32, i32, i8*, {{%.*}}*, i8, [3 x i8], i64 }>, align 8 + f4_helper(^{ if (b) return ll; return 0LL; }); +} + +// rdar://problem/11354538 +// The alignment after rounding up to the align of F5 is actually +// greater than the required alignment. Don't assert. +struct F5 { + char buffer[32] __attribute((aligned)); +}; +void f5_helper(void (^)(struct F5 *)); +// CHECK: define void @f5() +void f5(void) { + struct F5 value; + // CHECK: alloca <{ i8*, i32, i32, i8*, {{%.*}}*, [12 x i8], [[F5:%.*]] }>, align 16 + f5_helper(^(struct F5 *slot) { *slot = value; }); +} diff --git a/test/CodeGen/blocksignature.c b/test/CodeGen/blocksignature.c index 63fe1248a86d..fd586eb1e139 100644 --- a/test/CodeGen/blocksignature.c +++ b/test/CodeGen/blocksignature.c @@ -8,7 +8,7 @@ // X32: [[STR1:@.*]] = private unnamed_addr constant [6 x i8] c"v4@?0\00" // X32: @__block_descriptor_tmp = internal constant [[FULL_DESCRIPTOR_T:.*]] { i32 0, i32 20, i8* getelementptr inbounds ([6 x i8]* [[STR1]], i32 0, i32 0), i8* null } -// X32: @__block_literal_global = internal constant [[GLOBAL_LITERAL_T:.*]] { i8** @_NSConcreteGlobalBlock, i32 1342177280, i32 0, i8* bitcast (void (i8*)* @__block_global_{{.*}} to i8*), [[DESCRIPTOR_T:%.*]]* bitcast ([[FULL_DESCRIPTOR_T]]* @__block_descriptor_tmp to {{%.*}}*) } +// X32: @__block_literal_global = internal constant [[GLOBAL_LITERAL_T:.*]] { i8** @_NSConcreteGlobalBlock, i32 1342177280, i32 0, i8* bitcast (void (i8*)* @global_block_invoke{{.*}} to i8*), [[DESCRIPTOR_T:%.*]]* bitcast ([[FULL_DESCRIPTOR_T]]* @__block_descriptor_tmp to {{%.*}}*) } // X32: [[STR2:@.*]] = private unnamed_addr constant [11 x i8] c"i12@?0c4f8\00" // X32: @__block_descriptor_tmp{{.*}} = internal constant [[FULL_DESCRIPTOR_T]] { i32 0, i32 24, i8* getelementptr inbounds ([11 x i8]* [[STR2]], i32 0, i32 0), i8* null } // X32: store i32 1073741824, i32* diff --git a/test/CodeGen/blockwithlocalstatic.c b/test/CodeGen/blockwithlocalstatic.c index 1fdaaf37a1b3..8b4210ed1901 100644 --- a/test/CodeGen/blockwithlocalstatic.c +++ b/test/CodeGen/blockwithlocalstatic.c @@ -1,17 +1,17 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -emit-llvm -o - %s | FileCheck %s // pr8707 -// CHECK: @__block_global_0.test = internal global i32 +// CHECK: @block_block_invoke.test = internal global i32 int (^block)(void) = ^ { static int test=0; return test; }; -// CHECK: @__block_global_1.test = internal global i32 +// CHECK: @block1_block_invoke_2.test = internal global i32 void (^block1)(void) = ^ { static int test = 2; return; }; -// CHECK: @__block_global_2.test = internal global i32 +// CHECK: @block2_block_invoke_3.test = internal global i32 int (^block2)(void) = ^ { static int test = 5; return test; diff --git a/test/CodeGen/bmi-builtins.c b/test/CodeGen/bmi-builtins.c index 47b0da204ee9..2e1ba12d9b3c 100644 --- a/test/CodeGen/bmi-builtins.c +++ b/test/CodeGen/bmi-builtins.c @@ -5,9 +5,9 @@ #include <x86intrin.h> -unsigned short test__tzcnt16(unsigned short __X) { +unsigned short test__tzcnt_u16(unsigned short __X) { // CHECK: @llvm.cttz.i16 - return __tzcnt16(__X); + return __tzcnt_u16(__X); } unsigned int test__andn_u32(unsigned int __X, unsigned int __Y) { @@ -39,9 +39,9 @@ unsigned int test__blsr_u32(unsigned int __X) { return __blsr_u32(__X); } -unsigned int test_tzcnt32(unsigned int __X) { +unsigned int test_tzcnt_u32(unsigned int __X) { // CHECK: @llvm.cttz.i32 - return __tzcnt32(__X); + return __tzcnt_u32(__X); } unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) { @@ -73,7 +73,7 @@ unsigned long long test__blsr_u64(unsigned long long __X) { return __blsr_u64(__X); } -unsigned long long test__tzcnt64(unsigned long long __X) { +unsigned long long test__tzcnt_u64(unsigned long long __X) { // CHECK: @llvm.cttz.i64 - return __tzcnt64(__X); + return __tzcnt_u64(__X); } diff --git a/test/CodeGen/bool_test.c b/test/CodeGen/bool_test.c index ffaaef8123cc..715f8467b588 100644 --- a/test/CodeGen/bool_test.c +++ b/test/CodeGen/bool_test.c @@ -1,3 +1,4 @@ +// REQUIRES: ppc32-registered-target // RUN: %clang_cc1 -triple powerpc-apple-darwin -emit-llvm -o - %s| FileCheck -check-prefix=DARWINPPC-CHECK %s int boolsize = sizeof(_Bool); diff --git a/test/CodeGen/bounds-checking.c b/test/CodeGen/bounds-checking.c new file mode 100644 index 000000000000..e2786203e6a7 --- /dev/null +++ b/test/CodeGen/bounds-checking.c @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -fbounds-checking=4 -emit-llvm -triple x86_64-apple-darwin10 < %s | FileCheck %s + +// CHECK: @f +double f(int b, int i) { + double a[b]; + // CHECK: trap + return a[i]; +} + +// CHECK: @f2 +void f2() { + // everything is constant; no trap possible + // CHECK-NOT: trap + int a[2]; + a[1] = 42; + + short *b = malloc(64); + b[5] = *a + a[1] + 2; +} + +// CHECK: @f3 +void f3() { + int a[1]; + // CHECK: trap + a[2] = 1; +} diff --git a/test/CodeGen/branch-target-layout.c b/test/CodeGen/branch-target-layout.c new file mode 100644 index 000000000000..a6475d7ef116 --- /dev/null +++ b/test/CodeGen/branch-target-layout.c @@ -0,0 +1,40 @@ +// RUN: %clang_cc1 %s -O3 -emit-llvm -o - | FileCheck %s +// +// PR13214 +// No assumption may be made about the order that a frontend emits branch +// targets (basic blocks). However, the backend's basic block layout makes an +// attempt to preserve source order of control flow, and any bias toward source +// order must start with the frontend. +// +// Note that the frontend inverts branches to simplify the condition, so the +// order of a branch instruction's labels cannot be used as a source order bias. + +void calla(); +void callb(); +void callc(); + +// CHECK: @test1 +// CHECK: @calla +// CHECK: @callb +// CHECK: @callc +// CHECK: ret void +void test1(int a) { + if (a) + calla(); + else + callb(); + callc(); +} + +// CHECK: @test2 +// CHECK: @callb +// CHECK: @calla +// CHECK: @callc +// CHECK: ret void +void test2(int a) { + if (!a) + callb(); + else + calla(); + callc(); +} diff --git a/test/CodeGen/builtin-attributes.c b/test/CodeGen/builtin-attributes.c index 3781eba26694..1d3a94376d5f 100644 --- a/test/CodeGen/builtin-attributes.c +++ b/test/CodeGen/builtin-attributes.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple arm-unknown-linux-gnueabi -emit-llvm -o - %s | FileCheck %s // CHECK: declare i32 @printf(i8*, ...) diff --git a/test/CodeGen/builtins-arm.c b/test/CodeGen/builtins-arm.c index 09df1ef42c74..3611650c38ce 100644 --- a/test/CodeGen/builtins-arm.c +++ b/test/CodeGen/builtins-arm.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -Wall -Werror -triple thumbv7-eabi -target-cpu cortex-a8 -O3 -emit-llvm -o - %s | FileCheck %s void *f0() diff --git a/test/CodeGen/builtins-mips-args.c b/test/CodeGen/builtins-mips-args.c new file mode 100644 index 000000000000..a961b36a9533 --- /dev/null +++ b/test/CodeGen/builtins-mips-args.c @@ -0,0 +1,14 @@ +// REQUIRES: mips-registered-target +// RUN: %clang_cc1 -triple mips-unknown-linux-gnu -fsyntax-only -verify %s + +void foo() { + // MIPS DSP Rev 1 + + int a = 3; + __builtin_mips_wrdsp(2052, a); // expected-error{{argument to '__builtin_mips_wrdsp' must be a constant integer}} + __builtin_mips_rddsp(a); // expected-error{{argument to '__builtin_mips_rddsp' must be a constant integer}} + __builtin_mips_wrdsp(2052, -1); // expected-error{{argument should be a value from 0 to 63}} + __builtin_mips_rddsp(-1); // expected-error{{argument should be a value from 0 to 63}} + __builtin_mips_wrdsp(2052, 64); // expected-error{{argument should be a value from 0 to 63}} + __builtin_mips_rddsp(64); // expected-error{{argument should be a value from 0 to 63}} +} diff --git a/test/CodeGen/builtins-mips.c b/test/CodeGen/builtins-mips.c new file mode 100644 index 000000000000..8155a43c20f0 --- /dev/null +++ b/test/CodeGen/builtins-mips.c @@ -0,0 +1,324 @@ +// REQUIRES: mips-registered-target +// RUN: %clang_cc1 -triple mips-unknown-linux-gnu -emit-llvm %s -o - \ +// RUN: | FileCheck %s + +typedef int q31; +typedef int i32; +typedef unsigned int ui32; +typedef long long a64; + +typedef signed char v4i8 __attribute__ ((vector_size(4))); +typedef short v2q15 __attribute__ ((vector_size(4))); + +void foo() { + v2q15 v2q15_r, v2q15_a, v2q15_b, v2q15_c; + v4i8 v4i8_r, v4i8_a, v4i8_b, v4i8_c; + q31 q31_r, q31_a, q31_b, q31_c; + i32 i32_r, i32_a, i32_b, i32_c; + ui32 ui32_r, ui32_a, ui32_b, ui32_c; + a64 a64_r, a64_a, a64_b; + + // MIPS DSP Rev 1 + + v4i8_a = (v4i8) {1, 2, 3, 0xFF}; + v4i8_b = (v4i8) {2, 4, 6, 8}; + v4i8_r = __builtin_mips_addu_qb(v4i8_a, v4i8_b); +// CHECK: call <4 x i8> @llvm.mips.addu.qb + v4i8_r = __builtin_mips_addu_s_qb(v4i8_a, v4i8_b); +// CHECK: call <4 x i8> @llvm.mips.addu.s.qb + v4i8_r = __builtin_mips_subu_qb(v4i8_a, v4i8_b); +// CHECK: call <4 x i8> @llvm.mips.subu.qb + v4i8_r = __builtin_mips_subu_s_qb(v4i8_a, v4i8_b); +// CHECK: call <4 x i8> @llvm.mips.subu.s.qb + + v2q15_a = (v2q15) {0x0000, 0x8000}; + v2q15_b = (v2q15) {0x8000, 0x8000}; + v2q15_r = __builtin_mips_addq_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.addq.ph + v2q15_r = __builtin_mips_addq_s_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.addq.s.ph + v2q15_r = __builtin_mips_subq_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.subq.ph + v2q15_r = __builtin_mips_subq_s_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.subq.s.ph + + a64_a = 0x12345678; + i32_b = 0x80000000; + i32_c = 0x11112222; + a64_r = __builtin_mips_madd(a64_a, i32_b, i32_c); +// CHECK: call i64 @llvm.mips.madd + a64_a = 0x12345678; + ui32_b = 0x80000000; + ui32_c = 0x11112222; + a64_r = __builtin_mips_maddu(a64_a, ui32_b, ui32_c); +// CHECK: call i64 @llvm.mips.maddu + a64_a = 0x12345678; + i32_b = 0x80000000; + i32_c = 0x11112222; + a64_r = __builtin_mips_msub(a64_a, i32_b, i32_c); +// CHECK: call i64 @llvm.mips.msub + a64_a = 0x12345678; + ui32_b = 0x80000000; + ui32_c = 0x11112222; + a64_r = __builtin_mips_msubu(a64_a, ui32_b, ui32_c); +// CHECK: call i64 @llvm.mips.msubu + + q31_a = 0x12345678; + q31_b = 0x7FFFFFFF; + q31_r = __builtin_mips_addq_s_w(q31_a, q31_b); +// CHECK: call i32 @llvm.mips.addq.s.w + q31_r = __builtin_mips_subq_s_w(q31_a, q31_b); +// CHECK: call i32 @llvm.mips.subq.s.w + + i32_a = 0xFFFFFFFF; + i32_b = 1; + i32_r = __builtin_mips_addsc(i32_a, i32_b); +// CHECK: call i32 @llvm.mips.addsc + i32_a = 0; + i32_b = 1; + i32_r = __builtin_mips_addwc(i32_a, i32_b); +// CHECK: call i32 @llvm.mips.addwc + + i32_a = 20; + i32_b = 0x1402; + i32_r = __builtin_mips_modsub(i32_a, i32_b); +// CHECK: call i32 @llvm.mips.modsub + + v4i8_a = (v4i8) {1, 2, 3, 4}; + i32_r = __builtin_mips_raddu_w_qb(v4i8_a); +// CHECK: call i32 @llvm.mips.raddu.w.qb + + v2q15_a = (v2q15) {0xFFFF, 0x8000}; + v2q15_r = __builtin_mips_absq_s_ph(v2q15_a); +// CHECK: call <2 x i16> @llvm.mips.absq.s.ph + q31_a = 0x80000000; + q31_r = __builtin_mips_absq_s_w(q31_a); +// CHECK: call i32 @llvm.mips.absq.s.w + + v2q15_a = (v2q15) {0x1234, 0x5678}; + v2q15_b = (v2q15) {0x1111, 0x2222}; + v4i8_r = __builtin_mips_precrq_qb_ph(v2q15_a, v2q15_b); +// CHECK: call <4 x i8> @llvm.mips.precrq.qb.ph + + v2q15_a = (v2q15) {0x7F79, 0xFFFF}; + v2q15_b = (v2q15) {0x7F81, 0x2000}; + v4i8_r = __builtin_mips_precrqu_s_qb_ph(v2q15_a, v2q15_b); +// CHECK: call <4 x i8> @llvm.mips.precrqu.s.qb.ph + q31_a = 0x12345678; + q31_b = 0x11112222; + v2q15_r = __builtin_mips_precrq_ph_w(q31_a, q31_b); +// CHECK: call <2 x i16> @llvm.mips.precrq.ph.w + q31_a = 0x7000FFFF; + q31_b = 0x80000000; + v2q15_r = __builtin_mips_precrq_rs_ph_w(q31_a, q31_b); +// CHECK: call <2 x i16> @llvm.mips.precrq.rs.ph.w + v2q15_a = (v2q15) {0x1234, 0x5678}; + q31_r = __builtin_mips_preceq_w_phl(v2q15_a); +// CHECK: call i32 @llvm.mips.preceq.w.phl + q31_r = __builtin_mips_preceq_w_phr(v2q15_a); +// CHECK: call i32 @llvm.mips.preceq.w.phr + v4i8_a = (v4i8) {0x12, 0x34, 0x56, 0x78}; + v2q15_r = __builtin_mips_precequ_ph_qbl(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.precequ.ph.qbl + v2q15_r = __builtin_mips_precequ_ph_qbr(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.precequ.ph.qbr + v2q15_r = __builtin_mips_precequ_ph_qbla(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.precequ.ph.qbla + v2q15_r = __builtin_mips_precequ_ph_qbra(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.precequ.ph.qbra + v2q15_r = __builtin_mips_preceu_ph_qbl(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.preceu.ph.qbl + v2q15_r = __builtin_mips_preceu_ph_qbr(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.preceu.ph.qbr + v2q15_r = __builtin_mips_preceu_ph_qbla(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.preceu.ph.qbla + v2q15_r = __builtin_mips_preceu_ph_qbra(v4i8_a); +// CHECK: call <2 x i16> @llvm.mips.preceu.ph.qbra + + v4i8_a = (v4i8) {1, 2, 3, 4}; + v4i8_r = __builtin_mips_shll_qb(v4i8_a, 2); +// CHECK: call <4 x i8> @llvm.mips.shll.qb + v4i8_a = (v4i8) {128, 64, 32, 16}; + v4i8_r = __builtin_mips_shrl_qb(v4i8_a, 2); +// CHECK: call <4 x i8> @llvm.mips.shrl.qb + v2q15_a = (v2q15) {0x0001, 0x8000}; + v2q15_r = __builtin_mips_shll_ph(v2q15_a, 2); +// CHECK: call <2 x i16> @llvm.mips.shll.ph + v2q15_r = __builtin_mips_shll_s_ph(v2q15_a, 2); +// CHECK: call <2 x i16> @llvm.mips.shll.s.ph + v2q15_a = (v2q15) {0x7FFF, 0x8000}; + v2q15_r = __builtin_mips_shra_ph(v2q15_a, 2); +// CHECK: call <2 x i16> @llvm.mips.shra.ph + v2q15_r = __builtin_mips_shra_r_ph(v2q15_a, 2); +// CHECK: call <2 x i16> @llvm.mips.shra.r.ph + q31_a = 0x70000000; + q31_r = __builtin_mips_shll_s_w(q31_a, 2); +// CHECK: call i32 @llvm.mips.shll.s.w + q31_a = 0x7FFFFFFF; + q31_r = __builtin_mips_shra_r_w(q31_a, 2); +// CHECK: call i32 @llvm.mips.shra.r.w + a64_a = 0x1234567887654321LL; + a64_r = __builtin_mips_shilo(a64_a, -8); +// CHECK: call i64 @llvm.mips.shilo + + v4i8_a = (v4i8) {0x1, 0x3, 0x5, 0x7}; + v2q15_b = (v2q15) {0x1234, 0x5678}; + v2q15_r = __builtin_mips_muleu_s_ph_qbl(v4i8_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.muleu.s.ph.qbl + v2q15_r = __builtin_mips_muleu_s_ph_qbr(v4i8_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.muleu.s.ph.qbr + v2q15_a = (v2q15) {0x7FFF, 0x8000}; + v2q15_b = (v2q15) {0x7FFF, 0x8000}; + v2q15_r = __builtin_mips_mulq_rs_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.mulq.rs.ph + v2q15_a = (v2q15) {0x1234, 0x8000}; + v2q15_b = (v2q15) {0x5678, 0x8000}; + q31_r = __builtin_mips_muleq_s_w_phl(v2q15_a, v2q15_b); +// CHECK: call i32 @llvm.mips.muleq.s.w.phl + q31_r = __builtin_mips_muleq_s_w_phr(v2q15_a, v2q15_b); +// CHECK: call i32 @llvm.mips.muleq.s.w.phr + a64_a = 0; + v2q15_a = (v2q15) {0x0001, 0x8000}; + v2q15_b = (v2q15) {0x0002, 0x8000}; + a64_r = __builtin_mips_mulsaq_s_w_ph(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.mulsaq.s.w.ph + a64_a = 0; + v2q15_b = (v2q15) {0x0001, 0x8000}; + v2q15_c = (v2q15) {0x0002, 0x8000}; + a64_r = __builtin_mips_maq_s_w_phl(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.maq.s.w.phl + a64_r = __builtin_mips_maq_s_w_phr(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.maq.s.w.phr + a64_a = 0x7FFFFFF0; + a64_r = __builtin_mips_maq_sa_w_phl(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.maq.sa.w.phl + a64_r = __builtin_mips_maq_sa_w_phr(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.maq.sa.w.phr + i32_a = 0x80000000; + i32_b = 0x11112222; + a64_r = __builtin_mips_mult(i32_a, i32_b); +// CHECK: call i64 @llvm.mips.mult + ui32_a = 0x80000000; + ui32_b = 0x11112222; + a64_r = __builtin_mips_multu(ui32_a, ui32_b); +// CHECK: call i64 @llvm.mips.multu + + a64_a = 0; + v4i8_b = (v4i8) {1, 2, 3, 4}; + v4i8_c = (v4i8) {4, 5, 6, 7}; + a64_r = __builtin_mips_dpau_h_qbl(a64_a, v4i8_b, v4i8_c); +// CHECK: call i64 @llvm.mips.dpau.h.qbl + a64_r = __builtin_mips_dpau_h_qbr(a64_a, v4i8_b, v4i8_c); +// CHECK: call i64 @llvm.mips.dpau.h.qbr + a64_r = __builtin_mips_dpsu_h_qbl(a64_a, v4i8_b, v4i8_c); +// CHECK: call i64 @llvm.mips.dpsu.h.qbl + a64_r = __builtin_mips_dpsu_h_qbr(a64_a, v4i8_b, v4i8_c); +// CHECK: call i64 @llvm.mips.dpsu.h.qbr + a64_a = 0; + v2q15_b = (v2q15) {0x0001, 0x8000}; + v2q15_c = (v2q15) {0x0002, 0x8000}; + a64_r = __builtin_mips_dpaq_s_w_ph(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.dpaq.s.w.ph + a64_r = __builtin_mips_dpsq_s_w_ph(a64_a, v2q15_b, v2q15_c); +// CHECK: call i64 @llvm.mips.dpsq.s.w.ph + a64_a = 0; + q31_b = 0x80000000; + q31_c = 0x80000000; + a64_r = __builtin_mips_dpaq_sa_l_w(a64_a, q31_b, q31_c); +// CHECK: call i64 @llvm.mips.dpaq.sa.l.w + a64_r = __builtin_mips_dpsq_sa_l_w(a64_a, q31_b, q31_c); +// CHECK: call i64 @llvm.mips.dpsq.sa.l.w + + v4i8_a = (v4i8) {1, 4, 10, 8}; + v4i8_b = (v4i8) {1, 2, 100, 8}; + __builtin_mips_cmpu_eq_qb(v4i8_a, v4i8_b); +// CHECK: call void @llvm.mips.cmpu.eq.qb + __builtin_mips_cmpu_lt_qb(v4i8_a, v4i8_b); +// CHECK: call void @llvm.mips.cmpu.lt.qb + __builtin_mips_cmpu_le_qb(v4i8_a, v4i8_b); +// CHECK: call void @llvm.mips.cmpu.le.qb + i32_r = __builtin_mips_cmpgu_eq_qb(v4i8_a, v4i8_b); +// CHECK: call i32 @llvm.mips.cmpgu.eq.qb + i32_r = __builtin_mips_cmpgu_lt_qb(v4i8_a, v4i8_b); +// CHECK: call i32 @llvm.mips.cmpgu.lt.qb + i32_r = __builtin_mips_cmpgu_le_qb(v4i8_a, v4i8_b); +// CHECK: call i32 @llvm.mips.cmpgu.le.qb + v2q15_a = (v2q15) {0x1111, 0x1234}; + v2q15_b = (v2q15) {0x4444, 0x1234}; + __builtin_mips_cmp_eq_ph(v2q15_a, v2q15_b); +// CHECK: call void @llvm.mips.cmp.eq.ph + __builtin_mips_cmp_lt_ph(v2q15_a, v2q15_b); +// CHECK: call void @llvm.mips.cmp.lt.ph + __builtin_mips_cmp_le_ph(v2q15_a, v2q15_b); +// CHECK: call void @llvm.mips.cmp.le.ph + + a64_a = 0xFFFFF81230000000LL; + i32_r = __builtin_mips_extr_s_h(a64_a, 4); +// CHECK: call i32 @llvm.mips.extr.s.h + a64_a = 0x8123456712345678LL; + i32_r = __builtin_mips_extr_w(a64_a, 31); +// CHECK: call i32 @llvm.mips.extr.w + i32_r = __builtin_mips_extr_rs_w(a64_a, 31); +// CHECK: call i32 @llvm.mips.extr.rs.w + i32_r = __builtin_mips_extr_r_w(a64_a, 31); +// CHECK: call i32 @llvm.mips.extr.r.w + a64_a = 0x1234567887654321LL; + i32_r = __builtin_mips_extp(a64_a, 3); +// CHECK: call i32 @llvm.mips.extp + a64_a = 0x123456789ABCDEF0LL; + i32_r = __builtin_mips_extpdp(a64_a, 7); +// CHECK: call i32 @llvm.mips.extpdp + + __builtin_mips_wrdsp(2052, 3); +// CHECK: call void @llvm.mips.wrdsp + i32_r = __builtin_mips_rddsp(3); +// CHECK: call i32 @llvm.mips.rddsp + i32_a = 0xFFFFFFFF; + i32_b = 0x12345678; + __builtin_mips_wrdsp((16<<7) + 4, 3); +// CHECK: call void @llvm.mips.wrdsp + i32_r = __builtin_mips_insv(i32_a, i32_b); +// CHECK: call i32 @llvm.mips.insv + i32_a = 0x1234; + i32_r = __builtin_mips_bitrev(i32_a); +// CHECK: call i32 @llvm.mips.bitrev + v2q15_a = (v2q15) {0x1111, 0x2222}; + v2q15_b = (v2q15) {0x3333, 0x4444}; + v2q15_r = __builtin_mips_packrl_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.packrl.ph + i32_a = 100; + v4i8_r = __builtin_mips_repl_qb(i32_a); +// CHECK: call <4 x i8> @llvm.mips.repl.qb + i32_a = 0x1234; + v2q15_r = __builtin_mips_repl_ph(i32_a); +// CHECK: call <2 x i16> @llvm.mips.repl.ph + v4i8_a = (v4i8) {1, 4, 10, 8}; + v4i8_b = (v4i8) {1, 2, 100, 8}; + __builtin_mips_cmpu_eq_qb(v4i8_a, v4i8_b); +// CHECK: call void @llvm.mips.cmpu.eq.qb + v4i8_r = __builtin_mips_pick_qb(v4i8_a, v4i8_b); +// CHECK: call <4 x i8> @llvm.mips.pick.qb + v2q15_a = (v2q15) {0x1111, 0x1234}; + v2q15_b = (v2q15) {0x4444, 0x1234}; + __builtin_mips_cmp_eq_ph(v2q15_a, v2q15_b); +// CHECK: call void @llvm.mips.cmp.eq.ph + v2q15_r = __builtin_mips_pick_ph(v2q15_a, v2q15_b); +// CHECK: call <2 x i16> @llvm.mips.pick.ph + a64_a = 0x1234567887654321LL; + i32_b = 0x11112222; + __builtin_mips_wrdsp(0, 1); +// CHECK: call void @llvm.mips.wrdsp + a64_r = __builtin_mips_mthlip(a64_a, i32_b); +// CHECK: call i64 @llvm.mips.mthlip + i32_r = __builtin_mips_bposge32(); +// CHECK: call i32 @llvm.mips.bposge32 + char array_a[100]; + i32_r = __builtin_mips_lbux(array_a, 20); +// CHECK: call i32 @llvm.mips.lbux + short array_b[100]; + i32_r = __builtin_mips_lhx(array_b, 20); +// CHECK: call i32 @llvm.mips.lhx + int array_c[100]; + i32_r = __builtin_mips_lwx(array_c, 20); +// CHECK: call i32 @llvm.mips.lwx +} diff --git a/test/CodeGen/builtins-ptx.c b/test/CodeGen/builtins-nvptx.c index 6dd10188e9fb..fa6b14c1ca7d 100644 --- a/test/CodeGen/builtins-ptx.c +++ b/test/CodeGen/builtins-nvptx.c @@ -1,6 +1,5 @@ -// RUN: %clang_cc1 -triple ptx32-unknown-unknown -emit-llvm -o %t %s -// RUN: %clang_cc1 -triple ptx64-unknown-unknown -emit-llvm -o %t %s - +// RUN: %clang_cc1 -triple nvptx-unknown-unknown -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -emit-llvm -o %t %s int read_tid() { diff --git a/test/CodeGen/builtins-ppc-altivec.c b/test/CodeGen/builtins-ppc-altivec.c index b12ff014c193..e885cb03aa1a 100644 --- a/test/CodeGen/builtins-ppc-altivec.c +++ b/test/CodeGen/builtins-ppc-altivec.c @@ -1,3 +1,4 @@ +// REQUIRES: ppc32-registered-target // RUN: %clang_cc1 -faltivec -triple powerpc-unknown-unknown -emit-llvm %s -o - | FileCheck %s vector bool char vbc = { 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 }; diff --git a/test/CodeGen/builtins-x86.c b/test/CodeGen/builtins-x86.c index acb5554db4d3..fcf1512ca16e 100644 --- a/test/CodeGen/builtins-x86.c +++ b/test/CodeGen/builtins-x86.c @@ -344,7 +344,6 @@ void f0() { tmp_V16c = __builtin_ia32_lddqu(tmp_cCp); tmp_V2LLi = __builtin_ia32_palignr128(tmp_V2LLi, tmp_V2LLi, imm_i); tmp_V1LLi = __builtin_ia32_palignr(tmp_V1LLi, tmp_V1LLi, imm_i); - (void) __builtin_ia32_storelv4si(tmp_V2ip, tmp_V2LLi); #ifdef USE_SSE4 tmp_V16c = __builtin_ia32_pblendvb128(tmp_V16c, tmp_V16c, tmp_V16c); tmp_V8s = __builtin_ia32_pblendw128(tmp_V8s, tmp_V8s, imm_i_0_256); diff --git a/test/CodeGen/builtins.c b/test/CodeGen/builtins.c index fca087e197fc..65b9ad111fd8 100644 --- a/test/CodeGen/builtins.c +++ b/test/CodeGen/builtins.c @@ -203,3 +203,9 @@ void test_builtin_longjmp(void **buffer) { __builtin_longjmp(buffer, 1); // CHECK-NEXT: unreachable } + +// CHECK: define i64 @test_builtin_readcyclecounter +long long test_builtin_readcyclecounter() { + // CHECK: call i64 @llvm.readcyclecounter() + return __builtin_readcyclecounter(); +} diff --git a/test/CodeGen/capture-complex-expr-in-block.c b/test/CodeGen/capture-complex-expr-in-block.c index 9ce7570a4486..86c93d0252bc 100644 --- a/test/CodeGen/capture-complex-expr-in-block.c +++ b/test/CodeGen/capture-complex-expr-in-block.c @@ -12,7 +12,7 @@ int main () b(); } -// CHECK: define internal void @__main_block_invoke_0 +// CHECK: define internal void @__main_block_invoke // CHECK: [[C1:%.*]] = alloca { double, double }, align 8 // CHECK: [[RP:%.*]] = getelementptr inbounds { double, double }* [[C1]], i32 0, i32 0 // CHECK-NEXT: [[R:%.*]] = load double* [[RP]] diff --git a/test/CodeGen/catch-undef-behavior.c b/test/CodeGen/catch-undef-behavior.c index fef1587fad00..ee0b6586dd84 100644 --- a/test/CodeGen/catch-undef-behavior.c +++ b/test/CodeGen/catch-undef-behavior.c @@ -1,7 +1,17 @@ -// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm-only %s +// RUN: %clang_cc1 -fcatch-undefined-behavior -emit-llvm %s -o - | FileCheck %s // PR6805 +// CHECK: @foo void foo() { union { int i; } u; + // CHECK: objectsize + // CHECK: icmp uge u.i=1; } + +// CHECK: @bar +int bar(int *a) { + // CHECK: objectsize + // CHECK: icmp uge + return *a; +} diff --git a/test/CodeGen/compound-literal.c b/test/CodeGen/compound-literal.c index 969c5affe0b2..a8eec615ad62 100644 --- a/test/CodeGen/compound-literal.c +++ b/test/CodeGen/compound-literal.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s int* a = &(int){1}; struct s {int a, b, c;} * b = &(struct s) {1, 2, 3}; diff --git a/test/CodeGen/debug-info-gline-tables-only.c b/test/CodeGen/debug-info-gline-tables-only.c new file mode 100644 index 000000000000..067d8e772189 --- /dev/null +++ b/test/CodeGen/debug-info-gline-tables-only.c @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 %s -gline-tables-only -S -emit-llvm -o - | FileCheck %s +// Checks that clang with "-gline-tables-only" doesn't emit debug info +// for variables and types. + +// CHECK-NOT: DW_TAG_variable +int global = 42; + +// CHECK-NOT: DW_TAG_typedef +// CHECK-NOT: DW_TAG_const_type +// CHECK-NOT: DW_TAG_pointer_type +// CHECK-NOT: DW_TAG_array_type +typedef const char* constCharPtrArray[10]; + +// CHECK-NOT: DW_TAG_structure_type +struct S { + // CHECK-NOT: DW_TAG_member + char a; + double b; + constCharPtrArray c; +}; + +// CHECK-NOT: DW_TAG_enumerator +// CHECK-NOT: DW_TAG_enumeration_type +enum E { ZERO = 0, ONE = 1 }; + +// CHECK-NOT: DW_TAG_arg_variable +int sum(int p, int q) { + // CHECK-NOT: DW_TAG_auto_variable + int r = p + q; + struct S s; + enum E e; + return r; +} diff --git a/test/CodeGen/debug-info-gline-tables-only2.c b/test/CodeGen/debug-info-gline-tables-only2.c new file mode 100644 index 000000000000..8e9cc64e0d69 --- /dev/null +++ b/test/CodeGen/debug-info-gline-tables-only2.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 %s -gline-tables-only -S -emit-llvm -o - | FileCheck %s +// Checks that clang with "-gline-tables-only" emits metadata for +// compile unit, subprogram and file. + +int main() { + // CHECK: ret i32 0, !dbg + return 0; +} + +// CHECK: !llvm.dbg.cu = !{!0} +// CHECK: DW_TAG_compile_unit +// CHECK: {{.*main.* DW_TAG_subprogram}} +// CHECK: DW_TAG_file_type diff --git a/test/CodeGen/debug-info-line2.c b/test/CodeGen/debug-info-line2.c index b5eba8a1a060..893b021360fb 100644 --- a/test/CodeGen/debug-info-line2.c +++ b/test/CodeGen/debug-info-line2.c @@ -6,11 +6,12 @@ int foo(int i) { int j = 0; if (i) { j = bar(); -//CHECK: store i32 -//CHECK-NOT: br label %{{%[a-zA-Z0-9\.]+}}, !dbg } else { + // CHECK: add nsw + // CHECK-NEXT: store i32 %{{[a-zA-Z0-9]+}} + // CHECK-NOT: br label %{{[a-zA-Z0-9\.]+}}, !dbg j = bar() + 2; } return j; diff --git a/test/CodeGen/debug-info-line3.c b/test/CodeGen/debug-info-line3.c index 645ffb9e7485..a4e35e753d74 100644 --- a/test/CodeGen/debug-info-line3.c +++ b/test/CodeGen/debug-info-line3.c @@ -12,5 +12,5 @@ void func(char c, char* d) } -// CHECK: ret void, !dbg !19 -// CHECK: !19 = metadata !{i32 6, +// CHECK: ret void, !dbg !17 +// CHECK: !17 = metadata !{i32 6, diff --git a/test/CodeGen/debug-info-vla.c b/test/CodeGen/debug-info-vla.c new file mode 100644 index 000000000000..20fb6aace41f --- /dev/null +++ b/test/CodeGen/debug-info-vla.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s + +// CHECK: metadata !{i32 {{.*}}, metadata {{.*}}, metadata !"vla", metadata {{.*}}, i32 7, metadata {{.*}}, i32 0, i32 0, i64 2} ; [ DW_TAG_auto_variable ] + +void testVLAwithSize(int s) +{ + int vla[s]; + int i; + for (i = 0; i < s; i++) { + vla[i] = i*i; + } +} diff --git a/test/CodeGen/debug-line-1.c b/test/CodeGen/debug-line-1.c index 00d4f421f8a1..0c2d18583298 100644 --- a/test/CodeGen/debug-line-1.c +++ b/test/CodeGen/debug-line-1.c @@ -4,7 +4,7 @@ // Check to make sure that we emit the block for the break so that we can count the line. // CHECK: sw.bb: ; preds = %entry -// CHECK: br label %sw.epilog, !dbg !21 +// CHECK: br label %sw.epilog, !dbg !19 extern int atoi(const char *); diff --git a/test/CodeGen/fma-builtins.c b/test/CodeGen/fma-builtins.c new file mode 100644 index 000000000000..3424616b1233 --- /dev/null +++ b/test/CodeGen/fma-builtins.c @@ -0,0 +1,166 @@ +// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +fma -emit-llvm -o - | FileCheck %s + +// Don't include mm_malloc.h, it's system specific. +#define __MM_MALLOC_H + +#include <immintrin.h> + +__m128 test_mm_fmadd_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmadd.ps + return _mm_fmadd_ps(a, b, c); +} + +__m128d test_mm_fmadd_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmadd.pd + return _mm_fmadd_pd(a, b, c); +} + +__m128 test_mm_fmadd_ss(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmadd.ss + return _mm_fmadd_ss(a, b, c); +} + +__m128d test_mm_fmadd_sd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmadd.sd + return _mm_fmadd_sd(a, b, c); +} + +__m128 test_mm_fmsub_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmsub.ps + return _mm_fmsub_ps(a, b, c); +} + +__m128d test_mm_fmsub_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmsub.pd + return _mm_fmsub_pd(a, b, c); +} + +__m128 test_mm_fmsub_ss(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmsub.ss + return _mm_fmsub_ss(a, b, c); +} + +__m128d test_mm_fmsub_sd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmsub.sd + return _mm_fmsub_sd(a, b, c); +} + +__m128 test_mm_fnmadd_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfnmadd.ps + return _mm_fnmadd_ps(a, b, c); +} + +__m128d test_mm_fnmadd_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfnmadd.pd + return _mm_fnmadd_pd(a, b, c); +} + +__m128 test_mm_fnmadd_ss(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfnmadd.ss + return _mm_fnmadd_ss(a, b, c); +} + +__m128d test_mm_fnmadd_sd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfnmadd.sd + return _mm_fnmadd_sd(a, b, c); +} + +__m128 test_mm_fnmsub_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfnmsub.ps + return _mm_fnmsub_ps(a, b, c); +} + +__m128d test_mm_fnmsub_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfnmsub.pd + return _mm_fnmsub_pd(a, b, c); +} + +__m128 test_mm_fnmsub_ss(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfnmsub.ss + return _mm_fnmsub_ss(a, b, c); +} + +__m128d test_mm_fnmsub_sd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfnmsub.sd + return _mm_fnmsub_sd(a, b, c); +} + +__m128 test_mm_fmaddsub_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmaddsub.ps + return _mm_fmaddsub_ps(a, b, c); +} + +__m128d test_mm_fmaddsub_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmaddsub.pd + return _mm_fmaddsub_pd(a, b, c); +} + +__m128 test_mm_fmsubadd_ps(__m128 a, __m128 b, __m128 c) { + // CHECK: @llvm.x86.fma.vfmsubadd.ps + return _mm_fmsubadd_ps(a, b, c); +} + +__m128d test_mm_fmsubadd_pd(__m128d a, __m128d b, __m128d c) { + // CHECK: @llvm.x86.fma.vfmsubadd.pd + return _mm_fmsubadd_pd(a, b, c); +} + +__m256 test_mm256_fmadd_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfmadd.ps.256 + return _mm256_fmadd_ps(a, b, c); +} + +__m256d test_mm256_fmadd_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfmadd.pd.256 + return _mm256_fmadd_pd(a, b, c); +} + +__m256 test_mm256_fmsub_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfmsub.ps.256 + return _mm256_fmsub_ps(a, b, c); +} + +__m256d test_mm256_fmsub_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfmsub.pd.256 + return _mm256_fmsub_pd(a, b, c); +} + +__m256 test_mm256_fnmadd_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfnmadd.ps.256 + return _mm256_fnmadd_ps(a, b, c); +} + +__m256d test_mm256_fnmadd_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfnmadd.pd.256 + return _mm256_fnmadd_pd(a, b, c); +} + +__m256 test_mm256_fnmsub_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfnmsub.ps.256 + return _mm256_fnmsub_ps(a, b, c); +} + +__m256d test_mm256_fnmsub_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfnmsub.pd.256 + return _mm256_fnmsub_pd(a, b, c); +} + +__m256 test_mm256_fmaddsub_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfmaddsub.ps.256 + return _mm256_fmaddsub_ps(a, b, c); +} + +__m256d test_mm256_fmaddsub_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfmaddsub.pd.256 + return _mm256_fmaddsub_pd(a, b, c); +} + +__m256 test_mm256_fmsubadd_ps(__m256 a, __m256 b, __m256 c) { + // CHECK: @llvm.x86.fma.vfmsubadd.ps.256 + return _mm256_fmsubadd_ps(a, b, c); +} + +__m256d test_mm256_fmsubadd_pd(__m256d a, __m256d b, __m256d c) { + // CHECK: @llvm.x86.fma.vfmsubadd.pd.256 + return _mm256_fmsubadd_pd(a, b, c); +} diff --git a/test/CodeGen/fma4-builtins.c b/test/CodeGen/fma4-builtins.c index ddbaba748391..b805e9acb879 100644 --- a/test/CodeGen/fma4-builtins.c +++ b/test/CodeGen/fma4-builtins.c @@ -6,161 +6,161 @@ #include <x86intrin.h> __m128 test_mm_macc_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmadd.ps + // CHECK: @llvm.x86.fma.vfmadd.ps return _mm_macc_ps(a, b, c); } __m128d test_mm_macc_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmadd.pd + // CHECK: @llvm.x86.fma.vfmadd.pd return _mm_macc_pd(a, b, c); } __m128 test_mm_macc_ss(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmadd.ss + // CHECK: @llvm.x86.fma.vfmadd.ss return _mm_macc_ss(a, b, c); } __m128d test_mm_macc_sd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmadd.sd + // CHECK: @llvm.x86.fma.vfmadd.sd return _mm_macc_sd(a, b, c); } __m128 test_mm_msub_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmsub.ps + // CHECK: @llvm.x86.fma.vfmsub.ps return _mm_msub_ps(a, b, c); } __m128d test_mm_msub_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmsub.pd + // CHECK: @llvm.x86.fma.vfmsub.pd return _mm_msub_pd(a, b, c); } __m128 test_mm_msub_ss(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmsub.ss + // CHECK: @llvm.x86.fma.vfmsub.ss return _mm_msub_ss(a, b, c); } __m128d test_mm_msub_sd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmsub.sd + // CHECK: @llvm.x86.fma.vfmsub.sd return _mm_msub_sd(a, b, c); } __m128 test_mm_nmacc_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfnmadd.ps + // CHECK: @llvm.x86.fma.vfnmadd.ps return _mm_nmacc_ps(a, b, c); } __m128d test_mm_nmacc_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfnmadd.pd + // CHECK: @llvm.x86.fma.vfnmadd.pd return _mm_nmacc_pd(a, b, c); } __m128 test_mm_nmacc_ss(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfnmadd.ss + // CHECK: @llvm.x86.fma.vfnmadd.ss return _mm_nmacc_ss(a, b, c); } __m128d test_mm_nmacc_sd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfnmadd.sd + // CHECK: @llvm.x86.fma.vfnmadd.sd return _mm_nmacc_sd(a, b, c); } __m128 test_mm_nmsub_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfnmsub.ps + // CHECK: @llvm.x86.fma.vfnmsub.ps return _mm_nmsub_ps(a, b, c); } __m128d test_mm_nmsub_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfnmsub.pd + // CHECK: @llvm.x86.fma.vfnmsub.pd return _mm_nmsub_pd(a, b, c); } __m128 test_mm_nmsub_ss(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfnmsub.ss + // CHECK: @llvm.x86.fma.vfnmsub.ss return _mm_nmsub_ss(a, b, c); } __m128d test_mm_nmsub_sd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfnmsub.sd + // CHECK: @llvm.x86.fma.vfnmsub.sd return _mm_nmsub_sd(a, b, c); } __m128 test_mm_maddsub_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmaddsub.ps + // CHECK: @llvm.x86.fma.vfmaddsub.ps return _mm_maddsub_ps(a, b, c); } __m128d test_mm_maddsub_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmaddsub.pd + // CHECK: @llvm.x86.fma.vfmaddsub.pd return _mm_maddsub_pd(a, b, c); } __m128 test_mm_msubadd_ps(__m128 a, __m128 b, __m128 c) { - // CHECK: @llvm.x86.fma4.vfmsubadd.ps + // CHECK: @llvm.x86.fma.vfmsubadd.ps return _mm_msubadd_ps(a, b, c); } __m128d test_mm_msubadd_pd(__m128d a, __m128d b, __m128d c) { - // CHECK: @llvm.x86.fma4.vfmsubadd.pd + // CHECK: @llvm.x86.fma.vfmsubadd.pd return _mm_msubadd_pd(a, b, c); } __m256 test_mm256_macc_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfmadd.ps.256 + // CHECK: @llvm.x86.fma.vfmadd.ps.256 return _mm256_macc_ps(a, b, c); } __m256d test_mm256_macc_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfmadd.pd.256 + // CHECK: @llvm.x86.fma.vfmadd.pd.256 return _mm256_macc_pd(a, b, c); } __m256 test_mm256_msub_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfmsub.ps.256 + // CHECK: @llvm.x86.fma.vfmsub.ps.256 return _mm256_msub_ps(a, b, c); } __m256d test_mm256_msub_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfmsub.pd.256 + // CHECK: @llvm.x86.fma.vfmsub.pd.256 return _mm256_msub_pd(a, b, c); } __m256 test_mm256_nmacc_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfnmadd.ps.256 + // CHECK: @llvm.x86.fma.vfnmadd.ps.256 return _mm256_nmacc_ps(a, b, c); } __m256d test_mm256_nmacc_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfnmadd.pd.256 + // CHECK: @llvm.x86.fma.vfnmadd.pd.256 return _mm256_nmacc_pd(a, b, c); } __m256 test_mm256_nmsub_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfnmsub.ps.256 + // CHECK: @llvm.x86.fma.vfnmsub.ps.256 return _mm256_nmsub_ps(a, b, c); } __m256d test_mm256_nmsub_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfnmsub.pd.256 + // CHECK: @llvm.x86.fma.vfnmsub.pd.256 return _mm256_nmsub_pd(a, b, c); } __m256 test_mm256_maddsub_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfmaddsub.ps.256 + // CHECK: @llvm.x86.fma.vfmaddsub.ps.256 return _mm256_maddsub_ps(a, b, c); } __m256d test_mm256_maddsub_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfmaddsub.pd.256 + // CHECK: @llvm.x86.fma.vfmaddsub.pd.256 return _mm256_maddsub_pd(a, b, c); } __m256 test_mm256_msubadd_ps(__m256 a, __m256 b, __m256 c) { - // CHECK: @llvm.x86.fma4.vfmsubadd.ps.256 + // CHECK: @llvm.x86.fma.vfmsubadd.ps.256 return _mm256_msubadd_ps(a, b, c); } __m256d test_mm256_msubadd_pd(__m256d a, __m256d b, __m256d c) { - // CHECK: @llvm.x86.fma4.vfmsubadd.pd.256 + // CHECK: @llvm.x86.fma.vfmsubadd.pd.256 return _mm256_msubadd_pd(a, b, c); } diff --git a/test/CodeGen/forceinline.c b/test/CodeGen/forceinline.c new file mode 100644 index 000000000000..9a21c0dd2c78 --- /dev/null +++ b/test/CodeGen/forceinline.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple i686-win32 -emit-llvm -fms-extensions < %s | FileCheck %s + +void bar() { +} + +// CHECK-NOT: foo +__forceinline void foo() { + bar(); +} + +void i_want_bar() { +// CHECK: call void @bar + foo(); +} diff --git a/test/CodeGen/fp-contract.c b/test/CodeGen/fp-contract.c new file mode 100644 index 000000000000..eb95f1e21775 --- /dev/null +++ b/test/CodeGen/fp-contract.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -O3 -ffp-contract=fast -triple=powerpc-apple-darwin10 -S -o - %s | FileCheck %s +// REQUIRES: ppc32-registered-target + +float fma_test1(float a, float b, float c) { +// CHECK: fmadds + float x = a * b; + float y = x + c; + return y; +} diff --git a/test/CodeGen/fp16-ops.c b/test/CodeGen/fp16-ops.c index cbbfb884df50..e50651330670 100644 --- a/test/CodeGen/fp16-ops.c +++ b/test/CodeGen/fp16-ops.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -emit-llvm -o - -triple arm-none-linux-gnueabi %s | FileCheck %s typedef unsigned cond_t; diff --git a/test/CodeGen/func-aligned.c b/test/CodeGen/func-aligned.c index f8a4a29d9d2c..64b72932d0d2 100644 --- a/test/CodeGen/func-aligned.c +++ b/test/CodeGen/func-aligned.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s // rdar://7270273 void foo() __attribute__((aligned (64))); diff --git a/test/CodeGen/func-in-block.c b/test/CodeGen/func-in-block.c index 19001357d517..503695f8c378 100644 --- a/test/CodeGen/func-in-block.c +++ b/test/CodeGen/func-in-block.c @@ -15,5 +15,5 @@ int main() return 0; // not reached } -// CHECK: @__func__.__main_block_invoke_0 = private unnamed_addr constant [22 x i8] c"__main_block_invoke_0\00" -// CHECK: call void @PRINTF({{.*}}@__func__.__main_block_invoke_ +// CHECK: @__func__.__main_block_invoke = private unnamed_addr constant [20 x i8] c"__main_block_invoke\00" +// CHECK: call void @PRINTF({{.*}}@__func__.__main_block_invoke diff --git a/test/CodeGen/func-return-member.c b/test/CodeGen/func-return-member.c index 8c55a9671cd0..14ecac5d6bbb 100644 --- a/test/CodeGen/func-return-member.c +++ b/test/CodeGen/func-return-member.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s struct frk { float _Complex c; int x; }; struct faz { struct frk f; }; diff --git a/test/CodeGen/incomplete-function-type.c b/test/CodeGen/incomplete-function-type.c index 0ba6633b4adf..b6309472a5bc 100644 --- a/test/CodeGen/incomplete-function-type.c +++ b/test/CodeGen/incomplete-function-type.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s // CHECK: ModuleID // CHECK-NOT: opaque // CHECK: define void @f0 diff --git a/test/CodeGen/integer-overflow.c b/test/CodeGen/integer-overflow.c index 1d460656a1c7..d7fff4ee4a2a 100644 --- a/test/CodeGen/integer-overflow.c +++ b/test/CodeGen/integer-overflow.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT -// RUN: %clang_cc1 %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV -// RUN: %clang_cc1 %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV -// RUN: %clang_cc1 %s -emit-llvm -o - -ftrapv -ftrapv-handler foo | FileCheck %s --check-prefix=TRAPV_HANDLER +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=WRAPV +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=TRAPV +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv -ftrapv-handler foo | FileCheck %s --check-prefix=TRAPV_HANDLER // Tests for signed integer overflow stuff. diff --git a/test/CodeGen/libcalls.c b/test/CodeGen/libcalls.c index 458c591837ff..ec895ac6e857 100644 --- a/test/CodeGen/libcalls.c +++ b/test/CodeGen/libcalls.c @@ -73,3 +73,48 @@ void test_fma(float a0, double a1, long double a2) { // CHECK-NO: declare float @llvm.fma.f32(float, float, float) nounwind readnone // CHECK-NO: declare double @llvm.fma.f64(double, double, double) nounwind readnone // CHECK-NO: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) nounwind readnone + +// Just checking to make sure these library functions are marked readnone +void test_builtins(double d, float f, long double ld) { +// CHEC-NO: @test_builtins +// CHEC-YES: @test_builtins + double atan_ = atan(d); + long double atanl_ = atanl(ld); + float atanf_ = atanf(f); +// CHECK-NO: declare double @atan(double) nounwind readnone +// CHECK-NO: declare x86_fp80 @atanl(x86_fp80) nounwind readnone +// CHECK-NO: declare float @atanf(float) nounwind readnone +// CHECK-YES-NOT: declare double @atan(double) nounwind readnone +// CHECK-YES-NOT: declare x86_fp80 @atanl(x86_fp80) nounwind readnone +// CHECK-YES-NOT: declare float @atanf(float) nounwind readnone + + double atan2_ = atan2(d, 2); + long double atan2l_ = atan2l(ld, ld); + float atan2f_ = atan2f(f, f); +// CHECK-NO: declare double @atan2(double, double) nounwind readnone +// CHECK-NO: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) nounwind readnone +// CHECK-NO: declare float @atan2f(float, float) nounwind readnone +// CHECK-YES-NOT: declare double @atan2(double, double) nounwind readnone +// CHECK-YES-NOT: declare x86_fp80 @atan2l(x86_fp80, x86_fp80) nounwind readnone +// CHECK-YES-NOT: declare float @atan2f(float, float) nounwind readnone + + double exp_ = exp(d); + long double expl_ = expl(ld); + float expf_ = expf(f); +// CHECK-NO: declare double @exp(double) nounwind readnone +// CHECK-NO: declare x86_fp80 @expl(x86_fp80) nounwind readnone +// CHECK-NO: declare float @expf(float) nounwind readnone +// CHECK-YES-NOT: declare double @exp(double) nounwind readnone +// CHECK-YES-NOT: declare x86_fp80 @expl(x86_fp80) nounwind readnone +// CHECK-YES-NOT: declare float @expf(float) nounwind readnone + + double log_ = log(d); + long double logl_ = logl(ld); + float logf_ = logf(f); +// CHECK-NO: declare double @log(double) nounwind readnone +// CHECK-NO: declare x86_fp80 @logl(x86_fp80) nounwind readnone +// CHECK-NO: declare float @logf(float) nounwind readnone +// CHECK-YES-NOT: declare double @log(double) nounwind readnone +// CHECK-YES-NOT: declare x86_fp80 @logl(x86_fp80) nounwind readnone +// CHECK-YES-NOT: declare float @logf(float) nounwind readnone +} diff --git a/test/CodeGen/mips-byval-arg.c b/test/CodeGen/mips-byval-arg.c new file mode 100644 index 000000000000..4e5f41a14972 --- /dev/null +++ b/test/CodeGen/mips-byval-arg.c @@ -0,0 +1,15 @@ +// RUN: %clang -target mipsel-unknown-linux -ccc-clang-archs mipsel -O3 -S -o - -emit-llvm %s | FileCheck %s -check-prefix=O32 +// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s -check-prefix=N64 + +typedef struct { + float f[3]; +} S0; + +extern void foo2(S0); + +// O32: define void @foo1(i32 %a0.coerce0, i32 %a0.coerce1, i32 %a0.coerce2) +// N64: define void @foo1(i64 %a0.coerce0, i32 %a0.coerce1) + +void foo1(S0 a0) { + foo2(a0); +} diff --git a/test/CodeGen/mips-vector-arg.c b/test/CodeGen/mips-vector-arg.c new file mode 100644 index 000000000000..39998d91a64a --- /dev/null +++ b/test/CodeGen/mips-vector-arg.c @@ -0,0 +1,28 @@ +// RUN: %clang -target mipsel-unknown-linux -ccc-clang-archs mipsel -O3 -S -o - -emit-llvm %s | FileCheck %s -check-prefix=O32 +// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s -check-prefix=N64 + +// check that +// 1. vector arguments are passed in integer registers +// 2. argument alignment is no larger than 8-byte for O32 and 16-byte for N64. + +typedef float v4sf __attribute__ ((__vector_size__ (16))); +typedef int v4i32 __attribute__ ((__vector_size__ (16))); + +// O32: define void @test_v4sf(i32 %a1.coerce0, i32 %a1.coerce1, i32 %a1.coerce2, i32 %a1.coerce3, i32 %a2, i32, i32 %a3.coerce0, i32 %a3.coerce1, i32 %a3.coerce2, i32 %a3.coerce3) nounwind +// O32: declare i32 @test_v4sf_2(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) +// N64: define void @test_v4sf(i64 %a1.coerce0, i64 %a1.coerce1, i32 %a2, i64, i64 %a3.coerce0, i64 %a3.coerce1) nounwind +// N64: declare i32 @test_v4sf_2(i64, i64, i32, i64, i64, i64) +extern test_v4sf_2(v4sf, int, v4sf); +void test_v4sf(v4sf a1, int a2, v4sf a3) { + test_v4sf_2(a3, a2, a1); +} + +// O32: define void @test_v4i32(i32 %a1.coerce0, i32 %a1.coerce1, i32 %a1.coerce2, i32 %a1.coerce3, i32 %a2, i32, i32 %a3.coerce0, i32 %a3.coerce1, i32 %a3.coerce2, i32 %a3.coerce3) nounwind +// O32: declare i32 @test_v4i32_2(i32, i32, i32, i32, i32, i32, i32, i32, i32, i32) +// N64: define void @test_v4i32(i64 %a1.coerce0, i64 %a1.coerce1, i32 %a2, i64, i64 %a3.coerce0, i64 %a3.coerce1) nounwind +// N64: declare i32 @test_v4i32_2(i64, i64, i32, i64, i64, i64) +extern test_v4i32_2(v4i32, int, v4i32); +void test_v4i32(v4i32 a1, int a2, v4i32 a3) { + test_v4i32_2(a3, a2, a1); +} + diff --git a/test/CodeGen/mips-vector-return.c b/test/CodeGen/mips-vector-return.c new file mode 100644 index 000000000000..12e71fadf87b --- /dev/null +++ b/test/CodeGen/mips-vector-return.c @@ -0,0 +1,31 @@ +// RUN: %clang -target mipsel-unknown-linux -ccc-clang-archs mipsel -O3 -S -o - -emit-llvm %s | FileCheck %s -check-prefix=O32 +// RUN: %clang -target mips64el-unknown-linux -ccc-clang-archs mips64el -O3 -S -mabi=n64 -o - -emit-llvm %s | FileCheck %s -check-prefix=N64 + +// vectors larger than 16-bytes are returned via the hidden pointer argument. +// N64/N32 returns vectors whose size is equal to or smaller than 16-bytes in +// integer registers. +typedef float v4sf __attribute__ ((__vector_size__ (16))); +typedef double v4df __attribute__ ((__vector_size__ (32))); +typedef int v4i32 __attribute__ ((__vector_size__ (16))); + +// O32: define void @test_v4sf(<4 x float>* noalias nocapture sret +// N64: define { i64, i64 } @test_v4sf +v4sf test_v4sf(float a) { + return (v4sf){0.0f, a, 0.0f, 0.0f}; +} + +// O32: define void @test_v4df(<4 x double>* noalias nocapture sret +// N64: define void @test_v4df(<4 x double>* noalias nocapture sret +v4df test_v4df(double a) { + return (v4df){0.0, a, 0.0, 0.0}; +} + +// O32 returns integer vectors whose size is equal to or smaller than 16-bytes +// in integer registers. +// +// O32: define { i32, i32, i32, i32 } @test_v4i32 +// N64: define { i64, i64 } @test_v4i32 +v4i32 test_v4i32(int a) { + return (v4i32){0, a, 0, 0}; +} + diff --git a/test/CodeGen/mips64-class-return.cpp b/test/CodeGen/mips64-class-return.cpp index dc9ec0f5be4e..8e32d5cbd6f0 100644 --- a/test/CodeGen/mips64-class-return.cpp +++ b/test/CodeGen/mips64-class-return.cpp @@ -39,7 +39,7 @@ void foo3(D2 a0) { gd2 = a0; } -// CHECK: define void @_Z4foo42D0(%class.D0* nocapture byval %a0) +// CHECK: define void @_Z4foo42D0(i64 %a0.coerce0, i64 %a0.coerce1) void foo4(D0 a0) { gd0 = a0; } diff --git a/test/CodeGen/ms-declspecs.c b/test/CodeGen/ms-declspecs.c index d3235aee4364..91862a73b09c 100644 --- a/test/CodeGen/ms-declspecs.c +++ b/test/CodeGen/ms-declspecs.c @@ -1,5 +1,13 @@ // RUN: %clang_cc1 -triple i386-pc-win32 %s -emit-llvm -fms-compatibility -o - | FileCheck %s +struct __declspec(align(16)) S { + char x; +}; +union { struct S s; } u; + +// CHECK: @u = {{.*}}zeroinitializer, align 16 + + // CHECK: define void @t3() nounwind noinline naked { __declspec(naked) void t3() {} diff --git a/test/CodeGen/ms-inline-asm.c b/test/CodeGen/ms-inline-asm.c new file mode 100644 index 000000000000..8c3e5f7c569b --- /dev/null +++ b/test/CodeGen/ms-inline-asm.c @@ -0,0 +1,40 @@ +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -O0 -fms-extensions -fenable-experimental-ms-inline-asm -w -emit-llvm -o - | FileCheck %s + +void t1() { +// CHECK: @t1 +// CHECK: call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect +// CHECK: ret void + __asm {} +} + +void t2() { +// CHECK: @t2 +// CHECK: call void asm sideeffect "nop\0Anop\0Anop", "~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect +// CHECK: ret void + __asm nop + __asm nop + __asm nop +} + +void t3() { +// CHECK: @t3 +// CHECK: call void asm sideeffect "nop\0Anop\0Anop", "~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect +// CHECK: ret void + __asm nop __asm nop __asm nop +} + +void t4(void) { +// CHECK: @t4 +// CHECK: call void asm sideeffect "mov ebx, eax\0Amov ecx, ebx", "~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect +// CHECK: ret void + __asm mov ebx, eax + __asm mov ecx, ebx +} + +void t5(void) { +// CHECK: @t5 +// CHECK: call void asm sideeffect "mov ebx, eax\0Amov ecx, ebx", "~{dirflag},~{fpsr},~{flags}"() nounwind ia_nsdialect +// CHECK: ret void + __asm mov ebx, eax __asm mov ecx, ebx +} + diff --git a/test/CodeGen/no-common.c b/test/CodeGen/no-common.c index 7beefc7b690d..8d2c4d7d74c8 100644 --- a/test/CodeGen/no-common.c +++ b/test/CodeGen/no-common.c @@ -12,4 +12,4 @@ fn_t ABC __attribute__ ((nocommon)); // CHECK-DEFAULT: @y = common global // CHECK-NOCOMMON: @y = common global -int y __attribute__((common));
\ No newline at end of file +int y __attribute__((common)); diff --git a/test/CodeGen/nobuiltin.c b/test/CodeGen/nobuiltin.c new file mode 100644 index 000000000000..0a8e8bb4b6da --- /dev/null +++ b/test/CodeGen/nobuiltin.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fno-builtin -O1 -S -o - %s | FileCheck %s + +void PR13497() { + char content[2]; + // make sure we don't optimize this call to strcpy() + // CHECK: __strcpy_chk + __builtin___strcpy_chk(content, "", 1); +} diff --git a/test/CodeGen/ptx-cc.c b/test/CodeGen/nvptx-cc.c index 2212d4260b35..1c0d943f956b 100644 --- a/test/CodeGen/ptx-cc.c +++ b/test/CodeGen/nvptx-cc.c @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple ptx32-unknown-unknown -O3 -S -o %t %s -emit-llvm -// RUN: %clang_cc1 -triple ptx64-unknown-unknown -O3 -S -o %t %s -emit-llvm +// RUN: %clang_cc1 -triple nvptx-unknown-unknown -O3 -S -o %t %s -emit-llvm +// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -O3 -S -o %t %s -emit-llvm -// Just make sure Clang uses the proper calling convention for the PTX back-end. +// Just make sure Clang uses the proper calling convention for the NVPTX back-end. // If something is wrong, the back-end will fail. void foo(float* a, float* b) { diff --git a/test/CodeGen/nvptx-inlineasm.c b/test/CodeGen/nvptx-inlineasm.c new file mode 100644 index 000000000000..860b50ff5852 --- /dev/null +++ b/test/CodeGen/nvptx-inlineasm.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -triple nvptx-unknown-unknown -O3 -S -o - %s -emit-llvm | FileCheck %s +// RUN: %clang_cc1 -triple nvptx64-unknown-unknown -O3 -S -o - %s -emit-llvm | FileCheck %s + +int bar(int a) { + int result; + // CHECK: call i32 asm sideeffect "{ {{.*}} + asm __volatile__ ("{ \n\t" + ".reg .pred \t%%p1; \n\t" + ".reg .pred \t%%p2; \n\t" + "setp.ne.u32 \t%%p1, %1, 0; \n\t" + "vote.any.pred \t%%p2, %%p1; \n\t" + "selp.s32 \t%0, 1, 0, %%p2; \n\t" + "}" : "=r"(result) : "r"(a)); + return result; +} diff --git a/test/CodeGen/object-size.c b/test/CodeGen/object-size.c index 1f16d02d7d64..f6c7db835bf3 100644 --- a/test/CodeGen/object-size.c +++ b/test/CodeGen/object-size.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - 2>&1 | FileCheck %s #define strcpy(dest, src) \ ((__builtin_object_size(dest, 0) != -1ULL) \ @@ -55,7 +55,10 @@ void test6() { // CHECK: define void @test7 void test7() { int i; - // CHECK: = call i64 @llvm.objectsize.i64(i8* {{.*}}@gbuf{{.*}}, i1 false) + // Ensure we only evaluate the side-effect once. + // CHECK: = add + // CHECK-NOT: = add + // CHECK: = call i8* @__strcpy_chk(i8* getelementptr inbounds ([63 x i8]* @gbuf, i32 0, i32 0), i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i64 63) strcpy((++i, gbuf), "Hi there"); } @@ -124,6 +127,7 @@ void test16() { strcpy(gp += 1, "Hi there"); } +// CHECK: @test17 void test17() { // CHECK: store i32 -1 gi = __builtin_object_size(gp++, 0); @@ -134,3 +138,11 @@ void test17() { // CHECK: store i32 0 gi = __builtin_object_size(gp++, 3); } + +// CHECK: @test18 +unsigned test18(int cond) { + int a[4], b[4]; + // CHECK: phi i32* + // CHECK: call i64 @llvm.objectsize.i64 + return __builtin_object_size(cond ? a : b, 0); +} diff --git a/test/CodeGen/packed-nest-unpacked.c b/test/CodeGen/packed-nest-unpacked.c index 0ccc0c41b7e6..6097e3f32eae 100644 --- a/test/CodeGen/packed-nest-unpacked.c +++ b/test/CodeGen/packed-nest-unpacked.c @@ -45,3 +45,21 @@ void test6() { // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* bitcast (%struct.X* getelementptr inbounds (%struct.Y* @g, i32 0, i32 1) to i8*), i8* %{{.*}}, i64 24, i32 1, i1 false) g.y = foo(); } + + +struct XBitfield { + unsigned b1 : 10; + unsigned b2 : 12; + unsigned b3 : 10; +}; +struct YBitfield { + char x; + struct XBitfield y; +} __attribute((packed)); +struct YBitfield gbitfield; + +unsigned test7() { + // CHECK: @test7 + // CHECK: load i32* bitcast (%struct.XBitfield* getelementptr inbounds (%struct.YBitfield* @gbitfield, i32 0, i32 1) to i32*), align 1 + return gbitfield.y.b2; +} diff --git a/test/CodeGen/pclmul-builtins.c b/test/CodeGen/pclmul-builtins.c new file mode 100644 index 000000000000..cb0af28dbe0c --- /dev/null +++ b/test/CodeGen/pclmul-builtins.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +pclmul -emit-llvm -o - | FileCheck %s + +// Don't include mm_malloc.h, it's system specific. +#define __MM_MALLOC_H + +#include <wmmintrin.h> + +__m128i test_mm_clmulepi64_si128(__m128i a, __m128i b) { + // CHECK: @llvm.x86.pclmulqdq + return _mm_clmulepi64_si128(a, b, 0); +} diff --git a/test/CodeGen/powerpc_types.c b/test/CodeGen/powerpc_types.c index b7d0f5de4985..b4de31818845 100644 --- a/test/CodeGen/powerpc_types.c +++ b/test/CodeGen/powerpc_types.c @@ -1,3 +1,4 @@ +// REQUIRES: ppc32-registered-target // RUN: %clang_cc1 -triple powerpc-unknown-freebsd -emit-llvm -o - %s| FileCheck -check-prefix=SVR4-CHECK %s #include <stdarg.h> diff --git a/test/CodeGen/pr12251.c b/test/CodeGen/pr12251.c index a644bb79da55..b01713122141 100644 --- a/test/CodeGen/pr12251.c +++ b/test/CodeGen/pr12251.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -O1 -relaxed-aliasing -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -O1 -relaxed-aliasing -o - | FileCheck %s enum e1 {e1_a = -1 }; enum e1 g1(enum e1 *x) { diff --git a/test/CodeGen/pr13168.c b/test/CodeGen/pr13168.c new file mode 100644 index 000000000000..a848af472c96 --- /dev/null +++ b/test/CodeGen/pr13168.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - + +typedef int (*_MD_Open64)(int oflag, ...); +_MD_Open64 _open64; +void PR_OpenFile(int mode) { +_open64(0, mode); +} diff --git a/test/CodeGen/pr5406.c b/test/CodeGen/pr5406.c index da74d6b64fe5..2d198220a770 100644 --- a/test/CodeGen/pr5406.c +++ b/test/CodeGen/pr5406.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 %s -emit-llvm -triple arm-apple-darwin -o - | FileCheck %s // PR 5406 diff --git a/test/CodeGen/pragma-visibility.c b/test/CodeGen/pragma-visibility.c index 16460a28280e..a7fceb3d1ac1 100644 --- a/test/CodeGen/pragma-visibility.c +++ b/test/CodeGen/pragma-visibility.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o - %s | FileCheck %s #pragma GCC visibility push(hidden) int x = 2; diff --git a/test/CodeGen/rdrand-builtins.c b/test/CodeGen/rdrand-builtins.c new file mode 100644 index 000000000000..b7970f4dd427 --- /dev/null +++ b/test/CodeGen/rdrand-builtins.c @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -target-feature +rdrnd -emit-llvm -S -emit-llvm -o - %s | FileCheck %s + +// Don't include mm_malloc.h, it's system specific. +#define __MM_MALLOC_H + +#include <immintrin.h> + +int rdrand16(unsigned short *p) { + return _rdrand16_step(p); +// CHECK: @rdrand16 +// CHECK: call { i16, i32 } @llvm.x86.rdrand.16 +// CHECK: store i16 +} + +int rdrand32(unsigned *p) { + return _rdrand32_step(p); +// CHECK: @rdrand32 +// CHECK: call { i32, i32 } @llvm.x86.rdrand.32 +// CHECK: store i32 +} + +int rdrand64(unsigned long long *p) { + return _rdrand64_step(p); +// CHECK: @rdrand64 +// CHECK: call { i64, i32 } @llvm.x86.rdrand.64 +// CHECK: store i64 +} diff --git a/test/CodeGen/regparm-flag.c b/test/CodeGen/regparm-flag.c index 8ecf53950805..1330663e4528 100644 --- a/test/CodeGen/regparm-flag.c +++ b/test/CodeGen/regparm-flag.c @@ -1,5 +1,4 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 4 %s -emit-llvm -o %t -// RUN: FileCheck < %t %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -mregparm 4 %s -emit-llvm -o - | FileCheck %s void f1(int a, int b, int c, int d, int e, int f, int g, int h); diff --git a/test/CodeGen/regparm-struct.c b/test/CodeGen/regparm-struct.c new file mode 100644 index 000000000000..b31901266e6f --- /dev/null +++ b/test/CodeGen/regparm-struct.c @@ -0,0 +1,177 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s + +__attribute__((regparm(3))) void f1(int a, int b, int c, int d); +// CHECK: declare void @f1(i32 inreg, i32 inreg, i32 inreg, i32) +void g1() { + f1(41, 42, 43, 44); +} + +struct s1 { + int x1; +}; +__attribute__((regparm(3))) void f2(int a, int b, struct s1 c, int d); +// CHECK: declare void @f2(i32 inreg, i32 inreg, i32 inreg, i32) +void g2() { + struct s1 x = {43}; + f2(41, 42, x, 44); +} + +struct s2 { + int x1; + int x2; +}; +__attribute__((regparm(3))) void f3(int a, int b, struct s2 c, int d); +// CHECK: declare void @f3(i32 inreg, i32 inreg, i32, i32, i32) +void g3() { + struct s2 x = {43, 44}; + f3(41, 42, x, 45); +} +__attribute__((regparm(3))) void f4(int a, struct s2 b, int c); +// CHECK: declare void @f4(i32 inreg, i32 inreg, i32 inreg, i32) +void g4() { + struct s2 x = {42, 43}; + f4(41, x, 44); +} + +struct s3 { + int x1; + int x2; + int x3; +}; +__attribute__((regparm(3))) void f5(int a, struct s3 b, int c); +// CHECK: declare void @f5(i32 inreg, i32, i32, i32, i32) +void g5() { + struct s3 x = {42, 43, 44}; + f5(41, x, 45); +} +__attribute__((regparm(3))) void f6(struct s3 a, int b); +// CHECK: declare void @f6(i32 inreg, i32 inreg, i32 inreg, i32) +void g6() { + struct s3 x = {41, 42, 43}; + f6(x, 44); +} + +struct s4 { + int x1; + int x2; + int x3; + int x4; +}; +__attribute__((regparm(3))) void f7(struct s4 a, int b); +// CHECK: declare void @f7(i32, i32, i32, i32, i32) +void g7() { + struct s4 x = {41, 42, 43, 44}; + f7(x, 45); +} + +__attribute__((regparm(3))) void f8(float a, int b); +// CHECK: declare void @f8(float, i32 inreg) +void g8(void) { + f8(41, 42); +} + +struct s5 { + float x1; +}; +__attribute__((regparm(3))) void f9(struct s5 a, int b); +// CHECK: declare void @f9(float, i32 inreg) +void g9(void) { + struct s5 x = {41}; + f9(x, 42); +} + +struct s6 { + float x1; + int x2; +}; +__attribute__((regparm(3))) void f10(struct s6 a, int b); +// CHECK: declare void @f10(i32 inreg, i32 inreg, i32 inreg) +void g10(void) { + struct s6 x = {41, 42}; + f10(x, 43); +} + +struct s7 { + float x1; + int x2; + float x3; +}; +__attribute__((regparm(3))) void f11(struct s7 a, int b); +// CHECK: declare void @f11(i32 inreg, i32 inreg, i32 inreg, i32) +void g11(void) { + struct s7 x = {41, 42, 43}; + f11(x, 44); +} + +struct s8 { + float x1; + float x2; +}; +__attribute__((regparm(3))) void f12(struct s8 a, int b); +// CHECK: declare void @f12(i32 inreg, i32 inreg, i32 inreg) +void g12(void) { + struct s8 x = {41, 42}; + f12(x, 43); +} + +struct s9 { + float x1; + float x2; + float x3; +}; +__attribute__((regparm(3))) void f13(struct s9 a, int b); +// CHECK: declare void @f13(i32 inreg, i32 inreg, i32 inreg, i32) +void g13(void) { + struct s9 x = {41, 42, 43}; + f13(x, 44); +} + +struct s10 { + double x1; +}; +__attribute__((regparm(3))) void f14(struct s10 a, int b, int c); +// CHECK: declare void @f14(double, i32 inreg, i32 inreg) +void g14(void) { + struct s10 x = { 41 }; + f14(x, 42, 43); +} + +struct s11 { + double x1; + double x2; +}; +__attribute__((regparm(3))) void f15(struct s11 a, int b); +// CHECK: declare void @f15(double, double, i32) +void g15(void) { + struct s11 x = { 41, 42 }; + f15(x, 43); +} + +struct s12 { + double x1; + float x2; +}; +__attribute__((regparm(3))) void f16(struct s12 a, int b); +// CHECK: declare void @f16(i32 inreg, i32 inreg, i32 inreg, i32) +void g16(void) { + struct s12 x = { 41, 42 }; + f16(x, 43); +} + +__attribute__((regparm(3))) struct s12 f17(int a, int b, int c); +// CHECK: declare void @f17(%struct.s12* inreg sret, i32 inreg, i32 inreg, i32) +void g17(void) { + f17(41, 42, 43); +} + +struct s13 { + struct inner { + float x; + } y; +}; +__attribute__((regparm(3))) void f18(struct s13 a, int b, int c, int d); +// CHECK: declare void @f18(%struct.s13* byval align 4, i32 inreg, i32 inreg, i32 inreg) +void g18(void) { + struct s13 x = {{41}}; + f18(x, 42, 43, 44); +} diff --git a/test/CodeGen/sse-builtins.c b/test/CodeGen/sse-builtins.c index 2d5742515553..0e48560b0869 100644 --- a/test/CodeGen/sse-builtins.c +++ b/test/CodeGen/sse-builtins.c @@ -151,3 +151,9 @@ __m128d test_mm_round_sd(__m128d x, __m128d y) { // CHECK: @llvm.x86.sse41.round.sd return _mm_round_sd(x, y, 2); } + +void test_storel_epi64(__m128i x, void* y) { + // CHECK: define void @test_storel_epi64 + // CHECK: store {{.*}} i64* {{.*}}, align 1{{$}} + _mm_storel_epi64(y, x); +} diff --git a/test/CodeGen/sse4a-builtins.c b/test/CodeGen/sse4a-builtins.c new file mode 100644 index 000000000000..e1d7e8fb561b --- /dev/null +++ b/test/CodeGen/sse4a-builtins.c @@ -0,0 +1,39 @@ +// RUN: %clang_cc1 -ffreestanding -triple i386-apple-darwin9 -target-cpu pentium4 -target-feature +sse4a -g -emit-llvm %s -o - | FileCheck %s + +#include <ammintrin.h> + +__m128i test_extracti_si64(__m128i x) { + return _mm_extracti_si64(x, 3, 2); +// CHECK: @test_extracti_si64 +// CHECK: @llvm.x86.sse4a.extrqi(<2 x i64> %{{[^,]+}}, i8 3, i8 2) +} + +__m128i test_extract_si64(__m128i x, __m128i y) { + return _mm_extract_si64(x, y); +// CHECK: @test_extract_si64 +// CHECK: @llvm.x86.sse4a.extrq(<2 x i64> %{{[^,]+}}, <16 x i8> %{{[^,]+}}) +} + +__m128i test_inserti_si64(__m128i x, __m128i y) { + return _mm_inserti_si64(x, y, 5, 6); +// CHECK: @test_inserti_si64 +// CHECK: @llvm.x86.sse4a.insertqi(<2 x i64> %{{[^,]+}}, <2 x i64> %{{[^,]+}}, i8 5, i8 6) +} + +__m128i test_insert_si64(__m128i x, __m128i y) { + return _mm_insert_si64(x, y); +// CHECK: @test_insert_si64 +// CHECK: @llvm.x86.sse4a.insertq(<2 x i64> %{{[^,]+}}, <2 x i64> %{{[^,]+}}) +} + +void test_stream_sd(double *p, __m128d a) { + _mm_stream_sd(p, a); +// CHECK: @test_stream_sd +// CHECK: @llvm.x86.sse4a.movnt.sd(i8* %{{[^,]+}}, <2 x double> %{{[^,]+}}) +} + +void test_stream_ss(float *p, __m128 a) { + _mm_stream_ss(p, a); +// CHECK: @test_stream_ss +// CHECK: @llvm.x86.sse4a.movnt.ss(i8* %{{[^,]+}}, <4 x float> %{{[^,]+}}) +} diff --git a/test/CodeGen/struct-init.c b/test/CodeGen/struct-init.c index 6247729c17b7..5273138e4e5e 100644 --- a/test/CodeGen/struct-init.c +++ b/test/CodeGen/struct-init.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -S -triple armv7-apple-darwin %s -emit-llvm -o - | FileCheck %s typedef struct _zend_ini_entry zend_ini_entry; diff --git a/test/CodeGen/struct-matching-constraint.c b/test/CodeGen/struct-matching-constraint.c index 40c444f2b40d..bdd11c8b9000 100644 --- a/test/CodeGen/struct-matching-constraint.c +++ b/test/CodeGen/struct-matching-constraint.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -S -emit-llvm -triple armv7a-apple-darwin %s -o /dev/null typedef unsigned short uint16_t; typedef __attribute__((neon_vector_type(8))) uint16_t uint16x8_t; diff --git a/test/CodeGen/tbaa-for-vptr.cpp b/test/CodeGen/tbaa-for-vptr.cpp index 5ce6bf32edf3..b9a68fe0eae1 100644 --- a/test/CodeGen/tbaa-for-vptr.cpp +++ b/test/CodeGen/tbaa-for-vptr.cpp @@ -1,5 +1,13 @@ +// RUN: %clang_cc1 -emit-llvm -o - -O0 -fthread-sanitizer %s | FileCheck %s // RUN: %clang_cc1 -emit-llvm -o - -O1 %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -O1 -relaxed-aliasing -fthread-sanitizer %s | FileCheck %s +// +// RUN: %clang_cc1 -emit-llvm -o - -O0 %s | FileCheck %s --check-prefix=NOTBAA +// RUN: %clang_cc1 -emit-llvm -o - -O2 -relaxed-aliasing %s | FileCheck %s --check-prefix=NOTBAA +// // Check that we generate TBAA for vtable pointer loads and stores. +// When -fthread-sanitizer is used TBAA should be generated at all opt levels +// even if -relaxed-aliasing is present. struct A { virtual int foo() const ; virtual ~A(); @@ -15,5 +23,5 @@ void CallFoo(A *a) { // CHECK: %{{.*}} = load {{.*}} !tbaa !0 // CHECK: store {{.*}} !tbaa !0 -// CHECK: !0 = metadata !{metadata !"vtable pointer", metadata !1} -// CHECK: !1 = metadata !{metadata !"Simple C/C++ TBAA"} +// CHECK: = metadata !{metadata !"vtable pointer", metadata !{{.*}}} +// NOTBAA-NOT: = metadata !{metadata !"Simple C/C++ TBAA"} diff --git a/test/CodeGen/thread-specifier.c b/test/CodeGen/thread-specifier.c index a1f3e168000e..a2d3e62c8c5d 100644 --- a/test/CodeGen/thread-specifier.c +++ b/test/CodeGen/thread-specifier.c @@ -3,7 +3,13 @@ // CHECK: @b = external thread_local global // CHECK: @d.e = internal thread_local global // CHECK: @d.f = internal thread_local global +// CHECK: @f.a = internal thread_local(initialexec) global // CHECK: @a = thread_local global +// CHECK: @g = thread_local global +// CHECK: @h = thread_local(localdynamic) global +// CHECK: @i = thread_local(initialexec) global +// CHECK: @j = thread_local(localexec) global + __thread int a; extern __thread int b; int c() { return *&b; } @@ -13,3 +19,12 @@ int d() { return 0; } +__thread int g __attribute__((tls_model("global-dynamic"))); +__thread int h __attribute__((tls_model("local-dynamic"))); +__thread int i __attribute__((tls_model("initial-exec"))); +__thread int j __attribute__((tls_model("local-exec"))); + +int f() { + __thread static int a __attribute__((tls_model("initial-exec"))); + return a++; +} diff --git a/test/CodeGen/tls-model.c b/test/CodeGen/tls-model.c new file mode 100644 index 000000000000..b5bae77e97f3 --- /dev/null +++ b/test/CodeGen/tls-model.c @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD +// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=global-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-GD +// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=local-dynamic -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LD +// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=initial-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-IE +// RUN: %clang_cc1 %s -triple x86_64-pc-linux-gnu -ftls-model=local-exec -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-LE + +int __thread x; +int f() { + static int __thread y; + return y++; +} +int __thread __attribute__((tls_model("initial-exec"))) z; + +// CHECK-GD: @f.y = internal thread_local global i32 0 +// CHECK-GD: @x = thread_local global i32 0 +// CHECK-GD: @z = thread_local(initialexec) global i32 0 + +// CHECK-LD: @f.y = internal thread_local(localdynamic) global i32 0 +// CHECK-LD: @x = thread_local(localdynamic) global i32 0 +// CHECK-LD: @z = thread_local(initialexec) global i32 0 + +// CHECK-IE: @f.y = internal thread_local(initialexec) global i32 0 +// CHECK-IE: @x = thread_local(initialexec) global i32 0 +// CHECK-IE: @z = thread_local(initialexec) global i32 0 + +// CHECK-LE: @f.y = internal thread_local(localexec) global i32 0 +// CHECK-LE: @x = thread_local(localexec) global i32 0 +// CHECK-LE: @z = thread_local(initialexec) global i32 0 diff --git a/test/CodeGen/varargs.c b/test/CodeGen/varargs.c index b3dba240b559..b6973d8337d8 100644 --- a/test/CodeGen/varargs.c +++ b/test/CodeGen/varargs.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - %s +// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s // PR6433 - Don't crash on va_arg(typedef). @@ -9,3 +9,9 @@ void focus_changed_cb () { mfloat = __builtin_va_arg((pa), gdouble); } +void vararg(int, ...); +void function_as_vararg() { + // CHECK: define {{.*}}function_as_vararg + // CHECK-NOT: llvm.trap + vararg(0, focus_changed_cb); +} diff --git a/test/CodeGen/vector-alignment.c b/test/CodeGen/vector-alignment.c new file mode 100644 index 000000000000..92d1ae73f9e2 --- /dev/null +++ b/test/CodeGen/vector-alignment.c @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -w -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s +// rdar://11759609 + +// At or below target max alignment with no aligned attribute should align based +// on the size of vector. +double __attribute__((vector_size(16))) v1; +// CHECK: @v1 {{.*}}, align 16 +double __attribute__((vector_size(32))) v2; +// CHECK: @v2 {{.*}}, align 32 + +// Alignment above target max alignment with no aligned attribute should align +// based on the target max. +double __attribute__((vector_size(64))) v3; +// CHECK: @v3 {{.*}}, align 32 +double __attribute__((vector_size(1024))) v4; +// CHECK: @v4 {{.*}}, align 32 + +// Aliged attribute should always override. +double __attribute__((vector_size(16), aligned(16))) v5; +// CHECK: @v5 {{.*}}, align 16 +double __attribute__((vector_size(16), aligned(64))) v6; +// CHECK: @v6 {{.*}}, align 64 +double __attribute__((vector_size(32), aligned(16))) v7; +// CHECK: @v7 {{.*}}, align 16 +double __attribute__((vector_size(32), aligned(64))) v8; +// CHECK: @v8 {{.*}}, align 64 + +// Check non-power of 2 widths. +double __attribute__((vector_size(24))) v9; +// CHECK: @v9 {{.*}}, align 32 +double __attribute__((vector_size(40))) v10; +// CHECK: @v10 {{.*}}, align 32 + +// Check non-power of 2 widths with aligned attribute. +double __attribute__((vector_size(24), aligned(64))) v11; +// CHECK: @v11 {{.*}}, align 64 +double __attribute__((vector_size(80), aligned(16))) v12; +// CHECK: @v12 {{.*}}, align 16 diff --git a/test/CodeGen/vla.c b/test/CodeGen/vla.c index 9e62da52e026..e15182762706 100644 --- a/test/CodeGen/vla.c +++ b/test/CodeGen/vla.c @@ -142,3 +142,52 @@ int test4(unsigned n, char (*p)[n][n+1][6]) { // CHECK-NEXT: ret i32 [[T7]] return p2 - p; } + +// rdar://11485774 +void test5(void) +{ + // CHECK: define void @test5( + int a[5], i = 0; + // CHECK: [[A:%.*]] = alloca [5 x i32], align 4 + // CHECK-NEXT: [[I:%.*]] = alloca i32, align 4 + // CHECK-NEXT: [[CL:%.*]] = alloca i32*, align 4 + // CHECK-NEXT: store i32 0, i32* [[I]], align 4 + + (typeof(++i, (int (*)[i])a)){&a} += 0; + // CHECK-NEXT: [[Z:%.*]] = load i32* [[I]], align 4 + // CHECK-NEXT: [[INC:%.*]] = add nsw i32 [[Z]], 1 + // CHECK-NEXT: store i32 [[INC]], i32* [[I]], align 4 + // CHECK-NEXT: [[O:%.*]] = load i32* [[I]], align 4 + // CHECK-NEXT: [[AR:%.*]] = getelementptr inbounds [5 x i32]* [[A]], i32 0, i32 0 + // CHECK-NEXT: [[T:%.*]] = bitcast [5 x i32]* [[A]] to i32* + // CHECK-NEXT: store i32* [[T]], i32** [[CL]] + // CHECK-NEXT: [[TH:%.*]] = load i32** [[CL]] + // CHECK-NEXT: [[VLAIX:%.*]] = mul nsw i32 0, [[O]] + // CHECK-NEXT: [[ADDPTR:%.*]] = getelementptr inbounds i32* [[TH]], i32 [[VLAIX]] + // CHECK-NEXT: store i32* [[ADDPTR]], i32** [[CL]] +} + +void test6(void) +{ + // CHECK: define void @test6( + int n = 20, **a, i=0; + // CHECK: [[N:%.*]] = alloca i32, align 4 + // CHECK-NEXT: [[A:%.*]] = alloca i32**, align 4 + // CHECK-NEXT: [[I:%.*]] = alloca i32, align 4 + (int (**)[i]){&a}[0][1][5] = 0; + // CHECK-NEXT: [[CL:%.*]] = alloca i32**, align 4 + // CHECK-NEXT: store i32 20, i32* [[N]], align 4 + // CHECK-NEXT: store i32 0, i32* [[I]], align 4 + // CHECK-NEXT: [[Z:%.*]] = load i32* [[I]], align 4 + // CHECK-NEXT: [[O:%.*]] = bitcast i32*** [[A]] to i32** + // CHECK-NEXT: store i32** [[O]], i32*** [[CL]] + // CHECK-NEXT: [[T:%.*]] = load i32*** [[CL]] + // CHECK-NEXT: [[IX:%.*]] = getelementptr inbounds i32** [[T]], i32 0 + // CHECK-NEXT: [[TH:%.*]] = load i32** [[IX]], align 4 + // CHECK-NEXT: [[F:%.*]] = mul nsw i32 1, [[Z]] + // CHECK-NEXT: [[IX1:%.*]] = getelementptr inbounds i32* [[TH]], i32 [[F]] + // CHECK-NEXT: [[IX2:%.*]] = getelementptr inbounds i32* [[IX1]], i32 5 + // CHECK-NEXT: store i32 0, i32* [[IX2]], align 4 +} + + diff --git a/test/CodeGen/vld_dup.c b/test/CodeGen/vld_dup.c index e1d63cca2506..2bc251989b6a 100644 --- a/test/CodeGen/vld_dup.c +++ b/test/CodeGen/vld_dup.c @@ -1,3 +1,4 @@ +// REQUIRES: arm-registered-target // RUN: %clang_cc1 -triple armv7a-linux-gnueabi \ // RUN: -target-cpu cortex-a8 \ // RUN: -emit-llvm -O0 -o - %s | FileCheck %s diff --git a/test/CodeGen/x86_32-arguments-darwin.c b/test/CodeGen/x86_32-arguments-darwin.c index 0ac18b792f9f..5bbc80b9398b 100644 --- a/test/CodeGen/x86_32-arguments-darwin.c +++ b/test/CodeGen/x86_32-arguments-darwin.c @@ -324,3 +324,16 @@ void f64(struct s64 x) {} // CHECK: define float @f65() struct s65 { signed char a[0]; float b; }; struct s65 f65() { return (struct s65){{},2}; } + +// CHECK: define <2 x i64> @f66 +// CHECK: ptrtoint +// CHECK: and {{.*}}, -16 +// CHECK: inttoptr +typedef int T66 __attribute((vector_size(16))); +T66 f66(int i, ...) { + __builtin_va_list ap; + __builtin_va_start(ap, i); + T66 v = __builtin_va_arg(ap, T66); + __builtin_va_end(ap); + return v; +} diff --git a/test/CodeGen/xop-builtins.c b/test/CodeGen/xop-builtins.c new file mode 100644 index 000000000000..436deaa52134 --- /dev/null +++ b/test/CodeGen/xop-builtins.c @@ -0,0 +1,326 @@ +// RUN: %clang_cc1 %s -O3 -triple=x86_64-apple-darwin -target-feature +xop -emit-llvm -o - | FileCheck %s + +// Don't include mm_malloc.h, it's system specific. +#define __MM_MALLOC_H + +#include <x86intrin.h> + +__m128i test_mm_maccs_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacssww + return _mm_maccs_epi16(a, b, c); +} + +__m128i test_mm_macc_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacsww + return _mm_macc_epi16(a, b, c); +} + +__m128i test_mm_maccsd_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacsswd + return _mm_maccsd_epi16(a, b, c); +} + +__m128i test_mm_maccd_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacswd + return _mm_maccd_epi16(a, b, c); +} + +__m128i test_mm_maccs_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacssdd + return _mm_maccs_epi32(a, b, c); +} + +__m128i test_mm_macc_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacsdd + return _mm_macc_epi32(a, b, c); +} + +__m128i test_mm_maccslo_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacssdql + return _mm_maccslo_epi32(a, b, c); +} + +__m128i test_mm_macclo_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacsdql + return _mm_macclo_epi32(a, b, c); +} + +__m128i test_mm_maccshi_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacssdqh + return _mm_maccshi_epi32(a, b, c); +} + +__m128i test_mm_macchi_epi32(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmacsdqh + return _mm_macchi_epi32(a, b, c); +} + +__m128i test_mm_maddsd_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmadcsswd + return _mm_maddsd_epi16(a, b, c); +} + +__m128i test_mm_maddd_epi16(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpmadcswd + return _mm_maddd_epi16(a, b, c); +} + +__m128i test_mm_haddw_epi8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddbw + return _mm_haddw_epi8(a); +} + +__m128i test_mm_haddd_epi8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddbd + return _mm_haddd_epi8(a); +} + +__m128i test_mm_haddq_epi8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddbq + return _mm_haddq_epi8(a); +} + +__m128i test_mm_haddd_epi16(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddwd + return _mm_haddd_epi16(a); +} + +__m128i test_mm_haddq_epi16(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddwq + return _mm_haddq_epi16(a); +} + +__m128i test_mm_haddq_epi32(__m128i a) { + // CHECK: @llvm.x86.xop.vphadddq + return _mm_haddq_epi32(a); +} + +__m128i test_mm_haddw_epu8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddubw + return _mm_haddw_epu8(a); +} + +__m128i test_mm_haddd_epu8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddubd + return _mm_haddd_epu8(a); +} + +__m128i test_mm_haddq_epu8(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddubq + return _mm_haddq_epu8(a); +} + +__m128i test_mm_haddd_epu16(__m128i a) { + // CHECK: @llvm.x86.xop.vphadduwd + return _mm_haddd_epu16(a); +} + +__m128i test_mm_haddq_epu16(__m128i a) { + // CHECK: @llvm.x86.xop.vphadduwq + return _mm_haddq_epu16(a); +} + +__m128i test_mm_haddq_epu32(__m128i a) { + // CHECK: @llvm.x86.xop.vphaddudq + return _mm_haddq_epu32(a); +} + +__m128i test_mm_hsubw_epi8(__m128i a) { + // CHECK: @llvm.x86.xop.vphsubbw + return _mm_hsubw_epi8(a); +} + +__m128i test_mm_hsubd_epi16(__m128i a) { + // CHECK: @llvm.x86.xop.vphsubwd + return _mm_hsubd_epi16(a); +} + +__m128i test_mm_hsubq_epi32(__m128i a) { + // CHECK: @llvm.x86.xop.vphsubdq + return _mm_hsubq_epi32(a); +} + +__m128i test_mm_cmov_si128(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpcmov + return _mm_cmov_si128(a, b, c); +} + +__m256i test_mm256_cmov_si256(__m256i a, __m256i b, __m256i c) { + // CHECK: @llvm.x86.xop.vpcmov.256 + return _mm256_cmov_si256(a, b, c); +} + +__m128i test_mm_perm_epi8(__m128i a, __m128i b, __m128i c) { + // CHECK: @llvm.x86.xop.vpperm + return _mm_perm_epi8(a, b, c); +} + +__m128i test_mm_rot_epi8(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vprotb + return _mm_rot_epi8(a, b); +} + +__m128i test_mm_rot_epi16(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vprotw + return _mm_rot_epi16(a, b); +} + +__m128i test_mm_rot_epi32(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vprotd + return _mm_rot_epi32(a, b); +} + +__m128i test_mm_rot_epi64(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vprotq + return _mm_rot_epi64(a, b); +} + +__m128i test_mm_roti_epi8(__m128i a) { + // CHECK: @llvm.x86.xop.vprotbi + return _mm_roti_epi8(a, 1); +} + +__m128i test_mm_roti_epi16(__m128i a) { + // CHECK: @llvm.x86.xop.vprotwi + return _mm_roti_epi16(a, 50); +} + +__m128i test_mm_roti_epi32(__m128i a) { + // CHECK: @llvm.x86.xop.vprotdi + return _mm_roti_epi32(a, -30); +} + +__m128i test_mm_roti_epi64(__m128i a) { + // CHECK: @llvm.x86.xop.vprotqi + return _mm_roti_epi64(a, 100); +} + +__m128i test_mm_shl_epi8(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshlb + return _mm_shl_epi8(a, b); +} + +__m128i test_mm_shl_epi16(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshlw + return _mm_shl_epi16(a, b); +} + +__m128i test_mm_shl_epi32(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshld + return _mm_shl_epi32(a, b); +} + +__m128i test_mm_shl_epi64(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshlq + return _mm_shl_epi64(a, b); +} + +__m128i test_mm_sha_epi8(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshab + return _mm_sha_epi8(a, b); +} + +__m128i test_mm_sha_epi16(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshaw + return _mm_sha_epi16(a, b); +} + +__m128i test_mm_sha_epi32(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshad + return _mm_sha_epi32(a, b); +} + +__m128i test_mm_sha_epi64(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpshaq + return _mm_sha_epi64(a, b); +} + +__m128i test_mm_com_epu8(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomub + return _mm_com_epu8(a, b, 0); +} + +__m128i test_mm_com_epu16(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomuw + return _mm_com_epu16(a, b, 0); +} + +__m128i test_mm_com_epu32(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomud + return _mm_com_epu32(a, b, 0); +} + +__m128i test_mm_com_epu64(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomuq + return _mm_com_epu64(a, b, 0); +} + +__m128i test_mm_com_epi8(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomb + return _mm_com_epi8(a, b, 0); +} + +__m128i test_mm_com_epi16(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomw + return _mm_com_epi16(a, b, 0); +} + +__m128i test_mm_com_epi32(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomd + return _mm_com_epi32(a, b, 0); +} + +__m128i test_mm_com_epi64(__m128i a, __m128i b) { + // CHECK: @llvm.x86.xop.vpcomq + return _mm_com_epi64(a, b, 0); +} + +__m128d test_mm_permute2_pd(__m128d a, __m128d b, __m128i c) { + // CHECK: @llvm.x86.xop.vpermil2pd + return _mm_permute2_pd(a, b, c, 0); +} + +__m256d test_mm256_permute2_pd(__m256d a, __m256d b, __m256i c) { + // CHECK: @llvm.x86.xop.vpermil2pd.256 + return _mm256_permute2_pd(a, b, c, 0); +} + +__m128 test_mm_permute2_ps(__m128 a, __m128 b, __m128i c) { + // CHECK: @llvm.x86.xop.vpermil2ps + return _mm_permute2_ps(a, b, c, 0); +} + +__m256 test_mm256_permute2_ps(__m256 a, __m256 b, __m256i c) { + // CHECK: @llvm.x86.xop.vpermil2ps.256 + return _mm256_permute2_ps(a, b, c, 0); +} + +__m128 test_mm_frcz_ss(__m128 a) { + // CHECK: @llvm.x86.xop.vfrcz.ss + return _mm_frcz_ss(a); +} + +__m128d test_mm_frcz_sd(__m128d a) { + // CHECK: @llvm.x86.xop.vfrcz.sd + return _mm_frcz_sd(a); +} + +__m128 test_mm_frcz_ps(__m128 a) { + // CHECK: @llvm.x86.xop.vfrcz.ps + return _mm_frcz_ps(a); +} + +__m128d test_mm_frcz_pd(__m128d a) { + // CHECK: @llvm.x86.xop.vfrcz.pd + return _mm_frcz_pd(a); +} + +__m256 test_mm256_frcz_ps(__m256 a) { + // CHECK: @llvm.x86.xop.vfrcz.ps.256 + return _mm256_frcz_ps(a); +} + +__m256d test_mm256_frcz_pd(__m256d a) { + // CHECK: @llvm.x86.xop.vfrcz.pd.256 + return _mm256_frcz_pd(a); +} diff --git a/test/CodeGenCUDA/address-spaces.cu b/test/CodeGenCUDA/address-spaces.cu new file mode 100644 index 000000000000..61d4d6b6ba48 --- /dev/null +++ b/test/CodeGenCUDA/address-spaces.cu @@ -0,0 +1,24 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -fcuda-is-device -triple nvptx-unknown-unknown | FileCheck %s + +#include "../SemaCUDA/cuda.h" + +// CHECK: @i = addrspace(1) global +__device__ int i; + +// CHECK: @j = addrspace(4) global +__constant__ int j; + +// CHECK: @k = addrspace(3) global +__shared__ int k; + +__device__ void foo() { + // CHECK: load i32* bitcast (i32 addrspace(1)* @i to i32*) + i++; + + // CHECK: load i32* bitcast (i32 addrspace(4)* @j to i32*) + j++; + + // CHECK: load i32* bitcast (i32 addrspace(3)* @k to i32*) + k++; +} + diff --git a/test/CodeGenCUDA/ptx-kernels.cu b/test/CodeGenCUDA/ptx-kernels.cu index ecca8519af63..f0bf2952a126 100644 --- a/test/CodeGenCUDA/ptx-kernels.cu +++ b/test/CodeGenCUDA/ptx-kernels.cu @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple ptx32-unknown-unknown -fcuda-is-device -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -fcuda-is-device -emit-llvm -o - | FileCheck %s #include "../SemaCUDA/cuda.h" diff --git a/test/CodeGenCXX/anonymous-union-member-initializer.cpp b/test/CodeGenCXX/anonymous-union-member-initializer.cpp index a12ae53f395f..8dc4f4721dd0 100644 --- a/test/CodeGenCXX/anonymous-union-member-initializer.cpp +++ b/test/CodeGenCXX/anonymous-union-member-initializer.cpp @@ -179,3 +179,13 @@ namespace PR9683 { }; QueueEntry QE; } + +namespace PR13154 { + struct IndirectReferenceField { + struct { + float &x; + }; + IndirectReferenceField(float &x); + }; + IndirectReferenceField::IndirectReferenceField(float &xx) : x(xx) {} +} diff --git a/test/CodeGenCXX/block-in-ctor-dtor.cpp b/test/CodeGenCXX/block-in-ctor-dtor.cpp index e4389a4eeec8..4ee6b1c10eb1 100644 --- a/test/CodeGenCXX/block-in-ctor-dtor.cpp +++ b/test/CodeGenCXX/block-in-ctor-dtor.cpp @@ -36,13 +36,13 @@ X::~X() { }; +// CHECK: define internal void @___ZN4ZoneC2Ev_block_invoke // CHECK: define internal void @___ZN4ZoneC2Ev_block_invoke_ -// CHECK: define internal void @___ZN4ZoneC2Ev_block_invoke_ -// CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke_ +// CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke // CHECK: define internal void @___ZN4ZoneD2Ev_block_invoke_ +// CHECK: define internal void @___ZN1XC1Ev_block_invoke // CHECK: define internal void @___ZN1XC1Ev_block_invoke_ -// CHECK: define internal void @___ZN1XC1Ev_block_invoke_ +// CHECK: define internal void @___ZN1XC2Ev_block_invoke // CHECK: define internal void @___ZN1XC2Ev_block_invoke_ -// CHECK: define internal void @___ZN1XC2Ev_block_invoke_ -// CHECK: define internal void @___ZN1XD2Ev_block_invoke_ +// CHECK: define internal void @___ZN1XD2Ev_block_invoke // CHECK: define internal void @___ZN1XD2Ev_block_invoke_ diff --git a/test/CodeGenCXX/blocks.cpp b/test/CodeGenCXX/blocks.cpp index eb544787da7e..1500c0d69835 100644 --- a/test/CodeGenCXX/blocks.cpp +++ b/test/CodeGenCXX/blocks.cpp @@ -2,8 +2,8 @@ namespace test0 { // CHECK: define void @_ZN5test04testEi( - // CHECK: define internal void @__test_block_invoke_{{.*}}( - // CHECK: define internal void @__block_global_{{.*}}( + // CHECK: define internal void @___ZN5test04testEi_block_invoke{{.*}}( + // CHECK: define internal void @___ZN5test04testEi_block_invoke_2{{.*}}( void test(int x) { ^{ ^{ (void) x; }; }; } @@ -119,7 +119,7 @@ namespace test4 { consume(^{ return foo(A()); }); } // CHECK: define void @_ZN5test44testEv() - // CHECK: define internal void @__test_block_invoke + // CHECK: define internal void @___ZN5test44testEv_block_invoke // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align 1 // CHECK-NEXT: bitcast i8* // CHECK-NEXT: call void @_ZN5test41AC1Ev([[A]]* [[TMP]]) diff --git a/test/CodeGenCXX/class-layout.cpp b/test/CodeGenCXX/class-layout.cpp index dac0a0ae5467..21e1a2b40f04 100644 --- a/test/CodeGenCXX/class-layout.cpp +++ b/test/CodeGenCXX/class-layout.cpp @@ -77,3 +77,17 @@ namespace Test6 { class E : public B {}; E *e; } + +// <rdar://problem/11324125>: Make sure this doesn't crash. (It's okay +// if we start rejecting it at some point.) +namespace Test7 { + #pragma pack (1) + class A {}; + // CHECK: %"class.Test7::B" = type <{ i32 (...)**, %"class.Test7::A" }> + class B { + virtual ~B(); + A a; + }; + B* b; + #pragma pack () +} diff --git a/test/CodeGenCXX/const-init-cxx11.cpp b/test/CodeGenCXX/const-init-cxx11.cpp index 62a345a49564..db1bb412606b 100644 --- a/test/CodeGenCXX/const-init-cxx11.cpp +++ b/test/CodeGenCXX/const-init-cxx11.cpp @@ -49,6 +49,17 @@ namespace StructUnion { // CHECK: @_ZN11StructUnion1fE = global {{.*}} { i32 5 } D f; + + union E { + int a; + void *b = &f; + }; + + // CHECK: @_ZN11StructUnion1gE = global {{.*}} @_ZN11StructUnion1fE + E g; + + // CHECK: @_ZN11StructUnion1hE = global {{.*}} @_ZN11StructUnion1fE + E h = E(); } namespace BaseClass { @@ -110,6 +121,13 @@ namespace Array { }; // CHECK: @_ZN5Array1eE = constant {{.*}} { [4 x i8] c"foo\00", [4 x i8] c"x\00\00\00" } extern constexpr E e = E(); + + // PR13290 + struct F { constexpr F() : n(4) {} int n; }; + // CHECK: @_ZN5Array2f1E = global {{.*}} zeroinitializer + F f1[1][1][0] = { }; + // CHECK: @_ZN5Array2f2E = global {{.* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4 .* i32 4}} + F f2[2][2][2] = { }; } namespace MemberPtr { @@ -298,6 +316,20 @@ namespace VirtualMembers { static nsMemoryImpl sGlobalMemory; } +namespace PR13273 { + struct U { + int t; + U() = default; + }; + + struct S : U { + S() = default; + }; + + // CHECK: @_ZN7PR132731sE = {{.*}} zeroinitializer + extern const S s {}; +} + // Constant initialization tests go before this point, // dynamic initialization tests go after. diff --git a/test/CodeGenCXX/constructor-init.cpp b/test/CodeGenCXX/constructor-init.cpp index 9f808f6680ed..b33184e3966e 100644 --- a/test/CodeGenCXX/constructor-init.cpp +++ b/test/CodeGenCXX/constructor-init.cpp @@ -131,6 +131,26 @@ namespace rdar9694300 { } } +// Check that we emit a zero initialization step for list-value-initialization +// which calls a trivial default constructor. +namespace PR13273 { + struct U { + int t; + U() = default; + }; + + struct S : U { + S() = default; + }; + + // CHECK: define {{.*}}@_ZN7PR132731fEv( + int f() { + // CHECK-NOT: } + // CHECK: llvm.memset{{.*}}i8 0 + return (new S{})->t; + } +} + template<typename T> struct X { X(const X &); diff --git a/test/CodeGenCXX/cxx0x-delegating-ctors.cpp b/test/CodeGenCXX/cxx0x-delegating-ctors.cpp index f5684d93abd9..ad6492f5bfdc 100644 --- a/test/CodeGenCXX/cxx0x-delegating-ctors.cpp +++ b/test/CodeGenCXX/cxx0x-delegating-ctors.cpp @@ -54,3 +54,14 @@ delegator::delegator(char) delegator::delegator(int) : delegator() {} + +namespace PR12890 { + class X { + int x; + X() = default; + X(int); + }; + X::X(int) : X() {} +} +// CHECK: define {{.*}} @_ZN7PR128901XC1Ei(%"class.PR12890::X"* %this, i32) +// CHECK: call void @llvm.memset.p0i8.{{i32|i64}}(i8* {{.*}}, i8 0, {{i32|i64}} 4, i32 4, i1 false) diff --git a/test/CodeGenCXX/cxx0x-initializer-constructors.cpp b/test/CodeGenCXX/cxx0x-initializer-constructors.cpp new file mode 100644 index 000000000000..48fbe85d0d7a --- /dev/null +++ b/test/CodeGenCXX/cxx0x-initializer-constructors.cpp @@ -0,0 +1,37 @@ +// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s | FileCheck %s + +struct S { + S(int x) { } + S(int x, double y, double z) { } +}; + +void fn1() { + // CHECK: define void @_Z3fn1v + S s { 1 }; + // CHECK: alloca %struct.S, align 1 + // CHECK: call void @_ZN1SC1Ei(%struct.S* %s, i32 1) +} + +void fn2() { + // CHECK: define void @_Z3fn2v + S s { 1, 2.0, 3.0 }; + // CHECK: alloca %struct.S, align 1 + // CHECK: call void @_ZN1SC1Eidd(%struct.S* %s, i32 1, double 2.000000e+00, double 3.000000e+00) +} + +void fn3() { + // CHECK: define void @_Z3fn3v + S sa[] { { 1 }, { 2 }, { 3 } }; + // CHECK: alloca [3 x %struct.S], align 1 + // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 1) + // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 2) + // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 3) +} + +void fn4() { + // CHECK: define void @_Z3fn4v + S sa[] { { 1, 2.0, 3.0 }, { 4, 5.0, 6.0 } }; + // CHECK: alloca [2 x %struct.S], align 1 + // CHECK: call void @_ZN1SC1Eidd(%struct.S* %{{.+}}, i32 1, double 2.000000e+00, double 3.000000e+00) + // CHECK: call void @_ZN1SC1Eidd(%struct.S* %{{.+}}, i32 4, double 5.000000e+00, double 6.000000e+00) +} diff --git a/test/CodeGenCXX/cxx0x-initializer-references.cpp b/test/CodeGenCXX/cxx0x-initializer-references.cpp index 4c847b8e583c..660b018460db 100644 --- a/test/CodeGenCXX/cxx0x-initializer-references.cpp +++ b/test/CodeGenCXX/cxx0x-initializer-references.cpp @@ -28,6 +28,10 @@ namespace reference { // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** % A &ra1a = {a}; + using T = A&; + // CHECK-NEXT: store %{{.*}}* %{{.*}}, %{{.*}}** % + A &ra1b = T{a}; + // CHECK-NEXT: ret } diff --git a/test/CodeGenCXX/cxx11-initializer-aggregate.cpp b/test/CodeGenCXX/cxx11-initializer-aggregate.cpp new file mode 100644 index 000000000000..acc77825ae84 --- /dev/null +++ b/test/CodeGenCXX/cxx11-initializer-aggregate.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -std=c++11 -S -emit-llvm -o - %s -triple x86_64-linux-gnu | FileCheck %s + +struct A { int a, b; int f(); }; + +// CHECK: define {{.*}}@_Z3fn1i( +int fn1(int x) { + // CHECK: %[[INITLIST:.*]] = alloca %struct.A + // CHECK: %[[A:.*]] = getelementptr inbounds %struct.A* %[[INITLIST]], i32 0, i32 0 + // CHECK: store i32 %{{.*}}, i32* %[[A]], align 4 + // CHECK: %[[B:.*]] = getelementptr inbounds %struct.A* %[[INITLIST]], i32 0, i32 1 + // CHECK: store i32 5, i32* %[[B]], align 4 + // CHECK: call i32 @_ZN1A1fEv(%struct.A* %[[INITLIST]]) + return A{x, 5}.f(); +} + +struct B { int &r; int &f() { return r; } }; + +// CHECK: define {{.*}}@_Z3fn2Ri( +int &fn2(int &v) { + // CHECK: %[[INITLIST2:.*]] = alloca %struct.B, align 8 + // CHECK: %[[R:.*]] = getelementptr inbounds %struct.B* %[[INITLIST2:.*]], i32 0, i32 0 + // CHECK: store i32* %{{.*}}, i32** %[[R]], align 8 + // CHECK: call i32* @_ZN1B1fEv(%struct.B* %[[INITLIST2:.*]]) + return B{v}.f(); +} diff --git a/test/CodeGenCXX/cxx11-vtable-key-function.cpp b/test/CodeGenCXX/cxx11-vtable-key-function.cpp new file mode 100644 index 000000000000..cd2ab59506d4 --- /dev/null +++ b/test/CodeGenCXX/cxx11-vtable-key-function.cpp @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - -std=c++11 | FileCheck %s +// PR13424 + +namespace Test1 { +struct X { + virtual ~X(); // Key function. + virtual void f(); // Not a key function. +}; + +X::~X() = default; + +// Verify that the vtable is emitted. +// CHECK: @_ZTVN5Test11XE = unnamed_addr constant +} + +namespace Test2 { +struct X { + virtual ~X() = default; // Not a key function. + virtual void f(); // Key function. +}; + +void X::f() {} + +// Verify that the vtable is emitted. +// CHECK: @_ZTVN5Test21XE = unnamed_addr constant +} + +namespace Test3 { +struct X { + virtual ~X() = delete; // Not a key function. + virtual void f(); // Key function. +}; + +void X::f() {} + +// Verify that the vtable is emitted. +// CHECK: @_ZTVN5Test31XE = unnamed_addr constant +} diff --git a/test/CodeGenCXX/debug-info-artificial-arg.cpp b/test/CodeGenCXX/debug-info-artificial-arg.cpp index 92d1b162f533..35e5f2775fd7 100644 --- a/test/CodeGenCXX/debug-info-artificial-arg.cpp +++ b/test/CodeGenCXX/debug-info-artificial-arg.cpp @@ -23,8 +23,8 @@ int main(int argc, char **argv) { } // FIXME: The numbers are truly awful. -// CHECK: !18 = metadata !{i32 {{.*}}, i32 0, metadata !"", i32 0, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !19} ; [ DW_TAG_pointer_type ] -// CHECK: !19 = metadata !{i32 {{.*}}, null, metadata !"A", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !20, i32 0, metadata !19, null} ; [ DW_TAG_class_type ] -// CHECK: metadata !19, metadata !"A", metadata !"A", metadata !"", metadata !6, i32 12, metadata !45, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !47, i32 12} ; [ DW_TAG_subprogram ] -// CHECK: metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !46, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] -// CHECK: !46 = metadata !{null, metadata !18, metadata !9, metadata !34} +// CHECK: !16 = metadata !{i32 {{.*}}, i32 0, metadata !"", i32 0, i32 0, i64 64, i64 64, i64 0, i32 64, metadata !17} ; [ DW_TAG_pointer_type ] +// CHECK: !17 = metadata !{i32 {{.*}}, null, metadata !"A", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !18, i32 0, metadata !17, null} ; [ DW_TAG_class_type ] +// CHECK: metadata !17, metadata !"A", metadata !"A", metadata !"", metadata !6, i32 12, metadata !43, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !45, i32 12} ; [ DW_TAG_subprogram ] +// CHECK: metadata !"", i32 0, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !44, i32 0, i32 0} ; [ DW_TAG_subroutine_type ] +// CHECK: !44 = metadata !{null, metadata !16, metadata !9, metadata !32} diff --git a/test/CodeGenCXX/debug-info-cxx0x.cpp b/test/CodeGenCXX/debug-info-cxx0x.cpp index 37ccdb01c5c0..9d303755be0e 100644 --- a/test/CodeGenCXX/debug-info-cxx0x.cpp +++ b/test/CodeGenCXX/debug-info-cxx0x.cpp @@ -6,3 +6,13 @@ namespace PR9414 { return x; } } + +// Don't crash. +namespace PR13570 { + template<typename T, typename U> struct P {}; + template<typename T> struct A { + template<typename U> static P<T,U> isa(U); + decltype(isa(int())) f() {} + }; + template struct A<int>; +} diff --git a/test/CodeGenCXX/debug-info-determinism.cpp b/test/CodeGenCXX/debug-info-determinism.cpp new file mode 100644 index 000000000000..a96a14e9edcd --- /dev/null +++ b/test/CodeGenCXX/debug-info-determinism.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -S -emit-llvm -g -o %t1.ll %s +// RUN: %clang_cc1 -S -emit-llvm -g -o %t2.ll %s +// RUN: diff %t1.ll %t2.ll + +template <int N> struct C { + template <int M> int f() { + int arr[M] = {}; + return arr[M/2] + C<M/2>().template f<M-1>(); + } +}; +template <> template <> int C<0>::f<0>() { return 0; } +template <> template <> int C<0>::f<1>() { return 0; } +template <> template <> int C<1>::f<0>() { return 0; } +template <> template <> int C<1>::f<1>() { return 0; } + +int x = C<0>().f<64>(); diff --git a/test/CodeGenCXX/debug-info-enum-class.cpp b/test/CodeGenCXX/debug-info-enum-class.cpp new file mode 100644 index 000000000000..6f88439b1eed --- /dev/null +++ b/test/CodeGenCXX/debug-info-enum-class.cpp @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s + +enum class A { A1=1 }; // underlying type is int by default +enum class B: unsigned long { B1=1 }; // underlying type is unsigned long +enum C { C1 = 1 }; +enum D : short; // enum forward declaration +A a; +B b; +C c; +D d; + +// CHECK: metadata !{i32 {{.*}}, null, metadata !"A", metadata !4, i32 3, i64 32, i64 32, i32 0, i32 0, metadata !5, metadata !6, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"B", metadata !4, i32 4, i64 64, i64 64, i32 0, i32 0, metadata !9, metadata !10, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"C", metadata !4, i32 5, i64 32, i64 32, i32 0, i32 0, null, metadata !13, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"D", metadata !4, i32 6, i64 16, i64 16, i32 0, i32 4, null, metadata !16, i32 0, i32 0} ; [ DW_TAG_enumeration_type ] diff --git a/test/CodeGenCXX/debug-info-flex-member.cpp b/test/CodeGenCXX/debug-info-flex-member.cpp new file mode 100644 index 000000000000..b6aa6dac6bce --- /dev/null +++ b/test/CodeGenCXX/debug-info-flex-member.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s + +// CHECK: metadata !{i32 {{.*}}, i64 1, i64 0} ; [ DW_TAG_subrange_type ] + +struct StructName { + int member[]; +}; + +struct StructName SN; diff --git a/test/CodeGenCXX/debug-info-fwd-ref.cpp b/test/CodeGenCXX/debug-info-fwd-ref.cpp index 5480c6b14fd9..e7f2ed19d79f 100644 --- a/test/CodeGenCXX/debug-info-fwd-ref.cpp +++ b/test/CodeGenCXX/debug-info-fwd-ref.cpp @@ -19,8 +19,8 @@ int main(int argc, char** argv) { // Make sure we have two DW_TAG_class_types for baz and bar and no forward // references. // FIXME: These should be struct types to match the declaration. -// CHECK: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !20, i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 32, i64 32, i32 0, i32 0, null, metadata !23, i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 9, i64 0, i64 0, i32 0, i32 4, i32 0, null, i32 0, i32 0} ; [ DW_TAG_class_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 128, i64 64, i32 0, i32 0, null, metadata !18, i32 0, null, null} ; [ DW_TAG_class_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 32, i64 32, i32 0, i32 0, null, metadata !21, i32 0, null, null} ; [ DW_TAG_class_type ] +// CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"bar", metadata !6, i32 8, i64 0, i64 0, i32 0, i32 4, i32 0, null, i32 0, i32 0} ; [ DW_TAG_class_type ] // CHECK-NOT: metadata !{i32 {{.*}}, null, metadata !"baz", metadata !6, i32 3, i64 0, i64 0, i32 0, i32 4, null, null, i32 0, null, null} ; [ DW_TAG_class_type ] diff --git a/test/CodeGenCXX/debug-info-gline-tables-only.cpp b/test/CodeGenCXX/debug-info-gline-tables-only.cpp new file mode 100644 index 000000000000..8d2e63d67778 --- /dev/null +++ b/test/CodeGenCXX/debug-info-gline-tables-only.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 %s -O0 -gline-tables-only -S -emit-llvm -o - | FileCheck %s +// Checks that clang with "-gline-tables-only" doesn't emit debug info +// for variables and types. + +// CHECK-NOT: DW_TAG_namespace +namespace NS { +// CHECK-NOT: DW_TAG_class_type +// CHECK-NOT: DW_TAG_friend +class C { friend class D; }; +class D {}; +// CHECK-NOT: DW_TAG_inheritance +class E : public C { + // CHECK-NOT: DW_TAG_reference type + void x(const D& d); +}; +} + +// CHECK-NOT: DW_TAG_variable +NS::C c; +NS::D d; +NS::E e; diff --git a/test/CodeGenCXX/debug-info-globalinit.cpp b/test/CodeGenCXX/debug-info-globalinit.cpp new file mode 100644 index 000000000000..ff50fac4cfa3 --- /dev/null +++ b/test/CodeGenCXX/debug-info-globalinit.cpp @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -std=c++11 -g | FileCheck %s + +void crash() { + volatile char *ptr = 0; + char x = *ptr; +} + +int test() { + crash(); + return 1; +} + +static int i = test(); +__attribute__((nodebug)) static int j = test(); + +int main(void) {} + +// CHECK: define internal void @__cxx_global_var_init() +// CHECK-NOT: __cxx_global_var_init +// CHECK: %[[C0:.+]] = call i32 @_Z4testv(), !dbg ![[LINE:.*]] +// CHECK-NOT: __cxx_global_var_init +// CHECK: store i32 %[[C0]], i32* @_ZL1i, align 4, !dbg +// +// CHECK: define internal void @__cxx_global_var_init1() +// CHECK-NOT: dbg +// CHECK: %[[C1:.+]] = call i32 @_Z4testv() +// CHECK-NOT: dbg +// CHECK: store i32 %[[C1]], i32* @_ZL1j, align 4 +// +// CHECK: ![[LINE]] = metadata !{i32 13, i32 16 diff --git a/test/CodeGenCXX/debug-info-nullptr.cpp b/test/CodeGenCXX/debug-info-nullptr.cpp index 5540a9217cbe..4cc7e546d889 100644 --- a/test/CodeGenCXX/debug-info-nullptr.cpp +++ b/test/CodeGenCXX/debug-info-nullptr.cpp @@ -4,4 +4,4 @@ void foo() { decltype(nullptr) t = 0; } -// CHECK: !13 = metadata !{i32 {{.*}}, null, metadata !"nullptr_t", null, i32 0, i64 0, i64 0, i64 0, i32 0, i32 0} ; [ DW_TAG_unspecified_type ] +// CHECK: metadata !{i32 {{.*}}, null, metadata !"nullptr_t", null, i32 0, i64 0, i64 0, i64 0, i32 0, i32 0} ; [ DW_TAG_unspecified_type ] diff --git a/test/CodeGenCXX/debug-info-rvalue-ref.cpp b/test/CodeGenCXX/debug-info-rvalue-ref.cpp new file mode 100644 index 000000000000..b633c5ceb507 --- /dev/null +++ b/test/CodeGenCXX/debug-info-rvalue-ref.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s + +extern "C" { +extern int printf(const char * format, ...); +} +void foo (int &&i) +{ + printf("%d\n", i); +} + +// CHECK: metadata !{i32 {{.*}}, null, null, null, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !10} ; [ DW_TAG_rvalue_reference_type ] diff --git a/test/CodeGenCXX/debug-info-static-fns.cpp b/test/CodeGenCXX/debug-info-static-fns.cpp index 485d28aa7b7c..ee46f259a42e 100644 --- a/test/CodeGenCXX/debug-info-static-fns.cpp +++ b/test/CodeGenCXX/debug-info-static-fns.cpp @@ -7,4 +7,4 @@ namespace A { } // Verify that a is present and mangled. -// CHECK: metadata !{i32 786478, i32 0, metadata !6, metadata !"a", metadata !"a", metadata !"_ZN1AL1aEi", metadata !7, i32 4, metadata !8, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_ZN1AL1aEi, null, null, metadata !14, i32 4} ; [ DW_TAG_subprogram ] +// CHECK: metadata !{i32 {{.*}}, i32 0, metadata !6, metadata !"a", metadata !"a", metadata !"_ZN1AL1aEi", metadata !7, i32 4, metadata !8, i1 true, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_ZN1AL1aEi, null, null, metadata !1, i32 4} ; [ DW_TAG_subprogram ] diff --git a/test/CodeGenCXX/debug-info-template-array.cpp b/test/CodeGenCXX/debug-info-template-array.cpp new file mode 100644 index 000000000000..305327bbe099 --- /dev/null +++ b/test/CodeGenCXX/debug-info-template-array.cpp @@ -0,0 +1,14 @@ +// RUN: %clang -emit-llvm -g -S %s -o - +// PR13531 +template <typename> +struct unique_ptr { + unique_ptr() {} +}; + +template <unsigned> +struct Vertex {}; + +void crash() // Asserts +{ + unique_ptr<Vertex<2>[]> v = unique_ptr<Vertex<2>[]>(); +} diff --git a/test/CodeGenCXX/debug-info-template-limit.cpp b/test/CodeGenCXX/debug-info-template-limit.cpp index 796a80fd627f..afad31b14efa 100644 --- a/test/CodeGenCXX/debug-info-template-limit.cpp +++ b/test/CodeGenCXX/debug-info-template-limit.cpp @@ -1,8 +1,8 @@ // RUN: %clang -flimit-debug-info -emit-llvm -g -S %s -o - | FileCheck %s // Check that this pointer type is TC<int> -// CHECK: !10} ; [ DW_TAG_pointer_type -// CHECK-NEXT: !10 ={{.*}}"TC<int>" +// CHECK: ![[LINE:[0-9]+]]} ; [ DW_TAG_pointer_type ]{{.*}}[from TC<int>] +// CHECK-NEXT: ![[LINE]] ={{.*}}"TC<int>" template<typename T> class TC { @@ -12,4 +12,3 @@ public: }; TC<int> tci; - diff --git a/test/CodeGenCXX/debug-info-template-member.cpp b/test/CodeGenCXX/debug-info-template-member.cpp index 6208c80aeb61..f21718da5e67 100644 --- a/test/CodeGenCXX/debug-info-template-member.cpp +++ b/test/CodeGenCXX/debug-info-template-member.cpp @@ -17,5 +17,5 @@ private: MyClass m; // CHECK: metadata !{i32 {{.*}}, null, metadata !"MyClass", metadata {{.*}}, i32 {{.*}}, i64 8, i64 8, i32 0, i32 0, null, metadata [[C_MEM:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[C_MEM]] = metadata !{metadata {{.*}}, metadata [[C_TEMP:.*]], metadata {{.*}}} +// CHECK: [[C_MEM]] = metadata !{metadata {{.*}}, metadata [[C_TEMP:.*]]} // CHECK: [[C_TEMP]] = metadata !{i32 {{.*}}, i32 0, metadata {{.*}}, metadata !"add<2>", metadata !"add<2>", metadata !"_ZN7MyClass3addILi2EEEii", metadata {{.*}} diff --git a/test/CodeGenCXX/debug-info-template-quals.cpp b/test/CodeGenCXX/debug-info-template-quals.cpp new file mode 100644 index 000000000000..e5a9082c9c29 --- /dev/null +++ b/test/CodeGenCXX/debug-info-template-quals.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin %s -o - | FileCheck %s + +template<typename _CharT> +struct basic_string { + + basic_string& + assign(const _CharT* __s) + { + return *this; + } +}; + +void foo (const char *c) { + basic_string<char> str; + str.assign(c); +} + +// CHECK: [[P:.*]] = metadata !{i32 {{.*}}, metadata [[CON:.*]]} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from ] +// CHECK: [[CON]] = metadata !{i32 {{.*}}, metadata [[CH:.*]]} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from char] +// CHECK: [[CH]] = metadata !{i32 {{.*}}, metadata !"char", {{.*}}} ; [ DW_TAG_base_type ] [char] [line 0, size 8, align 8, offset 0, enc DW_ATE_signed_char] +// CHECK: metadata !{i32 {{.*}}, metadata !"_ZN12basic_stringIcE6assignEPKc", metadata !6, i32 7, metadata [[TYPE:.*]], i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, %struct.basic_string* (%struct.basic_string*, i8*)* @_ZN12basic_stringIcE6assignEPKc, null, metadata !18, metadata !1, i32 8} ; [ DW_TAG_subprogram ] [line 7] [def] [scope 8] [assign] +// CHECK: [[TYPE]] = metadata !{i32 {{.*}}, null, metadata [[ARGS:.*]], i32 0, i32 0} +// CHECK: [[ARGS]] = metadata !{metadata !15, metadata !23, metadata [[P]]} diff --git a/test/CodeGenCXX/debug-info-union.cpp b/test/CodeGenCXX/debug-info-union.cpp new file mode 100644 index 000000000000..588fa203367b --- /dev/null +++ b/test/CodeGenCXX/debug-info-union.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s + +union E { + int a; + float b; + int bb() { return a;} + float aa() { return b;} + E() { a = 0; } +}; + +E e; + +// CHECK: metadata !{i32 {{.*}}, null, metadata !"E", metadata !{{.*}}, i32 3, i64 32, i64 32, i64 0, i32 0, null, metadata !{{.*}}, i32 0, null} ; [ DW_TAG_union_type ] +// CHECK: metadata !{i32 {{.*}}, i32 0, metadata !{{.*}}, metadata !"bb", metadata !"bb", metadata !"_ZN1E2bbEv", metadata !{{.*}}, i32 6, metadata !{{.*}}, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !{{.*}}, i32 6} ; [ DW_TAG_subprogram ] +// CHECK: metadata !{i32 {{.*}}, i32 0, metadata !{{.*}}, metadata !"aa", metadata !"aa", metadata !"_ZN1E2aaEv", metadata !{{.*}}, i32 7, metadata !{{.*}}, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !{{.*}}, i32 7} ; [ DW_TAG_subprogram ] +// CHECK: metadata !{i32 {{.*}}, i32 0, metadata !{{.*}}, metadata !"E", metadata !"E", metadata !"", metadata !{{.*}}, i32 8, metadata !{{.*}}, i1 false, i1 false, i32 0, i32 0, null, i32 256, i1 false, null, null, i32 0, metadata !{{.*}}, i32 8} ; [ DW_TAG_subprogram ] diff --git a/test/CodeGenCXX/debug-info-user-def.cpp b/test/CodeGenCXX/debug-info-user-def.cpp new file mode 100644 index 000000000000..ecd387870549 --- /dev/null +++ b/test/CodeGenCXX/debug-info-user-def.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s + +class A { +}; + +template <typename T> class B { + T t; +}; + +A a; +B<int> b; + +// Check that no subprograms are emitted into debug info. +// CHECK-NOT: [ DW_TAG_subprogram ] diff --git a/test/CodeGenCXX/debug-lambda-expressions.cpp b/test/CodeGenCXX/debug-lambda-expressions.cpp index 859a71b621ca..1c823990c1d9 100644 --- a/test/CodeGenCXX/debug-lambda-expressions.cpp +++ b/test/CodeGenCXX/debug-lambda-expressions.cpp @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 -g | FileCheck %s auto var = [](int i) { return i+1; }; +void *use = &var; extern "C" auto cvar = []{}; @@ -13,59 +14,56 @@ int c(int x) { return [&x]{return x;}(); } struct D { D(); D(const D&); int x; }; int d(int x) { D y[10]; [x,y] { return y[x].x; }(); } - -// A: 5 -// CHECK: [[A_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE:.*]], metadata !"a", metadata !"a", metadata !"_Z1av", metadata {{.*}}, i32 [[A_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_Z1av, null, null, {{.*}} [ DW_TAG_subprogram ] - // Randomness for file. -- 6 -// CHECK: [[FILE]] = metadata !{i32 {{.*}}, metadata !{{.*}}debug-lambda-expressions.cpp{{.*}}; [ DW_TAG_file_type ] +// CHECK: [[FILE:.*]] = metadata !{i32 {{.*}}, metadata !{{.*}}debug-lambda-expressions.cpp{{.*}}; [ DW_TAG_file_type ] + +// A: 10 +// CHECK: [[A_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE]], metadata !"a", metadata !"a", metadata !"_Z1av", metadata {{.*}}, i32 [[A_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @_Z1av, null, null, {{.*}} [ DW_TAG_subprogram ] -// B: 12 +// B: 14 // CHECK: [[B_FUNC:.*]] = metadata !{i32 786478, i32 0, metadata [[FILE]], metadata !"b", metadata !"b", metadata !"_Z1bi", metadata [[FILE]], i32 [[B_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1bi, null, null, {{.*}} ; [ DW_TAG_subprogram ] // C: 17 // CHECK: [[C_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE]], metadata !"c", metadata !"c", metadata !"_Z1ci", metadata [[FILE]], i32 [[C_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1ci, null, null, metadata {{.*}} ; [ DW_TAG_subprogram ] -// D: 20 +// D: 18 // CHECK: [[D_FUNC:.*]] = metadata !{i32 {{.*}}, i32 0, metadata [[FILE]], metadata !"d", metadata !"d", metadata !"_Z1di", metadata [[FILE]], i32 [[D_LINE:.*]], metadata {{.*}}, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 (i32)* @_Z1di, null, null, metadata {{.*}} ; [ DW_TAG_subprogram ] -// Back to D. -- 120 +// Back to D. -- 24 // CHECK: [[LAM_D:.*]] = metadata !{i32 {{.*}}, metadata [[D_FUNC]], metadata !"", metadata [[FILE]], i32 [[D_LINE]], i64 352, i64 32, i32 0, i32 0, null, metadata [[LAM_D_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[LAM_D_ARGS]] = metadata !{metadata [[CAP_D_X:.*]], metadata [[CAP_D_Y:.*]], metadata [[CON_LAM_D:.*]], metadata [[DES_LAM_D:.*]]} -// CHECK: [[CAP_D_X]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"x", metadata [[FILE]], i32 14, i64 32, i64 32, i64 0, i32 1, metadata {{.*}} ; [ DW_TAG_member ] -// CHECK: [[CAP_D_Y]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"y", metadata [[FILE]], i32 14, i64 320, i64 32, i64 32, i32 1, metadata {{.*}} ; [ DW_TAG_member ] +// CHECK: [[LAM_D_ARGS]] = metadata !{metadata [[CAP_D_X:.*]], metadata [[CAP_D_Y:.*]], metadata [[CON_LAM_D:.*]]} +// CHECK: [[CAP_D_X]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"x", metadata [[FILE]], i32 [[D_LINE]], i64 32, i64 32, i64 0, i32 1, metadata {{.*}} ; [ DW_TAG_member ] +// CHECK: [[CAP_D_Y]] = metadata !{i32 {{.*}}, metadata [[LAM_D]], metadata !"y", metadata [[FILE]], i32 [[D_LINE]], i64 320, i64 32, i64 32, i32 1, metadata {{.*}} ; [ DW_TAG_member ] // CHECK: [[CON_LAM_D]] = metadata {{.*}}[[LAM_D]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ] -// CHECK: [[DES_LAM_D]] = metadata {{.*}}[[LAM_D]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ] -// Back to C. -- 159 +// Back to C. -- 55 // CHECK: [[LAM_C:.*]] = metadata !{i32 {{.*}}, metadata [[C_FUNC]], metadata !"", metadata [[FILE]], i32 [[C_LINE]], i64 64, i64 64, i32 0, i32 0, null, metadata [[LAM_C_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[LAM_C_ARGS]] = metadata !{metadata [[CAP_C:.*]], metadata [[CON_LAM_C:.*]], metadata [[DES_LAM_C:.*]]} +// CHECK: [[LAM_C_ARGS]] = metadata !{metadata [[CAP_C:.*]], metadata [[CON_LAM_C:.*]]} // Ignoring the member type for now. // CHECK: [[CAP_C]] = metadata !{i32 {{.*}}, metadata [[LAM_C]], metadata !"x", metadata [[FILE]], i32 [[C_LINE]], i64 64, i64 64, i64 0, i32 1, metadata {{.*}}} ; [ DW_TAG_member ] // CHECK: [[CON_LAM_C]] = metadata {{.*}}[[LAM_C]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ] -// CHECK: [[DES_LAM_C]] = metadata {{.*}}[[LAM_C]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ] -// Back to B. -- 179 +// Back to B. -- 67 // CHECK: [[LAM_B:.*]] = metadata !{i32 {{.*}}, metadata [[B_FUNC]], metadata !"", metadata [[FILE]], i32 [[B_LINE]], i64 32, i64 32, i32 0, i32 0, null, metadata [[LAM_B_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[LAM_B_ARGS]] = metadata !{metadata [[CAP_B:.*]], metadata [[CON_LAM_B:.*]], metadata [[DES_LAM_B:.*]]} +// CHECK: [[LAM_B_ARGS]] = metadata !{metadata [[CAP_B:.*]], metadata [[CON_LAM_B:.*]]} // CHECK: [[CAP_B]] = metadata !{i32 {{.*}}, metadata [[LAM_B]], metadata !"x", metadata [[FILE]], i32 [[B_LINE]], i64 32, i64 32, i64 0, i32 1, metadata {{.*}}} ; [ DW_TAG_member ] // CHECK: [[CON_LAM_B]] = metadata {{.*}}[[LAM_B]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ] -// CHECK: [[DES_LAM_B]] = metadata {{.*}}[[LAM_B]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ] -// Back to A. -- 204 + +// Back to A. -- 78 // CHECK: [[LAM_A:.*]] = metadata !{i32 {{.*}}, metadata [[A_FUNC]], metadata !"", metadata [[FILE]], i32 [[A_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata [[LAM_A_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[LAM_A_ARGS]] = metadata !{metadata [[CON_LAM_A:.*]], metadata [[DES_LAM_A:.*]]} +// CHECK: [[LAM_A_ARGS]] = metadata !{metadata [[CON_LAM_A:.*]]} // CHECK: [[CON_LAM_A]] = metadata {{.*}}[[LAM_A]], metadata !"operator()", metadata !"operator()"{{.*}}[ DW_TAG_subprogram ] -// CHECK: [[DES_LAM_A]] = metadata {{.*}}[[LAM_A]], metadata !"~", metadata !"~"{{.*}}[ DW_TAG_subprogram ] -// VAR: -// CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"var", metadata !"var", metadata !"", metadata [[FILE]], i32 [[VAR_LINE:.*]], metadata ![[VAR_T:.*]], i32 1, i32 1, %class.anon* @var} ; [ DW_TAG_variable ] -// CHECK: [[VAR_T]] = metadata !{i32 {{.*}}, null, metadata !"", metadata [[FILE]], i32 [[VAR_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata ![[VAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[VAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}} // CVAR: // CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"cvar", metadata !"cvar", metadata !"", metadata [[FILE]], i32 [[CVAR_LINE:.*]], metadata ![[CVAR_T:.*]], i32 0, i32 1, %class.anon.0* @cvar} ; [ DW_TAG_variable ] // CHECK: [[CVAR_T]] = metadata !{i32 {{.*}}, null, metadata !"", metadata [[FILE]], i32 [[CVAR_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata ![[CVAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] -// CHECK: [[CVAR_ARGS]] = metadata !{metadata !{{.*}}, metadata !{{.*}}, metadata !{{.*}}} +// CHECK: [[CVAR_ARGS]] = metadata !{metadata !{{.*}}} + +// VAR: +// CHECK: metadata !{i32 {{.*}}, i32 0, null, metadata !"var", metadata !"var", metadata !"", metadata [[FILE]], i32 [[VAR_LINE:.*]], metadata ![[VAR_T:.*]], i32 1, i32 1, %class.anon* @var} ; [ DW_TAG_variable ] +// CHECK: [[VAR_T]] = metadata !{i32 {{.*}}, null, metadata !"", metadata [[FILE]], i32 [[VAR_LINE]], i64 8, i64 8, i32 0, i32 0, null, metadata ![[VAR_ARGS:.*]], i32 0, null, null} ; [ DW_TAG_class_type ] +// CHECK: [[VAR_ARGS]] = metadata !{metadata !{{.*}}} diff --git a/test/CodeGenCXX/derived-to-base-conv.cpp b/test/CodeGenCXX/derived-to-base-conv.cpp index 8c51809e0427..9b15c6804dfc 100644 --- a/test/CodeGenCXX/derived-to-base-conv.cpp +++ b/test/CodeGenCXX/derived-to-base-conv.cpp @@ -1,85 +1,86 @@ -// REQUIRES: x86-registered-target,x86-64-registered-target -// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s -// RUN: %clang_cc1 -triple i386-apple-darwin -std=c++11 -S %s -o %t-32.s -// RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s - -extern "C" int printf(...); -extern "C" void exit(int); +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | FileCheck %s struct A { - A (const A&) { printf("A::A(const A&)\n"); } - A() {}; - ~A() { printf("A::~A()\n"); } + A(const A&); + A(); + ~A(); }; struct B : public A { - B() {}; - B(const B& Other) : A(Other) { printf("B::B(const B&)\n"); } - ~B() { printf("B::~B()\n"); } + B(); + B(const B& Other); + ~B(); }; struct C : public B { - C() {}; - C(const C& Other) : B(Other) { printf("C::C(const C&)\n"); } - ~C() { printf("C::~C()\n"); } + C(); + C(const C& Other); + ~C(); }; struct X { - operator B&() {printf("X::operator B&()\n"); return b; } - operator C&() {printf("X::operator C&()\n"); return c; } - X (const X&) { printf("X::X(const X&)\n"); } - X () { printf("X::X()\n"); } - ~X () { printf("X::~X()\n"); } - B b; - C c; + operator B&(); + operator C&(); + X(const X&); + X(); + ~X(); + B b; + C c; }; -void f(A) { - printf("f(A)\n"); -} - - -void func(X x) -{ - f (x); -} - -int main() -{ - X x; - func(x); +void test0_helper(A); +void test0(X x) { + test0_helper(x); + // CHECK: define void @_Z5test01X( + // CHECK: [[TMP:%.*]] = alloca [[A:%.*]], align + // CHECK-NEXT: [[T0:%.*]] = call [[B:%.*]]* @_ZN1XcvR1BEv( + // CHECK-NEXT: [[T1:%.*]] = bitcast [[B]]* [[T0]] to [[A]]* + // CHECK-NEXT: call void @_ZN1AC1ERKS_([[A]]* [[TMP]], [[A]]* [[T1]]) + // CHECK-NEXT: call void @_Z12test0_helper1A([[A]]* [[TMP]]) + // CHECK-NEXT: call void @_ZN1AD1Ev([[A]]* [[TMP]]) + // CHECK-NEXT: ret void } struct Base; struct Root { - operator Base&() { exit(1); } + operator Base&(); }; struct Derived; struct Base : Root { - Base(const Base&) { printf("Base::(const Base&)\n"); } - Base() { printf("Base::Base()\n"); } - operator Derived&() { exit(1); } + Base(const Base &); + Base(); + operator Derived &(); }; struct Derived : Base { }; -void foo(Base) {} - -void test(Derived bb) -{ - // CHECK-LP64-NOT: callq __ZN4BasecvR7DerivedEv - // CHECK-LP32-NOT: callq L__ZN4BasecvR7DerivedEv - foo(bb); +void test1_helper(Base); +void test1(Derived bb) { + // CHECK: define void @_Z5test17Derived( + // CHECK-NOT: call {{.*}} @_ZN4BasecvR7DerivedEv( + // CHECK: call void @_ZN4BaseC1ERKS_( + // CHECK-NOT: call {{.*}} @_ZN4BasecvR7DerivedEv( + // CHECK: call void @_Z12test1_helper4Base( + test1_helper(bb); } -// CHECK-LP64: callq __ZN1XcvR1BEv -// CHECK-LP64: callq __ZN1AC1ERKS_ - -// CHECK-LP32: calll L__ZN1XcvR1BEv -// CHECK-LP32: calll L__ZN1AC1ERKS_ - +// Don't crash after devirtualizing a derived-to-base conversion +// to an empty base allocated at offset zero. +// rdar://problem/11993704 +class Test2a {}; +class Test2b final : public virtual Test2a {}; +void test2(Test2b &x) { + Test2a &y = x; + // CHECK: define void @_Z5test2R6Test2b( + // CHECK: [[X:%.*]] = alloca [[B:%.*]]*, align 8 + // CHECK-NEXT: [[Y:%.*]] = alloca [[A:%.*]]*, align 8 + // CHECK-NEXT: store [[B]]* {{%.*}}, [[B]]** [[X]], align 8 + // CHECK-NEXT: [[T0:%.*]] = load [[B]]** [[X]], align 8 + // CHECK-NEXT: [[T1:%.*]] = bitcast [[B]]* [[T0]] to [[A]]* + // CHECK-NEXT: store [[A]]* [[T1]], [[A]]** [[Y]], align 8 + // CHECK-NEXT: ret void +} diff --git a/test/CodeGenCXX/destructor-debug-info.cpp b/test/CodeGenCXX/destructor-debug-info.cpp index 9e32275d3394..385c86d9be19 100644 --- a/test/CodeGenCXX/destructor-debug-info.cpp +++ b/test/CodeGenCXX/destructor-debug-info.cpp @@ -1,6 +1,5 @@ -// RUN: %clang_cc1 -g -S -emit-llvm -o %t %s -// RUN: grep "i32 20, i32 3, metadata" %t | count 1 -// Check there is a line number entry for line 20 where b1 is destructed. +// RUN: %clang_cc1 -g -S -emit-llvm %s -o - | FileCheck %s + class A { int a; }; class B { public: @@ -19,3 +18,5 @@ void foo() { fn (b1); } } +// Check there is a line number entry for line 19 where b1 is destructed. +// CHECK: i32 19, i32 3, metadata diff --git a/test/CodeGenCXX/destructor-exception-spec.cpp b/test/CodeGenCXX/destructor-exception-spec.cpp new file mode 100644 index 000000000000..579daef8541f --- /dev/null +++ b/test/CodeGenCXX/destructor-exception-spec.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -emit-llvm-only %s -std=c++11 + +// PR13479: don't crash with -fno-exceptions. +namespace { + struct SchedulePostRATDList { + virtual ~SchedulePostRATDList(); + }; + + SchedulePostRATDList::~SchedulePostRATDList() {} + + SchedulePostRATDList Scheduler; +} diff --git a/test/CodeGenCXX/destructors.cpp b/test/CodeGenCXX/destructors.cpp index d9962e615ec5..d665445f959e 100644 --- a/test/CodeGenCXX/destructors.cpp +++ b/test/CodeGenCXX/destructors.cpp @@ -350,6 +350,22 @@ namespace test8 { // CHECK: unreachable } +// PR12710 +namespace test9 { + struct ArgType { + ~ArgType(); + }; + template<typename T> + void f1(const ArgType& = ArgType()); + void f2(); + void bar() { + f1<int>(); + f2(); + } + // CHECK: call void @_ZN5test97ArgTypeD1Ev(%"struct.test9::ArgType"* % + // CHECK: call void @_ZN5test92f2Ev() +} + // Checks from test3: // CHECK: define internal void @_ZN5test312_GLOBAL__N_11DD0Ev(%"struct.test3::<anonymous namespace>::D"* %this) unnamed_addr diff --git a/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp b/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp index 3de75ed3db54..634bf84b416d 100644 --- a/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp +++ b/test/CodeGenCXX/devirtualize-virtual-function-calls-final.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -o - | FileCheck %s namespace Test1 { struct A { @@ -49,3 +49,140 @@ namespace Test3 { return static_cast<B*>(v)->f(); } } + +namespace Test4 { + struct A { + virtual void f(); + }; + + struct B final : A { + virtual void f(); + }; + + // CHECK: define void @_ZN5Test41fEPNS_1BE + void f(B* d) { + // CHECK: call void @_ZN5Test41B1fEv + static_cast<A*>(d)->f(); + } +} + +namespace Test5 { + struct A { + virtual void f(); + }; + + struct B : A { + virtual void f(); + }; + + struct C final : B { + }; + + // CHECK: define void @_ZN5Test51fEPNS_1CE + void f(C* d) { + // FIXME: It should be possible to devirtualize this case, but that is + // not implemented yet. + // CHECK: getelementptr + // CHECK-NEXT: %[[FUNC:.*]] = load + // CHECK-NEXT: call void %[[FUNC]] + static_cast<A*>(d)->f(); + } +} + +namespace Test6 { + struct A { + virtual ~A(); + }; + + struct B : public A { + virtual ~B(); + }; + + struct C { + virtual ~C(); + }; + + struct D final : public C, public B { + }; + + // CHECK: define void @_ZN5Test61fEPNS_1DE + void f(D* d) { + // CHECK: call void @_ZN5Test61DD1Ev + static_cast<A*>(d)->~A(); + } +} + +namespace Test7 { + struct foo { + virtual void g() {} + }; + + struct bar { + virtual int f() { return 0; } + }; + + struct zed final : public foo, public bar { + int z; + virtual int f() {return z;} + }; + + // CHECK: define i32 @_ZN5Test71fEPNS_3zedE + int f(zed *z) { + // CHECK: alloca + // CHECK-NEXT: store + // CHECK-NEXT: load + // CHECK-NEXT: bitcast + // CHECK-NEXT: call {{.*}} @_ZN5Test73zed1fEv + // CHECK-NEXT: ret + return static_cast<bar*>(z)->f(); + } +} + +namespace Test8 { + struct A { virtual ~A() {} }; + struct B { + int b; + virtual int foo() { return b; } + }; + struct C final : A, B { }; + // CHECK: define i32 @_ZN5Test84testEPNS_1CE + int test(C *c) { + // CHECK: %[[THIS:.*]] = phi + // CHECK-NEXT: call i32 @_ZN5Test81B3fooEv(%"struct.Test8::B"* %[[THIS]]) + return static_cast<B*>(c)->foo(); + } +} + +namespace Test9 { + struct A { + int a; + }; + struct B { + int b; + }; + struct C : public B, public A { + }; + struct RA { + virtual A *f() { + return 0; + } + }; + struct RC final : public RA { + virtual C *f() { + C *x = new C(); + x->a = 1; + x->b = 2; + return x; + } + }; + // CHECK: define {{.*}} @_ZN5Test91fEPNS_2RCE + A *f(RC *x) { + // FIXME: It should be possible to devirtualize this case, but that is + // not implemented yet. + // CHECK: getelementptr + // CHECK-NEXT: %[[FUNC:.*]] = load + // CHECK-NEXT: bitcast + // CHECK-NEXT: = call {{.*}} %[[FUNC]] + return static_cast<RA*>(x)->f(); + } +} diff --git a/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp b/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp index 5eede66cd7b4..c5a4094a53c3 100644 --- a/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp +++ b/test/CodeGenCXX/devirtualize-virtual-function-calls.cpp @@ -53,3 +53,33 @@ void f() { B().h().f(); } +namespace test2 { + struct foo { + virtual void f(); + virtual ~foo(); + }; + + struct bar : public foo { + virtual void f(); + virtual ~bar(); + }; + + void f(bar *b) { + // CHECK: call void @_ZN5test23foo1fEv + // CHECK: call void @_ZN5test23fooD1Ev + b->foo::f(); + b->foo::~foo(); + } +} + +namespace test3 { + // Test that we don't crash in this case. + struct B { + }; + struct D : public B { + }; + void f(D d) { + // CHECK: define void @_ZN5test31fENS_1DE + d.B::~B(); + } +} diff --git a/test/CodeGenCXX/dynamic-cast-always-null.cpp b/test/CodeGenCXX/dynamic-cast-always-null.cpp index 2c3ea13d1957..836cb110da31 100644 --- a/test/CodeGenCXX/dynamic-cast-always-null.cpp +++ b/test/CodeGenCXX/dynamic-cast-always-null.cpp @@ -17,3 +17,8 @@ C &f(B& b) { // CHECK: ret %struct.C* undef return dynamic_cast<C&>(b); } + +void dont_crash() { + (void) dynamic_cast<void*>((A*)0); + (void) dynamic_cast<void*>((B*)0); +} diff --git a/test/CodeGenCXX/exceptions.cpp b/test/CodeGenCXX/exceptions.cpp index 079c1e5e725f..8c20c9e9ce21 100644 --- a/test/CodeGenCXX/exceptions.cpp +++ b/test/CodeGenCXX/exceptions.cpp @@ -414,3 +414,39 @@ namespace test9 { // CHECK: [[TEST9_NEW:%.*]] = call noalias i8* @_Znam // CHECK: call void @_ZdaPv(i8* [[TEST9_NEW]]) } + +// In a destructor with a function-try-block, a return statement in a +// catch handler behaves differently from running off the end of the +// catch handler. PR13102. +namespace test10 { + extern void cleanup(); + extern bool suppress; + + struct A { ~A(); }; + A::~A() try { cleanup(); } catch (...) { return; } + // CHECK: define void @_ZN6test101AD1Ev( + // CHECK: invoke void @_ZN6test107cleanupEv() + // CHECK-NOT: rethrow + // CHECK: ret void + + struct B { ~B(); }; + B::~B() try { cleanup(); } catch (...) {} + // CHECK: define void @_ZN6test101BD1Ev( + // CHECK: invoke void @_ZN6test107cleanupEv() + // CHECK: call i8* @__cxa_begin_catch + // CHECK-NEXT: invoke void @__cxa_rethrow() + // CHECK: unreachable + + struct C { ~C(); }; + C::~C() try { cleanup(); } catch (...) { if (suppress) return; } + // CHECK: define void @_ZN6test101CD1Ev( + // CHECK: invoke void @_ZN6test107cleanupEv() + // CHECK: call i8* @__cxa_begin_catch + // CHECK-NEXT: load i8* @_ZN6test108suppressE, align 1 + // CHECK-NEXT: trunc + // CHECK-NEXT: br i1 + // CHECK: call void @__cxa_end_catch() + // CHECK-NEXT: br label + // CHECK: invoke void @__cxa_rethrow() + // CHECK: unreachable +} diff --git a/test/CodeGenCXX/global-array-destruction.cpp b/test/CodeGenCXX/global-array-destruction.cpp index 5b5dfac0f228..076ef942201d 100644 --- a/test/CodeGenCXX/global-array-destruction.cpp +++ b/test/CodeGenCXX/global-array-destruction.cpp @@ -1,6 +1,4 @@ -// REQUIRES: x86-64-registered-target -// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -S %s -o %t-64.s -// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin -std=c++11 -emit-llvm %s -o - | FileCheck %s extern "C" int printf(...); @@ -24,11 +22,24 @@ static S sarr1[4]; S s2; S arr3[3]; -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit -// CHECK-LP64: callq ___cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: call {{.*}} @__cxa_atexit + +struct T { + double d; + int n; + ~T(); +}; +T t[2][3] = { 1.0, 2, 3.0, 4, 5.0, 6, 7.0, 8, 9.0, 10, 11.0, 12 }; + +// CHECK: call {{.*}} @__cxa_atexit +// CHECK: getelementptr inbounds ({{.*}} bitcast {{.*}}* @t to %struct.T*), i64 6 +// CHECK: call void @_ZN1TD1Ev +// CHECK: icmp eq {{.*}} @t +// CHECK: br i1 {{.*}} diff --git a/test/CodeGenCXX/global-block-literal-helpers.cpp b/test/CodeGenCXX/global-block-literal-helpers.cpp new file mode 100644 index 000000000000..350ea548662c --- /dev/null +++ b/test/CodeGenCXX/global-block-literal-helpers.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -std=c++11 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 %s | FileCheck %s +// rdar://11343499 + +namespace N { + typedef void (^BL)(); + int func(BL, BL, BL); + +// CHECK: define internal void @_ZN1N8ArrBlockE_block_invoke( +// CHECK: define internal void @_ZN1N8ArrBlockE_block_invoke_2( +// CHECK: define internal void @_ZN1N8ArrBlockE_block_invoke_3 + BL ArrBlock [] = { ^{}, ^{}, ^{} }; + +// CHECK: define internal void @_ZN1N4ivalE_block_invoke_4( +// CHECK: define internal void @_ZN1N4ivalE_block_invoke_5( +// CHECK: define internal void @_ZN1N4ivalE_block_invoke_6( + int ival = func(^{}, ^{}, ^{}); + +// CHECK: define internal void @_ZN1N9gvarlobalE_block_invoke_7( + void (^gvarlobal)(void) = ^{}; + + struct S { + BL field = ^{}; + }; + +// CHECK: define internal void @_ZN1N3blfE_block_invoke_8( + S blf; +}; diff --git a/test/CodeGenCXX/global-init.cpp b/test/CodeGenCXX/global-init.cpp index 8e6ef775cad9..2a53ad9e3e77 100644 --- a/test/CodeGenCXX/global-init.cpp +++ b/test/CodeGenCXX/global-init.cpp @@ -70,17 +70,17 @@ namespace test3 { const char *test() { return var; } } -namespace test6 { +namespace test4 { struct A { A(); }; extern int foo(); // This needs an initialization function and guard variables. - // CHECK: load i8* bitcast (i64* @_ZGVN5test61xE - // CHECK: [[CALL:%.*]] = call i32 @_ZN5test63fooEv - // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test61xE - // CHECK-NEXT: store i64 1, i64* @_ZGVN5test61xE + // CHECK: load i8* bitcast (i64* @_ZGVN5test41xE + // CHECK: [[CALL:%.*]] = call i32 @_ZN5test43fooEv + // CHECK-NEXT: store i32 [[CALL]], i32* @_ZN5test41xE + // CHECK-NEXT: store i64 1, i64* @_ZGVN5test41xE __attribute__((weak)) int x = foo(); } @@ -95,14 +95,6 @@ namespace PR5974 { A* a = &c; B* b = &c; } -// CHECK: define internal void [[TEST1_Z_INIT:@.*]]() -// CHECK: load i32* @_ZN5test1L1yE -// CHECK-NEXT: xor -// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1zE -// CHECK: define internal void [[TEST1_Y_INIT:@.*]]() -// CHECK: load i32* @_ZN5test1L1xE -// CHECK-NEXT: sub -// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1yE // PR9570: the indirect field shouldn't crash IR gen. namespace test5 { @@ -111,9 +103,98 @@ namespace test5 { }; } +namespace std { struct type_info; } + +namespace test6 { + struct A { virtual ~A(); }; + struct B : A {}; + extern A *p; + + // We must emit a dynamic initializer for 'q', because it could throw. + B *const q = &dynamic_cast<B&>(*p); + // CHECK: call void @__cxa_bad_cast() + // CHECK: store {{.*}} @_ZN5test6L1qE + + // We don't need to emit 'r' at all, because it has internal linkage, is + // unused, and its initialization has no side-effects. + B *const r = dynamic_cast<B*>(p); + // CHECK-NOT: call void @__cxa_bad_cast() + // CHECK-NOT: store {{.*}} @_ZN5test6L1rE + + // This can throw, so we need to emit it. + const std::type_info *const s = &typeid(*p); + // CHECK: store {{.*}} @_ZN5test6L1sE + + // This can't throw, so we don't. + const std::type_info *const t = &typeid(p); + // CHECK-NOT: @_ZN5test6L1tE + + extern B *volatile v; + // CHECK: store {{.*}} @_ZN5test6L1wE + B *const w = dynamic_cast<B*>(v); + + // CHECK: load volatile + // CHECK: store {{.*}} @_ZN5test6L1xE + const int x = *(volatile int*)0x1234; + + namespace { + int a = int(); + volatile int b = int(); + int c = a; + int d = b; + // CHECK-NOT: store {{.*}} @_ZN5test6{{[A-Za-z0-9_]*}}1aE + // CHECK-NOT: store {{.*}} @_ZN5test6{{[A-Za-z0-9_]*}}1bE + // CHECK-NOT: store {{.*}} @_ZN5test6{{[A-Za-z0-9_]*}}1cE + // CHECK: load volatile {{.*}} @_ZN5test6{{[A-Za-z0-9_]*}}1bE + // CHECK: store {{.*}} @_ZN5test6{{[A-Za-z0-9_]*}}1dE + } +} + +namespace test7 { + struct A { A(); }; + struct B { ~B(); int n; }; + struct C { C() = default; C(const C&); int n; }; + struct D {}; + + // CHECK: call void @_ZN5test71AC1Ev({{.*}}@_ZN5test7L1aE) + const A a = A(); + + // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN5test71BD1Ev{{.*}} @_ZN5test7L2b1E + // CHECK: call i32 @__cxa_atexit({{.*}} @_ZN5test71BD1Ev{{.*}} @_ZGRN5test72b2E + // CHECK: call void @_ZN5test71BD1Ev( + // CHECK: store {{.*}} @_ZN5test7L2b3E + const B b1 = B(); + const B &b2 = B(); + const int b3 = B().n; + + // CHECK-NOT: @_ZN5test7L2c1E + // CHECK: @_ZN5test7L2c2E + // CHECK-NOT: @_ZN5test7L2c3E + // CHECK: @_ZN5test7L2c4E + const C c1 = C(); + const C c2 = static_cast<const C&>(C()); + const int c3 = C().n; + const int c4 = C(C()).n; + + // CHECK-NOT: @_ZN5test7L1dE + const D d = D(); + + // CHECK: store {{.*}} @_ZN5test71eE + int f(), e = f(); +} + // At the end of the file, we check that y is initialized before z. +// CHECK: define internal void [[TEST1_Z_INIT:@.*]]() +// CHECK: load i32* @_ZN5test1L1yE +// CHECK-NEXT: xor +// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1zE +// CHECK: define internal void [[TEST1_Y_INIT:@.*]]() +// CHECK: load i32* @_ZN5test1L1xE +// CHECK-NEXT: sub +// CHECK-NEXT: store i32 {{.*}}, i32* @_ZN5test1L1yE + // CHECK: define internal void @_GLOBAL__I_a() section "__TEXT,__StaticInit,regular,pure_instructions" { // CHECK: call void [[TEST1_Y_INIT]] // CHECK: call void [[TEST1_Z_INIT]] diff --git a/test/CodeGenCXX/inline-functions.cpp b/test/CodeGenCXX/inline-functions.cpp index 69dfe0db98f0..8c011de28a02 100644 --- a/test/CodeGenCXX/inline-functions.cpp +++ b/test/CodeGenCXX/inline-functions.cpp @@ -53,3 +53,17 @@ namespace test1 { c.func(); } } + +// PR13252 +namespace test2 { + struct A; + void f(const A& a); + struct A { + friend void f(const A& a) { } + }; + void g() { + A a; + f(a); + } + // CHECK: define linkonce_odr void @_ZN5test21fERKNS_1AE +} diff --git a/test/CodeGenCXX/lambda-expressions.cpp b/test/CodeGenCXX/lambda-expressions.cpp index 797cbf43a787..e872cc494bc6 100644 --- a/test/CodeGenCXX/lambda-expressions.cpp +++ b/test/CodeGenCXX/lambda-expressions.cpp @@ -1,7 +1,11 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -emit-llvm -o - %s -fexceptions -std=c++11 | FileCheck %s -// CHECK: @var = internal global -auto var = [](int i) { return i+1; }; +// CHECK-NOT: @unused +auto unused = [](int i) { return i+1; }; + +// CHECK: @used = internal global +auto used = [](int i) { return i+1; }; +void *use = &used; // CHECK: @cvar = global extern "C" auto cvar = []{}; diff --git a/test/CodeGenCXX/mangle-lambdas.cpp b/test/CodeGenCXX/mangle-lambdas.cpp index cc53b0105750..16ddf4838ea7 100644 --- a/test/CodeGenCXX/mangle-lambdas.cpp +++ b/test/CodeGenCXX/mangle-lambdas.cpp @@ -1,5 +1,10 @@ // RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-macosx10.7.0 -emit-llvm -o - %s | FileCheck %s +// CHECK: @_ZZNK7PR12917IJiiEE1nMUlvE_clEvE1n = linkonce_odr global i32 0 +// CHECK: @_ZZN7PR12917IJicdEEC1EicdEd_N1nE = linkonce_odr global i32 0 +// CHECK: @_ZZN7PR12917IJicdEEC1EicdEd0_N1nE = linkonce_odr global i32 0 +// CHECK: @_ZZN7PR12917IJicdEEC1EicdEd1_N1nE = linkonce_odr global i32 0 + // CHECK: define linkonce_odr void @_Z11inline_funci inline void inline_func(int n) { // CHECK: call i32 @_ZZ11inline_funciENKUlvE_clEv @@ -78,10 +83,10 @@ struct ST { // CHECK: define void @_Z7test_ST2STIdE void test_ST(ST<double> st) { - // CHECK: call double @_ZZN2ST1fET_S0_Ed0_NKUlvE_clEv - // CHECK-NEXT: call double @_ZZN2ST1fET_S0_Ed0_NKUlvE0_clEv + // CHECK: call double @_ZZN2STIdE1fEddEd0_NKUlvE_clEv + // CHECK-NEXT: call double @_ZZN2STIdE1fEddEd0_NKUlvE0_clEv // CHECK-NEXT: fadd double - // CHECK-NEXT: call double @_ZZN2ST1fET_S0_Ed_NKUlvE_clEv + // CHECK-NEXT: call double @_ZZN2STIdE1fEddEd_NKUlvE_clEv // CHECK-NEXT: call void @_ZN2STIdE1fEdd st.f(); @@ -89,11 +94,11 @@ void test_ST(ST<double> st) { } // Check the linkage of the lambda call operators used in test_ST. -// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed0_NKUlvE_clEv +// CHECK: define linkonce_odr double @_ZZN2STIdE1fEddEd0_NKUlvE_clEv // CHECK: ret double 1 -// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed0_NKUlvE0_clEv +// CHECK: define linkonce_odr double @_ZZN2STIdE1fEddEd0_NKUlvE0_clEv // CHECK: ret double 2 -// CHECK: define linkonce_odr double @_ZZN2ST1fET_S0_Ed_NKUlvE_clEv +// CHECK: define linkonce_odr double @_ZZN2STIdE1fEddEd_NKUlvE_clEv // CHECK: ret double 3 template<typename T> @@ -150,6 +155,24 @@ void use_func_template() { func_template<int>(); } + +template<typename...T> struct PR12917 { + PR12917(T ...t = []{ static int n = 0; return ++n; }()); + + static int n[3]; +}; +template<typename...T> int PR12917<T...>::n[3] = { + []{ static int n = 0; return ++n; }() +}; + +// CHECK: call i32 @_ZZN7PR12917IJicdEEC1EicdEd1_NKUlvE_clEv( +// CHECK: call i32 @_ZZN7PR12917IJicdEEC1EicdEd0_NKUlvE_clEv( +// CHECK: call i32 @_ZZN7PR12917IJicdEEC1EicdEd_NKUlvE_clEv( +// CHECK: call void @_ZN7PR12917IJicdEEC1Eicd( +PR12917<int, char, double> pr12917; +int *pr12917_p = PR12917<int, int>::n; + + // CHECK: define linkonce_odr void @_Z1fIZZNK23TestNestedInstantiationclEvENKUlvE_clEvEUlvE_EvT_ struct Members { diff --git a/test/CodeGenCXX/mangle-ms-abi-examples.cpp b/test/CodeGenCXX/mangle-ms-abi-examples.cpp new file mode 100644 index 000000000000..d6726cab0d58 --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-abi-examples.cpp @@ -0,0 +1,28 @@ +// RUN: %clang_cc1 -fms-extensions -fno-rtti -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +// CHECK: @"\01??_7D@C@?1??foo@@YAXXZ@6B@" = +// CHECK: @"\01??_7B@?1??foo@A@@QAEXH@Z@6B@" = +// CHECK: define {{.*}} @"\01?baz@E@?3??bar@C@?1??foo@@YAXXZ@QAEXXZ@QAEXXZ"( + +// Microsoft Visual C++ ABI examples. +struct A { + void foo (int) { + struct B { virtual ~B() {} }; + B(); + } +}; +void foo () { + struct C { + struct D { virtual ~D() {} }; + void bar () { + struct E { + void baz() { } + }; + E().baz(); + } + }; + A().foo(0); + C::D(); + C().bar(); +} + diff --git a/test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp b/test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp new file mode 100644 index 000000000000..27b47689771d --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-back-references-pr13207.cpp @@ -0,0 +1,165 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +// FIXME: add tests for return types with complex templates when PR13389 is fixed. + +template<class X, class Y, class Z> +class A {}; +template<class X> +class B {}; +template<class X> +class C {}; + +void foo_abbb(A<B<char>, B<char>, B<char> >) {} +// CHECK: "\01?foo_abbb@@YAXV?$A@V?$B@D@@V1@V1@@@@Z" +void foo_abb(A<char, B<char>, B<char> >) {} +// CHECK: "\01?foo_abb@@YAXV?$A@DV?$B@D@@V1@@@@Z" +void foo_abc(A<char, B<char>, C<char> >) {} +// CHECK: "\01?foo_abc@@YAXV?$A@DV?$B@D@@V?$C@D@@@@@Z" + +namespace N { +template<class X, class Y, class Z> +class A {}; +template<class X> +class B {}; +template<class X> +class C {}; +template<class X, class Y> +class D {}; +class Z {}; +} + +void foo_abbb(N::A<N::B<char>, N::B<char>, N::B<char> >) {} +// CHECK: "\01?foo_abbb@@YAXV?$A@V?$B@D@N@@V12@V12@@N@@@Z" +void foo_abb(N::A<char, N::B<char>, N::B<char> >) {} +// CHECK: "\01?foo_abb@@YAXV?$A@DV?$B@D@N@@V12@@N@@@Z" +void foo_abc(N::A<char, N::B<char>, N::C<char> >) {} +// CHECK: "\01?foo_abc@@YAXV?$A@DV?$B@D@N@@V?$C@D@2@@N@@@Z" + +N::A<char, N::B<char>, N::C<char> > abc_foo() { +// CHECK: ?abc_foo@@YA?AV?$A@DV?$B@D@N@@V?$C@D@2@@N@@XZ + return N::A<char, N::B<char>, N::C<char> >(); +} + +N::Z z_foo(N::Z arg) { +// CHECK: ?z_foo@@YA?AVZ@N@@V12@@Z + return arg; +} + +N::B<char> b_foo(N::B<char> arg) { +// CHECK: ?b_foo@@YA?AV?$B@D@N@@V12@@Z + return arg; +} + +N::D<char, char> d_foo(N::D<char, char> arg) { +// CHECK: ?d_foo@@YA?AV?$D@DD@N@@V12@@Z + return arg; +} + +N::A<char, N::B<char>, N::C<char> > abc_foo_abc(N::A<char, N::B<char>, N::C<char> >) { +// CHECK: ?abc_foo_abc@@YA?AV?$A@DV?$B@D@N@@V?$C@D@2@@N@@V12@@Z + return N::A<char, N::B<char>, N::C<char> >(); +} + +namespace NA { +class X {}; +template<class T> class Y {}; +} + +namespace NB { +class X {}; +template<class T> class Y {}; +} + +void foo5(NA::Y<NB::Y<NA::Y<NB::Y<NA::X> > > > arg) {} +// CHECK: "\01?foo5@@YAXV?$Y@V?$Y@V?$Y@V?$Y@VX@NA@@@NB@@@NA@@@NB@@@NA@@@Z" + +void foo11(NA::Y<NA::X>, NB::Y<NA::X>) {} +// CHECK: "\01?foo11@@YAXV?$Y@VX@NA@@@NA@@V1NB@@@Z" + +void foo112(NA::Y<NA::X>, NB::Y<NB::X>) {} +// CHECK: "\01?foo112@@YAXV?$Y@VX@NA@@@NA@@V?$Y@VX@NB@@@NB@@@Z" + +void foo22(NA::Y<NB::Y<NA::X> >, NB::Y<NA::Y<NA::X> >) {} +// CHECK: "\01?foo22@@YAXV?$Y@V?$Y@VX@NA@@@NB@@@NA@@V?$Y@V?$Y@VX@NA@@@NA@@@NB@@@Z" + +namespace PR13207 { +class A {}; +class B {}; +class C {}; + +template<class X> +class F {}; +template<class X> +class I {}; +template<class X, class Y> +class J {}; +template<class X, class Y, class Z> +class K {}; + +class L { + public: + void foo(I<A> x) {} +}; +// CHECK: "\01?foo@L@PR13207@@QAEXV?$I@VA@PR13207@@@2@@Z" + +void call_l_foo(L* l) { l->foo(I<A>()); } + +void foo(I<A> x) {} +// CHECK: "\01?foo@PR13207@@YAXV?$I@VA@PR13207@@@1@@Z" +void foo2(I<A> x, I<A> y) { } +// CHECK "\01?foo2@PR13207@@YAXV?$I@VA@PR13207@@@1@0@Z" +void bar(J<A,B> x) {} +// CHECK: "\01?bar@PR13207@@YAXV?$J@VA@PR13207@@VB@2@@1@@Z" +void spam(K<A,B,C> x) {} +// CHECK: "\01?spam@PR13207@@YAXV?$K@VA@PR13207@@VB@2@VC@2@@1@@Z" + +void baz(K<char, F<char>, I<char> >) {} +// CHECK: "\01?baz@PR13207@@YAXV?$K@DV?$F@D@PR13207@@V?$I@D@2@@1@@Z" +void qux(K<char, I<char>, I<char> >) {} +// CHECK: "\01?qux@PR13207@@YAXV?$K@DV?$I@D@PR13207@@V12@@1@@Z" + +namespace NA { +class X {}; +template<class T> class Y {}; +void foo(Y<X> x) {} +// CHECK: "\01?foo@NA@PR13207@@YAXV?$Y@VX@NA@PR13207@@@12@@Z" +void foofoo(Y<Y<X> > x) {} +// CHECK: "\01?foofoo@NA@PR13207@@YAXV?$Y@V?$Y@VX@NA@PR13207@@@NA@PR13207@@@12@@Z" +} + +namespace NB { +class X {}; +template<class T> class Y {}; +void foo(Y<NA::X> x) {} +// CHECK: "\01?foo@NB@PR13207@@YAXV?$Y@VX@NA@PR13207@@@12@@Z" + +void bar(NA::Y<X> x) {} +// CHECK: "\01?bar@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@NA@2@@Z" + +void spam(NA::Y<NA::X> x) {} +// CHECK: "\01?spam@NB@PR13207@@YAXV?$Y@VX@NA@PR13207@@@NA@2@@Z" + +void foobar(NA::Y<Y<X> > a, Y<Y<X> >) {} +// CHECK: "\01?foobar@NB@PR13207@@YAXV?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V312@@Z" + +void foobarspam(Y<X> a, NA::Y<Y<X> > b, Y<Y<X> >) {} +// CHECK: "\01?foobarspam@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V412@@Z" + +void foobarbaz(Y<X> a, NA::Y<Y<X> > b, Y<Y<X> >, Y<Y<X> > c) {} +// CHECK: "\01?foobarbaz@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V412@2@Z" + +void foobarbazqux(Y<X> a, NA::Y<Y<X> > b, Y<Y<X> >, Y<Y<X> > c , NA::Y<Y<Y<X> > > d) {} +// CHECK: "\01?foobarbazqux@NB@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NA@2@V412@2V?$Y@V?$Y@V?$Y@VX@NB@PR13207@@@NB@PR13207@@@NB@PR13207@@@52@@Z" +} + +namespace NC { +class X {}; +template<class T> class Y {}; + +void foo(Y<NB::X> x) {} +// CHECK: "\01?foo@NC@PR13207@@YAXV?$Y@VX@NB@PR13207@@@12@@Z" + +void foobar(NC::Y<NB::Y<NA::Y<NA::X> > > x) {} +// CHECK: "\01?foobar@NC@PR13207@@YAXV?$Y@V?$Y@V?$Y@VX@NA@PR13207@@@NA@PR13207@@@NB@PR13207@@@12@@Z" +} +} diff --git a/test/CodeGenCXX/mangle-ms-back-references.cpp b/test/CodeGenCXX/mangle-ms-back-references.cpp new file mode 100644 index 000000000000..5f93590cf2a2 --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-back-references.cpp @@ -0,0 +1,63 @@ +// RUN: %clang_cc1 -fms-extensions -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +void f1(const char* a, const char* b) {} +// CHECK: "\01?f1@@YAXPBD0@Z" + +void f2(const char* a, char* b) {} +// CHECK: "\01?f2@@YAXPBDPAD@Z" + +void f3(int a, const char* b, const char* c) {} +// CHECK: "\01?f3@@YAXHPBD0@Z" + +const char *f4(const char* a, const char* b) { return 0; } +// CHECK: "\01?f4@@YAPBDPBD0@Z" + +void f5(char const* a, unsigned int b, char c, void const* d, char const* e, unsigned int f) {} +// CHECK: "\01?f5@@YAXPBDIDPBX0I@Z" + +void f6(bool a, bool b) {} +// CHECK: "\01?f6@@YAX_N0@Z" + +void f7(int a, int* b, int c, int* d, bool e, bool f, bool* g) {} +// CHECK: "\01?f7@@YAXHPAHH0_N1PA_N@Z" + +// FIXME: tests for more than 10 types? + +struct S { + void mbb(bool a, bool b) {} +}; + +void g1(struct S a) {} +// CHECK: "\01?g1@@YAXUS@@@Z" + +void g2(struct S a, struct S b) {} +// CHECK: "\01?g2@@YAXUS@@0@Z" + +void g3(struct S a, struct S b, struct S* c, struct S* d) {} +// CHECK: "\01?g3@@YAXUS@@0PAU1@1@Z" + +void g4(const char* a, struct S* b, const char* c, struct S* d) { +// CHECK: "\01?g4@@YAXPBDPAUS@@01@Z" + b->mbb(false, false); +// CHECK: "\01?mbb@S@@QAEX_N0@Z" +} + +// Make sure that different aliases of built-in types end up mangled as the +// built-ins. +typedef unsigned int uintptr_t; +typedef unsigned int size_t; +void *h(size_t a, uintptr_t b) { return 0; } +// CHECK: "\01?h@@YAPAXII@Z" + +// Function pointers might be mangled in a complex way. +typedef void (*VoidFunc)(); +typedef int* (*PInt3Func)(int* a, int* b); + +void h1(const char* a, const char* b, VoidFunc c, VoidFunc d) {} +// CHECK: "\01?h1@@YAXPBD0P6AXXZ1@Z" + +void h2(void (*f_ptr)(void *), void *arg) {} +// CHECK: "\01?h2@@YAXP6AXPAX@Z0@Z" + +PInt3Func h3(PInt3Func x, PInt3Func y, int* z) { return 0; } +// CHECK: "\01?h3@@YAP6APAHPAH0@ZP6APAH00@Z10@Z" diff --git a/test/CodeGenCXX/mangle-ms-cxx11.cpp b/test/CodeGenCXX/mangle-ms-cxx11.cpp new file mode 100644 index 000000000000..6947a53c4d1e --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-cxx11.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -std=c++11 -fms-extensions -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +// CHECK: "\01?LRef@@YAXAAH@Z" +void LRef(int& a) { } + +// CHECK: "\01?RRef@@YAH$$QAH@Z" +int RRef(int&& a) { return a; } + +// CHECK: "\01?Null@@YAX$$T@Z" +namespace std { typedef decltype(__nullptr) nullptr_t; } +void Null(std::nullptr_t) {} diff --git a/test/CodeGenCXX/mangle-ms-return-qualifiers.cpp b/test/CodeGenCXX/mangle-ms-return-qualifiers.cpp new file mode 100644 index 000000000000..a5d03b343526 --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-return-qualifiers.cpp @@ -0,0 +1,173 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +void a1() {} +// CHECK: "\01?a1@@YAXXZ" + +int a2() { return 0; } +// CHECK: "\01?a2@@YAHXZ" + +const int a3() { return 0; } +// CHECK: "\01?a3@@YA?BHXZ" + +volatile int a4() { return 0; } +// CHECK: "\01?a4@@YA?CHXZ" + +const volatile int a5() { return 0; } +// CHECK: "\01?a5@@YA?DHXZ" + +float a6() { return 0.0f; } +// CHECK: "\01?a6@@YAMXZ" + +int *b1() { return 0; } +// CHECK: "\01?b1@@YAPAHXZ" + +const char *b2() { return 0; } +// CHECK: "\01?b2@@YAPBDXZ" + +float *b3() { return 0; } +// CHECK: "\01?b3@@YAPAMXZ" + +const float *b4() { return 0; } +// CHECK: "\01?b4@@YAPBMXZ" + +volatile float *b5() { return 0; } +// CHECK: "\01?b5@@YAPCMXZ" + +const volatile float *b6() { return 0; } +// CHECK: "\01?b6@@YAPDMXZ" + +float &b7() { return *(float*)0; } +// CHECK: "\01?b7@@YAAAMXZ" + +const float &b8() { return *(float*)0; } +// CHECK: "\01?b8@@YAABMXZ" + +volatile float &b9() { return *(float*)0; } +// CHECK: "\01?b9@@YAACMXZ" + +const volatile float &b10() { return *(float*)0; } +// CHECK: "\01?b10@@YAADMXZ" + +const char** b11() { return 0; } +// CHECK: "\01?b11@@YAPAPBDXZ" + +class A {}; + +A c1() { return A(); } +// CHECK: "\01?c1@@YA?AVA@@XZ" + +const A c2() { return A(); } +// CHECK: "\01?c2@@YA?BVA@@XZ" + +volatile A c3() { return A(); } +// CHECK: "\01?c3@@YA?CVA@@XZ" + +const volatile A c4() { return A(); } +// CHECK: "\01?c4@@YA?DVA@@XZ" + +const A* c5() { return 0; } +// CHECK: "\01?c5@@YAPBVA@@XZ" + +volatile A* c6() { return 0; } +// CHECK: "\01?c6@@YAPCVA@@XZ" + +const volatile A* c7() { return 0; } +// CHECK: "\01?c7@@YAPDVA@@XZ" + +A &c8() { return *(A*)0; } +// CHECK: "\01?c8@@YAAAVA@@XZ" + +const A &c9() { return *(A*)0; } +// CHECK: "\01?c9@@YAABVA@@XZ" + +volatile A &c10() { return *(A*)0; } +// CHECK: "\01?c10@@YAACVA@@XZ" + +const volatile A &c11() { return *(A*)0; } +// CHECK: "\01?c11@@YAADVA@@XZ" + +template<typename T> class B {}; + +B<int> d1() { return B<int>(); } +// CHECK: "\01?d1@@YA?AV?$B@H@@XZ" + +B<const char*> d2() {return B<const char*>(); } +// CHECK: "\01?d2@@YA?AV?$B@PBD@@XZ" + +B<A> d3() {return B<A>(); } +// CHECK: "\01?d3@@YA?AV?$B@VA@@@@XZ" + +B<A>* d4() { return 0; } +// CHECK: "\01?d4@@YAPAV?$B@VA@@@@XZ" + +const B<A>* d5() { return 0; } +// CHECK: "\01?d5@@YAPBV?$B@VA@@@@XZ" + +volatile B<A>* d6() { return 0; } +// CHECK: "\01?d6@@YAPCV?$B@VA@@@@XZ" + +const volatile B<A>* d7() { return 0; } +// CHECK: "\01?d7@@YAPDV?$B@VA@@@@XZ" + +B<A>& d8() { return *(B<A>*)0; } +// CHECK: "\01?d8@@YAAAV?$B@VA@@@@XZ" + +const B<A>& d9() { return *(B<A>*)0; } +// CHECK: "\01?d9@@YAABV?$B@VA@@@@XZ" + +volatile B<A>& d10() { return *(B<A>*)0; } +// CHECK: "\01?d10@@YAACV?$B@VA@@@@XZ" + +const volatile B<A>& d11() { return *(B<A>*)0; } +// CHECK: "\01?d11@@YAADV?$B@VA@@@@XZ" + +enum Enum { DEFAULT }; + +Enum e1() { return DEFAULT; } +// CHECK: "\01?e1@@YA?AW4Enum@@XZ" + +const Enum e2() { return DEFAULT; } +// CHECK: "\01?e2@@YA?BW4Enum@@XZ" + +Enum* e3() { return 0; } +// CHECK: "\01?e3@@YAPAW4Enum@@XZ" + +Enum& e4() { return *(Enum*)0; } +// CHECK: "\01?e4@@YAAAW4Enum@@XZ" + +struct S {}; + +struct S f1() { struct S s; return s; } +// CHECK: "\01?f1@@YA?AUS@@XZ" + +const struct S f2() { struct S s; return s; } +// CHECK: "\01?f2@@YA?BUS@@XZ" + +struct S* f3() { return 0; } +// CHECK: "\01?f3@@YAPAUS@@XZ" + +const struct S* f4() { return 0; } +// CHECK: "\01?f4@@YAPBUS@@XZ" + +const volatile struct S* f5() { return 0; } +// CHECK: "\01?f5@@YAPDUS@@XZ" + +struct S& f6() { return *(struct S*)0; } +// CHECK: "\01?f6@@YAAAUS@@XZ" + +typedef int (*function_pointer)(int); + +function_pointer g1() { return 0; } +// CHECK: "\01?g1@@YAP6AHH@ZXZ" + +const function_pointer g2() { return 0; } +// CHECK: "\01?g2@@YAQ6AHH@ZXZ" + +function_pointer* g3() { return 0; } +// CHECK: "\01?g3@@YAPAP6AHH@ZXZ" + +const function_pointer* g4() { return 0; } +// The mangling of g4 is currently "\01?g4@@YAPQ6AHH@ZXZ" which is wrong. +// This looks related to http://llvm.org/PR13444 +// FIXME: replace CHECK-NOT with CHECK once it is fixed. +// CHECK-NOT: "\01?g4@@YAPBQ6AHH@ZXZ" diff --git a/test/CodeGenCXX/mangle-ms-templates.cpp b/test/CodeGenCXX/mangle-ms-templates.cpp new file mode 100644 index 000000000000..977ef353dabc --- /dev/null +++ b/test/CodeGenCXX/mangle-ms-templates.cpp @@ -0,0 +1,68 @@ +// RUN: %clang_cc1 -fms-extensions -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +template<typename T> +class Class { + public: + void method() {} +}; + +class Typename { }; + +template<typename T> +class Nested { }; + +template<bool flag> +class BoolTemplate { + public: + BoolTemplate() {} +}; + +template<int param> +class IntTemplate { + public: + IntTemplate() {} +}; + +template<> +class BoolTemplate<true> { + public: + BoolTemplate() {} + template<class T> void Foo(T arg) {} +}; + +void template_mangling() { + Class<Typename> c1; + c1.method(); +// CHECK: call {{.*}} @"\01?method@?$Class@VTypename@@@@QAEXXZ" + + Class<Nested<Typename> > c2; + c2.method(); +// CHECK: call {{.*}} @"\01?method@?$Class@V?$Nested@VTypename@@@@@@QAEXXZ" + + BoolTemplate<false> _false; +// CHECK: call {{.*}} @"\01??0?$BoolTemplate@$0A@@@QAE@XZ" + + BoolTemplate<true> _true; + // PR13158 + _true.Foo(1); +// CHECK: call {{.*}} @"\01??0?$BoolTemplate@$00@@QAE@XZ" +// CHECK: call {{.*}} @"\01??$Foo@H@?$BoolTemplate@$00@@QAEXH@Z" + + IntTemplate<5> five; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$04@@QAE@XZ" + + IntTemplate<11> eleven; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0L@@@QAE@XZ" + + IntTemplate<65535> ffff; +// CHECK: call {{.*}} @"\01??0?$IntTemplate@$0PPPP@@@QAE@XZ" +} + +namespace space { + template<class T> const T& foo(const T& l) { return l; } +} +// CHECK: "\01??$foo@H@space@@YAABHABH@Z" + +void use() { + space::foo(42); +} diff --git a/test/CodeGenCXX/mangle-ms.cpp b/test/CodeGenCXX/mangle-ms.cpp index fe5fde1a1b3b..f392c1701edd 100644 --- a/test/CodeGenCXX/mangle-ms.cpp +++ b/test/CodeGenCXX/mangle-ms.cpp @@ -12,6 +12,13 @@ // CHECK: @"\01?j@@3P6GHCE@ZA" // CHECK: @"\01?k@@3PTfoo@@DA" // CHECK: @"\01?l@@3P8foo@@AEHH@ZA" +// CHECK: @"\01?color1@@3PANA" + +// FIXME: The following three tests currently fail, see PR13182. +// Replace "CHECK-NOT" with "CHECK" when it is fixed. +// CHECK-NOT: @"\01?color2@@3QBNB" +// CHECK-NOT: @"\01?color3@@3QAY02$$CBNA" +// CHECK-NOT: @"\01?color4@@3QAY02$$CBNA" int a; @@ -39,8 +46,13 @@ public: foo(char *q){} //CHECK: @"\01??0foo@@QAE@PAD@Z" + + static foo* static_method() { return 0; } + }f,s1(1),s2((char*)0); +typedef foo (foo2); + struct bar { static int g; }; @@ -57,8 +69,17 @@ enum quux { qthree }; -int foo::operator+(int a) {return a;} -// CHECK: @"\01??Hfoo@@QAEHH@Z" +foo bar() { return foo(); } +//CHECK: @"\01?bar@@YA?AVfoo@@XZ" + +int foo::operator+(int a) { +//CHECK: @"\01??Hfoo@@QAEHH@Z" + + foo::static_method(); +//CHECK: @"\01?static_method@foo@@SAPAV1@XZ" + bar(); + return a; +} const short foo::d = 0; volatile long foo::e; @@ -72,9 +93,9 @@ int i[10][20]; int (__stdcall *j)(signed char, unsigned char); -const volatile char foo::*k; +const volatile char foo2::*k; -int (foo::*l)(int); +int (foo2::*l)(int); // Static functions are mangled, too. // Also make sure calling conventions, arglists, and throw specs work. @@ -99,7 +120,45 @@ void delta(int * const a, const long &) {} void epsilon(int a[][10][20]) {} // CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z" -// Blocks mangling (Clang extension). -void zeta(int (^)(int, int)) {} -// CHECK: @"\01?zeta@@YAXP_EAHHH@Z@Z" +void zeta(int (*)(int, int)) {} +// CHECK: @"\01?zeta@@YAXP6AHHH@Z@Z" + +// Blocks mangling (Clang extension). A block should be mangled slightly +// differently from a similar function pointer. +void eta(int (^)(int, int)) {} +// CHECK: @"\01?eta@@YAXP_EAHHH@Z@Z" + +void operator_new_delete() { + char *ptr = new char; +// CHECK: @"\01??2@YAPAXI@Z" + + delete ptr; +// CHECK: @"\01??3@YAXPAX@Z" + + char *array = new char[42]; +// CHECK: @"\01??_U@YAPAXI@Z" + + delete [] array; +// CHECK: @"\01??_V@YAXPAX@Z" +} +// PR13022 +void (redundant_parens)(); +void redundant_parens_use() { redundant_parens(); } +// CHECK: @"\01?redundant_parens@@YAXXZ" + +// PR13182, PR13047 +typedef double RGB[3]; +RGB color1; +extern const RGB color2 = {}; +extern RGB const color3[5] = {}; +extern RGB const ((color4)[5]) = {}; + +// PR12603 +enum E {}; +// CHECK: "\01?fooE@@YA?AW4E@@XZ" +E fooE() { return E(); } + +class X {}; +// CHECK: "\01?fooX@@YA?AVX@@XZ" +X fooX() { return X(); } diff --git a/test/CodeGenCXX/mangle-ref-qualifiers.cpp b/test/CodeGenCXX/mangle-ref-qualifiers.cpp index 568cf9f24700..ce2af502e482 100644 --- a/test/CodeGenCXX/mangle-ref-qualifiers.cpp +++ b/test/CodeGenCXX/mangle-ref-qualifiers.cpp @@ -12,5 +12,11 @@ int X::g() && { return 0; } // CHECK: define i32 @_ZNKO1X1hEv int X::h() const && { return 0; } -// CHECK: define void @_Z1fM1XRFivEMS_OFivEMS_KOFivE +// CHECK: define void @_Z1fM1XFivREMS_FivOEMS_KFivOE void f(int (X::*)() &, int (X::*)() &&, int (X::*)() const&&) { } + +// CHECK: define void @_Z1g1AIFivEES_IFivREES_IFivOEES_IKFivEES_IKFivREES_IKFivOEES_IVKFivEES_IVKFivREES_IVKFivOEE() +template <class T> struct A {}; +void g(A<int()>, A<int()&>, A<int()&&>, + A<int() const>, A<int() const &>, A<int() const &&>, + A<int() const volatile>, A<int() const volatile &>, A<int() const volatile &&>) {} diff --git a/test/CodeGenCXX/member-data-pointers.cpp b/test/CodeGenCXX/member-data-pointers.cpp new file mode 100644 index 000000000000..d3473668a7f4 --- /dev/null +++ b/test/CodeGenCXX/member-data-pointers.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-unknown | FileCheck -check-prefix GLOBAL-LP64 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix GLOBAL-LP32 %s + +struct A; +typedef int A::*param_t; +struct { + const char *name; + param_t par; +} *ptr; +void test_ptr() { (void) ptr; } // forced use + +// GLOBAL-LP64: type { i8*, i64 } +// GLOBAL-LP32: type { i8*, i32 } diff --git a/test/CodeGenCXX/member-function-pointers.cpp b/test/CodeGenCXX/member-function-pointers.cpp index 2417aa41918b..84b54b67d315 100644 --- a/test/CodeGenCXX/member-function-pointers.cpp +++ b/test/CodeGenCXX/member-function-pointers.cpp @@ -1,6 +1,8 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin9 | FileCheck %s -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-apple-darwin9 | FileCheck -check-prefix LP32 %s -// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix ARM %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-unknown | FileCheck -check-prefix CODE-LP64 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-unknown-unknown | FileCheck -check-prefix CODE-LP32 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-unknown-unknown | FileCheck -check-prefix GLOBAL-LP64 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i386-unknown-unknown | FileCheck -check-prefix GLOBAL-LP32 %s +// RUN: %clang_cc1 %s -emit-llvm -o - -triple=armv7-unknown-unknown | FileCheck -check-prefix GLOBAL-ARM %s struct A { int a; void f(); virtual void vf1(); virtual void vf2(); }; struct B { int b; virtual void g(); }; @@ -11,66 +13,56 @@ void (A::*volatile vpa)(); void (B::*pb)(); void (C::*pc)(); -// CHECK: @pa2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 }, align 8 +// GLOBAL-LP64: @pa2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 }, align 8 void (A::*pa2)() = &A::f; -// CHECK: @pa3 = global { i64, i64 } { i64 1, i64 0 }, align 8 -// CHECK-LP32: @pa3 = global { i32, i32 } { i32 1, i32 0 }, align 4 +// GLOBAL-LP64: @pa3 = global { i64, i64 } { i64 1, i64 0 }, align 8 +// GLOBAL-LP32: @pa3 = global { i32, i32 } { i32 1, i32 0 }, align 4 void (A::*pa3)() = &A::vf1; -// CHECK: @pa4 = global { i64, i64 } { i64 9, i64 0 }, align 8 -// CHECK-LP32: @pa4 = global { i32, i32 } { i32 5, i32 0 }, align 4 +// GLOBAL-LP64: @pa4 = global { i64, i64 } { i64 9, i64 0 }, align 8 +// GLOBAL-LP32: @pa4 = global { i32, i32 } { i32 5, i32 0 }, align 4 void (A::*pa4)() = &A::vf2; -// CHECK: @pc2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 16 }, align 8 +// GLOBAL-LP64: @pc2 = global { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 16 }, align 8 void (C::*pc2)() = &C::f; -// CHECK: @pc3 = global { i64, i64 } { i64 1, i64 0 }, align 8 +// GLOBAL-LP64: @pc3 = global { i64, i64 } { i64 1, i64 0 }, align 8 void (A::*pc3)() = &A::vf1; -// Tests for test10. -// CHECK: @_ZN6test101aE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 0 }, align 8 -// CHECK: @_ZN6test101bE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8 -// CHECK: @_ZN6test101cE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8 -// CHECK: @_ZN6test101dE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 16 }, align 8 -// CHECK-LP32: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4 -// CHECK-LP32: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4 -// CHECK-LP32: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4 -// CHECK-LP32: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 - void f() { - // CHECK: store { i64, i64 } zeroinitializer, { i64, i64 }* @pa + // CODE-LP64: store { i64, i64 } zeroinitializer, { i64, i64 }* @pa pa = 0; // Is this okay? What are LLVM's volatile semantics for structs? - // CHECK: store volatile { i64, i64 } zeroinitializer, { i64, i64 }* @vpa + // CODE-LP64: store volatile { i64, i64 } zeroinitializer, { i64, i64 }* @vpa vpa = 0; - // CHECK: [[TMP:%.*]] = load { i64, i64 }* @pa, align 8 - // CHECK: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1 - // CHECK: [[ADJ:%.*]] = add nsw i64 [[TMPADJ]], 16 - // CHECK: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1 - // CHECK: store { i64, i64 } [[RES]], { i64, i64 }* @pc, align 8 + // CODE-LP64: [[TMP:%.*]] = load { i64, i64 }* @pa, align 8 + // CODE-LP64: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1 + // CODE-LP64: [[ADJ:%.*]] = add nsw i64 [[TMPADJ]], 16 + // CODE-LP64: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1 + // CODE-LP64: store { i64, i64 } [[RES]], { i64, i64 }* @pc, align 8 pc = pa; - // CHECK: [[TMP:%.*]] = load { i64, i64 }* @pc, align 8 - // CHECK: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1 - // CHECK: [[ADJ:%.*]] = sub nsw i64 [[TMPADJ]], 16 - // CHECK: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1 - // CHECK: store { i64, i64 } [[RES]], { i64, i64 }* @pa, align 8 + // CODE-LP64: [[TMP:%.*]] = load { i64, i64 }* @pc, align 8 + // CODE-LP64: [[TMPADJ:%.*]] = extractvalue { i64, i64 } [[TMP]], 1 + // CODE-LP64: [[ADJ:%.*]] = sub nsw i64 [[TMPADJ]], 16 + // CODE-LP64: [[RES:%.*]] = insertvalue { i64, i64 } [[TMP]], i64 [[ADJ]], 1 + // CODE-LP64: store { i64, i64 } [[RES]], { i64, i64 }* @pa, align 8 pa = static_cast<void (A::*)()>(pc); } void f2() { - // CHECK: store { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 } + // CODE-LP64: store { i64, i64 } { i64 ptrtoint (void (%struct.A*)* @_ZN1A1fEv to i64), i64 0 } void (A::*pa2)() = &A::f; - // CHECK: store { i64, i64 } { i64 1, i64 0 } - // CHECK-LP32: store { i32, i32 } { i32 1, i32 0 } + // CODE-LP64: store { i64, i64 } { i64 1, i64 0 } + // CODE-LP32: store { i32, i32 } { i32 1, i32 0 } void (A::*pa3)() = &A::vf1; - // CHECK: store { i64, i64 } { i64 9, i64 0 } - // CHECK-LP32: store { i32, i32 } { i32 5, i32 0 } + // CODE-LP64: store { i64, i64 } { i64 9, i64 0 } + // CODE-LP32: store { i32, i32 } { i32 5, i32 0 } void (A::*pa4)() = &A::vf2; } @@ -195,12 +187,12 @@ namespace test7 { struct B { void foo(); virtual void vfoo(); }; struct C : A, B { void foo(); virtual void vfoo(); }; - // CHECK-ARM: @_ZN5test74ptr0E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71A3fooEv to i32), i32 0 } - // CHECK-ARM: @_ZN5test74ptr1E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71B3fooEv to i32), i32 8 } - // CHECK-ARM: @_ZN5test74ptr2E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71C3fooEv to i32), i32 0 } - // CHECK-ARM: @_ZN5test74ptr3E = global {{.*}} { i32 0, i32 1 } - // CHECK-ARM: @_ZN5test74ptr4E = global {{.*}} { i32 0, i32 9 } - // CHECK-ARM: @_ZN5test74ptr5E = global {{.*}} { i32 0, i32 1 } + // GLOBAL-ARM: @_ZN5test74ptr0E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71A3fooEv to i32), i32 0 } + // GLOBAL-ARM: @_ZN5test74ptr1E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71B3fooEv to i32), i32 8 } + // GLOBAL-ARM: @_ZN5test74ptr2E = global {{.*}} { i32 ptrtoint ({{.*}}* @_ZN5test71C3fooEv to i32), i32 0 } + // GLOBAL-ARM: @_ZN5test74ptr3E = global {{.*}} { i32 0, i32 1 } + // GLOBAL-ARM: @_ZN5test74ptr4E = global {{.*}} { i32 0, i32 9 } + // GLOBAL-ARM: @_ZN5test74ptr5E = global {{.*}} { i32 0, i32 1 } void (C::*ptr0)() = &A::foo; void (C::*ptr1)() = &B::foo; void (C::*ptr2)() = &C::foo; @@ -234,9 +226,9 @@ namespace test9 { fooptr p; }; - // CHECK: define void @_ZN5test94testEv( - // CHECK: alloca i32 - // CHECK-NEXT: ret void + // CODE-LP64: define void @_ZN5test94testEv( + // CODE-LP64: alloca i32 + // CODE-LP64-NEXT: ret void void test() { int x; static S array[] = { (fooptr) &B::foo }; @@ -261,14 +253,37 @@ namespace test10 { virtual void requireNonZeroAdjustment(); }; - // Non-ARM tests at top of file. + +// It's not that the offsets are doubled on ARM, it's that they're left-shifted by 1. + +// GLOBAL-LP64: @_ZN6test101aE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 0 }, align 8 +// GLOBAL-LP32: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4 +// GLOBAL-ARM: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4 void (A::*a)() = &A::foo; + +// GLOBAL-LP64: @_ZN6test101bE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8 +// GLOBAL-LP32: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4 +// GLOBAL-ARM: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 void (B::*b)() = (void (B::*)()) &A::foo; + +// GLOBAL-LP64: @_ZN6test101cE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 8 }, align 8 +// GLOBAL-LP32: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 4 }, align 4 +// GLOBAL-ARM: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 void (C::*c)() = (void (C::*)()) (void (B::*)()) &A::foo; + +// GLOBAL-LP64: @_ZN6test101dE = global { i64, i64 } { i64 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i64), i64 16 }, align 8 +// GLOBAL-LP32: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 +// GLOBAL-ARM: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 16 }, align 4 void (D::*d)() = (void (C::*)()) (void (B::*)()) &A::foo; } -// It's not that the offsets are doubled on ARM, it's that they're left-shifted by 1. -// CHECK-ARM: @_ZN6test101aE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 0 }, align 4 -// CHECK-ARM: @_ZN6test101bE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 -// CHECK-ARM: @_ZN6test101cE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 8 }, align 4 -// CHECK-ARM: @_ZN6test101dE = global { i32, i32 } { i32 ptrtoint (void (%"struct.test10::A"*)* @_ZN6test101A3fooEv to i32), i32 16 }, align 4 + +namespace test11 { + struct A { virtual void a(); }; + struct B : A {}; + struct C : B { virtual void a(); }; + void (C::*x)() = &C::a; + + // GLOBAL-LP64: @_ZN6test111xE = global { i64, i64 } { i64 1, i64 0 } + // GLOBAL-LP32: @_ZN6test111xE = global { i32, i32 } { i32 1, i32 0 } + // GLOBAL-ARM: @_ZN6test111xE = global { i32, i32 } { i32 0, i32 1 } +} diff --git a/test/CodeGenCXX/member-init-anon-union.cpp b/test/CodeGenCXX/member-init-anon-union.cpp index 1ff7537387c2..4db31f0b83fd 100644 --- a/test/CodeGenCXX/member-init-anon-union.cpp +++ b/test/CodeGenCXX/member-init-anon-union.cpp @@ -2,8 +2,10 @@ // PR10531. +int make_a(); + static union { - int a = 42; + int a = make_a(); char *b; }; @@ -32,4 +34,4 @@ int g() { // CHECK: define {{.*}}@"[[CONSTRUCT_GLOBAL]]C2Ev" // CHECK-NOT: } -// CHECK: store i32 42 +// CHECK: call {{.*}}@_Z6make_a diff --git a/test/CodeGenCXX/member-init-ctor.cpp b/test/CodeGenCXX/member-init-ctor.cpp deleted file mode 100644 index 21723942571f..000000000000 --- a/test/CodeGenCXX/member-init-ctor.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck %s - -bool b(); -struct S { - int n = b() ? S().n + 1 : 0; -}; - -S s; - -// CHECK: define {{.*}} @_ZN1SC2Ev( -// CHECK-NOT } -// CHECK: call {{.*}} @_Z1bv() -// CHECK-NOT } -// CHECK: call {{.*}} @_ZN1SC1Ev( diff --git a/test/CodeGenCXX/member-pointer-type-convert.cpp b/test/CodeGenCXX/member-pointer-type-convert.cpp deleted file mode 100644 index 2970a2e39e3f..000000000000 --- a/test/CodeGenCXX/member-pointer-type-convert.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s - -struct A; -typedef int A::*param_t; -struct { - const char *name; - param_t par; -} *ptr; -void test_ptr() { (void) ptr; } // forced use - -// CHECK: type { i8*, {{i..}} } diff --git a/test/CodeGenCXX/microsoft-abi-array-cookies.cpp b/test/CodeGenCXX/microsoft-abi-array-cookies.cpp new file mode 100644 index 000000000000..e07b09744730 --- /dev/null +++ b/test/CodeGenCXX/microsoft-abi-array-cookies.cpp @@ -0,0 +1,59 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +struct ClassWithoutDtor { + char x; +}; + +void check_array_no_cookies() { +// CHECK: define void @"\01?check_array_no_cookies@@YAXXZ"() nounwind + +// CHECK: call noalias i8* @"\01??_U@YAPAXI@Z"(i32 42) + ClassWithoutDtor *array = new ClassWithoutDtor[42]; + +// CHECK: call void @"\01??_V@YAXPAX@Z"( + delete [] array; + +} + +struct ClassWithDtor { + char x; + ~ClassWithDtor() {} +}; + +void check_array_cookies_simple() { +// CHECK: define {{.*}} @"\01?check_array_cookies_simple@@YAXXZ"() + + ClassWithDtor *array = new ClassWithDtor[42]; +// CHECK: [[ALLOCATED:%.*]] = call noalias i8* @"\01??_U@YAPAXI@Z"(i32 46) +// 46 = 42 + size of cookie (4) +// CHECK: [[COOKIE:%.*]] = bitcast i8* [[ALLOCATED]] to i32* +// CHECK: store i32 42, i32* [[COOKIE]] +// CHECK: [[ARRAY:%.*]] = getelementptr inbounds i8* [[ALLOCATED]], i64 4 +// CHECK: bitcast i8* [[ARRAY]] to [[CLASS:%.*]]* + + delete [] array; +// CHECK: [[ARRAY_AS_CHAR:%.*]] = bitcast [[CLASS]]* {{%.*}} to i8* +// CHECK: getelementptr inbounds i8* [[ARRAY_AS_CHAR]], i64 -4 +} + +struct __attribute__((aligned(8))) ClassWithAlignment { + // FIXME: replace __attribute__((aligned(8))) with __declspec(align(8)) once + // http://llvm.org/bugs/show_bug.cgi?id=12631 is fixed. + int *x, *y; + ~ClassWithAlignment() {} +}; + +void check_array_cookies_aligned() { +// CHECK: define {{.*}} @"\01?check_array_cookies_aligned@@YAXXZ"() + ClassWithAlignment *array = new ClassWithAlignment[42]; +// CHECK: [[ALLOCATED:%.*]] = call noalias i8* @"\01??_U@YAPAXI@Z"(i32 344) +// 344 = 42*8 + size of cookie (8, due to alignment) +// CHECK: [[COOKIE:%.*]] = bitcast i8* [[ALLOCATED]] to i32* +// CHECK: store i32 42, i32* [[COOKIE]] +// CHECK: [[ARRAY:%.*]] = getelementptr inbounds i8* [[ALLOCATED]], i64 8 +// CHECK: bitcast i8* [[ARRAY]] to [[CLASS:%.*]]* + + delete [] array; +// CHECK: [[ARRAY_AS_CHAR:%.*]] = bitcast [[CLASS]]* +// CHECK: getelementptr inbounds i8* [[ARRAY_AS_CHAR]], i64 -8 +} diff --git a/test/CodeGenCXX/microsoft-abi-constructors.cpp b/test/CodeGenCXX/microsoft-abi-constructors.cpp new file mode 100644 index 000000000000..ac27f13308d8 --- /dev/null +++ b/test/CodeGenCXX/microsoft-abi-constructors.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +class A { + public: + A() { } + ~A() { } +}; + +void no_contstructor_destructor_infinite_recursion() { + A a; + +// Make sure that the constructor doesn't call itself: +// CHECK: define {{.*}} @"\01??0A@@QAE@XZ" +// CHECK-NOT: call void @"\01??0A@@QAE@XZ" +// CHECK: ret + +// Make sure that the destructor doesn't call itself: +// CHECK: define {{.*}} @"\01??1A@@QAE@XZ" +// CHECK-NOT: call void @"\01??1A@@QAE@XZ" +// CHECK: ret +} diff --git a/test/CodeGenCXX/microsoft-abi-methods.cpp b/test/CodeGenCXX/microsoft-abi-methods.cpp new file mode 100644 index 000000000000..6b7f00495d2b --- /dev/null +++ b/test/CodeGenCXX/microsoft-abi-methods.cpp @@ -0,0 +1,89 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +class C { + public: + void simple_method() {} + + void __cdecl cdecl_method() {} + + void vararg_method(const char *fmt, ...) {} + + static void static_method() {} + + int a; +}; + +void call_simple_method() { + C instance; + + instance.simple_method(); +// Make sure that the call uses the right calling convention: +// CHECK: call x86_thiscallcc void @"\01?simple_method@C@@QAEXXZ" +// CHECK: ret + +// Make sure that the definition uses the right calling convention: +// CHECK: define linkonce_odr x86_thiscallcc void @"\01?simple_method@C@@QAEXXZ" +// CHECK: ret +} + +void call_cdecl_method() { + C instance; + instance.cdecl_method(); +// Make sure that the call uses the right calling convention: +// CHECK: call void @"\01?cdecl_method@C@@QAAXXZ" +// CHECK: ret + +// Make sure that the definition uses the right calling convention: +// CHECK: define linkonce_odr void @"\01?cdecl_method@C@@QAAXXZ" +// CHECK: ret +} + +void call_vararg_method() { + C instance; + instance.vararg_method("Hello"); +// Make sure that the call uses the right calling convention: +// CHECK: call void (%class.C*, i8*, ...)* @"\01?vararg_method@C@@QAAXPBDZZ" +// CHECK: ret + +// Make sure that the definition uses the right calling convention: +// CHECK: define linkonce_odr void @"\01?vararg_method@C@@QAAXPBDZZ" +} + +void call_static_method() { + C::static_method(); +// Make sure that the call uses the right calling convention: +// CHECK: call void @"\01?static_method@C@@SAXXZ" +// CHECK: ret + +// Make sure that the definition uses the right calling convention: +// CHECK: define linkonce_odr void @"\01?static_method@C@@SAXXZ" +} + +class Base { + public: + Base() {} + ~Base() {} +}; + +class Child: public Base { }; + +void constructors() { + Child c; +// Make sure that the Base constructor call in the Child constructor uses +// the right calling convention: +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??0Child@@QAE@XZ" +// CHECK: call x86_thiscallcc void @"\01??0Base@@QAE@XZ" +// CHECK: ret + +// Make sure that the Base destructor call in the Child denstructor uses +// the right calling convention: +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??1Child@@QAE@XZ" +// CHECK: call x86_thiscallcc void @"\01??1Base@@QAE@XZ" +// CHECK: ret + +// Make sure that the Base destructor definition uses the right CC: +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??1Base@@QAE@XZ" + +// Make sure that the Base constructor definition uses the right CC: +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??0Base@@QAE@XZ" +} diff --git a/test/CodeGenCXX/microsoft-abi-static-initializers.cpp b/test/CodeGenCXX/microsoft-abi-static-initializers.cpp new file mode 100644 index 000000000000..d8b789943a43 --- /dev/null +++ b/test/CodeGenCXX/microsoft-abi-static-initializers.cpp @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s + +struct S { + S() {} + ~S() {} +} s; + +// CHECK: define internal void [[INIT_s:@.*global_var.*]] nounwind +// CHECK: call x86_thiscallcc void @"\01??0S@@QAE@XZ" +// CHECK: call i32 @atexit(void ()* @"__dtor_\01?s@@3US@@A") +// CHECK: ret void + +// CHECK: define internal void @"__dtor_\01?s@@3US@@A"() nounwind { +// CHECK: call x86_thiscallcc void @"\01??1S@@QAE@XZ" +// CHECK: ret void + +// Force WeakODRLinkage by using templates +class A { + public: + A() {} + ~A() {} +}; + +template<typename T> +class B { + public: + static A foo; +}; + +template<typename T> A B<T>::foo; + +void force_usage() { + (void)B<int>::foo; // (void) - force usage +} + +// CHECK: define internal void [[INIT_foo:@.*global_var.*]] nounwind +// CHECK: call x86_thiscallcc void @"\01??0A@@QAE@XZ" +// CHECK: call i32 @atexit(void ()* [[FOO_DTOR:@"__dtor_.*foo@.*]]) +// CHECK: ret void + +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??0A@@QAE@XZ" + +// CHECK: define linkonce_odr x86_thiscallcc void @"\01??1A@@QAE@XZ" + +// CHECK: define internal void [[FOO_DTOR]] +// CHECK: call x86_thiscallcc void @"\01??1A@@QAE@XZ"{{.*}}foo +// CHECK: ret void + +// CHECK: define internal void @_GLOBAL__I_a() nounwind { +// CHECK: call void [[INIT_s]] +// CHECK: call void [[INIT_foo]] +// CHECK: ret void diff --git a/test/CodeGenCXX/ms_wide_predefined_expr.cpp b/test/CodeGenCXX/ms_wide_predefined_expr.cpp new file mode 100644 index 000000000000..5f0bcdee8c05 --- /dev/null +++ b/test/CodeGenCXX/ms_wide_predefined_expr.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -fms-extensions -triple i686-pc-win32 -emit-llvm -o - | FileCheck %s + +// CHECK: @L__FUNCTION__._Z4funcv = private constant [5 x i16] [i16 102, i16 117, i16 110, i16 99, i16 0], align 2 + +void wprint(const wchar_t*); + +#define __STR2WSTR(str) L##str +#define _STR2WSTR(str) __STR2WSTR(str) +#define STR2WSTR(str) _STR2WSTR(str) + +void func() { + wprint(STR2WSTR(__FUNCTION__)); +} + +int main() { + func(); + + return 0; +} + diff --git a/test/CodeGenCXX/pointers-to-data-members.cpp b/test/CodeGenCXX/pointers-to-data-members.cpp index 90024e4dfed7..fe69cd5ddf78 100644 --- a/test/CodeGenCXX/pointers-to-data-members.cpp +++ b/test/CodeGenCXX/pointers-to-data-members.cpp @@ -240,3 +240,17 @@ namespace PR11487 { // CHECK-GLOBAL: @_ZN7PR114871xE = global %"union.PR11487::U" { i64 -1, [8 x i8] zeroinitializer }, align 8 } + +namespace PR13097 { + struct X { int x; X(const X&); }; + struct A { + int qq; + X x; + }; + A f(); + X g() { return f().*&A::x; } + // CHECK: define void @_ZN7PR130971gEv + // CHECK: call void @_ZN7PR130971fEv + // CHECK-NOT: memcpy + // CHECK: call void @_ZN7PR130971XC1ERKS0_ +} diff --git a/test/CodeGenCXX/pr13396.cpp b/test/CodeGenCXX/pr13396.cpp new file mode 100644 index 000000000000..7d4e2ce74f04 --- /dev/null +++ b/test/CodeGenCXX/pr13396.cpp @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -triple i686-pc-linux-gnu %s -emit-llvm -o - | FileCheck %s +struct foo { + template<typename T> + __attribute__ ((regparm (3))) foo(T x) {} + __attribute__ ((regparm (3))) foo(); + __attribute__ ((regparm (3))) ~foo(); +}; + +foo::foo() { + // CHECK: define void @_ZN3fooC1Ev(%struct.foo* inreg %this) + // CHECK: define void @_ZN3fooC2Ev(%struct.foo* inreg %this) +} + +foo::~foo() { + // CHECK: define void @_ZN3fooD1Ev(%struct.foo* inreg %this) + // CHECK: define void @_ZN3fooD2Ev(%struct.foo* inreg %this) +} + +void dummy() { + // FIXME: how can we explicitly instantiate a template constructor? Gcc and + // older clangs accept: + // template foo::foo(int x); + foo x(10); + // CHECK: define linkonce_odr void @_ZN3fooC1IiEET_(%struct.foo* inreg %this, i32 inreg %x) + // CHECK: define linkonce_odr void @_ZN3fooC2IiEET_(%struct.foo* inreg %this, i32 inreg %x) +} diff --git a/test/CodeGenCXX/pragma-visibility.cpp b/test/CodeGenCXX/pragma-visibility.cpp index e54626ee2e11..11a38c1d5fb9 100644 --- a/test/CodeGenCXX/pragma-visibility.cpp +++ b/test/CodeGenCXX/pragma-visibility.cpp @@ -17,14 +17,6 @@ int x2::y = 10; #pragma GCC visibility pop #pragma GCC visibility push(hidden) -struct x3 { - static int y; -} __attribute((visibility("default"))); -int x3::y = 10; -// CHECK: @_ZN2x31yE = global -#pragma GCC visibility pop - -#pragma GCC visibility push(hidden) template<class T> struct x4 { static int y; }; @@ -60,3 +52,23 @@ namespace n __attribute((visibility("default"))) { // CHECK: define hidden void @_ZN1n1gEv #pragma GCC visibility pop } + +namespace test2 { +#pragma GCC visibility push(default) +#pragma GCC visibility push(hidden) + struct foo { // foo is hidden + }; +#pragma GCC visibility pop + struct foo; // declaration is ok, we ignore the default in the stack + template<typename T> + struct bar { // bar is default + static void f(){} + }; +#pragma GCC visibility pop + void zed() { + bar<foo>::f(); + bar<int>::f(); + } + // CHECK: define linkonce_odr hidden void @_ZN5test23barINS_3fooEE1fEv + // CHECK: define linkonce_odr void @_ZN5test23barIiE1fEv +} diff --git a/test/CodeGenCXX/rvalue-references.cpp b/test/CodeGenCXX/rvalue-references.cpp index 1c25543beabc..b8d47dcfbe2f 100644 --- a/test/CodeGenCXX/rvalue-references.cpp +++ b/test/CodeGenCXX/rvalue-references.cpp @@ -10,7 +10,7 @@ B &getB(); // CHECK: define %struct.A* @_Z4getAv() // CHECK: call %struct.B* @_Z4getBv() // CHECK-NEXT: bitcast %struct.B* -// CHECK-NEXT: getelementptr i8* +// CHECK-NEXT: getelementptr inbounds i8* // CHECK-NEXT: bitcast i8* {{.*}} to %struct.A* // CHECK-NEXT: ret %struct.A* A &&getA() { return static_cast<A&&>(getB()); } diff --git a/test/CodeGenCXX/template-instantiation.cpp b/test/CodeGenCXX/template-instantiation.cpp index 09b3a4fcc544..b90716ba1ae6 100644 --- a/test/CodeGenCXX/template-instantiation.cpp +++ b/test/CodeGenCXX/template-instantiation.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -O1 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -O1 -disable-llvm-optzns -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s // CHECK: @_ZN7PR100011xE = global // CHECK-NOT: @_ZN7PR100014kBarE = external global i32 @@ -13,7 +13,7 @@ // CHECK-NOT: _ZTVN5test31SIiEE // CHECK-NOT: _ZTSN5test31SIiEE -// CHECK: define linkonce_odr void @_ZN5test21CIiEC1Ev(%"class.test2::C"* nocapture %this) unnamed_addr +// CHECK: define linkonce_odr void @_ZN5test21CIiEC1Ev(%"class.test2::C"* %this) unnamed_addr // CHECK: define linkonce_odr void @_ZN5test21CIiE6foobarIdEEvT_( // CHECK: define available_externally void @_ZN5test21CIiE6zedbarEd( diff --git a/test/CodeGenCXX/throw-expression-cleanup.cpp b/test/CodeGenCXX/throw-expression-cleanup.cpp new file mode 100644 index 000000000000..0c41bc65bc3c --- /dev/null +++ b/test/CodeGenCXX/throw-expression-cleanup.cpp @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 %s -emit-llvm -fcxx-exceptions -fexceptions -std=c++11 -o - | FileCheck %s +// PR13359 + +struct X { + ~X(); +}; +struct Error { + Error(const X&) noexcept; +}; + +void f() { + try { + throw Error(X()); + } catch (...) { } +} + +// CHECK: define void @_Z1fv +// CHECK: call void @_ZN5ErrorC1ERK1X +// CHECK: invoke void @__cxa_throw +// CHECK: landingpad +// CHECK: call void @_ZN1XD1Ev +// CHECK-NOT: __cxa_free_exception diff --git a/test/CodeGenCXX/virt-call-offsets.cpp b/test/CodeGenCXX/virt-call-offsets.cpp deleted file mode 100644 index 5eef6fea9e6f..000000000000 --- a/test/CodeGenCXX/virt-call-offsets.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s - -struct A { virtual void a(); }; -struct B : A {}; -struct C : B { virtual void a(); }; -void (C::*x)() = &C::a; - -// CHECK: @x = global { i{{[0-9]+}}, i{{[0-9]+}} } { i{{[0-9]+}} 1, i{{[0-9]+}} 0 } diff --git a/test/CodeGenCXX/virt-template-vtable.cpp b/test/CodeGenCXX/virt-template-vtable.cpp index 25736fd60309..a6067d62c61d 100644 --- a/test/CodeGenCXX/virt-template-vtable.cpp +++ b/test/CodeGenCXX/virt-template-vtable.cpp @@ -20,3 +20,13 @@ template class A<short>; // CHECK: @_ZTV1AIlE = weak_odr unnamed_addr constant // CHECK: @_ZTV1AIsE = weak_odr unnamed_addr constant // CHECK: @_ZTV1AIiE = linkonce_odr unnamed_addr constant + +template<class T> struct C { + virtual void c() {} +}; +struct D : C<int> { + virtual void d(); +}; +void D::d() {} + +// CHECK: define {{.*}}@_ZN1CIiE1cEv( diff --git a/test/CodeGenCXX/virtual-destructor-calls.cpp b/test/CodeGenCXX/virtual-destructor-calls.cpp index 1cc8bcc7753e..7ef50b23fa7c 100644 --- a/test/CodeGenCXX/virtual-destructor-calls.cpp +++ b/test/CodeGenCXX/virtual-destructor-calls.cpp @@ -46,3 +46,14 @@ C::~C() { } // CHECK: call void @_ZdlPv // Base dtor: just an alias to B's base dtor. + +namespace PR12798 { + // A qualified call to a base class destructor should not undergo virtual + // dispatch. Template instantiation used to lose the qualifier. + struct A { virtual ~A(); }; + template<typename T> void f(T *p) { p->A::~A(); } + + // CHECK: define {{.*}} @_ZN7PR127981fINS_1AEEEvPT_( + // CHECK: call void @_ZN7PR127981AD1Ev( + template void f(A*); +} diff --git a/test/CodeGenCXX/visibility-inlines-hidden.cpp b/test/CodeGenCXX/visibility-inlines-hidden.cpp index d660b1b41051..2bb13485e922 100644 --- a/test/CodeGenCXX/visibility-inlines-hidden.cpp +++ b/test/CodeGenCXX/visibility-inlines-hidden.cpp @@ -108,3 +108,21 @@ namespace PR11642 { template class Foo<int>; // CHECK: define weak_odr i32 @_ZN7PR116423FooIiE3fooEi } + +// Test that clang implements the new gcc behaviour for inline functions. +// GCC PR30066. +namespace test3 { + inline void foo(void) { + } + template<typename T> + inline void zed() { + } + template void zed<float>(); + void bar(void) { + foo(); + zed<int>(); + } + // CHECK: define weak_odr void @_ZN5test33zedIfEEvv + // CHECK: define linkonce_odr hidden void @_ZN5test33fooEv + // CHECK: define linkonce_odr hidden void @_ZN5test33zedIiEEvv +} diff --git a/test/CodeGenCXX/visibility.cpp b/test/CodeGenCXX/visibility.cpp index 59fd7c26f0d5..014503911a49 100644 --- a/test/CodeGenCXX/visibility.cpp +++ b/test/CodeGenCXX/visibility.cpp @@ -1,10 +1,24 @@ -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s -// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN +// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-apple-darwin10 -fvisibility hidden -emit-llvm -o - | FileCheck %s -check-prefix=CHECK-HIDDEN #define HIDDEN __attribute__((visibility("hidden"))) #define PROTECTED __attribute__((visibility("protected"))) #define DEFAULT __attribute__((visibility("default"))) +namespace test30 { + // When H is hidden, it should make X hidden, even if the template argument + // is not. + struct H { + }; + template<H *T> + struct X { + }; + H DEFAULT a; + X<&a> b; + // CHECK: _ZN6test301bE = global + // CHECK-HIDDEN: _ZN6test301bE = hidden global +} + namespace test25 { template<typename T> struct X { @@ -28,6 +42,62 @@ namespace test28 { // CHECK-HIDDEN: @_ZN6test285myvecE = hidden global } +namespace test29 { +#pragma GCC visibility push(hidden) + struct RECT { + int top; + }; + __attribute__ ((visibility ("default"))) extern RECT data_rect; + RECT data_rect = { -1}; +#pragma GCC visibility pop + // CHECK: @_ZN6test299data_rectE = global + // CHECK-HIDDEN: @_ZN6test299data_rectE = global +} + +namespace test40 { + template<typename T> + struct foo { + DEFAULT static int bar; + }; + template<typename T> + int foo<T>::bar; + template struct foo<int>; + // CHECK: _ZN6test403fooIiE3barE = weak_odr global + // CHECK-HIDDEN: _ZN6test403fooIiE3barE = weak_odr global +} + +namespace test41 { + // Unlike gcc we propagate the information that foo not only is hidden, but + // has been explicitly marked as so. This lets us produce a hidden undefined + // reference to bar. + struct __attribute__((visibility("hidden"))) foo {}; + extern foo bar; + foo *zed() { + return &bar; + } + // CHECK: @_ZN6test413barE = external hidden global + // CHECK-HIDDEN: @_ZN6test413barE = external hidden global +} + +namespace test48 { + // Test that we use the visibility of struct foo when instantiating the + // template. Note that is a case where we disagree with gcc, it produces + // a default symbol. + struct HIDDEN foo { + }; + DEFAULT foo x; + + struct bar { + template<foo *z> + struct zed { + }; + }; + + bar::zed<&x> y; + // CHECK: _ZN6test481yE = hidden global + // CHECK-HIDDEN: _ZN6test481yE = hidden global +} + // CHECK: @_ZN5Test425VariableInHiddenNamespaceE = hidden global i32 10 // CHECK: @_ZN5Test71aE = hidden global // CHECK: @_ZN5Test71bE = global @@ -510,6 +580,8 @@ namespace PR10113 { }; template class foo::bar<zed>; // CHECK: define weak_odr void @_ZN7PR101133foo3barINS_3zedEE3zedEv + + // FIXME: This should be hidden as zed is hidden. // CHECK-HIDDEN: define weak_odr void @_ZN7PR101133foo3barINS_3zedEE3zedEv } @@ -541,6 +613,8 @@ namespace PR11690_2 { }; template class foo::zed<baz>; // CHECK: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv + + // FIXME: This should be hidden as baz is hidden. // CHECK-HIDDEN: define weak_odr void @_ZN9PR11690_23foo3zedINS_3bazENS0_3barEE3barEv } @@ -605,3 +679,436 @@ namespace test26 { // CHECK: define void @_ZN6test261CIiE1fEv // CHECK-HIDDEN: define void @_ZN6test261CIiE1fEv } + +namespace test31 { + struct A { + struct HIDDEN B { + static void DEFAULT baz(); + }; + }; + void f() { + A::B::baz(); + } + // CHECK: declare void @_ZN6test311A1B3bazEv() + // CHECK-HIDDEN: declare void @_ZN6test311A1B3bazEv() +} + +namespace test32 { + struct HIDDEN A { + struct DEFAULT B { + void DEFAULT baz(); + }; + }; + void A::B::baz() { + } + // CHECK: define void @_ZN6test321A1B3bazEv + // CHECK-HIDDEN: define void @_ZN6test321A1B3bazEv +} + +namespace test33 { + template<typename T> + class foo { + void bar() {} + }; + struct HIDDEN zed { + }; + template class DEFAULT foo<zed>; + // CHECK: define weak_odr void @_ZN6test333fooINS_3zedEE3barEv + // CHECK-HIDDEN: define weak_odr void @_ZN6test333fooINS_3zedEE3barEv +} + +namespace test34 { + struct foo { + }; + template<class T> + void bar() {} + template DEFAULT void bar<foo>(); + // CHECK: define weak_odr void @_ZN6test343barINS_3fooEEEvv + // CHECK-HIDDEN: define weak_odr void @_ZN6test343barINS_3fooEEEvv +} + +namespace test35 { + // This is a really ugly testcase. GCC propagates the DEFAULT in zed's + // definition. What we do instead is be conservative about merging + // implicit visibilities. + // FIXME: Maybe the best thing to do here is error? The test at least + // makes sure we don't produce a hidden symbol for foo<zed>::bar. + template<typename T> + struct DEFAULT foo { + void bar() {} + }; + class zed; + template class foo<zed>; + class DEFAULT zed { + }; + // CHECK: define weak_odr void @_ZN6test353fooINS_3zedEE3barEv + // CHECK-HIDDEN: define weak_odr void @_ZN6test353fooINS_3zedEE3barEv +} + +namespace test36 { + template<typename T1, typename T2> + class foo { + void bar() {} + }; + class DEFAULT S1 {}; + struct HIDDEN S2 {}; + template class foo<S1, S2>; + // CHECK: define weak_odr hidden void @_ZN6test363fooINS_2S1ENS_2S2EE3barEv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test363fooINS_2S1ENS_2S2EE3barEv +} + +namespace test37 { + struct HIDDEN foo { + }; + template<class T> + DEFAULT void bar() {} + template DEFAULT void bar<foo>(); + // CHECK: define weak_odr void @_ZN6test373barINS_3fooEEEvv + // CHECK-HIDDEN: define weak_odr void @_ZN6test373barINS_3fooEEEvv +} + +namespace test38 { + template<typename T> + class DEFAULT foo { + void bar() {} + }; + struct HIDDEN zed { + }; + template class foo<zed>; + // CHECK: define weak_odr hidden void @_ZN6test383fooINS_3zedEE3barEv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test383fooINS_3zedEE3barEv +} + +namespace test39 { + class DEFAULT default_t; + class HIDDEN hidden_t; + template <class T> class A { + template <class U> class B { + HIDDEN void hidden() {} + void noattr() {} + template <class V> void temp() {} + }; + }; + template class DEFAULT A<hidden_t>; + template class DEFAULT A<hidden_t>::B<hidden_t>; + template void A<hidden_t>::B<hidden_t>::temp<default_t>(); + template void A<hidden_t>::B<hidden_t>::temp<hidden_t>(); + + // CHECK: define weak_odr hidden void @_ZN6test391AINS_8hidden_tEE1BIS1_E6hiddenEv + // CHECK: define weak_odr void @_ZN6test391AINS_8hidden_tEE1BIS1_E6noattrEv + // CHECK: define weak_odr void @_ZN6test391AINS_8hidden_tEE1BIS1_E4tempINS_9default_tEEEvv + + // GCC produces a default for this one. Why? + // CHECK: define weak_odr hidden void @_ZN6test391AINS_8hidden_tEE1BIS1_E4tempIS1_EEvv + + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test391AINS_8hidden_tEE1BIS1_E6hiddenEv + // CHECK-HIDDEN: define weak_odr void @_ZN6test391AINS_8hidden_tEE1BIS1_E6noattrEv + // CHECK-HIDDEN: define weak_odr void @_ZN6test391AINS_8hidden_tEE1BIS1_E4tempINS_9default_tEEEvv + + // GCC produces a default for this one. Why? + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test391AINS_8hidden_tEE1BIS1_E4tempIS1_EEvv +} + +namespace test42 { + struct HIDDEN foo { + }; + template <class P> + struct bar { + }; + template <> + struct HIDDEN bar<foo> { + DEFAULT static void zed(); + }; + void bar<foo>::zed() { + } + // CHECK: define hidden void @_ZN6test423barINS_3fooEE3zedEv + // CHECK-HIDDEN: define hidden void @_ZN6test423barINS_3fooEE3zedEv +} + +namespace test43 { + struct HIDDEN foo { + }; + template <class P> + void bar() { + } + template <> + DEFAULT void bar<foo>() { + } + // CHECK: define hidden void @_ZN6test433barINS_3fooEEEvv + // CHECK-HIDDEN: define hidden void @_ZN6test433barINS_3fooEEEvv +} + +namespace test44 { + template <typename T> + struct foo { + foo() {} + }; + namespace { + struct bar; + } + template struct DEFAULT foo<bar>; + foo<bar> x; + // CHECK: define internal void @_ZN6test443fooINS_12_GLOBAL__N_13barEEC1Ev + // CHECK-HIDDEN: define internal void @_ZN6test443fooINS_12_GLOBAL__N_13barEEC1Ev +} + +namespace test45 { + template <typename T> + struct foo { + template <typename T2> + struct bar { + bar() {}; + }; + }; + namespace { + struct zed; + } + template struct DEFAULT foo<int>::bar<zed>; + foo<int>::bar<zed> x; + // CHECK: define internal void @_ZN6test453fooIiE3barINS_12_GLOBAL__N_13zedEEC1Ev + // CHECK-HIDDEN: define internal void @_ZN6test453fooIiE3barINS_12_GLOBAL__N_13zedEEC1Ev +} + +namespace test46 { + template <typename T> + void foo() { + } + namespace { + struct bar; + } + template DEFAULT void foo<bar>(); + void zed() { + foo<bar>(); + } + // CHECK: define internal void @_ZN6test463fooINS_12_GLOBAL__N_13barEEEvv + // CHECK-HIDDEN: define internal void @_ZN6test463fooINS_12_GLOBAL__N_13barEEEvv +} + +namespace test47 { + struct foo { + template <typename T> + static void bar() { + } + }; + namespace { + struct zed; + } + template __attribute__((visibility("default"))) void foo::bar<zed>(); + void baz() { + foo::bar<zed>(); + } + // CHECK: define internal void @_ZN6test473foo3barINS_12_GLOBAL__N_13zedEEEvv + // CHECK-HIDDEN: define internal void @_ZN6test473foo3barINS_12_GLOBAL__N_13zedEEEvv +} + +namespace test49 { + // Test that we use the visibility of struct foo when instantiating the + // template. Note that is a case where we disagree with gcc, it produces + // a default symbol. + + struct HIDDEN foo { + }; + + DEFAULT foo x; + + struct bar { + template<foo *z> + void zed() { + } + }; + + template void bar::zed<&x>(); + // CHECK: define weak_odr hidden void @_ZN6test493bar3zedIXadL_ZNS_1xEEEEEvv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test493bar3zedIXadL_ZNS_1xEEEEEvv +} + +namespace test50 { + // Test that we use the visibility of struct foo when instantiating the + // template. Note that is a case where we disagree with gcc, it produces + // a default symbol. + + struct HIDDEN foo { + }; + DEFAULT foo x; + template<foo *z> + struct DEFAULT bar { + void zed() { + } + }; + template void bar<&x>::zed(); + // CHECK: define weak_odr hidden void @_ZN6test503barIXadL_ZNS_1xEEEE3zedEv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test503barIXadL_ZNS_1xEEEE3zedEv +} + +namespace test51 { + // Test that we use the visibility of struct foo when instantiating the + // template. Note that is a case where we disagree with gcc, it produces + // a default symbol. + + struct HIDDEN foo { + }; + DEFAULT foo x; + template<foo *z> + void DEFAULT zed() { + } + template void zed<&x>(); + // CHECK: define weak_odr hidden void @_ZN6test513zedIXadL_ZNS_1xEEEEEvv + // CHECK-HIDDEN: define weak_odr hidden void @_ZN6test513zedIXadL_ZNS_1xEEEEEvv +} + +namespace test52 { + // Test that we use the linkage of struct foo when instantiating the + // template. Note that is a case where we disagree with gcc, it produces + // an external symbol. + + namespace { + struct foo { + }; + } + template<foo *x> + void zed() { + } + void f() { + zed<nullptr>(); + } + // CHECK: define internal void @_ZN6test523zedILPNS_12_GLOBAL__N_13fooE0EEEvv + // CHECK-HIDDEN: define internal void @_ZN6test523zedILPNS_12_GLOBAL__N_13fooE0EEEvv +} + +namespace test53 { + template<typename _Tp > struct vector { + static void _M_fill_insert(); + }; +#pragma GCC visibility push(hidden) + // GCC doesn't seem to use the visibility of enums at all, we do. + enum zed {v1}; + + // GCC fails to mark this specialization hidden, we mark it. + template<> + struct vector<int> { + static void _M_fill_insert(); + }; + void foo() { + vector<unsigned>::_M_fill_insert(); + vector<int>::_M_fill_insert(); + vector<zed>::_M_fill_insert(); + } +#pragma GCC visibility pop + // CHECK: declare void @_ZN6test536vectorIjE14_M_fill_insertEv + // CHECK-HIDDEN: declare void @_ZN6test536vectorIjE14_M_fill_insertEv + // CHECK: declare hidden void @_ZN6test536vectorIiE14_M_fill_insertEv + // CHECK-HIDDEN: declare hidden void @_ZN6test536vectorIiE14_M_fill_insertEv + // CHECK: declare hidden void @_ZN6test536vectorINS_3zedEE14_M_fill_insertEv + // CHECK-HIDDEN: declare hidden void @_ZN6test536vectorINS_3zedEE14_M_fill_insertEv +} + +namespace test54 { + template <class T> + struct foo { + static void bar(); + }; +#pragma GCC visibility push(hidden) + class zed { + zed(const zed &); + }; + void bah() { + foo<zed>::bar(); + } +#pragma GCC visibility pop + // CHECK: declare hidden void @_ZN6test543fooINS_3zedEE3barEv + // CHECK-HIDDEN: declare hidden void @_ZN6test543fooINS_3zedEE3barEv +} + +namespace test55 { + template <class T> + struct __attribute__((visibility("hidden"))) foo { + static void bar(); + }; + template <class T> struct foo; + void foobar() { + foo<int>::bar(); + } + // CHECK: declare hidden void @_ZN6test553fooIiE3barEv + // CHECK-HIDDEN: declare hidden void @_ZN6test553fooIiE3barEv +} + +namespace test56 { + template <class T> struct foo; + template <class T> + struct __attribute__((visibility("hidden"))) foo { + static void bar(); + }; + void foobar() { + foo<int>::bar(); + } + // CHECK: declare hidden void @_ZN6test563fooIiE3barEv + // CHECK-HIDDEN: declare hidden void @_ZN6test563fooIiE3barEv +} + +namespace test57 { +#pragma GCC visibility push(hidden) + template <class T> + struct foo; + void bar(foo<int>*); + template <class T> + struct foo { + static void zed(); + }; + void bah() { + foo<int>::zed(); + } +#pragma GCC visibility pop + // CHECK: declare hidden void @_ZN6test573fooIiE3zedEv + // CHECK-HIDDEN: declare hidden void @_ZN6test573fooIiE3zedEv +} + +namespace test58 { +#pragma GCC visibility push(hidden) + struct foo; + template<typename T> + struct __attribute__((visibility("default"))) bar { + static void zed() { + } + }; + void bah() { + bar<foo>::zed(); + } +#pragma GCC visibility pop + // CHECK: define linkonce_odr hidden void @_ZN6test583barINS_3fooEE3zedEv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test583barINS_3fooEE3zedEv +} + +namespace test59 { + DEFAULT int f(); + HIDDEN int g(); + typedef int (*foo)(); + template<foo x, foo y> + void test() {} + void use() { + test<&g, &f>(); + // CHECK: define linkonce_odr hidden void @_ZN6test594testIXadL_ZNS_1gEvEEXadL_ZNS_1fEvEEEEvv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test594testIXadL_ZNS_1gEvEEXadL_ZNS_1fEvEEEEvv + + test<&f, &g>(); + // CHECK: define linkonce_odr hidden void @_ZN6test594testIXadL_ZNS_1fEvEEXadL_ZNS_1gEvEEEEvv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test594testIXadL_ZNS_1fEvEEXadL_ZNS_1gEvEEEEvv + } +} + +namespace test60 { + template<int i> + class __attribute__((visibility("hidden"))) a {}; + template<int i> + class __attribute__((visibility("default"))) b {}; + template<template<int> class x, template<int> class y> + void test() {} + void use() { + test<a, b>(); + // CHECK: define linkonce_odr hidden void @_ZN6test604testINS_1aENS_1bEEEvv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test604testINS_1aENS_1bEEEvv + + test<b, a>(); + // CHECK: define linkonce_odr hidden void @_ZN6test604testINS_1bENS_1aEEEvv + // CHECK-HIDDEN: define linkonce_odr hidden void @_ZN6test604testINS_1bENS_1aEEEvv + } +} diff --git a/test/CodeGenObjC/2008-11-12-Metadata.m b/test/CodeGenObjC/2008-11-12-Metadata.m index afd7ce035aea..afd340a067c3 100644 --- a/test/CodeGenObjC/2008-11-12-Metadata.m +++ b/test/CodeGenObjC/2008-11-12-Metadata.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-fragile-abi %s -o /dev/null +// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -o /dev/null @interface A @end diff --git a/test/CodeGenObjC/2008-11-24-ConstCFStrings.m b/test/CodeGenObjC/2008-11-24-ConstCFStrings.m index b37f66c29707..53eec2ab0500 100644 --- a/test/CodeGenObjC/2008-11-24-ConstCFStrings.m +++ b/test/CodeGenObjC/2008-11-24-ConstCFStrings.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-fragile-abi %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -o - | FileCheck %s // CHECK: _unnamed_cfstring_ diff --git a/test/CodeGenObjC/2010-03-17-StructRef.m b/test/CodeGenObjC/2010-03-17-StructRef.m index fd0e6462ce2e..ce24c8da575b 100644 --- a/test/CodeGenObjC/2010-03-17-StructRef.m +++ b/test/CodeGenObjC/2010-03-17-StructRef.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -fobjc-fragile-abi -o - | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -o - | FileCheck %s // Bitfield references must not touch memory outside of the enclosing // struct. Radar 7639995 typedef signed char BOOL; diff --git a/test/CodeGenObjC/arc-blocks.m b/test/CodeGenObjC/arc-blocks.m index 06acf01ce0f7..2326bce2be25 100644 --- a/test/CodeGenObjC/arc-blocks.m +++ b/test/CodeGenObjC/arc-blocks.m @@ -124,7 +124,7 @@ void test4(void) { // CHECK-NEXT: [[T1:%.*]] = load i8** [[T0]] // CHECK-NEXT: call void @objc_release(i8* [[T1]]) - // CHECK: define internal void @__test4_block_invoke_ + // CHECK: define internal void @__test4_block_invoke // CHECK: [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6 // CHECK-NEXT: [[T0:%.*]] = load i8** [[SLOT]], align 8 // CHECK-NEXT: store i8* null, i8** [[SLOT]], @@ -200,7 +200,7 @@ void test6(void) { // CHECK: [[T0:%.*]] = getelementptr inbounds [[BYREF_T]]* {{%.*}}, i32 0, i32 6 // CHECK-NEXT: call void @objc_destroyWeak(i8** [[T0]]) - // CHECK: define internal void @__test6_block_invoke_ + // CHECK: define internal void @__test6_block_invoke // CHECK: [[SLOT:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 6 // CHECK-NEXT: call i8* @objc_storeWeak(i8** [[SLOT]], i8* null) // CHECK-NEXT: ret void @@ -238,7 +238,7 @@ void test7(void) { // CHECK-NEXT: call void @objc_destroyWeak(i8** [[VAR]]) // CHECK-NEXT: ret void - // CHECK: define internal void @__test7_block_invoke_ + // CHECK: define internal void @__test7_block_invoke // CHECK: [[SLOT:%.*]] = getelementptr inbounds [[BLOCK_T]]* {{%.*}}, i32 0, i32 5 // CHECK-NEXT: [[T0:%.*]] = call i8* @objc_loadWeak(i8** [[SLOT]]) // CHECK-NEXT: call void @test7_consume(i8* [[T0]]) @@ -521,3 +521,14 @@ void test15_helper(void (^block)(void), int x); void test15(int a) { test15_helper(^{ (void) a; }, ({ a; })); } + +// rdar://11016025 +void test16() { + void (^BLKVAR)(void) = ^{ BLKVAR(); }; + + // CHECK: define void @test16( + // CHECK: [[BLKVAR:%.*]] = alloca void ()*, align 8 + // CHECK-NEXT: [[BLOCK:%.*]] = alloca [[BLOCK_T:<{.*}>]], + // CHECK-NEXT: [[SLOTREL:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 + // CHECK-NEXT: store void ()* null, void ()** [[BLKVAR]], align 8 +} diff --git a/test/CodeGenObjC/arc.m b/test/CodeGenObjC/arc.m index 2a98b10909bb..66a6a2f54b77 100644 --- a/test/CodeGenObjC/arc.m +++ b/test/CodeGenObjC/arc.m @@ -9,6 +9,9 @@ void test0(id x) { // CHECK-NEXT: [[TMP:%.*]] = load i8** [[X]] // CHECK-NEXT: call void @objc_release(i8* [[TMP]]) // CHECK-NEXT: ret void +// rdar://12040837 + // CHECK: declare extern_weak i8* @objc_retain(i8*) nonlazybind + // CHECK: declare extern_weak void @objc_release(i8*) nonlazybind } // CHECK: define i8* @test1(i8* diff --git a/test/CodeGenObjC/assign.m b/test/CodeGenObjC/assign.m index 82da800e7399..bdc99c635835 100644 --- a/test/CodeGenObjC/assign.m +++ b/test/CodeGenObjC/assign.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s struct s0 { int x; diff --git a/test/CodeGenObjC/autorelease.m b/test/CodeGenObjC/autorelease.m index 9260c3fafe8b..830929afb2e8 100644 --- a/test/CodeGenObjC/autorelease.m +++ b/test/CodeGenObjC/autorelease.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime-has-arc -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fobjc-runtime-has-arc -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime=macosx-10.7 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fobjc-runtime=macosx-10.7 -o - %s | FileCheck %s // rdar://8881826 // rdar://9412038 diff --git a/test/CodeGenObjC/bitfield-1.m b/test/CodeGenObjC/bitfield-1.m index 648ab2a374db..ad52d8f4789c 100644 --- a/test/CodeGenObjC/bitfield-1.m +++ b/test/CodeGenObjC/bitfield-1.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s -// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s @interface Object - (id) alloc; diff --git a/test/CodeGenObjC/bitfield-access.m b/test/CodeGenObjC/bitfield-access.m index 521d2e52a6fa..6d4c82a9b17c 100644 --- a/test/CodeGenObjC/bitfield-access.m +++ b/test/CodeGenObjC/bitfield-access.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o %t1 %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t1 %s // RUN: FileCheck -check-prefix=CHECK-I386 < %t1 %s -// RUN: %clang_cc1 -triple armv6-apple-darwin10 -fobjc-fragile-abi -target-abi apcs-gnu -emit-llvm -o %t2 %s +// RUN: %clang_cc1 -triple armv6-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -target-abi apcs-gnu -emit-llvm -o %t2 %s // RUN: FileCheck -check-prefix=CHECK-ARM < %t2 %s @interface I0 { diff --git a/test/CodeGenObjC/bitfield-gnu.m b/test/CodeGenObjC/bitfield-gnu.m index 7935bdaacf04..383907f15c51 100644 --- a/test/CodeGenObjC/bitfield-gnu.m +++ b/test/CodeGenObjC/bitfield-gnu.m @@ -1,4 +1,4 @@ -// RUN: %clang -S -emit-llvm -fgnu-runtime -o %t %s +// RUN: %clang -S -emit-llvm -fobjc-runtime=gcc -o %t %s typedef enum { A1, A2 } A; typedef struct { A a : 1; } B; @interface Obj { B *b; } @end diff --git a/test/CodeGenObjC/bitfield_encoding.m b/test/CodeGenObjC/bitfield_encoding.m index 17fd4a4108b7..1a516aaf8619 100644 --- a/test/CodeGenObjC/bitfield_encoding.m +++ b/test/CodeGenObjC/bitfield_encoding.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: grep "ib1b14" %t | count 1 -// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi -fgnu-runtime -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -fobjc-runtime=gcc -emit-llvm -o %t %s // RUN: grep "ib32i1b33i14" %t | count 1 struct foo{ diff --git a/test/CodeGenObjC/block-6.m b/test/CodeGenObjC/block-6.m index 140fa8831937..57b9ea3fa6ea 100644 --- a/test/CodeGenObjC/block-6.m +++ b/test/CodeGenObjC/block-6.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 -fobjc-fragile-abi | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -o - -fblocks -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 | FileCheck %s // rdar://8893785 void MYFUNC() { diff --git a/test/CodeGenObjC/block-var-layout.m b/test/CodeGenObjC/block-var-layout.m index 1d0ce2d373ad..c8065be88c76 100644 --- a/test/CodeGenObjC/block-var-layout.m +++ b/test/CodeGenObjC/block-var-layout.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -emit-llvm %s -o %t-64.s +// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -O0 -emit-llvm %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s struct S { diff --git a/test/CodeGenObjC/blocks-1.m b/test/CodeGenObjC/blocks-1.m index 64da3594c271..99a11f91e4cd 100644 --- a/test/CodeGenObjC/blocks-1.m +++ b/test/CodeGenObjC/blocks-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-fragile-abi +// RUN: %clang_cc1 %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 // RUN: grep "_Block_object_dispose" %t | count 6 // RUN: grep "__copy_helper_block_" %t | count 4 // RUN: grep "__destroy_helper_block_" %t | count 4 @@ -8,7 +8,7 @@ // RUN: grep "_Block_object_assign" %t | count 4 // RUN: grep "objc_read_weak" %t | count 2 // RUN: grep "objc_assign_weak" %t | count 3 -// RUN: %clang_cc1 -x objective-c++ %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-fragile-abi +// RUN: %clang_cc1 -x objective-c++ %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 // RUN: grep "_Block_object_dispose" %t | count 6 // RUN: grep "__copy_helper_block_" %t | count 4 // RUN: grep "__destroy_helper_block_" %t | count 4 diff --git a/test/CodeGenObjC/blocks-2.m b/test/CodeGenObjC/blocks-2.m index 591d63bf37da..b04fa008b275 100644 --- a/test/CodeGenObjC/blocks-2.m +++ b/test/CodeGenObjC/blocks-2.m @@ -1,10 +1,10 @@ // We run this twice, once as Objective-C and once as Objective-C++. -// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-fragile-abi | FileCheck %s -// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-fragile-abi -x objective-c++ | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 | FileCheck %s +// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -x objective-c++ | FileCheck %s // CHECK: define i8* @{{.*}}test0 -// CHECK: define internal void @__test0_block_invoke_0( +// CHECK: define internal void @{{.*}}_block_invoke( // CHECK: call i8* @objc_assign_strongCast( // CHECK-NEXT: ret void id test0(id x) { diff --git a/test/CodeGenObjC/blocks-3.m b/test/CodeGenObjC/blocks-3.m index 55e215c7e6ab..a7edc1243cf5 100644 --- a/test/CodeGenObjC/blocks-3.m +++ b/test/CodeGenObjC/blocks-3.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fblocks -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fblocks -o %t %s // 1x for the declaration // 1x for the object-pointer byref copy helper diff --git a/test/CodeGenObjC/blocks-4.m b/test/CodeGenObjC/blocks-4.m index b3d099811cf0..f5af9bc39eb8 100644 --- a/test/CodeGenObjC/blocks-4.m +++ b/test/CodeGenObjC/blocks-4.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions -fblocks -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -fblocks -o %t %s // rdar://7590273 void EXIT(id e); diff --git a/test/CodeGenObjC/blocks-5.m b/test/CodeGenObjC/blocks-5.m index caa8d664455e..18adb0fed9b1 100644 --- a/test/CodeGenObjC/blocks-5.m +++ b/test/CodeGenObjC/blocks-5.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fblocks -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fblocks -o %t %s // rdar: // 8064140 diff --git a/test/CodeGenObjC/blocks.m b/test/CodeGenObjC/blocks.m index f478c07f78fb..6c85da9f895c 100644 --- a/test/CodeGenObjC/blocks.m +++ b/test/CodeGenObjC/blocks.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fblocks -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fblocks -o - %s | FileCheck %s // test1. All of this is somehow testing rdar://6676764 struct S { @@ -18,7 +18,7 @@ void foo(T *P) { -(void) im0; @end -// CHECK: define internal i32 @"__8-[A im0]_block_invoke_0"( +// CHECK: define internal i32 @"__8-[A im0]_block_invoke"( @implementation A -(void) im0 { (void) ^{ return 1; }(); @@ -91,7 +91,7 @@ void test2(Test2 *x) { // rdar://problem/9124263 // In the test above, check that the use in the invocation function // doesn't require a read barrier. -// CHECK: define internal void @__test2_block_invoke_ +// CHECK: define internal void @__test2_block_invoke // CHECK: [[BLOCK:%.*]] = bitcast i8* {{%.*}} to [[BLOCK_T]]* // CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[BLOCK_T]]* [[BLOCK]], i32 0, i32 5 // CHECK-NEXT: [[T1:%.*]] = load i8** [[T0]] diff --git a/test/CodeGenObjC/boxing.m b/test/CodeGenObjC/boxing.m new file mode 100644 index 000000000000..9664298154dc --- /dev/null +++ b/test/CodeGenObjC/boxing.m @@ -0,0 +1,95 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s + +typedef long NSInteger; +typedef unsigned long NSUInteger; +typedef signed char BOOL; +#define nil ((void*) 0) + +@interface NSObject ++ (id)alloc; +@end + +@interface NSNumber : NSObject +@end + +@interface NSNumber (NSNumberCreation) +- (id)initWithChar:(char)value; +- (id)initWithUnsignedChar:(unsigned char)value; +- (id)initWithShort:(short)value; +- (id)initWithUnsignedShort:(unsigned short)value; +- (id)initWithInt:(int)value; +- (id)initWithUnsignedInt:(unsigned int)value; +- (id)initWithLong:(long)value; +- (id)initWithUnsignedLong:(unsigned long)value; +- (id)initWithLongLong:(long long)value; +- (id)initWithUnsignedLongLong:(unsigned long long)value; +- (id)initWithFloat:(float)value; +- (id)initWithDouble:(double)value; +- (id)initWithBool:(BOOL)value; +- (id)initWithInteger:(NSInteger)value; +- (id)initWithUnsignedInteger:(NSUInteger)value; + ++ (NSNumber *)numberWithChar:(char)value; ++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; ++ (NSNumber *)numberWithShort:(short)value; ++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; ++ (NSNumber *)numberWithInt:(int)value; ++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; ++ (NSNumber *)numberWithLong:(long)value; ++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; ++ (NSNumber *)numberWithLongLong:(long long)value; ++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; ++ (NSNumber *)numberWithFloat:(float)value; ++ (NSNumber *)numberWithDouble:(double)value; ++ (NSNumber *)numberWithBool:(BOOL)value; ++ (NSNumber *)numberWithInteger:(NSInteger)value; ++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; +@end + +@interface NSString : NSObject +@end + +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end + +// CHECK: [[WithIntMeth:@".*"]] = internal global [15 x i8] c"numberWithInt:\00" +// CHECK: [[WithIntSEL:@".*"]] = internal global i8* getelementptr inbounds ([15 x i8]* [[WithIntMeth]] +// CHECK: [[WithCharMeth:@".*"]] = internal global [16 x i8] c"numberWithChar:\00" +// CHECK: [[WithCharSEL:@".*"]] = internal global i8* getelementptr inbounds ([16 x i8]* [[WithCharMeth]] +// CHECK: [[WithBoolMeth:@".*"]] = internal global [16 x i8] c"numberWithBool:\00" +// CHECK: [[WithBoolSEL:@".*"]] = internal global i8* getelementptr inbounds ([16 x i8]* [[WithBoolMeth]] +// CHECK: [[WithIntegerMeth:@".*"]] = internal global [19 x i8] c"numberWithInteger:\00" +// CHECK: [[WithIntegerSEL:@".*"]] = internal global i8* getelementptr inbounds ([19 x i8]* [[WithIntegerMeth]] +// CHECK: [[WithUnsignedIntegerMeth:@".*"]] = internal global [27 x i8] c"numberWithUnsignedInteger:\00" +// CHECK: [[WithUnsignedIntegerSEL:@".*"]] = internal global i8* getelementptr inbounds ([27 x i8]* [[WithUnsignedIntegerMeth]] +// CHECK: [[stringWithUTF8StringMeth:@".*"]] = internal global [22 x i8] c"stringWithUTF8String:\00" +// CHECK: [[stringWithUTF8StringSEL:@".*"]] = internal global i8* getelementptr inbounds ([22 x i8]* [[stringWithUTF8StringMeth]] + +int main() { + // CHECK: load i8** [[WithIntSEL]] + int i; @(i); + // CHECK: load i8** [[WithCharSEL]] + signed char sc; @(sc); + // CHECK: load i8** [[WithBoolSEL]] + BOOL b; @(b); + // CHECK: load i8** [[WithBoolSEL]] + typeof(b) b2; @(b2); + // CHECK: load i8** [[WithBoolSEL]] + typedef const typeof(b) MyBOOL; MyBOOL b3; @(b3); + // CHECK: load i8** [[WithBoolSEL]] + @((BOOL)i); + // CHECK: load i8** [[WithIntegerSEL]] + @((NSInteger)i); + // CHECK: load i8** [[WithUnsignedIntegerSEL]] + @((NSUInteger)i); + // CHECK: load i8** [[stringWithUTF8StringSEL]] + const char *s; @(s); + + typedef enum : NSInteger { Red, Green, Blue } Color; + // CHECK: load i8** [[WithIntegerSEL]] + @(Red); + Color col = Red; + // CHECK: load i8** [[WithIntegerSEL]] + @(col); +} diff --git a/test/CodeGenObjC/builtins.m b/test/CodeGenObjC/builtins.m index cb2995da52a5..0c5744805e6d 100644 --- a/test/CodeGenObjC/builtins.m +++ b/test/CodeGenObjC/builtins.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s void test0(id receiver, SEL sel, const char *str) { short s = ((short (*)(id, SEL, const char*)) objc_msgSend)(receiver, sel, str); diff --git a/test/CodeGenObjC/category-class.m b/test/CodeGenObjC/category-class.m index 5a82c1425504..92fd36cbe406 100644 --- a/test/CodeGenObjC/category-class.m +++ b/test/CodeGenObjC/category-class.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // PR7431 // CHECK: module asm "\09.lazy_reference .objc_class_name_A" diff --git a/test/CodeGenObjC/class-type.m b/test/CodeGenObjC/class-type.m index 45aae254bd33..4eae1ae6eab6 100644 --- a/test/CodeGenObjC/class-type.m +++ b/test/CodeGenObjC/class-type.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -emit-llvm -o - %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s @interface I0 { diff --git a/test/CodeGenObjC/constant-string-class.m b/test/CodeGenObjC/constant-string-class.m index ea049a51e12b..adad6b012623 100644 --- a/test/CodeGenObjC/constant-string-class.m +++ b/test/CodeGenObjC/constant-string-class.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fno-constant-cfstrings -fconstant-string-class Foo -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fno-constant-cfstrings -fconstant-string-class Foo -emit-llvm -o %t %s // RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fno-constant-cfstrings -fconstant-string-class Foo -emit-llvm -o %t %s diff --git a/test/CodeGenObjC/constant-strings.m b/test/CodeGenObjC/constant-strings.m index c308d7a475dc..cad634a4b103 100644 --- a/test/CodeGenObjC/constant-strings.m +++ b/test/CodeGenObjC/constant-strings.m @@ -5,11 +5,11 @@ // // CHECK-NEXT: @.str = {{.*}}constant [13 x i8] c"Hello World!\00", align 1 -// RUN: %clang_cc1 -fgnu-runtime -emit-llvm -o %t %s +// RUN: %clang_cc1 -fobjc-runtime=gcc -emit-llvm -o %t %s // RUN: FileCheck --check-prefix=CHECK-GNU < %t %s // CHECK-GNU: NXConstantString -// RUN: %clang_cc1 -fgnu-runtime -fconstant-string-class NSConstantString -emit-llvm -o %t %s +// RUN: %clang_cc1 -fobjc-runtime=gcc -fconstant-string-class NSConstantString -emit-llvm -o %t %s // RUN: FileCheck --check-prefix=CHECK-GNU-WITH-CLASS < %t %s // CHECK-GNU-WITH-CLASS: NSConstantString id a = @"Hello World!"; diff --git a/test/CodeGenObjC/deadcode_strip_used_var.m b/test/CodeGenObjC/deadcode_strip_used_var.m index 3137ceb22298..b8a703487aa8 100644 --- a/test/CodeGenObjC/deadcode_strip_used_var.m +++ b/test/CodeGenObjC/deadcode_strip_used_var.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 %s -emit-llvm -o %t -triple i386-apple-darwin10 -fobjc-fragile-abi +// RUN: %clang_cc1 %s -emit-llvm -o %t -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 // RUN: grep "llvm.used" %t | count 1 -// RUN: %clang_cc1 %s -emit-llvm -o %t -triple x86_64-apple-darwin10 -fobjc-fragile-abi +// RUN: %clang_cc1 %s -emit-llvm -o %t -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 // RUN: grep "llvm.used" %t | count 1 diff --git a/test/CodeGenObjC/debug-info-block-helper.m b/test/CodeGenObjC/debug-info-block-helper.m index 83db0c97e5a8..cf8c2a2a9684 100644 --- a/test/CodeGenObjC/debug-info-block-helper.m +++ b/test/CodeGenObjC/debug-info-block-helper.m @@ -1,8 +1,8 @@ // REQUIRES: x86-64-registered-target -// RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s -o - | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -fblocks -g -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s -o - | FileCheck %s extern void foo(void(^)(void)); -// CHECK: metadata !{i32 786478, i32 0, metadata !27, metadata !"__destroy_helper_block_", metadata !"__destroy_helper_block_", metadata !"", metadata !27, i32 24, metadata !43, i1 true, i1 true, i32 0, i32 0, null, i32 0, i1 false, void (i8*)* @__destroy_helper_block_, null, null, metadata !45, i32 24} ; [ DW_TAG_subprogram ] +// CHECK: metadata !{i32 786478, i32 0, metadata !27, metadata !"__destroy_helper_block_", metadata !"__destroy_helper_block_", metadata !"", metadata !27, i32 24, metadata !37, i1 true, i1 true, i32 0, i32 0, null, i32 0, i1 false, void (i8*)* @__destroy_helper_block_, null, null, metadata !5, i32 24} ; [ DW_TAG_subprogram ] @interface NSObject { struct objc_object *isa; diff --git a/test/CodeGenObjC/debug-info-crash.m b/test/CodeGenObjC/debug-info-crash.m index 5504356d2e3a..abbe2eb651c6 100644 --- a/test/CodeGenObjC/debug-info-crash.m +++ b/test/CodeGenObjC/debug-info-crash.m @@ -1,5 +1,5 @@ // REQUIRES: x86-registered-target -// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-fragile-abi -fblocks -g -S %s -o - +// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fblocks -g -S %s -o - // rdar://7556129 @implementation test diff --git a/test/CodeGenObjC/debug-info-static-var.m b/test/CodeGenObjC/debug-info-static-var.m index c65e77c4d8d4..8602ffb78e46 100644 --- a/test/CodeGenObjC/debug-info-static-var.m +++ b/test/CodeGenObjC/debug-info-static-var.m @@ -1,5 +1,5 @@ // REQUIRES: x86-64-registered-target -// RUN: %clang_cc1 -g -triple x86_64-apple-darwin10 -fobjc-fragile-abi -S -masm-verbose -o - %s | FileCheck %s +// RUN: %clang_cc1 -g -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -S -masm-verbose -o - %s | FileCheck %s // Radar 8801045 // Do not emit AT_MIPS_linkage_name for static variable i diff --git a/test/CodeGenObjC/debug-info-synthesis.m b/test/CodeGenObjC/debug-info-synthesis.m index 7e263cf74c6e..bf8e6d104924 100644 --- a/test/CodeGenObjC/debug-info-synthesis.m +++ b/test/CodeGenObjC/debug-info-synthesis.m @@ -31,4 +31,4 @@ int main(int argc, char *argv[]) { } // CHECK: !7 = metadata !{i32 {{.*}}, metadata !"./foo.h" -// CHECK: !31 = metadata !{i32 {{.*}}, i32 0, metadata !7, metadata !"-[Foo dict]", metadata !"-[Foo dict]", metadata !"", metadata !7, i32 8, metadata !32, i1 true, i1 true, i32 0, i32 0, null, i32 320, i1 false, %1* (%0*, i8*)* @"\01-[Foo dict]", null, null, metadata !34, i32 8} ; [ DW_TAG_subprogram ] +// CHECK: !29 = metadata !{i32 {{.*}}, i32 0, metadata !7, metadata !"-[Foo dict]", metadata !"-[Foo dict]", metadata !"", metadata !7, i32 8, metadata !30, i1 true, i1 true, i32 0, i32 0, null, i32 320, i1 false, %1* (%0*, i8*)* @"\01-[Foo dict]", null, null, metadata !1, i32 8} ; [ DW_TAG_subprogram ] diff --git a/test/CodeGenObjC/encode-cstyle-method.m b/test/CodeGenObjC/encode-cstyle-method.m index ea630230b541..f3243a31487f 100644 --- a/test/CodeGenObjC/encode-cstyle-method.m +++ b/test/CodeGenObjC/encode-cstyle-method.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s // rdar: // 7445205 @interface Foo diff --git a/test/CodeGenObjC/encode-test-6.m b/test/CodeGenObjC/encode-test-6.m new file mode 100644 index 000000000000..10681dbcc592 --- /dev/null +++ b/test/CodeGenObjC/encode-test-6.m @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm -o %t %s +// RUN: FileCheck < %t %s +// rdar://11777609 + +typedef struct {} Z; + +@interface A +-(void)bar:(Z)a; +-(void)foo:(Z)a : (char*)b : (Z)c : (double) d; +@end + +@implementation A +-(void)bar:(Z)a {} +-(void)foo:(Z)a: (char*)b : (Z)c : (double) d {} +@end + +// CHECK: internal global [14 x i8] c"v16@0:8{?=}16 +// CHECK: internal global [26 x i8] c"v32@0:8{?=}16*16{?=}24d24 + diff --git a/test/CodeGenObjC/encode-test.m b/test/CodeGenObjC/encode-test.m index 02af5daa2265..3780068e6178 100644 --- a/test/CodeGenObjC/encode-test.m +++ b/test/CodeGenObjC/encode-test.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i686-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i686-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: FileCheck < %t %s // // CHECK: @"\01L_OBJC_METH_VAR_TYPE_34" = internal global [16 x i8] c"v12@0:4[3[4@]]8\00" diff --git a/test/CodeGenObjC/exceptions.m b/test/CodeGenObjC/exceptions.m index 24fb6575e440..25780fd518fe 100644 --- a/test/CodeGenObjC/exceptions.m +++ b/test/CodeGenObjC/exceptions.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -fexceptions -fobjc-exceptions -O2 -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fexceptions -fobjc-exceptions -O2 -o - %s | FileCheck %s // // <rdar://problem/7471679> [irgen] [eh] Exception code built with clang (x86_64) crashes diff --git a/test/CodeGenObjC/fp2ret.m b/test/CodeGenObjC/fp2ret.m index 9c956aec9b3f..2e65332ec974 100644 --- a/test/CodeGenObjC/fp2ret.m +++ b/test/CodeGenObjC/fp2ret.m @@ -1,10 +1,10 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | \ +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-X86_32 %s // -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | \ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-X86_64 %s // -// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fobjc-fragile-abi -emit-llvm -target-abi apcs-gnu -o - %s | \ +// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -target-abi apcs-gnu -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-ARMV7 %s @interface A diff --git a/test/CodeGenObjC/fpret.m b/test/CodeGenObjC/fpret.m index bf111e001d04..cabef108df48 100644 --- a/test/CodeGenObjC/fpret.m +++ b/test/CodeGenObjC/fpret.m @@ -1,10 +1,10 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | \ +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-X86_32 %s // -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | \ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-X86_64 %s // -// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fobjc-fragile-abi -emit-llvm -target-abi apcs-gnu -o - %s | \ +// RUN: %clang_cc1 -triple armv7-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -target-abi apcs-gnu -o - %s | \ // RUN: FileCheck --check-prefix=CHECK-ARMV7 %s @interface A diff --git a/test/CodeGenObjC/getter-property-mismatch.m b/test/CodeGenObjC/getter-property-mismatch.m new file mode 100644 index 000000000000..21ed6eea68e8 --- /dev/null +++ b/test/CodeGenObjC/getter-property-mismatch.m @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 %s -emit-llvm -triple x86_64-apple-darwin -o - | FileCheck %s +// rdar://11323676 + +@interface NSDictionary @end +@interface NSMutableDictionary : NSDictionary@end@interface CalDAVAddManagedAttachmentsTaskGroup { + NSMutableDictionary *_filenamesToServerLocation; +} +- (NSDictionary *)filenamesToServerLocation; +@property (readwrite, retain) NSMutableDictionary *filenamesToServerLocation; +@end + +@implementation CalDAVAddManagedAttachmentsTaskGroup +@synthesize filenamesToServerLocation=_filenamesToServerLocation; +@end + +// CHECK: [[CALL:%.*]] = call i8* @objc_getProperty +// CHECK: [[ONE:%.*]] = bitcast i8* [[CALL:%.*]] to [[T1:%.*]]* +// CHECK: [[TWO:%.*]] = bitcast [[T1]]* [[ONE]] to [[T2:%.*]]* +// CHECK: ret [[T2]]* [[TWO]] + diff --git a/test/CodeGenObjC/getter-property-type-mismatch.m b/test/CodeGenObjC/getter-property-type-mismatch.m new file mode 100644 index 000000000000..c7e1c1a96a42 --- /dev/null +++ b/test/CodeGenObjC/getter-property-type-mismatch.m @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s +// rdar://11515196 + +@interface NSArray @end + +@interface NSMutableArray : NSArray +- (void) addObject; +@end + +@interface BPXLAppDelegate + +- (NSArray *)arrayOfThings; + +@end + + +@interface BPXLAppDelegate () +@property (retain, nonatomic) NSMutableArray *arrayOfThings; +@end + +@implementation BPXLAppDelegate + +@synthesize arrayOfThings=_arrayOfThings; + +- (void)applicationDidFinishLaunching +{ + [self.arrayOfThings addObject]; +} + +@end + +// CHECK: define internal [[RET:%.*]]* @"\01-[BPXLAppDelegate arrayOfThings +// CHECK: [[THREE:%.*]] = bitcast [[OPQ:%.*]]* [[TWO:%.*]] to [[RET]]* +// CHECK: ret [[RET]]* [[THREE]] + diff --git a/test/CodeGenObjC/gnu-exceptions.m b/test/CodeGenObjC/gnu-exceptions.m index 8917bf3120da..141747ec8d3d 100644 --- a/test/CodeGenObjC/gnu-exceptions.m +++ b/test/CodeGenObjC/gnu-exceptions.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fgnu-runtime -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime=gcc -o - %s | FileCheck %s void opaque(void); void log(int i); diff --git a/test/CodeGenObjC/id-isa-codegen.m b/test/CodeGenObjC/id-isa-codegen.m index 8cac750773c4..8717ce2d0abb 100644 --- a/test/CodeGenObjC/id-isa-codegen.m +++ b/test/CodeGenObjC/id-isa-codegen.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix LP32 %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck -check-prefix LP32 %s typedef struct objc_class *Class; diff --git a/test/CodeGenObjC/image-info.m b/test/CodeGenObjC/image-info.m index 613b272bdea2..030bcaed1a38 100644 --- a/test/CodeGenObjC/image-info.m +++ b/test/CodeGenObjC/image-info.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s diff --git a/test/CodeGenObjC/implicit-objc_msgSend.m b/test/CodeGenObjC/implicit-objc_msgSend.m index aff0fe45a009..6fc3d46d50d9 100644 --- a/test/CodeGenObjC/implicit-objc_msgSend.m +++ b/test/CodeGenObjC/implicit-objc_msgSend.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: grep -F 'declare i8* @objc_msgSend(i8*, i8*, ...)' %t typedef struct objc_selector *SEL; diff --git a/test/CodeGenObjC/interface-layout-64.m b/test/CodeGenObjC/interface-layout-64.m index 4fdda4559d14..16361a21b67e 100644 --- a/test/CodeGenObjC/interface-layout-64.m +++ b/test/CodeGenObjC/interface-layout-64.m @@ -1,33 +1,32 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s // RUNX: llvm-gcc -m64 -emit-llvm -S -o %t %s && -// RUN: grep '@"OBJC_IVAR_$_I3._iv2" = global i64 8, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I3._iv3" = global i64 12, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I4._iv4" = global i64 13, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I5._iv5" = global i64 14, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I5._iv6_synth" = hidden global i64 16, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I5._iv7_synth" = hidden global i64 20, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I6.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I8.b" = global i64 8, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I9.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I10.iv1" = global i64 4, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '@"OBJC_IVAR_$_I12.iv2" = global i64 8, section "__DATA, __objc_ivar", align 8' %t -// RUN: grep '_OBJC_CLASS_RO_$_I3" = internal global .* { i32 0, i32 8, i32 13, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I4" = internal global .* { i32 0, i32 13, i32 14, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I5" = internal global .* { i32 0, i32 14, i32 24, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I6" = internal global .* { i32 2, i32 0, i32 1, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I8" = internal global .* { i32 0, i32 8, i32 16, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I9" = internal global .* { i32 2, i32 0, i32 4, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I10" = internal global .* { i32 0, i32 4, i32 5, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I11" = internal global .* { i32 0, i32 5, i32 5, .*' %t -// RUN: grep '_OBJC_CLASS_RO_$_I12" = internal global .* { i32 0, i32 8, i32 12, .*' %t - +// CHECK: @"OBJC_IVAR_$_I3._iv2" = global i64 8, section "__DATA, __objc_ivar", align 8 +// CHECK: @"OBJC_IVAR_$_I3._iv3" = global i64 12, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I3" = internal global {{.*}} { i32 0, i32 8, i32 13 +// CHECK: @"OBJC_IVAR_$_I4._iv4" = global i64 13, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I4" = internal global {{.*}} { i32 0, i32 13, i32 14, {{.*}} +// CHECK: @"OBJC_IVAR_$_I5._iv6_synth" = hidden global i64 16, section "__DATA, __objc_ivar", align 8 +// CHECK: @"OBJC_IVAR_$_I5._iv7_synth" = hidden global i64 20, section "__DATA, __objc_ivar", align 8 +// CHECK: @"OBJC_IVAR_$_I5._iv5" = global i64 14, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I5" = internal global {{.*}} { i32 0, i32 14, i32 24, {{.*}} +// CHECK: @"OBJC_IVAR_$_I6.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I6" = internal global {{.*}} { i32 2, i32 0, i32 1, {{.*}} +// CHECK: @"OBJC_IVAR_$_I8.b" = global i64 8, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I8" = internal global {{.*}} { i32 0, i32 8, i32 16, {{.*}} +// CHECK: @"OBJC_IVAR_$_I9.iv0" = global i64 0, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I9" = internal global {{.*}} { i32 2, i32 0, i32 4, {{.*}} +// CHECK: @"OBJC_IVAR_$_I10.iv1" = global i64 4, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I10" = internal global {{.*}} { i32 0, i32 4, i32 5, {{.*}} +// CHECK: _OBJC_CLASS_RO_$_I11" = internal global {{.*}} { i32 0, i32 5, i32 5, {{.*}} +// CHECK: @"OBJC_IVAR_$_I12.iv2" = global i64 8, section "__DATA, __objc_ivar", align 8 +// CHECK: _OBJC_CLASS_RO_$_I12" = internal global {{.*}} { i32 0, i32 8, i32 12, {{.*}} /* Compare to: - gcc -m64 -S -o - interface-layout-64.m | grep '^_OBJC_IVAR_$_*.*' -A 1 + gcc -m64 -S -o - interface-layout-64.m | grep '^_OBJC_IVAR_$_*{{.*}}' -A 1 and - gcc -m64 -S -o - interface-layout-64.m | grep '^l.*_CLASS_RO_$_I[0-9]*' -A 3 + gcc -m64 -S -o - interface-layout-64.m | grep '^l{{.*}}_CLASS_RO_$_I[0-9]*' -A 3 */ struct s0 { diff --git a/test/CodeGenObjC/interface.m b/test/CodeGenObjC/interface.m index 0ca64ecd3ffc..4adc926141b2 100644 --- a/test/CodeGenObjC/interface.m +++ b/test/CodeGenObjC/interface.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -O3 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -O3 -emit-llvm -o %t %s // RUN: grep 'ret i32 385' %t void *alloca(); diff --git a/test/CodeGenObjC/ivar-layout-64-bitfields.m b/test/CodeGenObjC/ivar-layout-64-bitfields.m index acc734a575de..f2f05931d913 100644 --- a/test/CodeGenObjC/ivar-layout-64-bitfields.m +++ b/test/CodeGenObjC/ivar-layout-64-bitfields.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s #ifdef __cplusplus typedef bool _Bool; diff --git a/test/CodeGenObjC/ivar-layout-array0-struct.m b/test/CodeGenObjC/ivar-layout-array0-struct.m index 7ef32f634237..267f947f42b6 100644 --- a/test/CodeGenObjC/ivar-layout-array0-struct.m +++ b/test/CodeGenObjC/ivar-layout-array0-struct.m @@ -1,5 +1,5 @@ // REQUIRES: x86-64-registered-target -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -S %s -o %t-64.s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -O0 -S %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s // rdar://8800513 diff --git a/test/CodeGenObjC/ivar-layout-no-optimize.m b/test/CodeGenObjC/ivar-layout-no-optimize.m index 85bba8abaaa9..46a7034a2249 100644 --- a/test/CodeGenObjC/ivar-layout-no-optimize.m +++ b/test/CodeGenObjC/ivar-layout-no-optimize.m @@ -1,7 +1,7 @@ // REQUIRES: x86-64-registered-target -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -S %s -o %t-64.s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -O0 -S %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s -// RUN: %clang_cc1 -x objective-c++ -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -O0 -S %s -o %t-64.s +// RUN: %clang_cc1 -x objective-c++ -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -O0 -S %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s @interface NSObject { diff --git a/test/CodeGenObjC/ivars.m b/test/CodeGenObjC/ivars.m index 6c8a72d0f100..1ccfa36345c5 100644 --- a/test/CodeGenObjC/ivars.m +++ b/test/CodeGenObjC/ivars.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s // RUN: %clang_cc1 -fobjc-gc -emit-llvm -o - %s // rdar://6800926 diff --git a/test/CodeGenObjC/layout-bitfield-crash.m b/test/CodeGenObjC/layout-bitfield-crash.m new file mode 100644 index 000000000000..5d0e7bfd2e7f --- /dev/null +++ b/test/CodeGenObjC/layout-bitfield-crash.m @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-gc -emit-llvm -g -o - %s +// Check that this doesn't crash when compiled with debugging on. +@class Foo; +typedef struct Bar *BarRef; + +@interface Baz +@end + +@interface Foo +- (void) setFlag; +@end + +@implementation Baz + +- (void) a:(BarRef)b +{ + Foo* view = (Foo*)self; + [view setFlag]; +} + +@end + + +@implementation Foo +{ + int flag : 1; +} + +- (void) setFlag +{ + if (!flag) + flag = 1; +} + +@end diff --git a/test/CodeGenObjC/link-errors.m b/test/CodeGenObjC/link-errors.m index 0d19681ec109..f2d9ddba883b 100644 --- a/test/CodeGenObjC/link-errors.m +++ b/test/CodeGenObjC/link-errors.m @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: grep '.lazy_reference .objc_class_name_A' %t | count 1 // RUN: grep '.lazy_reference .objc_class_name_Unknown' %t | count 1 // RUN: grep '.lazy_reference .objc_class_name_Protocol' %t | count 1 -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -DWITH_IMPL -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -DWITH_IMPL -emit-llvm -o %t %s // RUN: grep '.lazy_reference .objc_class_name_Root' %t | count 1 @interface Root diff --git a/test/CodeGenObjC/local-static-block.m b/test/CodeGenObjC/local-static-block.m index 7a7b6f6e087b..deea8bac13ea 100644 --- a/test/CodeGenObjC/local-static-block.m +++ b/test/CodeGenObjC/local-static-block.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o %t-64.ll +// RUN: %clang_cc1 -fblocks -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o %t-64.ll // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.ll %s // rdar: // 8390455 diff --git a/test/CodeGenObjC/messages-2.m b/test/CodeGenObjC/messages-2.m index 7c9d81cc9d71..ce6624ad5a0a 100644 --- a/test/CodeGenObjC/messages-2.m +++ b/test/CodeGenObjC/messages-2.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-NF // Most of this test is apparently just verifying that we don't crash. diff --git a/test/CodeGenObjC/messages.m b/test/CodeGenObjC/messages.m index 6f39602d9c96..a42677ef7849 100644 --- a/test/CodeGenObjC/messages.m +++ b/test/CodeGenObjC/messages.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC +// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC // RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-MAC-NF -// RUN: %clang_cc1 -fobjc-fragile-abi -fgnu-runtime -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-GNU -// RUN: %clang_cc1 -fgnu-runtime -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-GNU-NF +// RUN: %clang_cc1 -fobjc-runtime=gcc -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK-GNU +// RUN: %clang_cc1 -fobjc-runtime=gnustep -emit-llvm -o - %s | FileCheck %s -check-prefix CHECK-GNU-NF typedef struct { int x; diff --git a/test/CodeGenObjC/metadata-symbols-32.m b/test/CodeGenObjC/metadata-symbols-32.m index a7bcf01926b2..1df1560d8fcc 100644 --- a/test/CodeGenObjC/metadata-symbols-32.m +++ b/test/CodeGenObjC/metadata-symbols-32.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUNX: llvm-gcc -m32 -emit-llvm -S -o %t %s && // RUN: grep '@"\\01L_OBJC_CATEGORY_A_Cat" = internal global .*section "__OBJC,__category,regular,no_dead_strip", align 4' %t diff --git a/test/CodeGenObjC/misc-atomic-property.m b/test/CodeGenObjC/misc-atomic-property.m index f2645dcaef84..4c8cc669705d 100644 --- a/test/CodeGenObjC/misc-atomic-property.m +++ b/test/CodeGenObjC/misc-atomic-property.m @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar: //8808439 typedef struct { diff --git a/test/CodeGenObjC/mrr-autorelease.m b/test/CodeGenObjC/mrr-autorelease.m index f7a13fd8dcf2..773fdbc96854 100644 --- a/test/CodeGenObjC/mrr-autorelease.m +++ b/test/CodeGenObjC/mrr-autorelease.m @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar://8881826 // rdar://9423507 diff --git a/test/CodeGenObjC/nested-rethrow.m b/test/CodeGenObjC/nested-rethrow.m index 5576c1640d18..bff52c3b2494 100644 --- a/test/CodeGenObjC/nested-rethrow.m +++ b/test/CodeGenObjC/nested-rethrow.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions %s -o - | FileCheck %s extern int printf(const char*, ...); diff --git a/test/CodeGenObjC/next-objc-dispatch.m b/test/CodeGenObjC/next-objc-dispatch.m index 4288b2da0cb2..6afd658e03a7 100644 --- a/test/CodeGenObjC/next-objc-dispatch.m +++ b/test/CodeGenObjC/next-objc-dispatch.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s \ +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s \ // RUN: -fobjc-dispatch-method=legacy | \ // RUN: FileCheck -check-prefix CHECK-FRAGILE_LEGACY %s // diff --git a/test/CodeGenObjC/no-category-class.m b/test/CodeGenObjC/no-category-class.m index 3969f917e2f3..0c672f7894a6 100644 --- a/test/CodeGenObjC/no-category-class.m +++ b/test/CodeGenObjC/no-category-class.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s @interface NSObject @end diff --git a/test/CodeGenObjC/nonlazy-msgSend.m b/test/CodeGenObjC/nonlazy-msgSend.m index 73157c77c030..7c349b293807 100644 --- a/test/CodeGenObjC/nonlazy-msgSend.m +++ b/test/CodeGenObjC/nonlazy-msgSend.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: grep -F 'declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind' %t void f0(id x) { diff --git a/test/CodeGenObjC/ns-constant-strings.m b/test/CodeGenObjC/ns-constant-strings.m index d04793c8c239..ccaacaf53e76 100644 --- a/test/CodeGenObjC/ns-constant-strings.m +++ b/test/CodeGenObjC/ns-constant-strings.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fno-constant-cfstrings -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fno-constant-cfstrings -emit-llvm -o %t %s // RUN: FileCheck --check-prefix CHECK-FRAGILE < %t %s // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fno-constant-cfstrings -emit-llvm -o %t %s diff --git a/test/CodeGenObjC/objc-align.m b/test/CodeGenObjC/objc-align.m index f3c586eeb214..324740c8aefc 100644 --- a/test/CodeGenObjC/objc-align.m +++ b/test/CodeGenObjC/objc-align.m @@ -1,7 +1,7 @@ // 32-bit // RUNX: llvm-gcc -m32 -emit-llvm -S -o %t %s && -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s // RUN: grep '@"\\01L_OBJC_CATEGORY_A_Cat" = internal global .*, section "__OBJC,__category,regular,no_dead_strip", align 4' %t // RUN: grep '@"\\01L_OBJC_CLASS_A" = internal global .*, section "__OBJC,__class,regular,no_dead_strip", align 4' %t // RUN: grep '@"\\01L_OBJC_CLASS_C" = internal global .*, section "__OBJC,__class,regular,no_dead_strip", align 4' %t diff --git a/test/CodeGenObjC/objc-assign-ivar.m b/test/CodeGenObjC/objc-assign-ivar.m index d0a1a0fceefe..0dc9ec292d71 100644 --- a/test/CodeGenObjC/objc-assign-ivar.m +++ b/test/CodeGenObjC/objc-assign-ivar.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_ivar' %t | count 14 typedef struct { diff --git a/test/CodeGenObjC/objc-gc-aggr-assign.m b/test/CodeGenObjC/objc-gc-aggr-assign.m index dfdf02e2a5a6..6c2baac0504b 100644 --- a/test/CodeGenObjC/objc-gc-aggr-assign.m +++ b/test/CodeGenObjC/objc-gc-aggr-assign.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix C %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix CP %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix C %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix CP %s static int count; diff --git a/test/CodeGenObjC/objc-literal-debugger-test.m b/test/CodeGenObjC/objc-literal-debugger-test.m index 389ef2248a48..5f69fd5ba889 100644 --- a/test/CodeGenObjC/objc-literal-debugger-test.m +++ b/test/CodeGenObjC/objc-literal-debugger-test.m @@ -1,7 +1,29 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdebugger-objc-literal -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdebugger-objc-literal -emit-llvm -o - %s -DINCLUDE_INTERFACES=1 | FileCheck %s + +// We need two different RUN lines here because the first time a class/method is absent, +// it will be added for -fdebugger-objc-literal. + +#ifdef INCLUDE_INTERFACES +@interface NSObject +@end + +@interface NSNumber : NSObject +@end + +@interface NSArray : NSObject +@end + +@interface NSDictionary : NSObject +@end + +@interface NSString : NSObject +@end +#endif int main() { - id l = @'a'; + // object literals. + id l; l = @'a'; l = @42; l = @-42; @@ -11,6 +33,21 @@ int main() { l = @__objc_no; l = @{ @"name":@666 }; l = @[ @"foo", @"bar" ]; + +#if __has_feature(objc_boxed_expressions) + // boxed expressions. + id b; + b = @('a'); + b = @(42); + b = @(-42); + b = @(42u); + b = @(3.141592654f); + b = @(__objc_yes); + b = @(__objc_no); + b = @("hello"); +#else +#error "boxed expressions not supported" +#endif } // CHECK: declare i8* @objc_msgSend(i8*, i8*, ...) nonlazybind diff --git a/test/CodeGenObjC/objc-read-weak-byref.m b/test/CodeGenObjC/objc-read-weak-byref.m index 8fe1436567b1..94eca2899d9b 100644 --- a/test/CodeGenObjC/objc-read-weak-byref.m +++ b/test/CodeGenObjC/objc-read-weak-byref.m @@ -1,7 +1,7 @@ // REQUIRES: x86-registered-target,x86-64-registered-target -// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -S %s -o %t-64.s +// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -S %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s -// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -fobjc-fragile-abi -S %s -o %t-32.s +// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -S %s -o %t-32.s // RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s @interface NSObject diff --git a/test/CodeGenObjC/objc2-assign-global.m b/test/CodeGenObjC/objc2-assign-global.m index 36c95f792dae..147aa3d3e3f2 100644 --- a/test/CodeGenObjC/objc2-assign-global.m +++ b/test/CodeGenObjC/objc2-assign-global.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_global' %t | count 26 @class NSObject; diff --git a/test/CodeGenObjC/objc2-new-gc-api-strongcast.m b/test/CodeGenObjC/objc2-new-gc-api-strongcast.m index 1044ba529857..5619ab3d3d49 100644 --- a/test/CodeGenObjC/objc2-new-gc-api-strongcast.m +++ b/test/CodeGenObjC/objc2-new-gc-api-strongcast.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fblocks -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fblocks -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_strongCast' %t | count 4 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fblocks -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fblocks -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_strongCast' %t | count 4 @interface DSATextSearch @end diff --git a/test/CodeGenObjC/objc2-no-write-barrier.m b/test/CodeGenObjC/objc2-no-write-barrier.m index d439368cc608..ece6b9d582b7 100644 --- a/test/CodeGenObjC/objc2-no-write-barrier.m +++ b/test/CodeGenObjC/objc2-no-write-barrier.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep 'objc_assign' %t | count 0 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep 'objc_assign' %t | count 0 typedef struct { diff --git a/test/CodeGenObjC/objc2-retain-codegen.m b/test/CodeGenObjC/objc2-retain-codegen.m index d5b473e33473..594e3dfcd06b 100644 --- a/test/CodeGenObjC/objc2-retain-codegen.m +++ b/test/CodeGenObjC/objc2-retain-codegen.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc-only -emit-llvm -o %t %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc-only -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc-only -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc-only -emit-llvm -o %t %s @interface I0 { I0 *_f0; diff --git a/test/CodeGenObjC/objc2-strong-cast-1.m b/test/CodeGenObjC/objc2-strong-cast-1.m index 9bb750fd0523..4417084ebb9f 100644 --- a/test/CodeGenObjC/objc2-strong-cast-1.m +++ b/test/CodeGenObjC/objc2-strong-cast-1.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s @interface I { __attribute__((objc_gc(strong))) int *i_IdocumentIDs; diff --git a/test/CodeGenObjC/objc2-weak-assign.m b/test/CodeGenObjC/objc2-weak-assign.m index e5c67c58d64a..13ce3386c034 100644 --- a/test/CodeGenObjC/objc2-weak-assign.m +++ b/test/CodeGenObjC/objc2-weak-assign.m @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -e "objc_assign_weak" %t | grep -e "call" | count 6 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -e "objc_assign_weak" %t | grep -e "call" | count 6 __weak id* x; diff --git a/test/CodeGenObjC/objc2-weak-block-call.m b/test/CodeGenObjC/objc2-weak-block-call.m index 94c54e7f3ba2..25434947d104 100644 --- a/test/CodeGenObjC/objc2-weak-block-call.m +++ b/test/CodeGenObjC/objc2-weak-block-call.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o - | FileCheck -check-prefix LP64 %s -// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o - | FileCheck -check-prefix LP64 %s +// RUN: %clang_cc1 -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o - | FileCheck -check-prefix LP64 %s +// RUN: %clang_cc1 -fblocks -fobjc-gc -triple i386-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o - | FileCheck -check-prefix LP64 %s @interface MyView - (void)MyView_sharedInit; diff --git a/test/CodeGenObjC/objc2-weak-compare.m b/test/CodeGenObjC/objc2-weak-compare.m index 75cf689737b4..d8d5459aee23 100644 --- a/test/CodeGenObjC/objc2-weak-compare.m +++ b/test/CodeGenObjC/objc2-weak-compare.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s -// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s @interface PBXTarget { diff --git a/test/CodeGenObjC/objc2-weak-ivar-debug.m b/test/CodeGenObjC/objc2-weak-ivar-debug.m index 83262a82a61b..8c323b75213e 100644 --- a/test/CodeGenObjC/objc2-weak-ivar-debug.m +++ b/test/CodeGenObjC/objc2-weak-ivar-debug.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s -// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -g -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s +// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -g -emit-llvm -o - %s // rdar://7252252 @interface Loop { diff --git a/test/CodeGenObjC/objc2-weak-ivar.m b/test/CodeGenObjC/objc2-weak-ivar.m index 78ccdf8876cc..0c8503ed2ee4 100644 --- a/test/CodeGenObjC/objc2-weak-ivar.m +++ b/test/CodeGenObjC/objc2-weak-ivar.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s @class NSObject; @interface Foo { diff --git a/test/CodeGenObjC/objc2-write-barrier-2.m b/test/CodeGenObjC/objc2-write-barrier-2.m index eae2551aa074..6bc2f509083b 100644 --- a/test/CodeGenObjC/objc2-write-barrier-2.m +++ b/test/CodeGenObjC/objc2-write-barrier-2.m @@ -1,8 +1,8 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_global' %t | count 7 // RUN: grep -F '@objc_assign_ivar' %t | count 5 // RUN: grep -F '@objc_assign_strongCast' %t | count 8 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_global' %t | count 7 // RUN: grep -F '@objc_assign_ivar' %t | count 5 // RUN: grep -F '@objc_assign_strongCast' %t | count 8 diff --git a/test/CodeGenObjC/objc2-write-barrier-4.m b/test/CodeGenObjC/objc2-write-barrier-4.m index 4089920b0925..d01ed1934b39 100644 --- a/test/CodeGenObjC/objc2-write-barrier-4.m +++ b/test/CodeGenObjC/objc2-write-barrier-4.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep objc_assign_global %t | count 3 // RUN: grep objc_assign_strongCast %t | count 2 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep objc_assign_global %t | count 3 // RUN: grep objc_assign_strongCast %t | count 2 diff --git a/test/CodeGenObjC/objc2-write-barrier-5.m b/test/CodeGenObjC/objc2-write-barrier-5.m index 122fa9f3c0b7..65a71a5a1d35 100644 --- a/test/CodeGenObjC/objc2-write-barrier-5.m +++ b/test/CodeGenObjC/objc2-write-barrier-5.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep objc_assign_ivar %t | count 0 // RUN: grep objc_assign_strongCast %t | count 8 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep objc_assign_ivar %t | count 0 // RUN: grep objc_assign_strongCast %t | count 8 diff --git a/test/CodeGenObjC/objc2-write-barrier.m b/test/CodeGenObjC/objc2-write-barrier.m index bf2dfb9b14f9..7634dc97412a 100644 --- a/test/CodeGenObjC/objc2-write-barrier.m +++ b/test/CodeGenObjC/objc2-write-barrier.m @@ -1,7 +1,7 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_global' %t | count 21 // RUN: grep -F '@objc_assign_ivar' %t | count 11 -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o %t %s // RUN: grep -F '@objc_assign_global' %t | count 21 // RUN: grep -F '@objc_assign_ivar' %t | count 11 diff --git a/test/CodeGenObjC/object-incr-decr-1.m b/test/CodeGenObjC/object-incr-decr-1.m index 19c12cb315a2..c1181a21c720 100644 --- a/test/CodeGenObjC/object-incr-decr-1.m +++ b/test/CodeGenObjC/object-incr-decr-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm %s -o %t +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o %t @interface Foo { diff --git a/test/CodeGenObjC/objfw.m b/test/CodeGenObjC/objfw.m new file mode 100644 index 000000000000..98e3fb02652d --- /dev/null +++ b/test/CodeGenObjC/objfw.m @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fobjc-runtime=objfw -emit-llvm -o - %s | FileCheck %s + +// Test the ObjFW runtime. + +@interface Test0 ++ (void) test; +@end +void test0(void) { + [Test0 test]; +} +// CHECK: define void @test0() +// CHECK: [[T0:%.*]] = call i8* (i8*, i8*, ...)* (i8*, i8*)* @objc_msg_lookup(i8* bitcast (i64* @_OBJC_CLASS_Test0 to i8*), +// CHECK-NEXT: [[T1:%.*]] = bitcast i8* (i8*, i8*, ...)* [[T0]] to void (i8*, i8*)* +// CHECK-NEXT: call void [[T1]](i8* bitcast (i64* @_OBJC_CLASS_Test0 to i8*), +// CHECK-NEXT: ret void diff --git a/test/CodeGenObjC/predefined-expr.m b/test/CodeGenObjC/predefined-expr.m index 009bbcdb013c..d5866bbdbed5 100644 --- a/test/CodeGenObjC/predefined-expr.m +++ b/test/CodeGenObjC/predefined-expr.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi %s -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 %s -emit-llvm -o - | FileCheck %s // CHECK: @"__func__.-[Foo instanceTest1]" = private unnamed_addr constant [21 x i8] c"-[Foo instanceTest1]\00" // CHECK: @"__func__.-[Foo instanceTest2:]" = private unnamed_addr constant [22 x i8] c"-[Foo instanceTest2:]\00" diff --git a/test/CodeGenObjC/property-complex.m b/test/CodeGenObjC/property-complex.m index 3cdd2ecfd15d..027f6d632686 100644 --- a/test/CodeGenObjC/property-complex.m +++ b/test/CodeGenObjC/property-complex.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o %t %s @interface I0 { @public diff --git a/test/CodeGenObjC/property-ref-cast-to-void.m b/test/CodeGenObjC/property-ref-cast-to-void.m index ad1689fd6243..ae2a4583629b 100644 --- a/test/CodeGenObjC/property-ref-cast-to-void.m +++ b/test/CodeGenObjC/property-ref-cast-to-void.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar: // 8399655 @interface TestClass diff --git a/test/CodeGenObjC/protocol-in-extended-class.m b/test/CodeGenObjC/protocol-in-extended-class.m index a92408463deb..b919d5fd234a 100644 --- a/test/CodeGenObjC/protocol-in-extended-class.m +++ b/test/CodeGenObjC/protocol-in-extended-class.m @@ -1,7 +1,7 @@ // REQUIRES: x86-registered-target,x86-64-registered-target // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -S %s -o %t-64.s // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s -// RUN: %clang_cc1 -triple i386-apple-darwin -fobjc-fragile-abi -S %s -o %t-32.s +// RUN: %clang_cc1 -triple i386-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -S %s -o %t-32.s // RUN: FileCheck -check-prefix LP32 --input-file=%t-32.s %s @protocol MyProtocol diff --git a/test/CodeGenObjC/protocols-lazy.m b/test/CodeGenObjC/protocols-lazy.m index 1c551fbeec11..877d4923f387 100644 --- a/test/CodeGenObjC/protocols-lazy.m +++ b/test/CodeGenObjC/protocols-lazy.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin8 -fobjc-fragile-abi -o %t %s +// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin8 -fobjc-runtime=macosx-fragile-10.5 -o %t %s // RUNX: llvm-gcc -S -emit-llvm -o %t %s && // No object generated diff --git a/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m b/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m index a93ca033c13c..fb808b3b771b 100644 --- a/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m +++ b/test/CodeGenObjC/rdr-6732143-dangling-block-reference.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions %s -o - +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions %s -o - void f0(id x) { @synchronized (x) { diff --git a/test/CodeGenObjC/super-message-fragileabi.m b/test/CodeGenObjC/super-message-fragileabi.m index 0135919b8946..b6c908624ef6 100644 --- a/test/CodeGenObjC/super-message-fragileabi.m +++ b/test/CodeGenObjC/super-message-fragileabi.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o - | FileCheck %s @class Some; diff --git a/test/CodeGenObjC/synchronized.m b/test/CodeGenObjC/synchronized.m index 4997bb77525e..1f012820f9ba 100644 --- a/test/CodeGenObjC/synchronized.m +++ b/test/CodeGenObjC/synchronized.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin9 -fobjc-fragile-abi -o - %s -O2 | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -triple i686-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -o - %s -O2 | FileCheck %s @interface MyClass { diff --git a/test/CodeGenObjC/terminate.m b/test/CodeGenObjC/terminate.m index a86205839d45..8728ec4598bf 100644 --- a/test/CodeGenObjC/terminate.m +++ b/test/CodeGenObjC/terminate.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -fexceptions -fobjc-exceptions -fobjc-runtime-has-terminate -o - %s | FileCheck %s -check-prefix=CHECK-WITH -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s -check-prefix=CHECK-WITHOUT +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.8 -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s -check-prefix=CHECK-WITH +// RUN: %clang_cc1 -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.7 -emit-llvm -fexceptions -fobjc-exceptions -o - %s | FileCheck %s -check-prefix=CHECK-WITHOUT void destroy(void**); diff --git a/test/CodeGenObjC/undefined-protocol.m b/test/CodeGenObjC/undefined-protocol.m index d87a5c999ee9..e5a72ab602f0 100644 --- a/test/CodeGenObjC/undefined-protocol.m +++ b/test/CodeGenObjC/undefined-protocol.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm-only -fgnu-runtime %s +// RUN: %clang_cc1 -emit-llvm-only -fobjc-runtime=gcc %s @protocol MadeUpProtocol; diff --git a/test/CodeGenObjC/variadic-sends.m b/test/CodeGenObjC/variadic-sends.m index 94d7bafba472..726b497b21b4 100644 --- a/test/CodeGenObjC/variadic-sends.m +++ b/test/CodeGenObjC/variadic-sends.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-32 %s -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-64 %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-32 %s +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck -check-prefix=CHECK-X86-64 %s @interface A -(void) im0; diff --git a/test/CodeGenObjC/x86_64-struct-return-gc.m b/test/CodeGenObjC/x86_64-struct-return-gc.m index 76407d6654e0..dab5b15e284e 100644 --- a/test/CodeGenObjC/x86_64-struct-return-gc.m +++ b/test/CodeGenObjC/x86_64-struct-return-gc.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -fobjc-gc -emit-llvm -o - %s | FileCheck %s struct Coerce { id a; }; diff --git a/test/CodeGenObjCXX/arc.mm b/test/CodeGenObjCXX/arc.mm index 45211a2c19ab..f31b993946e8 100644 --- a/test/CodeGenObjCXX/arc.mm +++ b/test/CodeGenObjCXX/arc.mm @@ -252,3 +252,19 @@ template <class T> class Test38 { }; // CHECK: define weak_odr void @_ZN6Test38IiE4testEi( template class Test38<int>; + +// rdar://problem/11964832 +class Test39_base1 { + virtual void foo(); +}; +class Test39_base2 { + virtual id bar(); +}; +class Test39 : Test39_base1, Test39_base2 { // base2 is at non-zero offset + virtual id bar(); +}; +id Test39::bar() { return 0; } +// Note lack of autorelease. +// CHECK: define i8* @_ZThn8_N6Test393barEv( +// CHECK: call i8* @_ZN6Test393barEv( +// CHECK-NEXT: ret i8* diff --git a/test/CodeGenObjCXX/block-in-template-inst.mm b/test/CodeGenObjCXX/block-in-template-inst.mm index 93a0e4907d29..c280874dbb3f 100644 --- a/test/CodeGenObjCXX/block-in-template-inst.mm +++ b/test/CodeGenObjCXX/block-in-template-inst.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm-only -std=c++11 -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s +// RUN: %clang_cc1 -emit-llvm-only -std=c++11 -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s // rdar://9362021 @class DYFuture; diff --git a/test/CodeGenObjCXX/block-var-layout.mm b/test/CodeGenObjCXX/block-var-layout.mm index a8f8be0ea8a3..00dd2c00ef57 100644 --- a/test/CodeGenObjCXX/block-var-layout.mm +++ b/test/CodeGenObjCXX/block-var-layout.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-fragile-abi -emit-llvm %s -o %t-64.ll +// RUN: %clang_cc1 -x objective-c++ -fblocks -fobjc-gc -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 -emit-llvm %s -o %t-64.ll // RUN: FileCheck -check-prefix LP64 --input-file=%t-64.ll %s // See commentary in test/CodeGenObjC/block-var-layout.m, from which diff --git a/test/CodeGenObjCXX/blocks.mm b/test/CodeGenObjCXX/blocks.mm index 126931d51fad..62ae428e5ec1 100644 --- a/test/CodeGenObjCXX/blocks.mm +++ b/test/CodeGenObjCXX/blocks.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin -fobjc-fragile-abi %s -verify -emit-llvm -o %t +// RUN: %clang_cc1 -x objective-c++ -fblocks -triple x86_64-apple-darwin -fobjc-runtime=macosx-fragile-10.5 %s -verify -std=c++11 -emit-llvm -o %t // rdar://8979379 @interface A @@ -30,7 +30,7 @@ void foo(id <NSObject>(^objectCreationBlock)(void)) { // Test4 struct S { - S *(^a)() = ^{ // expected-warning {{C++11}} + S *(^a)() = ^{ return this; }; }; @@ -40,7 +40,22 @@ S s; struct X { void f() { ^ { - struct Nested { Nested *ptr = this; }; // expected-warning {{C++11}} + struct Nested { Nested *ptr = this; }; } (); }; }; + +// Regression test for PR13314 +class FooClass { }; +void fun() { + FooClass foovar; + ^() { // expected-warning {{expression result unused}} + return foovar; + }; +} +void gun() { + FooClass foovar; + [=]() { // expected-warning {{expression result unused}} + return foovar; + }; +} diff --git a/test/CodeGenObjCXX/catch-id-type.mm b/test/CodeGenObjCXX/catch-id-type.mm index a5fa3e78fb59..2d6cccc0f129 100644 --- a/test/CodeGenObjCXX/catch-id-type.mm +++ b/test/CodeGenObjCXX/catch-id-type.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-macosx10.6.6 -fobjc-fragile-abi -emit-llvm -fobjc-exceptions -fcxx-exceptions -fexceptions -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple i386-apple-macosx10.6.6 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -fobjc-exceptions -fcxx-exceptions -fexceptions -o - %s | FileCheck %s // rdar://8940528 @interface ns_array diff --git a/test/CodeGenObjCXX/copy.mm b/test/CodeGenObjCXX/copy.mm index 9382ee870a71..9e41bf026a76 100644 --- a/test/CodeGenObjCXX/copy.mm +++ b/test/CodeGenObjCXX/copy.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar://problem/9158302 // This should not use a memmove_collectable in non-GC mode. diff --git a/test/CodeGenObjCXX/copyable-property-object.mm b/test/CodeGenObjCXX/copyable-property-object.mm index 03c0c06a41ee..b2ca85c4ca92 100644 --- a/test/CodeGenObjCXX/copyable-property-object.mm +++ b/test/CodeGenObjCXX/copyable-property-object.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s struct POD { int array[3][4]; diff --git a/test/CodeGenObjCXX/encode.mm b/test/CodeGenObjCXX/encode.mm index 8391c04b7da8..1b6a241fcffa 100644 --- a/test/CodeGenObjCXX/encode.mm +++ b/test/CodeGenObjCXX/encode.mm @@ -87,8 +87,8 @@ namespace rdar9357400 { typedef vector< float, fixed<4> > vector4f; - // CHECK: @_ZN11rdar9357400L2ggE = internal constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00" - const char gg[] = @encode(vector4f); + // CHECK: @_ZN11rdar93574002ggE = constant [49 x i8] c"{vector<float, rdar9357400::fixed<4, -1> >=[4f]}\00" + extern const char gg[] = @encode(vector4f); } // rdar://9624314 @@ -97,12 +97,12 @@ namespace rdar9624314 { struct B3 {}; struct S : B2, B3 {}; - // CHECK: @_ZN11rdar9624314L2ggE = internal constant [6 x i8] c"{S=i}\00" - const char gg[] = @encode(S); + // CHECK: @_ZN11rdar96243142ggE = constant [6 x i8] c"{S=i}\00" + extern const char gg[] = @encode(S); struct S2 { unsigned : 0; int x; unsigned : 0; }; - // CHECK: @_ZN11rdar9624314L2g2E = internal constant [11 x i8] c"{S2=b0ib0}\00" - const char g2[] = @encode(S2); + // CHECK: @_ZN11rdar96243142g2E = constant [11 x i8] c"{S2=b0ib0}\00" + extern const char g2[] = @encode(S2); } namespace test { @@ -122,8 +122,8 @@ namespace test { int y; }; - // CHECK: @_ZN4testL3ecdE = internal constant [15 x i8] c"{Zoo=^^?ii^^?}\00" - const char ecd[] = @encode(Zoo); + // CHECK: @_ZN4test3ecdE = constant [15 x i8] c"{Zoo=^^?ii^^?}\00" + extern const char ecd[] = @encode(Zoo); } struct Base1 { @@ -143,17 +143,17 @@ struct Sub2 : public Sub_with_virt, public Base1, virtual DBase { float x; }; -// CHECK: @_ZL2g1 = internal constant [10 x i8] c"{Base1=c}\00" -const char g1[] = @encode(Base1); +// CHECK: @g1 = constant [10 x i8] c"{Base1=c}\00" +extern const char g1[] = @encode(Base1); -// CHECK: @_ZL2g2 = internal constant [14 x i8] c"{DBase=^^?cd}\00" -const char g2[] = @encode(DBase); +// CHECK: @g2 = constant [14 x i8] c"{DBase=^^?cd}\00" +extern const char g2[] = @encode(DBase); -// CHECK: @_ZL2g3 = internal constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00" -const char g3[] = @encode(Sub_with_virt); +// CHECK: @g3 = constant [26 x i8] c"{Sub_with_virt=^^?q^^?cd}\00" +extern const char g3[] = @encode(Sub_with_virt); -// CHECK: @_ZL2g4 = internal constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00" -const char g4[] = @encode(Sub2); +// CHECK: @g4 = constant [19 x i8] c"{Sub2=^^?qcf^^?cd}\00" +extern const char g4[] = @encode(Sub2); // http://llvm.org/PR9927 class allocator { @@ -165,8 +165,8 @@ char* _M_p; _Alloc_hider _M_dataplus; }; -// CHECK: @_ZL2g5 = internal constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00" -const char g5[] = @encode(basic_string); +// CHECK: @g5 = constant [32 x i8] c"{basic_string={_Alloc_hider=*}}\00" +extern const char g5[] = @encode(basic_string); // PR10990 @@ -175,8 +175,8 @@ class CefBase { }; class CefBrowser : public virtual CefBase {}; class CefBrowserImpl : public CefBrowser {}; -// CHECK: @_ZL2g6 = internal constant [21 x i8] c"{CefBrowserImpl=^^?}\00" -const char g6[] = @encode(CefBrowserImpl); +// CHECK: @g6 = constant [21 x i8] c"{CefBrowserImpl=^^?}\00" +extern const char g6[] = @encode(CefBrowserImpl); // PR10990_2 class CefBase2 { @@ -185,5 +185,19 @@ class CefBase2 { }; class CefBrowser2 : public virtual CefBase2 {}; class CefBrowserImpl2 : public CefBrowser2 {}; -// CHECK: @_ZL2g7 = internal constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00" -const char g7[] = @encode(CefBrowserImpl2); +// CHECK: @g7 = constant [26 x i8] c"{CefBrowserImpl2=^^?^^?i}\00" +extern const char g7[] = @encode(CefBrowserImpl2); + +// <rdar://problem/11324167> +struct Empty {}; + +struct X : Empty { + int array[10]; +}; + +struct Y : Empty { + X vec; +}; + +// CHECK: @g8 = constant [14 x i8] c"{Y={X=[10i]}}\00" +extern const char g8[] = @encode(Y); diff --git a/test/CodeGenObjCXX/gc.mm b/test/CodeGenObjCXX/gc.mm index 1e9fe00fd060..a504892bcbdf 100644 --- a/test/CodeGenObjCXX/gc.mm +++ b/test/CodeGenObjCXX/gc.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s namespace test0 { extern id x; diff --git a/test/CodeGenObjCXX/implicit-copy-assign-operator.mm b/test/CodeGenObjCXX/implicit-copy-assign-operator.mm index 0a6e08e2ff62..29ec9acd381d 100644 --- a/test/CodeGenObjCXX/implicit-copy-assign-operator.mm +++ b/test/CodeGenObjCXX/implicit-copy-assign-operator.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -emit-llvm -triple x86_64-apple-darwin10.0.0 -fobjc-fragile-abi -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -emit-llvm -triple x86_64-apple-darwin10.0.0 -fobjc-runtime=macosx-fragile-10.5 -o - %s | FileCheck %s struct A { A &operator=(const A&); A &operator=(A&); diff --git a/test/CodeGenObjCXX/implicit-copy-constructor.mm b/test/CodeGenObjCXX/implicit-copy-constructor.mm index 63dd4f084cd8..5cd6f42a6c42 100644 --- a/test/CodeGenObjCXX/implicit-copy-constructor.mm +++ b/test/CodeGenObjCXX/implicit-copy-constructor.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s struct A { A(); diff --git a/test/CodeGenObjCXX/lambda-expressions.mm b/test/CodeGenObjCXX/lambda-expressions.mm index 858cb74aa2a5..ec3eb1fda50b 100644 --- a/test/CodeGenObjCXX/lambda-expressions.mm +++ b/test/CodeGenObjCXX/lambda-expressions.mm @@ -9,7 +9,7 @@ fp f() { auto x = []{ return 3; }; return x; } // MRC: define i32 ()* @_Z1fv( // MRC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv" // MRC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*) -// MRC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke_0" to i8*) +// MRC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke" to i8*) // MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*) // MRC: call i32 ()* (i8*, i8*)* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i32 ()* (i8*, i8*)*) // MRC: ret i32 ()* @@ -17,7 +17,7 @@ fp f() { auto x = []{ return 3; }; return x; } // ARC: define i32 ()* @_Z1fv( // ARC: define internal i32 ()* @"_ZZ1fvENK3$_0cvU13block_pointerFivEEv" // ARC: store i8* bitcast (i8** @_NSConcreteStackBlock to i8*) -// ARC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke_0" to i8*) +// ARC: store i8* bitcast (i32 (i8*)* @"___ZZ1fvENK3$_0cvU13block_pointerFivEEv_block_invoke" to i8*) // ARC: call i8* @objc_retainBlock // ARC: call i8* @objc_autoreleaseReturnValue @@ -26,14 +26,14 @@ fp global; void f2() { global = []{ return 3; }; } // MRC: define void @_Z2f2v() nounwind { -// MRC: store i8* bitcast (i32 (i8*)* @__f2_block_invoke_0 to i8*), +// MRC: store i8* bitcast (i32 (i8*)* @___Z2f2v_block_invoke to i8*), // MRC-NOT: call // MRC: ret void // ("global" contains a dangling pointer after this function runs.) // ARC: define void @_Z2f2v() nounwind { -// ARC: store i8* bitcast (i32 (i8*)* @__f2_block_invoke_0 to i8*), +// ARC: store i8* bitcast (i32 (i8*)* @___Z2f2v_block_invoke to i8*), // ARC: call i8* @objc_retainBlock // ARC: call void @objc_release -// ARC: define internal i32 @__f2_block_invoke_0 +// ARC: define internal i32 @___Z2f2v_block_invoke // ARC: call i32 @"_ZZ2f2vENK3$_1clEv diff --git a/test/CodeGenObjCXX/mangle-blocks.mm b/test/CodeGenObjCXX/mangle-blocks.mm index fcbc60860884..892c8afedebf 100644 --- a/test/CodeGenObjCXX/mangle-blocks.mm +++ b/test/CodeGenObjCXX/mangle-blocks.mm @@ -1,19 +1,19 @@ -// RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-fragile-abi %s | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -fblocks -o - -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 %s | FileCheck %s -// CHECK: @_ZGVN3foo20__foo_block_invoke_05valueE = internal global i64 0 +// CHECK: @_ZGVN3foo22___Z3foov_block_invoke5valueE = internal global i64 0 int f(); void foo() { - // CHECK: define internal i32 @__foo_block_invoke_0 - // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVN3foo20__foo_block_invoke_05value + // CHECK: define internal i32 @___Z3foov_block_invoke + // CHECK: call i32 @__cxa_guard_acquire(i64* @_ZGVN3foo22___Z3foov_block_invoke5valueE (void)^(int x) { static int value = f(); return x + value; }; } -// CHECK: define internal i32 @__block_global_0 +// CHECK: define internal i32 @i_block_invoke int i = ^(int x) { return x;}(i); @interface A @@ -22,9 +22,9 @@ int i = ^(int x) { return x;}(i); @implementation A - (void)method { - // CHECK: define internal signext i8 @"__11-[A method]_block_invoke_0" + // CHECK: define internal signext i8 @"__11-[A method]_block_invoke" (void)^(int x) { - // CHECK: @"_ZN11-[A method]30__11-[A method]_block_invoke_04nameE" + // CHECK: @"_ZN11-[A method]28__11-[A method]_block_invoke4nameE" static const char *name = "hello"; return name[x]; }; @@ -39,10 +39,10 @@ void foo(int) { } namespace N { - // CHECK: define internal signext i8 @__bar_block_invoke_0 + // CHECK: define internal signext i8 @___Z3fooi_block_invoke void bar() { (void)^(int x) { - // CHECK: @_ZN1N3bar20__bar_block_invoke_04nameE + // CHECK: @_ZN1N3bar26___ZN1N3barEv_block_invoke4nameE static const char *name = "hello"; return name[x]; }; diff --git a/test/CodeGenObjCXX/message-reference.mm b/test/CodeGenObjCXX/message-reference.mm index fa41fef4c909..0d1bbc7bb0d4 100644 --- a/test/CodeGenObjCXX/message-reference.mm +++ b/test/CodeGenObjCXX/message-reference.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar://8604515 @interface I {} diff --git a/test/CodeGenObjCXX/nrvo.mm b/test/CodeGenObjCXX/nrvo.mm index ef5052eea603..47460c2fb3db 100644 --- a/test/CodeGenObjCXX/nrvo.mm +++ b/test/CodeGenObjCXX/nrvo.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -emit-llvm -o - -fblocks %s -O1 -triple x86_64-apple-darwin10.0.0 -fobjc-fragile-abi | FileCheck %s +// RUN: %clang_cc1 -emit-llvm -o - -fblocks %s -O1 -triple x86_64-apple-darwin10.0.0 -fobjc-runtime=macosx-fragile-10.5 | FileCheck %s // PR10835 / <rdar://problem/10050178> struct X { @@ -22,7 +22,7 @@ struct X { X blocksNRVO() { return ^{ - // CHECK: define internal void @__blocksNRVO_block_invoke_0 + // CHECK: define internal void @___Z10blocksNRVOv_block_invoke X x; // CHECK: tail call void @_ZN1XC1Ev // CHECK-NEXT: ret void diff --git a/test/CodeGenObjCXX/property-derived-to-base-conv.mm b/test/CodeGenObjCXX/property-derived-to-base-conv.mm index ddca857fbab0..5784f2be9cec 100644 --- a/test/CodeGenObjCXX/property-derived-to-base-conv.mm +++ b/test/CodeGenObjCXX/property-derived-to-base-conv.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s // rdar: // 7501812 struct A { diff --git a/test/CodeGenObjCXX/property-object-conditional-exp.mm b/test/CodeGenObjCXX/property-object-conditional-exp.mm index 281076e47f4d..899c2c80baee 100644 --- a/test/CodeGenObjCXX/property-object-conditional-exp.mm +++ b/test/CodeGenObjCXX/property-object-conditional-exp.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s struct CGRect { char* origin; diff --git a/test/CodeGenObjCXX/property-object-reference-2.mm b/test/CodeGenObjCXX/property-object-reference-2.mm index b150a3e3ea97..2a380385bc9d 100644 --- a/test/CodeGenObjCXX/property-object-reference-2.mm +++ b/test/CodeGenObjCXX/property-object-reference-2.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-10.7 -emit-llvm -o - | FileCheck %s // rdar://6137845 extern int DEFAULT(); diff --git a/test/CodeGenObjCXX/property-object-reference.mm b/test/CodeGenObjCXX/property-object-reference.mm index 0bd8fb8b9ff2..ec311f1956a4 100644 --- a/test/CodeGenObjCXX/property-object-reference.mm +++ b/test/CodeGenObjCXX/property-object-reference.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - | FileCheck %s // rdar://10188258 struct Foo {int i;}; diff --git a/test/CodeGenObjCXX/property-reference.mm b/test/CodeGenObjCXX/property-reference.mm index 4897f6d0e8f4..0e4897b74947 100644 --- a/test/CodeGenObjCXX/property-reference.mm +++ b/test/CodeGenObjCXX/property-reference.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - | FileCheck %s // rdar://9208606 struct MyStruct { diff --git a/test/CodeGenObjCXX/refence-assign-write-barrier.mm b/test/CodeGenObjCXX/refence-assign-write-barrier.mm index 206ecb0c29e3..ad277ef6d596 100644 --- a/test/CodeGenObjCXX/refence-assign-write-barrier.mm +++ b/test/CodeGenObjCXX/refence-assign-write-barrier.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar://8681766 @interface NSArray diff --git a/test/CodeGenObjCXX/selector-expr-lvalue.mm b/test/CodeGenObjCXX/selector-expr-lvalue.mm index 3e3bf4ecf20e..508ea83f0d51 100644 --- a/test/CodeGenObjCXX/selector-expr-lvalue.mm +++ b/test/CodeGenObjCXX/selector-expr-lvalue.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s // PR7390 @interface NSObject {} diff --git a/test/CodeGenObjCXX/write-barrier-global-assign.mm b/test/CodeGenObjCXX/write-barrier-global-assign.mm index cb563f339565..539e21fcfbee 100644 --- a/test/CodeGenObjCXX/write-barrier-global-assign.mm +++ b/test/CodeGenObjCXX/write-barrier-global-assign.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-fragile-abi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 -emit-llvm -o - %s | FileCheck %s // rdar://8761767 @class CPDestUser; diff --git a/test/CodeGenOpenCL/kernel-arg-info.cl b/test/CodeGenOpenCL/kernel-arg-info.cl new file mode 100644 index 000000000000..9d52736a76d8 --- /dev/null +++ b/test/CodeGenOpenCL/kernel-arg-info.cl @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 %s -cl-kernel-arg-info -emit-llvm -o - | FileCheck %s + +kernel void foo(int *X, int Y, int anotherArg) { + *X = Y + anotherArg; +} + +// CHECK: metadata !{metadata !"kernel_arg_name", metadata !"X", metadata !"Y", metadata !"anotherArg"} diff --git a/test/CodeGenOpenCL/kernel-attributes.cl b/test/CodeGenOpenCL/kernel-attributes.cl new file mode 100644 index 000000000000..de16a4145315 --- /dev/null +++ b/test/CodeGenOpenCL/kernel-attributes.cl @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -emit-llvm -O0 -o - %s | FileCheck %s + +kernel __attribute__((reqd_work_group_size(1,2,4))) void kernel1(int a) {} + +kernel __attribute__((work_group_size_hint(8,16,32))) void kernel2(int a) {} + +// CHECK: opencl.kernels = !{[[MDNODE0:![0-9]+]], [[MDNODE3:![0-9]+]]} + +// CHECK: [[MDNODE0]] = metadata !{void (i32)* @kernel1, metadata [[MDNODE2:![0-9]+]]} +// CHECK: [[MDNODE2]] = metadata !{metadata !"reqd_work_group_size", i32 1, i32 2, i32 4} +// CHECK: [[MDNODE3]] = metadata !{void (i32)* @kernel2, metadata [[MDNODE5:![0-9]+]]} +// CHECK: [[MDNODE5]] = metadata !{metadata !"work_group_size_hint", i32 8, i32 16, i32 32} diff --git a/test/CodeGenOpenCL/ptx-calls.cl b/test/CodeGenOpenCL/ptx-calls.cl index 6f336405c301..34a21c6c1da9 100644 --- a/test/CodeGenOpenCL/ptx-calls.cl +++ b/test/CodeGenOpenCL/ptx-calls.cl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple ptx32-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s void device_function() { } diff --git a/test/CodeGenOpenCL/ptx-kernels.cl b/test/CodeGenOpenCL/ptx-kernels.cl index 4d6fa1084d4b..1d7e497b7c01 100644 --- a/test/CodeGenOpenCL/ptx-kernels.cl +++ b/test/CodeGenOpenCL/ptx-kernels.cl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -triple ptx32-unknown-unknown -emit-llvm -o - | FileCheck %s +// RUN: %clang_cc1 %s -triple nvptx-unknown-unknown -emit-llvm -o - | FileCheck %s void device_function() { } diff --git a/test/Coverage/codegen-gnu.m b/test/Coverage/codegen-gnu.m index 432637c7e1ac..67f99064a6ab 100644 --- a/test/Coverage/codegen-gnu.m +++ b/test/Coverage/codegen-gnu.m @@ -1,3 +1,3 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-exceptions -fgnu-runtime -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-exceptions -fobjc-runtime=gcc -emit-llvm -o %t %s #include "objc-language-features.inc" diff --git a/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_dynamic.o b/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_dynamic.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_dynamic.o diff --git a/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_so.o b/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_so.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_so.o diff --git a/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_static.o b/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_static.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/basic_android_tree/usr/lib/crtbegin_static.o diff --git a/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_android.o b/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_android.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_android.o diff --git a/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_so.o b/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_so.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/basic_android_tree/usr/lib/crtend_so.o diff --git a/test/Driver/Inputs/debian_multiarch_tree/lib/mips-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/lib/mips-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/lib/mips-linux-gnu/.keep diff --git a/test/Driver/Inputs/debian_multiarch_tree/lib/mipsel-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/lib/mipsel-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/lib/mipsel-linux-gnu/.keep diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mips-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mips-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mips-linux-gnu/.keep diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mipsel-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mipsel-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/c++/4.5/mipsel-linux-gnu/.keep diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/mips-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/mips-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/mips-linux-gnu/.keep diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/include/mipsel-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/include/mipsel-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/include/mipsel-linux-gnu/.keep diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/64/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/64/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/64/crtbegin.o diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/crtbegin.o diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/n32/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/n32/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mips-linux-gnu/4.5/n32/crtbegin.o diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/64/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/64/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/64/crtbegin.o diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/crtbegin.o diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/n32/crtbegin.o b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/n32/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/gcc/mipsel-linux-gnu/4.5/n32/crtbegin.o diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/mips-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/mips-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/mips-linux-gnu/.keep diff --git a/test/Driver/Inputs/debian_multiarch_tree/usr/lib/mipsel-linux-gnu/.keep b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/mipsel-linux-gnu/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/debian_multiarch_tree/usr/lib/mipsel-linux-gnu/.keep diff --git a/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/crtbegin.o b/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/crtbegin.o new file mode 100644 index 000000000000..26d251da3967 --- /dev/null +++ b/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/crtbegin.o @@ -0,0 +1 @@ +dummy file for gcc toolchain detection (crtbegin.o) diff --git a/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/libgcc.a b/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/libgcc.a new file mode 100644 index 000000000000..d7969288d9b2 --- /dev/null +++ b/test/Driver/Inputs/montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/libgcc.a @@ -0,0 +1 @@ +dummy file for gcc toolchain detection (libgcc.a) diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/.keep diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabi/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabi/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabi/.keep diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabihf/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabihf/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/arm-linux-gnueabihf/.keep diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/.keep diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabi/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabi/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabi/.keep diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabihf/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabihf/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/arm-linux-gnueabihf/.keep diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/.keep diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crt1.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crt1.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crt1.o diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crti.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crti.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crti.o diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crtn.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crtn.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crtn.o diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crt1.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crt1.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crt1.o diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crti.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crti.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crti.o diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crtn.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crtn.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crtn.o diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o diff --git a/test/Driver/altivec.cpp b/test/Driver/altivec.cpp index 6059ad09e7c5..a8936360a3db 100644 --- a/test/Driver/altivec.cpp +++ b/test/Driver/altivec.cpp @@ -1,7 +1,8 @@ // Check that we error when -faltivec is specified on non-ppc platforms. -// RUN: %clang -ccc-clang-archs powerpc -target powerpc-apple-darwin -faltivec -fsyntax-only %s +// RUN: %clang -ccc-clang-archs powerpc -target powerpc-unk-unk -faltivec -fsyntax-only %s // RUN: %clang -ccc-clang-archs powerpc64 -target powerpc64-linux-gnu -faltivec -fsyntax-only %s +// RUN: %clang -ccc-clang-archs powerpc64 -target powerpc64-linux-gnu -maltivec -fsyntax-only %s // RUN: %clang -target i386-pc-win32 -faltivec -fsyntax-only %s 2>&1 | FileCheck %s // RUN: %clang -target x86_64-unknown-freebsd -faltivec -fsyntax-only %s 2>&1 | FileCheck %s diff --git a/test/Driver/apple-kext-i386.cpp b/test/Driver/apple-kext-i386.cpp index c11a1361a1a3..eb9f9578e9cb 100644 --- a/test/Driver/apple-kext-i386.cpp +++ b/test/Driver/apple-kext-i386.cpp @@ -41,6 +41,11 @@ // CHECK-UNSUPPORTED2: cc1plus" // CHECK-UNSUPPORTED2-NOT: "-Wconstant-logical-operand" +// Check that -serialize-diagnostics does not cause an "argument unused" error. +// RUN: %clang -target i386-apple-darwin10 \ +// RUN: -Wall -fapple-kext -### -serialize-diagnostics %t.dia -c %s 2>&1 | \ +// RUN: FileCheck --check-prefix=CHECK-UNUSED %s + // Check that --serialize-diagnostics does not cause an "argument unused" error. // RUN: %clang -target i386-apple-darwin10 \ // RUN: -Wall -fapple-kext -### --serialize-diagnostics %t.dia -c %s 2>&1 | \ diff --git a/test/Driver/arc.c b/test/Driver/arc.c index f2c1127116a0..5a5720c04aee 100644 --- a/test/Driver/arc.c +++ b/test/Driver/arc.c @@ -8,10 +8,10 @@ // Just to test clang is working. # foo -// CHECK: error: -fobjc-arc is not supported with fragile abi +// CHECK: error: -fobjc-arc is not supported with legacy abi // CHECK-NOT: invalid preprocessing directive -// NOTOBJC-NOT: error: -fobjc-arc is not supported with fragile abi +// NOTOBJC-NOT: error: -fobjc-arc is not supported with legacy abi // NOTOBJC: invalid preprocessing directive // UNSUPPORTED: error: -fobjc-arc is not supported on current deployment target diff --git a/test/Driver/arclite-link.c b/test/Driver/arclite-link.c index 9cf1efe987ca..3471bf6516a2 100644 --- a/test/Driver/arclite-link.c +++ b/test/Driver/arclite-link.c @@ -1,8 +1,17 @@ // RUN: touch %t.o -// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s +// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -lfoo -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-ARCLITE-OSX %s // RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.8 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s // RUN: %clang -### -target i386-apple-darwin10 -fobjc-link-runtime -mmacosx-version-min=10.7 %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOARCLITE %s +// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -nostdlib %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOSTDLIB %s +// CHECK-ARCLITE-OSX: -lfoo // CHECK-ARCLITE-OSX: libarclite_macosx.a +// CHECK-ARCLITE-OSX: -framework +// CHECK-ARCLITE-OSX: Foundation // CHECK-ARCLITE-OSX: -lobjc // CHECK-NOARCLITE-NOT: libarclite +// CHECK-NOSTDLIB-NOT: -lobjc + +// RUN: %clang -### -target x86_64-apple-darwin10 -fobjc-link-runtime -fobjc-arc -mmacosx-version-min=10.7 %s 2>&1 | FileCheck -check-prefix=CHECK-UNUSED %s + +// CHECK-UNUSED-NOT: warning: argument unused during compilation: '-fobjc-link-runtime' diff --git a/test/Driver/asan-ld.c b/test/Driver/asan-ld.c new file mode 100644 index 000000000000..daf046b53716 --- /dev/null +++ b/test/Driver/asan-ld.c @@ -0,0 +1,31 @@ +// Test AddressSanitizer ld flags. + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target i386-unknown-linux -faddress-sanitizer \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-LINUX %s +// CHECK-LINUX: "{{.*}}ld{{(.exe)?}}" +// CHECK-LINUX-NOT: "-lc" +// CHECK-LINUX: libclang_rt.asan-i386.a" +// CHECK-LINUX: "-lpthread" +// CHECK-LINUX: "-ldl" +// CHECK-LINUX: "-export-dynamic" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -faddress-sanitizer \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s +// CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" +// CHECK-ANDROID-NOT: "-lc" +// CHECK-ANDROID: "-u" "__asan_preinit" "-lasan" +// CHECK-ANDROID: "-lasan_preload" "-ldl" + +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi -faddress-sanitizer \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: -shared \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-SHARED %s +// CHECK-ANDROID-SHARED: "{{.*}}ld{{(.exe)?}}" +// CHECK-ANDROID-SHARED-NOT: "-lc" +// CHECK-ANDROID-SHARED-NOT: "-lasan" +// CHECK-ANDROID-SHARED: "-lasan_preload" "-ldl" diff --git a/test/Driver/bounds-checking.c b/test/Driver/bounds-checking.c new file mode 100644 index 000000000000..95bb8afd0d8b --- /dev/null +++ b/test/Driver/bounds-checking.c @@ -0,0 +1,7 @@ +// RUN: %clang -target x86_64-apple-darwin10 -fbounds-checking -### -fsyntax-only %s 2> %t +// RUN: FileCheck < %t %s +// RUN: %clang -target x86_64-apple-darwin10 -fbounds-checking=3 -### -fsyntax-only %s 2> %t +// RUN: FileCheck -check-prefix=CHECK2 < %t %s + +// CHECK: "-fbounds-checking=1" +// CHECK2: "-fbounds-checking=3" diff --git a/test/Driver/ccc-as-cpp.c b/test/Driver/ccc-as-cpp.c new file mode 100644 index 000000000000..feead5191db1 --- /dev/null +++ b/test/Driver/ccc-as-cpp.c @@ -0,0 +1,6 @@ +// REQUIRES: shell +// RUN: ln -sf %clang %T/clang-cpp + +// PR13529: Don't crash. +// RUN: %T/clang-cpp -lfoo -M %s 2>&1 | FileCheck --check-prefix=CHECK-PR13529 %s +// CHECK-PR13529: warning: -lfoo: 'linker' input unused in cpp mode diff --git a/test/Driver/clang-translation.c b/test/Driver/clang-translation.c index 0e82de4af3e4..76196da9fc3d 100644 --- a/test/Driver/clang-translation.c +++ b/test/Driver/clang-translation.c @@ -44,3 +44,33 @@ // ARMV7_HARDFLOAT: "-mfloat-abi" "hard" // ARMV7_HARDFLOAT-NOT: "-msoft-float" // ARMV7_HARDFLOAT: "-x" "c" + +// RUN: %clang -target arm-linux -### -S %s 2> %t.log \ +// RUN: -march=armv5e +// RUN: FileCheck -check-prefix=ARMV5E %s < %t.log +// ARMV5E: clang +// ARMV5E: "-cc1" +// ARMV5E: "-target-cpu" "arm1022e" + +// RUN: %clang -ccc-clang-archs powerpc64 \ +// RUN: -target powerpc64-unknown-linux-gnu -### -S %s 2> %t.log \ +// RUN: -mcpu=G5 +// RUN: FileCheck -check-prefix=PPCG5 %s < %t.log +// PPCG5: clang +// PPCG5: "-cc1" +// PPCG5: "-target-cpu" "g5" + +// RUN: %clang -ccc-clang-archs powerpc64 \ +// RUN: -target powerpc64-unknown-linux-gnu -### -S %s 2> %t.log \ +// RUN: -mcpu=power7 +// RUN: FileCheck -check-prefix=PPCPWR7 %s < %t.log +// PPCPWR7: clang +// PPCPWR7: "-cc1" +// PPCPWR7: "-target-cpu" "pwr7" + +// RUN: %clang -ccc-clang-archs powerpc64 \ +// RUN: -target powerpc64-unknown-linux-gnu -### -S %s 2> %t.log +// RUN: FileCheck -check-prefix=PPC64NS %s < %t.log +// PPC64NS: clang +// PPC64NS: "-cc1" +// PPC64NS: "-target-cpu" "ppc64" diff --git a/test/Driver/clang_f_opts.c b/test/Driver/clang_f_opts.c index 4eed4aa06f3f..0ee7d2dabe70 100644 --- a/test/Driver/clang_f_opts.c +++ b/test/Driver/clang_f_opts.c @@ -29,3 +29,12 @@ // RUN: %clang -### -c -Wdeprecated %s 2>&1 | FileCheck -check-prefix=DEPRECATED-OFF-CHECK %s // DEPRECATED-ON-CHECK: -fdeprecated-macro // DEPRECATED-OFF-CHECK-NOT: -fdeprecated-macro + +// RUN: %clang -### -S -ffp-contract=fast %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s +// RUN: %clang -### -S -ffast-math %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-FAST-CHECK %s +// RUN: %clang -### -S -ffp-contract=off %s 2>&1 | FileCheck -check-prefix=FP-CONTRACT-OFF-CHECK %s +// FP-CONTRACT-FAST-CHECK: -ffp-contract=fast +// FP-CONTRACT-OFF-CHECK: -ffp-contract=off + +// RUN: %clang -fms-extensions -fenable-experimental-ms-inline-asm %s -### 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS3 %s +// CHECK-OPTIONS3: -fenable-experimental-ms-inline-asm diff --git a/test/Driver/clang_f_opts.h b/test/Driver/clang_f_opts.h new file mode 100644 index 000000000000..e48d0cfc7c13 --- /dev/null +++ b/test/Driver/clang_f_opts.h @@ -0,0 +1,2 @@ +// RUN: %clang -### -fsyntax-only %s 2>&1 | FileCheck %s +// CHECK: -fsyntax-only diff --git a/test/Driver/constructors.c b/test/Driver/constructors.c new file mode 100644 index 000000000000..ca2cac22934e --- /dev/null +++ b/test/Driver/constructors.c @@ -0,0 +1,14 @@ +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ +// RUN: -target i386-unknown-linux \ +// RUN: --sysroot=%S/Inputs/fake_install_tree \ +// RUN: | FileCheck --check-prefix=CHECK-GCC-4-7 %s + +// CHECK-GCC-4-7: -fuse-init-array + +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \ +// RUN: -target i386-unknown-linux \ +// RUN: --sysroot=%S/Inputs/basic_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-GCC-4-6 %s + + +// CHECK-GCC-4-6-NOT: -fuse-init-array diff --git a/test/Driver/crash-report.c b/test/Driver/crash-report.c new file mode 100644 index 000000000000..7adaf42a2c95 --- /dev/null +++ b/test/Driver/crash-report.c @@ -0,0 +1,27 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: env TMPDIR=%t TEMP=%t TMP=%t %clang -fsyntax-only %s \ +// RUN: -F/tmp/ -I /tmp/ -idirafter /tmp/ -iquote /tmp/ -isystem /tmp/ \ +// RUN: -iprefix /the/prefix -iwithprefix /tmp -iwithprefixbefore /tmp/ \ +// RUN: -internal-isystem /tmp/ -internal-externc-isystem /tmp/ \ +// RUN: -DFOO=BAR 2>&1 | FileCheck %s +// RUN: cat %t/crash-report-*.c | FileCheck --check-prefix=CHECKSRC %s +// RUN: cat %t/crash-report-*.sh | FileCheck --check-prefix=CHECKSH %s +// REQUIRES: crash-recovery + +#pragma clang __debug parser_crash +// CHECK: Preprocessed source(s) and associated run script(s) are located at: +// CHECK-NEXT: note: diagnostic msg: {{.*}}.c +FOO +// CHECKSRC: FOO +// CHECKSH: -D "FOO=BAR" +// CHECKSH-NOT: -F/tmp/ +// CHECKSH-NOT: -I /tmp/ +// CHECKSH-NOT: -idirafter /tmp/ +// CHECKSH-NOT: -iquote /tmp/ +// CHECKSH-NOT: -isystem /tmp/ +// CHECKSH-NOT: -iprefix /the/prefix +// CHECKSH-NOT: -iwithprefix /tmp/ +// CHECKSH-NOT: -iwithprefixbefore /tmp/ +// CHECKSH-NOT: -internal-isystem /tmp/ +// CHECKSH-NOT: -internal-externc-isystem /tmp/ diff --git a/test/Driver/darwin-ld.c b/test/Driver/darwin-ld.c index 3206f654d5c0..4cda37f9b2e3 100644 --- a/test/Driver/darwin-ld.c +++ b/test/Driver/darwin-ld.c @@ -121,3 +121,8 @@ // RUN: %clang -target x86_64-apple-darwin12 -### %t.o 2> %t.log // RUN: FileCheck -check-prefix=LINK_NO_CRT1 %s < %t.log // LINK_NO_CRT1-NOT: crt + +// RUN: %clang -target i386-apple-darwin12 -pg -### %t.o 2> %t.log +// RUN: FileCheck -check-prefix=LINK_PG %s < %t.log +// LINK_PG: -lgcrt1.o +// LINK_PG: -no_new_main diff --git a/test/Driver/darwin-objc-defaults.m b/test/Driver/darwin-objc-defaults.m index 49fe8f9b9f7c..6265cfb41f10 100644 --- a/test/Driver/darwin-objc-defaults.m +++ b/test/Driver/darwin-objc-defaults.m @@ -7,7 +7,7 @@ // RUN: FileCheck --check-prefix CHECK-I386_OSX10_5 < %t %s // CHECK-CHECK-I386_OSX10_5: "-cc1" -// CHECK-CHECK-I386_OSX10_5: -fobjc-fragile-abi +// CHECK-CHECK-I386_OSX10_5: -fobjc-runtime=macosx-fragile-10.5 // CHECK-CHECK-I386_OSX10_5-NOT: -fobjc-dispatch-method // CHECK-CHECK-I386_OSX10_5: darwin-objc-defaults @@ -16,7 +16,7 @@ // RUN: FileCheck --check-prefix CHECK-I386_OSX10_6 < %t %s // CHECK-CHECK-I386_OSX10_6: "-cc1" -// CHECK-CHECK-I386_OSX10_6: -fobjc-fragile-abi +// CHECK-CHECK-I386_OSX10_6: -fobjc-runtime=macosx-fragile-10.6 // CHECK-CHECK-I386_OSX10_6-NOT: -fobjc-dispatch-method // CHECK-CHECK-I386_OSX10_6: darwin-objc-defaults @@ -25,7 +25,7 @@ // RUN: FileCheck --check-prefix CHECK-I386_IPHONE3_0 < %t %s // CHECK-CHECK-I386_IPHONE3_0: "-cc1" -// CHECK-CHECK-I386_IPHONE3_0: -fobjc-fragile-abi +// CHECK-CHECK-I386_IPHONE3_0: -fobjc-runtime=ios-3.0 // CHECK-CHECK-I386_IPHONE3_0-NOT: -fobjc-dispatch-method // CHECK-CHECK-I386_IPHONE3_0: darwin-objc-defaults @@ -36,7 +36,7 @@ // RUN: FileCheck --check-prefix CHECK-X86_64_OSX10_5 < %t %s // CHECK-CHECK-X86_64_OSX10_5: "-cc1" -// CHECK-CHECK-X86_64_OSX10_5-NOT: -fobjc-fragile-abi +// CHECK-CHECK-X86_64_OSX10_5: -fobjc-runtime=macosx-10.5 // CHECK-CHECK-X86_64_OSX10_5: -fobjc-dispatch-method=non-legacy // CHECK-CHECK-X86_64_OSX10_5: darwin-objc-defaults @@ -45,7 +45,7 @@ // RUN: FileCheck --check-prefix CHECK-X86_64_OSX10_6 < %t %s // CHECK-CHECK-X86_64_OSX10_6: "-cc1" -// CHECK-CHECK-X86_64_OSX10_6-NOT: -fobjc-fragile-abi +// CHECK-CHECK-X86_64_OSX10_6: -fobjc-runtime=macosx-10.6 // CHECK-CHECK-X86_64_OSX10_6: -fobjc-dispatch-method=mixed // CHECK-CHECK-X86_64_OSX10_6: darwin-objc-defaults @@ -54,7 +54,7 @@ // RUN: FileCheck --check-prefix CHECK-X86_64_IPHONE3_0 < %t %s // CHECK-CHECK-X86_64_IPHONE3_0: "-cc1" -// CHECK-CHECK-X86_64_IPHONE3_0-NOT: -fobjc-fragile-abi +// CHECK-CHECK-X86_64_IPHONE3_0: -fobjc-runtime=ios-3.0 // CHECK-CHECK-X86_64_IPHONE3_0: -fobjc-dispatch-method=mixed // CHECK-CHECK-X86_64_IPHONE3_0: darwin-objc-defaults @@ -65,7 +65,7 @@ // RUN: FileCheck --check-prefix CHECK-ARMV7_OSX10_5 < %t %s // CHECK-CHECK-ARMV7_OSX10_5: "-cc1" -// CHECK-CHECK-ARMV7_OSX10_5-NOT: -fobjc-fragile-abi +// CHECK-CHECK-ARMV7_OSX10_5: -fobjc-runtime=macosx-10.5 // CHECK-CHECK-ARMV7_OSX10_5-NOT: -fobjc-dispatch-method // CHECK-CHECK-ARMV7_OSX10_5: darwin-objc-defaults @@ -74,7 +74,7 @@ // RUN: FileCheck --check-prefix CHECK-ARMV7_OSX10_6 < %t %s // CHECK-CHECK-ARMV7_OSX10_6: "-cc1" -// CHECK-CHECK-ARMV7_OSX10_6-NOT: -fobjc-fragile-abi +// CHECK-CHECK-ARMV7_OSX10_6: -fobjc-runtime=macosx-10.6 // CHECK-CHECK-ARMV7_OSX10_6-NOT: -fobjc-dispatch-method // CHECK-CHECK-ARMV7_OSX10_6: darwin-objc-defaults @@ -83,6 +83,6 @@ // RUN: FileCheck --check-prefix CHECK-ARMV7_IPHONE3_0 < %t %s // CHECK-CHECK-ARMV7_IPHONE3_0: "-cc1" -// CHECK-CHECK-ARMV7_IPHONE3_0-NOT: -fobjc-fragile-abi +// CHECK-CHECK-ARMV7_IPHONE3_0: -fobjc-runtime=ios-3.0 // CHECK-CHECK-ARMV7_IPHONE3_0-NOT: -fobjc-dispatch-method // CHECK-CHECK-ARMV7_IPHONE3_0: darwin-objc-defaults diff --git a/test/Driver/darwin-objc-options.m b/test/Driver/darwin-objc-options.m index 5b421d891ff4..77501ab1b914 100644 --- a/test/Driver/darwin-objc-options.m +++ b/test/Driver/darwin-objc-options.m @@ -5,7 +5,7 @@ // RUN: FileCheck --check-prefix CHECK-X86_64_ABI1 < %t %s // CHECK-CHECK-X86_64_ABI1: "-cc1" -// CHECK-CHECK-X86_64_ABI1: -fobjc-fragile-abi +// CHECK-CHECK-X86_64_ABI1: -fobjc-runtime=macosx-fragile-10.6.0 // CHECK-CHECK-X86_64_ABI1-NOT: -fobjc-dispatch-method // CHECK-CHECK-X86_64_ABI1: darwin-objc-options @@ -14,8 +14,19 @@ // RUN: FileCheck --check-prefix CHECK-I386_ABI2 < %t %s // CHECK-CHECK-I386_ABI2: "-cc1" -// CHECK-CHECK-I386_ABI2-NOT: -fobjc-fragile-abi +// CHECK-CHECK-I386_ABI2: -fobjc-runtime=macosx-10.6.0 // CHECK-CHECK-I386_ABI2: -fobjc-exceptions // CHECK-CHECK-I386_ABI2: -fexceptions // CHECK-CHECK-I386_ABI2-NOT: -fobjc-dispatch-method // CHECK-CHECK-I386_ABI2: darwin-objc-options + +// RUN: %clang -target x86_64-apple-darwin10 -S -### %s \ +// RUN: -arch i386 -fobjc-runtime=ios-5.0 2> %t +// RUN: FileCheck --check-prefix CHECK-I386_IOS < %t %s + +// CHECK-CHECK-I386_IOS: "-cc1" +// CHECK-CHECK-I386_IOS: -fobjc-runtime=ios-5.0 +// CHECK-CHECK-I386_IOS: -fobjc-exceptions +// CHECK-CHECK-I386_IOS: -fexceptions +// CHECK-CHECK-I386_IOS-NOT: -fobjc-dispatch-method +// CHECK-CHECK-I386_IOS: darwin-objc-options diff --git a/test/Driver/debug-options-as.c b/test/Driver/debug-options-as.c index a1dbe2e048df..57036e42db07 100644 --- a/test/Driver/debug-options-as.c +++ b/test/Driver/debug-options-as.c @@ -4,7 +4,8 @@ // Check to make sure clang is somewhat picky about -g options. // (Delived from debug-options.c) // rdar://10383444 -// RUN: %clang -### -c -save-temps -g %s 2>&1 | FileCheck -check-prefix=SAVE %s +// RUN: %clang -### -c -save-temps -integrated-as -g %s 2>&1 \ +// RUN: | FileCheck -check-prefix=SAVE %s // // SAVE: "-cc1as" // SAVE-NOT: "-g" @@ -12,7 +13,8 @@ // Check to make sure clang with -g on a .s file gets passed. // rdar://9275556 // RUN: touch %t.s -// RUN: %clang -### -c -g %t.s 2>&1 | FileCheck -check-prefix=S %s +// RUN: %clang -### -c -integrated-as -g %t.s 2>&1 \ +// RUN: | FileCheck -check-prefix=S %s // // S: "-cc1as" // S: "-g" diff --git a/test/Driver/debug-options.c b/test/Driver/debug-options.c index 5dad8e938249..ca77abf9fd30 100644 --- a/test/Driver/debug-options.c +++ b/test/Driver/debug-options.c @@ -2,26 +2,43 @@ // rdar://10383444 // RUN: %clang -### -c -g %s 2>&1 | FileCheck -check-prefix=G %s -// RUN: %clang -### -c -g2 %s 2>&1 | FileCheck -check-prefix=G2 %s -// RUN: %clang -### -c -g3 %s 2>&1 | FileCheck -check-prefix=G3 %s -// RUN: %clang -### -c -ganything %s 2>&1 | FileCheck -check-prefix=GANY %s -// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=GGDB %s -// RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=GFOO %s +// RUN: %clang -### -c -g2 %s 2>&1 | FileCheck -check-prefix=G %s +// RUN: %clang -### -c -g3 %s 2>&1 | FileCheck -check-prefix=G %s +// RUN: %clang -### -c -ggdb %s 2>&1 | FileCheck -check-prefix=G %s +// RUN: %clang -### -c -ggdb1 %s 2>&1 | FileCheck -check-prefix=G %s +// RUN: %clang -### -c -ggdb3 %s 2>&1 | FileCheck -check-prefix=G %s +// RUN: %clang -### -c -gdwarf-2 %s 2>&1 | FileCheck -check-prefix=G %s +// +// RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=G_NO %s +// RUN: %clang -### -c -g -g0 %s 2>&1 | FileCheck -check-prefix=G_NO %s +// RUN: %clang -### -c -ggdb0 %s 2>&1 | FileCheck -check-prefix=G_NO %s +// +// RUN: %clang -### -c -gline-tables-only %s 2>&1 \ +// RUN: | FileCheck -check-prefix=GLTO_ONLY %s +// RUN: %clang -### -c -gline-tables-only -g %s 2>&1 \ +// RUN: | FileCheck -check-prefix=G_ONLY %s +// RUN: %clang -### -c -gline-tables-only -g0 %s 2>&1 \ +// RUN: | FileCheck -check-prefix=GLTO_NO %s +// +// RUN: %clang -### -c -grecord-gcc-switches -gno-record-gcc-switches \ +// RUN: -gstrict-dwarf -gno-strict-dwarf %s 2>&1 \ +// RUN: | not grep "argument unused during compilation" // // G: "-cc1" // G: "-g" // -// G2: "-cc1" -// G2: "-g" -// -// G3: "-cc1" -// G3: "-g" +// G_NO: "-cc1" +// G_NO-NOT: "-g" // -// GANY: "-cc1" -// GANY-NOT: "-g" +// GLTO_ONLY: "-cc1" +// GLTO_ONLY-NOT: "-g" +// GLTO_ONLY: "-gline-tables-only" +// GLTO_ONLY-NOT: "-g" // -// GGDB: "-cc1" -// GGDB: "-g" +// G_ONLY: "-cc1" +// G_ONLY-NOT: "-gline-tables-only" +// G_ONLY: "-g" +// G_ONLY-NOT: "-gline-tables-only" // -// GFOO: "-cc1" -// GFOO-NOT: "-g" +// GLTO_NO: "-cc1" +// GLTO_NO-NOT: "-gline-tables-only" diff --git a/test/Driver/debug-unsupported.c b/test/Driver/debug-unsupported.c new file mode 100644 index 000000000000..acbd7673a321 --- /dev/null +++ b/test/Driver/debug-unsupported.c @@ -0,0 +1,13 @@ +// RUN: %clang -c -gstabs %s 2>&1 | FileCheck %s +// RUN: %clang -c -gstabs+ %s 2>&1 | FileCheck %s +// RUN: %clang -c -gcoff %s 2>&1 | FileCheck %s +// RUN: %clang -c -gxcoff %s 2>&1 | FileCheck %s +// RUN: %clang -c -gxcoff+ %s 2>&1 | FileCheck %s +// RUN: %clang -c -gvms %s 2>&1 | FileCheck %s +// RUN: %clang -c -gstabs1 %s 2>&1 | FileCheck %s +// RUN: %clang -c -gcoff2 %s 2>&1 | FileCheck %s +// RUN: %clang -c -gxcoff3 %s 2>&1 | FileCheck %s +// RUN: %clang -c -gvms0 %s 2>&1 | FileCheck %s +// RUN: %clang -c -gtoggle %s 2>&1 | FileCheck %s +// +// CHECK: error: unsupported option diff --git a/test/Driver/fast-math.c b/test/Driver/fast-math.c index aef7cc3624d0..8426f0950acf 100644 --- a/test/Driver/fast-math.c +++ b/test/Driver/fast-math.c @@ -4,6 +4,9 @@ // LLVM only supports three switches which is more coarse grained than GCC's // support. // +// Both of them use gcc driver for as. +// XFAIL: cygwin,mingw32 +// // RUN: %clang -### -fno-honor-infinities -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s // CHECK-NO-INFS: "-cc1" @@ -19,8 +22,23 @@ // CHECK-MATH-ERRNO: "-cc1" // CHECK-MATH-ERRNO: "-fmath-errno" // -// RUN: %clang -### -fassociative-math -freciprocal-math -fno-signed-zeros \ -// RUN: -fno-trapping-math -c %s 2>&1 \ +// RUN: %clang -### -fmath-errno -fno-math-errno -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// RUN: %clang -### -target i686-apple-darwin -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// RUN: %clang -### -target x86_64-unknown-freebsd -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// RUN: %clang -### -target x86_64-unknown-netbsd -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// RUN: %clang -### -target x86_64-unknown-openbsd -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// RUN: %clang -### -target x86_64-unknown-dragonfly -c %s 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NO-MATH-ERRNO %s +// CHECK-NO-MATH-ERRNO: "-cc1" +// CHECK-NO-MATH-ERRNO-NOT: "-fmath-errno" +// +// RUN: %clang -### -fno-math-errno -fassociative-math -freciprocal-math \ +// RUN: -fno-signed-zeros -fno-trapping-math -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s // CHECK-UNSAFE-MATH: "-cc1" // CHECK-UNSAFE-MATH: "-menable-unsafe-fp-math" @@ -36,7 +54,7 @@ // RUN: | FileCheck --check-prefix=CHECK-NO-INFS %s // RUN: %clang -### -ffinite-math-only -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-NO-NANS %s -// RUN: %clang -### -funsafe-math-optimizations -c %s 2>&1 \ +// RUN: %clang -### -funsafe-math-optimizations -fno-math-errno -c %s 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-UNSAFE-MATH %s // // One umbrella flag is *really* weird and also changes the semantics of the diff --git a/test/Driver/flags.c b/test/Driver/flags.c index 7a885b699b15..698a54ecf78b 100644 --- a/test/Driver/flags.c +++ b/test/Driver/flags.c @@ -7,3 +7,5 @@ // RUN: %clang -target i386-apple-darwin9 -### -S -mno-soft-float %s -msoft-float 2> %t.log // RUN: grep '"-no-implicit-float"' %t.log +// RUN: %clang -target armv7-apple-darwin10 -### -S -mno-implicit-float %s 2> %t.log +// RUN: grep '"-no-implicit-float"' %t.log | count 1 diff --git a/test/Driver/fpack-struct.c b/test/Driver/fpack-struct.c new file mode 100644 index 000000000000..cc75da5bc0f8 --- /dev/null +++ b/test/Driver/fpack-struct.c @@ -0,0 +1,10 @@ +// RUN: %clang -fpack-struct -### %s 2> %t +// RUN: FileCheck < %t %s +// RUN: %clang -fpack-struct=8 -### %s 2> %t +// RUN: FileCheck < %t %s --check-prefix=EQ + +// CHECK: "-cc1" +// CHECK: "-fpack-struct=1" + +// CHECK-EQ: "-cc1" +// CHECK-EQ: "-fpack-struct=8" diff --git a/test/Driver/freebsd.c b/test/Driver/freebsd.c index 1fb84a02ac68..642c60ce77b5 100644 --- a/test/Driver/freebsd.c +++ b/test/Driver/freebsd.c @@ -28,3 +28,19 @@ // RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -print-search-dirs 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LIB32PATHS %s // CHECK-LIB32PATHS: libraries: ={{.*:?}}/usr/lib32 +// +// Check that the new linker flags are passed to FreeBSD +// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \ +// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS8 %s +// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd9 -m32 %s \ +// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS9 %s +// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd10.0 -m32 %s \ +// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS9 %s +// CHECK-LDFLAGS8-NOT: --hash-style=both +// CHECK-LDFLAGS8: --enable-new-dtags +// CHECK-LDFLAGS9: --hash-style=both +// CHECK-LDFLAGS9: --enable-new-dtags + diff --git a/test/Driver/gnu-runtime.m b/test/Driver/gnu-runtime.m index 12426d950571..1d7a40ab2b86 100644 --- a/test/Driver/gnu-runtime.m +++ b/test/Driver/gnu-runtime.m @@ -1,5 +1,4 @@ // RUN: %clang -target i386-apple-darwin10 -### -fsyntax-only -fgnu-runtime %s 2>&1 | FileCheck %s // RUN: %clang -target i386-apple-darwin10 -### -x objective-c++ -fsyntax-only -fgnu-runtime %s 2>&1 | FileCheck %s -// CHECK: -fgnu-runtime -// CHECK: -fobjc-runtime-has-arc -// CHECK: -fobjc-runtime-has-weak +// CHECK: -fobjc-runtime=gcc +// CHECK-NOT: fragile diff --git a/test/Driver/ios-simulator-arcruntime.c b/test/Driver/ios-simulator-arcruntime.c index 9bf2091fed5d..33d34924ced1 100644 --- a/test/Driver/ios-simulator-arcruntime.c +++ b/test/Driver/ios-simulator-arcruntime.c @@ -1,6 +1,8 @@ // RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=40201 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS1 %s -// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -mmacosx-version-min=10.6 -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s +// RUN: %clang -### -x objective-c -target i386-apple-darwin10 -arch i386 -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -fobjc-arc -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-OPTIONS2 %s // -// CHECK-OPTIONS1-NOT: -fobjc-runtime-has-weak -// CHECK-OPTIONS2: -fobjc-runtime-has-weak +// CHECK-OPTIONS1: i386-apple-macosx10.6.0 +// CHECK-OPTIONS1: -fobjc-runtime=ios-4.2.1 +// CHECK-OPTIONS2: i386-apple-macosx10.6.0 +// CHECK-OPTIONS2: -fobjc-runtime=ios-5.0.0 diff --git a/test/Driver/linker-opts.c b/test/Driver/linker-opts.c index d036dfd04fb5..85e180c4e210 100644 --- a/test/Driver/linker-opts.c +++ b/test/Driver/linker-opts.c @@ -2,4 +2,4 @@ // CHECK: "-L" "{{.*}}/test1" // GCC driver is used as linker on cygming. It should be aware of LIBRARY_PATH. -// XFAIL: cygwin,mingw32 +// XFAIL: cygwin,mingw32,win32 diff --git a/test/Driver/linux-as.c b/test/Driver/linux-as.c index 22eac0d2dd94..b3265da23478 100644 --- a/test/Driver/linux-as.c +++ b/test/Driver/linux-as.c @@ -3,29 +3,54 @@ // RUN: %clang -target arm-linux -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM %s -// CHECK-ARM: as{{(.exe)?}}" +// CHECK-ARM: as{{(.exe)?}}" "-mfloat-abi=soft" // // RUN: %clang -target arm-linux -mcpu=cortex-a8 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM-MCPU %s -// CHECK-ARM-MCPU: as{{(.exe)?}}" "-mcpu=cortex-a8" +// CHECK-ARM-MCPU: as{{(.exe)?}}" "-mfloat-abi=soft" "-mcpu=cortex-a8" // // RUN: %clang -target arm-linux -mfpu=neon -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM-MFPU %s -// CHECK-ARM-MFPU: as{{(.exe)?}}" "-mfpu=neon" +// CHECK-ARM-MFPU: as{{(.exe)?}}" "-mfloat-abi=soft" "-mfpu=neon" // // RUN: %clang -target arm-linux -march=armv7-a -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM-MARCH %s -// CHECK-ARM-MARCH: as{{(.exe)?}}" "-march=armv7-a" +// CHECK-ARM-MARCH: as{{(.exe)?}}" "-mfloat-abi=soft" "-march=armv7-a" // // RUN: %clang -target arm-linux -mcpu=cortex-a8 -mfpu=neon -march=armv7-a -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM-ALL %s -// CHECK-ARM-ALL: as{{(.exe)?}}" "-march=armv7-a" "-mcpu=cortex-a8" "-mfpu=neon" +// CHECK-ARM-ALL: as{{(.exe)?}}" "-mfloat-abi=soft" "-march=armv7-a" "-mcpu=cortex-a8" "-mfpu=neon" // // RUN: %clang -target armv7-linux -mcpu=cortex-a8 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=ARM-TARGET %s -// CHECK-ARM-TARGET: as{{(.exe)?}}" "-mfpu=neon" "-mcpu=cortex-a8" +// CHECK-ARM-TARGET: as{{(.exe)?}}" "-mfpu=neon" "-mfloat-abi=soft" "-mcpu=cortex-a8" +// +// RUN: %clang -target arm-linux -mfloat-abi=hard -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=ARM-MFLOAT-ABI %s +// CHECK-ARM-MFLOAT-ABI: as{{(.exe)?}}" "-mfloat-abi=hard" +// +// RUN: %clang -target arm-linux-androideabi -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=ARM-ANDROID %s +// CHECK-ARM-ANDROID: as{{(.exe)?}}" "-mfloat-abi=soft" +// +// RUN: %clang -target arm-linux-androideabi -march=armv7-a -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=ARM-ANDROID-SOFTFP %s +// CHECK-ARM-ANDROID-SOFTFP: as{{(.exe)?}}" "-mfloat-abi=softfp" "-march=armv7-a" +// +// RUN: %clang -target arm-linux-eabi -mhard-float -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=ARM-HARDFP %s +// CHECK-ARM-HARDFP: as{{(.exe)?}}" "-mfloat-abi=hard" +// +// RUN: %clang -target ppc-linux -mcpu=invalid-cpu -### \ +// RUN: -no-integrated-as -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=PPC-NO-MCPU %s +// CHECK-PPC-NO-MCPU-NOT: as{{.*}} "-mcpu=invalid-cpu" diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index 9a35d5d386ec..a6831b62a904 100644 --- a/test/Driver/linux-ld.c +++ b/test/Driver/linux-ld.c @@ -174,6 +174,39 @@ // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/lib" // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib" // +// Check multi arch support on Ubuntu 12.04 LTS. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-unknown-linux-gnueabihf \ +// RUN: --sysroot=%S/Inputs/ubuntu_12.04_LTS_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-12-04-ARM-HF %s +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crt1.o" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crti.o" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/lib/arm-linux-gnueabihf" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/arm-linux-gnueabihf" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../.." +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crtn.o" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-unknown-linux-gnueabi \ +// RUN: --sysroot=%S/Inputs/ubuntu_12.04_LTS_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-12-04-ARM %s +// CHECK-UBUNTU-12-04-ARM: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crt1.o" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crti.o" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/lib/arm-linux-gnueabi" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/arm-linux-gnueabi" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../.." +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crtn.o" +// // Test the setup that shipped in SUSE 10.3 on ppc64. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target powerpc64-suse-linux \ @@ -186,6 +219,21 @@ // CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/lib/../lib64" // CHECK-SUSE-10-3-PPC64: "-L[[SYSROOT]]/usr/lib/../lib64" // +// Check dynamic-linker for different archs +// RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-gnueabi \ +// RUN: | FileCheck --check-prefix=CHECK-ARM %s +// CHECK-ARM: "{{.*}}ld{{(.exe)?}}" +// CHECK-ARM: "-m" "armelf_linux_eabi" +// CHECK-ARM: "-dynamic-linker" "{{.*}}/lib/ld-linux.so.3" +// +// RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-gnueabihf \ +// RUN: | FileCheck --check-prefix=CHECK-ARM-HF %s +// CHECK-ARM-HF: "{{.*}}ld{{(.exe)?}}" +// CHECK-ARM-HF: "-m" "armelf_linux_eabi" +// CHECK-ARM-HF: "-dynamic-linker" "{{.*}}/lib/ld-linux-armhf.so.3" +// // Check that we do not pass --hash-style=gnu and --hash-style=both to linker // and provide correct path to the dynamic linker and emulation mode when build // for MIPS platforms. @@ -267,4 +315,86 @@ // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib/gcc/powerpc64-linux-gnu/4.5/../../.." // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/lib" // CHECK-DEBIAN-PPC64: "-L[[SYSROOT]]/usr/lib" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target mips-linux-gnu \ +// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS %s +// CHECK-DEBIAN-MIPS: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-DEBIAN-MIPS: "{{.*}}/usr/lib/gcc/mips-linux-gnu/4.5/crtbegin.o" +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5" +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/../../../mips-linux-gnu" +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/mips-linux-gnu" +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/../../.." +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/lib" +// CHECK-DEBIAN-MIPS: "-L[[SYSROOT]]/usr/lib" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target mipsel-linux-gnu \ +// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPSEL %s +// CHECK-DEBIAN-MIPSEL: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-DEBIAN-MIPSEL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.5/crtbegin.o" +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5" +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../../mipsel-linux-gnu" +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/mipsel-linux-gnu" +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../.." +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/lib" +// CHECK-DEBIAN-MIPSEL: "-L[[SYSROOT]]/usr/lib" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target mips64-linux-gnu \ +// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS64 %s +// CHECK-DEBIAN-MIPS64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-DEBIAN-MIPS64: "{{.*}}/usr/lib/gcc/mips-linux-gnu/4.5/64/crtbegin.o" +// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/64" +// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5" +// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib/gcc/mips-linux-gnu/4.5/../../.." +// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/lib" +// CHECK-DEBIAN-MIPS64: "-L[[SYSROOT]]/usr/lib" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target mips64el-linux-gnu \ +// RUN: --sysroot=%S/Inputs/debian_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-MIPS64EL %s +// CHECK-DEBIAN-MIPS64EL: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-DEBIAN-MIPS64EL: "{{.*}}/usr/lib/gcc/mipsel-linux-gnu/4.5/64/crtbegin.o" +// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/64" +// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5" +// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib/gcc/mipsel-linux-gnu/4.5/../../.." +// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/lib" +// CHECK-DEBIAN-MIPS64EL: "-L[[SYSROOT]]/usr/lib" // +// Test linker invocation on Android. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID %s +// CHECK-ANDROID: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-ANDROID: "{{.*}}/crtbegin_dynamic.o" +// CHECK-ANDROID: "-L[[SYSROOT]]/usr/lib" +// CHECK-ANDROID-NOT: "gcc_s" +// CHECK-ANDROID: "-lgcc" +// CHECK-ANDROID-NOT: "gcc_s" +// CHECK-ANDROID: "{{.*}}/crtend_android.o" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: -shared \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-SO %s +// CHECK-ANDROID-SO: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-ANDROID-SO: "{{.*}}/crtbegin_so.o" +// CHECK-ANDROID-SO: "-L[[SYSROOT]]/usr/lib" +// CHECK-ANDROID-SO-NOT: "gcc_s" +// CHECK-ANDROID-SO: "-lgcc" +// CHECK-ANDROID-SO-NOT: "gcc_s" +// CHECK-ANDROID-SO: "{{.*}}/crtend_so.o" +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-linux-androideabi \ +// RUN: --sysroot=%S/Inputs/basic_android_tree \ +// RUN: -static \ +// RUN: | FileCheck --check-prefix=CHECK-ANDROID-STATIC %s +// CHECK-ANDROID-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-ANDROID-STATIC: "{{.*}}/crtbegin_static.o" +// CHECK-ANDROID-STATIC: "-L[[SYSROOT]]/usr/lib" +// CHECK-ANDROID-STATIC-NOT: "gcc_s" +// CHECK-ANDROID-STATIC: "-lgcc" +// CHECK-ANDROID-STATIC-NOT: "gcc_s" +// CHECK-ANDROID-STATIC: "{{.*}}/crtend_android.o" diff --git a/test/Driver/mips-as.c b/test/Driver/mips-as.c index 44b8d8d3c4d8..0ace4dd51c74 100644 --- a/test/Driver/mips-as.c +++ b/test/Driver/mips-as.c @@ -3,29 +3,36 @@ // RUN: %clang -target mips-linux-gnu -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS32-EB-AS %s -// CHECK-MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB" +// MIPS32-EB-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB" +// MIPS32-EB-AS-NOT: "-KPIC" +// +// RUN: %clang -target mips-linux-gnu -### \ +// RUN: -no-integrated-as -fPIC -c %s 2>&1 \ +// RUN: | FileCheck -check-prefix=MIPS32-EB-PIC %s +// MIPS32-EB-PIC: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EB" +// MIPS32-EB-PIC: "-KPIC" // // RUN: %clang -target mipsel-linux-gnu -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS32-EL-AS %s -// CHECK-MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL" +// MIPS32-EL-AS: as{{(.exe)?}}" "-march" "mips32" "-mabi" "32" "-EL" // // RUN: %clang -target mips64-linux-gnu -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS64-EB-AS %s -// CHECK-MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB" +// MIPS64-EB-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EB" // // RUN: %clang -target mips64el-linux-gnu -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS64-EL-AS %s -// CHECK-MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL" +// MIPS64-EL-AS: as{{(.exe)?}}" "-march" "mips64" "-mabi" "64" "-EL" // // RUN: %clang -target mips-linux-gnu -mabi=eabi -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-EABI %s -// CHECK-MIPS-EABI: as{{(.exe)?}}" "-march" "mips32" "-mabi" "eabi" "-EB" +// MIPS-EABI: as{{(.exe)?}}" "-march" "mips32" "-mabi" "eabi" "-EB" // // RUN: %clang -target mips64-linux-gnu -mabi=n32 -### \ // RUN: -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS-N32 %s -// CHECK-MIPS-N32: as{{(.exe)?}}" "-march" "mips64" "-mabi" "n32" "-EB" +// MIPS-N32: as{{(.exe)?}}" "-march" "mips64" "-mabi" "n32" "-EB" diff --git a/test/Driver/mips-features.c b/test/Driver/mips-features.c new file mode 100644 index 000000000000..5be268318886 --- /dev/null +++ b/test/Driver/mips-features.c @@ -0,0 +1,39 @@ +// REQUIRES: mips-registered-target +// +// Check handling MIPS specific features options. +// +// -mips16 +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mno-mips16 -mips16 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS16 %s +// CHECK-MIPS16: "-target-feature" "+mips16" +// +// -mno-mips16 +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mips16 -mno-mips16 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NOMIPS16 %s +// CHECK-NOMIPS16: "-target-feature" "-mips16" +// +// -mdsp +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mno-dsp -mdsp 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MDSP %s +// CHECK-MDSP: "-target-feature" "+dsp" +// +// -mno-dsp +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mdsp -mno-dsp 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NOMDSP %s +// CHECK-NOMDSP: "-target-feature" "-dsp" +// +// -mdspr2 +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mno-dspr2 -mdspr2 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MDSPR2 %s +// CHECK-MDSPR2: "-target-feature" "+dspr2" +// +// -mno-dspr2 +// RUN: %clang -target mips-linux-gnu -### -c %s \ +// RUN: -mdspr2 -mno-dspr2 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-NOMDSPR2 %s +// CHECK-NOMDSPR2: "-target-feature" "-dspr2" diff --git a/test/Driver/mips-float.c b/test/Driver/mips-float.c index c9e107f593ae..95eb0025cc09 100644 --- a/test/Driver/mips-float.c +++ b/test/Driver/mips-float.c @@ -1,3 +1,4 @@ +// REQUIRES: mips-registered-target // Check handling -mhard-float / -msoft-float / -mfloat-abi options // when build for MIPS platforms. // diff --git a/test/Driver/montavista-gcc-toolchain.c b/test/Driver/montavista-gcc-toolchain.c new file mode 100644 index 000000000000..b9ab729ef21c --- /dev/null +++ b/test/Driver/montavista-gcc-toolchain.c @@ -0,0 +1,9 @@ +// Test that the montavista gcc-toolchain is correctly detected +// +// RUN: %clang -print-libgcc-file-name 2>&1 \ +// RUN: -target i686-montavista-linux \ +// RUN: -gcc-toolchain %S/Inputs/montavista_i686_tree/usr \ +// RUN: | FileCheck %s + +// Test for header search toolchain detection. +// CHECK: montavista_i686_tree/usr/lib/gcc/i686-montavista-linux/4.2.0/libgcc.a diff --git a/test/Driver/msvc_forward.c b/test/Driver/msvc_forward.c new file mode 100644 index 000000000000..fe0ae84790e0 --- /dev/null +++ b/test/Driver/msvc_forward.c @@ -0,0 +1,5 @@ +// RUN: %clang -target i686-pc-win32 -lkernel32.lib -luser32.lib -### %s 2>&1 | FileCheck %s +// CHECK-NOT: "-lkernel32.lib" +// CHECK-NOT: "-luser32.lib" +// CHECK: "kernel32.lib" +// CHECK: "user32.lib" diff --git a/test/Driver/nodefaultlib.c b/test/Driver/nodefaultlib.c new file mode 100644 index 000000000000..518928a8850a --- /dev/null +++ b/test/Driver/nodefaultlib.c @@ -0,0 +1,8 @@ +// RUN: %clang -target i686-pc-linux-gnu -### -nodefaultlibs %s 2> %t +// RUN: FileCheck < %t %s +// +// CHECK-NOT: start-group +// CHECK-NOT: -lgcc +// CHECK-NOT: -lc +// CHECK: crtbegin +// CHECK: crtend diff --git a/test/Driver/rewrite-legacy-objc.m b/test/Driver/rewrite-legacy-objc.m index af59ff672726..d243c7a15b39 100644 --- a/test/Driver/rewrite-legacy-objc.m +++ b/test/Driver/rewrite-legacy-objc.m @@ -3,7 +3,7 @@ // TEST0: clang{{.*}}" "-cc1" // TEST0: "-rewrite-objc" // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead. -// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-fragile-abi" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" +// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx-fragile" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" // TEST0: rewrite-legacy-objc.m" // RUN: not %clang -ccc-no-clang -target unknown -rewrite-legacy-objc %s -o - -### 2>&1 | \ diff --git a/test/Driver/rewrite-objc.m b/test/Driver/rewrite-objc.m index 7b080fc35e86..669679772203 100644 --- a/test/Driver/rewrite-objc.m +++ b/test/Driver/rewrite-objc.m @@ -3,7 +3,7 @@ // TEST0: clang{{.*}}" "-cc1" // TEST0: "-rewrite-objc" // FIXME: CHECK-NOT is broken somehow, it doesn't work here. Check adjacency instead. -// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime-has-arc" "-fobjc-runtime-has-weak" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" +// TEST0: "-fmessage-length" "0" "-stack-protector" "1" "-mstackrealign" "-fblocks" "-fobjc-runtime=macosx" "-fobjc-dispatch-method=mixed" "-fobjc-default-synthesize-properties" "-fno-objc-infer-related-result-type" "-fobjc-exceptions" "-fexceptions" "-fdiagnostics-show-option" // TEST0: rewrite-objc.m" // RUN: not %clang -ccc-no-clang -target unknown -rewrite-objc %s -o - -### 2>&1 | \ diff --git a/test/Driver/target-triple-deployment.c b/test/Driver/target-triple-deployment.c new file mode 100644 index 000000000000..8e4824a7fe95 --- /dev/null +++ b/test/Driver/target-triple-deployment.c @@ -0,0 +1,33 @@ +// RUN: touch %t.o +// RUN: %clang -target x86_64-apple-macosx -### %t.o 2> %t.log +// RUN: %clang -target x86_64-apple-darwin9 -### %t.o 2>> %t.log +// RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log +// +// RUN: %clang -target armv7-apple-ios -### %t.o 2>> %t.log +// RUN: %clang -target armv7-apple-ios0.0 -### %t.o 2>> %t.log +// RUN: %clang -target armv7-apple-ios1.2.3 -### %t.o 2>> %t.log +// RUN: %clang -target armv7-apple-ios5.0 -### %t.o 2>> %t.log +// +// RUN: FileCheck %s < %t.log + +// CHECK: {{ld(.exe)?"}} +// CHECK: -macosx_version_min +// CHECK: 10.4.0 +// CHECK: {{ld(.exe)?"}} +// CHECK: -macosx_version_min +// CHECK: 10.5.0 +// CHECK: {{ld(.exe)?"}} +// CHECK: -macosx_version_min +// CHECK: 10.7.0 +// CHECK: {{ld(.exe)?"}} +// CHECK: -iphoneos_version_min +// CHECK: 3.0.0 +// CHECK: {{ld(.exe)?"}} +// CHECK: -iphoneos_version_min +// CHECK: 3.0.0 +// CHECK: {{ld(.exe)?"}} +// CHECK: -iphoneos_version_min +// CHECK: 1.2.3 +// CHECK: {{ld(.exe)?"}} +// CHECK: -iphoneos_version_min +// CHECK: 5.0.0 diff --git a/test/Driver/warning-options.cpp b/test/Driver/warning-options.cpp new file mode 100644 index 000000000000..ab0da42e4bfc --- /dev/null +++ b/test/Driver/warning-options.cpp @@ -0,0 +1,10 @@ +// RUN: %clang -### -Wlarge-by-value-copy %s 2>&1 | FileCheck -check-prefix=LARGE_VALUE_COPY_DEFAULT %s +// LARGE_VALUE_COPY_DEFAULT: -Wlarge-by-value-copy=64 +// RUN: %clang -### -Wlarge-by-value-copy=128 %s 2>&1 | FileCheck -check-prefix=LARGE_VALUE_COPY_JOINED %s +// LARGE_VALUE_COPY_JOINED: -Wlarge-by-value-copy=128 + +// RUN: %clang -### -c -Wmonkey -Wno-monkey -Wno-unused-command-line-arguments \ +// RUN: -Wno-unused-command-line-argument %s 2>&1 | FileCheck %s +// CHECK: unknown warning option '-Wmonkey' +// CHECK: unknown warning option '-Wno-monkey' +// CHECK: unknown warning option '-Wno-unused-command-line-arguments'; did you mean '-Wno-unused-command-line-argument'? diff --git a/test/Driver/warning-options_pedantic.cpp b/test/Driver/warning-options_pedantic.cpp new file mode 100644 index 000000000000..c6d11be73d1f --- /dev/null +++ b/test/Driver/warning-options_pedantic.cpp @@ -0,0 +1,7 @@ +// RUN: %clang -### -pedantic -no-pedantic %s 2>&1 | FileCheck -check-prefix=NO_PEDANTIC %s +// RUN: %clang -### -pedantic -Wno-pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC %s +// NO_PEDANTIC-NOT: -pedantic +// RUN: %clang -### -pedantic -pedantic -no-pedantic -pedantic %s 2>&1 | FileCheck -check-prefix=PEDANTIC %s +// RUN: %clang -### -pedantic -pedantic -no-pedantic -Wpedantic %s 2>&1 | FileCheck -check-prefix=NO_PEDANTIC %s +// PEDANTIC: -pedantic +// XFAIL: cygwin,mingw32 diff --git a/test/FixIt/fixit-autoreleasepool.m b/test/FixIt/fixit-autoreleasepool.m new file mode 100644 index 000000000000..ba1ad130f22a --- /dev/null +++ b/test/FixIt/fixit-autoreleasepool.m @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s +// rdar://10723084 + +void f0() { + @autorelease { + } +} + +// CHECK: {5:4-5:15}:"autoreleasepool" diff --git a/test/FixIt/fixit-cxx0x.cpp b/test/FixIt/fixit-cxx0x.cpp index b6cc2c08b031..0c837b4beb02 100644 --- a/test/FixIt/fixit-cxx0x.cpp +++ b/test/FixIt/fixit-cxx0x.cpp @@ -108,3 +108,17 @@ void func(); template<int *ip> struct IP { }; // expected-note{{declared here}} IP<0> ip0; // expected-error{{null non-type template argument must be cast to template parameter type 'int *'}} +namespace MissingSemi { + struct a // expected-error {{expected ';' after struct}} + struct b // expected-error {{expected ';' after struct}} + enum x : int { x1, x2, x3 } // expected-error {{expected ';' after enum}} + struct c // expected-error {{expected ';' after struct}} + enum x : int // expected-error {{expected ';' after enum}} + // FIXME: The following gives a poor diagnostic (we parse the 'int' and the + // 'struct' as part of the same enum-base. + // enum x : int + // struct y + namespace N { + struct d // expected-error {{expected ';' after struct}} + } +} diff --git a/test/FixIt/fixit-include.c b/test/FixIt/fixit-include.c new file mode 100644 index 000000000000..51bd9b0dfd50 --- /dev/null +++ b/test/FixIt/fixit-include.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -Wall -pedantic -verify %s +// RUN: cp %s %t +// RUN: cp %S/fixit-include.h %T +// RUN: not %clang_cc1 -fsyntax-only -fixit %t +// RUN: %clang_cc1 -Wall -pedantic %t + +#include <fixit-include.h> // expected-error {{'fixit-include.h' file not found with <angled> include; use "quotes" instead}} + +#pragma does_not_exist // expected-warning {{unknown pragma ignored}} + +int main( void ) { + return 0; +} diff --git a/test/FixIt/fixit-include.h b/test/FixIt/fixit-include.h new file mode 100644 index 000000000000..6a22d2e88eb3 --- /dev/null +++ b/test/FixIt/fixit-include.h @@ -0,0 +1 @@ +// This file is purposefully left empty
diff --git a/test/FixIt/fixit-interface-as-param.m b/test/FixIt/fixit-interface-as-param.m new file mode 100644 index 000000000000..3295c82c31a1 --- /dev/null +++ b/test/FixIt/fixit-interface-as-param.m @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s +// rdar://11311333 + +@interface NSView @end + +@interface INTF +- (void) drawRect : inView:(NSView)view; +@end + +// CHECK: {7:35-7:35}:"*" + diff --git a/test/FixIt/fixit-objc-message-comma-separator.m b/test/FixIt/fixit-objc-message-comma-separator.m new file mode 100644 index 000000000000..0caa33eb0ad2 --- /dev/null +++ b/test/FixIt/fixit-objc-message-comma-separator.m @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fdiagnostics-parseable-fixits -x objective-c %s 2>&1 | FileCheck %s +// rdar://11376372 + +@class NSObject; + +@interface TestObj { +} +-(void)aMethodWithArg1:(NSObject*)arg1 arg2:(NSObject*)arg2; +@end + +int main(int argc, char *argv[]) +{ + TestObj *obj; + [obj aMethodWithArg1:@"Arg 1 Good", arg2:@"Arg 2 Good"]; +} + +// CHECK: {14:39-14:40}:"" diff --git a/test/FixIt/fixit-unicode.c b/test/FixIt/fixit-unicode.c new file mode 100644 index 000000000000..2af5e08faa41 --- /dev/null +++ b/test/FixIt/fixit-unicode.c @@ -0,0 +1,33 @@ +// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s +// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck -check-prefix=CHECK-MACHINE %s + +struct Foo { + int bar; +}; + +// PR13312 +void test1() { + struct Foo foo; + (&foo)☃>bar = 42; +// CHECK: error: expected ';' after expression +// Make sure we emit the fixit right in front of the snowman. +// CHECK: {{^ \^}} +// CHECK: {{^ ;}} + +// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{11:9-11:9}:";" +} + + +int printf(const char *, ...); +void test2() { + printf("∆: %d", 1L); +// CHECK: warning: format specifies type 'int' but the argument has type 'long' +// Don't crash emitting a fixit after the delta. +// CHECK: printf(" +// CHECK: : %d", 1L); +// Unfortunately, we can't actually check the location of the printed fixit, +// because different systems will render the delta differently (either as a +// character, or as <U+2206>.) The fixit should line up with the %d regardless. + +// CHECK-MACHINE: fix-it:"{{.*}}fixit-unicode.c":{23:16-23:18}:"%ld" +} diff --git a/test/FixIt/fixit-vexing-parse.cpp b/test/FixIt/fixit-vexing-parse.cpp index 8450590c67f9..dd0f87304a53 100644 --- a/test/FixIt/fixit-vexing-parse.cpp +++ b/test/FixIt/fixit-vexing-parse.cpp @@ -7,6 +7,7 @@ struct S { struct T { T(); + T(S, S); int n; }; @@ -30,26 +31,44 @@ S F2(); namespace N { void test() { - // CHECK: fix-it:"{{.*}}":{34:9-34:11}:" = {}" + // CHECK: fix-it:"{{.*}}":{35:9-35:11}:" = {}" S s1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{38:9-38:10}:";" - // CHECK: fix-it:"{{.*}}":{39:7-39:9}:" = {}" + // CHECK: fix-it:"{{.*}}":{39:9-39:10}:";" + // CHECK: fix-it:"{{.*}}":{40:7-40:9}:" = {}" S s2, // expected-note {{change this ',' to a ';' to call 'F2'}} F2(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{43:9-43:11}:"" // CHECK: fix-it:"{{.*}}":{44:9-44:11}:"" + // CHECK: fix-it:"{{.*}}":{45:9-45:11}:"" T t1(), // expected-warning {{function declaration}} expected-note {{remove parentheses}} t2(); // expected-warning {{function declaration}} expected-note {{remove parentheses}} - // CHECK: fix-it:"{{.*}}":{47:8-47:10}:" = {}" + // Suggest parentheses only around the first argument. + // CHECK: fix-it:"{{.*}}":{50:10-50:10}:"(" + // CHECK: fix-it:"{{.*}}":{50:13-50:13}:")" + T t3(S(), S()); // expected-warning {{disambiguated as a function declaration}} expected-note {{add a pair of parentheses}} + + // Check fixit position for pathological case + // CHECK: fix-it:"{{.*}}":{56:11-56:11}:"(" + // CHECK: fix-it:"{{.*}}":{56:20-56:20}:")" + float k[1]; + int l(int(k[0])); // expected-warning {{disambiguated as a function declaration}} expected-note {{add a pair of parentheses}} + + // Don't emit warning and fixit because this must be a function declaration due to void return type. + typedef void VO; + VO m(int (*p)[4]); + + // Don't emit warning and fixit because direct initializer is not permitted here. + if (int n(int())){} // expected-error {{function type is not allowed here}} expected-error {{condition must have an initializer}} + + // CHECK: fix-it:"{{.*}}":{66:8-66:10}:" = {}" U u(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{50:8-50:10}:"" + // CHECK: fix-it:"{{.*}}":{69:8-69:10}:"" V v(); // expected-warning {{function declaration}} expected-note {{remove parentheses}} - // CHECK: fix-it:"{{.*}}":{53:8-53:10}:"" + // CHECK: fix-it:"{{.*}}":{72:8-72:10}:"" W w(); // expected-warning {{function declaration}} expected-note {{remove parentheses}} // TODO: Removing the parens here would not initialize U::n. @@ -57,33 +76,33 @@ namespace N { // Maybe suggest removing the parens anyway? X x(); // expected-warning {{function declaration}} - // CHECK: fix-it:"{{.*}}":{61:11-61:13}:" = 0" + // CHECK: fix-it:"{{.*}}":{80:11-80:13}:" = 0" int n1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{65:11-65:12}:";" - // CHECK: fix-it:"{{.*}}":{66:7-66:9}:" = 0" + // CHECK: fix-it:"{{.*}}":{84:11-84:12}:";" + // CHECK: fix-it:"{{.*}}":{85:7-85:9}:" = 0" int n2, // expected-note {{change this ',' to a ';' to call 'F1'}} F1(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{69:13-69:15}:" = 0.0" + // CHECK: fix-it:"{{.*}}":{88:13-88:15}:" = 0.0" double d(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} typedef void *Ptr; - // CHECK: fix-it:"{{.*}}":{74:10-74:12}:" = 0" + // CHECK: fix-it:"{{.*}}":{93:10-93:12}:" = 0" Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} #define NULL 0 - // CHECK: fix-it:"{{.*}}":{78:10-78:12}:" = NULL" + // CHECK: fix-it:"{{.*}}":{97:10-97:12}:" = NULL" Ptr p(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{81:11-81:13}:" = false" + // CHECK: fix-it:"{{.*}}":{100:11-100:13}:" = false" bool b(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{84:11-84:13}:" = '\\0'" + // CHECK: fix-it:"{{.*}}":{103:11-103:13}:" = '\\0'" char c(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} - // CHECK: fix-it:"{{.*}}":{87:15-87:17}:" = L'\\0'" + // CHECK: fix-it:"{{.*}}":{106:15-106:17}:" = L'\\0'" wchar_t wc(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} } } diff --git a/test/FixIt/fixit.c b/test/FixIt/fixit.c index 5e4947b8cdd6..ce6f1092df19 100644 --- a/test/FixIt/fixit.c +++ b/test/FixIt/fixit.c @@ -100,3 +100,11 @@ int noSemiAfterLabel(int n) { } return 1; } + +struct noSemiAfterStruct // expected-error {{expected ';' after struct}} +struct noSemiAfterStruct { + int n // expected-warning {{';'}} +} // expected-error {{expected ';' after struct}} +enum noSemiAfterEnum { + e1 +} // expected-error {{expected ';' after enum}} diff --git a/test/FixIt/fixit.cpp b/test/FixIt/fixit.cpp index 7d531a537a35..3eac434a36bd 100644 --- a/test/FixIt/fixit.cpp +++ b/test/FixIt/fixit.cpp @@ -54,7 +54,7 @@ namespace rdar7853795 { } namespace rdar7796492 { - class A { int x, y; A(); }; + struct A { int x, y; A(); }; A::A() : x(1) y(2) { // expected-error{{missing ',' between base or member initializers}} @@ -204,3 +204,91 @@ template<template<typename> Foo, // expected-error {{template template parameter template<typename> typename Bar, // expected-error {{template template parameter requires 'class' after the parameter list}} template<typename> struct Baz> // expected-error {{template template parameter requires 'class' after the parameter list}} void func(); + +namespace ShadowedTagType { +class Foo { + public: + enum Bar { X, Y }; + void SetBar(Bar bar); + Bar Bar(); // expected-note 2 {{enum 'Bar' is hidden by a non-type declaration of 'Bar' here}} + private: + Bar bar_; // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}} +}; +void Foo::SetBar(Bar bar) { bar_ = bar; } // expected-error {{must use 'enum' tag to refer to type 'Bar' in this scope}} +} + +#define NULL __null +char c = NULL; // expected-warning {{implicit conversion of NULL constant to 'char'}} +double dbl = NULL; // expected-warning {{implicit conversion of NULL constant to 'double'}} + +namespace arrow_suggest { + +template <typename T> +class wrapped_ptr { + public: + wrapped_ptr(T* ptr) : ptr_(ptr) {} + T* operator->() { return ptr_; } + private: + T *ptr_; +}; + +class Worker { + public: + void DoSomething(); +}; + +void test() { + wrapped_ptr<Worker> worker(new Worker); + worker.DoSomething(); // expected-error {{no member named 'DoSomething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}} +} + +} // namespace arrow_suggest + +// Make sure fixing namespace-qualified identifiers functions properly with +// namespace-aware typo correction/ +namespace redecl_typo { +namespace Foo { + void BeEvil(); // expected-note {{'BeEvil' declared here}} +} +namespace Bar { + namespace Foo { + bool isGood(); // expected-note {{'Bar::Foo::isGood' declared here}} + void beEvil(); + } +} +bool Foo::isGood() { // expected-error {{out-of-line definition of 'isGood' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'Bar::Foo::isGood'?}} + return true; +} +void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}} +} + +// Test behavior when a template-id is ended by a token which starts with '>'. +namespace greatergreater { + template<typename T> struct S { S(); S(T); }; + void f(S<int>=0); // expected-error {{a space is required between a right angle bracket and an equals sign (use '> =')}} + + // FIXME: The fix-its here overlap so -fixit mode can't apply the second one. + //void f(S<S<int>>=S<int>()); + + struct Shr { + template<typename T> Shr(T); + template<typename T> void operator >>=(T); + }; + + template<template<typename>> struct TemplateTemplateParam; // expected-error {{requires 'class'}} + + template<typename T> void t(); + void g() { + void (*p)() = &t<int>; + (void)(&t<int>==p); // expected-error {{use '> ='}} + (void)(&t<int>>=p); // expected-error {{use '> >'}} + (void)(&t<S<int>>>=p); // expected-error {{use '> >'}} + (Shr)&t<S<int>>>>=p; // expected-error {{use '> >'}} + + // FIXME: We correct this to '&t<int> > >= p;' not '&t<int> >>= p;' + //(Shr)&t<int>>>=p; + + // FIXME: The fix-its here overlap. + //(void)(&t<S<int>>==p); + } +} diff --git a/test/FixIt/format-no-fixit.m b/test/FixIt/format-no-fixit.m new file mode 100644 index 000000000000..36ecd3f26c01 --- /dev/null +++ b/test/FixIt/format-no-fixit.m @@ -0,0 +1,30 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -fsyntax-only %s 2>&1 | FileCheck %s + +// CHECK-NOT: fix-it: + +@class NSString; +extern void NSLog(NSString *format, ...); +int printf(const char * restrict, ...) ; + + +void test_object_correction (id x) { + printf("%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'id'}} + printf("%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'id'}} + printf("%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'id'}} +} + + +// Old-style Core Foundation types do not have __attribute__((NSObject)). +// This is okay, but we won't suggest a fixit; arbitrary structure pointers may +// not be objects. +typedef const struct __CFString * CFStringRef; + +void test_cf_object_correction (CFStringRef x) { + NSLog(@"%@", x); // no-warning + + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'CFStringRef'}} + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'CFStringRef'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'CFStringRef'}} +} + diff --git a/test/FixIt/format.m b/test/FixIt/format.m new file mode 100644 index 000000000000..c4747019b2df --- /dev/null +++ b/test/FixIt/format.m @@ -0,0 +1,95 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s +// RUN: %clang_cc1 -fdiagnostics-parseable-fixits -fblocks %s 2>&1 | FileCheck %s + +@class NSString; +extern void NSLog(NSString *, ...); +int printf(const char * restrict, ...) ; + +void test_integer_correction (int x) { + printf("%d", x); // no-warning + printf("%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} + printf("%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'int'}} + // CHECK: fix-it:"{{.*}}":{10:11-10:13}:"%d" + // CHECK: fix-it:"{{.*}}":{11:11-11:14}:"%d" + + NSLog(@"%d", x); // no-warning + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'int'}} + NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'int'}} + // CHECK: fix-it:"{{.*}}":{16:11-16:13}:"%d" + // CHECK: fix-it:"{{.*}}":{17:11-17:14}:"%d" + // CHECK: fix-it:"{{.*}}":{18:11-18:13}:"%d" +} + +void test_string_correction (char *x) { + printf("%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}} + printf("%s", x); // no-warning + printf("%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'char *'}} + // CHECK: fix-it:"{{.*}}":{25:11-25:13}:"%s" + // CHECK: fix-it:"{{.*}}":{27:11-27:14}:"%s" + + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'char *'}} + NSLog(@"%s", x); // no-warning + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'char *'}} + NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'char *'}} + // CHECK: fix-it:"{{.*}}":{31:11-31:13}:"%s" + // CHECK: fix-it:"{{.*}}":{33:11-33:14}:"%s" + // CHECK: fix-it:"{{.*}}":{34:11-34:13}:"%s" +} + +void test_object_correction (id x) { + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'id'}} + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'id'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'id'}} + NSLog(@"%@", x); // no-warning + // CHECK: fix-it:"{{.*}}":{41:11-41:13}:"%@" + // CHECK: fix-it:"{{.*}}":{42:11-42:13}:"%@" + // CHECK: fix-it:"{{.*}}":{43:11-43:14}:"%@" +} + +typedef const struct __CFString * __attribute__((NSObject)) CFStringRef; +void test_cf_object_correction (CFStringRef x) { + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'CFStringRef'}} + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'CFStringRef'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'CFStringRef'}} + NSLog(@"%@", x); // no-warning + // CHECK: fix-it:"{{.*}}":{52:11-52:13}:"%@" + // CHECK: fix-it:"{{.*}}":{53:11-53:13}:"%@" + // CHECK: fix-it:"{{.*}}":{54:11-54:14}:"%@" +} + +typedef void (^block_t)(void); +void test_block_correction (block_t x) { + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'block_t'}} + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'block_t'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'block_t'}} + NSLog(@"%@", x); // no-warning + // CHECK: fix-it:"{{.*}}":{63:11-63:13}:"%@" + // CHECK: fix-it:"{{.*}}":{64:11-64:13}:"%@" + // CHECK: fix-it:"{{.*}}":{65:11-65:14}:"%@" +} + +void test_class_correction (Class x) { + NSLog(@"%d", x); // expected-warning{{format specifies type 'int' but the argument has type 'Class'}} + NSLog(@"%s", x); // expected-warning{{format specifies type 'char *' but the argument has type 'Class'}} + NSLog(@"%lf", x); // expected-warning{{format specifies type 'double' but the argument has type 'Class'}} + NSLog(@"%@", x); // no-warning + // CHECK: fix-it:"{{.*}}":{73:11-73:13}:"%@" + // CHECK: fix-it:"{{.*}}":{74:11-74:13}:"%@" + // CHECK: fix-it:"{{.*}}":{75:11-75:14}:"%@" +} + + +typedef enum : int { NSUTF8StringEncoding = 8 } NSStringEncoding; +void test_fixed_enum_correction(NSStringEncoding x) { + NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'NSStringEncoding'}} + // CHECK: fix-it:"{{.*}}":{85:11-85:13}:"%d" +} + +typedef __SIZE_TYPE__ size_t; +enum SomeSize : size_t { IntegerSize = sizeof(int) }; +void test_named_fixed_enum_correction(enum SomeSize x) { + NSLog(@"%@", x); // expected-warning{{format specifies type 'id' but the argument has type 'enum SomeSize'}} + // CHECK: fix-it:"{{.*}}":{92:11-92:13}:"%zu" +} + diff --git a/test/FixIt/messages.cpp b/test/FixIt/messages.cpp new file mode 100644 index 000000000000..b9391449ad16 --- /dev/null +++ b/test/FixIt/messages.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c++11 2>&1 %s | FileCheck -strict-whitespace %s + +struct A { + unsigned int a; +}; + +// PR10696 +void testOverlappingInsertions(int b) { + A var = { b }; + // CHECK: A var = { b }; + // CHECK: ^ + // CHECK: static_cast<unsigned int>( ) +} diff --git a/test/FixIt/objc-literals.m b/test/FixIt/objc-literals.m index 03d64b156496..549cfde20250 100644 --- a/test/FixIt/objc-literals.m +++ b/test/FixIt/objc-literals.m @@ -2,13 +2,13 @@ // RUN: cp %s %t // RUN: not %clang_cc1 -fsyntax-only -fixit -x objective-c %t // RUN: %clang_cc1 -fsyntax-only -pedantic -Werror -x objective-c %t -// RUN: grep arrayWithObjects %t typedef unsigned char BOOL; -@interface NSNumber @end +@interface NSObject +@end -@interface NSNumber (NSNumberCreation) +@interface NSNumber : NSObject + (NSNumber *)numberWithChar:(char)value; + (NSNumber *)numberWithUnsignedChar:(unsigned char)value; + (NSNumber *)numberWithShort:(short)value; @@ -24,17 +24,17 @@ typedef unsigned char BOOL; + (NSNumber *)numberWithBool:(BOOL)value; @end -@interface NSArray -@end - -@interface NSArray (NSArrayCreation) +@interface NSArray : NSObject + (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; @end -@interface NSDictionary +@interface NSDictionary : NSObject + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; @end +@interface NSString : NSObject +@end + void fixes() { id arr = @[ 17, // expected-error{{numeric literal must be prefixed by '@' in a collection}} diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/all.h b/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/all.h new file mode 100644 index 000000000000..0f3f0be3c764 --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/all.h @@ -0,0 +1 @@ +#include "warn.h" diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/warn.h b/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/warn.h new file mode 100644 index 000000000000..def881aa137e --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/libs/boost/warn.h @@ -0,0 +1,2 @@ +#if BOOST +#endif diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/all.h b/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/all.h new file mode 100644 index 000000000000..0f3f0be3c764 --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/all.h @@ -0,0 +1 @@ +#include "warn.h" diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/warn.h b/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/warn.h new file mode 100644 index 000000000000..6a0c102ea45d --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/libs/mylib/warn.h @@ -0,0 +1,2 @@ +#if MYLIB +#endif diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/src/all.h b/test/Frontend/Inputs/SystemHeaderPrefix/src/all.h new file mode 100644 index 000000000000..ace9699f85b3 --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/src/all.h @@ -0,0 +1,6 @@ +#include "libs/boost/all.h" +#include "libs/mylib/all.h" + +#include "libs/boost/warn.h" +#include "libs/mylib/warn.h" +#include "src/warn.h" diff --git a/test/Frontend/Inputs/SystemHeaderPrefix/src/warn.h b/test/Frontend/Inputs/SystemHeaderPrefix/src/warn.h new file mode 100644 index 000000000000..91e2591855e9 --- /dev/null +++ b/test/Frontend/Inputs/SystemHeaderPrefix/src/warn.h @@ -0,0 +1,2 @@ +#if SRC +#endif diff --git a/test/Frontend/Inputs/rewrite-includes1.h b/test/Frontend/Inputs/rewrite-includes1.h new file mode 100644 index 000000000000..1b6c80d5f435 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes1.h @@ -0,0 +1,3 @@ +#pragma clang system_header +included_line1 +#include "rewrite-includes2.h" diff --git a/test/Frontend/Inputs/rewrite-includes2.h b/test/Frontend/Inputs/rewrite-includes2.h new file mode 100644 index 000000000000..1114e51cc135 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes2.h @@ -0,0 +1 @@ +included_line2 diff --git a/test/Frontend/Inputs/rewrite-includes3.h b/test/Frontend/Inputs/rewrite-includes3.h new file mode 100644 index 000000000000..3757bc8b3416 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes3.h @@ -0,0 +1 @@ +included_line3 diff --git a/test/Frontend/Inputs/rewrite-includes4.h b/test/Frontend/Inputs/rewrite-includes4.h new file mode 100644 index 000000000000..b4e25d26f62d --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes4.h @@ -0,0 +1 @@ +included_line4 diff --git a/test/Frontend/Inputs/rewrite-includes5.h b/test/Frontend/Inputs/rewrite-includes5.h new file mode 100644 index 000000000000..934bf413e50f --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes5.h @@ -0,0 +1 @@ +included_line5 diff --git a/test/Frontend/Inputs/rewrite-includes6.h b/test/Frontend/Inputs/rewrite-includes6.h new file mode 100644 index 000000000000..c18e5013affc --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes6.h @@ -0,0 +1,2 @@ +#pragma once +included_line6 diff --git a/test/Frontend/Inputs/rewrite-includes7.h b/test/Frontend/Inputs/rewrite-includes7.h new file mode 100644 index 000000000000..da00d4fb97d8 --- /dev/null +++ b/test/Frontend/Inputs/rewrite-includes7.h @@ -0,0 +1,4 @@ +#ifndef REWRITE_INCLUDES_7 +#define REWRITE_INCLUDES_7 +included_line7 +#endif diff --git a/test/Frontend/rewrite-includes-missing.c b/test/Frontend/rewrite-includes-missing.c new file mode 100644 index 000000000000..b79bbd9ca8b5 --- /dev/null +++ b/test/Frontend/rewrite-includes-missing.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -verify -E -frewrite-includes %s -o - | FileCheck -strict-whitespace %s + +#include "foobar.h" // expected-error {{'foobar.h' file not found}} +// CHECK: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "foobar.h" +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 4 "{{.*}}rewrite-includes-missing.c" 2{{$}} diff --git a/test/Frontend/rewrite-includes.c b/test/Frontend/rewrite-includes.c new file mode 100644 index 000000000000..546a2c44af2c --- /dev/null +++ b/test/Frontend/rewrite-includes.c @@ -0,0 +1,145 @@ +// RUN: %clang_cc1 -verify -E -frewrite-includes -DFIRST -I %S/Inputs %s -o - | FileCheck -strict-whitespace %s +// RUN: %clang_cc1 -verify -E -frewrite-includes -P -DFIRST -I %S/Inputs %s -o - | FileCheck -check-prefix=CHECKNL -strict-whitespace %s +// STARTCOMPARE +#define A(a,b) a ## b +A(1,2) +#include "rewrite-includes1.h" +#ifdef FIRST +#define HEADER "rewrite-includes3.h" +#include HEADER +#else +#include "rewrite-includes4.h" +#endif +#/**/include /**/ "rewrite-includes5.h" /**/ \ + +#include "rewrite-includes6.h" // comment + +#include "rewrite-includes6.h" /* comment + continues */ +#include "rewrite-includes7.h" +#include "rewrite-includes7.h" +// ENDCOMPARE +// CHECK: {{^}}// STARTCOMPARE{{$}} +// CHECK-NEXT: {{^}}#define A(a,b) a ## b{{$}} +// CHECK-NEXT: {{^}}A(1,2){{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes1.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes1.h" 1{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#pragma clang system_header{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs[/\\]}}rewrite-includes1.h" 3{{$}} +// CHECK-NEXT: {{^}}included_line1{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes2.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes2.h" 1 3{{$}} +// CHECK-NEXT: {{^}}included_line2{{$}} +// CHECK-NEXT: {{^}}# 4 "{{.*[/\\]Inputs[/\\]}}rewrite-includes1.h" 2 3{{$}} +// CHECK-NEXT: {{^}}# 7 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#ifdef FIRST{{$}} +// CHECK-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include HEADER{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes3.h" 1{{$}} +// CHECK-NEXT: {{^}}included_line3{{$}} +// CHECK-NEXT: {{^}}# 10 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#else{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes4.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 12 "{{.*}}rewrite-includes.c"{{$}} +// CHECK-NEXT: {{^}}#endif{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}} +// CHECK-NEXT: {{^}} {{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes5.h" 1{{$}} +// CHECK-NEXT: {{^}}included_line5{{$}} +// CHECK-NEXT: {{^}}# 15 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes6.h" 1{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#pragma once{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 2 "{{.*[/\\]Inputs[/\\]}}rewrite-includes6.h"{{$}} +// CHECK-NEXT: {{^}}included_line6{{$}} +// CHECK-NEXT: {{^}}# 16 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}} {{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}} +// CHECK-NEXT: {{^}} continues */{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 19 "{{.*}}rewrite-includes.c"{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 1 "{{.*[/\\]Inputs[/\\]}}rewrite-includes7.h" 1{{$}} +// CHECK-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}} +// CHECK-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}} +// CHECK-NEXT: {{^}}included_line7{{$}} +// CHECK-NEXT: {{^}}#endif{{$}} +// CHECK-NEXT: {{^}}# 20 "{{.*}}rewrite-includes.c" 2{{$}} +// CHECK-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECK-NEXT: {{^}}# 21 "{{.*}}rewrite-includes.c"{{$}} +// CHECK-NEXT: {{^}}// ENDCOMPARE{{$}} + +// CHECKNL: {{^}}// STARTCOMPARE{{$}} +// CHECKNL-NEXT: {{^}}#define A(a,b) a ## b{{$}} +// CHECKNL-NEXT: {{^}}A(1,2){{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes1.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#pragma clang system_header{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line1{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes2.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line2{{$}} +// CHECKNL-NEXT: {{^}}#ifdef FIRST{{$}} +// CHECKNL-NEXT: {{^}}#define HEADER "rewrite-includes3.h"{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include HEADER{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line3{{$}} +// CHECKNL-NEXT: {{^}}#else{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes4.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#endif{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#/**/include /**/ "rewrite-includes5.h" /**/ {{\\}}{{$}} +// CHECKNL-NEXT: {{^}} {{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line5{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" // comment{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#pragma once{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}included_line6{{$}} +// CHECKNL-NEXT: {{^}} {{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes6.h" /* comment{{$}} +// CHECKNL-NEXT: {{^}} continues */{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#ifndef REWRITE_INCLUDES_7{{$}} +// CHECKNL-NEXT: {{^}}#define REWRITE_INCLUDES_7{{$}} +// CHECKNL-NEXT: {{^}}included_line7{{$}} +// CHECKNL-NEXT: {{^}}#endif{{$}} +// CHECKNL-NEXT: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}#include "rewrite-includes7.h"{{$}} +// CHECKNL-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}} +// CHECKNL-NEXT: {{^}}// ENDCOMPARE{{$}} diff --git a/test/Frontend/system-header-prefix.c b/test/Frontend/system-header-prefix.c new file mode 100644 index 000000000000..31194d96e58c --- /dev/null +++ b/test/Frontend/system-header-prefix.c @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -isystem-prefix libs/ -ino-system-prefix libs/mylib/ -I%S/Inputs/SystemHeaderPrefix -Wundef -E %s 2>&1 | FileCheck %s + +#include "src/all.h" + +// CHECK-NOT: BOOST +// CHECK: libs/mylib/warn.h:1:5: warning: 'MYLIB' is not defined, evaluates to 0 +// CHECK-NOT: BOOST +// CHECK: libs/mylib/warn.h:1:5: warning: 'MYLIB' is not defined, evaluates to 0 +// CHECK-NOT: BOOST +// CHECK: src/warn.h:1:5: warning: 'SRC' is not defined, evaluates to 0 +// CHECK-NOT: BOOST diff --git a/test/Frontend/verify-directive.h b/test/Frontend/verify-directive.h new file mode 100644 index 000000000000..cb405869b050 --- /dev/null +++ b/test/Frontend/verify-directive.h @@ -0,0 +1,2 @@ +// Check that directives inside includes are included! +// expected-error@1 {{include file test}} diff --git a/test/Frontend/verify-fatal.c b/test/Frontend/verify-fatal.c new file mode 100644 index 000000000000..0e74032a3afe --- /dev/null +++ b/test/Frontend/verify-fatal.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -Wfatal-errors -verify %s 2>&1 | FileCheck %s + +#error first fatal +// expected-error@-1 {{first fatal}} + +#error second fatal +// expected-error@-1 {{second fatal}} + + +// CHECK: error: 'error' diagnostics expected but not seen: +// CHECK-NEXT: Line 6 (directive at {{.*}}verify-fatal.c:7): second fatal +// CHECK-NEXT: 1 error generated. diff --git a/test/Frontend/verify.c b/test/Frontend/verify.c new file mode 100644 index 000000000000..f8d0f4282b4a --- /dev/null +++ b/test/Frontend/verify.c @@ -0,0 +1,125 @@ +// RUN: %clang_cc1 -DTEST1 -verify %s +// RUN: %clang_cc1 -DTEST2 -verify %s 2>&1 | FileCheck -check-prefix=CHECK2 %s +// RUN: %clang_cc1 -DTEST3 -verify %s 2>&1 | FileCheck -check-prefix=CHECK3 %s +// RUN: %clang_cc1 -DTEST4 -verify %s 2>&1 | FileCheck -check-prefix=CHECK4 %s +// RUN: %clang_cc1 -DTEST5 -verify %s 2>&1 | FileCheck -check-prefix=CHECK5 %s + +// expected-warning@ malformed +// expected-error@7 1 {{missing or invalid line number}} + +// expected-warning@0 malformed +// expected-error@10 {{missing or invalid line number}} + +// expected-warning@-50 malformed +// expected-error@13 {{missing or invalid line number}} + +// expected-warning malformed +// expected-error@16 {{cannot find start}} + +// expected-error 0+ {{should also be ignored}} + +#ifdef TEST1 +#if 0 +// expected-error {{should be ignored}} +#endif + +#error should not be ignored +// expected-error@-1 1+ {{should not be ignored}} + +#line 90 +unexpected a; // expected-error@+0 + {{unknown type}} + +#line 60 +unexpected b; // expected-error@33 1-1 {{unknown type}} + +// expected-error@+2 {{file not found}} check that multi-line handled correctly: \ + +#include "missing_header_file.include" +#endif + +#ifdef TEST2 +#define MACRO some_value // expected-error {{define_error}} +#undef MACRO extra_token // expected-warning {{undef_error}} +#line -2 // expected-error {{line_error}} +#error AAA // expected-error {{BBB}} <- this shall be part of diagnostic +#warning CCC // expected-warning {{DDD}} <- this shall be part of diagnostic + +#if 0 +// This is encapsulated in "#if 0" so that the expected-* checks below +// are not inadvertently included in the diagnostic checking! + +// CHECK2: error: 'error' diagnostics expected but not seen: +// CHECK2-NEXT: Line 41: define_error +// CHECK2-NEXT: Line 43: line_error +// CHECK2-NEXT: error: 'error' diagnostics seen but not expected: +// CHECK2-NEXT: Line 43: #line directive requires a positive integer argument +// CHECK2-NEXT: Line 44: AAA // expected-error {{[{][{]BBB[}][}]}} <- this shall be part of diagnostic +// CHECK2-NEXT: error: 'warning' diagnostics expected but not seen: +// CHECK2-NEXT: Line 42: undef_error +// CHECK2-NEXT: error: 'warning' diagnostics seen but not expected: +// CHECK2-NEXT: Line 42: extra tokens at end of #undef directive +// CHECK2-NEXT: Line 45: CCC // expected-warning {{[{][{]DDD[}][}]}} <- this shall be part of diagnostic +// CHECK2-NEXT: 7 errors generated. +#endif +#endif + +#ifdef TEST3 +#ifndef TEST3 // expected-note {{line_67}} + // expected-note {{line_68_ignored}} +# ifdef UNDEFINED // expected-note {{line_69_ignored}} +# endif // expected-note {{line_70_ignored}} +#elif defined(TEST3) // expected-note {{line_71}} +# if 1 // expected-note {{line_72}} + // expected-note {{line_73}} +# else // expected-note {{line_74}} + // expected-note {{line_75_ignored}} +# ifndef TEST3 // expected-note {{line_76_ignored}} +# endif // expected-note {{line_77_ignored}} +# endif // expected-note {{line_78}} +#endif + +// CHECK3: error: 'note' diagnostics expected but not seen: +// CHECK3-NEXT: Line 67: line_67 +// CHECK3-NEXT: Line 71: line_71 +// CHECK3-NEXT: Line 72: line_72 +// CHECK3-NEXT: Line 73: line_73 +// CHECK3-NEXT: Line 74: line_74 +// CHECK3-NEXT: Line 78: line_78 +// CHECK3-NEXT: 6 errors generated. +#endif + +#ifdef TEST4 +#include "missing_header_file.include" // expected-error {{include_error}} + +// CHECK4: error: 'error' diagnostics expected but not seen: +// CHECK4-NEXT: Line 92: include_error +// CHECK4-NEXT: error: 'error' diagnostics seen but not expected: +// CHECK4-NEXT: Line 92: 'missing_header_file.include' file not found +// CHECK4-NEXT: 2 errors generated. +#endif + +#ifdef TEST5 +#include "verify-directive.h" +// expected-error@50 {{source file test}} + +// CHECK5: error: 'error' diagnostics expected but not seen: +// CHECK5-NEXT: Line 1 (directive at {{.*}}verify-directive.h:2): include file test +// CHECK5-NEXT: Line 50 (directive at {{.*}}verify.c:103): source file test +// CHECK5-NEXT: 2 errors generated. +#endif + +#if 0 +// RUN: %clang_cc1 -verify %t.invalid 2>&1 | FileCheck -check-prefix=CHECK6 %s + +// CHECK6: error: 'error' diagnostics seen but not expected: +// CHECK6-NEXT: (frontend): error reading '{{.*}}verify.c.tmp.invalid' +// CHECK6-NEXT: 1 error generated. + +// RUN: echo -e '//expected-error@2{{1}}\n#error 2' | %clang_cc1 -verify 2>&1 | FileCheck -check-prefix=CHECK7 %s + +// CHECK7: error: 'error' diagnostics expected but not seen: +// CHECK7-NEXT: Line 2 (directive at <stdin>:1): 1 +// CHECK7-NEXT: error: 'error' diagnostics seen but not expected: +// CHECK7-NEXT: Line 2: 2 +// CHECK7-NEXT: 2 errors generated. +#endif diff --git a/test/Frontend/verify2.c b/test/Frontend/verify2.c new file mode 100644 index 000000000000..a1c797581ed9 --- /dev/null +++ b/test/Frontend/verify2.c @@ -0,0 +1,19 @@ +#if 0 +// RUN: %clang_cc1 -verify %s 2>&1 | FileCheck %s + +// Please note that all comments are inside "#if 0" blocks so that +// VerifyDiagnosticConsumer sees no comments while processing this +// test-case. +#endif + +#include "verify2.h" +#error source + +#if 0 +// expected-error {{should be ignored}} + +// CHECK: error: 'error' diagnostics seen but not expected: +// CHECK-NEXT: Line 1: header +// CHECK-NEXT: Line 10: source +// CHECK-NEXT: 2 errors generated. +#endif diff --git a/test/Frontend/verify2.h b/test/Frontend/verify2.h new file mode 100644 index 000000000000..8acbf6efdfe2 --- /dev/null +++ b/test/Frontend/verify2.h @@ -0,0 +1,5 @@ +#error header + +#if 0 +// expected-error {{should be ignored}} +#endif diff --git a/test/Headers/ms-null-ms-header-vs-stddef.cpp b/test/Headers/ms-null-ms-header-vs-stddef.cpp new file mode 100644 index 000000000000..7efa871da90e --- /dev/null +++ b/test/Headers/ms-null-ms-header-vs-stddef.cpp @@ -0,0 +1,16 @@ +// RUN: %clang -fsyntax-only -target i686-pc-win32 %s +// RUN: %clang -fsyntax-only -target i386-mingw32 %s + +// Something in MSVC's headers (pulled in e.g. by <crtdefs.h>) defines __null +// to something, mimick that. +#define __null + +#include <stddef.h> + +// __null is used as a type annotation in MS headers, with __null defined to +// nothing in regular builds. This should continue to work even with stddef.h +// included. +void f(__null void* p) { } + +// NULL should work fine even with __null defined to nothing. +void* p = NULL; diff --git a/test/Index/Inputs/CommentXML/invalid-function-01.xml b/test/Index/Inputs/CommentXML/invalid-function-01.xml new file mode 100644 index 000000000000..85f06695a0ce --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-01.xml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Parameters> +</Parameters> +</Function> diff --git a/test/Index/Inputs/CommentXML/invalid-function-02.xml b/test/Index/Inputs/CommentXML/invalid-function-02.xml new file mode 100644 index 000000000000..700711b0a08e --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-02.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Parameters> + <Parameter> + </Parameter> +</Parameters> +</Function> diff --git a/test/Index/Inputs/CommentXML/invalid-function-03.xml b/test/Index/Inputs/CommentXML/invalid-function-03.xml new file mode 100644 index 000000000000..0c4618f1efec --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-03.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Parameters> + <Parameter> + <Term></Term> + <Definition><Para>Bbb.</Para></Definition> + </Parameter> +</Parameters> +</Function> diff --git a/test/Index/Inputs/CommentXML/invalid-function-04.xml b/test/Index/Inputs/CommentXML/invalid-function-04.xml new file mode 100644 index 000000000000..88dd5a851c0a --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-04.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Parameters> + <Parameter> + <Term> </Term> + <Definition><Para>Bbb.</Para></Definition> + </Parameter> +</Parameters> +</Function> diff --git a/test/Index/Inputs/CommentXML/invalid-function-05.xml b/test/Index/Inputs/CommentXML/invalid-function-05.xml new file mode 100644 index 000000000000..ce96b7d05fe6 --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-05.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Parameters> + <Parameter> + <Term>x1</Term> + </Parameter> +</Parameters> +</Function> diff --git a/test/Index/Inputs/CommentXML/invalid-function-06.xml b/test/Index/Inputs/CommentXML/invalid-function-06.xml new file mode 100644 index 000000000000..5419c677aa0b --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-06.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa <monospaced></monospaced>.</Para></Abstract> +</Function> diff --git a/test/Index/Inputs/CommentXML/invalid-function-07.xml b/test/Index/Inputs/CommentXML/invalid-function-07.xml new file mode 100644 index 000000000000..ce7eccec1e4f --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-07.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Parameters> + <Parameter> + <Name>x1</Name> + <Index>-1</Index> + <Direction isExplicit="0">in</Direction> + <Discussion><Para>Bbb</Para></Discussion> + </Parameter> +</Parameters> +</Function> diff --git a/test/Index/Inputs/CommentXML/invalid-function-08.xml b/test/Index/Inputs/CommentXML/invalid-function-08.xml new file mode 100644 index 000000000000..66e69e817223 --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-08.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Parameters> + <Parameter> + <Name>x1</Name> + <Index>0</Index> + <Direction isExplicit="aaa">in</Direction> + <Discussion><Para>Bbb</Para></Discussion> + </Parameter> +</Parameters> +</Function> diff --git a/test/Index/Inputs/CommentXML/invalid-function-09.xml b/test/Index/Inputs/CommentXML/invalid-function-09.xml new file mode 100644 index 000000000000..39617b6a875d --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-09.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Parameters> + <Parameter> + <Name>x1</Name> + <Index>0</Index> + <Direction isExplicit="0">aaa</Direction> + <Discussion><Para>Bbb</Para></Discussion> + </Parameter> +</Parameters> +</Function> diff --git a/test/Index/Inputs/CommentXML/invalid-function-10.xml b/test/Index/Inputs/CommentXML/invalid-function-10.xml new file mode 100644 index 000000000000..ccce4bbe56b9 --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-10.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<TemplateParameters> + <Parameter> + <Name>x1</Name> + </Parameter> +</TemplateParameters> +</Function> + diff --git a/test/Index/Inputs/CommentXML/invalid-function-11.xml b/test/Index/Inputs/CommentXML/invalid-function-11.xml new file mode 100644 index 000000000000..167911e9e7dc --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-11.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<TemplateParameters> + <Parameter> + <Name>x1</Name> + <Index>aaa</Index> + <Discussion><Para>Bbb</Para></Discussion> + </Parameter> +</TemplateParameters> +</Function> + diff --git a/test/Index/Inputs/CommentXML/invalid-function-12.xml b/test/Index/Inputs/CommentXML/invalid-function-12.xml new file mode 100644 index 000000000000..f5b5e03e33b9 --- /dev/null +++ b/test/Index/Inputs/CommentXML/invalid-function-12.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function templateKind="aaa"> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Function> + diff --git a/test/Index/Inputs/CommentXML/valid-class-01.xml b/test/Index/Inputs/CommentXML/valid-class-01.xml new file mode 100644 index 000000000000..bd893e62d59c --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-class-01.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<Class> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Class> diff --git a/test/Index/Inputs/CommentXML/valid-class-02.xml b/test/Index/Inputs/CommentXML/valid-class-02.xml new file mode 100644 index 000000000000..2e20a921f7bc --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-class-02.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<Class templateKind="template"> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Class> diff --git a/test/Index/Inputs/CommentXML/valid-class-03.xml b/test/Index/Inputs/CommentXML/valid-class-03.xml new file mode 100644 index 000000000000..2ce1a2c98dd8 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-class-03.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<Class templateKind="specialization"> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Class> diff --git a/test/Index/Inputs/CommentXML/valid-class-04.xml b/test/Index/Inputs/CommentXML/valid-class-04.xml new file mode 100644 index 000000000000..da1522d85aab --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-class-04.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<Class templateKind="partialSpecialization"> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Class> diff --git a/test/Index/Inputs/CommentXML/valid-enum-01.xml b/test/Index/Inputs/CommentXML/valid-enum-01.xml new file mode 100644 index 000000000000..e346d738eb69 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-enum-01.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<Enum> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Enum> + diff --git a/test/Index/Inputs/CommentXML/valid-function-01.xml b/test/Index/Inputs/CommentXML/valid-function-01.xml new file mode 100644 index 000000000000..02060e7fb7b2 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-01.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Function> diff --git a/test/Index/Inputs/CommentXML/valid-function-02.xml b/test/Index/Inputs/CommentXML/valid-function-02.xml new file mode 100644 index 000000000000..989d6a7c143d --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-02.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa <bold>bbb</bold> <monospaced>ccc</monospaced> <emphasized>ddd</emphasized>.</Para></Abstract> +</Function> diff --git a/test/Index/Inputs/CommentXML/valid-function-03.xml b/test/Index/Inputs/CommentXML/valid-function-03.xml new file mode 100644 index 000000000000..891211d81c81 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-03.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Parameters> + <Parameter> + <Name>x1</Name> + <Direction isExplicit="0">in</Direction> + <Discussion><Para>Bbb</Para></Discussion> + </Parameter> +</Parameters> +</Function> diff --git a/test/Index/Inputs/CommentXML/valid-function-04.xml b/test/Index/Inputs/CommentXML/valid-function-04.xml new file mode 100644 index 000000000000..b65b3e92ff62 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-04.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Parameters> + <Parameter> + <Name>x1</Name> + <Index>0</Index> + <Direction isExplicit="0">in</Direction> + <Discussion><Para>Bbb</Para></Discussion> + </Parameter> +</Parameters> +</Function> diff --git a/test/Index/Inputs/CommentXML/valid-function-05.xml b/test/Index/Inputs/CommentXML/valid-function-05.xml new file mode 100644 index 000000000000..2dddbd7be227 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-05.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Discussion> + <Para>Ccc</Para> +</Discussion> +</Function> diff --git a/test/Index/Inputs/CommentXML/valid-function-06.xml b/test/Index/Inputs/CommentXML/valid-function-06.xml new file mode 100644 index 000000000000..1df3aa42b8e0 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-06.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<ResultDiscussion><Para>Ccc.</Para></ResultDiscussion> +</Function> diff --git a/test/Index/Inputs/CommentXML/valid-function-07.xml b/test/Index/Inputs/CommentXML/valid-function-07.xml new file mode 100644 index 000000000000..89b8a0ca6fc8 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-07.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<Parameters> + <Parameter> + <Name>x2</Name> + <Index>0</Index> + <Direction isExplicit="0">in</Direction> + <Discussion><Para>Bbb</Para></Discussion> + </Parameter> + <Parameter> + <Name>x3</Name> + <Index>2</Index> + <Direction isExplicit="1">out</Direction> + <Discussion><Para>Ccc</Para></Discussion> + </Parameter> + <Parameter> + <Name>x1</Name> + <Direction isExplicit="1">in,out</Direction> + <Discussion><Para>Ddd</Para></Discussion> + </Parameter> +</Parameters> +<ResultDiscussion><Para>Eee.</Para></ResultDiscussion> +<Discussion> + <Para>Fff</Para> + <Verbatim xml:space="preserve" kind="verbatim">Ggg</Verbatim> +</Discussion> +</Function> + diff --git a/test/Index/Inputs/CommentXML/valid-function-08.xml b/test/Index/Inputs/CommentXML/valid-function-08.xml new file mode 100644 index 000000000000..481a6c06589a --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-08.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<TemplateParameters> + <Parameter> + <Name>x1</Name> + <Index>0</Index> + <Discussion><Para>Bbb</Para></Discussion> + </Parameter> + <Parameter> + <Name>x2</Name> + <Discussion><Para>Ccc</Para></Discussion> + </Parameter> +</TemplateParameters> +</Function> + diff --git a/test/Index/Inputs/CommentXML/valid-function-09.xml b/test/Index/Inputs/CommentXML/valid-function-09.xml new file mode 100644 index 000000000000..cf4cc8fbd7cf --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-09.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function templateKind="template"> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Function> + diff --git a/test/Index/Inputs/CommentXML/valid-function-10.xml b/test/Index/Inputs/CommentXML/valid-function-10.xml new file mode 100644 index 000000000000..4fadf30e6fb1 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-function-10.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<Function templateKind="specialization"> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Function> + diff --git a/test/Index/Inputs/CommentXML/valid-namespace-01.xml b/test/Index/Inputs/CommentXML/valid-namespace-01.xml new file mode 100644 index 000000000000..a73aad5548f6 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-namespace-01.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<Namespace> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Namespace> + diff --git a/test/Index/Inputs/CommentXML/valid-other-01.xml b/test/Index/Inputs/CommentXML/valid-other-01.xml new file mode 100644 index 000000000000..46b8a4676f78 --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-other-01.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8"?> +<Other> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Other> diff --git a/test/Index/Inputs/CommentXML/valid-typedef-01.xml b/test/Index/Inputs/CommentXML/valid-typedef-01.xml new file mode 100644 index 000000000000..1b7da8d83bbf --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-typedef-01.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<Typedef> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Typedef> + diff --git a/test/Index/Inputs/CommentXML/valid-typedef-02.xml b/test/Index/Inputs/CommentXML/valid-typedef-02.xml new file mode 100644 index 000000000000..2a3218906b2d --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-typedef-02.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="utf-8"?> +<Typedef> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +<TemplateParameters> + <Parameter> + <Name>x1</Name> + <Index>0</Index> + <Discussion><Para>Bbb</Para></Discussion> + </Parameter> +</TemplateParameters> +<Parameters> + <Parameter> + <Name>x1</Name> + <Index>0</Index> + <Direction isExplicit="0">in</Direction> + <Discussion><Para>Ccc</Para></Discussion> + </Parameter> +</Parameters> +<ResultDiscussion><Para>Ddd.</Para></ResultDiscussion> +<Discussion> + <Para>Eee.</Para> +</Discussion> +</Typedef> + diff --git a/test/Index/Inputs/CommentXML/valid-variable-01.xml b/test/Index/Inputs/CommentXML/valid-variable-01.xml new file mode 100644 index 000000000000..e17da91da34d --- /dev/null +++ b/test/Index/Inputs/CommentXML/valid-variable-01.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8"?> +<Variable> +<Name>aaa</Name> +<Abstract><Para>Aaa.</Para></Abstract> +</Variable> + diff --git a/test/Index/Inputs/annotate-comments-preprocessor.h b/test/Index/Inputs/annotate-comments-preprocessor.h new file mode 100644 index 000000000000..220f36ede4bf --- /dev/null +++ b/test/Index/Inputs/annotate-comments-preprocessor.h @@ -0,0 +1,2 @@ +/* Meow */ + diff --git a/test/Index/annotate-comments-preprocessor.c b/test/Index/annotate-comments-preprocessor.c new file mode 100644 index 000000000000..202847ff9c91 --- /dev/null +++ b/test/Index/annotate-comments-preprocessor.c @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs %s + +// As long as none of this crashes, we don't care about comments in +// preprocessor directives. + +#include "annotate-comments-preprocessor.h" /* Aaa. */ /* Bbb. */ +#include "annotate-comments-preprocessor.h" /* Aaa. */ +#include "annotate-comments-preprocessor.h" /** Aaa. */ +#include "annotate-comments-preprocessor.h" /**< Aaa. */ +#include "annotate-comments-preprocessor.h" // Aaa. +#include "annotate-comments-preprocessor.h" /// Aaa. +#include "annotate-comments-preprocessor.h" ///< Aaa. + +#define A0 0 +#define A1 1 /* Aaa. */ +#define A2 1 /** Aaa. */ +#define A3 1 /**< Aaa. */ +#define A4 1 // Aaa. +#define A5 1 /// Aaa. +#define A6 1 ///< Aaa. + +int A[] = { A0, A1, A2, A3, A4, A5, A6 }; + +#if A0 /** Aaa. */ +int f(int a1[A1], int a2[A2], int a3[A3], int a4[A4], int a5[A5], int a6[A6]); +#endif /** Aaa. */ + +#if A1 /** Aaa. */ +int g(int a1[A1], int a2[A2], int a3[A3], int a4[A4], int a5[A5], int a6[A6]); +#endif /* Aaa. */ + +#pragma once /** Aaa. */ + +#define FOO \ + do { \ + /* Aaa. */ \ + /** Aaa. */ \ + /**< Aaa. */ \ + ; \ + } while(0) + +void h(void) { + FOO; +} + diff --git a/test/Index/annotate-comments-unterminated.c b/test/Index/annotate-comments-unterminated.c new file mode 100644 index 000000000000..6bba911aac93 --- /dev/null +++ b/test/Index/annotate-comments-unterminated.c @@ -0,0 +1,13 @@ +// RUN: c-index-test -test-load-source all %s | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -check-prefix=ERR %s + +// CHECK: annotate-comments-unterminated.c:9:5: VarDecl=x:{{.*}} RawComment=[/** Aaa. */]{{.*}} BriefComment=[Aaa.] +// CHECK: annotate-comments-unterminated.c:11:5: VarDecl=y:{{.*}} RawComment=[/**< Bbb. */]{{.*}} BriefComment=[Bbb.] +// CHECK-ERR: error: unterminated + +/** Aaa. */ +int x; + +int y; /**< Bbb. */ +/**< Ccc. + * Ddd. diff --git a/test/Index/annotate-comments.cpp b/test/Index/annotate-comments.cpp new file mode 100644 index 000000000000..22724d0b68d7 --- /dev/null +++ b/test/Index/annotate-comments.cpp @@ -0,0 +1,926 @@ +// Run lines are sensitive to line numbers and come below the code. + +#ifndef HEADER +#define HEADER + +// Not a Doxygen comment. NOT_DOXYGEN +void notdoxy1(void); + +/* Not a Doxygen comment. NOT_DOXYGEN */ +void notdoxy2(void); + +/*/ Not a Doxygen comment. NOT_DOXYGEN */ +void notdoxy3(void); + +/** Doxygen comment. isdoxy4 IS_DOXYGEN_SINGLE */ +void isdoxy4(void); + +/** + * Doxygen comment. isdoxy5 IS_DOXYGEN_SINGLE */ +void isdoxy5(void); + +/** + * Doxygen comment. + * isdoxy6 IS_DOXYGEN_SINGLE */ +void isdoxy6(void); + +/** + * Doxygen comment. + * isdoxy7 IS_DOXYGEN_SINGLE + */ +void isdoxy7(void); + +/*! Doxygen comment. isdoxy8 IS_DOXYGEN_SINGLE */ +void isdoxy8(void); + +/// Doxygen comment. isdoxy9 IS_DOXYGEN_SINGLE +void isdoxy9(void); + +// Not a Doxygen comment. NOT_DOXYGEN +/// Doxygen comment. isdoxy10 IS_DOXYGEN_SINGLE +void isdoxy10(void); + +/// Doxygen comment. isdoxy11 IS_DOXYGEN_SINGLE +// Not a Doxygen comment. NOT_DOXYGEN +void isdoxy11(void); + +/** Doxygen comment. isdoxy12 IS_DOXYGEN_SINGLE */ +/* Not a Doxygen comment. NOT_DOXYGEN */ +void isdoxy12(void); + +/// Doxygen comment. isdoxy13 IS_DOXYGEN_START +/// Doxygen comment. IS_DOXYGEN_END +void isdoxy13(void); + +/// Doxygen comment. isdoxy14 IS_DOXYGEN_START +/// Blah-blah-blah. +/// Doxygen comment. IS_DOXYGEN_END +void isdoxy14(void); + +/// Doxygen comment. isdoxy15 IS_DOXYGEN_START +/** Blah-blah-blah */ +/// Doxygen comment. IS_DOXYGEN_END +void isdoxy15(void); + +/** Blah-blah-blah. isdoxy16 IS_DOXYGEN_START *//** Blah */ +/// Doxygen comment. IS_DOXYGEN_END +void isdoxy16(void); + +/// isdoxy17 IS_DOXYGEN_START +// Not a Doxygen comment, but still picked up. +/// IS_DOXYGEN_END +void isdoxy17(void); + +unsigned +// NOT_DOXYGEN +/// isdoxy18 IS_DOXYGEN_START +// Not a Doxygen comment, but still picked up. +/// IS_DOXYGEN_END +// NOT_DOXYGEN +int isdoxy18(void); + +//! It all starts here. isdoxy19 IS_DOXYGEN_START +/*! It's a little odd to continue line this, + * + * but we need more multi-line comments. */ +/// This comment comes before my other comments +/** This is a block comment that is associated with the function f. It + * runs for three lines. IS_DOXYGEN_END + */ +void isdoxy19(int, int); + +// NOT IN THE COMMENT NOT_DOXYGEN +/// This is a BCPL comment. isdoxy20 IS_DOXYGEN_START +/// It has only two lines. +/** But there are other blocks that are part of the comment, too. IS_DOXYGEN_END */ +void isdoxy20(int); + +void notdoxy21(int); ///< This is a member comment. isdoxy21 IS_DOXYGEN_NOT_ATTACHED + +void notdoxy22(int); /*!< This is a member comment. isdoxy22 IS_DOXYGEN_NOT_ATTACHED */ + +void notdoxy23(int); /**< This is a member comment. isdoxy23 IS_DOXYGEN_NOT_ATTACHED */ + +void notdoxy24(int); // NOT_DOXYGEN + +/// IS_DOXYGEN_SINGLE +struct isdoxy25 { +}; + +struct test26 { + /// IS_DOXYGEN_SINGLE + int isdoxy26; +}; + +struct test27 { + int isdoxy27; ///< IS_DOXYGEN_SINGLE +}; + +struct notdoxy28 { +}; ///< IS_DOXYGEN_NOT_ATTACHED + +/// IS_DOXYGEN_SINGLE +enum isdoxy29 { +}; + +enum notdoxy30 { +}; ///< IS_DOXYGEN_NOT_ATTACHED + +/// IS_DOXYGEN_SINGLE +namespace isdoxy31 { +}; + +namespace notdoxy32 { +}; ///< IS_DOXYGEN_NOT_ATTACHED + +class test33 { + ///< IS_DOXYGEN_NOT_ATTACHED + int isdoxy33; ///< isdoxy33 IS_DOXYGEN_SINGLE + int isdoxy34; ///< isdoxy34 IS_DOXYGEN_SINGLE + + ///< IS_DOXYGEN_NOT_ATTACHED + int isdoxy35, ///< isdoxy35 IS_DOXYGEN_SINGLE + isdoxy36; ///< isdoxy36 IS_DOXYGEN_SINGLE + + ///< IS_DOXYGEN_NOT_ATTACHED + int isdoxy37 ///< isdoxy37 IS_DOXYGEN_SINGLE + , isdoxy38 ///< isdoxy38 IS_DOXYGEN_SINGLE + , isdoxy39; ///< isdoxy39 IS_DOXYGEN_SINGLE +}; + +// Verified that Doxygen attaches these. + +/// isdoxy40 IS_DOXYGEN_SINGLE +// NOT_DOXYGEN +void isdoxy40(int); + +unsigned +/// isdoxy41 IS_DOXYGEN_SINGLE +// NOT_DOXYGEN +int isdoxy41(int); + +class test42 { + int isdoxy42; /* NOT_DOXYGEN */ ///< isdoxy42 IS_DOXYGEN_SINGLE +}; + +/// IS_DOXYGEN_START +/// It is fine to have a command at the end of comment. +///\brief +/// +/// Some malformed command. +/* \*/ +/** + * \brief Aaa aaaaaaa aaaa. + * IS_DOXYGEN_END + */ +void isdoxy43(void); + +/// IS_DOXYGEN_START Aaa bbb +/// ccc. +/// +/// Ddd eee. +/// Fff. +/// +/// Ggg. IS_DOXYGEN_END +void isdoxy44(void); + +/// IS_DOXYGEN_START Aaa bbb +/// ccc. +/// +/// \brief +/// Ddd eee. +/// Fff. +/// +/// Ggg. IS_DOXYGEN_END +void isdoxy45(void); + +/// IS_DOXYGEN_START Aaa bbb +/// ccc. +/// +/// \short +/// Ddd eee. +/// Fff. +/// +/// Ggg. IS_DOXYGEN_END +void isdoxy46(void); + +/// IS_DOXYGEN_NOT_ATTACHED +#define FOO +void notdoxy47(void); + +/// IS_DOXYGEN_START Aaa bbb +/// \param ccc +/// \returns ddd IS_DOXYGEN_END +void isdoxy48(int); + +/// \brief IS_DOXYGEN_START Aaa +/// \returns bbb IS_DOXYGEN_END +void isdoxy49(void); + +/// \param ccc IS_DOXYGEN_START +/// \returns ddd IS_DOXYGEN_END +void isdoxy50(int); + +/// Aaa. +void comment_to_html_conversion_1(); + +/// \brief Aaa. +void comment_to_html_conversion_2(); + +/// \short Aaa. +void comment_to_html_conversion_3(); + +/// Aaa. +/// +/// \brief Bbb. +void comment_to_html_conversion_4(); + +/// Aaa. +/// +/// \brief Bbb. +/// +/// Ccc. +void comment_to_html_conversion_5(); + +/// \brief Aaa. +/// \brief Bbb. +void comment_to_html_conversion_6(); + +/// Aaa. +/// +/// \return Bbb. +void comment_to_html_conversion_7(); + +/// Aaa. +/// +/// \returns Bbb. +void comment_to_html_conversion_8(); + +/// Aaa. +/// +/// \result Bbb. +void comment_to_html_conversion_9(); + +/// \returns Aaa. +/// \returns Bbb. +void comment_to_html_conversion_10(); + +/// Aaa. +/// +/// Bbb. +/// +/// \returns Ccc. +void comment_to_html_conversion_11(); + +/// \param +void comment_to_html_conversion_12(int x1); + +/// \param x1 Aaa. +void comment_to_html_conversion_13(int x1); + +/// \param zzz Aaa. +void comment_to_html_conversion_14(int x1); + +/// \param x2 Bbb. +/// \param x1 Aaa. +void comment_to_html_conversion_15(int x1, int x2); + +/// \param x2 Bbb. +/// \param zzz Aaa. +/// \param x1 Aaa. +void comment_to_html_conversion_16(int x1, int x2); + +/// \tparam +/// \param aaa Blah blah +template<typename T> +void comment_to_html_conversion_17(T aaa); + +/// \tparam T +/// \param aaa Blah blah +template<typename T> +void comment_to_html_conversion_18(T aaa); + +/// \tparam T2 Bbb +/// \tparam T1 Aaa +template<typename T1, typename T2> +void comment_to_html_conversion_19(T1 aaa, T2 bbb); + +/// \tparam T2 Bbb +/// \tparam U Zzz +/// \tparam V Ccc +/// \tparam T1 Aaa +template<typename T1, typename T2, int V> +void comment_to_html_conversion_20(T1 aaa, T2 bbb); + +/// \tparam TTT Ddd +/// \tparam C Ccc +/// \tparam T Aaa +/// \tparam TT Bbb +template<template<template<typename T> class TT, class C> class TTT> +void comment_to_html_conversion_21(); + +/// \brief Aaa. +/// +/// Bbb. +/// +/// \param x2 Ddd. +/// \param x1 Ccc. +/// \returns Eee. +void comment_to_html_conversion_22(int x1, int x2); + +/// <br><a href="http://example.com/">Aaa</a> +void comment_to_html_conversion_23(); + +/// \verbatim +/// <a href="http://example.com/">Aaa</a> +/// <a href='http://example.com/'>Aaa</a> +/// \endverbatim +void comment_to_html_conversion_24(); + +/// \function foo +/// \class foo +/// \method foo +/// \interface foo +/// Blah blah. +void comment_to_html_conversion_25(); + +/// \b Aaa +void comment_to_html_conversion_26(); + +/// \c Aaa \p Bbb +void comment_to_html_conversion_27(); + +/// \a Aaa \e Bbb \em Ccc +void comment_to_html_conversion_28(); + +/// \a 1<2 \e 3<4 \em 5<6 \param 7<8 aaa \tparam 9<10 bbb +void comment_to_html_conversion_29(); + +/// \\ \@ \& \$ \# \< \> \% \" \. \:: +void comment_to_html_conversion_30(); + +/// & < > " +void comment_to_html_conversion_31(); + +/// <em>0<i</em> +void comment_to_html_conversion_32(); + +/// Aaa. +class comment_to_xml_conversion_01 { + /// \param aaa Blah blah. + comment_to_xml_conversion_01(int aaa); + + /// Aaa. + ~comment_to_xml_conversion_01(); + + /// \param aaa Blah blah. + int comment_to_xml_conversion_02(int aaa); + + /// \param aaa Blah blah. + static int comment_to_xml_conversion_03(int aaa); + + /// Aaa. + int comment_to_xml_conversion_04; + + /// Aaa. + static int comment_to_xml_conversion_05; + + /// \param aaa Blah blah. + void operator()(int aaa); + + /// Aaa. + operator bool(); + + /// Aaa. + typedef int comment_to_xml_conversion_06; + + /// Aaa. + using comment_to_xml_conversion_07 = int; + + template<typename T, typename U> + class comment_to_xml_conversion_08 { }; + + /// Aaa. + template<typename T> + using comment_to_xml_conversion_09 = comment_to_xml_conversion_08<T, int>; +}; + +/// Aaa. +template<typename T, typename U> +void comment_to_xml_conversion_10(T aaa, U bbb); + +/// Aaa. +template<> +void comment_to_xml_conversion_10(int aaa, int bbb); + +/// Aaa. +template<typename T, typename U> +class comment_to_xml_conversion_11 { }; + +/// Aaa. +template<typename T> +class comment_to_xml_conversion_11<T, int> { }; + +/// Aaa. +template<> +class comment_to_xml_conversion_11<int, int> { }; + +/// Aaa. +int comment_to_xml_conversion_12; + +/// Aaa. +namespace comment_to_xml_conversion_13 { + /// Aaa. + namespace comment_to_xml_conversion_14 { + } +} + +/// Aaa. +enum comment_to_xml_conversion_15 { + /// Aaa. + comment_to_xml_conversion_16 +}; + +/// Aaa. +enum class comment_to_xml_conversion_17 { + /// Aaa. + comment_to_xml_conversion_18 +}; + +#endif + +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: %clang_cc1 -x c++ -std=c++11 -emit-pch -o %t/out.pch %s +// RUN: %clang_cc1 -x c++ -std=c++11 -include-pch %t/out.pch -fsyntax-only %s + +// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s -std=c++11 > %t/out.c-index-direct +// RUN: c-index-test -test-load-tu %t/out.pch all > %t/out.c-index-pch + +// RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-direct +// RUN: FileCheck %s -check-prefix=WRONG < %t/out.c-index-pch + +// Declarations without Doxygen comments should not pick up some Doxygen comments. +// WRONG-NOT: notdoxy{{.*}}Comment= +// WRONG-NOT: test{{.*}}Comment= + +// Non-Doxygen comments should not be attached to anything. +// WRONG-NOT: NOT_DOXYGEN + +// Some Doxygen comments are not attached to anything. +// WRONG-NOT: IS_DOXYGEN_NOT_ATTACHED + +// Ensure we don't pick up extra comments. +// WRONG-NOT: IS_DOXYGEN_START{{.*}}IS_DOXYGEN_START{{.*}}BriefComment= +// WRONG-NOT: IS_DOXYGEN_END{{.*}}IS_DOXYGEN_END{{.*}}BriefComment= +// +// Ensure that XML is not invalid +// WRONG-NOT: CommentXMLInvalid + +// RUN: FileCheck %s < %t/out.c-index-direct +// RUN: FileCheck %s < %t/out.c-index-pch + +// CHECK: annotate-comments.cpp:16:6: FunctionDecl=isdoxy4:{{.*}} isdoxy4 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:20:6: FunctionDecl=isdoxy5:{{.*}} isdoxy5 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:25:6: FunctionDecl=isdoxy6:{{.*}} isdoxy6 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:31:6: FunctionDecl=isdoxy7:{{.*}} isdoxy7 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:34:6: FunctionDecl=isdoxy8:{{.*}} isdoxy8 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:37:6: FunctionDecl=isdoxy9:{{.*}} isdoxy9 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:41:6: FunctionDecl=isdoxy10:{{.*}} isdoxy10 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:53:6: FunctionDecl=isdoxy13:{{.*}} isdoxy13 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:58:6: FunctionDecl=isdoxy14:{{.*}} isdoxy14 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:63:6: FunctionDecl=isdoxy15:{{.*}} isdoxy15 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:67:6: FunctionDecl=isdoxy16:{{.*}} isdoxy16 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:72:6: FunctionDecl=isdoxy17:{{.*}} isdoxy17 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:80:5: FunctionDecl=isdoxy18:{{.*}} isdoxy18 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:90:6: FunctionDecl=isdoxy19:{{.*}} isdoxy19 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:96:6: FunctionDecl=isdoxy20:{{.*}} isdoxy20 IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END +// CHECK: annotate-comments.cpp:107:8: StructDecl=isdoxy25:{{.*}} IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:112:7: FieldDecl=isdoxy26:{{.*}} IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:116:7: FieldDecl=isdoxy27:{{.*}} IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:123:6: EnumDecl=isdoxy29:{{.*}} IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:130:11: Namespace=isdoxy31:{{.*}} IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:138:7: FieldDecl=isdoxy33:{{.*}} isdoxy33 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:139:7: FieldDecl=isdoxy34:{{.*}} isdoxy34 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:142:7: FieldDecl=isdoxy35:{{.*}} isdoxy35 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:143:7: FieldDecl=isdoxy36:{{.*}} isdoxy36 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:146:7: FieldDecl=isdoxy37:{{.*}} isdoxy37 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:147:7: FieldDecl=isdoxy38:{{.*}} isdoxy38 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:148:7: FieldDecl=isdoxy39:{{.*}} isdoxy39 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:155:6: FunctionDecl=isdoxy40:{{.*}} isdoxy40 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:160:5: FunctionDecl=isdoxy41:{{.*}} isdoxy41 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:163:7: FieldDecl=isdoxy42:{{.*}} isdoxy42 IS_DOXYGEN_SINGLE +// CHECK: annotate-comments.cpp:176:6: FunctionDecl=isdoxy43:{{.*}} IS_DOXYGEN_START{{.*}} IS_DOXYGEN_END + +// CHECK: annotate-comments.cpp:185:6: FunctionDecl=isdoxy44:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb ccc.] +// CHECK: annotate-comments.cpp:195:6: FunctionDecl=isdoxy45:{{.*}} BriefComment=[Ddd eee. Fff.] +// CHECK: annotate-comments.cpp:205:6: FunctionDecl=isdoxy46:{{.*}} BriefComment=[Ddd eee. Fff.] +// CHECK: annotate-comments.cpp:214:6: FunctionDecl=isdoxy48:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa bbb] +// CHECK: annotate-comments.cpp:218:6: FunctionDecl=isdoxy49:{{.*}} BriefComment=[IS_DOXYGEN_START Aaa] +// CHECK: annotate-comments.cpp:222:6: FunctionDecl=isdoxy50:{{.*}} BriefComment=[Returns ddd IS_DOXYGEN_END] + +// CHECK: annotate-comments.cpp:225:6: FunctionDecl=comment_to_html_conversion_1:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Aaa.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="225" column="6"><Name>comment_to_html_conversion_1</Name><USR>c:@F@comment_to_html_conversion_1#</USR><Abstract><Para> Aaa.</Para></Abstract></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])))] +// CHECK: annotate-comments.cpp:228:6: FunctionDecl=comment_to_html_conversion_2:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Aaa.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="228" column="6"><Name>comment_to_html_conversion_2</Name><USR>c:@F@comment_to_html_conversion_2#</USR><Abstract><Para> Aaa.</Para></Abstract></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:231:6: FunctionDecl=comment_to_html_conversion_3:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Aaa.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="231" column="6"><Name>comment_to_html_conversion_3</Name><USR>c:@F@comment_to_html_conversion_3#</USR><Abstract><Para> Aaa.</Para></Abstract></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[short] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:236:6: FunctionDecl=comment_to_html_conversion_4:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Bbb.</p><p> Aaa.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="236" column="6"><Name>comment_to_html_conversion_4</Name><USR>c:@F@comment_to_html_conversion_4#</USR><Abstract><Para> Bbb.</Para></Abstract><Discussion><Para> Aaa.</Para></Discussion></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:243:6: FunctionDecl=comment_to_html_conversion_5:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Bbb.</p><p> Aaa.</p><p> Ccc.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="243" column="6"><Name>comment_to_html_conversion_5</Name><USR>c:@F@comment_to_html_conversion_5#</USR><Abstract><Para> Bbb.</Para></Abstract><Discussion><Para> Aaa.</Para><Para> Ccc.</Para></Discussion></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))) +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ccc.])))] +// CHECK: annotate-comments.cpp:247:6: FunctionDecl=comment_to_html_conversion_6:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Aaa. </p><p class="para-brief"> Bbb.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="247" column="6"><Name>comment_to_html_conversion_6</Name><USR>c:@F@comment_to_html_conversion_6#</USR><Abstract><Para> Aaa. </Para></Abstract><Discussion><Para> Bbb.</Para></Discussion></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:252:6: FunctionDecl=comment_to_html_conversion_7:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Aaa.</p><p class="para-returns"><span class="word-returns">Returns</span> Bbb.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="252" column="6"><Name>comment_to_html_conversion_7</Name><USR>c:@F@comment_to_html_conversion_7#</USR><Abstract><Para> Aaa.</Para></Abstract><ResultDiscussion><Para> Bbb.</Para></ResultDiscussion></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[return] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:257:6: FunctionDecl=comment_to_html_conversion_8:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Aaa.</p><p class="para-returns"><span class="word-returns">Returns</span> Bbb.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="257" column="6"><Name>comment_to_html_conversion_8</Name><USR>c:@F@comment_to_html_conversion_8#</USR><Abstract><Para> Aaa.</Para></Abstract><ResultDiscussion><Para> Bbb.</Para></ResultDiscussion></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[returns] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:262:6: FunctionDecl=comment_to_html_conversion_9:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Aaa.</p><p class="para-returns"><span class="word-returns">Returns</span> Bbb.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="262" column="6"><Name>comment_to_html_conversion_9</Name><USR>c:@F@comment_to_html_conversion_9#</USR><Abstract><Para> Aaa.</Para></Abstract><ResultDiscussion><Para> Bbb.</Para></ResultDiscussion></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[result] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:266:6: FunctionDecl=comment_to_html_conversion_10:{{.*}} FullCommentAsHTML=[<p class="para-returns"><span class="word-returns">Returns</span> Bbb.</p><p class="para-returns"><span class="word-returns">Returns</span> Aaa. </p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="266" column="6"><Name>comment_to_html_conversion_10</Name><USR>c:@F@comment_to_html_conversion_10#</USR><ResultDiscussion><Para> Aaa. </Para></ResultDiscussion><Discussion><Para> Bbb.</Para></Discussion></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[returns] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[returns] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.]))))] +// CHECK: annotate-comments.cpp:273:6: FunctionDecl=comment_to_html_conversion_11:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Aaa.</p><p> Bbb.</p><p class="para-returns"><span class="word-returns">Returns</span> Ccc.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="273" column="6"><Name>comment_to_html_conversion_11</Name><USR>c:@F@comment_to_html_conversion_11#</USR><Abstract><Para> Aaa.</Para></Abstract><ResultDiscussion><Para> Ccc.</Para></ResultDiscussion><Discussion><Para> Bbb.</Para></Discussion></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.])) +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[returns] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ccc.]))))] +// CHECK: annotate-comments.cpp:276:6: FunctionDecl=comment_to_html_conversion_12:{{.*}} FullCommentAsHTML=[] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="276" column="6"><Name>comment_to_html_conversion_12</Name><USR>c:@F@comment_to_html_conversion_12#I#</USR></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[] ParamIndex=Invalid +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace)))] +// CHECK: annotate-comments.cpp:279:6: FunctionDecl=comment_to_html_conversion_13:{{.*}} FullCommentAsHTML=[<dl><dt class="param-name-index-0">x1</dt><dd class="param-descr-index-0"> Aaa.</dd></dl>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="279" column="6"><Name>comment_to_html_conversion_13</Name><USR>c:@F@comment_to_html_conversion_13#I#</USR><Parameters><Parameter><Name>x1</Name><Index>0</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Aaa.</Para></Discussion></Parameter></Parameters></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x1] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:282:6: FunctionDecl=comment_to_html_conversion_14:{{.*}} FullCommentAsHTML=[<dl><dt class="param-name-index-invalid">zzz</dt><dd class="param-descr-index-invalid"> Aaa.</dd></dl>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="282" column="6"><Name>comment_to_html_conversion_14</Name><USR>c:@F@comment_to_html_conversion_14#I#</USR><Parameters><Parameter><Name>zzz</Name><Direction isExplicit="0">in</Direction><Discussion><Para> Aaa.</Para></Discussion></Parameter></Parameters></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[zzz] ParamIndex=Invalid +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:286:6: FunctionDecl=comment_to_html_conversion_15:{{.*}} FullCommentAsHTML=[<dl><dt class="param-name-index-0">x1</dt><dd class="param-descr-index-0"> Aaa.</dd><dt class="param-name-index-1">x2</dt><dd class="param-descr-index-1"> Bbb. </dd></dl>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="286" column="6"><Name>comment_to_html_conversion_15</Name><USR>c:@F@comment_to_html_conversion_15#I#I#</USR><Parameters><Parameter><Name>x1</Name><Index>0</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Aaa.</Para></Discussion></Parameter><Parameter><Name>x2</Name><Index>1</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Bbb. </Para></Discussion></Parameter></Parameters></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x2] ParamIndex=1 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x1] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:291:6: FunctionDecl=comment_to_html_conversion_16:{{.*}} FullCommentAsHTML=[<dl><dt class="param-name-index-0">x1</dt><dd class="param-descr-index-0"> Aaa.</dd><dt class="param-name-index-1">x2</dt><dd class="param-descr-index-1"> Bbb. </dd><dt class="param-name-index-invalid">zzz</dt><dd class="param-descr-index-invalid"> Aaa. </dd></dl>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="291" column="6"><Name>comment_to_html_conversion_16</Name><USR>c:@F@comment_to_html_conversion_16#I#I#</USR><Parameters><Parameter><Name>x1</Name><Index>0</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Aaa.</Para></Discussion></Parameter><Parameter><Name>x2</Name><Index>1</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Bbb. </Para></Discussion></Parameter><Parameter><Name>zzz</Name><Direction isExplicit="0">in</Direction><Discussion><Para> Aaa. </Para></Discussion></Parameter></Parameters></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x2] ParamIndex=1 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[zzz] ParamIndex=Invalid +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x1] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))))] +// CHECK: annotate-comments.cpp:296:6: FunctionTemplate=comment_to_html_conversion_17:{{.*}} FullCommentAsHTML=[<dl><dt class="param-name-index-0">aaa</dt><dd class="param-descr-index-0"> Blah blah</dd></dl>] FullCommentAsXML=[<Function templateKind="template" file="{{[^"]+}}annotate-comments.cpp" line="296" column="6"><Name>comment_to_html_conversion_17</Name><USR>c:@FT@>1#Tcomment_to_html_conversion_17#t0.0#</USR><Parameters><Parameter><Name>aaa</Name><Index>0</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Blah blah</Para></Discussion></Parameter></Parameters></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[] ParamPosition=Invalid +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[aaa] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Blah blah]))))] +// CHECK: annotate-comments.cpp:301:6: FunctionTemplate=comment_to_html_conversion_18:{{.*}} FullCommentAsHTML=[<dl><dt class="param-name-index-0">aaa</dt><dd class="param-descr-index-0"> Blah blah</dd></dl>] FullCommentAsXML=[<Function templateKind="template" file="{{[^"]+}}annotate-comments.cpp" line="301" column="6"><Name>comment_to_html_conversion_18</Name><USR>c:@FT@>1#Tcomment_to_html_conversion_18#t0.0#</USR><Parameters><Parameter><Name>aaa</Name><Index>0</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Blah blah</Para></Discussion></Parameter></Parameters></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T] ParamPosition={0} +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[aaa] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Blah blah]))))] +// CHECK: annotate-comments.cpp:306:6: FunctionTemplate=comment_to_html_conversion_19:{{.*}} FullCommentAsHTML=[<dl><dt class="tparam-name-index-0">T1</dt><dd class="tparam-descr-index-0"> Aaa</dd><dt class="tparam-name-index-1">T2</dt><dd class="tparam-descr-index-1"> Bbb </dd></dl>] FullCommentAsXML=[<Function templateKind="template" file="{{[^"]+}}annotate-comments.cpp" line="306" column="6"><Name>comment_to_html_conversion_19</Name><USR>c:@FT@>2#T#Tcomment_to_html_conversion_19#t0.0#t0.1#</USR><TemplateParameters><Parameter><Name>T1</Name><Index>0</Index><Discussion><Para> Aaa</Para></Discussion></Parameter><Parameter><Name>T2</Name><Index>1</Index><Discussion><Para> Bbb </Para></Discussion></Parameter></TemplateParameters></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T2] ParamPosition={1} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T1] ParamPosition={0} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa]))))] +// CHECK: annotate-comments.cpp:313:6: FunctionTemplate=comment_to_html_conversion_20:{{.*}} FullCommentAsHTML=[<dl><dt class="tparam-name-index-0">T1</dt><dd class="tparam-descr-index-0"> Aaa</dd><dt class="tparam-name-index-1">T2</dt><dd class="tparam-descr-index-1"> Bbb </dd><dt class="tparam-name-index-2">V</dt><dd class="tparam-descr-index-2"> Ccc </dd><dt class="tparam-name-index-invalid">U</dt><dd class="tparam-descr-index-invalid"> Zzz </dd></dl>] FullCommentAsXML=[<Function templateKind="template" file="{{[^"]+}}annotate-comments.cpp" line="313" column="6"><Name>comment_to_html_conversion_20</Name><USR>c:@FT@>3#T#T#NIcomment_to_html_conversion_20#t0.0#t0.1#</USR><TemplateParameters><Parameter><Name>T1</Name><Index>0</Index><Discussion><Para> Aaa</Para></Discussion></Parameter><Parameter><Name>T2</Name><Index>1</Index><Discussion><Para> Bbb </Para></Discussion></Parameter><Parameter><Name>V</Name><Index>2</Index><Discussion><Para> Ccc </Para></Discussion></Parameter><Parameter><Name>U</Name><Discussion><Para> Zzz </Para></Discussion></Parameter></TemplateParameters></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T2] ParamPosition={1} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[U] ParamPosition=Invalid +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Zzz] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[V] ParamPosition={2} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ccc] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T1] ParamPosition={0} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa]))))] +// CHECK: annotate-comments.cpp:320:6: FunctionTemplate=comment_to_html_conversion_21:{{.*}} FullCommentAsHTML=[<dl><dt class="tparam-name-index-0">TTT</dt><dd class="tparam-descr-index-0"> Ddd </dd><dt class="tparam-name-index-other">C</dt><dd class="tparam-descr-index-other"> Ccc </dd><dt class="tparam-name-index-other">T</dt><dd class="tparam-descr-index-other"> Aaa </dd><dt class="tparam-name-index-other">TT</dt><dd class="tparam-descr-index-other"> Bbb</dd></dl>] FullCommentAsXML=[<Function templateKind="template" file="{{[^"]+}}annotate-comments.cpp" line="320" column="6"><Name>comment_to_html_conversion_21</Name><USR>c:@FT@>1#t>2#t>1#T#Tcomment_to_html_conversion_21#</USR><TemplateParameters><Parameter><Name>TTT</Name><Index>0</Index><Discussion><Para> Ddd </Para></Discussion></Parameter><Parameter><Name>C</Name><Discussion><Para> Ccc </Para></Discussion></Parameter><Parameter><Name>T</Name><Discussion><Para> Aaa </Para></Discussion></Parameter><Parameter><Name>TT</Name><Discussion><Para> Bbb</Para></Discussion></Parameter></TemplateParameters></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[TTT] ParamPosition={0} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ddd] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[C] ParamPosition={0, 1} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ccc] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[T] ParamPosition={0, 0, 0} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[TT] ParamPosition={0, 0} +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb]))))] +// CHECK: annotate-comments.cpp:329:6: FunctionDecl=comment_to_html_conversion_22:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Aaa.</p><p> Bbb.</p><dl><dt class="param-name-index-0">x1</dt><dd class="param-descr-index-0"> Ccc. </dd><dt class="param-name-index-1">x2</dt><dd class="param-descr-index-1"> Ddd. </dd></dl><p class="para-returns"><span class="word-returns">Returns</span> Eee.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="329" column="6"><Name>comment_to_html_conversion_22</Name><USR>c:@F@comment_to_html_conversion_22#I#I#</USR><Abstract><Para> Aaa.</Para></Abstract><Parameters><Parameter><Name>x1</Name><Index>0</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Ccc. </Para></Discussion></Parameter><Parameter><Name>x2</Name><Index>1</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Ddd. </Para></Discussion></Parameter></Parameters><ResultDiscussion><Para> Eee.</Para></ResultDiscussion><Discussion><Para> Bbb.</Para></Discussion></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[brief] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Aaa.]))) +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Bbb.])) +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x2] ParamIndex=1 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ddd.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[x1] ParamIndex=0 +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Ccc.] HasTrailingNewline) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace))) +// CHECK-NEXT: (CXComment_BlockCommand CommandName=[returns] +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ Eee.]))))] +// CHECK: annotate-comments.cpp:332:6: FunctionDecl=comment_to_html_conversion_23:{{.*}} FullCommentAsHTML=[<p class="para-brief"> <br><a href="http://example.com/">Aaa</a></p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="332" column="6"><Name>comment_to_html_conversion_23</Name><USR>c:@F@comment_to_html_conversion_23#</USR><Abstract><Para> <rawHTML><![CDATA[<br>]]></rawHTML><rawHTML><![CDATA[<a href="http://example.com/">]]></rawHTML>Aaa<rawHTML></a></rawHTML></Para></Abstract></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_HTMLStartTag Name=[br]) +// CHECK-NEXT: (CXComment_HTMLStartTag Name=[a] Attrs: href=http://example.com/) +// CHECK-NEXT: (CXComment_Text Text=[Aaa]) +// CHECK-NEXT: (CXComment_HTMLEndTag Name=[a])))] +// CHECK: annotate-comments.cpp:338:6: FunctionDecl=comment_to_html_conversion_24:{{.*}} FullCommentAsHTML=[<pre> <a href="http://example.com/">Aaa</a>\n <a href='http://example.com/'>Aaa</a></pre>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="338" column="6"><Name>comment_to_html_conversion_24</Name><USR>c:@F@comment_to_html_conversion_24#</USR><Discussion><Verbatim xml:space="preserve" kind="verbatim"> <a href="http://example.com/">Aaa</a>\n <a href='http://example.com/'>Aaa</a></Verbatim></Discussion></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph IsWhitespace +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_VerbatimBlockCommand CommandName=[verbatim] +// CHECK-NEXT: (CXComment_VerbatimBlockLine Text=[ <a href="http://example.com/">Aaa</a>]) +// CHECK-NEXT: (CXComment_VerbatimBlockLine Text=[ <a href='http://example.com/'>Aaa</a>])))] +// CHECK: annotate-comments.cpp:345:6: FunctionDecl=comment_to_html_conversion_25:{{.*}} FullCommentAsHTML=[<p class="para-brief"> Blah blah.</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="345" column="6"><Name>comment_to_html_conversion_25</Name><USR>c:@F@comment_to_html_conversion_25#</USR><Abstract><Para> Blah blah.</Para></Abstract></Function>] +// CHECK: CommentAST=[ +// CHECK: (CXComment_FullComment +// CHECK: (CXComment_Paragraph IsWhitespace +// CHECK: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK: (CXComment_VerbatimLine Text=[ foo]) +// CHECK: (CXComment_Paragraph IsWhitespace +// CHECK: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK: (CXComment_VerbatimLine Text=[ foo]) +// CHECK: (CXComment_Paragraph IsWhitespace +// CHECK: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK: (CXComment_VerbatimLine Text=[ foo]) +// CHECK: (CXComment_Paragraph IsWhitespace +// CHECK: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK: (CXComment_VerbatimLine Text=[ foo]) +// CHECK: (CXComment_Paragraph +// CHECK: (CXComment_Text Text=[ Blah blah.])))] +// CHECK: annotate-comments.cpp:348:6: FunctionDecl=comment_to_html_conversion_26:{{.*}} FullCommentAsHTML=[<p class="para-brief"> <b>Aaa</b></p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="348" column="6"><Name>comment_to_html_conversion_26</Name><USR>c:@F@comment_to_html_conversion_26#</USR><Abstract><Para> <bold>Aaa</bold></Para></Abstract></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[b] RenderBold Arg[0]=Aaa)))] +// CHECK: annotate-comments.cpp:351:6: FunctionDecl=comment_to_html_conversion_27:{{.*}} FullCommentAsHTML=[<p class="para-brief"> <tt>Aaa</tt> <tt>Bbb</tt></p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="351" column="6"><Name>comment_to_html_conversion_27</Name><USR>c:@F@comment_to_html_conversion_27#</USR><Abstract><Para> <monospaced>Aaa</monospaced> <monospaced>Bbb</monospaced></Para></Abstract></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[c] RenderMonospaced Arg[0]=Aaa) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[p] RenderMonospaced Arg[0]=Bbb)))] +// CHECK: annotate-comments.cpp:354:6: FunctionDecl=comment_to_html_conversion_28:{{.*}} FullCommentAsHTML=[<p class="para-brief"> <em>Aaa</em> <em>Bbb</em> <em>Ccc</em></p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="354" column="6"><Name>comment_to_html_conversion_28</Name><USR>c:@F@comment_to_html_conversion_28#</USR><Abstract><Para> <emphasized>Aaa</emphasized> <emphasized>Bbb</emphasized> <emphasized>Ccc</emphasized></Para></Abstract></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[a] RenderEmphasized Arg[0]=Aaa) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[e] RenderEmphasized Arg[0]=Bbb) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[em] RenderEmphasized Arg[0]=Ccc)))] +// CHECK: annotate-comments.cpp:357:6: FunctionDecl=comment_to_html_conversion_29:{{.*}} FullCommentAsHTML=[<p class="para-brief"> <em>1<2</em> <em>3<4</em> <em>5<6</em> </p><dl><dt class="tparam-name-index-invalid">9<10</dt><dd class="tparam-descr-index-invalid"> bbb</dd></dl><dl><dt class="param-name-index-invalid">7<8</dt><dd class="param-descr-index-invalid"> aaa </dd></dl>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="357" column="6"><Name>comment_to_html_conversion_29</Name><USR>c:@F@comment_to_html_conversion_29#</USR><Abstract><Para> <emphasized>1<2</emphasized> <emphasized>3<4</emphasized> <emphasized>5<6</emphasized> </Para></Abstract><TemplateParameters><Parameter><Name>9<10</Name><Discussion><Para> bbb</Para></Discussion></Parameter></TemplateParameters><Parameters><Parameter><Name>7<8</Name><Direction isExplicit="0">in</Direction><Discussion><Para> aaa </Para></Discussion></Parameter></Parameters></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[a] RenderEmphasized Arg[0]=1<2) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[e] RenderEmphasized Arg[0]=3<4) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_InlineCommand CommandName=[em] RenderEmphasized Arg[0]=5<6) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace)) +// CHECK-NEXT: (CXComment_ParamCommand in implicitly ParamName=[7<8] ParamIndex=Invalid +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ aaa ]))) +// CHECK-NEXT: (CXComment_TParamCommand ParamName=[9<10] ParamPosition=Invalid +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ bbb]))))] +// CHECK: annotate-comments.cpp:360:6: FunctionDecl=comment_to_html_conversion_30:{{.*}} FullCommentAsHTML=[<p class="para-brief"> \ @ & $ # < > % " . ::</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="360" column="6"><Name>comment_to_html_conversion_30</Name><USR>c:@F@comment_to_html_conversion_30#</USR><Abstract><Para> \ @ & $ # < > % " . ::</Para></Abstract></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[\]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[@]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[&]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[$]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[#]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[<]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[>]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[%]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=["]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[.]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[::])))] +// CHECK: annotate-comments.cpp:363:6: FunctionDecl=comment_to_html_conversion_31:{{.*}} FullCommentAsHTML=[<p class="para-brief"> & < > "</p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="363" column="6"><Name>comment_to_html_conversion_31</Name><USR>c:@F@comment_to_html_conversion_31#</USR><Abstract><Para> & < > "</Para></Abstract></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[&]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[<]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=[>]) +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_Text Text=["])))] +// CHECK: annotate-comments.cpp:366:6: FunctionDecl=comment_to_html_conversion_32:{{.*}} FullCommentAsHTML=[<p class="para-brief"> <em>0<i</em></p>] FullCommentAsXML=[<Function file="{{[^"]+}}annotate-comments.cpp" line="366" column="6"><Name>comment_to_html_conversion_32</Name><USR>c:@F@comment_to_html_conversion_32#</USR><Abstract><Para> <rawHTML><![CDATA[<em>]]></rawHTML>0<i<rawHTML></em></rawHTML></Para></Abstract></Function>] +// CHECK-NEXT: CommentAST=[ +// CHECK-NEXT: (CXComment_FullComment +// CHECK-NEXT: (CXComment_Paragraph +// CHECK-NEXT: (CXComment_Text Text=[ ] IsWhitespace) +// CHECK-NEXT: (CXComment_HTMLStartTag Name=[em]) +// CHECK-NEXT: (CXComment_Text Text=[0]) +// CHECK-NEXT: (CXComment_Text Text=[<]) +// CHECK-NEXT: (CXComment_Text Text=[i]) +// CHECK-NEXT: (CXComment_HTMLEndTag Name=[em])))] + +// CHECK: annotate-comments.cpp:369:7: ClassDecl=comment_to_xml_conversion_01:{{.*}} FullCommentAsXML=[<Class file="{{[^"]+}}annotate-comments.cpp" line="369" column="7"><Name>comment_to_xml_conversion_01</Name><USR>c:@C@comment_to_xml_conversion_01</USR><Abstract><Para> Aaa.</Para></Abstract></Class>] +// CHECK: annotate-comments.cpp:371:3: CXXConstructor=comment_to_xml_conversion_01:{{.*}} FullCommentAsXML=[<Function isInstanceMethod="1" file="{{[^"]+}}annotate-comments.cpp" line="371" column="3"><Name>comment_to_xml_conversion_01</Name><USR>c:@C@comment_to_xml_conversion_01@F@comment_to_xml_conversion_01#I#</USR><Parameters><Parameter><Name>aaa</Name><Index>0</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Blah blah.</Para></Discussion></Parameter></Parameters></Function>] +// CHECK: annotate-comments.cpp:374:3: CXXDestructor=~comment_to_xml_conversion_01:{{.*}} FullCommentAsXML=[<Function isInstanceMethod="1" file="{{[^"]+}}annotate-comments.cpp" line="374" column="3"><Name>~comment_to_xml_conversion_01</Name><USR>c:@C@comment_to_xml_conversion_01@F@~comment_to_xml_conversion_01#</USR><Abstract><Para> Aaa.</Para></Abstract></Function>] +// CHECK: annotate-comments.cpp:377:7: CXXMethod=comment_to_xml_conversion_02:{{.*}} FullCommentAsXML=[<Function isInstanceMethod="1" file="{{[^"]+}}annotate-comments.cpp" line="377" column="7"><Name>comment_to_xml_conversion_02</Name><USR>c:@C@comment_to_xml_conversion_01@F@comment_to_xml_conversion_02#I#</USR><Parameters><Parameter><Name>aaa</Name><Index>0</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Blah blah.</Para></Discussion></Parameter></Parameters></Function>] +// CHECK: annotate-comments.cpp:380:14: CXXMethod=comment_to_xml_conversion_03:{{.*}} FullCommentAsXML=[<Function isClassMethod="1" file="{{[^"]+}}annotate-comments.cpp" line="380" column="14"><Name>comment_to_xml_conversion_03</Name><USR>c:@C@comment_to_xml_conversion_01@F@comment_to_xml_conversion_03#I#S</USR><Parameters><Parameter><Name>aaa</Name><Index>0</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Blah blah.</Para></Discussion></Parameter></Parameters></Function>] +// CHECK: annotate-comments.cpp:383:7: FieldDecl=comment_to_xml_conversion_04:{{.*}} FullCommentAsXML=[<Variable file="{{[^"]+}}annotate-comments.cpp" line="383" column="7"><Name>comment_to_xml_conversion_04</Name><USR>c:@C@comment_to_xml_conversion_01@FI@comment_to_xml_conversion_04</USR><Abstract><Para> Aaa.</Para></Abstract></Variable>] +// CHECK: annotate-comments.cpp:386:14: VarDecl=comment_to_xml_conversion_05:{{.*}} FullCommentAsXML=[<Variable file="{{[^"]+}}annotate-comments.cpp" line="386" column="14"><Name>comment_to_xml_conversion_05</Name><USR>c:@C@comment_to_xml_conversion_01@comment_to_xml_conversion_05</USR><Abstract><Para> Aaa.</Para></Abstract></Variable>] +// CHECK: annotate-comments.cpp:389:8: CXXMethod=operator():{{.*}} FullCommentAsXML=[<Function isInstanceMethod="1" file="{{[^"]+}}annotate-comments.cpp" line="389" column="8"><Name>operator()</Name><USR>c:@C@comment_to_xml_conversion_01@F@operator()#I#</USR><Parameters><Parameter><Name>aaa</Name><Index>0</Index><Direction isExplicit="0">in</Direction><Discussion><Para> Blah blah.</Para></Discussion></Parameter></Parameters></Function>] +// CHECK: annotate-comments.cpp:392:3: CXXConversion=operator _Bool:{{.*}} FullCommentAsXML=[<Function isInstanceMethod="1" file="{{[^"]+}}annotate-comments.cpp" line="392" column="3"><Name>operator _Bool</Name><USR>c:@C@comment_to_xml_conversion_01@F@operator _Bool#</USR><Abstract><Para> Aaa.</Para></Abstract></Function>] +// CHECK: annotate-comments.cpp:395:15: TypedefDecl=comment_to_xml_conversion_06:{{.*}} FullCommentAsXML=[<Typedef file="{{[^"]+}}annotate-comments.cpp" line="395" column="15"><Name>comment_to_xml_conversion_06</Name><USR>c:annotate-comments.cpp@8055@C@comment_to_xml_conversion_01@T@comment_to_xml_conversion_06</USR><Abstract><Para> Aaa.</Para></Abstract></Typedef>] +// CHECK: annotate-comments.cpp:398:9: TypeAliasDecl=comment_to_xml_conversion_07:{{.*}} FullCommentAsXML=[<Typedef file="{{[^"]+}}annotate-comments.cpp" line="398" column="9"><Name>comment_to_xml_conversion_07</Name><USR>c:@C@comment_to_xml_conversion_01@comment_to_xml_conversion_07</USR><Abstract><Para> Aaa.</Para></Abstract></Typedef>] +// CHECK: annotate-comments.cpp:405:3: UnexposedDecl=comment_to_xml_conversion_09:{{.*}} FullCommentAsXML=[<Typedef file="{{[^"]+}}annotate-comments.cpp" line="405" column="3"><Name>comment_to_xml_conversion_09</Name><USR>c:@C@comment_to_xml_conversion_01@comment_to_xml_conversion_09</USR><Abstract><Para> Aaa.</Para></Abstract></Typedef>] +// CHECK: annotate-comments.cpp:410:6: FunctionTemplate=comment_to_xml_conversion_10:{{.*}} FullCommentAsXML=[<Function templateKind="template" file="{{[^"]+}}annotate-comments.cpp" line="410" column="6"><Name>comment_to_xml_conversion_10</Name><USR>c:@FT@>2#T#Tcomment_to_xml_conversion_10#t0.0#t0.1#</USR><Abstract><Para> Aaa.</Para></Abstract></Function>] +// CHECK: annotate-comments.cpp:414:6: FunctionDecl=comment_to_xml_conversion_10:{{.*}} FullCommentAsXML=[<Function templateKind="specialization" file="{{[^"]+}}annotate-comments.cpp" line="414" column="6"><Name>comment_to_xml_conversion_10</Name><USR>c:@F@comment_to_xml_conversion_10<#I#I>#I#I#</USR><Abstract><Para> Aaa.</Para></Abstract></Function>] +// CHECK: annotate-comments.cpp:418:7: ClassTemplate=comment_to_xml_conversion_11:{{.*}} FullCommentAsXML=[<Class templateKind="template" file="{{[^"]+}}annotate-comments.cpp" line="418" column="7"><Name>comment_to_xml_conversion_11</Name><USR>c:@CT>2#T#T@comment_to_xml_conversion_11</USR><Abstract><Para> Aaa.</Para></Abstract></Class>] +// CHECK: annotate-comments.cpp:422:7: ClassTemplatePartialSpecialization=comment_to_xml_conversion_11:{{.*}} FullCommentAsXML=[<Class templateKind="partialSpecialization" file="{{[^"]+}}annotate-comments.cpp" line="422" column="7"><Name>comment_to_xml_conversion_11</Name><USR>c:@CP>1#T@comment_to_xml_conversion_11>#t0.0#I</USR><Abstract><Para> Aaa.</Para></Abstract></Class>] +// CHECK: annotate-comments.cpp:426:7: ClassDecl=comment_to_xml_conversion_11:{{.*}} FullCommentAsXML=[<Class templateKind="specialization" file="{{[^"]+}}annotate-comments.cpp" line="426" column="7"><Name>comment_to_xml_conversion_11</Name><USR>c:@C@comment_to_xml_conversion_11>#I#I</USR><Abstract><Para> Aaa.</Para></Abstract></Class>] +// CHECK: annotate-comments.cpp:429:5: VarDecl=comment_to_xml_conversion_12:{{.*}} FullCommentAsXML=[<Variable file="{{[^"]+}}annotate-comments.cpp" line="429" column="5"><Name>comment_to_xml_conversion_12</Name><USR>c:@comment_to_xml_conversion_12</USR><Abstract><Para> Aaa.</Para></Abstract></Variable>] +// CHECK: annotate-comments.cpp:432:11: Namespace=comment_to_xml_conversion_13:{{.*}} FullCommentAsXML=[<Namespace file="{{[^"]+}}annotate-comments.cpp" line="432" column="11"><Name>comment_to_xml_conversion_13</Name><USR>c:@N@comment_to_xml_conversion_13</USR><Abstract><Para> Aaa.</Para></Abstract></Namespace>] +// CHECK: annotate-comments.cpp:434:13: Namespace=comment_to_xml_conversion_14:{{.*}} FullCommentAsXML=[<Namespace file="{{[^"]+}}annotate-comments.cpp" line="434" column="13"><Name>comment_to_xml_conversion_14</Name><USR>c:@N@comment_to_xml_conversion_13@N@comment_to_xml_conversion_14</USR><Abstract><Para> Aaa.</Para></Abstract></Namespace>] +// CHECK: annotate-comments.cpp:439:6: EnumDecl=comment_to_xml_conversion_15:{{.*}} FullCommentAsXML=[<Enum file="{{[^"]+}}annotate-comments.cpp" line="439" column="6"><Name>comment_to_xml_conversion_15</Name><USR>c:@E@comment_to_xml_conversion_15</USR><Abstract><Para> Aaa.</Para></Abstract></Enum>] +// CHECK: annotate-comments.cpp:441:3: EnumConstantDecl=comment_to_xml_conversion_16:{{.*}} FullCommentAsXML=[<Variable file="{{[^"]+}}annotate-comments.cpp" line="441" column="3"><Name>comment_to_xml_conversion_16</Name><USR>c:@E@comment_to_xml_conversion_15@comment_to_xml_conversion_16</USR><Abstract><Para> Aaa.</Para></Abstract></Variable>] +// CHECK: annotate-comments.cpp:445:12: EnumDecl=comment_to_xml_conversion_17:{{.*}} FullCommentAsXML=[<Enum file="{{[^"]+}}annotate-comments.cpp" line="445" column="12"><Name>comment_to_xml_conversion_17</Name><USR>c:@E@comment_to_xml_conversion_17</USR><Abstract><Para> Aaa.</Para></Abstract></Enum>] +// CHECK: annotate-comments.cpp:447:3: EnumConstantDecl=comment_to_xml_conversion_18:{{.*}} FullCommentAsXML=[<Variable file="{{[^"]+}}annotate-comments.cpp" line="447" column="3"><Name>comment_to_xml_conversion_18</Name><USR>c:@E@comment_to_xml_conversion_17@comment_to_xml_conversion_18</USR><Abstract><Para> Aaa.</Para></Abstract></Variable>] diff --git a/test/Index/availability.c b/test/Index/availability.c new file mode 100644 index 000000000000..e6b1273acafb --- /dev/null +++ b/test/Index/availability.c @@ -0,0 +1,10 @@ +// Run lines below; this test is line- and column-sensitive. + +void foo(void) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5,obsoleted=10.7), availability(ios,introduced=3.2,deprecated=4.1))); + +// RUN: c-index-test -test-load-source all %s > %t +// RUN: FileCheck -check-prefix=CHECK-1 %s < %t +// RUN: FileCheck -check-prefix=CHECK-2 %s < %t +// CHECK-1: (ios, introduced=3.2, deprecated=4.1) +// CHECK-2: (macosx, introduced=10.4, deprecated=10.5, obsoleted=10.7) + diff --git a/test/Index/boxed-exprs.h b/test/Index/boxed-exprs.h new file mode 100644 index 000000000000..bdb80383d7ea --- /dev/null +++ b/test/Index/boxed-exprs.h @@ -0,0 +1,10 @@ + +@interface NSString @end + +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end + +static inline void infoo(const char *cs) { + NSString *s = @(cs); +} diff --git a/test/Index/boxed-exprs.m b/test/Index/boxed-exprs.m new file mode 100644 index 000000000000..0a63b3f6099e --- /dev/null +++ b/test/Index/boxed-exprs.m @@ -0,0 +1,19 @@ + +#include "boxed-exprs.h" + +const char *glob_str; + +void foo() { + NSString *s = @(glob_str); +} + +// RUN: c-index-test -index-file -target x86_64-apple-macosx10.7 %s | FileCheck -check-prefix=CHECK-INDEX %s +// CHECK-INDEX: [indexEntityReference]: kind: variable | name: glob_str | {{.*}} | loc: 7:19 + +// RUN: c-index-test -cursor-at=%s:7:24 -target x86_64-apple-macosx10.7 %s | FileCheck -check-prefix=CHECK-CURSOR %s +// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%s:7:24 -target x86_64-apple-macosx10.7 %s | FileCheck -check-prefix=CHECK-CURSOR %s +// CHECK-CURSOR: 7:19 DeclRefExpr=glob_str:4:13 Extent=[7:19 - 7:27] Spelling=glob_str ([7:19 - 7:27]) + +// RUN: c-index-test -cursor-at=%S/boxed-exprs.h:9:19 -target x86_64-apple-macosx10.7 %s | FileCheck -check-prefix=CHECK-CURSOR2 %s +// RUN: env CINDEXTEST_EDITING=1 c-index-test -cursor-at=%S/boxed-exprs.h:9:19 -target x86_64-apple-macosx10.7 %s | FileCheck -check-prefix=CHECK-CURSOR2 %s +// CHECK-CURSOR2: 9:19 DeclRefExpr=cs:8:38 Extent=[9:19 - 9:21] Spelling=cs ([9:19 - 9:21]) diff --git a/test/Index/c-index-api-loadTU-test.m b/test/Index/c-index-api-loadTU-test.m index 251d73b3f819..7520330bce2e 100644 --- a/test/Index/c-index-api-loadTU-test.m +++ b/test/Index/c-index-api-loadTU-test.m @@ -83,7 +83,7 @@ struct X0 {}; // CHECK: <invalid loc>:0:0: attribute(ibaction)= // CHECK: c-index-api-loadTU-test.m:8:50: ParmDecl=msg:8:50 (Definition) Extent=[8:47 - 8:53] // CHECK: c-index-api-loadTU-test.m:8:47: TypeRef=id:0:0 Extent=[8:47 - 8:49] -// CHECK: c-index-api-loadTU-test.m:9:3: ObjCInstanceMethodDecl=foo:9:3 (deprecated) Extent=[9:1 - 9:35] +// CHECK: c-index-api-loadTU-test.m:9:3: ObjCInstanceMethodDecl=foo:9:3 (deprecated) (always deprecated: "") Extent=[9:1 - 9:35] // CHECK: c-index-api-loadTU-test.m:10:3: ObjCClassMethodDecl=fooC:10:3 Extent=[10:1 - 10:8] // CHECK: c-index-api-loadTU-test.m:14:12: ObjCInterfaceDecl=Bar:14:12 Extent=[14:1 - 18:5] // CHECK: c-index-api-loadTU-test.m:14:18: ObjCSuperClassRef=Foo:4:12 Extent=[14:18 - 14:21] diff --git a/test/Index/comment-xml-schema.c b/test/Index/comment-xml-schema.c new file mode 100644 index 000000000000..1166e78f577e --- /dev/null +++ b/test/Index/comment-xml-schema.c @@ -0,0 +1,43 @@ +// REQUIRES: xmllint + +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-other-01.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-01.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-02.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-03.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-04.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-05.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-06.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-07.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-08.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-function-09.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-01.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-02.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-03.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-class-04.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-variable-01.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-namespace-01.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-typedef-01.xml +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-typedef-02.xml +// +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/valid-enum-01.xml + +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-01.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-02.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-03.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-04.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-05.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-06.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-07.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-08.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-09.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-10.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-11.xml 2>&1 | FileCheck %s -check-prefix=INVALID +// RUN: xmllint --noout --relaxng %S/../../bindings/xml/comment-xml-schema.rng %S/Inputs/CommentXML/invalid-function-12.xml 2>&1 | FileCheck %s -check-prefix=INVALID + +// CHECK-INVALID: fails to validate + diff --git a/test/Index/compile_commands.json b/test/Index/compile_commands.json new file mode 100644 index 000000000000..89d9f0dd52d8 --- /dev/null +++ b/test/Index/compile_commands.json @@ -0,0 +1,27 @@ +[ +{ + "directory": "/home/john.doe/MyProject", + "command": "clang++ -o project.o -c /home/john.doe/MyProject/project.cpp", + "file": "/home/john.doe/MyProject/project.cpp" +}, +{ + "directory": "/home/john.doe/MyProjectA", + "command": "clang++ -o project2.o -c /home/john.doe/MyProject/project2.cpp", + "file": "/home/john.doe/MyProject/project2.cpp" +}, +{ + "directory": "/home/john.doe/MyProjectB", + "command": "clang++ -DFEATURE=1 -o project2-feature.o -c /home/john.doe/MyProject/project2.cpp", + "file": "/home/john.doe/MyProject/project2.cpp" +} +] +# RUN: c-index-test -compilation-db %s +# RUN: c-index-test -compilation-db lookup file_does_not_exists.cpp %s | FileCheck -check-prefix=FILE-NOT-FOUND %s +# FILE-NOT-FOUND: file file_does_not_exists.cpp not found in compilation db + +# RUN: c-index-test -compilation-db lookup /home/john.doe/MyProject/project.cpp %s | FileCheck -check-prefix=FILE-1-CMD %s +# FILE-1-CMD: workdir:'/home/john.doe/MyProject' cmdline:'clang++ -o project.o -c /home/john.doe/MyProject/project.cpp' + +# RUN: c-index-test -compilation-db lookup /home/john.doe/MyProject/project2.cpp %s | FileCheck -check-prefix=FILE-2-CMD %s +# FILE-2-CMD: workdir:'/home/john.doe/MyProjectA' cmdline:'clang++ -o project2.o -c /home/john.doe/MyProject/project2.cpp' +# FILE-2-CMD: workdir:'/home/john.doe/MyProjectB' cmdline:'clang++ -DFEATURE=1 -o project2-feature.o -c /home/john.doe/MyProject/project2.cpp' diff --git a/test/Index/complete-documentation.cpp b/test/Index/complete-documentation.cpp new file mode 100644 index 000000000000..a64e62f239de --- /dev/null +++ b/test/Index/complete-documentation.cpp @@ -0,0 +1,51 @@ +// Note: the run lines follow their respective tests, since line/column +// matter in this test. + +/// Aaa. +void T1(float x, float y); + +/// Bbb. +class T2 { +public: + /// Ccc. + void T3(); + + int T4; ///< Ddd. +}; + +/// Eee. +namespace T5 { +} + +struct T6 { + /// \brief Fff. + void T7(); + + /// \brief Ggg. + void T8(); +}; + +void T6::T7() { +} + +void test1() { + + T2 t2; + t2.T4; + + T6 t6; + t6.T8(); +} + +// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:32:1 %s | FileCheck -check-prefix=CC1 %s +// CHECK-CC1: FunctionDecl:{ResultType void}{TypedText T1}{{.*}}(brief comment: Aaa.) +// CHECK-CC1: ClassDecl:{TypedText T2}{{.*}}(brief comment: Bbb.) +// CHECK-CC1: Namespace:{TypedText T5}{{.*}}(brief comment: Eee.) + +// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:34:6 %s | FileCheck -check-prefix=CC2 %s +// CHECK-CC2: CXXMethod:{ResultType void}{TypedText T3}{{.*}}(brief comment: Ccc.) +// CHECK-CC2: FieldDecl:{ResultType int}{TypedText T4}{{.*}}(brief comment: Ddd.) + +// RUN: env CINDEXTEST_COMPLETION_BRIEF_COMMENTS=1 c-index-test -code-completion-at=%s:37:6 %s | FileCheck -check-prefix=CC3 %s +// CHECK-CC3: CXXMethod:{ResultType void}{TypedText T7}{LeftParen (}{RightParen )} (34) (parent: StructDecl 'T6')(brief comment: Fff.) +// CHECK-CC3: CXXMethod:{ResultType void}{TypedText T8}{LeftParen (}{RightParen )} (34) (parent: StructDecl 'T6')(brief comment: Ggg.) diff --git a/test/Index/complete-exprs.m b/test/Index/complete-exprs.m index c3ff63bdbda6..3fb1540351d5 100644 --- a/test/Index/complete-exprs.m +++ b/test/Index/complete-exprs.m @@ -18,8 +18,10 @@ __strong id global; @end // RUN: c-index-test -code-completion-at=%s:13:2 %s | FileCheck -check-prefix=CHECK-CC1 %s -// CHECK-CC1: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40) -// CHECK-CC1: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40) +// CHECK-CC1: NotImplemented:{ResultType NSString *}{TypedText @"}{Placeholder string}{Text "} (40) +// CHECK-CC1: NotImplemented:{ResultType id}{TypedText @(}{Placeholder expression}{RightParen )} (40) +// CHECK-CC1: NotImplemented:{ResultType NSArray *}{TypedText @[}{Placeholder objects, ...}{RightBracket ]} (40) +// CHECK-CC1: NotImplemented:{ResultType NSDictionary *}{TypedText @{}{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{RightBrace }} (40) // CHECK-CC1: NotImplemented:{ResultType SEL}{TypedText _cmd} (80) // CHECK-CC1: TypedefDecl:{TypedText BOOL} (50) // CHECK-CC1: macro definition:{TypedText bool} (51) @@ -40,8 +42,8 @@ __strong id global; // RUN: c-index-test -code-completion-at=%s:15:5 %s | FileCheck -check-prefix=CHECK-CC4 %s // RUN: c-index-test -code-completion-at=%s:16:5 %s | FileCheck -check-prefix=CHECK-CC4 %s // RUN: c-index-test -code-completion-at=%s:16:14 %s | FileCheck -check-prefix=CHECK-CC4 %s -// CHECK-CC4: NotImplemented:{TypedText @[}{HorizontalSpace }{Placeholder objects, ...}{HorizontalSpace }{RightBracket ]} (40) -// CHECK-CC4: NotImplemented:{TypedText @{}{HorizontalSpace }{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{HorizontalSpace }{RightBrace }} (40) +// CHECK-CC4: NotImplemented:{ResultType NSArray *}{TypedText @[}{Placeholder objects, ...}{RightBracket ]} (40) +// CHECK-CC4: NotImplemented:{ResultType NSDictionary *}{TypedText @{}{Placeholder key}{HorizontalSpace }{Colon :}{HorizontalSpace }{Placeholder object, ...}{RightBrace }} (40) // CHECK-CC4: NotImplemented:{ResultType SEL}{TypedText _cmd} (80) // CHECK-CC4: macro definition:{TypedText bool} (51) // CHECK-CC4: macro definition:{TypedText NO} (65) diff --git a/test/Index/complete-lambdas.mm b/test/Index/complete-lambdas.mm new file mode 100644 index 000000000000..3f77dd206922 --- /dev/null +++ b/test/Index/complete-lambdas.mm @@ -0,0 +1,51 @@ +// This test is line- and column-sensitive. See below for run lines. + + +@interface A +- instanceMethod:(int)value withOther:(int)other; ++ classMethod; +@end + +@interface B : A +@end + +@implementation B +- someMethod:(A*)a { + [a classMethod]; + [A classMethod]; + [a instanceMethod:0 withOther:1]; + [self someMethod:a]; + [super instanceMethod]; + [&,a ]{}; + [a,self instanceMethod:0 withOther:1]{}; +} + +@end + +// RUN: c-index-test -code-completion-at=%s:14:6 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod:}{Placeholder (int)}{HorizontalSpace }{TypedText withOther:}{Placeholder (int)} (35) (parent: ObjCInterfaceDecl 'A') + +// RUN: c-index-test -code-completion-at=%s:15:6 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC2 %s +// CHECK-CC2: ObjCClassMethodDecl:{ResultType id}{TypedText classMethod} (35) (parent: ObjCInterfaceDecl 'A') + +// RUN: c-index-test -code-completion-at=%s:16:4 -std=c++11 %s | FileCheck -check-prefix=CHECK-CC3 %s +// CHECK-CC3: ObjCInterfaceDecl:{TypedText A} (50) (parent: TranslationUnit '(null)') +// CHECK-CC3: ParmDecl:{ResultType A *}{TypedText a} (34) +// CHECK-CC3: ObjCInterfaceDecl:{TypedText B} (50) (parent: TranslationUnit '(null)') +// CHECK-CC3: TypedefDecl:{TypedText Class} (50) (parent: TranslationUnit '(null)') + + +// RUN: c-index-test -code-completion-at=%s:16:21 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC4 %s +// CHECK-CC4: NotImplemented:{ResultType B *}{TypedText self} (34) +// CHECK-CC4: NotImplemented:{ResultType A *}{TypedText super} (40) + +// RUN: c-index-test -code-completion-at=%s:18:10 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC1 %s + +// RUN: c-index-test -code-completion-at=%s:19:8 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC5 %s +// CHECK-CC5: NotImplemented:{ResultType SEL}{TypedText _cmd} (80) +// CHECK-CC5-NEXT: NotImplemented:{ResultType B *}{TypedText self} (34) + +// RUN: c-index-test -code-completion-at=%s:20:11 -x objective-c++ -std=c++11 %s | FileCheck -check-prefix=CHECK-CC6 %s +// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod:}{Placeholder (int)}{HorizontalSpace }{TypedText withOther:}{Placeholder (int)} (37) (parent: ObjCInterfaceDecl 'A') +// CHECK-CC6-NEXT: ObjCInstanceMethodDecl:{ResultType id}{TypedText someMethod:}{Placeholder (A *)} (32) (parent: ObjCImplementationDecl 'B') + diff --git a/test/Index/complete-method-decls.m b/test/Index/complete-method-decls.m index becb7de6eb8b..ce4824637092 100644 --- a/test/Index/complete-method-decls.m +++ b/test/Index/complete-method-decls.m @@ -8,7 +8,7 @@ - (int)getInt; - (id)getSelf; @end - +@protocol P1; @protocol P2<P1> + (id)alloc; @end diff --git a/test/Index/complete-properties.m b/test/Index/complete-properties.m index ce1870e6511b..a4450563698e 100644 --- a/test/Index/complete-properties.m +++ b/test/Index/complete-properties.m @@ -45,6 +45,17 @@ id test(I3 *i3) { @synthesize Prop2 = Prop2_; @end +@protocol P1 +@property int Prop5; +@end + +@class P1; + +@interface I5<P1> +@end +@implementation I5 +@synthesize Prop5; +@end // RUN: c-index-test -code-completion-at=%s:20:13 %s | FileCheck -check-prefix=CHECK-CC1 %s // CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText Prop0} // CHECK-CC1: ObjCPropertyDecl:{ResultType int}{TypedText Prop1} @@ -80,3 +91,6 @@ id test(I3 *i3) { // CHECK-CC7-NOT: ObjCIvarDecl:{ResultType id}{TypedText _Prop2} // CHECK-CC7: ObjCIvarDecl:{ResultType I4 *}{TypedText Prop1} (17) // CHECK-CC7: ObjCIvarDecl:{ResultType id}{TypedText Prop2_} (7) + +// RUN: c-index-test -code-completion-at=%s:57:13 -fobjc-nonfragile-abi %s | FileCheck -check-prefix=CHECK-CC8 %s +// CHECK-CC8: ObjCPropertyDecl:{ResultType int}{TypedText Prop5} (35) diff --git a/test/Index/create-tu-fail.c b/test/Index/create-tu-fail.c new file mode 100644 index 000000000000..f259cca50ff4 --- /dev/null +++ b/test/Index/create-tu-fail.c @@ -0,0 +1,10 @@ +// RUN: rm -f %t.c +// RUN: touch %t.c +// RUN: c-index-test -write-pch %t.pch %t.c +// RUN: cp %s %t.c +// RUN: c-index-test -test-load-tu %t.pch local 2>&1 | FileCheck %s + +// rdar://11558355 +// Unfortunately this would crash reliably only via valgrind. + +// CHECK: Unable to load translation unit diff --git a/test/Index/cursor-dynamic-call.mm b/test/Index/cursor-dynamic-call.mm new file mode 100644 index 000000000000..f9d6a8716d16 --- /dev/null +++ b/test/Index/cursor-dynamic-call.mm @@ -0,0 +1,59 @@ + +struct SB { + virtual void meth(); +}; + +struct SS : public SB { + void submeth() { + this->meth(); + SB::meth(); + } +}; + +@interface IB +-(void)meth; ++(void)ClsMeth; +@end + +@interface IS : IB +-(void)submeth; ++(void)ClsMeth; +@end + +@implementation IS +-(void)submeth { + [self meth]; + [super meth]; +} ++(void)ClsMeth { + [super ClsMeth]; +} +@end + +void foo(SS *ss, IS* is, Class cls) { + ss->meth(); + [is meth]; + [IB ClsMeth]; + [cls ClsMeth]; +} + +// RUN: c-index-test -cursor-at=%s:8:11 \ +// RUN: -cursor-at=%s:9:11 \ +// RUN: -cursor-at=%s:25:11 \ +// RUN: -cursor-at=%s:26:11 \ +// RUN: -cursor-at=%s:29:11 \ +// RUN: -cursor-at=%s:34:9 \ +// RUN: -cursor-at=%s:35:9 \ +// RUN: -cursor-at=%s:36:9 \ +// RUN: -cursor-at=%s:37:9 \ +// RUN: %s | FileCheck %s + +// CHECK: 8:11 MemberRefExpr=meth:3:16 {{.*}} Dynamic-call +// CHECK-NOT: 9:9 {{.*}} Dynamic-call +// CHECK: 25:3 ObjCMessageExpr=meth:14:8 {{.*}} Dynamic-call +// CHECK-NOT: 26:3 {{.*}} Dynamic-call +// CHECK-NOT: 29:3 {{.*}} Dynamic-call +// CHECK: 34:7 MemberRefExpr=meth:3:16 {{.*}} Dynamic-call +// CHECK: 35:3 ObjCMessageExpr=meth:14:8 {{.*}} Dynamic-call +// CHECK-NOT: 36:3 {{.*}} Dynamic-call +// CHECK: 37:3 ObjCMessageExpr=ClsMeth:15:8 {{.*}} Dynamic-call diff --git a/test/Index/get-cursor.c b/test/Index/get-cursor.c index 23a4b5cb5370..c0614af5dd34 100644 --- a/test/Index/get-cursor.c +++ b/test/Index/get-cursor.c @@ -4,11 +4,17 @@ struct _MyS { struct _MyS ww; +int x, y; + // RUN: c-index-test -cursor-at=%s:1:9 \ // RUN: -cursor-at=%s:2:9 \ // RUN: -cursor-at=%s:5:9 \ +// RUN: -cursor-at=%s:7:5 \ +// RUN: -cursor-at=%s:7:8 \ // RUN: %s | FileCheck %s // CHECK: StructDecl=_MyS:1:8 (Definition) // CHECK: FieldDecl=foo:2:7 (Definition) // CHECK: TypeRef=struct _MyS:1:8 +// CHECK: VarDecl=x:7:5 +// CHECK: VarDecl=y:7:8 diff --git a/test/Index/get-cursor.cpp b/test/Index/get-cursor.cpp index e1e6835becad..8b70216dd165 100644 --- a/test/Index/get-cursor.cpp +++ b/test/Index/get-cursor.cpp @@ -38,6 +38,13 @@ void test() { } catch (X e) { X x; } + + struct LocalS { + void meth() { + int x; + ++x; + } + }; } // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s @@ -93,3 +100,6 @@ void test() { // RUN: c-index-test -test-load-source-usrs local %s | FileCheck -check-prefix=CHECK-USR %s // CHECK-USR: get-cursor.cpp c:get-cursor.cpp@472@F@test#@e Extent=[38:12 - 38:15] // CHECK-USR: get-cursor.cpp c:get-cursor.cpp@483@F@test#@x Extent=[39:5 - 39:8] + +// RUN: c-index-test -cursor-at=%s:45:9 %s | FileCheck -check-prefix=CHECK-LOCALCLASS %s +// CHECK-LOCALCLASS: 45:9 DeclRefExpr=x:44:11 Extent=[45:9 - 45:10] Spelling=x ([45:9 - 45:10]) diff --git a/test/Index/get-cursor.m b/test/Index/get-cursor.m index 5ac337598816..d3da9ec19726 100644 --- a/test/Index/get-cursor.m +++ b/test/Index/get-cursor.m @@ -69,6 +69,28 @@ void foo3(Test3 *test3) { @class Forw1, Forw2, Forw3; +@interface Test5 { + id prop1; + id prop2; +} +@property (assign) id prop1; +@property (assign) id prop2; +@property (assign) id prop3; +@property (assign) id prop4; +@end + +@implementation Test5 +@synthesize prop1, prop2; +@dynamic prop3, prop4; + +-(id)meth1 { + return 0; +} +-(id)meth2{ + return 0; +} +@end + // RUN: c-index-test -cursor-at=%s:4:28 -cursor-at=%s:5:28 %s | FileCheck -check-prefix=CHECK-PROP %s // CHECK-PROP: ObjCPropertyDecl=foo1:4:26 // CHECK-PROP: ObjCPropertyDecl=foo2:5:27 @@ -102,3 +124,14 @@ void foo3(Test3 *test3) { // CHECK-SPELLRANGE: 70:8 ObjCClassRef=Forw1:70:8 Extent=[70:8 - 70:13] Spelling=Forw1 ([70:8 - 70:13]) // CHECK-SPELLRANGE: 70:15 ObjCClassRef=Forw2:70:15 Extent=[70:15 - 70:20] Spelling=Forw2 ([70:15 - 70:20]) // CHECK-SPELLRANGE: 70:22 ObjCClassRef=Forw3:70:22 Extent=[70:22 - 70:27] Spelling=Forw3 ([70:22 - 70:27]) + +// RUN: c-index-test -cursor-at=%s:83:15 -cursor-at=%s:83:21 \ +// RUN: -cursor-at=%s:84:12 -cursor-at=%s:84:20 %s | FileCheck -check-prefix=CHECK-MULTISYNTH %s +// CHECK-MULTISYNTH: 83:13 ObjCSynthesizeDecl=prop1:76:23 (Definition) Extent=[83:1 - 83:18] Spelling=prop1 ([83:13 - 83:18]) +// CHECK-MULTISYNTH: 83:20 ObjCSynthesizeDecl=prop2:77:23 (Definition) Extent=[83:1 - 83:25] Spelling=prop2 ([83:20 - 83:25]) +// CHECK-MULTISYNTH: 84:10 ObjCDynamicDecl=prop3:78:23 (Definition) Extent=[84:1 - 84:15] Spelling=prop3 ([84:10 - 84:15]) +// CHECK-MULTISYNTH: 84:17 ObjCDynamicDecl=prop4:79:23 (Definition) Extent=[84:1 - 84:22] Spelling=prop4 ([84:17 - 84:22]) + +// RUN: c-index-test -cursor-at=%s:86:7 -cursor-at=%s:89:7 %s | FileCheck -check-prefix=CHECK-SELECTORLOC %s +// CHECK-SELECTORLOC: 86:6 ObjCInstanceMethodDecl=meth1:86:6 (Definition) Extent=[86:1 - 88:2] Spelling=meth1 ([86:6 - 86:11]) Selector index=0 +// CHECK-SELECTORLOC: 89:6 ObjCInstanceMethodDecl=meth2:89:6 (Definition) Extent=[89:1 - 91:2] Spelling=meth2 ([89:6 - 89:11]) Selector index=0 diff --git a/test/Index/index-decls.m b/test/Index/index-decls.m index 9e4e620497fe..46d37c4345a4 100644 --- a/test/Index/index-decls.m +++ b/test/Index/index-decls.m @@ -11,12 +11,22 @@ @synthesize prop = _prop; @end -rdar://11015325 +// rdar://11015325 @interface I1 __attribute__((something)) @interface I2 @end @end -// RUN: c-index-test -index-file %s > %t +@interface I3 +@property (assign,readwrite) id auto_prop; +@end + +@implementation I3 +-(void)meth { + _auto_prop = 0; +} +@end + +// RUN: c-index-test -index-file %s -target x86_64-apple-macosx10.7 > %t // RUN: FileCheck %s -input-file=%t // CHECK: [indexDeclaration]: kind: objc-class | name: I | {{.*}} | loc: 1:12 // CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 3:2 @@ -28,3 +38,6 @@ __attribute__((something)) @interface I2 @end // CHECK: [indexDeclaration]: kind: objc-ivar | name: _prop | {{.*}} | loc: 11:20 // CHECK: [indexDeclaration]: kind: objc-instance-method | name: prop | {{.*}} | loc: 11:13 | {{.*}} | lexical-container: [I:10:17] // CHECK: [indexDeclaration]: kind: objc-instance-method | name: setProp: | {{.*}} | loc: 11:13 | {{.*}} | lexical-container: [I:10:17] + +// CHECK: [indexDeclaration]: kind: objc-ivar | name: _auto_prop | {{.*}} | loc: 20:33 +// CHECK: [indexEntityReference]: kind: objc-ivar | name: _auto_prop | {{.*}} | loc: 25:3 diff --git a/test/Index/index-kernel-invocation.cpp b/test/Index/index-kernel-invocation.cpp new file mode 100644 index 000000000000..dba8e6b91a08 --- /dev/null +++ b/test/Index/index-kernel-invocation.cpp @@ -0,0 +1,4 @@ +// RUN: c-index-test -index-file -arch i386 -mkernel %s | FileCheck %s + +// CHECK: [indexDeclaration]: kind: function | name: foobar +void foobar(void); diff --git a/test/Index/index-many-call-ops.cpp b/test/Index/index-many-call-ops.cpp new file mode 100644 index 000000000000..e732b5f188ae --- /dev/null +++ b/test/Index/index-many-call-ops.cpp @@ -0,0 +1,47 @@ +// RUN: c-index-test -index-file %s | FileCheck %s + +// rdar://11289247 +// Check that we don't get stack overflow trying to index a huge number of +// call operators. + +struct S { + S &operator()(); +}; + +// CHECK: [indexDeclaration]: kind: function | name: foo +void foo() { + S s; + s()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()() + ; +} + +// CHECK: [indexDeclaration]: kind: function | name: bar +void bar(); diff --git a/test/Index/index-refs.m b/test/Index/index-refs.m new file mode 100644 index 000000000000..b82345f9c685 --- /dev/null +++ b/test/Index/index-refs.m @@ -0,0 +1,18 @@ + +@class Protocol; + +@protocol Prot +@end + +struct FooS { + int x; +}; + +void foo() { + Protocol *p = @protocol(Prot); + @encode(struct FooS); +} + +// RUN: c-index-test -index-file %s | FileCheck %s +// CHECK: [indexEntityReference]: kind: objc-protocol | name: Prot | {{.*}} | loc: 12:27 +// CHECK: [indexEntityReference]: kind: struct | name: FooS | {{.*}} | loc: 13:18 diff --git a/test/Index/overrides.m b/test/Index/overrides.m index 690875456371..d0447b74739d 100644 --- a/test/Index/overrides.m +++ b/test/Index/overrides.m @@ -50,6 +50,52 @@ -(void)meth { } @end +@protocol P5 +-(void)kol; +-(void)kol; +@end + +@protocol P6 +@property (readonly) id prop1; +@property (readonly) id prop2; +-(void)meth; +@end + +@interface I3 <P6> +@property (readwrite) id prop1; +@property (readonly) id bar; +@end + +@interface I3() +@property (readwrite) id prop2; +@property (readwrite) id bar; +-(void)meth; +@end + +@interface B4 +-(id)prop; +-(void)setProp:(id)prop; +@end + +@interface I4 : B4 +@property (assign) id prop; +@end + +@interface B5 +@end + +@interface I5 : B5 +-(void)meth; +@end + +@interface B5(cat) +-(void)meth; +@end + +@implementation I5 +-(void)meth{} +@end + // RUN: c-index-test -test-load-source local %s | FileCheck %s // CHECK: overrides.m:12:9: ObjCInstanceMethodDecl=protoMethod:12:9 [Overrides @3:9] // CHECK: overrides.m:22:9: ObjCInstanceMethodDecl=method:22:9 [Overrides @16:9] @@ -59,3 +105,15 @@ // CHECK: overrides.m:32:9: ObjCInstanceMethodDecl=protoMethod:32:9 [Overrides @8:9] // CHECK: overrides.m:36:9: ObjCInstanceMethodDecl=protoMethod:36:9 [Overrides @12:9, @8:9, @32:9, @17:9] // CHECK: overrides.m:50:8: ObjCInstanceMethodDecl=meth:50:8 (Definition) [Overrides @43:8] +// CHECK: overrides.m:55:8: ObjCInstanceMethodDecl=kol:55:8 Extent=[55:1 - 55:12] +// CHECK: overrides.m:65:26: ObjCInstanceMethodDecl=prop1:65:26 [Overrides @59:25] Extent=[65:26 - 65:31] +// CHECK: overrides.m:65:26: ObjCInstanceMethodDecl=setProp1::65:26 Extent=[65:26 - 65:31] +// CHECK: overrides.m:70:26: ObjCInstanceMethodDecl=prop2:70:26 [Overrides @60:25] Extent=[70:26 - 70:31] +// CHECK: overrides.m:70:26: ObjCInstanceMethodDecl=setProp2::70:26 Extent=[70:26 - 70:31] +// CHECK: overrides.m:71:26: ObjCInstanceMethodDecl=setBar::71:26 Extent=[71:26 - 71:29] +// CHECK: overrides.m:72:8: ObjCInstanceMethodDecl=meth:72:8 [Overrides @61:8] Extent=[72:1 - 72:13] +// CHECK: overrides.m:81:23: ObjCInstanceMethodDecl=prop:81:23 [Overrides @76:6] Extent=[81:23 - 81:27] +// CHECK: overrides.m:81:23: ObjCInstanceMethodDecl=setProp::81:23 [Overrides @77:8] Extent=[81:23 - 81:27] +// CHECK: overrides.m:92:8: ObjCInstanceMethodDecl=meth:92:8 Extent=[92:1 - 92:13] +// CHECK: overrides.m:95:17: ObjCImplementationDecl=I5:95:17 (Definition) Extent=[95:1 - 97:2] +// CHECK: overrides.m:96:8: ObjCInstanceMethodDecl=meth:96:8 (Definition) [Overrides @92:8] Extent=[96:1 - 96:14] diff --git a/test/Index/pch-with-errors.c b/test/Index/pch-with-errors.c index be8728eb723b..2d396134e5f2 100644 --- a/test/Index/pch-with-errors.c +++ b/test/Index/pch-with-errors.c @@ -38,5 +38,7 @@ void foo(void) { // CHECK-INDEX: [indexEntityReference]: kind: function | name: erroneous // RUN: %clang -fsyntax-only %s -include %t.h 2>&1 | FileCheck -check-prefix=PCH-ERR %s - // PCH-ERR: error: PCH file contains compiler errors + +// RUN: c-index-test -write-pch %t.pch foobar.c 2>&1 | FileCheck -check-prefix=NONEXISTENT %s +// NONEXISTENT: Unable to load translation unit diff --git a/test/Index/print-typekind.m b/test/Index/print-typekind.m index 9db192938f44..565c5e38c4ce 100644 --- a/test/Index/print-typekind.m +++ b/test/Index/print-typekind.m @@ -1,10 +1,10 @@ @interface Foo @property (readonly) id x; -(int) mymethod; --(int) mymethod2:(int)x blah:(float)y; +-(const id) mymethod2:(id)x blah:(Class)y boo:(SEL)z; @end // RUN: c-index-test -test-print-typekind %s | FileCheck %s -// CHECK: ObjCPropertyDecl=x:2:25 typekind=Typedef [canonical=ObjCObjectPointer] +// CHECK: ObjCPropertyDecl=x:2:25 typekind=ObjCId [canonical=ObjCObjectPointer] // CHECK: ObjCInstanceMethodDecl=mymethod:3:8 typekind=Invalid [result=Int] -// CHECK: ObjCInstanceMethodDecl=mymethod2:blah::4:8 typekind=Invalid [result=Int] [args= Int Float] +// CHECK: ObjCInstanceMethodDecl=mymethod2:blah:boo::4:13 typekind=Invalid [result=ObjCId] [args= ObjCId ObjCClass ObjCSel] diff --git a/test/Index/recursive-cxx-member-calls.cpp b/test/Index/recursive-cxx-member-calls.cpp index b80cbf40e87c..9b93872ee01b 100644 --- a/test/Index/recursive-cxx-member-calls.cpp +++ b/test/Index/recursive-cxx-member-calls.cpp @@ -961,7 +961,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK-tokens: Punctuation: ">" [105:51 - 105:52] CallExpr=StringSwitch:87:12 // CHECK-tokens: Punctuation: "(" [105:53 - 105:54] CallExpr=StringSwitch:87:12 // CHECK-tokens: Identifier: "AttrName" [105:54 - 105:62] DeclRefExpr=AttrName:101:19 -// CHECK-tokens: Punctuation: ")" [105:62 - 105:63] CXXFunctionalCastExpr= +// CHECK-tokens: Punctuation: ")" [105:62 - 105:63] CallExpr=StringSwitch:87:12 // CHECK-tokens: Punctuation: "." [106:5 - 106:6] MemberRefExpr=Case:88:42 // CHECK-tokens: Identifier: "Case" [106:6 - 106:10] MemberRefExpr=Case:88:42 // CHECK-tokens: Punctuation: "(" [106:10 - 106:11] CallExpr=Case:88:42 @@ -2081,7 +2081,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK: 106:6: MemberRefExpr=Case:88:42 SingleRefName=[106:6 - 106:10] RefName=[106:6 - 106:10] Extent=[105:10 - 106:10] // CHECK: 105:10: CXXFunctionalCastExpr= Extent=[105:10 - 105:63] // CHECK: 105:16: TemplateRef=StringSwitch:83:47 Extent=[105:16 - 105:28] -// CHECK: 105:10: CallExpr=StringSwitch:87:12 Extent=[105:10 - 105:62] +// CHECK: 105:10: CallExpr=StringSwitch:87:12 Extent=[105:10 - 105:63] // CHECK: 105:54: CallExpr=StringRef:38:7 Extent=[105:54 - 105:62] // CHECK: 105:54: UnexposedExpr=AttrName:101:19 Extent=[105:54 - 105:62] // CHECK: 105:54: DeclRefExpr=AttrName:101:19 Extent=[105:54 - 105:62] @@ -2240,4 +2240,3 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo * Name) { // CHECK: 183:25: DeclRefExpr=AT_thiscall:27:44 Extent=[183:25 - 183:36] // CHECK: 184:11: StringLiteral= Extent=[184:11 - 184:21] // CHECK: 184:23: DeclRefExpr=AT_pascal:26:38 Extent=[184:23 - 184:32] - diff --git a/test/Lexer/bcpl-escaped-newline.c b/test/Lexer/bcpl-escaped-newline.c index 4d4a7b5e89eb..d87ee9b83aed 100644 --- a/test/Lexer/bcpl-escaped-newline.c +++ b/test/Lexer/bcpl-escaped-newline.c @@ -5,7 +5,8 @@ #error bar //??/ -#error qux // expected-error {{qux}} +#error qux +// expected-error@-1 {{qux}} // Trailing whitespace! //\ diff --git a/test/Lexer/c90.c b/test/Lexer/c90.c index d91057257dfb..7142c09ac486 100644 --- a/test/Lexer/c90.c +++ b/test/Lexer/c90.c @@ -32,3 +32,10 @@ void test3() { (void)L"\u1234"; // expected-error {{unicode escape sequences are only valid in C99 or C++}} (void)L'\u1234'; // expected-error {{unicode escape sequences are only valid in C99 or C++}} } + +#define PREFIX(x) foo ## x +int test4() { + int PREFIX(0p) = 0; + int *p = &PREFIX(0p+1); + return p[-1]; +} diff --git a/test/Lexer/char-literal.cpp b/test/Lexer/char-literal.cpp index 5dc53608f8f8..8556d468cba6 100644 --- a/test/Lexer/char-literal.cpp +++ b/test/Lexer/char-literal.cpp @@ -22,3 +22,6 @@ char m = '👿'; // expected-error {{character too large for enclosing character char32_t n = U'ab'; // expected-error {{Unicode character literals may not contain multiple characters}} char16_t o = '👽'; // expected-error {{character too large for enclosing character literal type}} + +char16_t p[2] = u"\U0000FFFF"; +char16_t q[2] = u"\U00010000"; // expected-error {{too long}} diff --git a/test/Lexer/hexfloat.cpp b/test/Lexer/hexfloat.cpp index 656693399fa1..9bd8f830f030 100644 --- a/test/Lexer/hexfloat.cpp +++ b/test/Lexer/hexfloat.cpp @@ -5,3 +5,11 @@ double e = 0x.p0; //expected-error{{hexadecimal floating constants require a sig double d = 0x.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}} float g = 0x1.2p2; // expected-warning{{hexadecimal floating constants are a C99 feature}} double h = 0x1.p2; // expected-warning{{hexadecimal floating constants are a C99 feature}} + +// PR12717: In order to minimally diverge from the C++ standard, we do not lex +// 'p[+-]' as part of a pp-number unless the token starts 0x and doesn't contain +// an underscore. +double i = 0p+3; // expected-error{{invalid suffix 'p' on integer constant}} +#define PREFIX(x) foo ## x +double foo0p = 1, j = PREFIX(0p+3); // ok +double k = 0x42_amp+3; // expected-error-re{{invalid suffix '_amp' on integer constant|no matching literal operator for call to 'operator "" _amp'}} diff --git a/test/Lexer/newline-eof.c b/test/Lexer/newline-eof.c index 825a266a0a36..a4a18835cf5f 100644 --- a/test/Lexer/newline-eof.c +++ b/test/Lexer/newline-eof.c @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -fsyntax-only -Wnewline-eof -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wnewline-eof %s 2>&1 | FileCheck %s // rdar://9133072 +// Make sure the diagnostic shows up properly at the end of the last line. +// CHECK: newline-eof.c:9:63 + // The following line isn't terminated, don't fix it. void foo() {} // expected-warning{{no newline at end of file}}
\ No newline at end of file diff --git a/test/Lexer/pragma-operators.cpp b/test/Lexer/pragma-operators.cpp index d1645adbc252..a76e0b2f97e2 100644 --- a/test/Lexer/pragma-operators.cpp +++ b/test/Lexer/pragma-operators.cpp @@ -9,7 +9,6 @@ // CHECK: #line // CHECK: #pragma warning(push) // CHECK: int foo() { return 0; } } -// CHECK: #line // CHECK: #pragma warning(pop) #define A(X) extern "C" { __pragma(warning(push)) \ int X() { return 0; } \ diff --git a/test/Lexer/wchar-signedness.c b/test/Lexer/wchar-signedness.c new file mode 100644 index 000000000000..fea0ecac64f5 --- /dev/null +++ b/test/Lexer/wchar-signedness.c @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple x86_64-none-linux-gnu | FileCheck %s --check-prefix=X86 +// RUN: %clang_cc1 -fsyntax-only -dM -E %s -triple armv7-none-eabi | FileCheck %s --check-prefix=ARM + +// CHECK-X86-NOT: #define __WCHAR_UNSIGNED__ +// CHECK-X86: #define __WINT_UNSIGNED__ 1 + +// CHECK-ARM: #define __WCHAR_UNSIGNED__ 1 +// CHECK-ARM-NOT: #define __WINT_UNSIGNED__ 1 diff --git a/test/Misc/ast-dump-wchar.cpp b/test/Misc/ast-dump-wchar.cpp new file mode 100644 index 000000000000..87d962fec870 --- /dev/null +++ b/test/Misc/ast-dump-wchar.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -std=c++11 -ast-dump %s -triple x86_64-linux-gnu | FileCheck %s + +char c8[] = u8"test\0\\\"\t\a\b\234"; +// CHECK: char c8[12] = (StringLiteral {{.*}} lvalue u8"test\000\\\"\t\a\b\234") + +char16_t c16[] = u"test\0\\\"\t\a\b\234\u1234"; +// CHECK: char16_t c16[13] = (StringLiteral {{.*}} lvalue u"test\000\\\"\t\a\b\234\u1234") + +char32_t c32[] = U"test\0\\\"\t\a\b\234\u1234\U0010ffff"; // \ +// CHECK: char32_t c32[14] = (StringLiteral {{.*}} lvalue U"test\000\\\"\t\a\b\234\u1234\U0010FFFF") + +wchar_t wc[] = L"test\0\\\"\t\a\b\234\u1234\xffffffff"; // \ +// CHECK: wchar_t wc[14] = (StringLiteral {{.*}} lvalue L"test\000\\\"\t\a\b\234\x1234\xFFFFFFFF") diff --git a/test/Misc/diag-aka-types.cpp b/test/Misc/diag-aka-types.cpp index 4c9a7312cdaf..3a00b7122e83 100644 --- a/test/Misc/diag-aka-types.cpp +++ b/test/Misc/diag-aka-types.cpp @@ -30,27 +30,6 @@ void test(Foo::foo* x) { bar::f(x); // expected-error{{cannot initialize a parameter of type 'Foo::foo *' (aka 'bar::Foo::foo *') with an lvalue of type 'Foo::foo *'}} } -// PR9548 - "no known conversion from 'vector<string>' to 'vector<string>'" -// vector<string> refers to two different types here. Make sure the message -// gives a way to tell them apart. -class versa_string; -typedef versa_string string; - -namespace std {template <typename T> class vector;} -using std::vector; - -void f(vector<string> v); // expected-note {{candidate function not viable: no known conversion from 'vector<string>' (aka 'std::vector<std::basic_string>') to 'vector<string>' (aka 'std::vector<versa_string>') for 1st argument}} - -namespace std { - class basic_string; - typedef basic_string string; - template <typename T> class vector {}; - void g() { - vector<string> v; - f(v); // expected-error{{no matching function for call to 'f'}} - } -} - namespace ns { struct str { static void method(struct data *) {} @@ -61,7 +40,7 @@ struct data { int i; }; typedef void (*callback)(struct data *); -void helper(callback cb) {} // expected-note{{candidate function not viable: no known conversion from 'void (*)(struct data *)' (aka 'void (*)(ns::data *)') to 'callback' (aka 'void (*)(struct data *)') for 1st argument;}} +void helper(callback cb) {} // expected-note{{candidate function not viable: no known conversion from 'void (*)(struct data *)' (aka 'void (*)(ns::data *)') to 'callback' (aka 'void (*)(struct data *)') for 1st argument}} void test() { helper(&ns::str::method); // expected-error{{no matching function for call to 'helper'}} diff --git a/test/Misc/diag-template-diffing-color.cpp b/test/Misc/diag-template-diffing-color.cpp new file mode 100644 index 000000000000..6903e848d3df --- /dev/null +++ b/test/Misc/diag-template-diffing-color.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -fcolor-diagnostics %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -fsyntax-only -fcolor-diagnostics -fdiagnostics-show-template-tree %s 2>&1 | FileCheck %s -check-prefix=TREE +// REQUIRES: ansi-escape-sequences +template<typename> struct foo {}; +void func(foo<int>); +int main() { + func(foo<double>()); +} +// CHECK: {{.*}}candidate function not viable: no known conversion from 'foo<{{.}}[0;1;36mdouble{{.}}[0m>' to 'foo<{{.}}[0;1;36mint{{.}}[0m>' for 1st argument{{.}}[0m +// TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// TREE: foo< +// TREE: [{{.}}[0;1;36mdouble{{.}}[0m != {{.}}[0;1;36mint{{.}}[0m]>{{.}}[0m + +foo<int> A; +foo<double> &B = A; +// CHECK: {{.*}}non-const lvalue reference to type 'foo<{{.}}[0;1;36mdouble{{.}}[0m{{.}}[1m>' cannot bind to a value of unrelated type 'foo<{{.}}[0;1;36mint{{.}}[0m{{.}}[1m>'{{.}}[0m +// TREE: non-const lvalue reference cannot bind to a value of unrelated type +// TREE: foo< +// TREE: [{{.}}[0;1;36mdouble{{.}}[0m{{.}}[1m != {{.}}[0;1;36mint{{.}}[0m{{.}}[1m]>{{.}}[0m diff --git a/test/Misc/diag-template-diffing.cpp b/test/Misc/diag-template-diffing.cpp new file mode 100644 index 000000000000..9addcc50aec6 --- /dev/null +++ b/test/Misc/diag-template-diffing.cpp @@ -0,0 +1,433 @@ +// RUN: %clang_cc1 -fsyntax-only %s -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-ELIDE-NOTREE +// RUN: %clang_cc1 -fsyntax-only %s -fno-elide-type -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-NOELIDE-NOTREE +// RUN: %clang_cc1 -fsyntax-only %s -fdiagnostics-show-template-tree -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-ELIDE-TREE +// RUN: %clang_cc1 -fsyntax-only %s -fno-elide-type -fdiagnostics-show-template-tree -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-NOELIDE-TREE + +// PR9548 - "no known conversion from 'vector<string>' to 'vector<string>'" +// vector<string> refers to two different types here. Make sure the message +// gives a way to tell them apart. +class versa_string; +typedef versa_string string; + +namespace std {template <typename T> class vector;} +using std::vector; + +void f(vector<string> v); + +namespace std { + class basic_string; + typedef basic_string string; + template <typename T> class vector {}; + void g() { + vector<string> v; + f(v); + } +} // end namespace std +// CHECK-ELIDE-NOTREE: no matching function for call to 'f' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<class std::basic_string>' to 'vector<class versa_string>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'f' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<class std::basic_string>' to 'vector<class versa_string>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'f' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: vector< +// CHECK-ELIDE-TREE: [class std::basic_string != class versa_string]> +// CHECK-NOELIDE-TREE: no matching function for call to 'f' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: vector< +// CHECK-NOELIDE-TREE: [class std::basic_string != class versa_string]> + +template <int... A> +class I1{}; +void set1(I1<1,2,3,4,2,3,4,3>) {}; +void test1() { + set1(I1<1,2,3,4,2,2,4,3,7>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set1' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'I1<[5 * ...], 2, [2 * ...], 7>' to 'I1<[5 * ...], 3, [2 * ...], (no argument)>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set1' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'I1<1, 2, 3, 4, 2, 2, 4, 3, 7>' to 'I1<1, 2, 3, 4, 2, 3, 4, 3, (no argument)>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set1' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: I1< +// CHECK-ELIDE-TREE: [5 * ...], +// CHECK-ELIDE-TREE: [2 != 3], +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: [7 != (no argument)]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set1' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: I1< +// CHECK-NOELIDE-TREE: 1, +// CHECK-NOELIDE-TREE: 2, +// CHECK-NOELIDE-TREE: 3, +// CHECK-NOELIDE-TREE: 4, +// CHECK-NOELIDE-TREE: 2, +// CHECK-NOELIDE-TREE: [2 != 3], +// CHECK-NOELIDE-TREE: 4, +// CHECK-NOELIDE-TREE: 3, +// CHECK-NOELIDE-TREE: [7 != (no argument)]> + +template <class A, class B, class C = void> +class I2{}; +void set2(I2<int, int>) {}; +void test2() { + set2(I2<double, int, int>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set2' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'I2<double, [...], int>' to 'I2<int, [...], (default) void>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set2' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'I2<double, int, int>' to 'I2<int, int, (default) void>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set2' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: I2< +// CHECK-ELIDE-TREE: [double != int], +// CHECK-ELIDE-TREE: [...], +// CHECK-ELIDE-TREE: [int != (default) void]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set2' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: I2< +// CHECK-NOELIDE-TREE: [double != int], +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: [int != (default) void]> + +int V1, V2, V3; +template <int* A, int *B> +class I3{}; +void set3(I3<&V1, &V2>) {}; +void test3() { + set3(I3<&V3, &V2>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set3' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'I3<&V3, [...]>' to 'I3<&V1, [...]>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set3' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'I3<&V3, &V2>' to 'I3<&V1, &V2>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set3' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: I3< +// CHECK-ELIDE-TREE: [&V3 != &V1] +// CHECK-ELIDE-TREE: [...]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set3' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: I3< +// CHECK-NOELIDE-TREE: [&V3 != &V1] +// CHECK-NOELIDE-TREE: &V2> + +template <class A, class B> +class Alpha{}; +template <class A, class B> +class Beta{}; +template <class A, class B> +class Gamma{}; +template <class A, class B> +class Delta{}; + +void set4(Alpha<int, int>); +void test4() { + set4(Beta<void, void>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set4' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set4' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set4' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument +// CHECK-NOELIDE-TREE: no matching function for call to 'set4' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument + +void set5(Alpha<Beta<Gamma<Delta<int, int>, int>, int>, int>); +void test5() { + set5(Alpha<Beta<Gamma<void, void>, double>, double>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set5' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha<Beta<Gamma<void, void>, double>, double>' to 'Alpha<Beta<Gamma<Delta<int, int>, int>, int>, int>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set5' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha<Beta<Gamma<void, void>, double>, double>' to 'Alpha<Beta<Gamma<Delta<int, int>, int>, int>, int>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set5' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: Alpha< +// CHECK-ELIDE-TREE: Beta< +// CHECK-ELIDE-TREE: Gamma< +// CHECK-ELIDE-TREE: [void != Delta<int, int>], +// CHECK-ELIDE-TREE: [void != int]> +// CHECK-ELIDE-TREE: [double != int]> +// CHECK-ELIDE-TREE: [double != int]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set5' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: Alpha< +// CHECK-NOELIDE-TREE: Beta< +// CHECK-NOELIDE-TREE: Gamma< +// CHECK-NOELIDE-TREE: [void != Delta<int, int>], +// CHECK-NOELIDE-TREE: [void != int]> +// CHECK-NOELIDE-TREE: [double != int]> +// CHECK-NOELIDE-TREE: [double != int]> + +void test6() { + set5(Alpha<Beta<Delta<int, int>, int>, int>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set5' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha<Beta<Delta<int, int>, [...]>, [...]>' to 'Alpha<Beta<Gamma<Delta<int, int>, int>, [...]>, [...]>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set5' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha<Beta<Delta<int, int>, int>, int>' to 'Alpha<Beta<Gamma<Delta<int, int>, int>, int>, int>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set5' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: Alpha< +// CHECK-ELIDE-TREE: Beta< +// CHECK-ELIDE-TREE: [Delta<int, int> != Gamma<Delta<int, int>, int>], +// CHECK-ELIDE-TREE: [...]> +// CHECK-ELIDE-TREE: [...]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set5' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: Alpha< +// CHECK-NOELIDE-TREE: Beta< +// CHECK-NOELIDE-TREE: [Delta<int, int> != Gamma<Delta<int, int>, int>], +// CHECK-NOELIDE-TREE: int> +// CHECK-NOELIDE-TREE: int> + +int a7, b7; +int c7[] = {1,2,3}; +template<int *A> +class class7 {}; +void set7(class7<&a7> A) {} +void test7() { + set7(class7<&a7>()); + set7(class7<&b7>()); + set7(class7<c7>()); + set7(class7<nullptr>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<&b7>' to 'class7<&a7>' for 1st argument +// CHECK-ELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<c7>' to 'class7<&a7>' for 1st argument +// CHECK-ELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<nullptr>' to 'class7<&a7>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<&b7>' to 'class7<&a7>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<c7>' to 'class7<&a7>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set7' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<nullptr>' to 'class7<&a7>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set7' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class7< +// CHECK-ELIDE-TREE: [&b7 != &a7]> +// CHECK-ELIDE-TREE: no matching function for call to 'set7' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class7< +// CHECK-ELIDE-TREE: [c7 != &a7]> +// CHECK-ELIDE-TREE: no matching function for call to 'set7' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class7< +// CHECK-ELIDE-TREE: [nullptr != &a7]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set7' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class7< +// CHECK-NOELIDE-TREE: [&b7 != &a7]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set7' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class7< +// CHECK-NOELIDE-TREE: [c7 != &a7]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set7' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class7< +// CHECK-NOELIDE-TREE: [nullptr != &a7]> + +template<typename ...T> struct S8 {}; +template<typename T> using U8 = S8<int, char, T>; +int f8(S8<int, char, double>); +int k8 = f8(U8<char>()); +// CHECK-ELIDE-NOTREE: no matching function for call to 'f8' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'S8<[2 * ...], char>' to 'S8<[2 * ...], double>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'f8' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'S8<int, char, char>' to 'S8<int, char, double>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'f8' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: S8< +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: [char != double]> +// CHECK-NOELIDE-TREE: no matching function for call to 'f8' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: S8< +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: char, +// CHECK-NOELIDE-TREE: [char != double]> + +template<typename ...T> struct S9 {}; +template<typename T> using U9 = S9<int, char, T>; +template<typename T> using V9 = U9<U9<T>>; +int f9(S9<int, char, U9<const double>>); +int k9 = f9(V9<double>()); + +// CHECK-ELIDE-NOTREE: no matching function for call to 'f9' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'S9<[2 * ...], S9<[2 * ...], double>>' to 'S9<[2 * ...], S9<[2 * ...], const double>>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'f9' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'S9<int, char, S9<int, char, double>>' to 'S9<int, char, S9<int, char, const double>>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'f9' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: S9< +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: S9< +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: [double != const double]>> +// CHECK-NOELIDE-TREE: no matching function for call to 'f9' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: S9< +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: char, +// CHECK-NOELIDE-TREE: S9< +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: char, +// CHECK-NOELIDE-TREE: [double != const double]>> + +template<typename ...A> class class_types {}; +void set10(class_types<int, int>) {} +void test10() { + set10(class_types<int>()); + set10(class_types<int, int, int>()); +} + +// CHECK-ELIDE-NOTREE: no matching function for call to 'set10' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<[...], (no argument)>' to 'class_types<[...], int>' for 1st argument +// CHECK-ELIDE-NOTREE: no matching function for call to 'set10' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<[2 * ...], int>' to 'class_types<[2 * ...], (no argument)>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set10' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<int, (no argument)>' to 'class_types<int, int>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set10' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<int, int, int>' to 'class_types<int, int, (no argument)>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set10' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_types< +// CHECK-ELIDE-TREE: [...], +// CHECK-ELIDE-TREE: [(no argument) != int]> +// CHECK-ELIDE-TREE: no matching function for call to 'set10' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_types< +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: [int != (no argument)]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set10' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_types< +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: [(no argument) != int]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set10' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_types< +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: [int != (no argument)]> + +template<int ...A> class class_ints {}; +void set11(class_ints<2, 3>) {} +void test11() { + set11(class_ints<1>()); + set11(class_ints<0, 3, 6>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set11' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<1, (no argument)>' to 'class_ints<2, 3>' for 1st argument +// CHECK-ELIDE-NOTREE: no matching function for call to 'set11' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<0, [...], 6>' to 'class_ints<2, [...], (no argument)>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set11' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<1, (no argument)>' to 'class_ints<2, 3>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set11' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<0, 3, 6>' to 'class_ints<2, 3, (no argument)>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set11' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_ints< +// CHECK-ELIDE-TREE: [1 != 2], +// CHECK-ELIDE-TREE: [(no argument) != 3]> +// CHECK-ELIDE-TREE: no matching function for call to 'set11' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_ints< +// CHECK-ELIDE-TREE: [0 != 2], +// CHECK-ELIDE-TREE: [...], +// CHECK-ELIDE-TREE: [6 != (no argument)]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set11' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_ints< +// CHECK-NOELIDE-TREE: [1 != 2], +// CHECK-NOELIDE-TREE: [(no argument) != 3]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set11' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_ints< +// CHECK-NOELIDE-TREE: [0 != 2], +// CHECK-NOELIDE-TREE: 3, +// CHECK-NOELIDE-TREE: [6 != (no argument)]> + +template<template<class> class ...A> class class_template_templates {}; +template<class> class tt1 {}; +template<class> class tt2 {}; +void set12(class_template_templates<tt1, tt1>) {} +void test12() { + set12(class_template_templates<tt2>()); + set12(class_template_templates<tt1, tt1, tt1>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set12' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_template_templates<template tt2, template (no argument)>' to 'class_template_templates<template tt1, template tt1>' for 1st argument +// CHECK-ELIDE-NOTREE: no matching function for call to 'set12' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_template_templates<[2 * ...], template tt1>' to 'class_template_templates<[2 * ...], template (no argument)>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set12' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_template_templates<template tt2, template (no argument)>' to 'class_template_templates<template tt1, template tt1>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set12' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_template_templates<template tt1, template tt1, template tt1>' to 'class_template_templates<template tt1, template tt1, template (no argument)>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set12' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_template_templates< +// CHECK-ELIDE-TREE: [template tt2 != template tt1], +// CHECK-ELIDE-TREE: [template (no argument) != template tt1]> +// CHECK-ELIDE-TREE: no matching function for call to 'set12' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_template_templates< +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: [template tt1 != template (no argument)]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set12' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_template_templates< +// CHECK-NOELIDE-TREE: [template tt2 != template tt1], +// CHECK-NOELIDE-TREE: [template (no argument) != template tt1]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set12' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_template_templates< +// CHECK-NOELIDE-TREE: template tt1, +// CHECK-NOELIDE-TREE: template tt1, +// CHECK-NOELIDE-TREE: [template tt1 != template (no argument)]> + +double a13, b13, c13, d13; +template<double* ...A> class class_ptrs {}; +void set13(class_ptrs<&a13, &b13>) {} +void test13() { + set13(class_ptrs<&c13>()); + set13(class_ptrss<&a13, &b13, &d13>()); +} +// CHECK-ELIDE-NOTREE: no matching function for call to 'set13' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ptrs<&c13, (no argument)>' to 'class_ptrs<&a13, &b13>' for 1st argument +// CHECK-ELIDE-NOTREE: no matching function for call to 'set13' +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ptrs<[2 * ...], &d13>' to 'class_ptrs<[2 * ...], (no argument)>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set13' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ptrs<&c13, (no argument)>' to 'class_ptrs<&a13, &b13>' for 1st argument +// CHECK-NOELIDE-NOTREE: no matching function for call to 'set13' +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ptrs<&a13, &b13, &d13>' to 'class_ptrs<&a13, &b13, (no argument)>' for 1st argument +// CHECK-ELIDE-TREE: no matching function for call to 'set13' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_ptrs< +// CHECK-ELIDE-TREE: [&c13 != &a13], +// CHECK-ELIDE-TREE: [(no argument) != &b13]> +// CHECK-ELIDE-TREE: no matching function for call to 'set13' +// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-ELIDE-TREE: class_ptrs< +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: [&d13 != (no argument)]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set13' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_ptrs< +// CHECK-NOELIDE-TREE: [&c13 != &a13], +// CHECK-NOELIDE-TREE: [(no argument) != &b13]> +// CHECK-NOELIDE-TREE: no matching function for call to 'set13' +// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument +// CHECK-NOELIDE-TREE: class_ptrs< +// CHECK-NOELIDE-TREE: &a13, +// CHECK-NOELIDE-TREE: &b13, +// CHECK-NOELIDE-TREE: [&d13 != (no argument)]> + + +// CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated. +// CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated. +// CHECK-ELIDE-TREE: {{[0-9]*}} errors generated. +// CHECK-NOELIDE-TREE: {{[0-9]*}} errors generated. diff --git a/test/Misc/diag-trailing-null-bytes.cpp b/test/Misc/diag-trailing-null-bytes.cpp new file mode 100644 index 000000000000..91b159ca257d --- /dev/null +++ b/test/Misc/diag-trailing-null-bytes.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only %s 2>&1 | FileCheck -strict-whitespace %s +// CHECK: {{ERR_DNS_SERVER_REQUIRES_TCP$}} + +// http://llvm.org/PR12674 +#define NET_ERROR(label, value) ERR_ ## label = value, + +NET_ERROR(DNS_SERVER_REQUIRES_TCP, -801) + +#undef NET_ERROR + diff --git a/test/Misc/emit-html.c b/test/Misc/emit-html.c index 48c8b61b38de..ec07a60a6066 100644 --- a/test/Misc/emit-html.c +++ b/test/Misc/emit-html.c @@ -16,3 +16,11 @@ int main(int argc, char **argv) { FOR_ALL_FILES(f) { } #endif +// <rdar://problem/11625964> +// -emit-html filters out # directives, but not _Pragma (or MS __pragma) +// Diagnostic push/pop is stateful, so re-lexing a file can cause problems +// if these pragmas are interpreted normally. +_Pragma("clang diagnostic push") +_Pragma("clang diagnostic ignored \"-Wformat-extra-args\"") +_Pragma("clang diagnostic pop") + diff --git a/test/Misc/integer-literal-printing.cpp b/test/Misc/integer-literal-printing.cpp index d751730d95f6..4085d606d2ad 100644 --- a/test/Misc/integer-literal-printing.cpp +++ b/test/Misc/integer-literal-printing.cpp @@ -2,10 +2,10 @@ // PR11179 template <short T> class Type1 {}; -template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate function [with T = -42] not viable: no known conversion from 'Type1<-42>' to 'Type1<-42> &' for 1st argument;}} +template <short T> void Function1(Type1<T>& x) {} // expected-note{{candidate function [with T = -42] not viable: expects an l-value for 1st argument}} template <unsigned short T> class Type2 {}; -template <unsigned short T> void Function2(Type2<T>& x) {} // expected-note{{candidate function [with T = 42] not viable: no known conversion from 'Type2<42>' to 'Type2<42> &' for 1st argument;}} +template <unsigned short T> void Function2(Type2<T>& x) {} // expected-note{{candidate function [with T = 42] not viable: expects an l-value for 1st argument}} void Function() { Function1(Type1<-42>()); // expected-error{{no matching function for call to 'Function1'}} diff --git a/test/Misc/serialized-diags-frontend.c b/test/Misc/serialized-diags-frontend.c new file mode 100644 index 000000000000..453ed1470aaa --- /dev/null +++ b/test/Misc/serialized-diags-frontend.c @@ -0,0 +1,8 @@ +// RUN: rm -f %t +// RUN: %clang -fsyntax-only %s -Wblahblah --serialize-diagnostics %t > /dev/null 2>&1 || true +// RUN: c-index-test -read-diagnostics %t 2>&1 | FileCheck %s + +// This test case tests that we can handle frontend diagnostics. + +// CHECK: warning: unknown warning option '-Wblahblah' +// CHECK: Number of diagnostics: 1 diff --git a/test/Misc/show-diag-options.c b/test/Misc/show-diag-options.c index f0404a8555de..ef0a5a660da4 100644 --- a/test/Misc/show-diag-options.c +++ b/test/Misc/show-diag-options.c @@ -23,5 +23,5 @@ void test(int x, int y) { // OPTION_ERROR_CATEGORY: {{.*}}: error: {{[a-z ]+}} [-Werror,-Wparentheses,Semantic Issue] // Leverage the fact that all these '//'s get warned about in C89 pedantic. - // OPTION_PEDANTIC: {{.*}}: warning: {{[/a-z ]+}} [-pedantic,-Wcomment] + // OPTION_PEDANTIC: {{.*}}: warning: {{[/a-z ]+}} [-Wcomment] } diff --git a/test/Misc/tabstop.c b/test/Misc/tabstop.c index 49c4d7bebbba..7f59b6ab32b1 100644 --- a/test/Misc/tabstop.c +++ b/test/Misc/tabstop.c @@ -35,13 +35,22 @@ void f(void) { if (0 & 1 == 1) {} + + if (1 == 0 & 1) + {} } // CHECK-3: {{^ }}if (0 & 1 == 1) // CHECK-3: {{^ }} ( ) +// CHECK-3: {{^ }}if (1 == 0 & 1) +// CHECK-3: {{^ }} ( ) // CHECK-4: {{^ }}if (0 & 1 == 1) // CHECK-4: {{^ }} ( ) +// CHECK-4: {{^ }}if (1 == 0 & 1) +// CHECK-4: {{^ }} ( ) // CHECK-5: {{^ }}if (0 & 1 == 1) // CHECK-5: {{^ }} ( ) +// CHECK-5: {{^ }}if (1 == 0 & 1) +// CHECK-5: {{^ }} ( ) diff --git a/test/Misc/warning-flags-enabled.c b/test/Misc/warning-flags-enabled.c new file mode 100644 index 000000000000..7ef5c94dbc8c --- /dev/null +++ b/test/Misc/warning-flags-enabled.c @@ -0,0 +1,27 @@ +// RUN: diagtool show-enabled %s | FileCheck %s +// +// This shows warnings which are on by default. +// We just check a few to make sure it's doing something sensible. +// +// CHECK: ext_unterminated_string +// CHECK: warn_condition_is_assignment +// CHECK: warn_null_arg + + +// RUN: diagtool show-enabled -Wno-everything %s | count 0 + + +// RUN: diagtool show-enabled -Wno-everything -Wobjc-root-class %s | FileCheck -check-prefix CHECK-WARN %s +// RUN: diagtool show-enabled -Wno-everything -Werror=objc-root-class %s | FileCheck -check-prefix CHECK-ERROR %s +// RUN: diagtool show-enabled -Wno-everything -Wfatal-errors=objc-root-class %s | FileCheck -check-prefix CHECK-FATAL %s +// +// CHECK-WARN: W warn_objc_root_class_missing [-Wobjc-root-class] +// CHECK-ERROR: E warn_objc_root_class_missing [-Wobjc-root-class] +// CHECK-FATAL: F warn_objc_root_class_missing [-Wobjc-root-class] + +// RUN: diagtool show-enabled --no-levels -Wno-everything -Wobjc-root-class %s | FileCheck -check-prefix CHECK-NO-LEVELS %s +// +// CHECK-NO-LEVELS-NOT: W +// CHECK-NO-LEVELS-NOT: E +// CHECK-NO-LEVELS-NOT: F +// CHECK-NO-LEVELS: warn_objc_root_class_missing [-Wobjc-root-class] diff --git a/test/Misc/warning-flags-tree.c b/test/Misc/warning-flags-tree.c new file mode 100644 index 000000000000..a64e942f20bd --- /dev/null +++ b/test/Misc/warning-flags-tree.c @@ -0,0 +1,56 @@ +// RUN: diagtool tree | FileCheck -strict-whitespace %s +// RUN: diagtool tree -Weverything | FileCheck -strict-whitespace %s +// RUN: diagtool tree everything | FileCheck -strict-whitespace %s +// +// These three ways of running diagtool tree are the same: +// they produce a tree for every top-level diagnostic flag. +// Just check a few to make sure we're actually showing more than one group. +// +// CHECK: -W +// CHECK: -Wextra +// CHECK: -Wmissing-field-initializers +// CHECK: warn_missing_field_initializers +// CHECK: -Wall +// CHECK: -Wmost + +// These flags are currently unimplemented; test that we output them anyway. +// CHECK: -Wstrict-aliasing +// CHECK-NEXT: -Wstrict-aliasing=0 +// CHECK-NEXT: -Wstrict-aliasing=1 +// CHECK-NEXT: -Wstrict-aliasing=2 +// CHECK: -Wstrict-overflow +// CHECK-NEXT: -Wstrict-overflow=0 +// CHECK-NEXT: -Wstrict-overflow=1 +// CHECK-NEXT: -Wstrict-overflow=2 +// CHECK-NEXT: -Wstrict-overflow=3 +// CHECK-NEXT: -Wstrict-overflow=4 +// CHECK-NEXT: -Wstrict-overflow=5 + + +// RUN: not diagtool tree -Wthis-is-not-a-valid-flag + + +// RUN: diagtool tree -Wgnu | FileCheck -strict-whitespace -check-prefix CHECK-GNU %s +// CHECK-GNU: -Wgnu +// CHECK-GNU: -Wgnu-designator +// CHECK-GNU: ext_gnu_array_range +// CHECK-GNU: ext_gnu_missing_equal_designator +// CHECK-GNU: ext_gnu_old_style_field_designator +// CHECK-GNU: -Wvla +// CHECK-GNU: ext_vla +// CHECK-GNU: ext_array_init_copy +// CHECK-GNU: ext_empty_struct_union +// CHECK-GNU: ext_expr_not_ice +// There are more GNU extensions but we don't need to check them all. + +// RUN: diagtool tree --flags-only -Wgnu | FileCheck -check-prefix CHECK-FLAGS-ONLY %s +// CHECK-FLAGS-ONLY: -Wgnu +// CHECK-FLAGS-ONLY: -Wgnu-designator +// CHECK-FLAGS-ONLY-NOT: ext_gnu_array_range +// CHECK-FLAGS-ONLY-NOT: ext_gnu_missing_equal_designator +// CHECK-FLAGS-ONLY-NOT: ext_gnu_old_style_field_designator +// CHECK-FLAGS-ONLY: -Wvla +// CHECK-FLAGS-ONLY-NOT: ext_vla +// CHECK-FLAGS-ONLY-NOT: ext_array_init_copy +// CHECK-FLAGS-ONLY-NOT: ext_empty_struct_union +// CHECK-FLAGS-ONLY-NOT: ext_expr_not_ice diff --git a/test/Misc/warning-flags.c b/test/Misc/warning-flags.c index bc0c941bd99d..06c70eb57c59 100644 --- a/test/Misc/warning-flags.c +++ b/test/Misc/warning-flags.c @@ -1,4 +1,5 @@ -RUN: diagtool list-warnings 2>&1 | FileCheck %s +RUN: diagtool list-warnings > %t 2>&1 +RUN: FileCheck --input-file=%t %s This test serves two purposes: @@ -17,73 +18,27 @@ This test serves two purposes: The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (253): -CHECK-NEXT: ext_anonymous_struct_union_qualified -CHECK-NEXT: ext_binary_literal -CHECK-NEXT: ext_cast_fn_obj +CHECK: Warnings without flags (159): CHECK-NEXT: ext_delete_void_ptr_operand -CHECK-NEXT: ext_designated_init -CHECK-NEXT: ext_duplicate_declspec -CHECK-NEXT: ext_ellipsis_exception_spec -CHECK-NEXT: ext_empty_fnmacro_arg -CHECK-NEXT: ext_empty_source_file CHECK-NEXT: ext_enum_friend -CHECK-NEXT: ext_enum_value_not_int -CHECK-NEXT: ext_enumerator_list_comma CHECK-NEXT: ext_expected_semi_decl_list -CHECK-NEXT: ext_explicit_instantiation_without_qualified_id CHECK-NEXT: ext_explicit_specialization_storage_class -CHECK-NEXT: ext_extra_ivar_semi -CHECK-NEXT: ext_extra_struct_semi -CHECK-NEXT: ext_forward_ref_enum -CHECK-NEXT: ext_freestanding_complex -CHECK-NEXT: ext_hexconstant_invalid -CHECK-NEXT: ext_ident_list_in_param -CHECK-NEXT: ext_imaginary_constant CHECK-NEXT: ext_implicit_lib_function_decl -CHECK-NEXT: ext_in_class_initializer_non_constant -CHECK-NEXT: ext_integer_complement_complex -CHECK-NEXT: ext_integer_complex -CHECK-NEXT: ext_integer_increment_complex -CHECK-NEXT: ext_invalid_sign_spec CHECK-NEXT: ext_missing_declspec -CHECK-NEXT: ext_missing_varargs_arg CHECK-NEXT: ext_missing_whitespace_after_macro_name CHECK-NEXT: ext_new_paren_array_nonconst -CHECK-NEXT: ext_nonstandard_escape -CHECK-NEXT: ext_param_not_declared -CHECK-NEXT: ext_paste_comma CHECK-NEXT: ext_plain_complex -CHECK-NEXT: ext_pp_bad_vaargs_use -CHECK-NEXT: ext_pp_comma_expr -CHECK-NEXT: ext_pp_ident_directive -CHECK-NEXT: ext_pp_include_next_directive -CHECK-NEXT: ext_pp_line_too_big CHECK-NEXT: ext_pp_macro_redef -CHECK-NEXT: ext_pp_warning_directive -CHECK-NEXT: ext_return_has_void_expr -CHECK-NEXT: ext_subscript_non_lvalue CHECK-NEXT: ext_template_arg_extra_parens -CHECK-NEXT: ext_thread_before -CHECK-NEXT: ext_top_level_semi -CHECK-NEXT: ext_typecheck_addrof_void -CHECK-NEXT: ext_typecheck_cast_nonscalar -CHECK-NEXT: ext_typecheck_cast_to_union CHECK-NEXT: ext_typecheck_comparison_of_distinct_pointers CHECK-NEXT: ext_typecheck_comparison_of_distinct_pointers_nonstandard -CHECK-NEXT: ext_typecheck_comparison_of_fptr_to_void CHECK-NEXT: ext_typecheck_comparison_of_pointer_integer CHECK-NEXT: ext_typecheck_cond_incompatible_operands CHECK-NEXT: ext_typecheck_cond_incompatible_operands_nonstandard -CHECK-NEXT: ext_typecheck_cond_one_void -CHECK-NEXT: ext_typecheck_convert_pointer_void_func CHECK-NEXT: ext_typecheck_ordered_comparison_of_function_pointers -CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_and_zero CHECK-NEXT: ext_typecheck_ordered_comparison_of_pointer_integer -CHECK-NEXT: ext_typecheck_zero_array_size CHECK-NEXT: ext_unknown_escape CHECK-NEXT: ext_using_undefined_std -CHECK-NEXT: ext_vla_folded_to_constant CHECK-NEXT: pp_include_next_absolute_path CHECK-NEXT: pp_include_next_in_primary CHECK-NEXT: pp_invalid_string_literal @@ -96,26 +51,6 @@ CHECK-NEXT: w_asm_qualifier_ignored CHECK-NEXT: warn_accessor_property_type_mismatch CHECK-NEXT: warn_anon_bitfield_width_exceeds_type_size CHECK-NEXT: warn_asm_label_on_auto_decl -CHECK-NEXT: warn_attribute_ibaction -CHECK-NEXT: warn_attribute_iboutlet -CHECK-NEXT: warn_attribute_ignored -CHECK-NEXT: warn_attribute_ignored_for_field_of_type -CHECK-NEXT: warn_attribute_malloc_pointer_only -CHECK-NEXT: warn_attribute_nonnull_no_pointers -CHECK-NEXT: warn_attribute_precede_definition -CHECK-NEXT: warn_attribute_sentinel_named_arguments -CHECK-NEXT: warn_attribute_sentinel_not_variadic -CHECK-NEXT: warn_attribute_type_not_supported -CHECK-NEXT: warn_attribute_unknown_visibility -CHECK-NEXT: warn_attribute_void_function_method -CHECK-NEXT: warn_attribute_weak_import_invalid_on_definition -CHECK-NEXT: warn_attribute_weak_on_field -CHECK-NEXT: warn_attribute_weak_on_local -CHECK-NEXT: warn_attribute_wrong_decl_type -CHECK-NEXT: warn_availability_and_unavailable -CHECK-NEXT: warn_availability_unknown_platform -CHECK-NEXT: warn_availability_version_ordering -CHECK-NEXT: warn_bad_receiver_type CHECK-NEXT: warn_bitfield_width_exceeds_type_size CHECK-NEXT: warn_bool_switch_condition CHECK-NEXT: warn_braces_around_scalar_init @@ -124,7 +59,6 @@ CHECK-NEXT: warn_call_to_pure_virtual_member_function_from_ctor_dtor CHECK-NEXT: warn_call_wrong_number_of_arguments CHECK-NEXT: warn_case_empty_range CHECK-NEXT: warn_char_constant_too_large -CHECK-NEXT: warn_class_method_not_found CHECK-NEXT: warn_cmdline_missing_macro_defs CHECK-NEXT: warn_collection_expr_type CHECK-NEXT: warn_conflicting_param_types @@ -133,19 +67,15 @@ CHECK-NEXT: warn_conflicting_variadic CHECK-NEXT: warn_conv_to_base_not_used CHECK-NEXT: warn_conv_to_self_not_used CHECK-NEXT: warn_conv_to_void_not_used -CHECK-NEXT: warn_cxx0x_right_shift_in_template_arg CHECK-NEXT: warn_delete_array_type -CHECK-NEXT: warn_division_by_zero CHECK-NEXT: warn_double_const_requires_fp64 CHECK-NEXT: warn_drv_assuming_mfloat_abi_is CHECK-NEXT: warn_drv_clang_unsupported -CHECK-NEXT: warn_drv_input_file_unused CHECK-NEXT: warn_drv_not_using_clang_arch CHECK-NEXT: warn_drv_not_using_clang_cpp CHECK-NEXT: warn_drv_not_using_clang_cxx CHECK-NEXT: warn_drv_objc_gc_unsupported CHECK-NEXT: warn_drv_pch_not_first_include -CHECK-NEXT: warn_drv_preprocessed_input_file_unused CHECK-NEXT: warn_dup_category_def CHECK-NEXT: warn_duplicate_protocol_def CHECK-NEXT: warn_enum_too_large @@ -155,24 +85,17 @@ CHECK-NEXT: warn_exception_caught_by_earlier_handler CHECK-NEXT: warn_excess_initializers CHECK-NEXT: warn_excess_initializers_in_char_array_initializer CHECK-NEXT: warn_expected_qualified_after_typename -CHECK-NEXT: warn_extern_init CHECK-NEXT: warn_extraneous_char_constant CHECK-NEXT: warn_fe_cc_log_diagnostics_failure CHECK-NEXT: warn_fe_cc_print_header_failure CHECK-NEXT: warn_fe_macro_contains_embedded_newline CHECK-NEXT: warn_file_asm_volatile -CHECK-NEXT: warn_function_attribute_wrong_type -CHECK-NEXT: warn_gc_attribute_weak_on_local -CHECK-NEXT: warn_gnu_inline_attribute_requires_inline CHECK-NEXT: warn_hex_escape_too_large CHECK-NEXT: warn_ignoring_ftabstop_value -CHECK-NEXT: warn_illegal_constant_array_size CHECK-NEXT: warn_implements_nscopying CHECK-NEXT: warn_incompatible_qualified_id CHECK-NEXT: warn_initializer_string_for_char_array_too_long CHECK-NEXT: warn_inline_namespace_reopened_noninline -CHECK-NEXT: warn_inst_method_not_found -CHECK-NEXT: warn_instance_method_on_class_found CHECK-NEXT: warn_integer_too_large CHECK-NEXT: warn_integer_too_large_for_signed CHECK-NEXT: warn_invalid_asm_cast_lvalue @@ -189,19 +112,13 @@ CHECK-NEXT: warn_multiple_method_decl CHECK-NEXT: warn_no_constructor_for_refconst CHECK-NEXT: warn_nonnull_pointers_only CHECK-NEXT: warn_not_compound_assign -CHECK-NEXT: warn_ns_attribute_wrong_parameter_type -CHECK-NEXT: warn_ns_attribute_wrong_return_type -CHECK-NEXT: warn_objc_object_attribute_wrong_type CHECK-NEXT: warn_objc_property_copy_missing_on_block -CHECK-NEXT: warn_objc_property_default_assign_on_object -CHECK-NEXT: warn_objc_property_no_assignment_attribute CHECK-NEXT: warn_objc_protocol_qualifier_missing_id CHECK-NEXT: warn_octal_escape_too_large CHECK-NEXT: warn_odr_tag_type_inconsistent CHECK-NEXT: warn_on_superclass_use CHECK-NEXT: warn_param_default_argument_redefinition CHECK-NEXT: warn_partial_specs_not_deducible -CHECK-NEXT: warn_pointer_attribute_wrong_type CHECK-NEXT: warn_pp_convert_lhs_to_positive CHECK-NEXT: warn_pp_convert_rhs_to_positive CHECK-NEXT: warn_pp_expr_overflow @@ -238,14 +155,11 @@ CHECK-NEXT: warn_property_attribute CHECK-NEXT: warn_property_getter_owning_mismatch CHECK-NEXT: warn_property_types_are_incompatible CHECK-NEXT: warn_readonly_property -CHECK-NEXT: warn_receiver_forward_class CHECK-NEXT: warn_redecl_library_builtin CHECK-NEXT: warn_redeclaration_without_attribute_prev_attribute_ignored CHECK-NEXT: warn_register_objc_catch_parm CHECK-NEXT: warn_related_result_type_compatibility_class CHECK-NEXT: warn_related_result_type_compatibility_protocol -CHECK-NEXT: warn_remainder_by_zero -CHECK-NEXT: warn_root_inst_method_not_found CHECK-NEXT: warn_second_parameter_of_va_start_not_last_named_argument CHECK-NEXT: warn_second_parameter_to_va_arg_never_compatible CHECK-NEXT: warn_standalone_specifier @@ -254,20 +168,17 @@ CHECK-NEXT: warn_static_non_static CHECK-NEXT: warn_template_export_unsupported CHECK-NEXT: warn_template_spec_extra_headers CHECK-NEXT: warn_tentative_incomplete_array -CHECK-NEXT: warn_transparent_union_attribute_field_size_align -CHECK-NEXT: warn_transparent_union_attribute_floating -CHECK-NEXT: warn_transparent_union_attribute_not_definition -CHECK-NEXT: warn_transparent_union_attribute_zero_fields CHECK-NEXT: warn_typecheck_function_qualifiers CHECK-NEXT: warn_unavailable_fwdclass_message CHECK-NEXT: warn_undef_interface CHECK-NEXT: warn_undef_interface_suggest CHECK-NEXT: warn_undef_protocolref CHECK-NEXT: warn_undefined_internal -CHECK-NEXT: warn_unknown_analyzer_checker CHECK-NEXT: warn_unknown_method_family -CHECK-NEXT: warn_unterminated_char -CHECK-NEXT: warn_unterminated_string CHECK-NEXT: warn_use_out_of_scope_declaration CHECK-NEXT: warn_weak_identifier_undeclared CHECK-NEXT: warn_weak_import + +The list of warnings in -Wpedantic should NEVER grow. + +CHECK: Number in -Wpedantic (not covered by other -W flags): 39 diff --git a/test/Misc/wnull-character.cpp b/test/Misc/wnull-character.cpp Binary files differdeleted file mode 100644 index a618da272a13..000000000000 --- a/test/Misc/wnull-character.cpp +++ /dev/null diff --git a/test/Modules/Inputs/Module.framework/Headers/Module.h b/test/Modules/Inputs/Module.framework/Headers/Module.h index 738b2221cbb5..f8949848bd4c 100644 --- a/test/Modules/Inputs/Module.framework/Headers/Module.h +++ b/test/Modules/Inputs/Module.framework/Headers/Module.h @@ -1,4 +1,8 @@ -// expected-warning{{umbrella header}} +// expected-warning 0-1 {{umbrella header}} + +// FIXME: The "umbrella header" warning should be moved to a separate test. +// This "0-1" is only here because the warning is only emitted when the +// module is (otherwise) successfully included. #ifndef MODULE_H #define MODULE_H diff --git a/test/Modules/Inputs/category_right.h b/test/Modules/Inputs/category_right.h index d993b50db4bf..812a84078249 100644 --- a/test/Modules/Inputs/category_right.h +++ b/test/Modules/Inputs/category_right.h @@ -8,5 +8,5 @@ -(void)right2; @end -@interface Foo(Duplicate) // expected-warning {{duplicate definition of category}} +@interface Foo(Duplicate) @end diff --git a/test/Modules/Inputs/import-decl.h b/test/Modules/Inputs/import-decl.h new file mode 100644 index 000000000000..9741d6c543ee --- /dev/null +++ b/test/Modules/Inputs/import-decl.h @@ -0,0 +1 @@ +struct T {}; diff --git a/test/Modules/Inputs/module.map b/test/Modules/Inputs/module.map index e8d1f2c666fc..79056cb51800 100644 --- a/test/Modules/Inputs/module.map +++ b/test/Modules/Inputs/module.map @@ -84,3 +84,6 @@ module MethodPoolA { module MethodPoolB { header "MethodPoolB.h" } +module import_decl { + header "import-decl.h" +} diff --git a/test/Modules/cstd.m b/test/Modules/cstd.m index 1752cd314bb3..e262c7e14429 100644 --- a/test/Modules/cstd.m +++ b/test/Modules/cstd.m @@ -13,7 +13,7 @@ void test_fprintf(FILE *file) { fprintf(file, "Hello, modules\n"); } -// Supplied by compiler, which forwards to the the "/usr/include" version. +// Supplied by compiler, which forwards to the "/usr/include" version. @__experimental_modules_import cstd.stdint; my_awesome_nonstandard_integer_type value; diff --git a/test/Modules/import-decl.cpp b/test/Modules/import-decl.cpp new file mode 100644 index 000000000000..76966934acc8 --- /dev/null +++ b/test/Modules/import-decl.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %t +// RUN: %clang -fmodule-cache-path %t -fmodules -x objective-c -I %S/Inputs -emit-ast -o %t.ast %s +// RUN: %clang -cc1 -ast-print -x ast - < %t.ast | FileCheck %s + +@__experimental_modules_import import_decl; +// CHECK: struct T + +int main() { + return 0; +} diff --git a/test/Modules/lookup.cpp b/test/Modules/lookup.cpp index 98390355339e..70d210750d94 100644 --- a/test/Modules/lookup.cpp +++ b/test/Modules/lookup.cpp @@ -5,6 +5,8 @@ import lookup_left_cxx; #define IMPORT(X) @__experimental_modules_import X IMPORT(lookup_right_cxx); +// in lookup_left.hpp: expected-warning@3 {{weak identifier 'weak_identifier' never declared}} + void test(int i, float f) { // unqualified lookup f0(&i); diff --git a/test/Modules/objc-categories.m b/test/Modules/objc-categories.m index 340f279adf3f..b26759239dda 100644 --- a/test/Modules/objc-categories.m +++ b/test/Modules/objc-categories.m @@ -12,6 +12,7 @@ // in category_left.h: expected-note {{previous definition}} +// in category_right.h: expected-warning@11 {{duplicate definition of category}} @interface Foo(Source) -(void)source; diff --git a/test/Modules/on-demand-build.m b/test/Modules/on-demand-build.m index cf1ae99ce0c9..4ee6b58d96b4 100644 --- a/test/Modules/on-demand-build.m +++ b/test/Modules/on-demand-build.m @@ -7,10 +7,7 @@ @interface OtherClass @end - - - -// in module: expected-note{{class method 'alloc' is assumed to return an instance of its receiver type ('Module *')}} +// in module: expected-note@17{{class method 'alloc' is assumed to return an instance of its receiver type ('Module *')}} void test_getModuleVersion() { const char *version = getModuleVersion(); const char *version2 = [Module version]; diff --git a/test/PCH/Inputs/__va_list_tag.h b/test/PCH/Inputs/__va_list_tag.h new file mode 100644 index 000000000000..e3266039a96e --- /dev/null +++ b/test/PCH/Inputs/__va_list_tag.h @@ -0,0 +1,5 @@ +// Header for PCH test __va_list_tag.h + +typedef __builtin_va_list va_list; + +extern int myvfprintf(const char * , va_list); diff --git a/test/PCH/__va_list_tag.c b/test/PCH/__va_list_tag.c new file mode 100644 index 000000000000..23c54ea8fb8e --- /dev/null +++ b/test/PCH/__va_list_tag.c @@ -0,0 +1,12 @@ +// PR13189 +// rdar://problem/11741429 +// Test this without pch. +// RUN: %clang_cc1 -triple=x86_64-unknown-freebsd7.0 -include %S/Inputs/__va_list_tag.h %s -emit-llvm -o - + +// Test with pch. +// RUN: %clang_cc1 -triple=x86_64-unknown-freebsd7.0 -emit-pch -x c-header -o %t %S/Inputs/__va_list_tag.h +// RUN: %clang_cc1 -triple=x86_64-unknown-freebsd7.0 -include-pch %t %s -verify + +int myvprintf(const char *fmt, va_list args) { + return myvfprintf(fmt, args); +} diff --git a/test/PCH/attrs.c b/test/PCH/attrs.c index 2f868ac6624e..6a4b8f667cbc 100644 --- a/test/PCH/attrs.c +++ b/test/PCH/attrs.c @@ -8,10 +8,11 @@ #ifndef HEADER #define HEADER -int f(int) __attribute__((visibility("default"), overloadable)); // expected-note{{previous overload}} +int f(int) __attribute__((visibility("default"), overloadable)); #else double f(double); // expected-error{{overloadable}} + // expected-note@11{{previous overload}} #endif diff --git a/test/PCH/badpch-dir.h.gch/.keep b/test/PCH/badpch-dir.h.gch/.keep new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/PCH/badpch-dir.h.gch/.keep diff --git a/test/PCH/badpch-empty.h.gch b/test/PCH/badpch-empty.h.gch new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/PCH/badpch-empty.h.gch diff --git a/test/PCH/badpch.c b/test/PCH/badpch.c new file mode 100644 index 000000000000..e687ef324682 --- /dev/null +++ b/test/PCH/badpch.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -include-pch %S/badpch-empty.h.gch %s 2>&1 | FileCheck -check-prefix=CHECK-EMPTY %s +// RUN: %clang_cc1 -fsyntax-only -include-pch %S/badpch-dir.h.gch %s 2>&1 | FileCheck -check-prefix=CHECK-DIR %s + +// The purpose of this test is to verify that various invalid PCH files are +// reported as such. + +// PR4568: The messages were much improved since the bug was filed on +// 2009-07-16, though in the case of the PCH being a directory, the error +// message still did not contain the name of the PCH. Also, r149918 which was +// submitted on 2012-02-06 introduced a segfault in the case where the PCH is +// an empty file and clang was built with assertions. +// CHECK-EMPTY: error: input is not a PCH file: '{{.*[/\\]}}badpch-empty.h.gch' +// CHECK-DIR: error: unable to read PCH file {{.*[/\\]}}badpch-dir.h.gch: diff --git a/test/PCH/chain-staticvar-instantiation.cpp b/test/PCH/chain-staticvar-instantiation.cpp new file mode 100644 index 000000000000..850b8d185e3c --- /dev/null +++ b/test/PCH/chain-staticvar-instantiation.cpp @@ -0,0 +1,45 @@ +// Without PCH +// RUN: %clang_cc1 -fsyntax-only -verify -include %s -include %s %s + +// With PCH +// RUN: %clang_cc1 -fsyntax-only -verify %s -chain-include %s -chain-include %s + +#ifndef HEADER1 +#define HEADER1 +//===----------------------------------------------------------------------===// + +namespace NS { + +template <class _Tp, _Tp __v> +struct TS +{ + static const _Tp value = __v; +}; + +template <class _Tp, _Tp __v> +const _Tp TS<_Tp, __v>::value; + +TS<int, 2> g1; + +} + +//===----------------------------------------------------------------------===// +#elif not defined(HEADER2) +#define HEADER2 +#if !defined(HEADER1) +#error Header inclusion order messed up +#endif + +int g2 = NS::TS<int, 2>::value; + +//===----------------------------------------------------------------------===// +#else +//===----------------------------------------------------------------------===// + +// expected-warning@+1 {{reached main file}} +#warning reached main file + +int g3 = NS::TS<int, 2>::value; + +//===----------------------------------------------------------------------===// +#endif diff --git a/test/PCH/chain-trivial.c b/test/PCH/chain-trivial.c index 85b1eabd86f8..a0f5827fb91d 100644 --- a/test/PCH/chain-trivial.c +++ b/test/PCH/chain-trivial.c @@ -1,4 +1,2 @@ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t1 %S/Inputs/chain-trivial1.h // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-pch -o %t2 -include-pch %t1 %S/Inputs/chain-trivial2.h -// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-print -include-pch %t2 %s | FileCheck %s -// CHECK: struct __va_list_tag { diff --git a/test/PCH/cxx-friends.cpp b/test/PCH/cxx-friends.cpp index a8d75586e431..bdba42bbcb51 100644 --- a/test/PCH/cxx-friends.cpp +++ b/test/PCH/cxx-friends.cpp @@ -11,3 +11,11 @@ class F { a->x = 0; } }; + +template<typename T> class PR12585::future_base::setter { +public: + int f() { + return promise<T*>().k; + } +}; +int k = PR12585::future_base::setter<int>().f(); diff --git a/test/PCH/cxx-friends.h b/test/PCH/cxx-friends.h index 2a33f15a5329..05dcc9606636 100644 --- a/test/PCH/cxx-friends.h +++ b/test/PCH/cxx-friends.h @@ -4,3 +4,15 @@ class A { int x; friend class F; }; + +namespace PR12585 { + struct future_base { + template<typename> class setter; + }; + template<typename> class promise { + // We used to inject this into future_base with no access specifier, + // then crash during AST writing. + template<typename> friend class future_base::setter; + int k; + }; +} diff --git a/test/PCH/cxx-member-init.cpp b/test/PCH/cxx-member-init.cpp index 28206652b8ff..20594d532e33 100644 --- a/test/PCH/cxx-member-init.cpp +++ b/test/PCH/cxx-member-init.cpp @@ -12,10 +12,14 @@ struct S { int &m = n; S *that = this; }; +template<typename T> struct X { T t {0}; }; #endif #ifdef SOURCE S s; + +struct E { explicit E(int); }; +X<E> x; #elif HEADER #undef HEADER #define SOURCE diff --git a/test/PCH/cxx-static_assert.cpp b/test/PCH/cxx-static_assert.cpp index ace12e0922d4..8049525fb598 100644 --- a/test/PCH/cxx-static_assert.cpp +++ b/test/PCH/cxx-static_assert.cpp @@ -9,11 +9,12 @@ #define HEADER template<int N> struct T { - static_assert(N == 2, "N is not 2!"); // expected-error {{static_assert failed "N is not 2!"}} + static_assert(N == 2, "N is not 2!"); }; #else +// expected-error@12 {{static_assert failed "N is not 2!"}} T<1> t1; // expected-note {{in instantiation of template class 'T<1>' requested here}} T<2> t2; diff --git a/test/PCH/cxx-trailing-return.cpp b/test/PCH/cxx-trailing-return.cpp index ff85f6d1c5fd..aa3879077f06 100644 --- a/test/PCH/cxx-trailing-return.cpp +++ b/test/PCH/cxx-trailing-return.cpp @@ -4,12 +4,14 @@ #ifndef HEADER_INCLUDED #define HEADER_INCLUDED -typedef auto f() -> int; // expected-note {{here}} -typedef int g(); // expected-note {{here}} +typedef auto f() -> int; +typedef int g(); #else typedef void f; // expected-error {{typedef redefinition with different types ('void' vs 'auto () -> int')}} + // expected-note@7 {{here}} typedef void g; // expected-error {{typedef redefinition with different types ('void' vs 'int ()')}} + // expected-note@8 {{here}} #endif diff --git a/test/PCH/cxx0x-default-delete.cpp b/test/PCH/cxx0x-default-delete.cpp index 6eb65d61df42..39a90b858fd2 100644 --- a/test/PCH/cxx0x-default-delete.cpp +++ b/test/PCH/cxx0x-default-delete.cpp @@ -9,15 +9,15 @@ struct foo { foo() = default; - void bar() = delete; // expected-note{{deleted here}} + void bar() = delete; }; struct baz { - ~baz() = delete; // expected-note{{deleted here}} + ~baz() = delete; }; class quux { - ~quux() = default; // expected-note{{private here}} + ~quux() = default; }; #else @@ -25,10 +25,10 @@ class quux { foo::foo() { } // expected-error{{definition of explicitly defaulted default constructor}} foo f; void fn() { - f.bar(); // expected-error{{deleted function}} + f.bar(); // expected-error{{deleted function}} expected-note@12{{deleted here}} } -baz bz; // expected-error{{deleted function}} -quux qx; // expected-error{{private destructor}} +baz bz; // expected-error{{deleted function}} expected-note@16{{deleted here}} +quux qx; // expected-error{{private destructor}} expected-note@20{{private here}} #endif diff --git a/test/PCH/cxx0x-delegating-ctors.cpp b/test/PCH/cxx0x-delegating-ctors.cpp index f2b7e9036252..bf5daefa5589 100644 --- a/test/PCH/cxx0x-delegating-ctors.cpp +++ b/test/PCH/cxx0x-delegating-ctors.cpp @@ -8,13 +8,17 @@ #ifndef PASS1 #define PASS1 struct foo { - foo(int) : foo() { } // expected-note{{it delegates to}} + foo(int) : foo() { } foo(); - foo(bool) : foo('c') { } // expected-note{{it delegates to}} - foo(char) : foo(true) { } // expected-error{{creates a delegation cycle}} \ - // expected-note{{which delegates to}} + foo(bool) : foo('c') { } + foo(char) : foo(true) { } }; #else foo::foo() : foo(1) { } // expected-error{{creates a delegation cycle}} \ // expected-note{{which delegates to}} + +// expected-note@11{{it delegates to}} +// expected-note@13{{it delegates to}} +// expected-error@14{{creates a delegation cycle}} +// expected-note@14{{which delegates to}} #endif diff --git a/test/PCH/cxx11-constexpr.cpp b/test/PCH/cxx11-constexpr.cpp index 338543ecf93b..ce43206d3960 100644 --- a/test/PCH/cxx11-constexpr.cpp +++ b/test/PCH/cxx11-constexpr.cpp @@ -6,11 +6,11 @@ #define HEADER_INCLUDED struct B { - B(); // expected-note {{here}} + B(); constexpr B(char) {} }; -struct C { // expected-note {{not an aggregate and has no constexpr constructors}} +struct C { B b; double d = 0.0; }; @@ -24,6 +24,8 @@ struct D : B { static_assert(D(4).k == 9, ""); constexpr int f(C c) { return 0; } // expected-error {{not a literal type}} +// expected-note@13 {{not an aggregate and has no constexpr constructors}} constexpr B b; // expected-error {{constant expression}} expected-note {{non-constexpr}} + // expected-note@9 {{here}} #endif diff --git a/test/PCH/cxx11-enum-template.cpp b/test/PCH/cxx11-enum-template.cpp index 70b0ff9ecbd2..ca70601da77c 100644 --- a/test/PCH/cxx11-enum-template.cpp +++ b/test/PCH/cxx11-enum-template.cpp @@ -7,7 +7,7 @@ template<typename T> struct S { enum class E { - e = T() // expected-error {{conversion from 'double' to 'int'}} + e = T() }; }; @@ -20,7 +20,7 @@ template struct S<char>; int k1 = (int)S<int>::E::e; int k2 = (int)decltype(b)::e; -int k3 = (int)decltype(c)::e; // expected-note {{here}} +int k3 = (int)decltype(c)::e; // expected-error@10 {{conversion from 'double' to 'int'}} expected-note {{here}} int k4 = (int)S<char>::E::e; #endif diff --git a/test/PCH/cxx11-user-defined-literals.cpp b/test/PCH/cxx11-user-defined-literals.cpp index 4a7c24b9944e..7ad17f55d712 100644 --- a/test/PCH/cxx11-user-defined-literals.cpp +++ b/test/PCH/cxx11-user-defined-literals.cpp @@ -8,7 +8,7 @@ using size_t = decltype(sizeof(int)); int operator"" _foo(const char *p, size_t); -template<typename T> auto f(T t) -> decltype(t + ""_foo) { return 0; } // expected-note {{substitution failure}} +template<typename T> auto f(T t) -> decltype(t + ""_foo) { return 0; } #else @@ -17,5 +17,6 @@ int k = f(0); int *l = f(&k); struct S {}; int m = f(S()); // expected-error {{no matching}} + // expected-note@11 {{substitution failure}} #endif diff --git a/test/PCH/empty-with-headers.c b/test/PCH/empty-with-headers.c new file mode 100644 index 000000000000..751be1c9eb39 --- /dev/null +++ b/test/PCH/empty-with-headers.c @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic-errors %s +// RUN: %clang_cc1 -fsyntax-only -std=c99 -emit-pch -o %t %s +// RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic-errors -include-pch %t %s + +// RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic-errors -DINCLUDED %s -verify +// This last one should warn for -Wempty-translation-unit (C99 6.9p1). + +#if defined(INCLUDED) + +// empty except for the prefix header + +#elif defined(HEADER) + +typedef int my_int; +#define INCLUDED + +#else + +#define HEADER +#include "empty-with-headers.c" +// empty except for the header + +#endif + +// This should only fire if the header is not included, +// either explicitly or as a prefix header. +// expected-error{{ISO C requires a translation unit to contain at least one declaration.}} diff --git a/test/PCH/exprs.h b/test/PCH/exprs.h index 09a50135e40e..d08b1f64edec 100644 --- a/test/PCH/exprs.h +++ b/test/PCH/exprs.h @@ -87,7 +87,7 @@ struct { int x; float y; } designated_inits[3] = { [0].y = 17, - [2].x = 12.3, // expected-warning {{implicit conversion turns literal floating-point number into integer}} + [2].x = 12.3, // expected-warning {{implicit conversion from 'double' to 'int' changes value from 12.3 to 12}} 3.5 }; // TypesCompatibleExpr diff --git a/test/PCH/format-strings.c b/test/PCH/format-strings.c new file mode 100644 index 000000000000..7198c4d3a263 --- /dev/null +++ b/test/PCH/format-strings.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -D FOOBAR="\"\"" %s -emit-pch -o %t.pch +// RUN: %clang_cc1 -D FOOBAR="\"\"" %s -include-pch %t.pch + +// rdar://11418366 + +#ifndef HEADER +#define HEADER + +extern int printf(const char *restrict, ...); +#define LOG printf(FOOBAR "%f", __LINE__) + +#else + +void foo() { + LOG; +} + +#endif diff --git a/test/PCH/ms-if-exists.cpp b/test/PCH/ms-if-exists.cpp index 4bea198d9bab..be29ac62ef24 100644 --- a/test/PCH/ms-if-exists.cpp +++ b/test/PCH/ms-if-exists.cpp @@ -11,7 +11,7 @@ void f(T t) { } __if_not_exists(T::bar) { - int *i = t; // expected-error{{no viable conversion from 'HasFoo' to 'int *'}} + int *i = t; { } } } @@ -25,5 +25,6 @@ struct HasBar { }; template void f(HasFoo); // expected-note{{in instantiation of function template specialization 'f<HasFoo>' requested here}} + // expected-error@14{{no viable conversion from 'HasFoo' to 'int *'}} template void f(HasBar); #endif diff --git a/test/PCH/objc_methods.h b/test/PCH/objc_methods.h index c9b1ad4342c6..6dfa24896238 100644 --- a/test/PCH/objc_methods.h +++ b/test/PCH/objc_methods.h @@ -9,3 +9,33 @@ // FIXME: @compatibility_alias AliasForTestPCH TestPCH; +// http://llvm.org/PR12689 +@interface PR12689 +@end + +@implementation PR12689 +-(void)mugi:(int)x { + switch(x) { + case 23: {} + } +} +-(void)bonk:(int)x { + switch(x) { + case 42: {} + } +} +@end + +@interface PR12689_2 +@end + +@implementation PR12689_2 +-(void)mugi:(int)x { + switch(x) { + case 23: [self bonk:x]; break; + case 82: break; + } +} +-(void)bonk:(int)x { +} +@end diff --git a/test/PCH/objc_methods.m b/test/PCH/objc_methods.m index e90a463dce6b..e8aab843dc51 100644 --- a/test/PCH/objc_methods.m +++ b/test/PCH/objc_methods.m @@ -1,5 +1,5 @@ // Test this without pch. -// RUN: %clang_cc1 -include %S/objc_methods.h -fsyntax-only -verify %s +// RUN: %clang_cc1 -include %S/objc_methods.h -fsyntax-only -Wno-objc-root-class -verify %s // Test with pch. // RUN: %clang_cc1 -x objective-c -emit-pch -o %t %S/objc_methods.h diff --git a/test/PCH/objc_stmts.m b/test/PCH/objc_stmts.m index 3bc728c35e42..b9b10c53480a 100644 --- a/test/PCH/objc_stmts.m +++ b/test/PCH/objc_stmts.m @@ -1,11 +1,11 @@ // Test this without pch. // RUN: %clang_cc1 -include %S/objc_stmts.h -emit-llvm -fobjc-exceptions -o - %s -// RUN: %clang_cc1 -include %S/objc_stmts.h -ast-dump -fobjc-exceptions -o - %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -include %S/objc_stmts.h -ast-dump -fobjc-exceptions -o - %s | FileCheck %s // Test with pch. // RUN: %clang_cc1 -x objective-c -emit-pch -fobjc-exceptions -o %t %S/objc_stmts.h // RUN: %clang_cc1 -include-pch %t -emit-llvm -fobjc-exceptions -o - %s -// RUN: %clang_cc1 -include-pch %t -ast-dump -fobjc-exceptions -o - %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -include-pch %t -ast-dump -fobjc-exceptions -o - %s | FileCheck %s // CHECK: catch parm = "A *a" // CHECK: catch parm = "B *b" diff --git a/test/PCH/pch__VA_ARGS__.c b/test/PCH/pch__VA_ARGS__.c new file mode 100644 index 000000000000..9bc1d3c66b8e --- /dev/null +++ b/test/PCH/pch__VA_ARGS__.c @@ -0,0 +1,6 @@ +// Test with pch. +// RUN: %clang_cc1 -emit-pch -o %t %S/pch__VA_ARGS__.h +// RUN: %clang_cc1 -include-pch %t -fsyntax-only -Weverything %s 2>&1 | FileCheck %s + +#define mylog(...) printf(__VA_ARGS__) +// CHECK-NOT: warning: __VA_ARGS__ can only appear in the expansion of a C99 variadic macro diff --git a/test/PCH/pch__VA_ARGS__.h b/test/PCH/pch__VA_ARGS__.h new file mode 100644 index 000000000000..9eb1005ce447 --- /dev/null +++ b/test/PCH/pch__VA_ARGS__.h @@ -0,0 +1,2 @@ +// Header for PCH test fuzzy-pch.c +void f(int X); diff --git a/test/PCH/remap-file-from-pch.cpp b/test/PCH/remap-file-from-pch.cpp new file mode 100644 index 000000000000..8b965cf11c34 --- /dev/null +++ b/test/PCH/remap-file-from-pch.cpp @@ -0,0 +1,10 @@ +// %clang_cc1 -remap-file "%s;%S/Inputs/remapped-file" -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXIST %s + +// RUN: %clang_cc1 -x c++-header %s.h -emit-pch -o %t.pch +// RUN: %clang_cc1 %s -include-pch %t.pch -remap-file "%s.h;%s.remap.h" -fsyntax-only 2>&1 | FileCheck %s + +const char *str = STR; +int ge = zool; + +// CHECK: file '{{.*[/\\]}}remap-file-from-pch.cpp.h' from the precompiled header has been overridden +// CHECK: use of undeclared identifier 'zool' diff --git a/test/PCH/remap-file-from-pch.cpp.h b/test/PCH/remap-file-from-pch.cpp.h new file mode 100644 index 000000000000..0edf6aa7cd3d --- /dev/null +++ b/test/PCH/remap-file-from-pch.cpp.h @@ -0,0 +1,2 @@ + +#define STR "nexus" diff --git a/test/PCH/remap-file-from-pch.cpp.remap.h b/test/PCH/remap-file-from-pch.cpp.remap.h new file mode 100644 index 000000000000..e8e8ab7e4bdb --- /dev/null +++ b/test/PCH/remap-file-from-pch.cpp.remap.h @@ -0,0 +1,4 @@ + +#define STR "nexus" + +int zool; diff --git a/test/PCH/replaced-decl.m b/test/PCH/replaced-decl.m index b9fee950d7a1..5636a5746161 100644 --- a/test/PCH/replaced-decl.m +++ b/test/PCH/replaced-decl.m @@ -12,11 +12,12 @@ #elif !defined(HEADER2) #define HEADER2 -@interface I // expected-note {{previous}} +@interface I @end #else typedef int I; // expected-error {{redefinition}} + // expected-note@15 {{previous}} #endif diff --git a/test/PCH/typo2.cpp b/test/PCH/typo2.cpp index f9b4c833e040..9aa97bdfb177 100644 --- a/test/PCH/typo2.cpp +++ b/test/PCH/typo2.cpp @@ -4,10 +4,11 @@ #ifndef HEADER_INCLUDED #define HEADER_INCLUDED -void func(struct Test); // expected-note{{'Test' declared here}} +void func(struct Test); #else ::Yest *T; // expected-error{{did you mean 'Test'}} + // expected-note@7{{'Test' declared here}} #endif diff --git a/test/PCH/variables.c b/test/PCH/variables.c index 9f90b37d4162..2c8c1368e173 100644 --- a/test/PCH/variables.c +++ b/test/PCH/variables.c @@ -11,12 +11,12 @@ extern float y; extern int *ip, x; -float z; // expected-note{{previous}} +float z; -int z2 = 17; // expected-note{{previous}} +int z2 = 17; #define MAKE_HAPPY(X) X##Happy -int MAKE_HAPPY(Very); // expected-note{{previous definition is here}} +int MAKE_HAPPY(Very); #define A_MACRO_IN_THE_PCH 492 #define FUNCLIKE_MACRO(X, Y) X ## Y @@ -32,9 +32,9 @@ int UNIQUE(a); // a1 int *ip2 = &x; float *fp = &ip; // expected-warning{{incompatible pointer types}} -double z; // expected-error{{redefinition}} -int z2 = 18; // expected-error{{redefinition}} -double VeryHappy; // expected-error{{redefinition}} +double z; // expected-error{{redefinition}} expected-note@14{{previous}} +int z2 = 18; // expected-error{{redefinition}} expected-note@16{{previous}} +double VeryHappy; // expected-error{{redefinition}} expected-note@19{{previous definition is here}} int Q = A_MACRO_IN_THE_PCH; diff --git a/test/Parser/DelayedTemplateParsing.cpp b/test/Parser/DelayedTemplateParsing.cpp index 9737c731bd17..77b47239f4c8 100644 --- a/test/Parser/DelayedTemplateParsing.cpp +++ b/test/Parser/DelayedTemplateParsing.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify %s +// RUN: %clang_cc1 -fms-extensions -fdelayed-template-parsing -fsyntax-only -verify -std=c++11 %s template <class T> class A { @@ -90,3 +90,14 @@ Callback Bind() { } } + +namespace rdar11700604 { + template<typename T> void foo() = delete; + + struct X { + X() = default; + + template<typename T> void foo() = delete; + }; +} + diff --git a/test/Parser/MicrosoftExtensions.c b/test/Parser/MicrosoftExtensions.c index 1ef326aaf5d3..7703999d67ce 100644 --- a/test/Parser/MicrosoftExtensions.c +++ b/test/Parser/MicrosoftExtensions.c @@ -3,24 +3,24 @@ __stdcall int func0(); int __stdcall func(); typedef int (__cdecl *tptr)(); void (*__fastcall fastpfunc)(); -struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {}; +struct __declspec(uuid("00000000-0000-0000-C000-000000000046")) __declspec(novtable) IUnknown {}; /* expected-warning{{__declspec attribute 'novtable' is not supported}} */ extern __declspec(dllimport) void __stdcall VarR4FromDec(); __declspec(deprecated) __declspec(deprecated) char * __cdecl ltoa( long _Val, char * _DstBuf, int _Radix); -__declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory ); +__declspec(noalias) __declspec(restrict) void * __cdecl xxx( void * _Memory ); /* expected-warning{{__declspec attribute 'noalias' is not supported}} expected-warning{{__declspec attribute 'restrict' is not supported}} */ typedef __w64 unsigned long ULONG_PTR, *PULONG_PTR; void * __ptr64 PtrToPtr64(const void *p) { - return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p ); // expected-warning {{unknown attribute '__ptr64' ignored}} + return((void * __ptr64) (unsigned __int64) (ULONG_PTR)p ); } void * __ptr32 PtrToPtr32(const void *p) { - return((void * __ptr32) (unsigned __int32) (ULONG_PTR)p ); // expected-warning {{unknown attribute '__ptr32' ignored}} + return((void * __ptr32) (unsigned __int32) (ULONG_PTR)p ); } void __forceinline InterlockedBitTestAndSet (long *Base, long Bit) { - __asm { + __asm { // expected-warning {{MS-style inline assembly is not supported}} mov eax, Bit mov ecx, Base lock bts [ecx], eax @@ -29,6 +29,11 @@ void __forceinline InterlockedBitTestAndSet (long *Base, long Bit) } _inline int foo99() { return 99; } +void test_ms_alignof_alias() { + unsigned int s = _alignof(int); + s = __builtin_alignof(int); +} + void *_alloca(int); void foo() { @@ -49,8 +54,8 @@ char x = FOO(a); typedef enum E { e1 }; -enum __declspec(deprecated) E2 { i, j, k }; -__declspec(deprecated) enum E3 { a, b, c } e; +enum __declspec(deprecated) E2 { i, j, k }; // expected-note {{declared here}} +__declspec(deprecated) enum E3 { a, b, c } e; // expected-note {{declared here}} void deprecated_enum_test(void) { @@ -64,7 +69,7 @@ void deprecated_enum_test(void) [repeatable][source_annotation_attribute( Parameter|ReturnValue )] struct SA_Post{ SA_Post(); int attr; }; -[returnvalue:SA_Post( attr=1)] +[returnvalue:SA_Post( attr=1)] int foo1([SA_Post(attr=1)] void *param); @@ -75,3 +80,25 @@ void ms_intrinsics(int a) __assume(a); __debugbreak(); } + +struct __declspec(frobble) S1 {}; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} */ +struct __declspec(12) S2 {}; /* expected-error {{__declspec attributes must be an identifier or string literal}} */ +struct __declspec("testing") S3 {}; /* expected-warning {{__declspec attribute '"testing"' is not supported}} */ + +/* Ensure multiple declspec attributes are supported */ +struct __declspec(align(8) deprecated) S4 {}; + +/* But multiple declspecs must still be legal */ +struct __declspec(deprecated frobble "testing") S5 {}; /* expected-warning {{unknown __declspec attribute 'frobble' ignored}} expected-warning {{__declspec attribute '"testing"' is not supported}} */ +struct __declspec(unknown(12) deprecated) S6 {}; /* expected-warning {{unknown __declspec attribute 'unknown' ignored}}*/ + +struct S7 { + int foo() { return 12; } + __declspec(property(get=foo) deprecated) int t; // expected-note {{declared here}} +}; + +/* Technically, this is legal (though it does nothing) */ +__declspec() void quux( void ) { + struct S7 s; + int i = s.t; /* expected-warning {{'t' is deprecated}} */ +} diff --git a/test/Parser/MicrosoftExtensions.cpp b/test/Parser/MicrosoftExtensions.cpp index 3a1ffea453ca..6219e29f597a 100644 --- a/test/Parser/MicrosoftExtensions.cpp +++ b/test/Parser/MicrosoftExtensions.cpp @@ -151,11 +151,24 @@ void missing_template_keyword(){ class AAAA { }; +template <typename T> +class SimpleTemplate {}; + template <class T> void redundant_typename() { typename T t;// expected-warning {{expected a qualified name after 'typename'}} typename AAAA a;// expected-warning {{expected a qualified name after 'typename'}} + t = 3; + + typedef typename T* pointerT;// expected-warning {{expected a qualified name after 'typename'}} + typedef typename SimpleTemplate<int> templateT;// expected-warning {{expected a qualified name after 'typename'}} + + pointerT pT = &t; + *pT = 4; + + int var; + int k = typename var;// expected-error {{expected a qualified name after 'typename'}} } @@ -284,28 +297,29 @@ int main () { missing_template_keyword<int>(); } +namespace access_protected_PTM { + class A { + protected: + void f(); // expected-note {{must name member using the type of the current context 'access_protected_PTM::B'}} + }; + class B : public A{ + public: + void test_access(); + static void test_access_static(); + }; -
-namespace access_protected_PTM {
-
-class A {
-protected:
- void f(); // expected-note {{must name member using the type of the current context 'access_protected_PTM::B'}}
-};
-
-class B : public A{
-public:
- void test_access();
- static void test_access_static();
-};
-
-void B::test_access() {
- &A::f; // expected-error {{'f' is a protected member of 'access_protected_PTM::A'}}
-}
-
-void B::test_access_static() {
- &A::f;
-}
-
-}
\ No newline at end of file + void B::test_access() { + &A::f; // expected-error {{'f' is a protected member of 'access_protected_PTM::A'}} + } + + void B::test_access_static() { + &A::f; + } +} + +namespace Inheritance { + class __single_inheritance A; + class __multiple_inheritance B; + class __virtual_inheritance C; +} diff --git a/test/Parser/altivec.c b/test/Parser/altivec.c index d1e655213761..0bdc3dcffe2a 100644 --- a/test/Parser/altivec.c +++ b/test/Parser/altivec.c @@ -76,6 +76,16 @@ vector bool unsigned int v_bsc2; // expected-error {{cannot use 'unsigned' w vector bool long v_bl; // expected-error {{cannot use 'long' with '__vector bool'}} vector bool long long v_bll; // expected-error {{cannot use 'long long' with '__vector bool'}} +typedef char i8; +typedef short i16; +typedef int i32; +struct S { + // i8, i16, i32 here are field names, not type names. + vector bool i8; // expected-error {{requires a specifier or qualifier}} + vector pixel i16; + vector long i32; // expected-warning {{deprecated}} +}; + void f() { __vector unsigned int v = {0,0,0,0}; __vector int v__cast = (__vector int)v; diff --git a/test/Parser/c1x-alignas.c b/test/Parser/c1x-alignas.c index 5dccc99035ad..81cd6816307f 100644 --- a/test/Parser/c1x-alignas.c +++ b/test/Parser/c1x-alignas.c @@ -1,7 +1,13 @@ -// RUN: %clang_cc1 -std=c1x -fsyntax-only -verify %s +// RUN: %clang_cc1 -std=c11 -fsyntax-only -verify %s +// RUN: not %clang_cc1 -pedantic -fsyntax-only %s 2>&1 | FileCheck -check-prefix=CHECK-EXT %s _Alignas(4) char c1; unsigned _Alignas(long) char c2; char _Alignas(16) c3; char c4 _Alignas(32); // expected-error {{expected ';' after top level declarator}} + +char _Alignas(_Alignof(int)) c5; + +// CHECK-EXT: _Alignas is a C11-specific feature +// CHECK-EXT: _Alignof is a C11-specific feature diff --git a/test/Parser/completely-empty-header-file.h b/test/Parser/completely-empty-header-file.h new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Parser/completely-empty-header-file.h diff --git a/test/Parser/cuda-kernel-call.cu b/test/Parser/cuda-kernel-call.cu index f95ae9e6195f..92e46e3acaf5 100644 --- a/test/Parser/cuda-kernel-call.cu +++ b/test/Parser/cuda-kernel-call.cu @@ -1,9 +1,16 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +template<typename> struct S {}; +template<typename> void f(); + void foo(void) { foo<<<1; // expected-error {{expected '>>>'}} expected-note {{to match this '<<<'}} foo<<<1,1>>>; // expected-error {{expected '('}} foo<<<>>>(); // expected-error {{expected expression}} + + S<S<S<int>>> s; // expected-error 2{{use '> >'}} + + (void)(&f<S<S<int>>>==0); // expected-error 2{{use '> >'}} } diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp index 1b3dd41ee829..feccba85cf00 100644 --- a/test/Parser/cxx-class.cpp +++ b/test/Parser/cxx-class.cpp @@ -12,11 +12,15 @@ protected: int : 1, : 2; public: + void m0() {}; // ok, one extra ';' is permitted + void m1() {} + ; // ok, one extra ';' is permitted void m() { int l = 2; - }; + };; // expected-warning{{extra ';' after member function definition}} - template<typename T> void mt(T) { }; + template<typename T> void mt(T) { } + ; ; // expected-warning{{extra ';' inside a class}} virtual int vf() const volatile = 0; diff --git a/test/Parser/cxx-decl.cpp b/test/Parser/cxx-decl.cpp index 57f33d826fff..951cd3dfd1e1 100644 --- a/test/Parser/cxx-decl.cpp +++ b/test/Parser/cxx-decl.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux %s +// RUN: %clang_cc1 -verify -fsyntax-only -triple i386-linux -pedantic %s int x(*g); // expected-error {{use of undeclared identifier 'g'}} @@ -44,7 +44,7 @@ class asm_class_test { void foo() __asm__("baz"); }; -enum { fooenum = 1 }; +enum { fooenum = 1, }; // expected-warning {{commas at the end of enumerator lists are a C++11 extension}} struct a { int Type : fooenum; @@ -125,5 +125,3 @@ test6a { ;// expected-error {{C++ requires a type specifier for all declarations // expected-error {{expected ';' after top level declarator}} int test6b; - - diff --git a/test/Parser/cxx-extra-semi.cpp b/test/Parser/cxx-extra-semi.cpp new file mode 100644 index 000000000000..2aa18dfcc0e4 --- /dev/null +++ b/test/Parser/cxx-extra-semi.cpp @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -DPEDANTIC %s +// RUN: %clang_cc1 -fsyntax-only -Wextra-semi -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wextra-semi -verify -std=c++11 %s +// RUN: cp %s %t +// RUN: %clang_cc1 -x c++ -Wextra-semi -fixit %t +// RUN: %clang_cc1 -x c++ -Wextra-semi -Werror %t + +class A { + void A1(); + void A2() { }; +#ifndef PEDANTIC + // This warning is only produced if we specify -Wextra-semi, and not if only + // -pedantic is specified, since one semicolon is technically permitted. + // expected-warning@-4{{extra ';' after member function definition}} +#endif + void A2b() { };; // expected-warning{{extra ';' after member function definition}} + ; // expected-warning{{extra ';' inside a class}} + void A2c() { } + ; +#ifndef PEDANTIC + // expected-warning@-2{{extra ';' after member function definition}} +#endif + void A3() { }; ;; // expected-warning{{extra ';' after member function definition}} + ;;;;;;; // expected-warning{{extra ';' inside a class}} + ; // expected-warning{{extra ';' inside a class}} + ; ;; ; ;;; // expected-warning{{extra ';' inside a class}} + ; ; ; ; ;; // expected-warning{{extra ';' inside a class}} + void A4(); +}; + +union B { + int a1; + int a2;; // expected-warning{{extra ';' inside a union}} +}; + +; +; ;; +#if __cplusplus < 201103L +// expected-warning@-3{{extra ';' outside of a function is a C++11 extension}} +// expected-warning@-3{{extra ';' outside of a function is a C++11 extension}} +#endif diff --git a/test/Parser/cxx-template-argument.cpp b/test/Parser/cxx-template-argument.cpp index c85b1c928111..5479961d563d 100644 --- a/test/Parser/cxx-template-argument.cpp +++ b/test/Parser/cxx-template-argument.cpp @@ -10,3 +10,18 @@ A<int x; // expected-error {{expected '>'}} // PR8912 template <bool> struct S {}; S<bool(2 > 1)> s; + +// Test behavior when a template-id is ended by a token which starts with '>'. +namespace greatergreater { + template<typename T> struct S { S(); S(T); }; + void f(S<int>=0); // expected-error {{a space is required between a right angle bracket and an equals sign (use '> =')}} + void f(S<S<int>>=S<int>()); // expected-error {{use '> >'}} expected-error {{use '> ='}} + template<typename T> void t(); + void g() { + void (*p)() = &t<int>; + (void)(&t<int>==p); // expected-error {{use '> ='}} + (void)(&t<int>>=p); // expected-error {{use '> >'}} + (void)(&t<S<int>>>=p); // expected-error {{use '> >'}} + (void)(&t<S<int>>==p); // expected-error {{use '> >'}} expected-error {{use '> ='}} + } +} diff --git a/test/Parser/cxx-throw.cpp b/test/Parser/cxx-throw.cpp index d63b6d4cae6c..a1be710fb5c0 100644 --- a/test/Parser/cxx-throw.cpp +++ b/test/Parser/cxx-throw.cpp @@ -13,3 +13,5 @@ void foo() { __extension__ throw 1; // expected-error {{expected expression}} (void)throw; // expected-error {{expected expression}} } + +void f() throw(static); // expected-error {{expected a type}} expected-error {{does not allow storage class}} diff --git a/test/Parser/cxx-undeclared-identifier.cpp b/test/Parser/cxx-undeclared-identifier.cpp index f15deabc6da5..6ea2965913a9 100644 --- a/test/Parser/cxx-undeclared-identifier.cpp +++ b/test/Parser/cxx-undeclared-identifier.cpp @@ -1,5 +1,17 @@ // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s +namespace ImplicitInt { + static a(4); // expected-error {{requires a type specifier}} + b(int n); // expected-error {{requires a type specifier}} + c (*p)[]; // expected-error {{unknown type name 'c'}} + itn f(char *p, *q); // expected-error {{unknown type name 'itn'}} expected-error {{requires a type specifier}} + + struct S { + void f(); + }; + S::f() {} // expected-error {{requires a type specifier}} +} + // PR7180 int f(a::b::c); // expected-error {{use of undeclared identifier 'a'}} diff --git a/test/Parser/cxx-using-declaration.cpp b/test/Parser/cxx-using-declaration.cpp index 2b2a69d1a421..320fd09e55a1 100644 --- a/test/Parser/cxx-using-declaration.cpp +++ b/test/Parser/cxx-using-declaration.cpp @@ -43,3 +43,19 @@ using F::X; // Should have some errors here. Waiting for implementation. void X(int); struct X *x; + + +namespace ShadowedTagNotes { + +namespace foo { + class Bar {}; +} + +void Bar(int); // expected-note{{class 'Bar' is hidden by a non-type declaration of 'Bar' here}} +using foo::Bar; + +void ambiguity() { + const Bar *x; // expected-error{{must use 'class' tag to refer to type 'Bar' in this scope}} +} + +} // namespace ShadowedTagNotes diff --git a/test/Parser/cxx-using-directive.cpp b/test/Parser/cxx-using-directive.cpp index 1d781fbdcf64..9a1a6de89267 100644 --- a/test/Parser/cxx-using-directive.cpp +++ b/test/Parser/cxx-using-directive.cpp @@ -3,7 +3,8 @@ class A {}; namespace B { - namespace A {} // expected-note{{namespace '::B::A' defined here}} + namespace A {} // expected-note{{namespace '::B::A' defined here}} \ + // expected-note{{namespace 'B::A' defined here}} using namespace A ; } @@ -25,7 +26,7 @@ namespace D { } using namespace ! ; // expected-error{{expected namespace name}} -using namespace A ; // expected-error{{expected namespace name}} +using namespace A ; // expected-error{{no namespace named 'A'; did you mean 'B::A'?}} using namespace ::A // expected-error{{expected namespace name}} \ // expected-error{{expected ';' after namespace name}} B ; diff --git a/test/Parser/cxx0x-ambig.cpp b/test/Parser/cxx0x-ambig.cpp index 98757b48c716..96e200642b56 100644 --- a/test/Parser/cxx0x-ambig.cpp +++ b/test/Parser/cxx0x-ambig.cpp @@ -57,7 +57,7 @@ namespace bitfield { // This could be a bit-field, but would be ill-formed due to the anonymous // member being initialized. struct S5 { - enum E : int { a = 1 } { b = 2 }; // expected-error {{expected member name}} + enum E : int { a = 1 } { b = 2 }; // expected-error {{expected ';' after enum}} expected-error {{expected member name}} }; // This could be a bit-field. struct S6 { @@ -85,7 +85,7 @@ namespace trailing_return { struct S { S(int); - S *operator()() const; + S *operator()(...) const; int n; }; @@ -94,7 +94,9 @@ namespace trailing_return { // This parses as a function declaration, but DR1223 makes the presence of // 'auto' be used for disambiguation. S(a)()->n; // ok, expression; expected-warning{{expression result unused}} + S(a)(int())->n; // ok, expression; expected-warning{{expression result unused}} auto(a)()->n; // ok, function declaration + auto(b)(int())->n; // ok, function declaration using T = decltype(a); using T = auto() -> n; } diff --git a/test/Parser/cxx0x-attributes.cpp b/test/Parser/cxx0x-attributes.cpp index f97995e975c8..a0b8467bcca3 100644 --- a/test/Parser/cxx0x-attributes.cpp +++ b/test/Parser/cxx0x-attributes.cpp @@ -1,15 +1,50 @@ // RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 %s +// Need std::initializer_list +namespace std { + typedef decltype(sizeof(int)) size_t; + + // libc++'s implementation + template <class _E> + class initializer_list + { + const _E* __begin_; + size_t __size_; + + initializer_list(const _E* __b, size_t __s) + : __begin_(__b), + __size_(__s) + {} + + public: + typedef _E value_type; + typedef const _E& reference; + typedef const _E& const_reference; + typedef size_t size_type; + + typedef const _E* iterator; + typedef const _E* const_iterator; + + initializer_list() : __begin_(nullptr), __size_(0) {} + + size_t size() const {return __size_;} + const _E* begin() const {return __begin_;} + const _E* end() const {return __begin_ + __size_;} + }; +} + + // Declaration syntax checks [[]] int before_attr; int [[]] between_attr; +const [[]] int between_attr_2 = 0; // expected-error {{an attribute list cannot appear here}} int after_attr [[]]; int * [[]] ptr_attr; int & [[]] ref_attr = after_attr; int && [[]] rref_attr = 0; int array_attr [1] [[]]; alignas(8) int aligned_attr; -[[test::valid(for 42 [very] **** '+' symbols went on a trip; the end.)]] +[[test::valid(for 42 [very] **** '+' symbols went on a trip and had a "good"_time; the end.)]] int garbage_attr; [[,,,static, class, namespace,, inline, constexpr, mutable,, bi\ tand, bitor::compl(!.*_ Cx.!U^*R),,,]] int more_garbage_attr; @@ -19,7 +54,18 @@ void noexcept_fn_attr () noexcept [[]]; struct MemberFnOrder { virtual void f() const volatile && noexcept [[]] final = 0; }; +struct [[]] struct_attr; class [[]] class_attr {}; +union [[]] union_attr; +[[]] struct with_init_declarators {} init_declarator; +[[]] struct no_init_declarators; // expected-error {{an attribute list cannot appear here}} +[[]]; +struct ctordtor { + [[]] ctordtor(); + [[]] ~ctordtor(); +}; +[[]] ctordtor::ctordtor() {} +[[]] ctordtor::~ctordtor() {} extern "C++" [[]] int extern_attr; template <typename T> [[]] void template_attr (); [[]] [[]] int [[]] [[]] multi_attr [[]] [[]]; @@ -27,7 +73,8 @@ template <typename T> [[]] void template_attr (); int comma_attr [[,]]; int scope_attr [[foo::]]; // expected-error {{expected identifier}} int (paren_attr) [[]]; // expected-error {{an attribute list cannot appear here}} -unsigned [[]] int attr_in_decl_spec; // expected-error {{expected unqualified-id}} +unsigned [[]] int attr_in_decl_spec; // expected-error {{an attribute list cannot appear here}} +unsigned [[]] int [[]] const double_decl_spec = 0; // expected-error 2{{an attribute list cannot appear here}} class foo { void const_after_attr () [[]] const; // expected-error {{expected ';'}} }; @@ -40,6 +87,52 @@ extern "C++" [[]] { } // expected-error {{an attribute list cannot appear here}} [[]] using ns::i; // expected-error {{an attribute list cannot appear here}} [[]] using namespace ns; +[[]] using T = int; // expected-error {{an attribute list cannot appear here}} +using T [[]] = int; // ok +template<typename T> using U [[]] = T; +using ns::i [[]]; // expected-error {{an attribute list cannot appear here}} +using [[]] ns::i; // expected-error {{an attribute list cannot appear here}} + +auto trailing() -> [[]] const int; // expected-error {{an attribute list cannot appear here}} +auto trailing() -> const [[]] int; // expected-error {{an attribute list cannot appear here}} +auto trailing() -> const int [[]]; +auto trailing_2() -> struct struct_attr [[]]; + +namespace N { + struct S {}; +}; +template<typename> struct Template {}; + +// FIXME: Improve this diagnostic +struct [[]] N::S s; // expected-error {{an attribute list cannot appear here}} +struct [[]] Template<int> t; // expected-error {{an attribute list cannot appear here}} +struct [[]] ::template Template<int> u; // expected-error {{an attribute list cannot appear here}} +template struct [[]] Template<char>; // expected-error {{an attribute list cannot appear here}} +template <> struct [[]] Template<void>; + +enum [[]] E1 {}; +enum [[]] E2; // expected-error {{forbids forward references}} +enum [[]] E1; +enum [[]] E3 : int; +enum [[]] { + k_123 [[]] = 123 // expected-error {{an attribute list cannot appear here}} +}; +enum [[]] E1 e; // expected-error {{an attribute list cannot appear here}} +enum [[]] class E4 { }; // expected-error {{an attribute list cannot appear here}} +enum struct [[]] E5; + +struct S { + friend int f [[]] (); // expected-FIXME{{an attribute list cannot appear here}} + [[]] friend int g(); // expected-FIXME{{an attribute list cannot appear here}} + [[]] friend int h() { + } + friend class [[]] C; // expected-error{{an attribute list cannot appear here}} +}; +template<typename T> void tmpl(T) {} +template void tmpl [[]] (int); // expected-FIXME {{an attribute list cannot appear here}} +template [[]] void tmpl(char); // expected-error {{an attribute list cannot appear here}} +template void [[]] tmpl(short); + // Argument tests alignas int aligned_no_params; // expected-error {{expected '('}} alignas(i) int aligned_nonconst; // expected-error {{'aligned' attribute requires integer constant}} expected-note {{read of non-const variable 'i'}} @@ -81,3 +174,41 @@ void foo () { template<typename...Ts> void variadic() { void bar [[noreturn...]] (); // expected-error {{attribute 'noreturn' cannot be used as an attribute pack}} } + +// Expression tests +void bar () { + [] () [[noreturn]] { return; } (); // expected-error {{should not return}} + [] () [[noreturn]] { throw; } (); + new int[42][[]][5][[]]{}; +} + +// Condition tests +void baz () { + if ([[]] bool b = true) { + switch ([[]] int n { 42 }) { + default: + for ([[]] int n = 0; [[]] char b = n < 5; ++b) { + } + } + } + int x; + // An attribute can be applied to an expression-statement, such as the first + // statement in a for. But it can't be applied to a condition which is an + // expression. + for ([[]] x = 0; ; ) {} // expected-error {{an attribute list cannot appear here}} + for (; [[]] x < 5; ) {} // expected-error {{an attribute list cannot appear here}} + while ([[]] bool k { false }) { + } + while ([[]] true) { // expected-error {{an attribute list cannot appear here}} + } + do { + } while ([[]] false); // expected-error {{an attribute list cannot appear here}} + + for ([[]] int n : { 1, 2, 3 }) { + } +} + +enum class __attribute__((visibility("hidden"))) SecretKeepers { + one, /* rest are deprecated */ two, three +}; +enum class [[]] EvenMoreSecrets {}; diff --git a/test/Parser/cxx0x-decl.cpp b/test/Parser/cxx0x-decl.cpp index b9f5141a531e..a6fc49cb9e9d 100644 --- a/test/Parser/cxx0x-decl.cpp +++ b/test/Parser/cxx0x-decl.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -fsyntax-only -std=c++0x %s +// RUN: %clang_cc1 -verify -fsyntax-only -std=c++11 -pedantic %s // Make sure we know these are legitimate commas and not typos for ';'. namespace Commas { @@ -8,7 +8,7 @@ namespace Commas { } struct S {}; -enum E { e }; +enum E { e, }; auto f() -> struct S { return S(); @@ -16,3 +16,15 @@ auto f() -> struct S { auto g() -> enum E { return E(); } + +class ExtraSemiAfterMemFn { + // Due to a peculiarity in the C++11 grammar, a deleted or defaulted function + // is permitted to be followed by either one or two semicolons. + void f() = delete // expected-error {{expected ';' after delete}} + void g() = delete; // ok + void h() = delete;; // ok + void i() = delete;;; // expected-warning {{extra ';' after member function definition}} +}; + +int *const const p = 0; // ok +const const int *q = 0; // expected-warning {{duplicate 'const' declaration specifier}} diff --git a/test/Parser/cxx0x-lambda-expressions.cpp b/test/Parser/cxx0x-lambda-expressions.cpp index 9c7194142128..7e9d4751e6ef 100644 --- a/test/Parser/cxx0x-lambda-expressions.cpp +++ b/test/Parser/cxx0x-lambda-expressions.cpp @@ -40,4 +40,11 @@ class C { int a5[3] = { []{return 0;}() }; int a6[1] = {[this] = 1 }; // expected-error{{integral constant expression must have integral or unscoped enumeration type, not 'C *'}} } + + void delete_lambda(int *p) { + delete [] p; + delete [] (int*) { new int }; // ok, compound-literal, not lambda + delete [] { return new int; } (); // expected-error{{expected expression}} + delete [&] { return new int; } (); // ok, lambda + } }; diff --git a/test/Parser/cxx11-type-specifier.cpp b/test/Parser/cxx11-type-specifier.cpp index 2e629f3ab564..c66462a84f01 100644 --- a/test/Parser/cxx11-type-specifier.cpp +++ b/test/Parser/cxx11-type-specifier.cpp @@ -18,3 +18,7 @@ void f() { (void) new struct S {}; // expected-error{{'S' can not be defined in a type specifier}} (void) new enum E { e }; // expected-error{{'E' can not be defined in a type specifier}} } + +// And for trailing-type-specifier-seq + +auto f() -> unknown; // expected-error{{unknown type name 'unknown'}} diff --git a/test/Parser/declarators.c b/test/Parser/declarators.c index a7a01d8b4e83..f63b59f7caa6 100644 --- a/test/Parser/declarators.c +++ b/test/Parser/declarators.c @@ -100,3 +100,15 @@ long struct X { int x; } test15(); // expected-error {{'long struct' is invalid} void test16(i) int i j; { } // expected-error {{expected ';' at end of declaration}} void test17(i, j) int i, j k; { } // expected-error {{expected ';' at end of declaration}} + + +// PR12595 +void test18() { + int x = 4+(5-12)); // expected-error {{extraneous ')' before ';'}} +} + +enum E1 { e1 }: // expected-error {{expected ';'}} +struct EnumBitfield { + enum E2 { e2 } : 4; // ok + struct S { int n; }: // expected-error {{expected ';'}} +}; diff --git a/test/Parser/empty-translation-unit.c b/test/Parser/empty-translation-unit.c new file mode 100644 index 000000000000..0dbf37e447c3 --- /dev/null +++ b/test/Parser/empty-translation-unit.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c99 -pedantic -W -verify %s +// RUN: %clang_cc1 -fsyntax-only -x c++ -std=c++03 -pedantic-errors -W %s + +#include "completely-empty-header-file.h" +// no-warning -- an empty file is OK + +#define A_MACRO_IS_NOT_GOOD_ENOUGH 1 + +// In C we should get this warning, but in C++ we shouldn't. +// expected-warning{{ISO C requires a translation unit to contain at least one declaration.}} diff --git a/test/Parser/missing-selector-name.mm b/test/Parser/missing-selector-name.mm new file mode 100644 index 000000000000..d5554c5e6545 --- /dev/null +++ b/test/Parser/missing-selector-name.mm @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s +// rdar://11939584 + +@interface PodiumWalkerController +@property (assign) id PROP; +- (void) // expected-error {{expected ';' after method prototype}} +@end // expected-error {{expected selector for Objective-C method}} + + +id GVAR; + +id StopProgressAnimation() +{ + + PodiumWalkerController *controller; + return controller.PROP; +} + +@interface P1 +@property (assign) id PROP; +- (void); // expected-error {{expected selector for Objective-C method}} +@end + +id GG=0; + +id Stop1() +{ + + PodiumWalkerController *controller; + return controller.PROP; +} + +@interface P2 +@property (assign) id PROP; +- (void)Meth {} // expected-error {{expected ';' after method prototype}} +@end + +@interface P3 +@property (assign) id PROP; +- (void) +- (void)Meth {} // expected-error {{expected selector for Objective-C method}} \ + // expected-error {{expected ';' after method prototype}} +@end + +id HH=0; + +id Stop2() +{ + + PodiumWalkerController *controller; + return controller.PROP; +} diff --git a/test/Parser/ms-inline-asm.c b/test/Parser/ms-inline-asm.c index b1af23e47280..2d181958857b 100644 --- a/test/Parser/ms-inline-asm.c +++ b/test/Parser/ms-inline-asm.c @@ -3,23 +3,36 @@ #define M __asm int 0x2c #define M2 int -void t1(void) { M } -void t2(void) { __asm int 0x2c } -void t3(void) { __asm M2 0x2c } -void* t4(void) { __asm mov eax, fs:[0x10] } +void t1(void) { M } // expected-warning {{MS-style inline assembly is not supported}} +void t2(void) { __asm int 0x2c } // expected-warning {{MS-style inline assembly is not supported}} +void t3(void) { __asm M2 0x2c } // expected-warning {{MS-style inline assembly is not supported}} +void* t4(void) { __asm mov eax, fs:[0x10] } // expected-warning {{MS-style inline assembly is not supported}} void t5() { - __asm { + __asm { // expected-warning {{MS-style inline assembly is not supported}} int 0x2c ; } asm comments are fun! }{ } - __asm {} + __asm {} // no warning as this gets merged with the previous inline asm } int t6() { - __asm int 3 ; } comments for single-line asm - __asm {} + __asm int 3 ; } comments for single-line asm // expected-warning {{MS-style inline assembly is not supported}} + __asm {} // no warning as this gets merged with the previous inline asm - __asm int 4 + __asm int 4 // no warning as this gets merged with the previous inline asm return 10; } -int t7() { // expected-note {{to match this}} +int t7() { + __asm { // expected-warning {{MS-style inline assembly is not supported}} + push ebx + mov ebx, 0x07 + pop ebx + } +} +void t8() { + __asm nop __asm nop __asm nop // expected-warning {{MS-style inline assembly is not supported}} +} +void t9() { + __asm nop __asm nop ; __asm nop // expected-warning {{MS-style inline assembly is not supported}} +} +int t_fail() { // expected-note {{to match this}} __asm __asm { // expected-error 3 {{expected}} expected-note {{to match this}} diff --git a/test/Parser/objc-boxing.m b/test/Parser/objc-boxing.m new file mode 100644 index 000000000000..a16a137b8f65 --- /dev/null +++ b/test/Parser/objc-boxing.m @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +@interface NSString @end + +@interface NSString (NSStringExtensionMethods) ++ (id)stringWithUTF8String:(const char *)nullTerminatedCString; +@end + +extern char *strdup(const char *str); + +id constant_string() { + return @("boxed constant string."); +} + +id dynamic_string() { + return @(strdup("boxed dynamic string")); +} + +id const_char_pointer() { + return @((const char *)"constant character pointer"); +} + +id missing_parentheses() { + return @(5; // expected-error {{expected ')'}} \ + // expected-note {{to match this '('}} +} diff --git a/test/Parser/objc-diag-width.mm b/test/Parser/objc-diag-width.mm new file mode 100644 index 000000000000..3929ba2b090e --- /dev/null +++ b/test/Parser/objc-diag-width.mm @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 %s 2>&1 | FileCheck %s + +// Just shouldn't crash. -verify suppresses the crash, so don't use it. +// PR13417 +// CHECK-NOT: Assertion failed +@interface ExtensionActionContextMenu @end +@implementation ExtensionActionContextMenu +namespace { diff --git a/test/Parser/objc-forcollection-neg.m b/test/Parser/objc-forcollection-neg.m index 1a989a14464c..9e5400c5f2ed 100644 --- a/test/Parser/objc-forcollection-neg.m +++ b/test/Parser/objc-forcollection-neg.m @@ -26,12 +26,12 @@ typedef struct objc_object { int i=0; for (int * elem in elem) // expected-error {{selector element type 'int *' is not a valid object}} \ - expected-error {{collection expression type 'int *' is not a valid object}} + expected-error {{the type 'int *' is not a pointer to a fast-enumerable object}} ++i; for (i in elem) // expected-error {{use of undeclared identifier 'elem'}} \ expected-error {{selector element type 'int' is not a valid object}} ++i; - for (id se in i) // expected-error {{collection expression type 'int' is not a valid object}} + for (id se in i) // expected-error {{the type 'int' is not a pointer to a fast-enumerable object}} ++i; } @end diff --git a/test/Parser/objc-init.m b/test/Parser/objc-init.m index efa1266e7b8e..c9d7d5d301ea 100644 --- a/test/Parser/objc-init.m +++ b/test/Parser/objc-init.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -pedantic -Wno-objc-root-class %s -// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -x objective-c++ -Wno-objc-root-class %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -pedantic -Wno-objc-root-class %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class %s // rdar://5707001 @interface NSNumber; diff --git a/test/Parser/objc-recover.mm b/test/Parser/objc-recover.mm new file mode 100644 index 000000000000..61444c7178d0 --- /dev/null +++ b/test/Parser/objc-recover.mm @@ -0,0 +1,64 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s + +@interface StopAtAtEnd +// This used to eat the @end +int 123 // expected-error{{expected unqualified-id}} +@end + +@implementation StopAtAtEnd // no-warning +int 123 // expected-error{{expected unqualified-id}} +@end + + +@interface StopAtMethodDecls +// This used to eat the method declarations +int 123 // expected-error{{expected unqualified-id}} +- (void)foo; // expected-note{{here}} +int 456 // expected-error{{expected unqualified-id}} ++ (void)bar; // expected-note{{here}} +@end + +@implementation StopAtMethodDecls +int 123 // expected-error{{expected unqualified-id}} +- (id)foo {} // expected-warning{{conflicting return type}} +int 456 // expected-error{{expected unqualified-id}} ++ (id)bar {} // expected-warning{{conflicting return type}} +@end + + +@interface EmbeddedNamespace +// This used to cause an infinite loop. +namespace NS { // expected-error{{expected unqualified-id}} +} +- (id)test; // expected-note{{here}} +@end + +@implementation EmbeddedNamespace +int 123 // expected-error{{expected unqualified-id}} +// We should still stop here and parse this namespace. +namespace NS { + void foo(); +} + +// Make sure the declaration of -test was recognized. +- (void)test { // expected-warning{{conflicting return type}} + // Make sure the declaration of NS::foo was recognized. + NS::foo(); +} + +@end + + +@protocol ProtocolWithEmbeddedNamespace +namespace NS { // expected-error{{expected unqualified-id}} + +} +- (void)PWEN_foo; // expected-note{{here}} +@end + +@interface ImplementPWEN <ProtocolWithEmbeddedNamespace> +@end + +@implementation ImplementPWEN +- (id)PWEN_foo {} // expected-warning{{conflicting return type}} +@end diff --git a/test/Parser/objcxx11-attributes.mm b/test/Parser/objcxx11-attributes.mm index 0c91392978af..1b9bf66fad9a 100644 --- a/test/Parser/objcxx11-attributes.mm +++ b/test/Parser/objcxx11-attributes.mm @@ -35,7 +35,8 @@ void f(X *noreturn) { [[class, test(foo 'x' bar),,,]]; [[bitand, noreturn]]; // expected-warning {{attribute noreturn cannot be specified on a statement}} - [[noreturn]]int(e)(); + // FIXME: Suppress vexing parse warning + [[noreturn]]int(e)(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} int e2(); // expected-warning {{interpreted as a function declaration}} expected-note{{}} // A function taking a noreturn function. diff --git a/test/Parser/opencl-pragma.cl b/test/Parser/opencl-pragma.cl index 19460771137b..4c48b2a496f7 100644 --- a/test/Parser/opencl-pragma.cl +++ b/test/Parser/opencl-pragma.cl @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only +// RUN: %clang_cc1 %s -verify -pedantic -Wno-empty-translation-unit -fsyntax-only #pragma OPENCL EXTENSION cl_khr_fp16 : enable diff --git a/test/Parser/recovery.c b/test/Parser/recovery.c index 3916acfda1e0..178427e4b3c2 100644 --- a/test/Parser/recovery.c +++ b/test/Parser/recovery.c @@ -37,8 +37,9 @@ void test(int a) { test(0); else ; - - if (x.i == 0)) // expected-error {{expected expression}} + + // PR12595 + if (x.i == 0)) // expected-error {{extraneous ')' after condition, expected a statement}} test(0); else ; diff --git a/test/Parser/recovery.cpp b/test/Parser/recovery.cpp index ffa1bab55a44..ff687583c253 100644 --- a/test/Parser/recovery.cpp +++ b/test/Parser/recovery.cpp @@ -12,13 +12,12 @@ inline namespace Std { // expected-error {{cannot be reopened as inline}} int x; Std::Important y; -// FIXME: Recover as if the typo correction were applied. -extenr "C" { // expected-error {{did you mean 'extern'}} expected-error {{unqualified-id}} +extenr "C" { // expected-error {{did you mean the keyword 'extern'}} void f(); } void g() { z = 1; // expected-error {{undeclared}} - f(); // expected-error {{undeclared}} + f(); } struct S { @@ -37,6 +36,7 @@ namespace N { int } // expected-error {{unqualified-id}} -// FIXME: Recover as if the typo correction were applied. -strcut U { // expected-error {{did you mean 'struct'}} -} *u[3]; // expected-error {{expected ';'}} +strcut Uuuu { // expected-error {{did you mean the keyword 'struct'}} \ + // expected-note {{'Uuuu' declared here}} +} *u[3]; +uuuu v; // expected-error {{did you mean 'Uuuu'}} diff --git a/test/Preprocessor/_Pragma-location.c b/test/Preprocessor/_Pragma-location.c index 8b68d6ca1f76..5031ee4edcc6 100644 --- a/test/Preprocessor/_Pragma-location.c +++ b/test/Preprocessor/_Pragma-location.c @@ -1,4 +1,47 @@ -// RUN: %clang_cc1 %s -E | not grep 'scratch space' +// RUN: %clang_cc1 %s -fms-extensions -E | FileCheck %s +// We use -fms-extensions to test both _Pragma and __pragma. -#define push _Pragma ("pack(push)") -push +// A long time ago the pragma lexer's buffer showed through in -E output. +// CHECK-NOT: scratch space + +#define push_p _Pragma ("pack(push)") +push_p +// CHECK: #pragma pack(push) + +push_p _Pragma("pack(push)") __pragma(pack(push)) +// CHECK: #pragma pack(push) +// CHECK-NEXT: #line 11 "{{.*}}_Pragma-location.c" +// CHECK-NEXT: #pragma pack(push) +// CHECK-NEXT: #line 11 "{{.*}}_Pragma-location.c" +// CHECK-NEXT: #pragma pack(push) + + +#define __PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS _Pragma("clang diagnostic push") \ +_Pragma("clang diagnostic ignored \"-Wformat-extra-args\"") +#define __PRAGMA_POP_NO_EXTRA_ARG_WARNINGS _Pragma("clang diagnostic pop") + +void test () { + 1;_Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wformat-extra-args\"") + _Pragma("clang diagnostic pop") + + 2;__PRAGMA_PUSH_NO_EXTRA_ARG_WARNINGS + 3;__PRAGMA_POP_NO_EXTRA_ARG_WARNINGS +} + +// CHECK: void test () { +// CHECK-NEXT: 1; +// CHECK-NEXT: #line 24 "{{.*}}_Pragma-location.c" +// CHECK-NEXT: #pragma clang diagnostic push +// CHECK-NEXT: #pragma clang diagnostic ignored "-Wformat-extra-args" +// CHECK-NEXT: #pragma clang diagnostic pop + +// CHECK: 2; +// CHECK-NEXT: #line 28 "{{.*}}_Pragma-location.c" +// CHECK-NEXT: #pragma clang diagnostic push +// CHECK-NEXT: #line 28 "{{.*}}_Pragma-location.c" +// CHECK-NEXT: #pragma clang diagnostic ignored "-Wformat-extra-args" +// CHECK-NEXT: 3; +// CHECK-NEXT: #line 29 "{{.*}}_Pragma-location.c" +// CHECK-NEXT: #pragma clang diagnostic pop +// CHECK-NEXT: } diff --git a/test/Preprocessor/comment_save.c b/test/Preprocessor/comment_save.c index b86004272b20..1100ea29bba9 100644 --- a/test/Preprocessor/comment_save.c +++ b/test/Preprocessor/comment_save.c @@ -6,3 +6,17 @@ /* bar */ // CHECK: /* bar */ +#if FOO +#endif +/* baz */ +// CHECK: /* baz */ + +_Pragma("unknown") // after unknown pragma +// CHECK: #pragma unknown +// CHECK-NEXT: # +// CHECK-NEXT: // after unknown pragma + +_Pragma("comment(\"abc\")") // after known pragma +// CHECK: #pragma comment("abc") +// CHECK-NEXT: # +// CHECK-NEXT: // after known pragma diff --git a/test/Preprocessor/disabled-cond-diags2.c b/test/Preprocessor/disabled-cond-diags2.c new file mode 100644 index 000000000000..d0629aee4f2b --- /dev/null +++ b/test/Preprocessor/disabled-cond-diags2.c @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -Eonly -verify %s + +#if 0 +#if 1 +#endif junk // shouldn't produce diagnostics +#endif + +#if 0 +#endif junk // expected-warning{{extra tokens at end of #endif directive}} + +#if 1 junk // expected-error{{token is not a valid binary operator in a preprocessor subexpression}} +#X // shouldn't produce diagnostics (block #if condition not valid, so skipped) +#else +#X // expected-error{{invalid preprocessing directive}} +#endif + +#if 0 +// diagnostics should not be produced until final #endif +#X +#include +#if 1 junk +#else junk +#endif junk +#line -2 +#error +#warning +#endif junk // expected-warning{{extra tokens at end of #endif directive}} diff --git a/test/Preprocessor/has_attribute.c b/test/Preprocessor/has_attribute.c index 80f53a52fe38..711cf671cfea 100644 --- a/test/Preprocessor/has_attribute.c +++ b/test/Preprocessor/has_attribute.c @@ -24,3 +24,13 @@ int has_has_attribute(); #if !__has_attribute(something_we_dont_have) int has_something_we_dont_have(); #endif + +// rdar://10253857 +#if __has_attribute(__const) + int fn3() __attribute__ ((__const)); +#endif + +#if __has_attribute(const) + static int constFunction() __attribute__((const)); +#endif + diff --git a/test/Preprocessor/has_include.c b/test/Preprocessor/has_include.c index fdcae78b751e..13c8d566223f 100644 --- a/test/Preprocessor/has_include.c +++ b/test/Preprocessor/has_include.c @@ -65,19 +65,45 @@ #endif // Try badly formed expressions. -// FIXME: I don't quite know how to avoid preprocessor side effects. -// Use FileCheck? -// It also assert due to unterminated #if's. +// FIXME: We can recover better in almost all of these cases. (PR13335) + +// expected-error@+1 {{missing '(' after '__has_include'}} expected-error@+1 {{expected end of line}} +#if __has_include "stdint.h") +#endif + +// expected-error@+1 {{expected "FILENAME" or <FILENAME>}} expected-error@+1 {{token is not a valid binary operator in a preprocessor subexpression}} +#if __has_include(stdint.h) +#endif + +// expected-error@+1 {{expected "FILENAME" or <FILENAME>}} +#if __has_include() +#endif + +// expected-error@+1 {{missing '(' after '__has_include'}} +#if __has_include) +#endif + +// expected-error@+1 {{missing '(' after '__has_include'}} expected-error@+1 {{token is not a valid binary operator in a preprocessor subexpression}} +#if __has_include<stdint.h>) +#endif + +// expected-error@+1 {{expected "FILENAME" or <FILENAME>}} expected-warning@+1 {{missing terminating '"' character}} +#if __has_include("stdint.h) +#endif + +// expected-error@+1 {{expected "FILENAME" or <FILENAME>}} expected-warning@+1 {{missing terminating '"' character}} expected-error@+1 {{token is not a valid binary operator in a preprocessor subexpression}} +#if __has_include(stdint.h") +#endif + +// expected-error@+1 {{expected "FILENAME" or <FILENAME>}} expected-error@+1 {{token is not a valid binary operator in a preprocessor subexpression}} +#if __has_include(stdint.h>) +#endif + + +// FIXME: These test cases cause the compiler to crash. (PR13334) //#if __has_include("stdint.h" -//#if __has_include "stdint.h") -//#if __has_include(stdint.h) -//#if __has_include() //#if __has_include( -//#if __has_include) //#if __has_include //#if __has_include(<stdint.h> -//#if __has_include<stdint.h>) -//#if __has_include("stdint.h) -//#if __has_include(stdint.h") //#if __has_include(<stdint.h) -//#if __has_include(stdint.h>) + diff --git a/test/Preprocessor/init.c b/test/Preprocessor/init.c index e0f45f17283e..e7321e063099 100644 --- a/test/Preprocessor/init.c +++ b/test/Preprocessor/init.c @@ -48,6 +48,9 @@ // COMMON:#define __GNUC_STDC_INLINE__ 1 // COMMON:#define __GNUC__ // COMMON:#define __GXX_ABI_VERSION +// COMMON:#define __ORDER_BIG_ENDIAN__ 4321 +// COMMON:#define __ORDER_LITTLE_ENDIAN__ 1234 +// COMMON:#define __ORDER_PDP_ENDIAN__ 3412 // COMMON:#define __STDC_HOSTED__ 1 // COMMON:#define __STDC_VERSION__ // COMMON:#define __STDC__ 1 @@ -62,12 +65,21 @@ // // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -check-prefix FREESTANDING %s // FREESTANDING:#define __STDC_HOSTED__ 0 -// +// +// +// RUN: %clang_cc1 -x c++ -std=gnu++11 -E -dM < /dev/null | FileCheck -check-prefix GXX11 %s +// +// GXX11:#define __GNUG__ +// GXX11:#define __GXX_WEAK__ 1 +// GXX11:#define __cplusplus 201103L +// GXX11:#define __private_extern__ extern +// +// // RUN: %clang_cc1 -x c++ -std=gnu++98 -E -dM < /dev/null | FileCheck -check-prefix GXX98 %s // // GXX98:#define __GNUG__ // GXX98:#define __GXX_WEAK__ 1 -// GXX98:#define __cplusplus 1 +// GXX98:#define __cplusplus 199711L // GXX98:#define __private_extern__ extern // // @@ -76,7 +88,7 @@ // C94:#define __STDC_VERSION__ 199409L // // -// RUN: %clang_cc1 -fms-extensions -triple i686-pc-win32 -fobjc-fragile-abi -E -dM < /dev/null | FileCheck -check-prefix MSEXT %s +// RUN: %clang_cc1 -fms-extensions -triple i686-pc-win32 -fobjc-runtime=gcc -E -dM < /dev/null | FileCheck -check-prefix MSEXT %s // // MSEXT-NOT:#define __STDC__ // MSEXT:#define _INTEGRAL_MAX_BITS 64 @@ -99,12 +111,39 @@ // NONFRAGILE:#define OBJC_ZEROCOST_EXCEPTIONS 1 // NONFRAGILE:#define __OBJC2__ 1 // -// +// +// RUN: %clang_cc1 -O0 -E -dM < /dev/null | FileCheck -check-prefix O0 %s +// +// O0:#define __NO_INLINE__ 1 +// O0-NOT:#define __OPTIMIZE_SIZE__ +// O0-NOT:#define __OPTIMIZE__ +// +// +// RUN: %clang_cc1 -fno-inline -O3 -E -dM < /dev/null | FileCheck -check-prefix NO_INLINE %s +// +// NO_INLINE:#define __NO_INLINE__ 1 +// NO_INLINE-NOT:#define __OPTIMIZE_SIZE__ +// NO_INLINE:#define __OPTIMIZE__ +// +// // RUN: %clang_cc1 -O1 -E -dM < /dev/null | FileCheck -check-prefix O1 %s // +// O1-NOT:#define __OPTIMIZE_SIZE__ // O1:#define __OPTIMIZE__ 1 // -// +// +// RUN: %clang_cc1 -Os -E -dM < /dev/null | FileCheck -check-prefix Os %s +// +// Os:#define __OPTIMIZE_SIZE__ 1 +// Os:#define __OPTIMIZE__ 1 +// +// +// RUN: %clang_cc1 -Oz -E -dM < /dev/null | FileCheck -check-prefix Oz %s +// +// Oz:#define __OPTIMIZE_SIZE__ 1 +// Oz:#define __OPTIMIZE__ 1 +// +// // RUN: %clang_cc1 -fpascal-strings -E -dM < /dev/null | FileCheck -check-prefix PASCAL %s // // PASCAL:#define __PASCAL_STRINGS__ 1 @@ -125,9 +164,11 @@ // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-none-none < /dev/null | FileCheck -check-prefix ARM %s // +// ARM-NOT:#define _LP64 // ARM:#define __APCS_32__ 1 // ARM:#define __ARMEL__ 1 // ARM:#define __ARM_ARCH_6J__ 1 +// ARM:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // ARM:#define __CHAR16_TYPE__ unsigned short // ARM:#define __CHAR32_TYPE__ unsigned int // ARM:#define __CHAR_BIT__ 8 @@ -187,7 +228,7 @@ // ARM:#define __LITTLE_ENDIAN__ 1 // ARM:#define __LONG_LONG_MAX__ 9223372036854775807LL // ARM:#define __LONG_MAX__ 2147483647L -// ARM:#define __NO_INLINE__ 1 +// ARM-NOT:#define __LP64__ // ARM:#define __POINTER_WIDTH__ 32 // ARM:#define __PTRDIFF_TYPE__ int // ARM:#define __PTRDIFF_WIDTH__ 32 @@ -222,6 +263,8 @@ // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-none-none < /dev/null | FileCheck -check-prefix I386 %s // +// I386-NOT:#define _LP64 +// I386:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // I386:#define __CHAR16_TYPE__ unsigned short // I386:#define __CHAR32_TYPE__ unsigned int // I386:#define __CHAR_BIT__ 8 @@ -281,7 +324,7 @@ // I386:#define __LITTLE_ENDIAN__ 1 // I386:#define __LONG_LONG_MAX__ 9223372036854775807LL // I386:#define __LONG_MAX__ 2147483647L -// I386:#define __NO_INLINE__ 1 +// I386-NOT:#define __LP64__ // I386:#define __NO_MATH_INLINES 1 // I386:#define __POINTER_WIDTH__ 32 // I386:#define __PTRDIFF_TYPE__ int @@ -317,6 +360,8 @@ // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-pc-linux-gnu -target-cpu pentium4 < /dev/null | FileCheck -check-prefix I386-LINUX %s // +// I386-LINUX-NOT:#define _LP64 +// I386-LINUX:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // I386-LINUX:#define __CHAR16_TYPE__ unsigned short // I386-LINUX:#define __CHAR32_TYPE__ unsigned int // I386-LINUX:#define __CHAR_BIT__ 8 @@ -376,7 +421,7 @@ // I386-LINUX:#define __LITTLE_ENDIAN__ 1 // I386-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL // I386-LINUX:#define __LONG_MAX__ 2147483647L -// I386-LINUX:#define __NO_INLINE__ 1 +// I386-LINUX-NOT:#define __LP64__ // I386-LINUX:#define __NO_MATH_INLINES 1 // I386-LINUX:#define __POINTER_WIDTH__ 32 // I386-LINUX:#define __PTRDIFF_TYPE__ int @@ -414,11 +459,13 @@ // // MIPS32BE:#define MIPSEB 1 // MIPS32BE:#define _ABIO32 1 +// MIPS32BE-NOT:#define _LP64 // MIPS32BE:#define _MIPSEB 1 // MIPS32BE:#define _MIPS_SIM _ABIO32 // MIPS32BE:#define _MIPS_SZINT 32 // MIPS32BE:#define _MIPS_SZLONG 32 // MIPS32BE:#define _MIPS_SZPTR 32 +// MIPS32BE:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // MIPS32BE:#define __CHAR16_TYPE__ unsigned short // MIPS32BE:#define __CHAR32_TYPE__ unsigned int // MIPS32BE:#define __CHAR_BIT__ 8 @@ -478,9 +525,9 @@ // MIPS32BE:#define __LDBL_MIN__ 2.2250738585072014e-308 // MIPS32BE:#define __LONG_LONG_MAX__ 9223372036854775807LL // MIPS32BE:#define __LONG_MAX__ 2147483647L +// MIPS32BE-NOT:#define __LP64__ // MIPS32BE:#define __MIPSEB 1 // MIPS32BE:#define __MIPSEB__ 1 -// MIPS32BE:#define __NO_INLINE__ 1 // MIPS32BE:#define __POINTER_WIDTH__ 32 // MIPS32BE:#define __PRAGMA_REDEFINE_EXTNAME 1 // MIPS32BE:#define __PTRDIFF_TYPE__ int @@ -526,11 +573,13 @@ // // MIPS32EL:#define MIPSEL 1 // MIPS32EL:#define _ABIO32 1 +// MIPS32EL-NOT:#define _LP64 // MIPS32EL:#define _MIPSEL 1 // MIPS32EL:#define _MIPS_SIM _ABIO32 // MIPS32EL:#define _MIPS_SZINT 32 // MIPS32EL:#define _MIPS_SZLONG 32 // MIPS32EL:#define _MIPS_SZPTR 32 +// MIPS32EL:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // MIPS32EL:#define __CHAR16_TYPE__ unsigned short // MIPS32EL:#define __CHAR32_TYPE__ unsigned int // MIPS32EL:#define __CHAR_BIT__ 8 @@ -590,9 +639,9 @@ // MIPS32EL:#define __LDBL_MIN__ 2.2250738585072014e-308 // MIPS32EL:#define __LONG_LONG_MAX__ 9223372036854775807LL // MIPS32EL:#define __LONG_MAX__ 2147483647L +// MIPS32EL-NOT:#define __LP64__ // MIPS32EL:#define __MIPSEL 1 // MIPS32EL:#define __MIPSEL__ 1 -// MIPS32EL:#define __NO_INLINE__ 1 // MIPS32EL:#define __POINTER_WIDTH__ 32 // MIPS32EL:#define __PRAGMA_REDEFINE_EXTNAME 1 // MIPS32EL:#define __PTRDIFF_TYPE__ int @@ -635,11 +684,13 @@ // // MIPS64BE:#define MIPSEB 1 // MIPS64BE:#define _ABI64 3 +// MIPS64BE:#define _LP64 1 // MIPS64BE:#define _MIPSEB 1 // MIPS64BE:#define _MIPS_SIM _ABI64 // MIPS64BE:#define _MIPS_SZINT 32 // MIPS64BE:#define _MIPS_SZLONG 64 // MIPS64BE:#define _MIPS_SZPTR 64 +// MIPS64BE:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // MIPS64BE:#define __CHAR16_TYPE__ unsigned short // MIPS64BE:#define __CHAR32_TYPE__ unsigned int // MIPS64BE:#define __CHAR_BIT__ 8 @@ -699,9 +750,9 @@ // MIPS64BE:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L // MIPS64BE:#define __LONG_LONG_MAX__ 9223372036854775807LL // MIPS64BE:#define __LONG_MAX__ 9223372036854775807L +// MIPS64BE:#define __LP64__ 1 // MIPS64BE:#define __MIPSEB 1 // MIPS64BE:#define __MIPSEB__ 1 -// MIPS64BE:#define __NO_INLINE__ 1 // MIPS64BE:#define __POINTER_WIDTH__ 64 // MIPS64BE:#define __PRAGMA_REDEFINE_EXTNAME 1 // MIPS64BE:#define __PTRDIFF_TYPE__ long int @@ -744,11 +795,13 @@ // // MIPS64EL:#define MIPSEL 1 // MIPS64EL:#define _ABI64 3 +// MIPS64EL:#define _LP64 1 // MIPS64EL:#define _MIPSEL 1 // MIPS64EL:#define _MIPS_SIM _ABI64 // MIPS64EL:#define _MIPS_SZINT 32 // MIPS64EL:#define _MIPS_SZLONG 64 // MIPS64EL:#define _MIPS_SZPTR 64 +// MIPS64EL:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // MIPS64EL:#define __CHAR16_TYPE__ unsigned short // MIPS64EL:#define __CHAR32_TYPE__ unsigned int // MIPS64EL:#define __CHAR_BIT__ 8 @@ -808,9 +861,9 @@ // MIPS64EL:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L // MIPS64EL:#define __LONG_LONG_MAX__ 9223372036854775807LL // MIPS64EL:#define __LONG_MAX__ 9223372036854775807L +// MIPS64EL:#define __LP64__ 1 // MIPS64EL:#define __MIPSEL 1 // MIPS64EL:#define __MIPSEL__ 1 -// MIPS64EL:#define __NO_INLINE__ 1 // MIPS64EL:#define __POINTER_WIDTH__ 64 // MIPS64EL:#define __PRAGMA_REDEFINE_EXTNAME 1 // MIPS64EL:#define __PTRDIFF_TYPE__ long int @@ -864,11 +917,40 @@ // RUN: %clang_cc1 -target-feature +single-float -E -dM -ffreestanding \ // RUN: -triple=mips-none-none < /dev/null \ // RUN: | FileCheck -check-prefix MIPS-FABI-SINGLE %s +// MIPS-FABI-SINGLE:#define __mips_hard_float 1 // MIPS-FABI-SINGLE:#define __mips_single_float 1 // +// Check MIPS features macros +// +// RUN: %clang_cc1 -target-feature +mips16 \ +// RUN: -E -dM -triple=mips-none-none < /dev/null \ +// RUN: | FileCheck -check-prefix MIPS16 %s +// MIPS16:#define __mips16 1 +// +// RUN: %clang_cc1 -target-feature -mips16 \ +// RUN: -E -dM -triple=mips-none-none < /dev/null \ +// RUN: | FileCheck -check-prefix NOMIPS16 %s +// NOMIPS16-NOT:#define __mips16 1 +// +// RUN: %clang_cc1 -target-feature +dsp \ +// RUN: -E -dM -triple=mips-none-none < /dev/null \ +// RUN: | FileCheck -check-prefix MIPS-DSP %s +// MIPS-DSP:#define __mips_dsp 1 +// MIPS-DSP:#define __mips_dsp_rev 1 +// MIPS-DSP-NOT:#define __mips_dspr2 1 +// +// RUN: %clang_cc1 -target-feature +dspr2 \ +// RUN: -E -dM -triple=mips-none-none < /dev/null \ +// RUN: | FileCheck -check-prefix MIPS-DSPR2 %s +// MIPS-DSPR2:#define __mips_dsp 1 +// MIPS-DSPR2:#define __mips_dsp_rev 2 +// MIPS-DSPR2:#define __mips_dspr2 1 +// // RUN: %clang_cc1 -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -check-prefix MSP430 %s // // MSP430:#define MSP430 1 +// MSP430-NOT:#define _LP64 +// MSP430:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // MSP430:#define __CHAR16_TYPE__ unsigned short // MSP430:#define __CHAR32_TYPE__ unsigned int // MSP430:#define __CHAR_BIT__ 8 @@ -926,8 +1008,8 @@ // MSP430:#define __LDBL_MIN__ 2.2250738585072014e-308 // MSP430:#define __LONG_LONG_MAX__ 9223372036854775807LL // MSP430:#define __LONG_MAX__ 2147483647L +// MSP430-NOT:#define __LP64__ // MSP430:#define __MSP430__ 1 -// MSP430:#define __NO_INLINE__ 1 // MSP430:#define __POINTER_WIDTH__ 16 // MSP430:#define __PTRDIFF_TYPE__ int // MSP430:#define __PTRDIFF_WIDTH__ 16 @@ -957,13 +1039,315 @@ // MSP430:#define __WINT_WIDTH__ 16 // MSP430:#define __clang__ 1 // -// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64 %s +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=nvptx-none-none < /dev/null | FileCheck -check-prefix NVPTX32 %s +// +// NVPTX32-NOT:#define _LP64 +// NVPTX32:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ +// NVPTX32:#define __CHAR16_TYPE__ unsigned short +// NVPTX32:#define __CHAR32_TYPE__ unsigned int +// NVPTX32:#define __CHAR_BIT__ 8 +// NVPTX32:#define __CONSTANT_CFSTRINGS__ 1 +// NVPTX32:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 +// NVPTX32:#define __DBL_DIG__ 15 +// NVPTX32:#define __DBL_EPSILON__ 2.2204460492503131e-16 +// NVPTX32:#define __DBL_HAS_DENORM__ 1 +// NVPTX32:#define __DBL_HAS_INFINITY__ 1 +// NVPTX32:#define __DBL_HAS_QUIET_NAN__ 1 +// NVPTX32:#define __DBL_MANT_DIG__ 53 +// NVPTX32:#define __DBL_MAX_10_EXP__ 308 +// NVPTX32:#define __DBL_MAX_EXP__ 1024 +// NVPTX32:#define __DBL_MAX__ 1.7976931348623157e+308 +// NVPTX32:#define __DBL_MIN_10_EXP__ (-307) +// NVPTX32:#define __DBL_MIN_EXP__ (-1021) +// NVPTX32:#define __DBL_MIN__ 2.2250738585072014e-308 +// NVPTX32:#define __DECIMAL_DIG__ 17 +// NVPTX32:#define __FINITE_MATH_ONLY__ 0 +// NVPTX32:#define __FLT_DENORM_MIN__ 1.40129846e-45F +// NVPTX32:#define __FLT_DIG__ 6 +// NVPTX32:#define __FLT_EPSILON__ 1.19209290e-7F +// NVPTX32:#define __FLT_EVAL_METHOD__ 0 +// NVPTX32:#define __FLT_HAS_DENORM__ 1 +// NVPTX32:#define __FLT_HAS_INFINITY__ 1 +// NVPTX32:#define __FLT_HAS_QUIET_NAN__ 1 +// NVPTX32:#define __FLT_MANT_DIG__ 24 +// NVPTX32:#define __FLT_MAX_10_EXP__ 38 +// NVPTX32:#define __FLT_MAX_EXP__ 128 +// NVPTX32:#define __FLT_MAX__ 3.40282347e+38F +// NVPTX32:#define __FLT_MIN_10_EXP__ (-37) +// NVPTX32:#define __FLT_MIN_EXP__ (-125) +// NVPTX32:#define __FLT_MIN__ 1.17549435e-38F +// NVPTX32:#define __FLT_RADIX__ 2 +// NVPTX32:#define __INT16_TYPE__ short +// NVPTX32:#define __INT32_TYPE__ int +// NVPTX32:#define __INT64_C_SUFFIX__ LL +// NVPTX32:#define __INT64_TYPE__ long long int +// NVPTX32:#define __INT8_TYPE__ char +// NVPTX32:#define __INTMAX_MAX__ 9223372036854775807LL +// NVPTX32:#define __INTMAX_TYPE__ long long int +// NVPTX32:#define __INTMAX_WIDTH__ 64 +// NVPTX32:#define __INTPTR_TYPE__ unsigned int +// NVPTX32:#define __INTPTR_WIDTH__ 32 +// NVPTX32:#define __INT_MAX__ 2147483647 +// NVPTX32:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324 +// NVPTX32:#define __LDBL_DIG__ 15 +// NVPTX32:#define __LDBL_EPSILON__ 2.2204460492503131e-16 +// NVPTX32:#define __LDBL_HAS_DENORM__ 1 +// NVPTX32:#define __LDBL_HAS_INFINITY__ 1 +// NVPTX32:#define __LDBL_HAS_QUIET_NAN__ 1 +// NVPTX32:#define __LDBL_MANT_DIG__ 53 +// NVPTX32:#define __LDBL_MAX_10_EXP__ 308 +// NVPTX32:#define __LDBL_MAX_EXP__ 1024 +// NVPTX32:#define __LDBL_MAX__ 1.7976931348623157e+308 +// NVPTX32:#define __LDBL_MIN_10_EXP__ (-307) +// NVPTX32:#define __LDBL_MIN_EXP__ (-1021) +// NVPTX32:#define __LDBL_MIN__ 2.2250738585072014e-308 +// NVPTX32:#define __LONG_LONG_MAX__ 9223372036854775807LL +// NVPTX32:#define __LONG_MAX__ 9223372036854775807L +// NVPTX32-NOT:#define __LP64__ +// NVPTX32:#define __NVPTX__ 1 +// NVPTX32:#define __POINTER_WIDTH__ 32 +// NVPTX32:#define __PRAGMA_REDEFINE_EXTNAME 1 +// NVPTX32:#define __PTRDIFF_TYPE__ unsigned int +// NVPTX32:#define __PTRDIFF_WIDTH__ 32 +// NVPTX32:#define __PTX__ 1 +// NVPTX32:#define __SCHAR_MAX__ 127 +// NVPTX32:#define __SHRT_MAX__ 32767 +// NVPTX32:#define __SIG_ATOMIC_WIDTH__ 32 +// NVPTX32:#define __SIZEOF_DOUBLE__ 8 +// NVPTX32:#define __SIZEOF_FLOAT__ 4 +// NVPTX32:#define __SIZEOF_INT__ 4 +// NVPTX32:#define __SIZEOF_LONG_DOUBLE__ 8 +// NVPTX32:#define __SIZEOF_LONG_LONG__ 8 +// NVPTX32:#define __SIZEOF_LONG__ 8 +// NVPTX32:#define __SIZEOF_POINTER__ 4 +// NVPTX32:#define __SIZEOF_PTRDIFF_T__ 4 +// NVPTX32:#define __SIZEOF_SHORT__ 2 +// NVPTX32:#define __SIZEOF_SIZE_T__ 4 +// NVPTX32:#define __SIZEOF_WCHAR_T__ 4 +// NVPTX32:#define __SIZEOF_WINT_T__ 4 +// NVPTX32:#define __SIZE_TYPE__ unsigned int +// NVPTX32:#define __SIZE_WIDTH__ 32 +// NVPTX32:#define __UINTMAX_TYPE__ long long unsigned int +// NVPTX32:#define __USER_LABEL_PREFIX__ _ +// NVPTX32:#define __WCHAR_MAX__ 2147483647 +// NVPTX32:#define __WCHAR_TYPE__ int +// NVPTX32:#define __WCHAR_WIDTH__ 32 +// NVPTX32:#define __WINT_TYPE__ int +// NVPTX32:#define __WINT_WIDTH__ 32 +// +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=nvptx64-none-none < /dev/null | FileCheck -check-prefix NVPTX64 %s +// +// NVPTX64:#define _LP64 1 +// NVPTX64:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ +// NVPTX64:#define __CHAR16_TYPE__ unsigned short +// NVPTX64:#define __CHAR32_TYPE__ unsigned int +// NVPTX64:#define __CHAR_BIT__ 8 +// NVPTX64:#define __CONSTANT_CFSTRINGS__ 1 +// NVPTX64:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 +// NVPTX64:#define __DBL_DIG__ 15 +// NVPTX64:#define __DBL_EPSILON__ 2.2204460492503131e-16 +// NVPTX64:#define __DBL_HAS_DENORM__ 1 +// NVPTX64:#define __DBL_HAS_INFINITY__ 1 +// NVPTX64:#define __DBL_HAS_QUIET_NAN__ 1 +// NVPTX64:#define __DBL_MANT_DIG__ 53 +// NVPTX64:#define __DBL_MAX_10_EXP__ 308 +// NVPTX64:#define __DBL_MAX_EXP__ 1024 +// NVPTX64:#define __DBL_MAX__ 1.7976931348623157e+308 +// NVPTX64:#define __DBL_MIN_10_EXP__ (-307) +// NVPTX64:#define __DBL_MIN_EXP__ (-1021) +// NVPTX64:#define __DBL_MIN__ 2.2250738585072014e-308 +// NVPTX64:#define __DECIMAL_DIG__ 17 +// NVPTX64:#define __FINITE_MATH_ONLY__ 0 +// NVPTX64:#define __FLT_DENORM_MIN__ 1.40129846e-45F +// NVPTX64:#define __FLT_DIG__ 6 +// NVPTX64:#define __FLT_EPSILON__ 1.19209290e-7F +// NVPTX64:#define __FLT_EVAL_METHOD__ 0 +// NVPTX64:#define __FLT_HAS_DENORM__ 1 +// NVPTX64:#define __FLT_HAS_INFINITY__ 1 +// NVPTX64:#define __FLT_HAS_QUIET_NAN__ 1 +// NVPTX64:#define __FLT_MANT_DIG__ 24 +// NVPTX64:#define __FLT_MAX_10_EXP__ 38 +// NVPTX64:#define __FLT_MAX_EXP__ 128 +// NVPTX64:#define __FLT_MAX__ 3.40282347e+38F +// NVPTX64:#define __FLT_MIN_10_EXP__ (-37) +// NVPTX64:#define __FLT_MIN_EXP__ (-125) +// NVPTX64:#define __FLT_MIN__ 1.17549435e-38F +// NVPTX64:#define __FLT_RADIX__ 2 +// NVPTX64:#define __INT16_TYPE__ short +// NVPTX64:#define __INT32_TYPE__ int +// NVPTX64:#define __INT64_C_SUFFIX__ LL +// NVPTX64:#define __INT64_TYPE__ long long int +// NVPTX64:#define __INT8_TYPE__ char +// NVPTX64:#define __INTMAX_MAX__ 9223372036854775807LL +// NVPTX64:#define __INTMAX_TYPE__ long long int +// NVPTX64:#define __INTMAX_WIDTH__ 64 +// NVPTX64:#define __INTPTR_TYPE__ long long unsigned int +// NVPTX64:#define __INTPTR_WIDTH__ 64 +// NVPTX64:#define __INT_MAX__ 2147483647 +// NVPTX64:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324 +// NVPTX64:#define __LDBL_DIG__ 15 +// NVPTX64:#define __LDBL_EPSILON__ 2.2204460492503131e-16 +// NVPTX64:#define __LDBL_HAS_DENORM__ 1 +// NVPTX64:#define __LDBL_HAS_INFINITY__ 1 +// NVPTX64:#define __LDBL_HAS_QUIET_NAN__ 1 +// NVPTX64:#define __LDBL_MANT_DIG__ 53 +// NVPTX64:#define __LDBL_MAX_10_EXP__ 308 +// NVPTX64:#define __LDBL_MAX_EXP__ 1024 +// NVPTX64:#define __LDBL_MAX__ 1.7976931348623157e+308 +// NVPTX64:#define __LDBL_MIN_10_EXP__ (-307) +// NVPTX64:#define __LDBL_MIN_EXP__ (-1021) +// NVPTX64:#define __LDBL_MIN__ 2.2250738585072014e-308 +// NVPTX64:#define __LONG_LONG_MAX__ 9223372036854775807LL +// NVPTX64:#define __LONG_MAX__ 9223372036854775807L +// NVPTX64:#define __LP64__ 1 +// NVPTX64:#define __NVPTX__ 1 +// NVPTX64:#define __POINTER_WIDTH__ 64 +// NVPTX64:#define __PRAGMA_REDEFINE_EXTNAME 1 +// NVPTX64:#define __PTRDIFF_TYPE__ long long unsigned int +// NVPTX64:#define __PTRDIFF_WIDTH__ 64 +// NVPTX64:#define __PTX__ 1 +// NVPTX64:#define __SCHAR_MAX__ 127 +// NVPTX64:#define __SHRT_MAX__ 32767 +// NVPTX64:#define __SIG_ATOMIC_WIDTH__ 32 +// NVPTX64:#define __SIZEOF_DOUBLE__ 8 +// NVPTX64:#define __SIZEOF_FLOAT__ 4 +// NVPTX64:#define __SIZEOF_INT__ 4 +// NVPTX64:#define __SIZEOF_LONG_DOUBLE__ 8 +// NVPTX64:#define __SIZEOF_LONG_LONG__ 8 +// NVPTX64:#define __SIZEOF_LONG__ 8 +// NVPTX64:#define __SIZEOF_POINTER__ 8 +// NVPTX64:#define __SIZEOF_PTRDIFF_T__ 8 +// NVPTX64:#define __SIZEOF_SHORT__ 2 +// NVPTX64:#define __SIZEOF_SIZE_T__ 8 +// NVPTX64:#define __SIZEOF_WCHAR_T__ 4 +// NVPTX64:#define __SIZEOF_WINT_T__ 4 +// NVPTX64:#define __SIZE_TYPE__ long long unsigned int +// NVPTX64:#define __SIZE_WIDTH__ 64 +// NVPTX64:#define __UINTMAX_TYPE__ long long unsigned int +// NVPTX64:#define __USER_LABEL_PREFIX__ _ +// NVPTX64:#define __WCHAR_MAX__ 2147483647 +// NVPTX64:#define __WCHAR_TYPE__ int +// NVPTX64:#define __WCHAR_WIDTH__ 32 +// NVPTX64:#define __WINT_TYPE__ int +// NVPTX64:#define __WINT_WIDTH__ 32 +// +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-none-none -target-cpu 603e < /dev/null | FileCheck -check-prefix PPC603E %s +// +// PPC603E:#define _ARCH_603 1 +// PPC603E:#define _ARCH_603E 1 +// PPC603E:#define _ARCH_PPC 1 +// PPC603E:#define _ARCH_PPCGR 1 +// PPC603E:#define _BIG_ENDIAN 1 +// PPC603E-NOT:#define _LP64 +// PPC603E:#define __BIG_ENDIAN__ 1 +// PPC603E:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ +// PPC603E:#define __CHAR16_TYPE__ unsigned short +// PPC603E:#define __CHAR32_TYPE__ unsigned int +// PPC603E:#define __CHAR_BIT__ 8 +// PPC603E:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 +// PPC603E:#define __DBL_DIG__ 15 +// PPC603E:#define __DBL_EPSILON__ 2.2204460492503131e-16 +// PPC603E:#define __DBL_HAS_DENORM__ 1 +// PPC603E:#define __DBL_HAS_INFINITY__ 1 +// PPC603E:#define __DBL_HAS_QUIET_NAN__ 1 +// PPC603E:#define __DBL_MANT_DIG__ 53 +// PPC603E:#define __DBL_MAX_10_EXP__ 308 +// PPC603E:#define __DBL_MAX_EXP__ 1024 +// PPC603E:#define __DBL_MAX__ 1.7976931348623157e+308 +// PPC603E:#define __DBL_MIN_10_EXP__ (-307) +// PPC603E:#define __DBL_MIN_EXP__ (-1021) +// PPC603E:#define __DBL_MIN__ 2.2250738585072014e-308 +// PPC603E:#define __DECIMAL_DIG__ 33 +// PPC603E:#define __FLT_DENORM_MIN__ 1.40129846e-45F +// PPC603E:#define __FLT_DIG__ 6 +// PPC603E:#define __FLT_EPSILON__ 1.19209290e-7F +// PPC603E:#define __FLT_EVAL_METHOD__ 0 +// PPC603E:#define __FLT_HAS_DENORM__ 1 +// PPC603E:#define __FLT_HAS_INFINITY__ 1 +// PPC603E:#define __FLT_HAS_QUIET_NAN__ 1 +// PPC603E:#define __FLT_MANT_DIG__ 24 +// PPC603E:#define __FLT_MAX_10_EXP__ 38 +// PPC603E:#define __FLT_MAX_EXP__ 128 +// PPC603E:#define __FLT_MAX__ 3.40282347e+38F +// PPC603E:#define __FLT_MIN_10_EXP__ (-37) +// PPC603E:#define __FLT_MIN_EXP__ (-125) +// PPC603E:#define __FLT_MIN__ 1.17549435e-38F +// PPC603E:#define __FLT_RADIX__ 2 +// PPC603E:#define __INT16_TYPE__ short +// PPC603E:#define __INT32_TYPE__ int +// PPC603E:#define __INT64_C_SUFFIX__ LL +// PPC603E:#define __INT64_TYPE__ long long int +// PPC603E:#define __INT8_TYPE__ char +// PPC603E:#define __INTMAX_MAX__ 9223372036854775807LL +// PPC603E:#define __INTMAX_TYPE__ long long int +// PPC603E:#define __INTMAX_WIDTH__ 64 +// PPC603E:#define __INTPTR_TYPE__ long int +// PPC603E:#define __INTPTR_WIDTH__ 32 +// PPC603E:#define __INT_MAX__ 2147483647 +// PPC603E:#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L +// PPC603E:#define __LDBL_DIG__ 31 +// PPC603E:#define __LDBL_EPSILON__ 4.94065645841246544176568792868221e-324L +// PPC603E:#define __LDBL_HAS_DENORM__ 1 +// PPC603E:#define __LDBL_HAS_INFINITY__ 1 +// PPC603E:#define __LDBL_HAS_QUIET_NAN__ 1 +// PPC603E:#define __LDBL_MANT_DIG__ 106 +// PPC603E:#define __LDBL_MAX_10_EXP__ 308 +// PPC603E:#define __LDBL_MAX_EXP__ 1024 +// PPC603E:#define __LDBL_MAX__ 1.79769313486231580793728971405301e+308L +// PPC603E:#define __LDBL_MIN_10_EXP__ (-291) +// PPC603E:#define __LDBL_MIN_EXP__ (-968) +// PPC603E:#define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L +// PPC603E:#define __LONG_DOUBLE_128__ 1 +// PPC603E:#define __LONG_LONG_MAX__ 9223372036854775807LL +// PPC603E:#define __LONG_MAX__ 2147483647L +// PPC603E-NOT:#define __LP64__ +// PPC603E:#define __NATURAL_ALIGNMENT__ 1 +// PPC603E:#define __POINTER_WIDTH__ 32 +// PPC603E:#define __POWERPC__ 1 +// PPC603E:#define __PTRDIFF_TYPE__ long int +// PPC603E:#define __PTRDIFF_WIDTH__ 32 +// PPC603E:#define __REGISTER_PREFIX__ +// PPC603E:#define __SCHAR_MAX__ 127 +// PPC603E:#define __SHRT_MAX__ 32767 +// PPC603E:#define __SIG_ATOMIC_WIDTH__ 32 +// PPC603E:#define __SIZEOF_DOUBLE__ 8 +// PPC603E:#define __SIZEOF_FLOAT__ 4 +// PPC603E:#define __SIZEOF_INT__ 4 +// PPC603E:#define __SIZEOF_LONG_DOUBLE__ 16 +// PPC603E:#define __SIZEOF_LONG_LONG__ 8 +// PPC603E:#define __SIZEOF_LONG__ 4 +// PPC603E:#define __SIZEOF_POINTER__ 4 +// PPC603E:#define __SIZEOF_PTRDIFF_T__ 4 +// PPC603E:#define __SIZEOF_SHORT__ 2 +// PPC603E:#define __SIZEOF_SIZE_T__ 4 +// PPC603E:#define __SIZEOF_WCHAR_T__ 4 +// PPC603E:#define __SIZEOF_WINT_T__ 4 +// PPC603E:#define __SIZE_TYPE__ long unsigned int +// PPC603E:#define __SIZE_WIDTH__ 32 +// PPC603E:#define __UINTMAX_TYPE__ long long unsigned int +// PPC603E:#define __USER_LABEL_PREFIX__ _ +// PPC603E:#define __WCHAR_MAX__ 2147483647 +// PPC603E:#define __WCHAR_TYPE__ int +// PPC603E:#define __WCHAR_WIDTH__ 32 +// PPC603E:#define __WINT_TYPE__ int +// PPC603E:#define __WINT_WIDTH__ 32 +// PPC603E:#define __powerpc__ 1 +// PPC603E:#define __ppc__ 1 +// +// RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr7 -fno-signed-char < /dev/null | FileCheck -check-prefix PPC64 %s // // PPC64:#define _ARCH_PPC 1 // PPC64:#define _ARCH_PPC64 1 +// PPC64:#define _ARCH_PPCGR 1 +// PPC64:#define _ARCH_PPCSQ 1 +// PPC64:#define _ARCH_PWR4 1 +// PPC64:#define _ARCH_PWR5 1 +// PPC64:#define _ARCH_PWR6 1 +// PPC64:#define _ARCH_PWR7 1 // PPC64:#define _BIG_ENDIAN 1 // PPC64:#define _LP64 1 // PPC64:#define __BIG_ENDIAN__ 1 +// PPC64:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // PPC64:#define __CHAR16_TYPE__ unsigned short // PPC64:#define __CHAR32_TYPE__ unsigned int // PPC64:#define __CHAR_BIT__ 8 @@ -1026,7 +1410,6 @@ // PPC64:#define __LONG_MAX__ 9223372036854775807L // PPC64:#define __LP64__ 1 // PPC64:#define __NATURAL_ALIGNMENT__ 1 -// PPC64:#define __NO_INLINE__ 1 // PPC64:#define __POINTER_WIDTH__ 64 // PPC64:#define __POWERPC__ 1 // PPC64:#define __PTRDIFF_TYPE__ long int @@ -1066,6 +1449,7 @@ // PPC64-LINUX:#define _BIG_ENDIAN 1 // PPC64-LINUX:#define _LP64 1 // PPC64-LINUX:#define __BIG_ENDIAN__ 1 +// PPC64-LINUX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // PPC64-LINUX:#define __CHAR16_TYPE__ unsigned short // PPC64-LINUX:#define __CHAR32_TYPE__ unsigned int // PPC64-LINUX:#define __CHAR_BIT__ 8 @@ -1128,7 +1512,6 @@ // PPC64-LINUX:#define __LONG_MAX__ 9223372036854775807L // PPC64-LINUX:#define __LP64__ 1 // PPC64-LINUX:#define __NATURAL_ALIGNMENT__ 1 -// PPC64-LINUX:#define __NO_INLINE__ 1 // PPC64-LINUX:#define __POINTER_WIDTH__ 64 // PPC64-LINUX:#define __POWERPC__ 1 // PPC64-LINUX:#define __PTRDIFF_TYPE__ long int @@ -1168,7 +1551,9 @@ // // PPC:#define _ARCH_PPC 1 // PPC:#define _BIG_ENDIAN 1 +// PPC-NOT:#define _LP64 // PPC:#define __BIG_ENDIAN__ 1 +// PPC:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // PPC:#define __CHAR16_TYPE__ unsigned short // PPC:#define __CHAR32_TYPE__ unsigned int // PPC:#define __CHAR_BIT__ 8 @@ -1229,8 +1614,8 @@ // PPC:#define __LONG_DOUBLE_128__ 1 // PPC:#define __LONG_LONG_MAX__ 9223372036854775807LL // PPC:#define __LONG_MAX__ 2147483647L +// PPC-NOT:#define __LP64__ // PPC:#define __NATURAL_ALIGNMENT__ 1 -// PPC:#define __NO_INLINE__ 1 // PPC:#define __POINTER_WIDTH__ 32 // PPC:#define __POWERPC__ 1 // PPC:#define __PTRDIFF_TYPE__ long int @@ -1266,7 +1651,9 @@ // // PPC-LINUX:#define _ARCH_PPC 1 // PPC-LINUX:#define _BIG_ENDIAN 1 +// PPC-LINUX-NOT:#define _LP64 // PPC-LINUX:#define __BIG_ENDIAN__ 1 +// PPC-LINUX:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // PPC-LINUX:#define __CHAR16_TYPE__ unsigned short // PPC-LINUX:#define __CHAR32_TYPE__ unsigned int // PPC-LINUX:#define __CHAR_BIT__ 8 @@ -1327,8 +1714,8 @@ // PPC-LINUX:#define __LONG_DOUBLE_128__ 1 // PPC-LINUX:#define __LONG_LONG_MAX__ 9223372036854775807LL // PPC-LINUX:#define __LONG_MAX__ 2147483647L +// PPC-LINUX-NOT:#define __LP64__ // PPC-LINUX:#define __NATURAL_ALIGNMENT__ 1 -// PPC-LINUX:#define __NO_INLINE__ 1 // PPC-LINUX:#define __POINTER_WIDTH__ 32 // PPC-LINUX:#define __POWERPC__ 1 // PPC-LINUX:#define __PTRDIFF_TYPE__ int @@ -1364,6 +1751,8 @@ // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc-none-none < /dev/null | FileCheck -check-prefix SPARC %s // +// SPARC-NOT:#define _LP64 +// SPARC:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // SPARC:#define __CHAR16_TYPE__ unsigned short // SPARC:#define __CHAR32_TYPE__ unsigned int // SPARC:#define __CHAR_BIT__ 8 @@ -1422,7 +1811,7 @@ // SPARC:#define __LDBL_MIN__ 2.2250738585072014e-308 // SPARC:#define __LONG_LONG_MAX__ 9223372036854775807LL // SPARC:#define __LONG_MAX__ 2147483647L -// SPARC:#define __NO_INLINE__ 1 +// SPARC-NOT:#define __LP64__ // SPARC:#define __POINTER_WIDTH__ 32 // SPARC:#define __PTRDIFF_TYPE__ long int // SPARC:#define __PTRDIFF_WIDTH__ 32 @@ -1459,6 +1848,8 @@ // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=tce-none-none < /dev/null | FileCheck -check-prefix TCE %s // +// TCE-NOT:#define _LP64 +// TCE:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // TCE:#define __CHAR16_TYPE__ unsigned short // TCE:#define __CHAR32_TYPE__ unsigned int // TCE:#define __CHAR_BIT__ 8 @@ -1515,7 +1906,7 @@ // TCE:#define __LDBL_MIN__ 1.17549435e-38F // TCE:#define __LONG_LONG_MAX__ 2147483647LL // TCE:#define __LONG_MAX__ 2147483647L -// TCE:#define __NO_INLINE__ 1 +// TCE-NOT:#define __LP64__ // TCE:#define __POINTER_WIDTH__ 32 // TCE:#define __PTRDIFF_TYPE__ int // TCE:#define __PTRDIFF_WIDTH__ 32 @@ -1552,6 +1943,7 @@ // RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-none-none < /dev/null | FileCheck -check-prefix X86_64 %s // // X86_64:#define _LP64 1 +// X86_64:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // X86_64:#define __CHAR16_TYPE__ unsigned short // X86_64:#define __CHAR32_TYPE__ unsigned int // X86_64:#define __CHAR_BIT__ 8 @@ -1613,7 +2005,6 @@ // X86_64:#define __LONG_MAX__ 9223372036854775807L // X86_64:#define __LP64__ 1 // X86_64:#define __MMX__ 1 -// X86_64:#define __NO_INLINE__ 1 // X86_64:#define __NO_MATH_INLINES 1 // X86_64:#define __POINTER_WIDTH__ 64 // X86_64:#define __PTRDIFF_TYPE__ long int @@ -1655,6 +2046,7 @@ // RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-pc-linux-gnu < /dev/null | FileCheck -check-prefix X86_64-LINUX %s // // X86_64-LINUX:#define _LP64 1 +// X86_64-LINUX:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // X86_64-LINUX:#define __CHAR16_TYPE__ unsigned short // X86_64-LINUX:#define __CHAR32_TYPE__ unsigned int // X86_64-LINUX:#define __CHAR_BIT__ 8 @@ -1716,7 +2108,6 @@ // X86_64-LINUX:#define __LONG_MAX__ 9223372036854775807L // X86_64-LINUX:#define __LP64__ 1 // X86_64-LINUX:#define __MMX__ 1 -// X86_64-LINUX:#define __NO_INLINE__ 1 // X86_64-LINUX:#define __NO_MATH_INLINES 1 // X86_64-LINUX:#define __POINTER_WIDTH__ 64 // X86_64-LINUX:#define __PTRDIFF_TYPE__ long int @@ -1755,10 +2146,13 @@ // X86_64-LINUX:#define __x86_64 1 // X86_64-LINUX:#define __x86_64__ 1 // -// RUN: %clang_cc1 -x c++ -triple i686-pc-linux-gnu -fobjc-fragile-abi -E -dM < /dev/null | FileCheck -check-prefix GNUSOURCE %s +// RUN: %clang_cc1 -x c++ -triple i686-pc-linux-gnu -fobjc-runtime=gcc -E -dM < /dev/null | FileCheck -check-prefix GNUSOURCE %s // GNUSOURCE:#define _GNU_SOURCE 1 // // RUN: %clang_cc1 -x c++ -std=c++98 -fno-rtti -E -dM < /dev/null | FileCheck -check-prefix NORTTI %s // NORTTI: __GXX_ABI_VERSION // NORTTI-NOT:#define __GXX_RTTI // NORTTI: __STDC__ +// +// RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -check-prefix ANDROID %s +// ANDROID: __ANDROID__ 1 diff --git a/test/Preprocessor/line-directive.c b/test/Preprocessor/line-directive.c index 28e93029a5ce..ffa7c5a41973 100644 --- a/test/Preprocessor/line-directive.c +++ b/test/Preprocessor/line-directive.c @@ -3,8 +3,8 @@ // RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: DEF' #line 'a' // expected-error {{#line directive requires a positive integer argument}} -#line 0 // expected-error {{#line directive requires a positive integer argument}} -#line 00 // expected-error {{#line directive requires a positive integer argument}} +#line 0 // expected-warning {{#line directive with zero argument is a GNU extension}} +#line 00 // expected-warning {{#line directive with zero argument is a GNU extension}} #line 2147483648 // expected-warning {{C requires #line number to be less than 2147483648, allowed as extension}} #line 42 // ok #line 42 'a' // expected-error {{invalid filename for #line directive}} @@ -33,8 +33,11 @@ // These are checked by the RUN line. #line 92 "blonk.c" -#error ABC // expected-error {{#error ABC}} -#error DEF // expected-error {{#error DEF}} +#error ABC +#error DEF +// expected-error@-2 {{ABC}} +#line 150 +// expected-error@-3 {{DEF}} // Verify that linemarker diddling of the system header flag works. @@ -88,5 +91,8 @@ extern char array2[\ _\ _LINE__ == 42 ? 1: -1]; /* line marker is location of first _ */ +// rdar://11550996 +#line 0 "line-directive.c" // expected-warning {{#line directive with zero argument is a GNU extension}} +undefined t; // expected-error {{unknown type name 'undefined'}} diff --git a/test/Preprocessor/macro_fn.c b/test/Preprocessor/macro_fn.c index 85733b4af068..f93d52c7eda7 100644 --- a/test/Preprocessor/macro_fn.c +++ b/test/Preprocessor/macro_fn.c @@ -4,8 +4,8 @@ #define zero() 0 #define one(x) 0 #define two(x, y) 0 -#define zero_dot(...) 0 /* expected-warning {{variadic macros were introduced in C99}} */ -#define one_dot(x, ...) 0 /* expected-warning {{variadic macros were introduced in C99}} */ +#define zero_dot(...) 0 /* expected-warning {{variadic macros are a C99 feature}} */ +#define one_dot(x, ...) 0 /* expected-warning {{variadic macros are a C99 feature}} expected-note 2{{macro 'one_dot' defined here}} */ zero() zero(1); /* expected-error {{too many arguments provided to function-like macro invocation}} */ @@ -19,25 +19,25 @@ one(a, b) /* expected-error {{too many arguments provided to function-li two() /* expected-error {{too few arguments provided to function-like macro invocation}} */ two(a) /* expected-error {{too few arguments provided to function-like macro invocation}} */ two(a,b) -two(a, ) /* expected-warning {{empty macro arguments were standardized in C99}} */ +two(a, ) /* expected-warning {{empty macro arguments are a C99 feature}} */ two(a,b,c) /* expected-error {{too many arguments provided to function-like macro invocation}} */ two( - , /* expected-warning {{empty macro arguments were standardized in C99}} */ - , /* expected-warning {{empty macro arguments were standardized in C99}} \ + , /* expected-warning {{empty macro arguments are a C99 feature}} */ + , /* expected-warning {{empty macro arguments are a C99 feature}} \ expected-error {{too many arguments provided to function-like macro invocation}} */ ) -two(,) /* expected-warning 2 {{empty macro arguments were standardized in C99}} */ +two(,) /* expected-warning 2 {{empty macro arguments are a C99 feature}} */ /* PR4006 & rdar://6807000 */ -#define e(...) __VA_ARGS__ /* expected-warning {{variadic macros were introduced in C99}} */ +#define e(...) __VA_ARGS__ /* expected-warning {{variadic macros are a C99 feature}} */ e(x) e() zero_dot() -one_dot(x) /* empty ... argument: expected-warning {{varargs argument missing, but tolerated as an extension}} */ -one_dot() /* empty first argument, elided ...: expected-warning {{varargs argument missing, but tolerated as an extension}} */ +one_dot(x) /* empty ... argument: expected-warning {{must specify at least one argument for '...' parameter of variadic macro}} */ +one_dot() /* empty first argument, elided ...: expected-warning {{must specify at least one argument for '...' parameter of variadic macro}} */ /* rdar://6816766 - Crash with function-like macro test at end of directive. */ diff --git a/test/Preprocessor/macro_paste_c_block_comment.c b/test/Preprocessor/macro_paste_c_block_comment.c index c690a4c7c9f5..c558be58ee7b 100644 --- a/test/Preprocessor/macro_paste_c_block_comment.c +++ b/test/Preprocessor/macro_paste_c_block_comment.c @@ -1,5 +1,9 @@ // RUN: %clang_cc1 %s -Eonly -verify +// expected-error@9 {{EOF}} #define COMM / ## * COMM // expected-error {{pasting formed '/*', an invalid preprocessing token}} +// Demonstrate that an invalid preprocessing token +// doesn't swallow the rest of the file... +#error EOF diff --git a/test/Preprocessor/macro_paste_identifier_error.c b/test/Preprocessor/macro_paste_identifier_error.c new file mode 100644 index 000000000000..457e6f7fc1aa --- /dev/null +++ b/test/Preprocessor/macro_paste_identifier_error.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fms-extensions -Wno-invalid-token-paste %s -verify +// RUN: %clang_cc1 -E -fms-extensions -Wno-invalid-token-paste %s | FileCheck %s +// RUN: %clang_cc1 -E -fms-extensions -Wno-invalid-token-paste -x assembler-with-cpp %s | FileCheck %s + +#define foo a ## b ## = 0 +int foo; +// CHECK: int ab = 0; diff --git a/test/Preprocessor/mmx.c b/test/Preprocessor/mmx.c index 2613cb6ebed7..59e715ec1932 100644 --- a/test/Preprocessor/mmx.c +++ b/test/Preprocessor/mmx.c @@ -1,8 +1,11 @@ // RUN: %clang -march=i386 -m32 -E -dM %s -msse -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=SSE_AND_MMX // RUN: %clang -march=i386 -m32 -E -dM %s -msse -mno-mmx -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=SSE_NO_MMX // RUN: %clang -march=i386 -m32 -E -dM %s -mno-mmx -msse -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=SSE_NO_MMX // SSE_AND_MMX: #define __MMX__ diff --git a/test/Preprocessor/non_fragile_feature1.m b/test/Preprocessor/non_fragile_feature1.m index 79cc488a0b6e..6ea7fa8b6c5a 100644 --- a/test/Preprocessor/non_fragile_feature1.m +++ b/test/Preprocessor/non_fragile_feature1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi %s +// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-runtime=gcc %s #ifndef __has_feature #error Should have __has_feature #endif diff --git a/test/Preprocessor/pp-record.c b/test/Preprocessor/pp-record.c index f098683eeaa8..dd958d0e56d1 100644 --- a/test/Preprocessor/pp-record.c +++ b/test/Preprocessor/pp-record.c @@ -10,3 +10,14 @@ #include STRINGIZE(INC) CAKE; + +#define DIR 1 +#define FNM(x) x + +FNM( +#if DIR + int a; +#else + int b; +#endif +) diff --git a/test/Preprocessor/predefined-arch-macros.c b/test/Preprocessor/predefined-arch-macros.c index b063f7fe089a..2361abe20cd0 100644 --- a/test/Preprocessor/predefined-arch-macros.c +++ b/test/Preprocessor/predefined-arch-macros.c @@ -4,16 +4,19 @@ // Begin X86/GCC/Linux tests ---------------- // // RUN: %clang -march=i386 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_I386_M32 // CHECK_I386_M32: #define __i386 1 // CHECK_I386_M32: #define __i386__ 1 // CHECK_I386_M32: #define __tune_i386__ 1 // CHECK_I386_M32: #define i386 1 // RUN: %clang -march=i386 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_I386_M64 // CHECK_I386_M64: error: // // RUN: %clang -march=i486 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_I486_M32 // CHECK_I486_M32: #define __i386 1 // CHECK_I486_M32: #define __i386__ 1 @@ -22,10 +25,12 @@ // CHECK_I486_M32: #define __tune_i486__ 1 // CHECK_I486_M32: #define i386 1 // RUN: %clang -march=i486 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_I486_M64 // CHECK_I486_M64: error: // // RUN: %clang -march=i586 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_I586_M32 // CHECK_I586_M32: #define __i386 1 // CHECK_I586_M32: #define __i386__ 1 @@ -37,10 +42,12 @@ // CHECK_I586_M32: #define __tune_pentium__ 1 // CHECK_I586_M32: #define i386 1 // RUN: %clang -march=i586 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_I586_M64 // CHECK_I586_M64: error: // // RUN: %clang -march=pentium -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_M32 // CHECK_PENTIUM_M32: #define __i386 1 // CHECK_PENTIUM_M32: #define __i386__ 1 @@ -52,10 +59,12 @@ // CHECK_PENTIUM_M32: #define __tune_pentium__ 1 // CHECK_PENTIUM_M32: #define i386 1 // RUN: %clang -march=pentium -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_M64 // CHECK_PENTIUM_M64: error: // // RUN: %clang -march=pentium-mmx -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_MMX_M32 // CHECK_PENTIUM_MMX_M32: #define __MMX__ 1 // CHECK_PENTIUM_MMX_M32: #define __i386 1 @@ -70,10 +79,12 @@ // CHECK_PENTIUM_MMX_M32: #define __tune_pentium_mmx__ 1 // CHECK_PENTIUM_MMX_M32: #define i386 1 // RUN: %clang -march=pentium-mmx -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_MMX_M64 // CHECK_PENTIUM_MMX_M64: error: // // RUN: %clang -march=winchip-c6 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_WINCHIP_C6_M32 // CHECK_WINCHIP_C6_M32: #define __MMX__ 1 // CHECK_WINCHIP_C6_M32: #define __i386 1 @@ -83,10 +94,12 @@ // CHECK_WINCHIP_C6_M32: #define __tune_i486__ 1 // CHECK_WINCHIP_C6_M32: #define i386 1 // RUN: %clang -march=winchip-c6 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_WINCHIP_C6_M64 // CHECK_WINCHIP_C6_M64: error: // // RUN: %clang -march=winchip2 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_WINCHIP2_M32 // CHECK_WINCHIP2_M32: #define __3dNOW__ 1 // CHECK_WINCHIP2_M32: #define __MMX__ 1 @@ -97,10 +110,12 @@ // CHECK_WINCHIP2_M32: #define __tune_i486__ 1 // CHECK_WINCHIP2_M32: #define i386 1 // RUN: %clang -march=winchip2 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_WINCHIP2_M64 // CHECK_WINCHIP2_M64: error: // // RUN: %clang -march=c3 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_C3_M32 // CHECK_C3_M32: #define __3dNOW__ 1 // CHECK_C3_M32: #define __MMX__ 1 @@ -111,10 +126,12 @@ // CHECK_C3_M32: #define __tune_i486__ 1 // CHECK_C3_M32: #define i386 1 // RUN: %clang -march=c3 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_C3_M64 // CHECK_C3_M64: error: // // RUN: %clang -march=c3-2 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_C3_2_M32 // CHECK_C3_2_M32: #define __MMX__ 1 // CHECK_C3_2_M32: #define __SSE__ 1 @@ -129,10 +146,12 @@ // CHECK_C3_2_M32: #define __tune_pentiumpro__ 1 // CHECK_C3_2_M32: #define i386 1 // RUN: %clang -march=c3-2 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_C3_2_M64 // CHECK_C3_2_M64: error: // // RUN: %clang -march=i686 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_I686_M32 // CHECK_I686_M32: #define __i386 1 // CHECK_I686_M32: #define __i386__ 1 @@ -142,10 +161,12 @@ // CHECK_I686_M32: #define __pentiumpro__ 1 // CHECK_I686_M32: #define i386 1 // RUN: %clang -march=i686 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_I686_M64 // CHECK_I686_M64: error: // // RUN: %clang -march=pentiumpro -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUMPRO_M32 // CHECK_PENTIUMPRO_M32: #define __i386 1 // CHECK_PENTIUMPRO_M32: #define __i386__ 1 @@ -157,10 +178,12 @@ // CHECK_PENTIUMPRO_M32: #define __tune_pentiumpro__ 1 // CHECK_PENTIUMPRO_M32: #define i386 1 // RUN: %clang -march=pentiumpro -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUMPRO_M64 // CHECK_PENTIUMPRO_M64: error: // // RUN: %clang -march=pentium2 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM2_M32 // CHECK_PENTIUM2_M32: #define __MMX__ 1 // CHECK_PENTIUM2_M32: #define __i386 1 @@ -174,10 +197,12 @@ // CHECK_PENTIUM2_M32: #define __tune_pentiumpro__ 1 // CHECK_PENTIUM2_M32: #define i386 1 // RUN: %clang -march=pentium2 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM2_M64 // CHECK_PENTIUM2_M64: error: // // RUN: %clang -march=pentium3 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM3_M32 // CHECK_PENTIUM3_M32: #define __MMX__ 1 // CHECK_PENTIUM3_M32: #define __SSE__ 1 @@ -193,10 +218,12 @@ // CHECK_PENTIUM3_M32: #define __tune_pentiumpro__ 1 // CHECK_PENTIUM3_M32: #define i386 1 // RUN: %clang -march=pentium3 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM3_M64 // CHECK_PENTIUM3_M64: error: // // RUN: %clang -march=pentium3m -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM3M_M32 // CHECK_PENTIUM3M_M32: #define __MMX__ 1 // CHECK_PENTIUM3M_M32: #define __SSE__ 1 @@ -210,10 +237,12 @@ // CHECK_PENTIUM3M_M32: #define __tune_pentiumpro__ 1 // CHECK_PENTIUM3M_M32: #define i386 1 // RUN: %clang -march=pentium3m -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM3M_M64 // CHECK_PENTIUM3M_M64: error: // // RUN: %clang -march=pentium-m -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_M_M32 // CHECK_PENTIUM_M_M32: #define __MMX__ 1 // CHECK_PENTIUM_M_M32: #define __SSE2__ 1 @@ -228,10 +257,12 @@ // CHECK_PENTIUM_M_M32: #define __tune_pentiumpro__ 1 // CHECK_PENTIUM_M_M32: #define i386 1 // RUN: %clang -march=pentium-m -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM_M_M64 // CHECK_PENTIUM_M_M64: error: // // RUN: %clang -march=pentium4 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM4_M32 // CHECK_PENTIUM4_M32: #define __MMX__ 1 // CHECK_PENTIUM4_M32: #define __SSE2__ 1 @@ -243,10 +274,12 @@ // CHECK_PENTIUM4_M32: #define __tune_pentium4__ 1 // CHECK_PENTIUM4_M32: #define i386 1 // RUN: %clang -march=pentium4 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM4_M64 // CHECK_PENTIUM4_M64: error: // // RUN: %clang -march=pentium4m -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM4M_M32 // CHECK_PENTIUM4M_M32: #define __MMX__ 1 // CHECK_PENTIUM4M_M32: #define __SSE2__ 1 @@ -258,10 +291,12 @@ // CHECK_PENTIUM4M_M32: #define __tune_pentium4__ 1 // CHECK_PENTIUM4M_M32: #define i386 1 // RUN: %clang -march=pentium4m -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PENTIUM4M_M64 // CHECK_PENTIUM4M_M64: error: // // RUN: %clang -march=prescott -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PRESCOTT_M32 // CHECK_PRESCOTT_M32: #define __MMX__ 1 // CHECK_PRESCOTT_M32: #define __SSE2__ 1 @@ -274,10 +309,12 @@ // CHECK_PRESCOTT_M32: #define __tune_nocona__ 1 // CHECK_PRESCOTT_M32: #define i386 1 // RUN: %clang -march=prescott -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_PRESCOTT_M64 // CHECK_PRESCOTT_M64: error: // // RUN: %clang -march=nocona -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_NOCONA_M32 // CHECK_NOCONA_M32: #define __MMX__ 1 // CHECK_NOCONA_M32: #define __SSE2__ 1 @@ -290,6 +327,7 @@ // CHECK_NOCONA_M32: #define __tune_nocona__ 1 // CHECK_NOCONA_M32: #define i386 1 // RUN: %clang -march=nocona -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_NOCONA_M64 // CHECK_NOCONA_M64: #define __MMX__ 1 // CHECK_NOCONA_M64: #define __SSE2_MATH__ 1 @@ -306,6 +344,7 @@ // CHECK_NOCONA_M64: #define __x86_64__ 1 // // RUN: %clang -march=core2 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_CORE2_M32 // CHECK_CORE2_M32: #define __MMX__ 1 // CHECK_CORE2_M32: #define __SSE2__ 1 @@ -319,6 +358,7 @@ // CHECK_CORE2_M32: #define __tune_core2__ 1 // CHECK_CORE2_M32: #define i386 1 // RUN: %clang -march=core2 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_CORE2_M64 // CHECK_CORE2_M64: #define __MMX__ 1 // CHECK_CORE2_M64: #define __SSE2_MATH__ 1 @@ -336,8 +376,10 @@ // CHECK_CORE2_M64: #define __x86_64__ 1 // // RUN: %clang -march=corei7 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_COREI7_M32 // CHECK_COREI7_M32: #define __MMX__ 1 +// CHECK_COREI7_M32: #define __POPCNT__ 1 // CHECK_COREI7_M32: #define __SSE2__ 1 // CHECK_COREI7_M32: #define __SSE3__ 1 // CHECK_COREI7_M32: #define __SSE4_1__ 1 @@ -351,8 +393,10 @@ // CHECK_COREI7_M32: #define __tune_corei7__ 1 // CHECK_COREI7_M32: #define i386 1 // RUN: %clang -march=corei7 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_COREI7_M64 // CHECK_COREI7_M64: #define __MMX__ 1 +// CHECK_COREI7_M64: #define __POPCNT__ 1 // CHECK_COREI7_M64: #define __SSE2_MATH__ 1 // CHECK_COREI7_M64: #define __SSE2__ 1 // CHECK_COREI7_M64: #define __SSE3__ 1 @@ -370,11 +414,14 @@ // CHECK_COREI7_M64: #define __x86_64__ 1 // // RUN: %clang -march=corei7-avx -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_COREI7_AVX_M32 // CHECK_COREI7_AVX_M32: #define __AES__ 1 -// FIXME: AVX is not yet enabled with Clang. -// CHECK_COREI7_AVX_M32-NOT: #define __AVX__ 1 +// CHECK_COREI7_AVX_M32: #define __AVX__ 1 // CHECK_COREI7_AVX_M32: #define __MMX__ 1 +// CHECK_COREI7_AVX_M32: #define __PCLMUL__ 1 +// CHECK_COREI7_AVX_M32-NOT: __RDRND__ +// CHECK_COREI7_AVX_M32: #define __POPCNT__ 1 // CHECK_COREI7_AVX_M32: #define __SSE2__ 1 // CHECK_COREI7_AVX_M32: #define __SSE3__ 1 // CHECK_COREI7_AVX_M32: #define __SSE4_1__ 1 @@ -388,11 +435,14 @@ // CHECK_COREI7_AVX_M32: #define __tune_corei7__ 1 // CHECK_COREI7_AVX_M32: #define i386 1 // RUN: %clang -march=corei7-avx -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_COREI7_AVX_M64 // CHECK_COREI7_AVX_M64: #define __AES__ 1 -// FIXME: AVX is not yet enabled with Clang. -// CHECK_COREI7_AVX_M64-NOT: #define __AVX__ 1 +// CHECK_COREI7_AVX_M64: #define __AVX__ 1 // CHECK_COREI7_AVX_M64: #define __MMX__ 1 +// CHECK_COREI7_AVX_M64: #define __PCLMUL__ 1 +// CHECK_COREI7_AVX_M64-NOT: __RDRND__ +// CHECK_COREI7_AVX_M64: #define __POPCNT__ 1 // CHECK_COREI7_AVX_M64: #define __SSE2_MATH__ 1 // CHECK_COREI7_AVX_M64: #define __SSE2__ 1 // CHECK_COREI7_AVX_M64: #define __SSE3__ 1 @@ -410,11 +460,13 @@ // CHECK_COREI7_AVX_M64: #define __x86_64__ 1 // // RUN: %clang -march=core-avx-i -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_CORE_AVX_I_M32 // CHECK_CORE_AVX_I_M32: #define __AES__ 1 -// FIXME: AVX is not yet enabled with Clang. -// CHECK_CORE_AVX_I_M32-NOT: #define __AVX__ 1 +// CHECK_CORE_AVX_I_M32: #define __AVX__ 1 // CHECK_CORE_AVX_I_M32: #define __MMX__ 1 +// CHECK_CORE_AVX_I_M32: #define __PCLMUL__ 1 +// CHECK_CORE_AVX_I_M32: #define __RDRND__ 1 // CHECK_CORE_AVX_I_M32: #define __SSE2__ 1 // CHECK_CORE_AVX_I_M32: #define __SSE3__ 1 // CHECK_CORE_AVX_I_M32: #define __SSE4_1__ 1 @@ -428,11 +480,13 @@ // CHECK_CORE_AVX_I_M32: #define __tune_corei7__ 1 // CHECK_CORE_AVX_I_M32: #define i386 1 // RUN: %clang -march=core-avx-i -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_CORE_AVX_I_M64 // CHECK_CORE_AVX_I_M64: #define __AES__ 1 -// FIXME: AVX is not yet enabled with Clang. -// CHECK_CORE_AVX_I_M64-NOT: #define __AVX__ 1 +// CHECK_CORE_AVX_I_M64: #define __AVX__ 1 // CHECK_CORE_AVX_I_M64: #define __MMX__ 1 +// CHECK_CORE_AVX_I_M64: #define __PCLMUL__ 1 +// CHECK_CORE_AVX_I_M64: #define __RDRND__ 1 // CHECK_CORE_AVX_I_M64: #define __SSE2_MATH__ 1 // CHECK_CORE_AVX_I_M64: #define __SSE2__ 1 // CHECK_CORE_AVX_I_M64: #define __SSE3__ 1 @@ -449,7 +503,62 @@ // CHECK_CORE_AVX_I_M64: #define __x86_64 1 // CHECK_CORE_AVX_I_M64: #define __x86_64__ 1 // +// RUN: %clang -march=core-avx2 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ +// RUN: | FileCheck %s -check-prefix=CHECK_CORE_AVX2_M32 +// CHECK_CORE_AVX2_M32: #define __AES__ 1 +// CHECK_CORE_AVX2_M32: #define __AVX__ 1 +// CHECK_CORE_AVX2_M32: #define __BMI2__ 1 +// CHECK_CORE_AVX2_M32: #define __BMI__ 1 +// CHECK_CORE_AVX2_M32: #define __FMA__ 1 +// CHECK_CORE_AVX2_M32: #define __LZCNT__ 1 +// CHECK_CORE_AVX2_M32: #define __MMX__ 1 +// CHECK_CORE_AVX2_M32: #define __PCLMUL__ 1 +// CHECK_CORE_AVX2_M32: #define __POPCNT__ 1 +// CHECK_CORE_AVX2_M32: #define __RDRND__ 1 +// CHECK_CORE_AVX2_M32: #define __SSE2__ 1 +// CHECK_CORE_AVX2_M32: #define __SSE3__ 1 +// CHECK_CORE_AVX2_M32: #define __SSE4_1__ 1 +// CHECK_CORE_AVX2_M32: #define __SSE4_2__ 1 +// CHECK_CORE_AVX2_M32: #define __SSE__ 1 +// CHECK_CORE_AVX2_M32: #define __SSSE3__ 1 +// CHECK_CORE_AVX2_M32: #define __corei7 1 +// CHECK_CORE_AVX2_M32: #define __corei7__ 1 +// CHECK_CORE_AVX2_M32: #define __i386 1 +// CHECK_CORE_AVX2_M32: #define __i386__ 1 +// CHECK_CORE_AVX2_M32: #define __tune_corei7__ 1 +// CHECK_CORE_AVX2_M32: #define i386 1 +// RUN: %clang -march=core-avx2 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ +// RUN: | FileCheck %s -check-prefix=CHECK_CORE_AVX2_M64 +// CHECK_CORE_AVX2_M64: #define __AES__ 1 +// CHECK_CORE_AVX2_M64: #define __AVX__ 1 +// CHECK_CORE_AVX2_M64: #define __BMI2__ 1 +// CHECK_CORE_AVX2_M64: #define __BMI__ 1 +// CHECK_CORE_AVX2_M64: #define __FMA__ 1 +// CHECK_CORE_AVX2_M64: #define __LZCNT__ 1 +// CHECK_CORE_AVX2_M64: #define __MMX__ 1 +// CHECK_CORE_AVX2_M64: #define __PCLMUL__ 1 +// CHECK_CORE_AVX2_M64: #define __POPCNT__ 1 +// CHECK_CORE_AVX2_M64: #define __RDRND__ 1 +// CHECK_CORE_AVX2_M64: #define __SSE2_MATH__ 1 +// CHECK_CORE_AVX2_M64: #define __SSE2__ 1 +// CHECK_CORE_AVX2_M64: #define __SSE3__ 1 +// CHECK_CORE_AVX2_M64: #define __SSE4_1__ 1 +// CHECK_CORE_AVX2_M64: #define __SSE4_2__ 1 +// CHECK_CORE_AVX2_M64: #define __SSE_MATH__ 1 +// CHECK_CORE_AVX2_M64: #define __SSE__ 1 +// CHECK_CORE_AVX2_M64: #define __SSSE3__ 1 +// CHECK_CORE_AVX2_M64: #define __amd64 1 +// CHECK_CORE_AVX2_M64: #define __amd64__ 1 +// CHECK_CORE_AVX2_M64: #define __corei7 1 +// CHECK_CORE_AVX2_M64: #define __corei7__ 1 +// CHECK_CORE_AVX2_M64: #define __tune_corei7__ 1 +// CHECK_CORE_AVX2_M64: #define __x86_64 1 +// CHECK_CORE_AVX2_M64: #define __x86_64__ 1 +// // RUN: %clang -march=atom -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATOM_M32 // CHECK_ATOM_M32: #define __MMX__ 1 // CHECK_ATOM_M32: #define __SSE2__ 1 @@ -463,6 +572,7 @@ // CHECK_ATOM_M32: #define __tune_atom__ 1 // CHECK_ATOM_M32: #define i386 1 // RUN: %clang -march=atom -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATOM_M64 // CHECK_ATOM_M64: #define __MMX__ 1 // CHECK_ATOM_M64: #define __SSE2_MATH__ 1 @@ -480,6 +590,7 @@ // CHECK_ATOM_M64: #define __x86_64__ 1 // // RUN: %clang -march=geode -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_GEODE_M32 // CHECK_GEODE_M32: #define __3dNOW_A__ 1 // CHECK_GEODE_M32: #define __3dNOW__ 1 @@ -491,10 +602,12 @@ // CHECK_GEODE_M32: #define __tune_geode__ 1 // CHECK_GEODE_M32: #define i386 1 // RUN: %clang -march=geode -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_GEODE_M64 // CHECK_GEODE_M64: error: // // RUN: %clang -march=k6 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_K6_M32 // CHECK_K6_M32: #define __MMX__ 1 // CHECK_K6_M32: #define __i386 1 @@ -504,10 +617,12 @@ // CHECK_K6_M32: #define __tune_k6__ 1 // CHECK_K6_M32: #define i386 1 // RUN: %clang -march=k6 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_K6_M64 // CHECK_K6_M64: error: // // RUN: %clang -march=k6-2 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_K6_2_M32 // CHECK_K6_2_M32: #define __3dNOW__ 1 // CHECK_K6_2_M32: #define __MMX__ 1 @@ -520,10 +635,12 @@ // CHECK_K6_2_M32: #define __tune_k6__ 1 // CHECK_K6_2_M32: #define i386 1 // RUN: %clang -march=k6-2 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_K6_2_M64 // CHECK_K6_2_M64: error: // // RUN: %clang -march=k6-3 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_K6_3_M32 // CHECK_K6_3_M32: #define __3dNOW__ 1 // CHECK_K6_3_M32: #define __MMX__ 1 @@ -536,10 +653,12 @@ // CHECK_K6_3_M32: #define __tune_k6__ 1 // CHECK_K6_3_M32: #define i386 1 // RUN: %clang -march=k6-3 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_K6_3_M64 // CHECK_K6_3_M64: error: // // RUN: %clang -march=athlon -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_M32 // CHECK_ATHLON_M32: #define __3dNOW_A__ 1 // CHECK_ATHLON_M32: #define __3dNOW__ 1 @@ -551,10 +670,12 @@ // CHECK_ATHLON_M32: #define __tune_athlon__ 1 // CHECK_ATHLON_M32: #define i386 1 // RUN: %clang -march=athlon -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_M64 // CHECK_ATHLON_M64: error: // // RUN: %clang -march=athlon-tbird -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_TBIRD_M32 // CHECK_ATHLON_TBIRD_M32: #define __3dNOW_A__ 1 // CHECK_ATHLON_TBIRD_M32: #define __3dNOW__ 1 @@ -566,10 +687,12 @@ // CHECK_ATHLON_TBIRD_M32: #define __tune_athlon__ 1 // CHECK_ATHLON_TBIRD_M32: #define i386 1 // RUN: %clang -march=athlon-tbird -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_TBIRD_M64 // CHECK_ATHLON_TBIRD_M64: error: // // RUN: %clang -march=athlon-4 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_4_M32 // CHECK_ATHLON_4_M32: #define __3dNOW_A__ 1 // CHECK_ATHLON_4_M32: #define __3dNOW__ 1 @@ -584,10 +707,12 @@ // CHECK_ATHLON_4_M32: #define __tune_athlon_sse__ 1 // CHECK_ATHLON_4_M32: #define i386 1 // RUN: %clang -march=athlon-4 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_4_M64 // CHECK_ATHLON_4_M64: error: // // RUN: %clang -march=athlon-xp -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_XP_M32 // CHECK_ATHLON_XP_M32: #define __3dNOW_A__ 1 // CHECK_ATHLON_XP_M32: #define __3dNOW__ 1 @@ -602,10 +727,12 @@ // CHECK_ATHLON_XP_M32: #define __tune_athlon_sse__ 1 // CHECK_ATHLON_XP_M32: #define i386 1 // RUN: %clang -march=athlon-xp -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_XP_M64 // CHECK_ATHLON_XP_M64: error: // // RUN: %clang -march=athlon-mp -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_MP_M32 // CHECK_ATHLON_MP_M32: #define __3dNOW_A__ 1 // CHECK_ATHLON_MP_M32: #define __3dNOW__ 1 @@ -620,10 +747,12 @@ // CHECK_ATHLON_MP_M32: #define __tune_athlon_sse__ 1 // CHECK_ATHLON_MP_M32: #define i386 1 // RUN: %clang -march=athlon-mp -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_MP_M64 // CHECK_ATHLON_MP_M64: error: // // RUN: %clang -march=x86-64 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_X86_64_M32 // CHECK_X86_64_M32: #define __MMX__ 1 // CHECK_X86_64_M32: #define __SSE2__ 1 @@ -634,6 +763,7 @@ // CHECK_X86_64_M32: #define __k8__ 1 // CHECK_X86_64_M32: #define i386 1 // RUN: %clang -march=x86-64 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_X86_64_M64 // CHECK_X86_64_M64: #define __MMX__ 1 // CHECK_X86_64_M64: #define __SSE2_MATH__ 1 @@ -648,6 +778,7 @@ // CHECK_X86_64_M64: #define __x86_64__ 1 // // RUN: %clang -march=k8 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_K8_M32 // CHECK_K8_M32: #define __3dNOW_A__ 1 // CHECK_K8_M32: #define __3dNOW__ 1 @@ -661,6 +792,7 @@ // CHECK_K8_M32: #define __tune_k8__ 1 // CHECK_K8_M32: #define i386 1 // RUN: %clang -march=k8 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_K8_M64 // CHECK_K8_M64: #define __3dNOW_A__ 1 // CHECK_K8_M64: #define __3dNOW__ 1 @@ -678,6 +810,7 @@ // CHECK_K8_M64: #define __x86_64__ 1 // // RUN: %clang -march=k8-sse3 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_K8_SSE3_M32 // CHECK_K8_SSE3_M32: #define __3dNOW_A__ 1 // CHECK_K8_SSE3_M32: #define __3dNOW__ 1 @@ -692,6 +825,7 @@ // CHECK_K8_SSE3_M32: #define __tune_k8__ 1 // CHECK_K8_SSE3_M32: #define i386 1 // RUN: %clang -march=k8-sse3 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_K8_SSE3_M64 // CHECK_K8_SSE3_M64: #define __3dNOW_A__ 1 // CHECK_K8_SSE3_M64: #define __3dNOW__ 1 @@ -710,6 +844,7 @@ // CHECK_K8_SSE3_M64: #define __x86_64__ 1 // // RUN: %clang -march=opteron -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_OPTERON_M32 // CHECK_OPTERON_M32: #define __3dNOW_A__ 1 // CHECK_OPTERON_M32: #define __3dNOW__ 1 @@ -723,6 +858,7 @@ // CHECK_OPTERON_M32: #define __tune_k8__ 1 // CHECK_OPTERON_M32: #define i386 1 // RUN: %clang -march=opteron -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_OPTERON_M64 // CHECK_OPTERON_M64: #define __3dNOW_A__ 1 // CHECK_OPTERON_M64: #define __3dNOW__ 1 @@ -740,6 +876,7 @@ // CHECK_OPTERON_M64: #define __x86_64__ 1 // // RUN: %clang -march=opteron-sse3 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_OPTERON_SSE3_M32 // CHECK_OPTERON_SSE3_M32: #define __3dNOW_A__ 1 // CHECK_OPTERON_SSE3_M32: #define __3dNOW__ 1 @@ -754,6 +891,7 @@ // CHECK_OPTERON_SSE3_M32: #define __tune_k8__ 1 // CHECK_OPTERON_SSE3_M32: #define i386 1 // RUN: %clang -march=opteron-sse3 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_OPTERON_SSE3_M64 // CHECK_OPTERON_SSE3_M64: #define __3dNOW_A__ 1 // CHECK_OPTERON_SSE3_M64: #define __3dNOW__ 1 @@ -772,6 +910,7 @@ // CHECK_OPTERON_SSE3_M64: #define __x86_64__ 1 // // RUN: %clang -march=athlon64 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON64_M32 // CHECK_ATHLON64_M32: #define __3dNOW_A__ 1 // CHECK_ATHLON64_M32: #define __3dNOW__ 1 @@ -785,6 +924,7 @@ // CHECK_ATHLON64_M32: #define __tune_k8__ 1 // CHECK_ATHLON64_M32: #define i386 1 // RUN: %clang -march=athlon64 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON64_M64 // CHECK_ATHLON64_M64: #define __3dNOW_A__ 1 // CHECK_ATHLON64_M64: #define __3dNOW__ 1 @@ -802,6 +942,7 @@ // CHECK_ATHLON64_M64: #define __x86_64__ 1 // // RUN: %clang -march=athlon64-sse3 -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON64_SSE3_M32 // CHECK_ATHLON64_SSE3_M32: #define __3dNOW_A__ 1 // CHECK_ATHLON64_SSE3_M32: #define __3dNOW__ 1 @@ -816,6 +957,7 @@ // CHECK_ATHLON64_SSE3_M32: #define __tune_k8__ 1 // CHECK_ATHLON64_SSE3_M32: #define i386 1 // RUN: %clang -march=athlon64-sse3 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON64_SSE3_M64 // CHECK_ATHLON64_SSE3_M64: #define __3dNOW_A__ 1 // CHECK_ATHLON64_SSE3_M64: #define __3dNOW__ 1 @@ -834,6 +976,7 @@ // CHECK_ATHLON64_SSE3_M64: #define __x86_64__ 1 // // RUN: %clang -march=athlon-fx -m32 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_FX_M32 // CHECK_ATHLON_FX_M32: #define __3dNOW_A__ 1 // CHECK_ATHLON_FX_M32: #define __3dNOW__ 1 @@ -847,6 +990,7 @@ // CHECK_ATHLON_FX_M32: #define __tune_k8__ 1 // CHECK_ATHLON_FX_M32: #define i386 1 // RUN: %clang -march=athlon-fx -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ // RUN: | FileCheck %s -check-prefix=CHECK_ATHLON_FX_M64 // CHECK_ATHLON_FX_M64: #define __3dNOW_A__ 1 // CHECK_ATHLON_FX_M64: #define __3dNOW__ 1 @@ -862,5 +1006,50 @@ // CHECK_ATHLON_FX_M64: #define __tune_k8__ 1 // CHECK_ATHLON_FX_M64: #define __x86_64 1 // CHECK_ATHLON_FX_M64: #define __x86_64__ 1 +// RUN: %clang -march=amdfam10 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ +// RUN: | FileCheck %s -check-prefix=CHECK_AMDFAM10_M64 +// CHECK_AMDFAM10_M64: #define __3dNOW_A__ 1 +// CHECK_AMDFAM10_M64: #define __3dNOW__ 1 +// CHECK_AMDFAM10_M64: #define __MMX__ 1 +// CHECK_AMDFAM10_M64: #define __SSE2_MATH__ 1 +// CHECK_AMDFAM10_M64: #define __SSE2__ 1 +// CHECK_AMDFAM10_M64: #define __SSE3__ 1 +// CHECK_AMDFAM10_M64: #define __SSE4A__ 1 +// CHECK_AMDFAM10_M64: #define __SSE_MATH__ 1 +// CHECK_AMDFAM10_M64: #define __SSE__ 1 +// CHECK_AMDFAM10_M64: #define __amd64 1 +// CHECK_AMDFAM10_M64: #define __amd64__ 1 +// CHECK_AMDFAM10_M64: #define __amdfam10 1 +// CHECK_AMDFAM10_M64: #define __amdfam10__ 1 +// CHECK_AMDFAM10_M64: #define __tune_amdfam10__ 1 +// CHECK_AMDFAM10_M64: #define __x86_64 1 +// CHECK_AMDFAM10_M64: #define __x86_64__ 1 +// RUN: %clang -march=bdver1 -m64 -E -dM %s -o - 2>&1 \ +// RUN: -target i386-unknown-linux \ +// RUN: | FileCheck %s -check-prefix=CHECK_BDVER1_M64 +// CHECK_BDVER1_M64: #define __AVX__ 1 +// CHECK_BDVER1_M64-NOT: #define __3dNOW_A__ 1 +// CHECK_BDVER1_M64-NOT: #define __3dNOW__ 1 +// CHECK_BDVER1_M64: #define __FMA4__ 1 +// CHECK_BDVER1_M64: #define __MMX__ 1 +// CHECK_BDVER1_M64: #define __PCLMUL__ 1 +// CHECK_BDVER1_M64: #define __SSE2_MATH__ 1 +// CHECK_BDVER1_M64: #define __SSE2__ 1 +// CHECK_BDVER1_M64: #define __SSE3__ 1 +// CHECK_BDVER1_M64: #define __SSE4A__ 1 +// CHECK_BDVER1_M64: #define __SSE4_1__ 1 +// CHECK_BDVER1_M64: #define __SSE4_2__ 1 +// CHECK_BDVER1_M64: #define __SSE_MATH__ 1 +// CHECK_BDVER1_M64: #define __SSE__ 1 +// CHECK_BDVER1_M64: #define __SSSE3__ 1 +// CHECK_BDVER1_M64: #define __XOP__ 1 +// CHECK_BDVER1_M64: #define __amd64 1 +// CHECK_BDVER1_M64: #define __amd64__ 1 +// CHECK_BDVER1_M64: #define __bdver1 1 +// CHECK_BDVER1_M64: #define __bdver1__ 1 +// CHECK_BDVER1_M64: #define __tune_bdver1__ 1 +// CHECK_BDVER1_M64: #define __x86_64 1 +// CHECK_BDVER1_M64: #define __x86_64__ 1 // // End X86/GCC/Linux tests ------------------ diff --git a/test/Preprocessor/predefined-macros.c b/test/Preprocessor/predefined-macros.c index 5c11c3b7b2a3..2c193018b5c0 100644 --- a/test/Preprocessor/predefined-macros.c +++ b/test/Preprocessor/predefined-macros.c @@ -13,3 +13,16 @@ // RUN: %clang_cc1 %s -E -dM -ffast-math -o - \ // RUN: | FileCheck %s --check-prefix=CHECK-FAST-MATH // CHECK-FAST-MATH: #define __FAST_MATH__ +// CHECK-FAST-MATH: #define __FINITE_MATH_ONLY__ 1 +// +// RUN: %clang_cc1 %s -E -dM -ffinite-math-only -o - \ +// RUN: | FileCheck %s --check-prefix=CHECK-FINITE-MATH-ONLY +// CHECK-FINITE-MATH-ONLY: #define __FINITE_MATH_ONLY__ 1 +// +// RUN: %clang %s -E -dM -fno-finite-math-only -o - \ +// RUN: | FileCheck %s --check-prefix=CHECK-NO-FINITE-MATH-ONLY +// CHECK-NO-FINITE-MATH-ONLY: #define __FINITE_MATH_ONLY__ 0 +// +// RUN: %clang_cc1 %s -E -dM -o - \ +// RUN: | FileCheck %s --check-prefix=CHECK-FINITE-MATH-FLAG-UNDEFINED +// CHECK-FINITE-MATH-FLAG-UNDEFINED: #define __FINITE_MATH_ONLY__ 0 diff --git a/test/Preprocessor/undef-error.c b/test/Preprocessor/undef-error.c index ad611decedda..959c163e031d 100644 --- a/test/Preprocessor/undef-error.c +++ b/test/Preprocessor/undef-error.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -pedantic-errors -verify +// RUN: %clang_cc1 %s -pedantic-errors -Wno-empty-translation-unit -verify // PR2045 #define b diff --git a/test/Preprocessor/warning_tests.c b/test/Preprocessor/warning_tests.c index 96b96efc7e69..3f2865cdb470 100644 --- a/test/Preprocessor/warning_tests.c +++ b/test/Preprocessor/warning_tests.c @@ -6,14 +6,16 @@ #if __has_warning("not valid") // expected-warning {{__has_warning expected option name}} #endif +// expected-warning@+2 {{Should have -Wparentheses}} #if __has_warning("-Wparentheses") -#warning Should have -Wparentheses // expected-warning {{Should have -Wparentheses}} +#warning Should have -Wparentheses #endif #if __has_warning(-Wfoo) // expected-error {{builtin warning check macro requires a parenthesized string}} #endif +// expected-warning@+3 {{Not a valid warning flag}} #if __has_warning("-Wnot-a-valid-warning-flag-at-all") #else -#warning Not a valid warning flag // expected-warning {{Not a valid warning flag}} -#endif
\ No newline at end of file +#warning Not a valid warning flag +#endif diff --git a/test/Rewriter/blockcast3.mm b/test/Rewriter/blockcast3.mm index ceafcff3b091..697a465a9317 100644 --- a/test/Rewriter/blockcast3.mm +++ b/test/Rewriter/blockcast3.mm @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -E %s -o %t.mm -// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %t.mm -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %t.mm -o %t-rw.cpp // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o %t-modern-rw.cpp // RUN: FileCheck -check-prefix LP --input-file=%t-modern-rw.cpp %s diff --git a/test/Rewriter/blockstruct.m b/test/Rewriter/blockstruct.m index ef85c587b129..2c443616cf86 100644 --- a/test/Rewriter/blockstruct.m +++ b/test/Rewriter/blockstruct.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar://8918702 diff --git a/test/Rewriter/crash.m b/test/Rewriter/crash.m index c61100ed0f09..7908d9fea5e2 100644 --- a/test/Rewriter/crash.m +++ b/test/Rewriter/crash.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -o - %s +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -o - %s // rdar://5950938 @interface NSArray {} + (id)arrayWithObjects:(id)firstObj, ...; diff --git a/test/Rewriter/finally.m b/test/Rewriter/finally.m index 8fd475cab6e2..f46b4b01a5ff 100644 --- a/test/Rewriter/finally.m +++ b/test/Rewriter/finally.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -fobjc-exceptions -verify %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -fobjc-exceptions -verify %s -o - int main() { @try { diff --git a/test/Rewriter/func-in-impl.m b/test/Rewriter/func-in-impl.m index 350a72671b66..9c4a159364f4 100644 --- a/test/Rewriter/func-in-impl.m +++ b/test/Rewriter/func-in-impl.m @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -E %s -o %t.m -// RUN: %clang_cc1 -fobjc-fragile-abi -rewrite-objc %t.m -o - | FileCheck %s +// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -rewrite-objc %t.m -o - | FileCheck %s @interface I { id _delegate; diff --git a/test/Rewriter/id-test-3.m b/test/Rewriter/id-test-3.m index d7a7bf3eb7a0..ec4cfe44b0c9 100644 --- a/test/Rewriter/id-test-3.m +++ b/test/Rewriter/id-test-3.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @protocol P - (id<P>) Meth: (id<P>) Arg; diff --git a/test/Rewriter/inner-block-helper-funcs.mm b/test/Rewriter/inner-block-helper-funcs.mm index d30e1dcadc87..fb565b6e30f3 100644 --- a/test/Rewriter/inner-block-helper-funcs.mm +++ b/test/Rewriter/inner-block-helper-funcs.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s // rdar://9846759 diff --git a/test/Rewriter/instancetype-test.mm b/test/Rewriter/instancetype-test.mm index 788505562c39..4a7f96103afd 100644 --- a/test/Rewriter/instancetype-test.mm +++ b/test/Rewriter/instancetype-test.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp diff --git a/test/Rewriter/ivar-encoding-1.m b/test/Rewriter/ivar-encoding-1.m index d2949439c733..3f5543e4cd15 100644 --- a/test/Rewriter/ivar-encoding-1.m +++ b/test/Rewriter/ivar-encoding-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @interface Intf { diff --git a/test/Rewriter/ivar-encoding-2.m b/test/Rewriter/ivar-encoding-2.m index da60c79e260a..422568bf479c 100644 --- a/test/Rewriter/ivar-encoding-2.m +++ b/test/Rewriter/ivar-encoding-2.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @implementation Intf { diff --git a/test/Rewriter/metadata-test-1.m b/test/Rewriter/metadata-test-1.m index b2d6e8daee23..caa7ca3b54e3 100644 --- a/test/Rewriter/metadata-test-1.m +++ b/test/Rewriter/metadata-test-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @interface Intf @end diff --git a/test/Rewriter/metadata-test-2.m b/test/Rewriter/metadata-test-2.m index 90399f7968ae..3ffda5809c53 100644 --- a/test/Rewriter/metadata-test-2.m +++ b/test/Rewriter/metadata-test-2.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - typedef struct _NSPoint { float x; diff --git a/test/Rewriter/method-encoding-1.m b/test/Rewriter/method-encoding-1.m index 27abea575e07..2cd309ee9b98 100644 --- a/test/Rewriter/method-encoding-1.m +++ b/test/Rewriter/method-encoding-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @protocol P1 - (void) MyProtoMeth : (int **) arg1 : (void*) arg2; diff --git a/test/Rewriter/objc-bool-literal-modern-1.mm b/test/Rewriter/objc-bool-literal-modern-1.mm index 782517242e52..7aaa79b1e943 100644 --- a/test/Rewriter/objc-bool-literal-modern-1.mm +++ b/test/Rewriter/objc-bool-literal-modern-1.mm @@ -2,6 +2,9 @@ // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"__declspec(X)=" %t-rw.cpp // rdar://11231426 +// rdar://11375908 +typedef unsigned long size_t; + typedef bool BOOL; BOOL yes() { diff --git a/test/Rewriter/objc-encoding-bug-1.m b/test/Rewriter/objc-encoding-bug-1.m index 083b570e52d3..55e980493c29 100644 --- a/test/Rewriter/objc-encoding-bug-1.m +++ b/test/Rewriter/objc-encoding-bug-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - typedef struct NSMethodFrameArgInfo { struct NSMethodFrameArgInfo *subInfo; diff --git a/test/Rewriter/objc-ivar-receiver-1.m b/test/Rewriter/objc-ivar-receiver-1.m index 51950427ca87..6cccf88d104c 100644 --- a/test/Rewriter/objc-ivar-receiver-1.m +++ b/test/Rewriter/objc-ivar-receiver-1.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - | grep 'newInv->_container' +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - | grep 'newInv->_container' @interface NSMutableArray - (void)addObject:(id)addObject; diff --git a/test/Rewriter/objc-modern-StretAPI.mm b/test/Rewriter/objc-modern-StretAPI.mm new file mode 100644 index 000000000000..129b56cbe92d --- /dev/null +++ b/test/Rewriter/objc-modern-StretAPI.mm @@ -0,0 +1,45 @@ +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// rdar://11359268 + +extern "C" void *sel_registerName(const char *); +typedef unsigned long size_t; + +union U { + double d1; + char filler[32]; +}; + +struct S { + char filler[128]; +}; + +@interface I +- (struct S) Meth : (int) arg1 : (id) arg2; +- (struct S) Meth1; +- (union U) Meth2 : (double)d; +- (struct S) VAMeth : (int)anchor, ...; +@end + +I* PI(); + +extern "C" { + +struct S foo () { + struct S s = [PI() Meth : 1 : (id)0]; + + U u = [PI() Meth2 : 3.14]; + + S s1 = [PI() VAMeth : 12, 13.4, 1000, "hello"]; + + S s2 = [PI() VAMeth : 12]; + + S s3 = [PI() VAMeth : 0, "hello", "there"]; + + S s4 = [PI() VAMeth : 2, ^{}, &foo]; + + return [PI() Meth1]; +} + +} + diff --git a/test/Rewriter/objc-modern-boxing.mm b/test/Rewriter/objc-modern-boxing.mm new file mode 100644 index 000000000000..8f8ed751c58e --- /dev/null +++ b/test/Rewriter/objc-modern-boxing.mm @@ -0,0 +1,72 @@ +// RUN: %clang_cc1 -E %s -o %t.mm +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp -Wno-attributes + +extern char *strdup(const char *str); +extern "C" void *sel_registerName(const char *); + +typedef signed char BOOL; +typedef long NSInteger; +typedef unsigned long NSUInteger; + +#if __has_feature(objc_bool) +#define YES __objc_yes +#define NO __objc_no +#else +#define YES ((BOOL)1) +#define NO ((BOOL)0) +#endif + +@interface NSNumber ++ (NSNumber *)numberWithChar:(char)value; ++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; ++ (NSNumber *)numberWithShort:(short)value; ++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; ++ (NSNumber *)numberWithInt:(int)value; ++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; ++ (NSNumber *)numberWithLong:(long)value; ++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; ++ (NSNumber *)numberWithLongLong:(long long)value; ++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; ++ (NSNumber *)numberWithFloat:(float)value; ++ (NSNumber *)numberWithDouble:(double)value; ++ (NSNumber *)numberWithBool:(BOOL)value; ++ (NSNumber *)numberWithInteger:(NSInteger)value ; ++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value ; +@end + +@interface NSString ++ (id)stringWithUTF8String:(const char *)str; +@end + +int main(int argc, const char *argv[]) { + // character. + NSNumber *theLetterZ = @('Z'); // equivalent to [NSNumber numberWithChar:('Z')] + + // integral. + NSNumber *fortyTwo = @(42); // equivalent to [NSNumber numberWithInt:(42)] + NSNumber *fortyTwoUnsigned = @(42U); // equivalent to [NSNumber numberWithUnsignedInt:(42U)] + NSNumber *fortyTwoLong = @(42L); // equivalent to [NSNumber numberWithLong:(42L)] + NSNumber *fortyTwoLongLong = @(42LL); // equivalent to [NSNumber numberWithLongLong:(42LL)] + + // floating point. + NSNumber *piFloat = @(3.141592654F); // equivalent to [NSNumber numberWithFloat:(3.141592654F)] + NSNumber *piDouble = @(3.1415926535); // equivalent to [NSNumber numberWithDouble:(3.1415926535)] + + BOOL b; + NSNumber *nsb = @(b); + + // Strings. + NSString *duplicateString = @(strdup("Hello")); +} + +// CHECK: NSNumber *theLetterZ = ((NSNumber *(*)(id, SEL, char))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithChar:"), ('Z')); +// CHECK: NSNumber *fortyTwo = ((NSNumber *(*)(id, SEL, int))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithInt:"), (42)); +// CHECK: NSNumber *fortyTwoUnsigned = ((NSNumber *(*)(id, SEL, unsigned int))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithUnsignedInt:"), (42U)); +// CHECK: NSNumber *fortyTwoLong = ((NSNumber *(*)(id, SEL, long))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithLong:"), (42L)); +// CHECK: NSNumber *fortyTwoLongLong = ((NSNumber *(*)(id, SEL, long long))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithLongLong:"), (42LL)); +// CHECK: NSNumber *piFloat = ((NSNumber *(*)(id, SEL, float))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithFloat:"), (3.1415927)); +// CHECK: NSNumber *piDouble = ((NSNumber *(*)(id, SEL, double))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithDouble:"), (3.1415926535)); +// CHECK: NSNumber *nsb = ((NSNumber *(*)(id, SEL, BOOL))(void *)objc_msgSend)(objc_getClass("NSNumber"), sel_registerName("numberWithBool:"), (BOOL)(b)); +// CHECK: NSString *duplicateString = ((NSString *(*)(id, SEL, const char *))(void *)objc_msgSend)(objc_getClass("NSString"), sel_registerName("stringWithUTF8String:"), (const char *)(strdup("Hello"))); diff --git a/test/Rewriter/objc-modern-container-subscript.mm b/test/Rewriter/objc-modern-container-subscript.mm index d6bb9c2eb31d..cdcff03b770b 100644 --- a/test/Rewriter/objc-modern-container-subscript.mm +++ b/test/Rewriter/objc-modern-container-subscript.mm @@ -2,9 +2,10 @@ // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar://11203853 +typedef unsigned long size_t; + void *sel_registerName(const char *); -typedef unsigned int size_t; @protocol P @end @interface NSMutableArray diff --git a/test/Rewriter/objc-modern-getclass-proto.mm b/test/Rewriter/objc-modern-getclass-proto.mm new file mode 100644 index 000000000000..98e76e01aac7 --- /dev/null +++ b/test/Rewriter/objc-modern-getclass-proto.mm @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -E %s -o %t.mm +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %t.mm -o %t-rw.cpp +// rdar://11375495 + +@interface I @end +@implementation I @end + +// CHECK: __OBJC_RW_DLLIMPORT struct objc_class *objc_getClass(const char *); +// CHECK: __OBJC_RW_DLLIMPORT struct objc_class *objc_getMetaClass(const char *); + diff --git a/test/Rewriter/objc-modern-property-attributes.mm b/test/Rewriter/objc-modern-property-attributes.mm index 7d74a95e7d16..abebb2c0feff 100644 --- a/test/Rewriter/objc-modern-property-attributes.mm +++ b/test/Rewriter/objc-modern-property-attributes.mm @@ -33,3 +33,13 @@ typedef void (^void_block_t)(void); // CHECK: T@?,C,V__completion // CHECK: T@\"PropertyClass\",&,VYVAR +@interface Test @end +@interface Test (Category) +@property int q; +@end + +@implementation Test (Category) +@dynamic q; +@end + +// CHECK: {{"q","Ti,D"}} diff --git a/test/Rewriter/objc-string-concat-1.m b/test/Rewriter/objc-string-concat-1.m index 80a9f04651dd..9a23abcc7ff9 100644 --- a/test/Rewriter/objc-string-concat-1.m +++ b/test/Rewriter/objc-string-concat-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @class NSString; diff --git a/test/Rewriter/objc-super-test.m b/test/Rewriter/objc-super-test.m index fa95ad2fd346..68412d899b9c 100644 --- a/test/Rewriter/objc-super-test.m +++ b/test/Rewriter/objc-super-test.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - | grep objc_msgSendSuper | grep MainMethod +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - | grep objc_msgSendSuper | grep MainMethod typedef struct objc_selector *SEL; typedef struct objc_object *id; diff --git a/test/Rewriter/objc-synchronized-1.m b/test/Rewriter/objc-synchronized-1.m index df5553690ffc..0e985ab67f2b 100644 --- a/test/Rewriter/objc-synchronized-1.m +++ b/test/Rewriter/objc-synchronized-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - id SYNCH_EXPR(); void SYNCH_BODY(); diff --git a/test/Rewriter/properties.m b/test/Rewriter/properties.m index 493fc3f8f4b1..67e864ed0fab 100644 --- a/test/Rewriter/properties.m +++ b/test/Rewriter/properties.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp void *sel_registerName(const char *); diff --git a/test/Rewriter/property-dot-syntax.mm b/test/Rewriter/property-dot-syntax.mm index c8ee7234b4b2..c3e4405ebb58 100644 --- a/test/Rewriter/property-dot-syntax.mm +++ b/test/Rewriter/property-dot-syntax.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar:// 8520727 diff --git a/test/Rewriter/protocol-rewrite-1.m b/test/Rewriter/protocol-rewrite-1.m index 687a2591611a..541b7ee9baba 100644 --- a/test/Rewriter/protocol-rewrite-1.m +++ b/test/Rewriter/protocol-rewrite-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - typedef struct MyWidget { int a; diff --git a/test/Rewriter/protocol-rewrite-2.m b/test/Rewriter/protocol-rewrite-2.m index e0ec4f991b53..e0d59e88fe33 100644 --- a/test/Rewriter/protocol-rewrite-2.m +++ b/test/Rewriter/protocol-rewrite-2.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o %t.cpp +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t.cpp // RUN: %clang_cc1 -fsyntax-only %t.cpp // rdar://10234024 diff --git a/test/Rewriter/rewrite-anonymous-union.m b/test/Rewriter/rewrite-anonymous-union.m index 339524fbc8ab..bc35fd02e9fc 100644 --- a/test/Rewriter/rewrite-anonymous-union.m +++ b/test/Rewriter/rewrite-anonymous-union.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -o - %s +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -o - %s // rdar://6948022 typedef unsigned int uint32_t; diff --git a/test/Rewriter/rewrite-api-bug.m b/test/Rewriter/rewrite-api-bug.m index ebaa0be13d67..f4a88ddf7782 100644 --- a/test/Rewriter/rewrite-api-bug.m +++ b/test/Rewriter/rewrite-api-bug.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @interface MyDerived - (void) instanceMethod; diff --git a/test/Rewriter/rewrite-block-argument.m b/test/Rewriter/rewrite-block-argument.m index 898f9836a743..4e1194d507d4 100644 --- a/test/Rewriter/rewrite-block-argument.m +++ b/test/Rewriter/rewrite-block-argument.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" -emit-llvm -o %t %t-rw.cpp // radar 7987817 diff --git a/test/Rewriter/rewrite-block-consts.mm b/test/Rewriter/rewrite-block-consts.mm index 1d6de8cd6abc..1b32b35f33a8 100644 --- a/test/Rewriter/rewrite-block-consts.mm +++ b/test/Rewriter/rewrite-block-consts.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D__block="" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar:// 8243071 diff --git a/test/Rewriter/rewrite-block-ivar-call.mm b/test/Rewriter/rewrite-block-ivar-call.mm index 2ec27b3eb065..8e5a2ea124a8 100644 --- a/test/Rewriter/rewrite-block-ivar-call.mm +++ b/test/Rewriter/rewrite-block-ivar-call.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -fobjc-fragile-abi -o - %s +// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -o - %s @interface Foo { void (^_block)(void); diff --git a/test/Rewriter/rewrite-block-literal-1.mm b/test/Rewriter/rewrite-block-literal-1.mm index f152117443a7..88ad5742effa 100644 --- a/test/Rewriter/rewrite-block-literal-1.mm +++ b/test/Rewriter/rewrite-block-literal-1.mm @@ -1,10 +1,13 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // radar 9254348 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // rdar://11259664 +// rdar://11375908 +typedef unsigned long size_t; + void *sel_registerName(const char *); typedef void (^BLOCK_TYPE)(void); diff --git a/test/Rewriter/rewrite-block-literal.mm b/test/Rewriter/rewrite-block-literal.mm index 083312e79dd7..43f581125ba0 100644 --- a/test/Rewriter/rewrite-block-literal.mm +++ b/test/Rewriter/rewrite-block-literal.mm @@ -1,10 +1,13 @@ // RUN: %clang_cc1 -E %s -o %t.mm // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp +// rdar://11375908 +typedef unsigned long size_t; + // rdar: // 11006566 void I( void (^)(void)); diff --git a/test/Rewriter/rewrite-block-pointer.mm b/test/Rewriter/rewrite-block-pointer.mm index 58407a7ac5cf..9f3368098cad 100644 --- a/test/Rewriter/rewrite-block-pointer.mm +++ b/test/Rewriter/rewrite-block-pointer.mm @@ -1,9 +1,12 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 7638400 +// rdar://11375908 +typedef unsigned long size_t; + typedef void * id; void *sel_registerName(const char *); diff --git a/test/Rewriter/rewrite-block-property.m b/test/Rewriter/rewrite-block-property.m index 5c44b7dd1ee9..1328ab7918ec 100644 --- a/test/Rewriter/rewrite-block-property.m +++ b/test/Rewriter/rewrite-block-property.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar://9055596 diff --git a/test/Rewriter/rewrite-byref-in-nested-blocks.mm b/test/Rewriter/rewrite-byref-in-nested-blocks.mm index a65938345637..022bb5f4e357 100644 --- a/test/Rewriter/rewrite-byref-in-nested-blocks.mm +++ b/test/Rewriter/rewrite-byref-in-nested-blocks.mm @@ -1,9 +1,12 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp -// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp -// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-modern-rw.cpp // radar 7692350 +// rdar://11375908 +typedef unsigned long size_t; + void f(void (^block)(void)); @interface X { diff --git a/test/Rewriter/rewrite-byref-vars.mm b/test/Rewriter/rewrite-byref-vars.mm index 14a182a345c3..cfc51341d736 100644 --- a/test/Rewriter/rewrite-byref-vars.mm +++ b/test/Rewriter/rewrite-byref-vars.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // radar 7540194 @@ -53,5 +53,5 @@ __declspec(dllexport) extern "C" __declspec(dllexport) void XXXXBreakTheRewriter - (void) Meth { __attribute__((__blocks__(byref))) void ** listp = (void **)list; } @end -// $CLANG -cc1 -fms-extensions -rewrite-objc -fobjc-fragile-abi -x objective-c++ -fblocks bug.mm +// $CLANG -cc1 -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -x objective-c++ -fblocks bug.mm // g++ -c -D"__declspec(X)=" bug.cpp diff --git a/test/Rewriter/rewrite-cast-ivar-access.mm b/test/Rewriter/rewrite-cast-ivar-access.mm index ccc1cdec606c..4e50ff142a8c 100644 --- a/test/Rewriter/rewrite-cast-ivar-access.mm +++ b/test/Rewriter/rewrite-cast-ivar-access.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s // radar 7575882 diff --git a/test/Rewriter/rewrite-cast-to-bool.mm b/test/Rewriter/rewrite-cast-to-bool.mm index b3272b6d99b3..58db706e3ce9 100644 --- a/test/Rewriter/rewrite-cast-to-bool.mm +++ b/test/Rewriter/rewrite-cast-to-bool.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // radar 9899834 diff --git a/test/Rewriter/rewrite-category-property.mm b/test/Rewriter/rewrite-category-property.mm index b54bb67063f5..50ef4326e4e9 100644 --- a/test/Rewriter/rewrite-category-property.mm +++ b/test/Rewriter/rewrite-category-property.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s // radar 7630636 diff --git a/test/Rewriter/rewrite-constructor-init.mm b/test/Rewriter/rewrite-constructor-init.mm index f12de1f0329b..fa0e14893e0f 100644 --- a/test/Rewriter/rewrite-constructor-init.mm +++ b/test/Rewriter/rewrite-constructor-init.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar : // 8213998 diff --git a/test/Rewriter/rewrite-eh.m b/test/Rewriter/rewrite-eh.m index 46d1930cad95..6e6fb1c24cc6 100644 --- a/test/Rewriter/rewrite-eh.m +++ b/test/Rewriter/rewrite-eh.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi -fobjc-exceptions -o - %s +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -fobjc-exceptions -o - %s // rdar://7522880 @interface NSException diff --git a/test/Rewriter/rewrite-elaborated-type.mm b/test/Rewriter/rewrite-elaborated-type.mm index a0c7e43b0429..f2faa55cb5ad 100644 --- a/test/Rewriter/rewrite-elaborated-type.mm +++ b/test/Rewriter/rewrite-elaborated-type.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D_Bool=bool -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D_Bool=bool -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp diff --git a/test/Rewriter/rewrite-extern-c.mm b/test/Rewriter/rewrite-extern-c.mm index c6104938adab..cf37d7597e3a 100644 --- a/test/Rewriter/rewrite-extern-c.mm +++ b/test/Rewriter/rewrite-extern-c.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -fobjc-fragile-abi -o - %s +// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -o - %s // radar 7546096 extern "C" { diff --git a/test/Rewriter/rewrite-foreach-1.m b/test/Rewriter/rewrite-foreach-1.m index f57e13c40956..5263fffbe7dd 100644 --- a/test/Rewriter/rewrite-foreach-1.m +++ b/test/Rewriter/rewrite-foreach-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @protocol P @end diff --git a/test/Rewriter/rewrite-foreach-2.m b/test/Rewriter/rewrite-foreach-2.m index 228612aa854c..120d7d7e7985 100644 --- a/test/Rewriter/rewrite-foreach-2.m +++ b/test/Rewriter/rewrite-foreach-2.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @protocol P @end diff --git a/test/Rewriter/rewrite-foreach-3.m b/test/Rewriter/rewrite-foreach-3.m index ef3803f55234..6e67415002a3 100644 --- a/test/Rewriter/rewrite-foreach-3.m +++ b/test/Rewriter/rewrite-foreach-3.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @protocol P @end diff --git a/test/Rewriter/rewrite-foreach-4.m b/test/Rewriter/rewrite-foreach-4.m index 42cb2fb0c25e..e852c75cd2ef 100644 --- a/test/Rewriter/rewrite-foreach-4.m +++ b/test/Rewriter/rewrite-foreach-4.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @interface MyList - (id) allKeys; diff --git a/test/Rewriter/rewrite-foreach-5.m b/test/Rewriter/rewrite-foreach-5.m index 2940f453d932..1d3cc57618ec 100644 --- a/test/Rewriter/rewrite-foreach-5.m +++ b/test/Rewriter/rewrite-foreach-5.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp void *sel_registerName(const char *); diff --git a/test/Rewriter/rewrite-foreach-6.m b/test/Rewriter/rewrite-foreach-6.m index 968c6f4a47ec..5159d383e577 100644 --- a/test/Rewriter/rewrite-foreach-6.m +++ b/test/Rewriter/rewrite-foreach-6.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar://5716356 // FIXME: Should be able to pipe into clang, but code is not diff --git a/test/Rewriter/rewrite-foreach-7.m b/test/Rewriter/rewrite-foreach-7.m index 8c9293fec953..8f3a7c8819fa 100644 --- a/test/Rewriter/rewrite-foreach-7.m +++ b/test/Rewriter/rewrite-foreach-7.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @class NSArray; int main() { diff --git a/test/Rewriter/rewrite-foreach-in-block.mm b/test/Rewriter/rewrite-foreach-in-block.mm index fd34212d672e..2c1023b0c706 100644 --- a/test/Rewriter/rewrite-foreach-in-block.mm +++ b/test/Rewriter/rewrite-foreach-in-block.mm @@ -1,9 +1,11 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // rdar:// 9878420 +typedef unsigned long size_t; + void objc_enumerationMutation(id); void *sel_registerName(const char *); typedef void (^CoreDAVCompletionBlock)(void); diff --git a/test/Rewriter/rewrite-foreach-protocol-id.m b/test/Rewriter/rewrite-foreach-protocol-id.m index 034fb7a9bb08..5680110a524e 100644 --- a/test/Rewriter/rewrite-foreach-protocol-id.m +++ b/test/Rewriter/rewrite-foreach-protocol-id.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar:// 9039342 diff --git a/test/Rewriter/rewrite-forward-class.m b/test/Rewriter/rewrite-forward-class.m index 0ac620a058c1..28bab9d441e0 100644 --- a/test/Rewriter/rewrite-forward-class.m +++ b/test/Rewriter/rewrite-forward-class.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar://6969189 diff --git a/test/Rewriter/rewrite-forward-class.mm b/test/Rewriter/rewrite-forward-class.mm index 8e4eda63f88e..9f4e7e21e862 100644 --- a/test/Rewriter/rewrite-forward-class.mm +++ b/test/Rewriter/rewrite-forward-class.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp extern "C" { diff --git a/test/Rewriter/rewrite-function-decl.mm b/test/Rewriter/rewrite-function-decl.mm index 883d3931d638..af85f687bf5a 100644 --- a/test/Rewriter/rewrite-function-decl.mm +++ b/test/Rewriter/rewrite-function-decl.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fms-extensions -rewrite-objc -fobjc-fragile-abi -x objective-c++ -fblocks -o - %s +// RUN: %clang_cc1 -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -x objective-c++ -fblocks -o - %s extern "C" __declspec(dllexport) void BreakTheRewriter(void) { __block int aBlockVariable = 0; diff --git a/test/Rewriter/rewrite-implementation.mm b/test/Rewriter/rewrite-implementation.mm index 2cc3387b32bb..8ef4ebe97aff 100644 --- a/test/Rewriter/rewrite-implementation.mm +++ b/test/Rewriter/rewrite-implementation.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // radar 7649577 diff --git a/test/Rewriter/rewrite-ivar-use.m b/test/Rewriter/rewrite-ivar-use.m index 53b07c434f37..17bbf01af133 100644 --- a/test/Rewriter/rewrite-ivar-use.m +++ b/test/Rewriter/rewrite-ivar-use.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // radar 7490331 diff --git a/test/Rewriter/rewrite-local-externs-in-block.mm b/test/Rewriter/rewrite-local-externs-in-block.mm index 35d282bd5193..b31b422ab758 100644 --- a/test/Rewriter/rewrite-local-externs-in-block.mm +++ b/test/Rewriter/rewrite-local-externs-in-block.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // radar 7735987 diff --git a/test/Rewriter/rewrite-local-static-id.mm b/test/Rewriter/rewrite-local-static-id.mm index b002b6eefd24..b3d2c4833ed1 100644 --- a/test/Rewriter/rewrite-local-static-id.mm +++ b/test/Rewriter/rewrite-local-static-id.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" -emit-llvm -o %t %t-rw.cpp // radar 7946975 diff --git a/test/Rewriter/rewrite-message-expr.mm b/test/Rewriter/rewrite-message-expr.mm index dafb31b2b543..72569cb8376f 100644 --- a/test/Rewriter/rewrite-message-expr.mm +++ b/test/Rewriter/rewrite-message-expr.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s // radar 7617047 diff --git a/test/Rewriter/rewrite-modern-atautoreleasepool.mm b/test/Rewriter/rewrite-modern-atautoreleasepool.mm new file mode 100644 index 000000000000..57c08abb78e7 --- /dev/null +++ b/test/Rewriter/rewrite-modern-atautoreleasepool.mm @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -E %s -o %t.mm +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o %t-rw.cpp +// RUN: FileCheck --input-file=%t-rw.cpp %s +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// radar 11474836 + +extern "C" +void *sel_registerName(const char *); + +@interface I +{ + id ivar; +} +- (id) Meth; ++ (id) MyAlloc;; +@end + +@implementation I +- (id) Meth { + @autoreleasepool { + id p = [I MyAlloc]; + if (!p) + return ivar; + } + return 0; +} ++ (id) MyAlloc { + return 0; +} +@end + +// CHECK: /* @autoreleasepool */ { __AtAutoreleasePool __autoreleasepool; diff --git a/test/Rewriter/rewrite-modern-block-consts.mm b/test/Rewriter/rewrite-modern-block-consts.mm new file mode 100644 index 000000000000..48c8d4023d31 --- /dev/null +++ b/test/Rewriter/rewrite-modern-block-consts.mm @@ -0,0 +1,22 @@ +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -U__declspec -D"__declspec(X)=" %t-modern-rw.cpp +// rdar:// 8243071 + +// rdar://11375908 +typedef unsigned long size_t; + +void x(int y) {} +void f() { + const int bar = 3; + int baz = 4; + __block int bab = 4; + __block const int bas = 5; + void (^b)() = ^{ + x(bar); + x(baz); + x(bab); + x(bas); + b(); + }; + b(); +} diff --git a/test/Rewriter/rewrite-modern-block.mm b/test/Rewriter/rewrite-modern-block.mm index 8da723d319ff..23029654c984 100644 --- a/test/Rewriter/rewrite-modern-block.mm +++ b/test/Rewriter/rewrite-modern-block.mm @@ -1,7 +1,8 @@ // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp -// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp // rdar://11230308 +typedef unsigned long size_t; typedef struct { char byte0; char byte1; @@ -20,4 +21,45 @@ void y() { // rdar://11236342 int foo() { __block int hello; + return hello; } + +// rdar://7547630 +// rewriting multiple __block decls on wintin same decl stmt. +void radar7547630() { + __block int BI1, BI2; + + __block float FLOAT1, FT2, FFFFFFFF3, + FFFXXX4; + + __block void (^B)(), (^BB)(); +} + +// rewriting multiple __block decls on wintin same decl stmt +// with initializers. +int rdar7547630(const char *keybuf, const char *valuebuf) { + __block int BI1 = 1, BI2 = 2; + + double __block BYREFVAR = 1.34, BYREFVAR_NO_INIT, BYREFVAR2 = 1.37; + + __block const char *keys = keybuf, *values = valuebuf, *novalues; + + return BI2; +} + +// rdar://11326988 +typedef struct _z { + int location; + int length; +} z; + +z w(int loc, int len); + +@interface rdar11326988 +@end +@implementation rdar11326988 +- (void)y:(int)options { + __attribute__((__blocks__(byref))) z firstRange = w(1, 0); + options &= ~(1 | 2); +} +@end diff --git a/test/Rewriter/rewrite-modern-captured-nested-bvar.mm b/test/Rewriter/rewrite-modern-captured-nested-bvar.mm new file mode 100644 index 000000000000..a8fd18073372 --- /dev/null +++ b/test/Rewriter/rewrite-modern-captured-nested-bvar.mm @@ -0,0 +1,35 @@ +// RUN: %clang_cc1 -E %s -o %t.mm +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %t.mm -o - | FileCheck %s +// rdar://9006279 + +void q(void (^p)(void)) { + p(); +} + +void f() { + __block char BYREF_VAR_CHECK = 'a'; + __block char d = 'd'; + q(^{ + q(^{ + __block char e = 'e'; + char l = 'l'; + BYREF_VAR_CHECK = 'b'; + d = 'd'; + q(^{ + e = '1'; + BYREF_VAR_CHECK = '2'; + d = '3'; + } + ); + }); + }); +} + +int main() { + f(); + return 0; +} + +// CHECK 2: (__Block_byref_BYREF_VAR_CHECK_0 *)BYREF_VAR_CHECK +// CHECK: {(void*)0,(__Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, 0, sizeof(__Block_byref_BYREF_VAR_CHECK_0), 'a'} +// CHECK: __Block_byref_BYREF_VAR_CHECK_0 *)&BYREF_VAR_CHECK, (__Block_byref_d_1 *)&d, 570425344)); diff --git a/test/Rewriter/rewrite-modern-default-property-synthesis.mm b/test/Rewriter/rewrite-modern-default-property-synthesis.mm new file mode 100644 index 000000000000..fd1a578f083f --- /dev/null +++ b/test/Rewriter/rewrite-modern-default-property-synthesis.mm @@ -0,0 +1,80 @@ +// RUN: %clang_cc1 -E %s -o %t.mm +// RUN: %clang_cc1 -x objective-c++ -fms-extensions -fobjc-default-synthesize-properties -rewrite-objc %t.mm -o %t-rw.cpp +// RUN: FileCheck --input-file=%t-rw.cpp %s +// RUN: %clang_cc1 -fsyntax-only -Werror -DSEL="void *" -Did="struct objc_object *" -Wno-attributes -Wno-address-of-temporary -U__declspec -D"__declspec(X)=" %t-rw.cpp +// rdar://11374235 + +extern "C" void *sel_registerName(const char *); + +@interface NSObject +- (void) release; +- (id) retain; +@end +@class NSString; + +@interface SynthItAll : NSObject +@property int howMany; +@property (retain) NSString* what; +@end + +@implementation SynthItAll +@end + + +@interface SynthSetter : NSObject +@property (nonatomic) int howMany; +@property (nonatomic, retain) NSString* what; +@end + +@implementation SynthSetter + +- (int) howMany { + return _howMany; +} +// - (void) setHowMany: (int) value + +- (NSString*) what { + return _what; +} +// - (void) setWhat: (NSString*) value +@end + + +@interface SynthGetter : NSObject +@property (nonatomic) int howMany; +@property (nonatomic, retain) NSString* what; +@end + +@implementation SynthGetter +// - (int) howMany +- (void) setHowMany: (int) value { + _howMany = value; +} + +// - (NSString*) what +- (void) setWhat: (NSString*) value { + if (_what != value) { + [_what release]; + _what = [value retain]; + } +} +@end + +typedef struct { + int x:1; + int y:1; +} TBAR; + +@interface NONAME +{ + TBAR _bar; +} +@property TBAR bad; +@end + +@implementation NONAME +@end + +// CHECK: (*(int *)((char *)self + OBJC_IVAR_$_SynthItAll$_howMany)) = howMany; +// CHECK: return (*(int *)((char *)self + OBJC_IVAR_$_SynthGetter$_howMany)); +// CHECK: (*(TBAR *)((char *)self + OBJC_IVAR_$_NONAME$_bad)) = bad; diff --git a/test/Rewriter/rewrite-modern-extern-c-func-decl.mm b/test/Rewriter/rewrite-modern-extern-c-func-decl.mm index 82d5a4d9c34e..c3bfec9e228c 100644 --- a/test/Rewriter/rewrite-modern-extern-c-func-decl.mm +++ b/test/Rewriter/rewrite-modern-extern-c-func-decl.mm @@ -2,6 +2,7 @@ // RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp // rdar://11131490 +typedef unsigned long size_t; extern "C" __declspec(dllexport) void BreakTheRewriter(void) { __block int aBlockVariable = 0; void (^aBlock)(void) = ^ { @@ -43,3 +44,51 @@ main (int argc, char *argv[]) bBlockVariable = 42; }; } + +// rdar://11275241 +static char stringtype; +char CFStringGetTypeID(); +void x(void (^)()); + +static void initStatics(int arg, ...) { + x(^{ + stringtype = CFStringGetTypeID(); + }); +} +static void initStatics1(...) { + x(^{ + stringtype = CFStringGetTypeID(); + }); +} +static void initStatics2() { + x(^{ + stringtype = CFStringGetTypeID(); + }); +} + +// rdar://11314329 +static inline const void *auto_zone_base_pointer(void *zone, const void *ptr) { return 0; } + +@interface I +{ + id list; +} +- (void) Meth; +// radar 7589385 use before definition +- (void) allObjects; +@end + +@implementation I +// radar 7589385 use before definition +- (void) allObjects { + __attribute__((__blocks__(byref))) id *listp; + + void (^B)(void) = ^(void) { + *listp++ = 0; + }; + + B(); +} +- (void) Meth { __attribute__((__blocks__(byref))) void ** listp = (void **)list; } +@end + diff --git a/test/Rewriter/rewrite-modern-ivar-access.mm b/test/Rewriter/rewrite-modern-ivar-access.mm new file mode 100644 index 000000000000..4bde1a401312 --- /dev/null +++ b/test/Rewriter/rewrite-modern-ivar-access.mm @@ -0,0 +1,98 @@ +// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %s -o %t-rw.cpp +// RUN: %clang_cc1 -Werror -fsyntax-only -Wno-address-of-temporary -Wno-c++11-narrowing -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp + +struct OUTSIDE { + int i_OUTSIDE; + double d_OUTSIDE; +}; + + +@interface I1 { +@protected + struct OUTSIDE ivar_I1; + + struct INNER_I1 { + int i_INNER_I1; + double d_INNER_I1; + }; + + struct INNER_I1 ivar_I2; + + struct OUTSIDE ivar_I3; + + struct { + int i_noname; + double d_noname; + } NONAME_I4; + + struct { + int i_noname; + double d_noname; + } NONAME_I5; +} +@end + +@implementation I1 +- (void) I1_Meth { + ivar_I1.i_OUTSIDE = 0; + + ivar_I2.i_INNER_I1 = 1; + + ivar_I3.i_OUTSIDE = 2; + + NONAME_I4.i_noname = 3; + + NONAME_I5.i_noname = 4; +} +@end + +@interface INTF2 { +@protected + struct OUTSIDE ivar_INTF2; + + struct { + int i_noname; + double d_noname; + } NONAME_INTF4; + + + struct OUTSIDE ivar_INTF3; + + struct INNER_I1 ivar_INTF4; + + struct { + int i_noname; + double d_noname; + } NONAME_INTF5; + + struct INNER_INTF2 { + int i_INNER_INTF2; + double d_INNER_INTF2; + }; + + struct INNER_INTF2 ivar_INTF6, ivar_INTF7; + + struct INNER_INTF3 { + int i; + } X1,X2,X3; + +} +@end + +@implementation INTF2 +- (void) I2_Meth { + ivar_INTF2.i_OUTSIDE = 0; + + ivar_INTF4.i_INNER_I1 = 1; + + ivar_INTF3.i_OUTSIDE = 2; + + NONAME_INTF4.i_noname = 3; + + NONAME_INTF5.i_noname = 4; + ivar_INTF6.i_INNER_INTF2 = 5; + ivar_INTF7.i_INNER_INTF2 = 5; + X1.i = X2.i = X3.i = 1; +} +@end + diff --git a/test/Rewriter/rewrite-modern-ivars-1.mm b/test/Rewriter/rewrite-modern-ivars-1.mm index 376d300c7e9d..dbd28d121ee0 100644 --- a/test/Rewriter/rewrite-modern-ivars-1.mm +++ b/test/Rewriter/rewrite-modern-ivars-1.mm @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw.cpp -// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp @interface NSCheapMutableString { @private @@ -87,3 +87,38 @@ } @end +enum OUTSIDE { + yes +}; + +@interface MoreEnumTests { +@private + enum INSIDE { + no + } others; + + enum OUTSIDE meetoo; + + enum { + one, + two + } eu; +} +@end + +@interface I { + enum INSIDE I1; + enum OUTSIDE I2; + enum ALSO_INSIDE { + maybe + } I3; + + enum ALSO_INSIDE I4; + + enum { + three, + four + } I5; +} +@end + diff --git a/test/Rewriter/rewrite-modern-private-ivars.mm b/test/Rewriter/rewrite-modern-private-ivars.mm new file mode 100644 index 000000000000..fc2e73bb26e6 --- /dev/null +++ b/test/Rewriter/rewrite-modern-private-ivars.mm @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %s -o %t-rw.cpp +// RUN: %clang_cc1 -Werror -fsyntax-only -Wno-address-of-temporary -Wno-c++11-narrowing -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp +// rdar://11351299 + +struct Q { + int x; +}; + +@interface I +@end + +@interface I() { + + struct { + int x; + } unnamed; + + struct S { + int x; + } foo; + + double dd; + + struct S foo1; +} +@end + +@implementation I +{ + struct P { + int x; + } bar; + + double ee; + + struct Q bar1; + + struct { + int x; + } noname; +} + +- (void) Meth { + foo.x = 1; + bar.x = 2; + dd = 1.23; + ee = 0.0; + foo1.x = 3; + bar1.x = 4; + noname.x = 3; + unnamed.x = 10; +} +@end diff --git a/test/Rewriter/rewrite-modern-struct-ivar-1.mm b/test/Rewriter/rewrite-modern-struct-ivar-1.mm new file mode 100644 index 000000000000..a17fe3f85675 --- /dev/null +++ b/test/Rewriter/rewrite-modern-struct-ivar-1.mm @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %s -o %t-rw.cpp +// RUN: %clang_cc1 -Werror -fsyntax-only -Wno-address-of-temporary -Wno-c++11-narrowing -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp +// rdar://11323187 + +typedef unsigned long NSUInteger; + +typedef struct _NSRange { + NSUInteger location; + NSUInteger length; +} NSRange; + +typedef struct { + NSUInteger _capacity; + NSRange _ranges[0]; +} _NSRangeInfo; + +@interface Foo{ + @protected + struct _bar { + int x:1; + int y:1; + } bar; + union { + struct { + NSRange _range; + } _singleRange; + struct { + void * _data; + void *_reserved; + } _multipleRanges; + } _internal; +} +@end +@implementation Foo +- (void)x:(Foo *)other { + bar.x = 0; + bar.y = 1; + self->_internal._singleRange._range = (( other ->bar.x) ? &( other ->_internal._singleRange._range) : ((NSRange *)(&(((_NSRangeInfo *)( other ->_internal._multipleRanges._data))->_ranges))))[0]; +} +@end +@interface FooS : Foo +@end +@implementation FooS +- (void)y { + + NSUInteger asdf = (( self ->bar.x) ? 1 : ((_NSRangeInfo *)( self ->_internal._multipleRanges._data))->_capacity ); +} +@end diff --git a/test/Rewriter/rewrite-modern-struct-ivar.mm b/test/Rewriter/rewrite-modern-struct-ivar.mm index 09c02dffab19..9f56cd8b1b83 100644 --- a/test/Rewriter/rewrite-modern-struct-ivar.mm +++ b/test/Rewriter/rewrite-modern-struct-ivar.mm @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -E %s -o %t.mm // RUN: %clang_cc1 -fblocks -rewrite-objc -fms-extensions %t.mm -o %t-rw.cpp // RUN: FileCheck --input-file=%t-rw.cpp %s -// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -Wno-c++11-narrowing -std=c++11 -D"Class=void*" -D"id=void*" -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp struct S { int i1; @@ -20,5 +20,33 @@ struct S { @implementation I - (struct S) dMeth{ return struct_ivar; } @end - + // CHECK: return (*(struct S *)((char *)self + OBJC_IVAR_$_I$struct_ivar)); + +// rdar://11323187 +@interface Foo{ + @protected + struct { + int x:1; + int y:1; + } bar; + + struct _S { + int x:1; + int y:1; + } s; + +} +@end +@implementation Foo +- (void)x { + bar.x = 0; + bar.y = 1; + + s.x = 0; + s.y = 1; +} +@end + +// CHECK: (*(decltype(((Foo_IMPL *)0U)->bar) *)((char *)self + OBJC_IVAR_$_Foo$bar)).x = 0; +// CHECK: (*(struct _S *)((char *)self + OBJC_IVAR_$_Foo$s)).x = 0; diff --git a/test/Rewriter/rewrite-modern-typeof.mm b/test/Rewriter/rewrite-modern-typeof.mm index 4650ab7b7f30..a493c1184967 100644 --- a/test/Rewriter/rewrite-modern-typeof.mm +++ b/test/Rewriter/rewrite-modern-typeof.mm @@ -2,6 +2,7 @@ // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -Wno-attributes -D"Class=void*" -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +typedef unsigned long size_t; extern "C" { extern "C" void *_Block_copy(const void *aBlock); extern "C" void _Block_release(const void *aBlock); diff --git a/test/Rewriter/rewrite-nest.m b/test/Rewriter/rewrite-nest.m index a08f9475d5d6..41bb875c680a 100644 --- a/test/Rewriter/rewrite-nest.m +++ b/test/Rewriter/rewrite-nest.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @interface NSMapTable @end @interface NSEnumerator @end diff --git a/test/Rewriter/rewrite-nested-blocks-1.mm b/test/Rewriter/rewrite-nested-blocks-1.mm index 25b17cfce179..8981777b8e95 100644 --- a/test/Rewriter/rewrite-nested-blocks-1.mm +++ b/test/Rewriter/rewrite-nested-blocks-1.mm @@ -1,9 +1,10 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 7696893 +typedef unsigned long size_t; void *sel_registerName(const char *); void f(void (^block)(void)); diff --git a/test/Rewriter/rewrite-nested-blocks-2.mm b/test/Rewriter/rewrite-nested-blocks-2.mm index d1513f3a5fa0..46afdf16889c 100644 --- a/test/Rewriter/rewrite-nested-blocks-2.mm +++ b/test/Rewriter/rewrite-nested-blocks-2.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // grep "static void __FUNC_block_copy_" %t-rw.cpp | count 2 // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp @@ -6,6 +6,7 @@ // grep "static void __FUNC_block_copy_" %t-modern-rw.cpp | count 2 // rdar://8499592 +typedef unsigned long size_t; void Outer(void (^bk)()); void Inner(void (^bk)()); void INNER_FUNC(id d); diff --git a/test/Rewriter/rewrite-nested-blocks.mm b/test/Rewriter/rewrite-nested-blocks.mm index d492afa18d49..16a9b31415a8 100644 --- a/test/Rewriter/rewrite-nested-blocks.mm +++ b/test/Rewriter/rewrite-nested-blocks.mm @@ -1,10 +1,11 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 7682149 +typedef unsigned long size_t; void f(void (^block)(void)); @interface X { diff --git a/test/Rewriter/rewrite-nested-ivar.mm b/test/Rewriter/rewrite-nested-ivar.mm index bab221d33f35..07fc2f51b404 100644 --- a/test/Rewriter/rewrite-nested-ivar.mm +++ b/test/Rewriter/rewrite-nested-ivar.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw-modern.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw-modern.cpp diff --git a/test/Rewriter/rewrite-nested-property-in-blocks.mm b/test/Rewriter/rewrite-nested-property-in-blocks.mm index 7f9361ed0788..d029559b64f8 100755 --- a/test/Rewriter/rewrite-nested-property-in-blocks.mm +++ b/test/Rewriter/rewrite-nested-property-in-blocks.mm @@ -1,9 +1,10 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fms-extensions -Wno-address-of-temporary -Did="void *" -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 8608293 +typedef unsigned long size_t; void *sel_registerName(const char *); extern "C" void nowarn(id); diff --git a/test/Rewriter/rewrite-no-nextline.mm b/test/Rewriter/rewrite-no-nextline.mm index 4ef37157f748..51f412f3e7ca 100644 --- a/test/Rewriter/rewrite-no-nextline.mm +++ b/test/Rewriter/rewrite-no-nextline.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // radar 7946975 diff --git a/test/Rewriter/rewrite-property-attributes.mm b/test/Rewriter/rewrite-property-attributes.mm index c70760353f8c..4a8b1972779c 100644 --- a/test/Rewriter/rewrite-property-attributes.mm +++ b/test/Rewriter/rewrite-property-attributes.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // radar 7214439 diff --git a/test/Rewriter/rewrite-property-set-cfstring.mm b/test/Rewriter/rewrite-property-set-cfstring.mm index 3ac90656ba04..9de76428ada6 100644 --- a/test/Rewriter/rewrite-property-set-cfstring.mm +++ b/test/Rewriter/rewrite-property-set-cfstring.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar:// 8527018 diff --git a/test/Rewriter/rewrite-protocol-property.mm b/test/Rewriter/rewrite-protocol-property.mm index 3a53f2377fc4..c3f154c8526a 100644 --- a/test/Rewriter/rewrite-protocol-property.mm +++ b/test/Rewriter/rewrite-protocol-property.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -Did="void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar:// 8558702 diff --git a/test/Rewriter/rewrite-protocol-qualified.mm b/test/Rewriter/rewrite-protocol-qualified.mm index f828724a1568..7a7eed737311 100644 --- a/test/Rewriter/rewrite-protocol-qualified.mm +++ b/test/Rewriter/rewrite-protocol-qualified.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"id=void*" -D"__declspec(X)=" %t-rw.cpp // radar 7589414 diff --git a/test/Rewriter/rewrite-protocol-type-1.m b/test/Rewriter/rewrite-protocol-type-1.m index 5246df45ffc6..2ecae8b584a7 100644 --- a/test/Rewriter/rewrite-protocol-type-1.m +++ b/test/Rewriter/rewrite-protocol-type-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @protocol MyProto1 @end diff --git a/test/Rewriter/rewrite-qualified-id.mm b/test/Rewriter/rewrite-qualified-id.mm index f54bae9c3718..428b65563cc3 100644 --- a/test/Rewriter/rewrite-qualified-id.mm +++ b/test/Rewriter/rewrite-qualified-id.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // radar 7680953 diff --git a/test/Rewriter/rewrite-rewritten-initializer.mm b/test/Rewriter/rewrite-rewritten-initializer.mm index 14734f9af2c3..25d16253607d 100644 --- a/test/Rewriter/rewrite-rewritten-initializer.mm +++ b/test/Rewriter/rewrite-rewritten-initializer.mm @@ -1,7 +1,10 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp -// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp +// RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc %s -o %t-rw-modern.cpp +// RUN: %clang_cc1 -fsyntax-only -Werror -Wno-address-of-temporary -D"SEL=void*" -U__declspec -D"__declspec(X)=" %t-rw-modern.cpp // radar 7669784 +typedef unsigned long size_t; typedef void * id; void *sel_registerName(const char *); diff --git a/test/Rewriter/rewrite-static-block.mm b/test/Rewriter/rewrite-static-block.mm index 4ee227ea91d2..ed720e034a28 100644 --- a/test/Rewriter/rewrite-static-block.mm +++ b/test/Rewriter/rewrite-static-block.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp -emit-llvm -o %t-rw.ll // RUN: FileCheck --input-file=%t-rw.ll %s diff --git a/test/Rewriter/rewrite-super-message.mm b/test/Rewriter/rewrite-super-message.mm index d770b33750e5..45d7e1301f21 100644 --- a/test/Rewriter/rewrite-super-message.mm +++ b/test/Rewriter/rewrite-super-message.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -DKEEP_ATTRIBUTES -D"id=struct objc_object *" -D"Class=struct objc_class *" -D"SEL=void*" -D"__declspec(X)=" -emit-llvm -o - %t-rw.cpp | FileCheck %t-rw.cpp // radar 7738453 diff --git a/test/Rewriter/rewrite-trivial-constructor.mm b/test/Rewriter/rewrite-trivial-constructor.mm index f14f4b15b3bf..e343a383102a 100644 --- a/test/Rewriter/rewrite-trivial-constructor.mm +++ b/test/Rewriter/rewrite-trivial-constructor.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fms-extensions -rewrite-objc -fobjc-fragile-abi -x objective-c++ -fblocks -o - %s +// RUN: %clang_cc1 -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -x objective-c++ -fblocks -o - %s // radar 7537770 typedef struct { diff --git a/test/Rewriter/rewrite-try-catch.m b/test/Rewriter/rewrite-try-catch.m index b4d13b6ac2fe..8720d0c9b91b 100644 --- a/test/Rewriter/rewrite-try-catch.m +++ b/test/Rewriter/rewrite-try-catch.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @interface Foo @end @interface GARF @end diff --git a/test/Rewriter/rewrite-typeof.mm b/test/Rewriter/rewrite-typeof.mm index 24e3bcc55bce..02c36f88a569 100644 --- a/test/Rewriter/rewrite-typeof.mm +++ b/test/Rewriter/rewrite-typeof.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: FileCheck -check-prefix LP --input-file=%t-rw.cpp %s extern "C" { diff --git a/test/Rewriter/rewrite-unique-block-api.mm b/test/Rewriter/rewrite-unique-block-api.mm index 1dcc1b67fe7b..85ead11d2fab 100644 --- a/test/Rewriter/rewrite-unique-block-api.mm +++ b/test/Rewriter/rewrite-unique-block-api.mm @@ -1,9 +1,10 @@ -// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc %s -o %t-modern-rw.cpp // RUN: %clang_cc1 -fsyntax-only -Wno-address-of-temporary -D"SEL=void*" -D"__declspec(X)=" %t-modern-rw.cpp // radar 7630551 +typedef unsigned long size_t; void f(void (^b)(char c)); @interface a diff --git a/test/Rewriter/rewrite-user-defined-accessors.mm b/test/Rewriter/rewrite-user-defined-accessors.mm index 3c38e178d619..24d7b05d7aa5 100644 --- a/test/Rewriter/rewrite-user-defined-accessors.mm +++ b/test/Rewriter/rewrite-user-defined-accessors.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -Did="void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar:// 8570020 diff --git a/test/Rewriter/rewrite-vararg.m b/test/Rewriter/rewrite-vararg.m index bd58a6acf3c3..ff7b250f809f 100644 --- a/test/Rewriter/rewrite-vararg.m +++ b/test/Rewriter/rewrite-vararg.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-fragile-abi %s -o %t-rw.cpp +// RUN: %clang_cc1 -x objective-c++ -Wno-return-type -fblocks -fms-extensions -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o %t-rw.cpp // RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-address-of-temporary -D"id=void*" -D"SEL=void*" -D"__declspec(X)=" %t-rw.cpp // rdar://9056351 diff --git a/test/Rewriter/rewrite-weak-attr.m b/test/Rewriter/rewrite-weak-attr.m index 60c6fc881a83..f8eb3b727e0f 100644 --- a/test/Rewriter/rewrite-weak-attr.m +++ b/test/Rewriter/rewrite-weak-attr.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -fblocks -Dnil=0 -rewrite-objc -fobjc-fragile-abi -o - %s +// RUN: %clang_cc1 -triple i686-pc-win32 -fms-extensions -fblocks -Dnil=0 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 -o - %s int main() { __weak __block id foo = nil; __block id foo2 = nil; diff --git a/test/Rewriter/static-type-protocol-1.m b/test/Rewriter/static-type-protocol-1.m index bafe2860d1c0..dbf9d38670fc 100644 --- a/test/Rewriter/static-type-protocol-1.m +++ b/test/Rewriter/static-type-protocol-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @protocol Proto - (void) ProtoDidget; diff --git a/test/Rewriter/undecl-objc-h.m b/test/Rewriter/undecl-objc-h.m index 5c3e6930da06..2581aa598a89 100644 --- a/test/Rewriter/undecl-objc-h.m +++ b/test/Rewriter/undecl-objc-h.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - typedef struct S { int * pint; diff --git a/test/Rewriter/undeclared-method-1.m b/test/Rewriter/undeclared-method-1.m index 9b4ca1920ba0..a52c677bc721 100644 --- a/test/Rewriter/undeclared-method-1.m +++ b/test/Rewriter/undeclared-method-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @interface Derived @end diff --git a/test/Rewriter/undef-field-reference-1.m b/test/Rewriter/undef-field-reference-1.m index 9c067a80a4e9..07bd21b756c9 100644 --- a/test/Rewriter/undef-field-reference-1.m +++ b/test/Rewriter/undef-field-reference-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - @interface MyDerived { diff --git a/test/Rewriter/va-method.m b/test/Rewriter/va-method.m index c232d2359413..78d9367819b5 100644 --- a/test/Rewriter/va-method.m +++ b/test/Rewriter/va-method.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - #include <stdarg.h> diff --git a/test/Rewriter/weak_byref_objects.m b/test/Rewriter/weak_byref_objects.m index 1b9efbe573b4..09d30ed268b0 100644 --- a/test/Rewriter/weak_byref_objects.m +++ b/test/Rewriter/weak_byref_objects.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fblocks -triple i386-apple-darwin9 -fobjc-gc -rewrite-objc -fobjc-fragile-abi %s -o - +// RUN: %clang_cc1 -fblocks -triple i386-apple-darwin9 -fobjc-gc -rewrite-objc -fobjc-runtime=macosx-fragile-10.5 %s -o - #define nil 0 int main() { diff --git a/test/Sema/128bitint.c b/test/Sema/128bitint.c index 89d3ee201283..ddad83554753 100644 --- a/test/Sema/128bitint.c +++ b/test/Sema/128bitint.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 %s +// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-apple-darwin9 -fms-extensions %s typedef int i128 __attribute__((__mode__(TI))); typedef unsigned u128 __attribute__((__mode__(TI))); @@ -11,3 +11,10 @@ __uint128_t b = (__uint128_t)-1; // PR11916: Support for libstdc++ 4.7 __int128 i = (__int128)0; unsigned __int128 u = (unsigned __int128)-1; + +long long SignedTooBig = 123456789012345678901234567890; // expected-warning {{integer constant is too large for its type}} +__int128_t Signed128 = 123456789012345678901234567890i128; +long long Signed64 = 123456789012345678901234567890i128; // expected-warning {{implicit conversion from '__int128' to 'long long' changes value from 123456789012345678901234567890 to -4362896299872285998}} +unsigned long long UnsignedTooBig = 123456789012345678901234567890; // expected-warning {{integer constant is too large for its type}} +__uint128_t Unsigned128 = 123456789012345678901234567890Ui128; +unsigned long long Unsigned64 = 123456789012345678901234567890Ui128; // expected-warning {{implicit conversion from 'unsigned __int128' to 'unsigned long long' changes value from 123456789012345678901234567890 to 14083847773837265618}} diff --git a/test/Sema/Inputs/format-unused-system-args.h b/test/Sema/Inputs/format-unused-system-args.h new file mode 100644 index 000000000000..3a6b1654fbd6 --- /dev/null +++ b/test/Sema/Inputs/format-unused-system-args.h @@ -0,0 +1,8 @@ +// "System header" for testing that -Wformat-extra-args does not apply to +// arguments specified in system headers. + +#define PRINT2(fmt, a1, a2) \ + printf((fmt), (a1), (a2)) + +#define PRINT1(fmt, a1) \ + PRINT2((fmt), (a1), 0) diff --git a/test/Sema/MicrosoftCompatibility.c b/test/Sema/MicrosoftCompatibility.c index f148e869ff05..6b137a60c4f0 100644 --- a/test/Sema/MicrosoftCompatibility.c +++ b/test/Sema/MicrosoftCompatibility.c @@ -1,6 +1,6 @@ // RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-compatibility -enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}} +enum ENUM1; // expected-warning {{forward references to 'enum' types are a Microsoft extension}} enum ENUM1 var1 = 3; enum ENUM1* var2 = 0; @@ -14,3 +14,8 @@ enum ENUM2 { __declspec(noreturn) void f6( void ) { return; // expected-warning {{function 'f6' declared 'noreturn' should not return}} } + +__declspec(align(32768)) struct S1 { int a; } s; /* expected-error {{requested alignment must be 8192 bytes or smaller}} */ +struct __declspec(aligned) S2 {}; /* expected-warning {{unknown __declspec attribute 'aligned' ignored}} */ + +struct __declspec(appdomain) S3 {}; /* expected-warning {{__declspec attribute 'appdomain' is not supported}} */
\ No newline at end of file diff --git a/test/Sema/MicrosoftExtensions.c b/test/Sema/MicrosoftExtensions.c index fb0c6bde9a50..5d7330e3f700 100644 --- a/test/Sema/MicrosoftExtensions.c +++ b/test/Sema/MicrosoftExtensions.c @@ -87,11 +87,13 @@ typedef struct { AA; // expected-warning {{anonymous structs are a Microsoft extension}} } BB; -__declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1; -struct __declspec(deprecated) DS1 { int i; float f; }; +__declspec(deprecated("This is deprecated")) enum DE1 { one, two } e1; // expected-note {{'e1' declared here}} +struct __declspec(deprecated) DS1 { int i; float f; }; // expected-note {{declared here}} #define MY_TEXT "This is also deprecated" -__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} +__declspec(deprecated(MY_TEXT)) void Dfunc1( void ) {} // expected-note {{'Dfunc1' declared here}} + +struct __declspec(deprecated(123)) DS2 {}; // expected-error {{argument to deprecated attribute was not a string literal}} void test( void ) { e1 = one; // expected-warning {{'e1' is deprecated: This is deprecated}} diff --git a/test/Sema/alignas.c b/test/Sema/alignas.c index 5832393e3b61..d9a0164010f9 100644 --- a/test/Sema/alignas.c +++ b/test/Sema/alignas.c @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -std=c1x %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -Dalignof=__alignof %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c11 -Dalignof=_Alignof %s _Alignas(3) int align_illegal; //expected-error {{requested alignment is not a power of 2}} _Alignas(int) char align_big; @@ -11,9 +12,9 @@ struct align_member { typedef _Alignas(8) char align_typedef; // FIXME: this should be rejected -_Static_assert(__alignof(align_big) == __alignof(int), "k's alignment is wrong"); -_Static_assert(__alignof(align_small) == 1, "j's alignment is wrong"); -_Static_assert(__alignof(align_multiple) == 8, "l's alignment is wrong"); -_Static_assert(__alignof(struct align_member) == 8, "quuux's alignment is wrong"); +_Static_assert(alignof(align_big) == alignof(int), "k's alignment is wrong"); +_Static_assert(alignof(align_small) == 1, "j's alignment is wrong"); +_Static_assert(alignof(align_multiple) == 8, "l's alignment is wrong"); +_Static_assert(alignof(struct align_member) == 8, "quuux's alignment is wrong"); _Static_assert(sizeof(struct align_member) == 8, "quuux's size is wrong"); -_Static_assert(__alignof(align_typedef) == 8, "typedef's alignment is wrong"); +_Static_assert(alignof(align_typedef) == 8, "typedef's alignment is wrong"); diff --git a/test/Sema/alloc_size.c b/test/Sema/alloc_size.c new file mode 100644 index 000000000000..e2f52987d1db --- /dev/null +++ b/test/Sema/alloc_size.c @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +void* my_malloc(unsigned char) __attribute__((alloc_size(1))); +void* my_calloc(unsigned char, short) __attribute__((alloc_size(1,2))); +void* my_realloc(void*, unsigned) __attribute__((alloc_size(2))); + + +void* fn1(int) __attribute__((alloc_size("xpto"))); // expected-error{{attribute requires integer constant}} + +void* fn2(void*) __attribute__((alloc_size(1))); // expected-error{{attribute requires integer constant}} + +void* fn3(unsigned) __attribute__((alloc_size(0))); // expected-error{{attribute parameter 1 is out of bounds}} +void* fn4(unsigned) __attribute__((alloc_size(2))); // expected-error{{attribute parameter 1 is out of bounds}} + +void fn5(unsigned) __attribute__((alloc_size(1))); // expected-warning{{only applies to functions that return a pointer}} +char fn6(unsigned) __attribute__((alloc_size(1))); // expected-warning{{only applies to functions that return a pointer}} + +void* fn7(unsigned) __attribute__((alloc_size)); // expected-error {{attribute takes at least 1 argument}} + +void *fn8(int, int) __attribute__((alloc_size(1, 1))); // OK + +void* fn9(unsigned) __attribute__((alloc_size(12345678901234567890123))); // expected-warning {{integer constant is too large for its type}} // expected-error {{attribute parameter 1 is out of bounds}} + +void* fn10(size_t, size_t) __attribute__((alloc_size(1,2))); // expected-error{{redefinition of parameter}} \ + // expected-error{{a parameter list without types is only allowed in a function definition}} \ + // expected-warning{{alloc_size attribute only applies to functions and methods}} diff --git a/test/Sema/annotate.c b/test/Sema/annotate.c index 5b2727752bbd..ef878d4c9824 100644 --- a/test/Sema/annotate.c +++ b/test/Sema/annotate.c @@ -4,7 +4,8 @@ void __attribute__((annotate("foo"))) foo(float *a) { __attribute__((annotate("bar"))) int x; __attribute__((annotate(1))) int y; // expected-error {{argument to annotate attribute was not a string literal}} __attribute__((annotate("bar", 1))) int z; // expected-error {{attribute takes one argument}} - int u = __builtin_annotation(z, (char*) 0); // expected-error {{__builtin_annotation requires a non wide string constant}} - int v = __builtin_annotation(z, (char*) L"bar"); // expected-error {{__builtin_annotation requires a non wide string constant}} + int u = __builtin_annotation(z, (char*) 0); // expected-error {{second argument to __builtin_annotation must be a non-wide string constant}} + int v = __builtin_annotation(z, (char*) L"bar"); // expected-error {{second argument to __builtin_annotation must be a non-wide string constant}} int w = __builtin_annotation(z, "foo"); + float b = __builtin_annotation(*a, "foo"); // expected-error {{first argument to __builtin_annotation must be an integer}} } diff --git a/test/Sema/array-bounds-ptr-arith.c b/test/Sema/array-bounds-ptr-arith.c index 022335bd37a7..e3de06a104e4 100644 --- a/test/Sema/array-bounds-ptr-arith.c +++ b/test/Sema/array-bounds-ptr-arith.c @@ -19,3 +19,21 @@ void pr11594(struct S *s) { int a[10]; int *p = a - s->n; } + +// Test case reduced from <rdar://problem/11387038>. This resulted in +// an assertion failure because of the typedef instead of an explicit +// constant array type. +struct RDar11387038 {}; +typedef struct RDar11387038 RDar11387038Array[1]; +struct RDar11387038_Table { + RDar11387038Array z; +}; +typedef struct RDar11387038_Table * TPtr; +typedef TPtr *TabHandle; +struct RDar11387038_B { TabHandle x; }; +typedef struct RDar11387038_B RDar11387038_B; + +void radar11387038() { + RDar11387038_B *pRDar11387038_B; + struct RDar11387038* y = &(*pRDar11387038_B->x)->z[4]; +} diff --git a/test/Sema/array-init.c b/test/Sema/array-init.c index 26c0b2418221..cfdf8e2bd7ca 100644 --- a/test/Sema/array-init.c +++ b/test/Sema/array-init.c @@ -50,7 +50,7 @@ void func() { static long x2[3] = { 1.0, "abc", // expected-warning{{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [4]'}} - 5.8 }; // expected-warning {{implicit conversion turns literal floating-point number into integer}} + 5.8 }; // expected-warning {{implicit conversion from 'double' to 'long' changes value from 5.8 to 5}} } void test() { diff --git a/test/Sema/attr-aligned.c b/test/Sema/attr-aligned.c index c094ff172dd5..92f2742d2f22 100644 --- a/test/Sema/attr-aligned.c +++ b/test/Sema/attr-aligned.c @@ -32,7 +32,7 @@ struct D { int member __attribute__((aligned(2))) __attribute__((packed)); } d; char d1[__alignof__(d) == 2 ?: -1] = {0}; char d2[__alignof__(d.member) == 2 ?: -1] = {0}; -struct E { int member __attribute__((aligned(2))); } __attribute__((packed)); +struct E { int member __attribute__((align(2))); } __attribute__((packed)); struct E e; char e1[__alignof__(e) == 2 ?: -1] = {0}; char e2[__alignof__(e.member) == 2 ?: -1] = {0}; diff --git a/test/Sema/attr-availability-ios.c b/test/Sema/attr-availability-ios.c index ea05e17bad8e..329068cf16bb 100644 --- a/test/Sema/attr-availability-ios.c +++ b/test/Sema/attr-availability-ios.c @@ -1,14 +1,14 @@ // RUN: %clang_cc1 "-triple" "x86_64-apple-ios3.0" -fsyntax-only -verify %s -void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))); +void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))); // expected-note {{'f0' declared here}} void f1(int) __attribute__((availability(ios,introduced=2.1))); -void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); +void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{'f2' declared here}} void f3(int) __attribute__((availability(ios,introduced=3.0))); void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=2.1,obsoleted=3.0))); // expected-note{{explicitly marked unavailable}} -void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0))); +void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f5' declared here}} void f6(int) __attribute__((availability(ios,deprecated=3.0))); -void f6(int) __attribute__((availability(ios,introduced=2.0))); +void f6(int) __attribute__((availability(ios,introduced=2.0))); // expected-note {{'f6' declared here}} void test() { f0(0); // expected-warning{{'f0' is deprecated: first deprecated in iOS 2.1}} diff --git a/test/Sema/attr-availability-macosx.c b/test/Sema/attr-availability-macosx.c index 1de26e9e9eac..781523a2e06a 100644 --- a/test/Sema/attr-availability-macosx.c +++ b/test/Sema/attr-availability-macosx.c @@ -2,7 +2,7 @@ void f0(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.6))); void f1(int) __attribute__((availability(macosx,introduced=10.5))); -void f2(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))); +void f2(int) __attribute__((availability(macosx,introduced=10.4,deprecated=10.5))); // expected-note {{'f2' declared here}} void f3(int) __attribute__((availability(macosx,introduced=10.6))); void f4(int) __attribute__((availability(macosx,introduced=10.1,deprecated=10.3,obsoleted=10.5), availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly marked unavailable}} void f5(int) __attribute__((availability(ios,introduced=3.2), availability(macosx,unavailable))); // expected-note{{function has been explicitly marked unavailable here}} diff --git a/test/Sema/attr-availability.c b/test/Sema/attr-availability.c index 0e6ea9697b55..b4a6f9616df4 100644 --- a/test/Sema/attr-availability.c +++ b/test/Sema/attr-availability.c @@ -8,7 +8,7 @@ void f3() __attribute__((availability(otheros,introduced=2.2))); // expected-war // rdar://10095131 extern void -ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); +ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); // expected-note {{'ATSFontGetName' declared here}} extern void ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{function has been explicitly marked unavailable here}} @@ -24,3 +24,22 @@ enum { NSDataWritingFileProtectionWriteOnly = 0x30000000, NSDataWritingFileProtectionCompleteUntilUserAuthentication = 0x40000000, }; + +void f4(int) __attribute__((availability(ios,deprecated=3.0))); +void f4(int) __attribute__((availability(ios,introduced=4.0))); // expected-warning {{feature cannot be deprecated in iOS version 3.0 before it was introduced in version 4.0; attribute ignored}} + +void f5(int) __attribute__((availability(ios,deprecated=3.0), + availability(ios,introduced=4.0))); // expected-warning {{feature cannot be deprecated in iOS version 3.0 before it was introduced in version 4.0; attribute ignored}} + +void f6(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{previous attribute is here}} +void f6(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warning {{availability does not match previous declaration}} + +void f7(int) __attribute__((availability(ios,introduced=2.0))); +void f7(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{previous attribute is here}} +void f7(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warning {{availability does not match previous declaration}} + + +// <rdar://problem/11886458> +#if !__has_feature(attribute_availability_with_message) +# error "Missing __has_feature" +#endif diff --git a/test/Sema/attr-coldhot.c b/test/Sema/attr-coldhot.c new file mode 100644 index 000000000000..253b1898c0a0 --- /dev/null +++ b/test/Sema/attr-coldhot.c @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +int foo() __attribute__((__hot__)); +int bar() __attribute__((__cold__)); + +int var1 __attribute__((__cold__)); // expected-warning{{'__cold__' attribute only applies to functions}} +int var2 __attribute__((__hot__)); // expected-warning{{'__hot__' attribute only applies to functions}} + +int qux() __attribute__((__hot__)) __attribute__((__cold__)); // expected-error{{'__hot__' and cold attributes are not compatible}} +int baz() __attribute__((__cold__)) __attribute__((__hot__)); // expected-error{{'__cold__' and hot attributes are not compatible}} diff --git a/test/Sema/attr-decl-after-definition.c b/test/Sema/attr-decl-after-definition.c index 4d32e0028b54..17b94cc47ec6 100644 --- a/test/Sema/attr-decl-after-definition.c +++ b/test/Sema/attr-decl-after-definition.c @@ -14,6 +14,26 @@ int bar __attribute__((weak)); int bar __attribute__((used)); extern int bar __attribute__((weak)); int bar = 0; // expected-note {{previous definition is here}} -int bar __attribute__((weak)); // expected-warning {{must precede definition}} +int bar __attribute__((weak)); // no warning as it matches the existing + // attribute. +int bar __attribute__((used, + visibility("hidden"))); // expected-warning {{must precede definition}} int bar; +struct zed { // expected-note {{previous definition is here}} +}; +struct __attribute__((visibility("hidden"))) zed; // expected-warning {{must precede definition}} + +struct __attribute__((visibility("hidden"))) zed2 { +}; +struct __attribute__((visibility("hidden"))) zed2; + +struct __attribute__((visibility("hidden"))) zed3 { // expected-note {{previous definition is here}} +}; +struct __attribute__((visibility("hidden"), + packed // expected-warning {{must precede definition}} + )) zed3; + +struct __attribute__((visibility("hidden"))) zed4 { // expected-note {{previous attribute is here}} +}; +struct __attribute__((visibility("default"))) zed4; // expected-error {{visibility does not match previous declaration}} diff --git a/test/Sema/attr-deprecated-message.c b/test/Sema/attr-deprecated-message.c index 5de31d0d13f8..f48d13e607dd 100644 --- a/test/Sema/attr-deprecated-message.c +++ b/test/Sema/attr-deprecated-message.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only // rdar: // 6734520 -typedef int INT1 __attribute__((deprecated("Please avoid INT1"))); +typedef int INT1 __attribute__((deprecated("Please avoid INT1"))); // expected-note 3 {{'INT1' declared here}} typedef INT1 INT2 __attribute__ ((__deprecated__("Please avoid INT2"))); @@ -12,16 +12,16 @@ typedef INT1 INT1b __attribute__ ((deprecated("Please avoid INT1b"))); INT1 should_be_unavailable; // expected-warning {{'INT1' is deprecated: Please avoid INT1}} INT1a should_not_be_deprecated; -INT1 f1(void) __attribute__ ((deprecated("Please avoid f1"))); +INT1 f1(void) __attribute__ ((deprecated("Please avoid f1"))); // expected-note {{'f1' declared here}} INT1 f2(void); // expected-warning {{'INT1' is deprecated: Please avoid INT1}} -typedef enum {red, green, blue} Color __attribute__((deprecated("Please avoid Color"))); +typedef enum {red, green, blue} Color __attribute__((deprecated("Please avoid Color"))); // expected-note {{'Color' declared here}} Color c1; // expected-warning {{'Color' is deprecated: Please avoid Color}} int g1; -int g2 __attribute__ ((deprecated("Please avoid g2"))); +int g2 __attribute__ ((deprecated("Please avoid g2"))); // expected-note {{'g2' declared here}} int func1() { diff --git a/test/Sema/attr-deprecated.c b/test/Sema/attr-deprecated.c index 4760dabc4cd6..565be7ff5997 100644 --- a/test/Sema/attr-deprecated.c +++ b/test/Sema/attr-deprecated.c @@ -1,10 +1,10 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only -int f() __attribute__((deprecated)); +int f() __attribute__((deprecated)); // expected-note 2 {{declared here}} void g() __attribute__((deprecated)); -void g(); +void g(); // expected-note {{declared here}} -extern int var __attribute__((deprecated)); +extern int var __attribute__((deprecated)); // expected-note {{declared here}} int a() { int (*ptr)() = f; // expected-warning {{'f' is deprecated}} @@ -17,13 +17,13 @@ int a() { } // test if attributes propagate to variables -extern int var; +extern int var; // expected-note {{declared here}} int w() { return var; // expected-warning {{'var' is deprecated}} } int old_fn() __attribute__ ((deprecated)); -int old_fn(); +int old_fn(); // expected-note {{declared here}} int (*fn_ptr)() = old_fn; // expected-warning {{'old_fn' is deprecated}} int old_fn() { @@ -32,7 +32,7 @@ int old_fn() { struct foo { - int x __attribute__((deprecated)); + int x __attribute__((deprecated)); // expected-note 3 {{declared here}} }; void test1(struct foo *F) { @@ -41,11 +41,11 @@ void test1(struct foo *F) { struct foo f2 = { 17 }; // expected-warning {{'x' is deprecated}} } -typedef struct foo foo_dep __attribute__((deprecated)); +typedef struct foo foo_dep __attribute__((deprecated)); // expected-note 12 {{declared here}} foo_dep *test2; // expected-warning {{'foo_dep' is deprecated}} struct __attribute__((deprecated, - invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}} + invalid_attribute)) bar_dep ; // expected-warning {{unknown attribute 'invalid_attribute' ignored}} expected-note 2 {{declared here}} struct bar_dep *test3; // expected-warning {{'bar_dep' is deprecated}} @@ -102,9 +102,9 @@ foo_dep test17, // expected-warning {{'foo_dep' is deprecated}} test19; // rdar://problem/8518751 -enum __attribute__((deprecated)) Test20 { - test20_a __attribute__((deprecated)), - test20_b +enum __attribute__((deprecated)) Test20 { // expected-note {{declared here}} + test20_a __attribute__((deprecated)), // expected-note {{declared here}} + test20_b // expected-note {{declared here}} }; void test20() { enum Test20 f; // expected-warning {{'Test20' is deprecated}} @@ -113,3 +113,10 @@ void test20() { } char test21[__has_feature(attribute_deprecated_with_message) ? 1 : -1]; + +struct test22 { + foo_dep a __attribute((deprecated)); + foo_dep b; // expected-warning {{'foo_dep' is deprecated}} + foo_dep c, d __attribute((deprecated)); // expected-warning {{'foo_dep' is deprecated}} + __attribute((deprecated)) foo_dep e, f; +}; diff --git a/test/Sema/attr-nodebug.c b/test/Sema/attr-nodebug.c index a66e96168dd6..3cc4088e4b3c 100644 --- a/test/Sema/attr-nodebug.c +++ b/test/Sema/attr-nodebug.c @@ -1,8 +1,11 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only -int a __attribute__((nodebug)); // expected-warning {{'nodebug' attribute only applies to functions}} +int a __attribute__((nodebug)); + +void b() { + int b __attribute__((nodebug)); // expected-warning {{'nodebug' only applies to variables with static storage duration and functions}} +} void t1() __attribute__((nodebug)); void t2() __attribute__((nodebug(2))); // expected-error {{attribute takes no arguments}} - diff --git a/test/Sema/attr-section.c b/test/Sema/attr-section.c index a9325254080b..69ca732517af 100644 --- a/test/Sema/attr-section.c +++ b/test/Sema/attr-section.c @@ -13,3 +13,7 @@ void test() { __attribute__((section("NEAR,x"))) int n1; // expected-error {{'section' attribute is not valid on local variables}} __attribute__((section("NEAR,x"))) static int n2; // ok. } + +// pr9356 +void __attribute__((section("foo,zed"))) test2(void); // expected-note {{previous attribute is here}} +void __attribute__((section("bar,zed"))) test2(void) {} // expected-warning {{section does not match previous declaration}} diff --git a/test/Sema/attr-tls_model.c b/test/Sema/attr-tls_model.c new file mode 100644 index 000000000000..e184ebc82af0 --- /dev/null +++ b/test/Sema/attr-tls_model.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -verify -fsyntax-only %s + +#if !__has_attribute(tls_model) +#error "Should support tls_model attribute" +#endif + +int f() __attribute((tls_model("global-dynamic"))); // expected-error {{'tls_model' attribute only applies to thread-local variables}} + +int x __attribute((tls_model("global-dynamic"))); // expected-error {{'tls_model' attribute only applies to thread-local variables}} +static __thread int y __attribute((tls_model("global-dynamic"))); // no-warning + +static __thread int y __attribute((tls_model("local", "dynamic"))); // expected-error {{attribute takes one argument}} +static __thread int y __attribute((tls_model(123))); // expected-error {{argument to tls_model attribute was not a string literal}} +static __thread int y __attribute((tls_model("foobar"))); // expected-error {{tls_model must be "global-dynamic", "local-dynamic", "initial-exec" or "local-exec"}} diff --git a/test/Sema/attr-unavailable-message.c b/test/Sema/attr-unavailable-message.c index b2956d85534d..97104960e5e4 100644 --- a/test/Sema/attr-unavailable-message.c +++ b/test/Sema/attr-unavailable-message.c @@ -29,8 +29,8 @@ void unavail(void) { // rdar://10201690 enum foo { - a = 1, - b __attribute__((deprecated())) = 2, + a = 1, // expected-note {{declared here}} + b __attribute__((deprecated())) = 2, // expected-note {{declared here}} c = 3 }__attribute__((deprecated())); diff --git a/test/Sema/attr-visibility.c b/test/Sema/attr-visibility.c index 5cf269582abc..77bc39c9e6e8 100644 --- a/test/Sema/attr-visibility.c +++ b/test/Sema/attr-visibility.c @@ -7,3 +7,18 @@ void test2() __attribute__((visibility("internal"))); // rdar://problem/10753392 void test3() __attribute__((visibility("protected"))); // expected-warning {{target does not support 'protected' visibility; using 'default'}} +struct __attribute__((visibility("hidden"))) test4; // expected-note {{previous attribute is here}} +struct test4; +struct __attribute__((visibility("default"))) test4; // expected-error {{visibility does not match previous declaration}} + +struct test5; +struct __attribute__((visibility("hidden"))) test5; // expected-note {{previous attribute is here}} +struct __attribute__((visibility("default"))) test5; // expected-error {{visibility does not match previous declaration}} + +void test6() __attribute__((visibility("hidden"), // expected-note {{previous attribute is here}} + visibility("default"))); // expected-error {{visibility does not match previous declaration}} + +extern int test7 __attribute__((visibility("default"))); // expected-note {{previous attribute is here}} +extern int test7 __attribute__((visibility("hidden"))); // expected-error {{visibility does not match previous declaration}} + +typedef int __attribute__((visibility("default"))) bar; // expected-warning {{visibility attribute ignored}} diff --git a/test/Sema/c89-2.c b/test/Sema/c89-2.c index f6f6bd972090..14b955a6a4b3 100644 --- a/test/Sema/c89-2.c +++ b/test/Sema/c89-2.c @@ -1,4 +1,4 @@ -/* RUN: %clang_cc1 %s -std=c89 -pedantic-errors -verify +/* RUN: %clang_cc1 %s -std=c89 -pedantic-errors -Wno-empty-translation-unit -verify */ #if 1LL /* expected-error {{long long}} */ diff --git a/test/Sema/compare.c b/test/Sema/compare.c index 03aebb3a0462..406ade81aa0d 100644 --- a/test/Sema/compare.c +++ b/test/Sema/compare.c @@ -333,3 +333,10 @@ struct test11S { unsigned x : 30; }; int test11(unsigned y, struct test11S *p) { return y > (p->x >> 24); // no-warning } + +typedef char one_char[1]; +typedef char two_chars[2]; + +void test12(unsigned a) { + if (0 && -1 > a) { } +} diff --git a/test/Sema/conditional-expr.c b/test/Sema/conditional-expr.c index 184ac4a9e7e9..5ff58a2ec476 100644 --- a/test/Sema/conditional-expr.c +++ b/test/Sema/conditional-expr.c @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wsign-conversion %s void foo() { *(0 ? (double *)0 : (void *)0) = 0; - // FIXME: GCC doesn't consider the the following two statements to be errors. + // FIXME: GCC doesn't consider the following two statements to be errors. *(0 ? (double *)0 : (void *)(int *)0) = 0; // expected-error {{incomplete type 'void' is not assignable}} *(0 ? (double *)0 : (void *)(double *)0) = 0; // expected-error {{incomplete type 'void' is not assignable}} *(0 ? (double *)0 : (int *)(void *)0) = 0; // expected-error {{incomplete type 'void' is not assignable}} expected-warning {{pointer type mismatch ('double *' and 'int *')}} diff --git a/test/Sema/const-eval.c b/test/Sema/const-eval.c index bc8b227ac8b9..16d028eaf60e 100644 --- a/test/Sema/const-eval.c +++ b/test/Sema/const-eval.c @@ -131,3 +131,6 @@ EVAL_EXPR(49, &x < &x - 100 ? 1 : -1) // expected-error {{must have a constant s extern struct Test50S Test50; EVAL_EXPR(50, &Test50 < (struct Test50S*)((unsigned)&Test50 + 10)) // expected-error {{must have a constant size}} + +// <rdar://problem/11874571> +EVAL_EXPR(51, 0 != (float)1e99) diff --git a/test/Sema/dllimport-dllexport.c b/test/Sema/dllimport-dllexport.c index 610059ec9f6b..00c9df594b6f 100644 --- a/test/Sema/dllimport-dllexport.c +++ b/test/Sema/dllimport-dllexport.c @@ -35,3 +35,9 @@ typedef int __declspec(dllimport) type2; // expected-warning{{'dllimport' attrib void __declspec(dllimport) foo12(); void foo12(){} // expected-warning {{'foo12' redeclared without dllimport attribute: previous dllimport ignored}} + +void __attribute__((dllimport)) foo13(); // expected-warning{{dllimport attribute ignored}} +void __attribute__((dllexport)) foo13(); + +extern int foo14 __attribute__((dllexport)); +extern int foo14 __attribute__((dllimport)); // expected-warning{{dllimport attribute ignored}} diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c index 72cff65f4837..a93e12ec390b 100644 --- a/test/Sema/exprs.c +++ b/test/Sema/exprs.c @@ -162,11 +162,20 @@ void test17(int x) { x = sizeof(x/0); // no warning. } -// PR6501 +// PR6501 & PR11857 void test18_a(int a); // expected-note 2 {{'test18_a' declared here}} +void test18_b(int); // expected-note {{'test18_b' declared here}} +void test18_c(int a, int b); // expected-note 2 {{'test18_c' declared here}} +void test18_d(int a, ...); // expected-note {{'test18_d' declared here}} +void test18_e(int a, int b, ...); // expected-note {{'test18_e' declared here}} void test18(int b) { - test18_a(b, b); // expected-error {{too many arguments to function call, expected 1, have 2}} - test18_a(); // expected-error {{too few arguments to function call, expected 1, have 0}} + test18_a(b, b); // expected-error {{too many arguments to function call, expected single argument 'a', have 2}} + test18_a(); // expected-error {{too few arguments to function call, single argument 'a' was not specified}} + test18_b(); // expected-error {{too few arguments to function call, expected 1, have 0}} + test18_c(b); // expected-error {{too few arguments to function call, expected 2, have 1}} + test18_c(b, b, b); // expected-error {{too many arguments to function call, expected 2, have 3}} + test18_d(); // expected-error {{too few arguments to function call, at least argument 'a' must be specified}} + test18_e(); // expected-error {{too few arguments to function call, expected at least 2, have 0}} } // PR7569 diff --git a/test/Sema/format-strings-enum-fixed-type.cpp b/test/Sema/format-strings-enum-fixed-type.cpp new file mode 100644 index 000000000000..8b6b23764520 --- /dev/null +++ b/test/Sema/format-strings-enum-fixed-type.cpp @@ -0,0 +1,92 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin9 -x c++ -std=c++11 -verify %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -x objective-c -verify %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -x objective-c++ -verify %s + +#ifdef __cplusplus +# define EXTERN_C extern "C" +#else +# define EXTERN_C extern +#endif + +EXTERN_C int printf(const char *,...); + +typedef enum : short { Constant = 0 } TestEnum; +// Note that in C (and Objective-C), the type of 'Constant' is 'short'. +// In C++ (and Objective-C++) it is 'TestEnum'. +// This is why we don't check for that in the expected output. + +void test(TestEnum input) { + printf("%hhd", input); // expected-warning{{format specifies type 'char' but the argument has type 'TestEnum'}} + printf("%hhd", Constant); // expected-warning{{format specifies type 'char'}} + + printf("%hd", input); // no-warning + printf("%hd", Constant); // no-warning + + // While these are less correct, they are still safe. + printf("%d", input); // no-warning + printf("%d", Constant); // no-warning + + printf("%lld", input); // expected-warning{{format specifies type 'long long' but the argument has type 'TestEnum'}} + printf("%lld", Constant); // expected-warning{{format specifies type 'long long'}} +} + + +typedef enum : unsigned long { LongConstant = ~0UL } LongEnum; + +void testLong(LongEnum input) { + printf("%u", input); // expected-warning{{format specifies type 'unsigned int' but the argument has type 'LongEnum'}} + printf("%u", LongConstant); // expected-warning{{format specifies type 'unsigned int'}} + + printf("%lu", input); + printf("%lu", LongConstant); +} + + +typedef short short_t; +typedef enum : short_t { ShortConstant = 0 } ShortEnum; + +void testUnderlyingTypedef(ShortEnum input) { + printf("%hhd", input); // expected-warning{{format specifies type 'char' but the argument has type 'ShortEnum'}} + printf("%hhd", ShortConstant); // expected-warning{{format specifies type 'char'}} + + printf("%hd", input); // no-warning + printf("%hd", ShortConstant); // no-warning + + // While these are less correct, they are still safe. + printf("%d", input); // no-warning + printf("%d", ShortConstant); // no-warning + + printf("%lld", input); // expected-warning{{format specifies type 'long long' but the argument has type 'ShortEnum'}} + printf("%lld", ShortConstant); // expected-warning{{format specifies type 'long long'}} +} + + +typedef ShortEnum ShortEnum2; + +void testTypedefChain(ShortEnum2 input) { + printf("%hhd", input); // expected-warning{{format specifies type 'char' but the argument has type 'ShortEnum2' (aka 'ShortEnum')}} + printf("%hd", input); // no-warning + printf("%d", input); // no-warning + printf("%lld", input); // expected-warning{{format specifies type 'long long' but the argument has type 'ShortEnum2' (aka 'ShortEnum')}} +} + + +typedef enum : char { CharConstant = 'a' } CharEnum; + +// %hhd is deliberately not required to be signed, because 'char' isn't either. +// This is a separate code path in FormatString.cpp. +void testChar(CharEnum input) { + printf("%hhd", input); // no-warning + printf("%hhd", CharConstant); // no-warning + + // This is not correct but it is safe. We warn because '%hd' shows intent. + printf("%hd", input); // expected-warning{{format specifies type 'short' but the argument has type 'CharEnum'}} + printf("%hd", CharConstant); // expected-warning{{format specifies type 'short'}} + + // This is not correct but it matches the promotion rules (and is safe). + printf("%d", input); // no-warning + printf("%d", CharConstant); // no-warning + + printf("%lld", input); // expected-warning{{format specifies type 'long long' but the argument has type 'CharEnum'}} + printf("%lld", CharConstant); // expected-warning{{format specifies type 'long long'}} +} diff --git a/test/Sema/format-strings-enum.c b/test/Sema/format-strings-enum.c new file mode 100644 index 000000000000..a6c27d0b6eb3 --- /dev/null +++ b/test/Sema/format-strings-enum.c @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x c++ -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x c++ -std=c++11 -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c++ -std=c++11 -verify %s + +#ifdef __cplusplus +# define EXTERN_C extern "C" +#else +# define EXTERN_C extern +#endif + +EXTERN_C int printf(const char *,...); + +typedef enum { Constant = 0 } TestEnum; +// Note that in C, the type of 'Constant' is 'int'. In C++ it is 'TestEnum'. +// This is why we don't check for that in the expected output. + +void test(TestEnum input) { + printf("%d", input); // no-warning + printf("%d", Constant); // no-warning + + printf("%lld", input); // expected-warning{{format specifies type 'long long' but the argument has type 'TestEnum'}} + printf("%lld", Constant); // expected-warning{{format specifies type 'long long'}} +} + + +typedef enum { LongConstant = ~0UL } LongEnum; + +void testLong(LongEnum input) { + printf("%u", input); // expected-warning{{format specifies type 'unsigned int' but the argument has type 'LongEnum'}} + printf("%u", LongConstant); // expected-warning{{format specifies type 'unsigned int'}} + + printf("%lu", input); + printf("%lu", LongConstant); +} diff --git a/test/Sema/format-strings-fixit.c b/test/Sema/format-strings-fixit.c index 800691ecc8cd..15ac71342876 100644 --- a/test/Sema/format-strings-fixit.c +++ b/test/Sema/format-strings-fixit.c @@ -64,6 +64,18 @@ void test() { printf("%f", (uintmax_t) 42); printf("%f", (ptrdiff_t) 42); + // Look beyond the first typedef. + typedef size_t my_size_type; + typedef intmax_t my_intmax_type; + typedef uintmax_t my_uintmax_type; + typedef ptrdiff_t my_ptrdiff_type; + typedef int my_int_type; + printf("%f", (my_size_type) 42); + printf("%f", (my_intmax_type) 42); + printf("%f", (my_uintmax_type) 42); + printf("%f", (my_ptrdiff_type) 42); + printf("%f", (my_int_type) 42); + // string printf("%ld", "foo"); @@ -122,6 +134,18 @@ void test2() { scanf("%f", &uIntmaxVar); scanf("%f", &ptrdiffVar); + // Look beyond the first typedef for named integer types. + typedef size_t my_size_type; + typedef intmax_t my_intmax_type; + typedef uintmax_t my_uintmax_type; + typedef ptrdiff_t my_ptrdiff_type; + typedef int my_int_type; + scanf("%f", (my_size_type*)&sizeVar); + scanf("%f", (my_intmax_type*)&intmaxVar); + scanf("%f", (my_uintmax_type*)&uIntmaxVar); + scanf("%f", (my_ptrdiff_type*)&ptrdiffVar); + scanf("%f", (my_int_type*)&intVar); + // Preserve the original formatting. scanf("%o", &longVar); scanf("%u", &longVar); @@ -162,6 +186,11 @@ void test2() { // CHECK: printf("%jd", (intmax_t) 42); // CHECK: printf("%ju", (uintmax_t) 42); // CHECK: printf("%td", (ptrdiff_t) 42); +// CHECK: printf("%zu", (my_size_type) 42); +// CHECK: printf("%jd", (my_intmax_type) 42); +// CHECK: printf("%ju", (my_uintmax_type) 42); +// CHECK: printf("%td", (my_ptrdiff_type) 42); +// CHECK: printf("%d", (my_int_type) 42); // CHECK: printf("%s", "foo"); // CHECK: printf("%lo", (long) 42); // CHECK: printf("%lu", (long) 42); @@ -193,6 +222,11 @@ void test2() { // CHECK: scanf("%jd", &intmaxVar); // CHECK: scanf("%ju", &uIntmaxVar); // CHECK: scanf("%td", &ptrdiffVar); +// CHECK: scanf("%zu", (my_size_type*)&sizeVar); +// CHECK: scanf("%jd", (my_intmax_type*)&intmaxVar); +// CHECK: scanf("%ju", (my_uintmax_type*)&uIntmaxVar); +// CHECK: scanf("%td", (my_ptrdiff_type*)&ptrdiffVar); +// CHECK: scanf("%d", (my_int_type*)&intVar); // CHECK: scanf("%lo", &longVar); // CHECK: scanf("%lu", &longVar); // CHECK: scanf("%lx", &longVar); diff --git a/test/Sema/format-strings-scanf.c b/test/Sema/format-strings-scanf.c index e94af5acb11c..235ac11faa1c 100644 --- a/test/Sema/format-strings-scanf.c +++ b/test/Sema/format-strings-scanf.c @@ -33,6 +33,12 @@ void test(const char *s, int *i) { scanf("%*d", i); // // expected-warning{{data argument not used by format string}} scanf("%*d", i); // // expected-warning{{data argument not used by format string}} scanf("%*d%1$d", i); // no-warning + + scanf("%s", (char*)0); // no-warning + scanf("%s", (volatile char*)0); // no-warning + scanf("%s", (signed char*)0); // no-warning + scanf("%s", (unsigned char*)0); // no-warning + scanf("%hhu", (signed char*)0); // no-warning } void bad_length_modifiers(char *s, void *p, wchar_t *ws, long double *ld) { @@ -121,3 +127,52 @@ void test_quad(int *x, long long *llx) { scanf("%qd", x); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}} scanf("%qd", llx); // no-warning } + +void test_writeback(int *x) { + scanf("%n", (void*)0); // expected-warning{{format specifies type 'int *' but the argument has type 'void *'}} + scanf("%n %c", x, x); // expected-warning{{format specifies type 'char *' but the argument has type 'int *'}} + + scanf("%hhn", (signed char*)0); // no-warning + scanf("%hhn", (char*)0); // no-warning + scanf("%hhn", (unsigned char*)0); // no-warning + scanf("%hhn", (int*)0); // expected-warning{{format specifies type 'signed char *' but the argument has type 'int *'}} + + scanf("%hn", (short*)0); // no-warning + scanf("%hn", (unsigned short*)0); // no-warning + scanf("%hn", (int*)0); // expected-warning{{format specifies type 'short *' but the argument has type 'int *'}} + + scanf("%n", (int*)0); // no-warning + scanf("%n", (unsigned int*)0); // no-warning + scanf("%n", (char*)0); // expected-warning{{format specifies type 'int *' but the argument has type 'char *'}} + + scanf("%ln", (long*)0); // no-warning + scanf("%ln", (unsigned long*)0); // no-warning + scanf("%ln", (int*)0); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}} + + scanf("%lln", (long long*)0); // no-warning + scanf("%lln", (unsigned long long*)0); // no-warning + scanf("%lln", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}} + + scanf("%qn", (long long*)0); // no-warning + scanf("%qn", (unsigned long long*)0); // no-warning + scanf("%qn", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}} + +} + +void test_qualifiers(const int *cip, volatile int* vip, + const char *ccp, volatile char* vcp, + const volatile int *cvip) { + scanf("%d", cip); // expected-warning{{format specifies type 'int *' but the argument has type 'const int *'}} + scanf("%n", cip); // expected-warning{{format specifies type 'int *' but the argument has type 'const int *'}} + scanf("%s", ccp); // expected-warning{{format specifies type 'char *' but the argument has type 'const char *'}} + scanf("%d", cvip); // expected-warning{{format specifies type 'int *' but the argument has type 'const volatile int *'}} + + scanf("%d", vip); // No warning. + scanf("%n", vip); // No warning. + scanf("%c", vcp); // No warning. + + typedef int* ip_t; + typedef const int* cip_t; + scanf("%d", (ip_t)0); // No warning. + scanf("%d", (cip_t)0); // expected-warning{{format specifies type 'int *' but the argument has type 'cip_t' (aka 'const int *')}} +} diff --git a/test/Sema/format-strings-size_t.c b/test/Sema/format-strings-size_t.c index 7f88ff38c302..5058a762183d 100644 --- a/test/Sema/format-strings-size_t.c +++ b/test/Sema/format-strings-size_t.c @@ -13,3 +13,16 @@ void test(void) { // ptrdiff_t printf("%td", (double)42); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'long') but the argument has type 'double'}} } + +void test_writeback(void) { + printf("%jn", (long*)0); // no-warning + printf("%jn", (unsigned long*)0); // no-warning + printf("%jn", (int*)0); // expected-warning{{format specifies type 'intmax_t *' (aka 'long *') but the argument has type 'int *'}} + + printf("%zn", (long*)0); // no-warning + // FIXME: Warn about %zn with non-ssize_t argument. + + printf("%tn", (long*)0); // no-warning + printf("%tn", (unsigned long*)0); // no-warning + printf("%tn", (int*)0); // expected-warning{{format specifies type 'ptrdiff_t *' (aka 'long *') but the argument has type 'int *'}} +} diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index 086c5c6d6fe8..86b9296108c6 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -1,7 +1,10 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -isystem %S/Inputs %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -isystem %S/Inputs -fno-signed-char %s +#define __need_wint_t #include <stdarg.h> -typedef __typeof(sizeof(int)) size_t; +#include <stddef.h> // For wint_t and wchar_t + typedef struct _FILE FILE; int fprintf(FILE *, const char *restrict, ...); int printf(const char *restrict, ...); // expected-note{{passing argument to parameter here}} @@ -85,9 +88,35 @@ void check_writeback_specifier() { int x; char *b; + printf("%n", b); // expected-warning{{format specifies type 'int *' but the argument has type 'char *'}} + printf("%n", &x); // no-warning + + printf("%hhn", (signed char*)0); // no-warning + printf("%hhn", (char*)0); // no-warning + printf("%hhn", (unsigned char*)0); // no-warning + printf("%hhn", (int*)0); // expected-warning{{format specifies type 'signed char *' but the argument has type 'int *'}} + + printf("%hn", (short*)0); // no-warning + printf("%hn", (unsigned short*)0); // no-warning + printf("%hn", (int*)0); // expected-warning{{format specifies type 'short *' but the argument has type 'int *'}} + + printf("%n", (int*)0); // no-warning + printf("%n", (unsigned int*)0); // no-warning + printf("%n", (char*)0); // expected-warning{{format specifies type 'int *' but the argument has type 'char *'}} + + printf("%ln", (long*)0); // no-warning + printf("%ln", (unsigned long*)0); // no-warning + printf("%ln", (int*)0); // expected-warning{{format specifies type 'long *' but the argument has type 'int *'}} + + printf("%lln", (long long*)0); // no-warning + printf("%lln", (unsigned long long*)0); // no-warning + printf("%lln", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}} + + printf("%qn", (long long*)0); // no-warning + printf("%qn", (unsigned long long*)0); // no-warning + printf("%qn", (int*)0); // expected-warning{{format specifies type 'long long *' but the argument has type 'int *'}} - printf("%n",&x); // expected-warning {{'%n' in format string discouraged}} - sprintf(b,"%d%%%n",1, &x); // expected-warning {{'%n' in format string dis}} + printf("%Ln", 0); // expected-warning{{length modifier 'L' results in undefined behavior or no effect with 'n' conversion specifier}} } void check_invalid_specifier(FILE* fp, char *buf) @@ -164,7 +193,6 @@ void test9(char *P) { int x; printf(P); // expected-warning {{format string is not a string literal (potentially insecure)}} printf(P, 42); - printf("%n", &x); // expected-warning {{use of '%n' in format string discouraged }} } void torture(va_list v8) { @@ -182,7 +210,6 @@ void test10(int x, float f, int i, long long lli) { printf("%*d\n", f, x); // expected-warning{{field width should have type 'int', but argument has type 'double'}} printf("%*.*d\n", x, f, x); // expected-warning{{field precision should have type 'int', but argument has type 'double'}} printf("%**\n"); // expected-warning{{invalid conversion specifier '*'}} - printf("%n", &i); // expected-warning{{use of '%n' in format string discouraged (potentially insecure)}} printf("%d%d\n", x); // expected-warning{{more '%' conversions than data arguments}} printf("%d\n", x, x); // expected-warning{{data argument not used by format string}} printf("%W%d%Z\n", x, x, x); // expected-warning{{invalid conversion specifier 'W'}} expected-warning{{invalid conversion specifier 'Z'}} @@ -258,7 +285,6 @@ void f0(int_t x) { printf("%d\n", x); } // Unicode test cases. These are possibly specific to Mac OS X. If so, they should // eventually be moved into a separate test. -typedef __WCHAR_TYPE__ wchar_t; void test_unicode_conversions(wchar_t *s) { printf("%S", s); // no-warning @@ -314,14 +340,14 @@ void bug7377_bad_length_mod_usage() { // Bad flag usage printf("%#p", (void *) 0); // expected-warning{{flag '#' results in undefined behavior with 'p' conversion specifier}} printf("%0d", -1); // no-warning - printf("%#n", (void *) 0); // expected-warning{{flag '#' results in undefined behavior with 'n' conversion specifier}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}} - printf("%-n", (void *) 0); // expected-warning{{flag '-' results in undefined behavior with 'n' conversion specifier}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}} + printf("%#n", (int *) 0); // expected-warning{{flag '#' results in undefined behavior with 'n' conversion specifier}} + printf("%-n", (int *) 0); // expected-warning{{flag '-' results in undefined behavior with 'n' conversion specifier}} printf("%-p", (void *) 0); // no-warning // Bad optional amount use printf("%.2c", 'a'); // expected-warning{{precision used with 'c' conversion specifier, resulting in undefined behavior}} - printf("%1n", (void *) 0); // expected-warning{{field width used with 'n' conversion specifier, resulting in undefined behavior}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}} - printf("%.9n", (void *) 0); // expected-warning{{precision used with 'n' conversion specifier, resulting in undefined behavior}} expected-warning{{use of '%n' in format string discouraged (potentially insecure)}} + printf("%1n", (int *) 0); // expected-warning{{field width used with 'n' conversion specifier, resulting in undefined behavior}} + printf("%.9n", (int *) 0); // expected-warning{{precision used with 'n' conversion specifier, resulting in undefined behavior}} // Ignored flags printf("% +f", 1.23); // expected-warning{{flag ' ' is ignored when flag '+' is present}} @@ -332,17 +358,18 @@ void bug7377_bad_length_mod_usage() { } // PR 7981 - handle '%lc' (wint_t) -#ifndef wint_t -typedef int __darwin_wint_t; -typedef __darwin_wint_t wint_t; -#endif void pr7981(wint_t c, wchar_t c2) { printf("%lc", c); // no-warning printf("%lc", 1.0); // expected-warning{{the argument has type 'double'}} printf("%lc", (char) 1); // no-warning - printf("%lc", &c); // expected-warning{{the argument has type 'wint_t *' (aka 'int *')}} + printf("%lc", &c); // expected-warning{{the argument has type 'wint_t *'}} + // If wint_t and wchar_t are the same width and wint_t is signed where + // wchar_t is unsigned, an implicit conversion isn't possible. +#if defined(__WINT_UNSIGNED__) || !defined(__WCHAR_UNSIGNED__) || \ + __WINT_WIDTH__ > __WCHAR_WIDTH__ printf("%lc", c2); // no-warning +#endif } // <rdar://problem/8269537> -Wformat-security says NULL is not a string literal @@ -432,10 +459,6 @@ void pr9751() { printf(kFormat2, 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (2)}} printf("%18$s\n", 1, "foo"); // expected-warning{{data argument position '18' exceeds the number of data arguments (2)}} - const char kFormat3[] = "%n"; // expected-note{{format string is defined here}} - printf(kFormat3, "as"); // expected-warning{{use of '%n' in format string discouraged}} - printf("%n", "as"); // expected-warning{{use of '%n' in format string discouraged}} - const char kFormat4[] = "%y"; // expected-note{{format string is defined here}} printf(kFormat4, 5); // expected-warning{{invalid conversion specifier 'y'}} printf("%y", 5); // expected-warning{{invalid conversion specifier 'y'}} @@ -497,6 +520,15 @@ void pr9751() { printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}} printf("%a", (long double)0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}} + + // Test braced char[] initializers. + const char kFormat18[] = { "%lld" }; // expected-note{{format string is defined here}} + printf(kFormat18, 0); // expected-warning{{format specifies type}} + + // Make sure we point at the offending argument rather than the format string. + const char kFormat19[] = "%d"; // expected-note{{format string is defined here}} + printf(kFormat19, + 0.0); // expected-warning{{format specifies}} } // PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx @@ -521,3 +553,48 @@ void test_other_formats() { dateformat(""); // expected-warning{{format string is empty}} dateformat(str); // no-warning (using strftime non literal is not unsafe) } + +// Do not warn about unused arguments coming from system headers. +// <rdar://problem/11317765> +#include <format-unused-system-args.h> +void test_unused_system_args(int x) { + PRINT1("%d\n", x); // no-warning{{extra argument is system header is OK}} +} + +void pr12761(char c) { + // This should not warn even with -fno-signed-char. + printf("%hhx", c); +} + + +// Test that we correctly merge the format in both orders. +extern void test14_foo(const char *, const char *, ...) + __attribute__((__format__(__printf__, 1, 3))); +extern void test14_foo(const char *, const char *, ...) + __attribute__((__format__(__scanf__, 2, 3))); + +extern void test14_bar(const char *, const char *, ...) + __attribute__((__format__(__scanf__, 2, 3))); +extern void test14_bar(const char *, const char *, ...) + __attribute__((__format__(__printf__, 1, 3))); + +void test14_zed(int *p) { + test14_foo("%", "%d", p); // expected-warning{{incomplete format specifier}} + test14_bar("%", "%d", p); // expected-warning{{incomplete format specifier}} +} + +void test_qualifiers(volatile int *vip, const int *cip, + const volatile int *cvip) { + printf("%n", cip); // expected-warning{{format specifies type 'int *' but the argument has type 'const int *'}} + printf("%n", cvip); // expected-warning{{format specifies type 'int *' but the argument has type 'const volatile int *'}} + + printf("%n", vip); // No warning. + printf("%p", cip); // No warning. + printf("%p", cvip); // No warning. + + + typedef int* ip_t; + typedef const int* cip_t; + printf("%n", (ip_t)0); // No warning. + printf("%n", (cip_t)0); // expected-warning{{format specifies type 'int *' but the argument has type 'cip_t' (aka 'const int *')}} +} diff --git a/test/Sema/fpack-struct.c b/test/Sema/fpack-struct.c index 37c8444ae9f8..63766e9c9dbd 100644 --- a/test/Sema/fpack-struct.c +++ b/test/Sema/fpack-struct.c @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=5 -fpack-struct 1 %s -// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=6 -fpack-struct 2 %s +// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=5 -fpack-struct=1 %s +// RUN: %clang_cc1 -DEXPECTED_STRUCT_SIZE=6 -fpack-struct=2 %s struct s0 { int x; diff --git a/test/Sema/implicit-builtin-decl.c b/test/Sema/implicit-builtin-decl.c index 8cdd36518e81..d7ec16953a09 100644 --- a/test/Sema/implicit-builtin-decl.c +++ b/test/Sema/implicit-builtin-decl.c @@ -55,3 +55,5 @@ void snprintf() { } // PR8316 void longjmp(); // expected-warning{{declaration of built-in function 'longjmp' requires inclusion of the header <setjmp.h>}} + +extern float fmaxf(float, float); diff --git a/test/Sema/inline.c b/test/Sema/inline.c index 3c99f2433783..c27c00efaad2 100644 --- a/test/Sema/inline.c +++ b/test/Sema/inline.c @@ -1,6 +1,78 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +#if defined(INCLUDE) +// ------- +// This section acts like a header file. +// ------- + +// Check the use of static variables in non-static inline functions. +static int staticVar; // expected-note + {{'staticVar' declared here}} +static int staticFunction(); // expected-note + {{'staticFunction' declared here}} +static struct { int x; } staticStruct; // expected-note + {{'staticStruct' declared here}} + +inline int useStatic () { // expected-note 3 {{use 'static' to give inline function 'useStatic' internal linkage}} + staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}} + (void)staticStruct.x; // expected-warning{{static variable 'staticStruct' is used in an inline function with external linkage}} + return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}} +} + +extern inline int useStaticFromExtern () { // no suggestions + staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}} + return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}} +} + +static inline int useStaticFromStatic () { + staticFunction(); // no-warning + return staticVar; // no-warning +} + +extern inline int useStaticInlineFromExtern () { + // Heuristic: if the function we're using is also inline, don't warn. + // This can still be wrong (in this case, we end up inlining calls to + // staticFunction and staticVar) but this got very noisy even using + // standard headers. + return useStaticFromStatic(); // no-warning +} + +static int constFunction() __attribute__((const)); + +inline int useConst () { + return constFunction(); // no-warning +} + +#else +// ------- +// This is the main source file. +// ------- + +#define INCLUDE +#include "inline.c" + // Check that we don't allow illegal uses of inline inline int a; // expected-error{{'inline' can only appear on functions}} typedef inline int b; // expected-error{{'inline' can only appear on functions}} int d(inline int a); // expected-error{{'inline' can only appear on functions}} + +// Check that the warnings from the "header file" aren't on by default in +// the main source file. + +inline int useStaticMainFile () { + staticFunction(); // no-warning + return staticVar; // no-warning +} + +// Check that the warnings show up when explicitly requested. + +#pragma clang diagnostic push +#pragma clang diagnostic warning "-Wstatic-in-inline" + +inline int useStaticAgain () { // expected-note 2 {{use 'static' to give inline function 'useStaticAgain' internal linkage}} + staticFunction(); // expected-warning{{static function 'staticFunction' is used in an inline function with external linkage}} + return staticVar; // expected-warning{{static variable 'staticVar' is used in an inline function with external linkage}} +} + +#pragma clang diagnostic pop + +#endif + + diff --git a/test/Sema/invalid-decl.c b/test/Sema/invalid-decl.c index a5e7ad3b1ec1..2699b254926a 100644 --- a/test/Sema/invalid-decl.c +++ b/test/Sema/invalid-decl.c @@ -20,3 +20,12 @@ zend_module_entry openssl_module_entry = { sizeof(zend_module_entry) }; +// <rdar://problem/11067144> +typedef int (FunctionType)(int *value); +typedef struct { + UndefinedType undef; // expected-error {{unknown type name 'UndefinedType'}} + FunctionType fun; // expected-error {{field 'fun' declared as a function}} +} StructType; +void f(StructType *buf) { + buf->fun = 0; +} diff --git a/test/Sema/knr-def-call.c b/test/Sema/knr-def-call.c index f41275d1e618..80ad0d820b1a 100644 --- a/test/Sema/knr-def-call.c +++ b/test/Sema/knr-def-call.c @@ -36,6 +36,6 @@ void proto(x) } void use_proto() { - proto(42.1); // expected-warning{{implicit conversion turns literal floating-point number into integer}} - (&proto)(42.1); // expected-warning{{implicit conversion turns literal floating-point number into integer}} + proto(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}} + (&proto)(42.1); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 42.1 to 42}} } diff --git a/test/Sema/ms_class_layout.cpp b/test/Sema/ms_class_layout.cpp index ea3f899ea249..f48494733184 100644 --- a/test/Sema/ms_class_layout.cpp +++ b/test/Sema/ms_class_layout.cpp @@ -97,6 +97,48 @@ struct P : public M, public virtual L { struct R {}; +class IA { +public: + virtual ~IA(){} + virtual void ia() = 0; +}; + +class ICh : public virtual IA { +public: + virtual ~ICh(){} + virtual void ia(){} + virtual void iCh(){} +}; + +struct f { + virtual int asd() {return -90;} +}; + +struct s : public virtual f { + virtual ~s(){} + int r; + virtual int asd() {return -9;} +}; + +struct sd : virtual s, virtual ICh { + virtual ~sd(){} + int q; + char y; + virtual int asd() {return -1;} +}; +struct AV { + virtual void foo(); +}; +struct BV : AV { +}; +struct CV : virtual BV { + CV(); + virtual void foo(); +}; +struct DV : BV { +}; +struct EV : CV, DV { +}; #pragma pack(pop) // This needs only for building layouts. @@ -113,6 +155,8 @@ int main() { O* o; P* p; R* r; + sd *h; + EV *j; return 0; } @@ -333,3 +377,132 @@ int main() { // CHECK-NEXT: nvsize=0, nvalign=1 //CHECK: %struct.R = type { i8 } + +// CHECK: 0 | struct f +// CHECK-NEXT: 0 | (f vftable pointer) +// CHECK-NEXT: sizeof=4, dsize=4, align=4 +// CHECK-NEXT: nvsize=4, nvalign=4 + +// CHECK: 0 | struct s +// CHECK-NEXT: 0 | (s vftable pointer) +// CHECK-NEXT: 4 | (s vbtable pointer) +// CHECK-NEXT: 8 | int r +// CHECK-NEXT: 12 | (vtordisp for vbase f) +// CHECK-NEXT: 16 | struct f (virtual base) +// CHECK-NEXT: 16 | (f vftable pointer) +// CHECK-NEXT: sizeof=20, dsize=20, align=4 +// CHECK-NEXT: nvsize=12, nvalign=4 + +// CHECK: 0 | class IA +// CHECK-NEXT: 0 | (IA vftable pointer) +// CHECK-NEXT: sizeof=4, dsize=4, align=4 +// CHECK-NEXT: nvsize=4, nvalign=4 + +// CHECK: 0 | class ICh +// CHECK-NEXT: 0 | (ICh vftable pointer) +// CHECK-NEXT: 4 | (ICh vbtable pointer) +// CHECK-NEXT: 8 | (vtordisp for vbase IA) +// CHECK-NEXT: 12 | class IA (virtual base) +// CHECK-NEXT: 12 | (IA vftable pointer) +// CHECK-NEXT: sizeof=16, dsize=16, align=4 +// CHECK-NEXT: nvsize=8, nvalign=4 + +// CHECK: 0 | struct sd +// CHECK-NEXT: 0 | (sd vbtable pointer) +// CHECK-NEXT: 4 | int q +// CHECK-NEXT: 8 | char y +// CHECK-NEXT: 12 | (vtordisp for vbase f) +// CHECK-NEXT: 16 | struct f (virtual base) +// CHECK-NEXT: 16 | (f vftable pointer) +// CHECK-NEXT: 20 | struct s (virtual base) +// CHECK-NEXT: 20 | (s vftable pointer) +// CHECK-NEXT: 24 | (s vbtable pointer) +// CHECK-NEXT: 28 | int r +// CHECK-NEXT: 32 | (vtordisp for vbase IA) +// CHECK-NEXT: 36 | class IA (virtual base) +// CHECK-NEXT: 36 | (IA vftable pointer) +// CHECK-NEXT: 40 | class ICh (virtual base) +// CHECK-NEXT: 40 | (ICh vftable pointer) +// CHECK-NEXT: 44 | (ICh vbtable pointer) +// CHECK-NEXT: sizeof=48, dsize=48, align=4 +// CHECK-NEXT: nvsize=12, nvalign=4 + +// CHECK: %struct.f = type { i32 (...)** } +// CHECK: %struct.s = type { i32 (...)**, i32*, i32, [4 x i8], %struct.f } +// CHECK: %class.IA = type { i32 (...)** } +// CHECK: %class.ICh = type { i32 (...)**, i32*, [4 x i8], %class.IA } +// CHECK: %struct.sd = type { i32*, i32, i8, [7 x i8], %struct.f, %struct.s.base, [4 x i8], %class.IA, %class.ICh.base } + +// CHECK: 0 | struct AV +// CHECK-NEXT: 0 | (AV vftable pointer) +// CHECK-NEXT: sizeof=4, dsize=4, align=4 +// CHECK-NEXT: nvsize=4, nvalign=4 + + +// CHECK: 0 | struct BV +// CHECK-NEXT: 0 | struct AV (primary base) +// CHECK-NEXT: 0 | (AV vftable pointer) +// CHECK-NEXT: sizeof=4, dsize=4, align=4 +// CHECK-NEXT: nvsize=4, nvalign=4 + + +// CHECK: 0 | struct CV +// CHECK-NEXT: 0 | (CV vbtable pointer) +// CHECK-NEXT: 4 | (vtordisp for vbase BV) +// CHECK-NEXT: 8 | struct BV (virtual base) +// CHECK-NEXT: 8 | struct AV (primary base) +// CHECK-NEXT: 8 | (AV vftable pointer) +// CHECK-NEXT: sizeof=12, dsize=12, align=4 +// CHECK-NEXT: nvsize=4, nvalign=4 + +// CHECK: %struct.AV = type { i32 (...)** } +// CHECK: %struct.BV = type { %struct.AV } +// CHECK: %struct.CV = type { i32*, [4 x i8], %struct.BV } +// CHECK: %struct.CV.base = type { i32* } + +// CHECK: 0 | struct DV +// CHECK-NEXT: 0 | struct BV (primary base) +// CHECK-NEXT: 0 | struct AV (primary base) +// CHECK-NEXT: 0 | (AV vftable pointer) +// CHECK-NEXT: sizeof=4, dsize=4, align=4 +// CHECK-NEXT: nvsize=4, nvalign=4 + +// CHECK: %struct.DV = type { %struct.BV } + +// CHECK: 0 | struct EV +// CHECK-NEXT: 4 | struct CV (base) +// CHECK-NEXT: 4 | (CV vbtable pointer) +// CHECK-NEXT: 0 | struct DV (primary base) +// CHECK-NEXT: 0 | struct BV (primary base) +// CHECK-NEXT: 0 | struct AV (primary base) +// CHECK-NEXT: 0 | (AV vftable pointer) +// CHECK-NEXT: 8 | (vtordisp for vbase BV) +// CHECK-NEXT: 12 | struct BV (virtual base) +// CHECK-NEXT: 12 | struct AV (primary base) +// CHECK-NEXT: 12 | (AV vftable pointer) +// CHECK-NEXT: sizeof=16, dsize=16, align=4 +// CHECK-NEXT: nvsize=8, nvalign=4 + +// CHECK: %struct.EV = type { %struct.DV, %struct.CV.base, [4 x i8], %struct.BV } +// CHECK: %struct.EV.base = type { %struct.DV, %struct.CV.base } + +// Overriding a method means that all the vbases containing that +// method need a vtordisp. +namespace test1 { + struct A { virtual void foo(); }; + struct B : A {}; + struct C : virtual A, virtual B { C(); virtual void foo(); }; + void test() { C *c; } + +// CHECK: 0 | struct test1::C +// CHECK-NEXT: 0 | (C vbtable pointer) +// CHECK-NEXT: 4 | (vtordisp for vbase A) +// CHECK-NEXT: 8 | struct test1::A (virtual base) +// CHECK-NEXT: 8 | (A vftable pointer) +// CHECK-NEXT: 12 | (vtordisp for vbase B) +// CHECK-NEXT: 16 | struct test1::B (virtual base) +// CHECK-NEXT: 16 | struct test1::A (primary base) +// CHECK-NEXT: 16 | (A vftable pointer) +// CHECK-NEXT: sizeof=20, dsize=20, align=4 +// CHECK-NEXT: nvsize=4, nvalign=4 +} diff --git a/test/Sema/ms_wide_predefined_expr.cpp b/test/Sema/ms_wide_predefined_expr.cpp new file mode 100644 index 000000000000..8e816e00b37a --- /dev/null +++ b/test/Sema/ms_wide_predefined_expr.cpp @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -fsyntax-only -Wno-unused-value -Wmicrosoft -verify -fms-extensions + +// Wide character predefined identifiers +#define _STR2WSTR(str) L##str +#define STR2WSTR(str) _STR2WSTR(str) +void abcdefghi12(void) { + const wchar_t (*ss)[12] = &STR2WSTR(__FUNCTION__); + static int arr[sizeof(STR2WSTR(__FUNCTION__))==12*sizeof(wchar_t) ? 1 : -1]; +} + +namespace PR13206 { +void foo(const wchar_t *); + +template<class T> class A { +public: + void method() { + foo(L__FUNCTION__); + } +}; + +void bar() { + A<int> x; + x.method(); +} +} diff --git a/test/Sema/pragma-pack-6.c b/test/Sema/pragma-pack-6.c new file mode 100644 index 000000000000..40659c23bda8 --- /dev/null +++ b/test/Sema/pragma-pack-6.c @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -triple i686-apple-darwin9 %s -fsyntax-only -verify + +// Pragma pack handling with tag declarations + +struct X; + +#pragma pack(2) +struct X { int x; }; +struct Y; +#pragma pack() + +struct Y { int y; }; + +extern int check[__alignof(struct X) == 2 ? 1 : -1]; +extern int check[__alignof(struct Y) == 4 ? 1 : -1]; + diff --git a/test/Sema/switch.c b/test/Sema/switch.c index a7a7f6049215..e37d5da25926 100644 --- a/test/Sema/switch.c +++ b/test/Sema/switch.c @@ -9,7 +9,7 @@ void foo(int X) { switch (X) { case 42: ; // expected-note {{previous case}} case 5000000000LL: // expected-warning {{overflow}} - case 42: // expected-error {{duplicate case value}} + case 42: // expected-error {{duplicate case value '42'}} ; case 100 ... 99: ; // expected-warning {{empty case range}} @@ -320,3 +320,32 @@ void rdar110822110(Ints i) break; } } + +// PR9243 +#define TEST19MACRO 5 +void test19(int i) { + enum { + kTest19Enum1 = 7, + kTest19Enum2 = kTest19Enum1 + }; + const int a = 3; + switch (i) { + case 5: // expected-note {{previous case}} + case TEST19MACRO: // expected-error {{duplicate case value '5'}} + + case 7: // expected-note {{previous case}} + case kTest19Enum1: // expected-error {{duplicate case value: '7' and 'kTest19Enum1' both equal '7'}} \ + // expected-note {{previous case}} + case kTest19Enum1: // expected-error {{duplicate case value 'kTest19Enum1'}} \ + // expected-note {{previous case}} + case kTest19Enum2: // expected-error {{duplicate case value: 'kTest19Enum1' and 'kTest19Enum2' both equal '7'}} \ + // expected-note {{previous case}} + case (int)kTest19Enum2: //expected-error {{duplicate case value 'kTest19Enum2'}} + + case 3: // expected-note {{previous case}} + case a: // expected-error {{duplicate case value: '3' and 'a' both equal '3'}} \ + // expected-note {{previous case}} + case a: // expected-error {{duplicate case value 'a'}} + break; + } +} diff --git a/test/Sema/thread-specifier.c b/test/Sema/thread-specifier.c index 9ec88c521945..0d439b1669c1 100644 --- a/test/Sema/thread-specifier.c +++ b/test/Sema/thread-specifier.c @@ -1,19 +1,21 @@ -// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple i686-pc-linux-gnu -fsyntax-only -verify -pedantic %s __thread int t1; -__thread extern int t2; -__thread static int t3; +__thread extern int t2; // expected-warning {{'__thread' before 'extern'}} +__thread static int t3; // expected-warning {{'__thread' before 'static'}} __thread __private_extern__ int t4; struct t5 { __thread int x; }; // expected-error {{type name does not allow storage class to be specified}} __thread int t6(); // expected-error {{'__thread' is only allowed on variable declarations}} + int f(__thread int t7) { // expected-error {{'__thread' is only allowed on variable declarations}} __thread int t8; // expected-error {{'__thread' variables must have global storage}} - __thread extern int t9; - __thread static int t10; + extern __thread int t9; + static __thread int t10; __thread __private_extern__ int t11; __thread auto int t12; // expected-error {{'__thread' variables must have global storage}} __thread register int t13; // expected-error {{'__thread' variables must have global storage}} } + __thread typedef int t14; // expected-error {{'__thread' is only allowed on variable declarations}} __thread int t15; // expected-note {{previous definition is here}} int t15; // expected-error {{non-thread-local declaration of 't15' follows thread-local declaration}} diff --git a/test/Sema/tls.c b/test/Sema/tls.c new file mode 100644 index 000000000000..3b2a441bfea8 --- /dev/null +++ b/test/Sema/tls.c @@ -0,0 +1,20 @@ +// Test that TLS is correctly considered supported or unsupported for the +// different targets. + +// Linux supports TLS. +// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only %s +// RUN: %clang_cc1 -triple i386-pc-linux-gnu -fsyntax-only %s + +// Darwin supports TLS since 10.7. +// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s +// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only %s + +// FIXME: I thought it was supported actually? +// RUN: not %clang_cc1 -triple x86_64-pc-win32 -fsyntax-only %s +// RUN: not %clang_cc1 -triple i386-pc-win32 -fsyntax-only %s + +// OpenBSD does not suppport TLS. +// RUN: not %clang_cc1 -triple x86_64-pc-openbsd -fsyntax-only %s +// RUN: not %clang_cc1 -triple i386-pc-openbsd -fsyntax-only %s + +__thread int x; diff --git a/test/Sema/typeof-use-deprecated.c b/test/Sema/typeof-use-deprecated.c index 238e5019f121..1518c83701c1 100644 --- a/test/Sema/typeof-use-deprecated.c +++ b/test/Sema/typeof-use-deprecated.c @@ -1,25 +1,25 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only -struct s { int a; } __attribute__((deprecated)) x; // expected-warning {{'s' is deprecated}} +struct s { int a; } __attribute__((deprecated)) x; // expected-warning {{'s' is deprecated}} expected-note 2 {{'s' declared here}} typeof(x) y; // expected-warning {{'s' is deprecated}} -union un{ int a; } __attribute__((deprecated)) u; // expected-warning {{'un' is deprecated}} +union un{ int a; } __attribute__((deprecated)) u; // expected-warning {{'un' is deprecated}} expected-note 2 {{'un' declared here}} typeof( u) z; // expected-warning {{'un' is deprecated}} -enum E{ one} __attribute__((deprecated)) e; // expected-warning {{'E' is deprecated}} +enum E{ one} __attribute__((deprecated)) e; // expected-warning {{'E' is deprecated}} expected-note 2 {{'E' declared here}} typeof( e) w; // expected-warning {{'E' is deprecated}} -struct foo { int x; } __attribute__((deprecated)); -typedef struct foo bar __attribute__((deprecated)); +struct foo { int x; } __attribute__((deprecated)); // expected-note {{'foo' declared here}} +typedef struct foo bar __attribute__((deprecated)); // expected-note {{'bar' declared here}} bar x1; // expected-warning {{'bar' is deprecated}} int main() { typeof(x1) y; } // expected-warning {{'foo' is deprecated}} struct gorf { int x; }; -typedef struct gorf T __attribute__((deprecated)); +typedef struct gorf T __attribute__((deprecated)); // expected-note {{'T' declared here}} T t; // expected-warning {{'T' is deprecated}} void wee() { typeof(t) y; } diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c index d62186df731e..634ae0dc4284 100644 --- a/test/Sema/uninit-variables.c +++ b/test/Sema/uninit-variables.c @@ -39,17 +39,19 @@ int test6() { int test7(int y) { int x; // expected-note{{initialize the variable 'x' to silence this warning}} - if (y) + if (y) // expected-warning{{variable 'x' is used uninitialized whenever 'if' condition is false}} \ + // expected-note{{remove the 'if' if its condition is always true}} x = 1; - return x; // expected-warning{{variable 'x' may be uninitialized when used here}} + return x; // expected-note{{uninitialized use occurs here}} } int test7b(int y) { int x = x; // expected-note{{variable 'x' is declared here}} if (y) x = 1; - // Warn with "may be uninitialized" here (not "is uninitialized"), since the - // self-initialization is intended to suppress a -Wuninitialized warning. + // Warn with "may be uninitialized" here (not "is sometimes uninitialized"), + // since the self-initialization is intended to suppress a -Wuninitialized + // warning. return x; // expected-warning{{variable 'x' may be uninitialized when used here}} } @@ -150,15 +152,15 @@ int test19() { int test20() { int z; // expected-note{{initialize the variable 'z' to silence this warning}} - if ((test19_aux1() + test19_aux2() && test19_aux1()) || test19_aux3(&z)) - return z; // expected-warning{{variable 'z' may be uninitialized when used here}} + if ((test19_aux1() + test19_aux2() && test19_aux1()) || test19_aux3(&z)) // expected-warning {{variable 'z' is used uninitialized whenever '||' condition is true}} expected-note {{remove the '||' if its condition is always false}} + return z; // expected-note {{uninitialized use occurs here}} return 0; } int test21(int x, int y) { int z; // expected-note{{initialize the variable 'z' to silence this warning}} - if ((x && y) || test19_aux3(&z) || test19_aux2()) - return z; // expected-warning{{variable 'z' may be uninitialized when used here}} + if ((x && y) || test19_aux3(&z) || test19_aux2()) // expected-warning {{variable 'z' is used uninitialized whenever '||' condition is true}} expected-note {{remove the '||' if its condition is always false}} + return z; // expected-note {{uninitialized use occurs here}} return 0; } @@ -293,8 +295,9 @@ int test40(int x) { int test41(int x) { int y; // expected-note{{initialize the variable 'y' to silence this warning}} - if (x) y = 1; // no-warning - return y; // expected-warning {{variable 'y' may be uninitialized when used here}} + if (x) y = 1; // expected-warning{{variable 'y' is used uninitialized whenever 'if' condition is false}} \ + // expected-note{{remove the 'if' if its condition is always true}} + return y; // expected-note{{uninitialized use occurs here}} } void test42() { @@ -424,3 +427,84 @@ void rdar9432305(float *P) { for (; i < 10000; ++i) // expected-warning {{variable 'i' is uninitialized when used here}} P[i] = 0.0f; } + +// Test that fixits are not emitted inside macros. +#define UNINIT(T, x, y) T x; T y = x; +#define ASSIGN(T, x, y) T y = x; +void test54() { + UNINIT(int, a, b); // expected-warning {{variable 'a' is uninitialized when used here}} \ + // expected-note {{variable 'a' is declared here}} + int c; // expected-note {{initialize the variable 'c' to silence this warning}} + ASSIGN(int, c, d); // expected-warning {{variable 'c' is uninitialized when used here}} +} + +// Taking the address is fine +struct { struct { void *p; } a; } test55 = { { &test55.a }}; // no-warning +struct { struct { void *p; } a; } test56 = { { &(test56.a) }}; // no-warning + +void uninit_in_loop() { + int produce(void); + void consume(int); + for (int n = 0; n < 100; ++n) { + int k; // expected-note {{initialize}} + consume(k); // expected-warning {{variable 'k' is uninitialized}} + k = produce(); + } +} + +void uninit_in_loop_goto() { + int produce(void); + void consume(int); + for (int n = 0; n < 100; ++n) { + goto skip_decl; + int k; // expected-note {{initialize}} +skip_decl: + // FIXME: This should produce the 'is uninitialized' diagnostic, but we + // don't have enough information in the CFG to easily tell that the + // variable's scope has been left and re-entered. + consume(k); // expected-warning {{variable 'k' may be uninitialized}} + k = produce(); + } +} + +typedef char jmp_buf[256]; +extern int setjmp(jmp_buf env); // implicitly returns_twice + +void do_stuff_and_longjmp(jmp_buf env, int *result) __attribute__((noreturn)); + +int returns_twice() { + int a; // expected-note {{initialize}} + if (!a) { // expected-warning {{variable 'a' is uninitialized}} + jmp_buf env; + int b; + if (setjmp(env) == 0) { + do_stuff_and_longjmp(env, &b); + } else { + a = b; // no warning + } + } + return a; +} + +int compound_assign(int *arr, int n) { + int sum; // expected-note {{initialize}} + for (int i = 0; i < n; ++i) + sum += arr[i]; // expected-warning {{variable 'sum' is uninitialized}} + return sum / n; +} + +int compound_assign_2() { + int x; // expected-note {{initialize}} + return x += 1; // expected-warning {{variable 'x' is uninitialized}} +} + +int compound_assign_3() { + int x; // expected-note {{initialize}} + x *= 0; // expected-warning {{variable 'x' is uninitialized}} + return x; +} + +int self_init_in_cond(int *p) { + int n = ((p && (0 || 1)) && (n = *p)) ? n : -1; // ok + return n; +} diff --git a/test/Sema/unused-expr.c b/test/Sema/unused-expr.c index 97611168f1a2..056d09a8713b 100644 --- a/test/Sema/unused-expr.c +++ b/test/Sema/unused-expr.c @@ -82,7 +82,7 @@ void t5() { int fn1() __attribute__ ((warn_unused_result)); int fn2() __attribute__ ((pure)); -int fn3() __attribute__ ((const)); +int fn3() __attribute__ ((__const)); // rdar://6587766 int t6() { if (fn1() < 0 || fn2(2,1) < 0 || fn3(2) < 0) // no warnings @@ -92,6 +92,7 @@ int t6() { fn2(92, 21); // expected-warning {{ignoring return value of function declared with pure attribute}} fn3(42); // expected-warning {{ignoring return value of function declared with const attribute}} __builtin_fabsf(0); // expected-warning {{ignoring return value of function declared with const attribute}} + (void)0, fn1(); // expected-warning {{ignoring return value of function declared with warn_unused_result attribute}} return 0; } diff --git a/test/Sema/vector-ops.c b/test/Sema/vector-ops.c index 3ab75d0e1163..652a076c780f 100644 --- a/test/Sema/vector-ops.c +++ b/test/Sema/vector-ops.c @@ -13,7 +13,7 @@ void test1(v2u v2ua, v2s v2sa, v2f v2fa) { (void)(~v2fa); // expected-error{{invalid argument type 'v2f' to unary}} // Comparison operators - v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' from 'int __attribute__((ext_vector_type(2)))'}} + v2ua = (v2ua==v2sa); // expected-warning{{incompatible vector types assigning to 'v2u' from 'int __attribute__((ext_vector_type(2)))'}} v2sa = (v2ua==v2sa); // Arrays diff --git a/test/Sema/warn-documentation-almost-trailing.c b/test/Sema/warn-documentation-almost-trailing.c new file mode 100644 index 000000000000..fa17cac83a9d --- /dev/null +++ b/test/Sema/warn-documentation-almost-trailing.c @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// RUN: cp %s %t +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fixit %t +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -Werror %t + +struct a { + int x; //< comment // expected-warning {{not a Doxygen trailing comment}} + int y; /*< comment */ // expected-warning {{not a Doxygen trailing comment}} +}; + +// CHECK: fix-it:"{{.*}}":{8:10-8:13}:"///<" +// CHECK: fix-it:"{{.*}}":{9:10-9:13}:"/**<" + diff --git a/test/Sema/warn-documentation-fixits.cpp b/test/Sema/warn-documentation-fixits.cpp new file mode 100644 index 000000000000..732b44db027a --- /dev/null +++ b/test/Sema/warn-documentation-fixits.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s + +// expected-warning@+1 {{parameter 'ZZZZZZZZZZ' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}} +/// \param ZZZZZZZZZZ Blah blah. +int test1(int a); + +// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}} +/// \param aab Blah blah. +int test2(int aaa, int bbb); + +// expected-warning@+1 {{template parameter 'ZZZZZZZZZZ' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}} +/// \tparam ZZZZZZZZZZ Aaa +template<typename T> +void test3(T aaa); + +// expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}} +/// \tparam SomTy Aaa +/// \tparam OtherTy Bbb +template<typename SomeTy, typename OtherTy> +void test4(SomeTy aaa, OtherTy bbb); + +// CHECK: fix-it:"{{.*}}":{5:12-5:22}:"a" +// CHECK: fix-it:"{{.*}}":{9:12-9:15}:"aaa" +// CHECK: fix-it:"{{.*}}":{13:13-13:23}:"T" +// CHECK: fix-it:"{{.*}}":{18:13-18:18}:"SomeTy" + diff --git a/test/Sema/warn-documentation.cpp b/test/Sema/warn-documentation.cpp new file mode 100644 index 000000000000..16ba4297cdc4 --- /dev/null +++ b/test/Sema/warn-documentation.cpp @@ -0,0 +1,670 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s + +// This file contains lots of corner cases, so ensure that XML we generate is not invalid. +// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | FileCheck %s -check-prefix=WRONG +// WRONG-NOT: CommentXMLInvalid + +// expected-warning@+1 {{expected quoted string after equals sign}} +/// <a href=> +int test_html1(int); + +// expected-warning@+1 {{expected quoted string after equals sign}} +/// <a href==> +int test_html2(int); + +// expected-warning@+2 {{expected quoted string after equals sign}} +// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} +/// <a href= blah +int test_html3(int); + +// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} +/// <a => +int test_html4(int); + +// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} +/// <a "aaa"> +int test_html5(int); + +// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} +/// <a a="b" => +int test_html6(int); + +// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} +/// <a a="b" "aaa"> +int test_html7(int); + +// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} +/// <a a="b" = +int test_html8(int); + +// expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}} +/** Aaa bbb<ccc ddd eee + * fff ggg. + */ +int test_html9(int); + +// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} +/** Aaa bbb<ccc ddd eee 42% + * fff ggg. + */ +int test_html10(int); + +// expected-warning@+1 {{HTML end tag 'br' is forbidden}} +/// <br></br> +int test_html11(int); + +/// <blockquote>Meow</blockquote> +int test_html_nesting1(int); + +/// <b><i>Meow</i></b> +int test_html_nesting2(int); + +/// <p>Aaa<br> +/// Bbb</p> +int test_html_nesting3(int); + +/// <p>Aaa<br /> +/// Bbb</p> +int test_html_nesting4(int); + +// expected-warning@+1 {{HTML end tag does not match any start tag}} +/// <b><i>Meow</a> +int test_html_nesting5(int); + +// expected-warning@+2 {{HTML start tag 'i' closed by 'b'}} +// expected-warning@+1 {{HTML end tag does not match any start tag}} +/// <b><i>Meow</b></b> +int test_html_nesting6(int); + +// expected-warning@+2 {{HTML start tag 'i' closed by 'b'}} +// expected-warning@+1 {{HTML end tag does not match any start tag}} +/// <b><i>Meow</b></i> +int test_html_nesting7(int); + + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\returns Aaa +int test_block_command1(int); + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief \returns Aaa +int test_block_command2(int); + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief +/// \returns Aaa +int test_block_command3(int); + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief +/// +/// \returns Aaa +int test_block_command4(int); + +// There is trailing whitespace on one of the following lines, don't remove it! +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief +/// +/// \returns Aaa +int test_block_command5(int); + +/// \brief \c Aaa +int test_block_command6(int); + +// expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\brief' here}} +/// \brief Aaa +/// +/// Bbb +/// +/// \brief Ccc +int test_duplicate_brief1(int); + +// expected-warning@+5 {{duplicated command '\short'}} expected-note@+1 {{previous command '\short' here}} +/// \short Aaa +/// +/// Bbb +/// +/// \short Ccc +int test_duplicate_brief2(int); + +// expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\short' (an alias of '\brief') here}} +/// \short Aaa +/// +/// Bbb +/// +/// \brief Ccc +int test_duplicate_brief3(int); + + +// expected-warning@+5 {{duplicated command '\return'}} expected-note@+1 {{previous command '\return' here}} +/// \return Aaa +/// +/// Bbb +/// +/// \return Ccc +int test_duplicate_returns1(int); + +// expected-warning@+5 {{duplicated command '\returns'}} expected-note@+1 {{previous command '\returns' here}} +/// \returns Aaa +/// +/// Bbb +/// +/// \returns Ccc +int test_duplicate_returns2(int); + +// expected-warning@+5 {{duplicated command '\result'}} expected-note@+1 {{previous command '\result' here}} +/// \result Aaa +/// +/// Bbb +/// +/// \result Ccc +int test_duplicate_returns3(int); + +// expected-warning@+5 {{duplicated command '\return'}} expected-note@+1 {{previous command '\returns' (an alias of '\return') here}} +/// \returns Aaa +/// +/// Bbb +/// +/// \return Ccc +int test_duplicate_returns4(int); + + +// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}} +/// \param a Blah blah. +int test_param1; + +// expected-warning@+1 {{empty paragraph passed to '\param' command}} +/// \param +/// \param a Blah blah. +int test_param2(int a); + +// expected-warning@+1 {{empty paragraph passed to '\param' command}} +/// \param a +int test_param3(int a); + +/// \param a Blah blah. +int test_param4(int a); + +/// \param [in] a Blah blah. +int test_param5(int a); + +/// \param [out] a Blah blah. +int test_param6(int a); + +/// \param [in,out] a Blah blah. +int test_param7(int a); + +// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}} +/// \param [ in ] a Blah blah. +int test_param8(int a); + +// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}} +/// \param [in, out] a Blah blah. +int test_param9(int a); + +// expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}} +/// \param [ junk] a Blah blah. +int test_param10(int a); + +// expected-warning@+1 {{parameter 'a' not found in the function declaration}} +/// \param a Blah blah. +int test_param11(); + +// expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}} +/// \param A Blah blah. +int test_param12(int a); + +// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}} +/// \param aab Blah blah. +int test_param13(int aaa, int bbb); + +// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} +/// \param aab Blah blah. +int test_param14(int bbb, int ccc); + +class C { + // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}} + /// \param aaa Blah blah. + C(int bbb, int ccc); + + // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}} + /// \param aaa Blah blah. + int test_param15(int bbb, int ccc); +}; + +// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} +/// \param aab Blah blah. +template<typename T> +void test_param16(int bbb, int ccc); + +// expected-warning@+3 {{parameter 'a' is already documented}} +// expected-note@+1 {{previous documentation}} +/// \param a Aaa. +/// \param a Aaa. +int test_param17(int a); + +// expected-warning@+4 {{parameter 'x2' is already documented}} +// expected-note@+2 {{previous documentation}} +/// \param x1 Aaa. +/// \param x2 Bbb. +/// \param x2 Ccc. +int test_param18(int x1, int x2, int x3); + + +// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}} +/// \tparam T Aaa +int test_tparam1; + +// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}} +/// \tparam T Aaa +void test_tparam2(int aaa); + +// expected-warning@+1 {{empty paragraph passed to '\tparam' command}} +/// \tparam +/// \param aaa Blah blah +template<typename T> +void test_tparam3(T aaa); + +// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}} +/// \tparam T Aaa +template<typename TT> +void test_tparam4(TT aaa); + +// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}} +/// \tparam T Aaa +template<typename TT> +class test_tparam5 { + // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}} + /// \tparam T Aaa + template<typename TTT> + void test_tparam6(TTT aaa); +}; + +/// \tparam T1 Aaa +/// \tparam T2 Bbb +template<typename T1, typename T2> +void test_tparam7(T1 aaa, T2 bbb); + +// expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}} +/// \tparam SomTy Aaa +/// \tparam OtherTy Bbb +template<typename SomeTy, typename OtherTy> +void test_tparam8(SomeTy aaa, OtherTy bbb); + +// expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}} +/// \tparam T1 Aaa +/// \tparam T1 Bbb +template<typename T1, typename T2> +void test_tparam9(T1 aaa, T2 bbb); + +/// \tparam T Aaa +/// \tparam TT Bbb +template<template<typename T> class TT> +void test_tparam10(TT<int> aaa); + +/// \tparam T Aaa +/// \tparam TT Bbb +/// \tparam TTT Ccc +template<template<template<typename T> class TT, class C> class TTT> +void test_tparam11(); + +/// \tparam I Aaa +template<int I> +void test_tparam12(); + +template<typename T, typename U> +class test_tparam13 { }; + +/// \tparam T Aaa +template<typename T> +using test_tparam14 = test_tparam13<T, int>; + +// expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}} +/// \tparam U Aaa +template<typename T> +using test_tparam15 = test_tparam13<T, int>; + +// no-warning +/// \returns Aaa +int test_returns_right_decl_1(int); + +class test_returns_right_decl_2 { + // no-warning + /// \returns Aaa + int test_returns_right_decl_3(int); +}; + +// no-warning +/// \returns Aaa +template<typename T> +int test_returns_right_decl_4(T aaa); + +// no-warning +/// \returns Aaa +template<> +int test_returns_right_decl_4(int aaa); + +/// \returns Aaa +template<typename T> +T test_returns_right_decl_5(T aaa); + +// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} +/// \returns Aaa +int test_returns_wrong_decl_1; + +// expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}} +/// \return Aaa +int test_returns_wrong_decl_2; + +// expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}} +/// \result Aaa +int test_returns_wrong_decl_3; + +// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}} +/// \returns Aaa +void test_returns_wrong_decl_4(int); + +// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}} +/// \returns Aaa +template<typename T> +void test_returns_wrong_decl_5(T aaa); + +// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}} +/// \returns Aaa +template<> +void test_returns_wrong_decl_5(int aaa); + +// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} +/// \returns Aaa +struct test_returns_wrong_decl_6 { }; + +// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} +/// \returns Aaa +class test_returns_wrong_decl_7 { + // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}} + /// \returns Aaa + test_returns_wrong_decl_7(); + + // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}} + /// \returns Aaa + ~test_returns_wrong_decl_7(); +}; + +// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} +/// \returns Aaa +enum test_returns_wrong_decl_8 { + // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} + /// \returns Aaa + test_returns_wrong_decl_9 +}; + +// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}} +/// \returns Aaa +namespace test_returns_wrong_decl_10 { }; + + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +int test1; ///< \brief\author Aaa + +// expected-warning@+2 {{empty paragraph passed to '\brief' command}} +// expected-warning@+2 {{empty paragraph passed to '\brief' command}} +int test2, ///< \brief\author Aaa + test3; ///< \brief\author Aaa + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +int test4; ///< \brief + ///< \author Aaa + + +// Check that we attach the comment to the declaration during parsing in the +// following cases. The test is based on the fact that we don't parse +// documentation comments that are not attached to anything. + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +int test_attach1; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +int test_attach2(int); + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +struct test_attach3 { + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} + /// \brief\author Aaa + int test_attach4; + + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} + int test_attach5; ///< \brief\author Aaa + + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} + /// \brief\author Aaa + int test_attach6(int); +}; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +class test_attach7 { + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} + /// \brief\author Aaa + int test_attach8; + + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} + int test_attach9; ///< \brief\author Aaa + + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} + /// \brief\author Aaa + int test_attach10(int); +}; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +enum test_attach9 { + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} + /// \brief\author Aaa + test_attach10, + + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} + test_attach11 ///< \brief\author Aaa +}; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +struct test_noattach12 *test_attach13; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +typedef struct test_noattach14 *test_attach15; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +typedef struct test_attach16 { int a; } test_attach17; + +struct S { int a; }; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +struct S *test_attach18; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +typedef struct S *test_attach19; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +struct test_attach20; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +typedef struct test_attach21 { + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} + /// \brief\author Aaa + int test_attach22; +} test_attach23; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +namespace test_attach24 { + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} + /// \brief\author Aaa + namespace test_attach25 { + } +} + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +/// \tparam T Aaa +template<typename T> +void test_attach26(T aaa); + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +/// \tparam T Aaa +template<typename T, typename U> +void test_attach27(T aaa, U bbb); + +// expected-warning@+2 {{empty paragraph passed to '\brief' command}} +// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} +/// \brief\author Aaa +/// \tparam T Aaa +template<> +void test_attach27(int aaa, int bbb); + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +/// \tparam T Aaa +template<typename T> +class test_attach28 { + T aaa; +}; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +using test_attach29 = test_attach28<int>; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +/// \tparam T Aaa +template<typename T, typename U> +class test_attach30 { }; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +/// \tparam T Aaa +template<typename T> +class test_attach30<T, int> { }; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +template<> +class test_attach30<int, int> { }; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +template<typename T> +using test_attach31 = test_attach30<T, int>; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +/// \tparam T Aaa +template<typename T, typename U, typename V> +class test_attach32 { }; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +/// \tparam T Aaa +template<typename T, typename U> +class test_attach32<T, U, int> { }; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +/// \tparam T Aaa +template<typename T> +class test_attach32<T, int, int> { }; + +// expected-warning@+2 {{empty paragraph passed to '\brief' command}} +// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} +/// \brief\author Aaa +/// \tparam T Aaa +template<> +class test_attach32<int, int, int> { }; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +class test_attach33 { + // expected-warning@+1 {{empty paragraph passed to '\brief' command}} + /// \brief\author Aaa + /// \tparam T Aaa + template<typename T, typename U> + void test_attach34(T aaa, U bbb); +}; + +template<typename T> +class test_attach35 { + // expected-warning@+2 {{empty paragraph passed to '\brief' command}} + // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} + /// \brief\author Aaa + /// \tparam T Aaa + template<typename TT, typename UU> + void test_attach36(TT aaa, UU bbb); +}; + +// expected-warning@+2 {{empty paragraph passed to '\brief' command}} +// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} +/// \brief\author Aaa +/// \tparam T Aaa +template<> template<> +void test_attach35<int>::test_attach36(int aaa, int bbb) {} + +template<typename T> +class test_attach37 { + // expected-warning@+2 {{empty paragraph passed to '\brief' command}} + // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}} + /// \brief\author Aaa + /// \tparam T Aaa + void test_attach38(int aaa, int bbb); +}; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +/// \tparam T Aaa +template<typename T> +void test_attach37<T>::test_attach38(int aaa, int bbb) {} + +// expected-warning@+2 {{empty paragraph passed to '\brief' command}} +// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} +/// \brief\author Aaa +/// \tparam T Aaa +template<> +void test_attach37<int>::test_attach38(int aaa, int bbb) {} + + +// PR13411, reduced. We used to crash on this. +/** + * @code Aaa. + */ +void test_nocrash1(int); + +// We used to crash on this. +// expected-warning@+2 {{empty paragraph passed to '\param' command}} +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \param\brief +void test_nocrash2(int); + +// PR13593 + +/** +* Bla. +*/ +template <typename> +void test_nocrash3(); + +/// Foo +template <typename, typename> +void test_nocrash4() { } + +template <typename> +void test_nocrash3() +{ +} diff --git a/test/Sema/warn-documentation.m b/test/Sema/warn-documentation.m new file mode 100644 index 000000000000..d6af6edcc85d --- /dev/null +++ b/test/Sema/warn-documentation.m @@ -0,0 +1,93 @@ +// RUN: %clang_cc1 -fsyntax-only -Wno-objc-root-class -Wdocumentation -Wdocumentation-pedantic -verify %s + +@class NSString; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +@interface Test1 +// expected-warning@+2 {{empty paragraph passed to '\brief' command}} +/** + * \brief\author Aaa + * \param aaa Aaa + * \param bbb Bbb + */ ++ (NSString *)test1:(NSString *)aaa suffix:(NSString *)bbb; + +// expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'aaa'?}} +/** + * \param aab Aaa + */ ++ (NSString *)test2:(NSString *)aaa; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +@property int test3; // a property: ObjCPropertyDecl + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +@property int test4; // a property: ObjCPropertyDecl +@end + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +@interface Test1() +@end + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +@implementation Test1 // a class implementation : ObjCImplementationDecl ++ (NSString *)test1:(NSString *)aaa suffix:(NSString *)bbb { + return 0; +} + ++ (NSString *)test2:(NSString *)aaa { + return 0; +} + +@synthesize test3; // a property implementation: ObjCPropertyImplDecl +@dynamic test4; // a property implementation: ObjCPropertyImplDecl + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +NSString *_test5; +@end + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +@interface Test1(Test1Category) // a category: ObjCCategoryDecl +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa ++ (NSString *)test3:(NSString *)aaa; +@end + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +@implementation Test1(Test1Category) // a category implementation: ObjCCategoryImplDecl ++ (NSString *)test3:(NSString *)aaa { + return 0; +} +@end + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +@protocol TestProto1 // a protocol: ObjCProtocolDecl +@end + +int a; + +// expected-warning@+1 {{empty paragraph passed to '\brief' command}} +/// \brief\author Aaa +@interface Test4 +@end + +int b; + +@interface TestReturns1 +/// \returns Aaa +- (int)test1:(NSString *)aaa; + +// expected-warning@+1 {{'\returns' command used in a comment that is attached to a method returning void}} +/// \returns Aaa +- (void)test2:(NSString *)aaa; +@end + diff --git a/test/Sema/warn-outof-range-assign-enum.c b/test/Sema/warn-outof-range-assign-enum.c new file mode 100644 index 000000000000..2e79e66f49bd --- /dev/null +++ b/test/Sema/warn-outof-range-assign-enum.c @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wassign-enum %s +// rdar://11824807 + +typedef enum CCTestEnum +{ + One, + Two=4, + Three +} CCTestEnum; + +CCTestEnum test = 50; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}} +CCTestEnum test1 = -50; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}} + +CCTestEnum foo(CCTestEnum r) { + return 20; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}} +} + +enum Test2 { K_zero, K_one }; +enum Test2 test2(enum Test2 *t) { + *t = 20; // expected-warning {{integer constant not in range of enumerated type 'enum Test2'}} + return 10; // expected-warning {{integer constant not in range of enumerated type 'enum Test2'}} +} + +int main() { + CCTestEnum test = 1; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}} + test = 600; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}} + foo(2); // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}} + foo(-1); // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}} + foo(4); + foo(Two+1); +} + diff --git a/test/Sema/warn-self-assign-field.mm b/test/Sema/warn-self-assign-field.mm new file mode 100644 index 000000000000..3ba8d62b663f --- /dev/null +++ b/test/Sema/warn-self-assign-field.mm @@ -0,0 +1,66 @@ +// RUN: %clang_cc1 -fsyntax-only -Wno-objc-root-class -verify %s + +class S { + public: + int a_; + void s(int a) { + a_ = a_; // expected-warning {{assigning field to itself}} + + // Don't really care about this one either way. + this->a_ = a_; // expected-warning {{assigning field to itself}} + + a_ += a_; // Shouldn't warn. + } +}; + +void f0(S* s) { + // Would be nice to have, but not important. + s->a_ = s->a_; +} + +void f1(S* s, S* t) { + // Shouldn't warn. + t->a_ = s->a_; +} + +struct T { + S* s_; +}; + +void f2(T* t) { + // Would be nice to have, but even less important. + t->s_->a_ = t->s_->a_; +} + +void f3(T* t, T* t2) { + // Shouldn't warn. + t2->s_->a_ = t->s_->a_; +} + +void f4(int i) { + // This is a common pattern to silence "parameter unused". Shouldn't warn. + i = i; + + int j = 0; + j = j; // Likewise. +} + +@interface I { + int a_; +} +@end + +@implementation I +- (void)setA:(int)a { + a_ = a_; // expected-warning {{assigning instance variable to itself}} +} + +- (void)foo:(I*)i { + // Don't care much about this warning. + i->a_ = i->a_; // expected-warning {{assigning instance variable to itself}} + + // Shouldn't warn. + a_ = i->a_; + i->a_ = a_; +} +@end diff --git a/test/Sema/warn-strncat-size.c b/test/Sema/warn-strncat-size.c index 7157edffea47..dcc3367e9499 100644 --- a/test/Sema/warn-strncat-size.c +++ b/test/Sema/warn-strncat-size.c @@ -59,7 +59,7 @@ void size_1() { char z[1]; char str[] = "hi"; - strncat(z, str, sizeof(z)); // expected-warning{{the value of the size argument in 'strncat' is too large, might lead to a buffer overflow}} + strncat(z, str, sizeof(z)); // expected-warning{{the value of the size argument to 'strncat' is wrong}} } // Support VLAs. @@ -69,3 +69,8 @@ void vlas(int size) { strncat(z, str, sizeof(str)); // expected-warning {{size argument in 'strncat' call appears to be size of the source}} expected-note {{change the argument to be the free space in the destination buffer minus the terminating null byte}} } + +// Non-array type gets a different error message. +void f(char* s, char* d) { + strncat(d, s, sizeof(d)); // expected-warning {{the value of the size argument to 'strncat' is wrong}} +} diff --git a/test/SemaCXX/MicrosoftCompatibility.cpp b/test/SemaCXX/MicrosoftCompatibility.cpp index 3634fa346272..6a48f36801bd 100644 --- a/test/SemaCXX/MicrosoftCompatibility.cpp +++ b/test/SemaCXX/MicrosoftCompatibility.cpp @@ -1,6 +1,10 @@ // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -std=c++11 -Wmicrosoft -verify -fms-compatibility -fexceptions -fcxx-exceptions +typedef unsigned short char16_t; +typedef unsigned int char32_t; + +typename decltype(3) a; // expected-warning {{expected a qualified name after 'typename'}} namespace ms_conversion_rules { diff --git a/test/SemaCXX/MicrosoftCompatibilityNoExceptions.cpp b/test/SemaCXX/MicrosoftCompatibilityNoExceptions.cpp new file mode 100644 index 000000000000..d932b5dbbcea --- /dev/null +++ b/test/SemaCXX/MicrosoftCompatibilityNoExceptions.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify -fms-compatibility + +// PR13153 +namespace std {} +class type_info {}; +void f() { + (void)typeid(int); +} diff --git a/test/SemaCXX/PR10243.cpp b/test/SemaCXX/PR10243.cpp index 129ff80e2d2e..19a8b04e84fa 100644 --- a/test/SemaCXX/PR10243.cpp +++ b/test/SemaCXX/PR10243.cpp @@ -9,12 +9,12 @@ struct T0 { struct T1 { S s; // expected-error{{field has incomplete type 'S'}} - T1(T1&) = default; + T1(const T1&) = default; }; struct T2 { S s; // expected-error{{field has incomplete type 'S'}} - T2& operator=(T2&) = default; + T2& operator=(const T2&) = default; }; struct T3 { diff --git a/test/SemaCXX/abstract.cpp b/test/SemaCXX/abstract.cpp index b164d9eda6a5..e20a89009bd9 100644 --- a/test/SemaCXX/abstract.cpp +++ b/test/SemaCXX/abstract.cpp @@ -259,3 +259,17 @@ namespace pr9247 { }; }; } + +namespace pr12658 { + class C {
+ public:
+ C(int v){}
+ virtual void f() = 0; // expected-note {{unimplemented pure virtual method 'f' in 'C'}}
+ };
+
+ void foo( C& c ) {}
+
+ void bar( void ) {
+ foo(C(99)); // expected-error {{allocating an object of abstract class type 'pr12658::C'}}
+ } +} diff --git a/test/SemaCXX/address-of-temporary.cpp b/test/SemaCXX/address-of-temporary.cpp index eb5dee50598e..bb6cba3187f5 100644 --- a/test/SemaCXX/address-of-temporary.cpp +++ b/test/SemaCXX/address-of-temporary.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -Wno-error=address-of-temporary -verify %s -struct X { +// RUN: %clang_cc1 -fsyntax-only -Wno-error=address-of-temporary -verify -std=gnu++11 %s +struct X { X(); X(int); X(int, int); @@ -10,3 +10,39 @@ void f1() { (void)&X(1); } // expected-warning{{taking the address of a temporar void f2() { (void)&X(1, 2); } // expected-warning{{taking the address of a temporary object}} void f3() { (void)&(X)1; } // expected-warning{{taking the address of a temporary object}} + +namespace PointerToArrayDecay { + struct Y { + int a[4]; + }; + + typedef int A[4]; + + template<typename T> void consume(T); + struct S { int *p; }; + + void g0() { int *p = Y().a; } // expected-warning{{pointer is initialized by a temporary array}} + void g1() { int *p = Y{}.a; } // expected-warning{{pointer is initialized by a temporary array}} + void g2() { int *p = A{}; } // expected-warning{{pointer is initialized by a temporary array}} + void g3() { int *p = (A){}; } // expected-warning{{pointer is initialized by a temporary array}} + + void h0() { consume(Y().a); } + void h1() { consume(Y{}.a); } + void h2() { consume(A{}); } + void h3() { consume((A){}); } + + void i0() { S s = { Y().a }; } // expected-warning{{pointer is initialized by a temporary array}} + void i1() { S s = { Y{}.a }; } // expected-warning{{pointer is initialized by a temporary array}} + void i2() { S s = { A{} }; } // expected-warning{{pointer is initialized by a temporary array}} + void i3() { S s = { (A){} }; } // expected-warning{{pointer is initialized by a temporary array}} + + void j0() { (void)S { Y().a }; } + void j1() { (void)S { Y{}.a }; } + void j2() { (void)S { A{} }; } + void j3() { (void)S { (A){} }; } + + void k0() { consume(S { Y().a }); } + void k1() { consume(S { Y{}.a }); } + void k2() { consume(S { A{} }); } + void k3() { consume(S { (A){} }); } +} diff --git a/test/SemaCXX/alias-template.cpp b/test/SemaCXX/alias-template.cpp index 484dd3379ed7..4bf79f851e0b 100644 --- a/test/SemaCXX/alias-template.cpp +++ b/test/SemaCXX/alias-template.cpp @@ -145,3 +145,30 @@ namespace Curried { template<typename T, typename U> struct S; template<typename T> template<typename U> using SS = S<T, U>; // expected-error {{extraneous template parameter list in alias template declaration}} } + +// PR12647 +namespace SFINAE { + template<bool> struct enable_if; // expected-note 2{{here}} + template<> struct enable_if<true> { using type = void; }; + + template<typename T> struct is_enum { static constexpr bool value = __is_enum(T); }; + + template<typename T> using EnableIf = typename enable_if<T::value>::type; // expected-error {{undefined template}} + template<typename T> using DisableIf = typename enable_if<!T::value>::type; // expected-error {{undefined template}} + + template<typename T> EnableIf<is_enum<T>> f(); + template<typename T> DisableIf<is_enum<T>> f(); + + enum E { e }; + + int main() { + f<int>(); + f<E>(); + } + + template<typename T, typename U = EnableIf<is_enum<T>>> struct fail1 {}; // expected-note {{here}} + template<typename T> struct fail2 : DisableIf<is_enum<T>> {}; // expected-note {{here}} + + fail1<int> f1; // expected-note {{here}} + fail2<E> f2; // expected-note {{here}} +} diff --git a/test/SemaCXX/altivec.cpp b/test/SemaCXX/altivec.cpp index 39421b7c40f4..9de1f04b697c 100644 --- a/test/SemaCXX/altivec.cpp +++ b/test/SemaCXX/altivec.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -faltivec -fno-lax-vector-conversions -triple powerpc-unknown-unknown -verify %s +// RUN: %clang_cc1 -faltivec -fno-lax-vector-conversions -triple powerpc-unknown-unknown -fcxx-exceptions -verify %s typedef int V4i __attribute__((vector_size(16))); @@ -76,3 +76,8 @@ namespace LValueToRValueConversions { vector float initFloat = (vector float)(Struct().f); // expected-error {{did you mean to call it}} vector int initInt = (vector int)(Struct().n); // expected-error {{did you mean to call it}} } + +void f() { + try {} + catch (vector pixel px) {} +}; diff --git a/test/SemaCXX/anonymous-union-cxx11.cpp b/test/SemaCXX/anonymous-union-cxx11.cpp new file mode 100644 index 000000000000..8e682ebcda3d --- /dev/null +++ b/test/SemaCXX/anonymous-union-cxx11.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -pedantic %s + +namespace PR12866 { + struct bar { + union { + int member; + }; + }; + + void foo( void ) { + (void)sizeof(bar::member); + } +} diff --git a/test/SemaCXX/array-bound-merge.cpp b/test/SemaCXX/array-bound-merge.cpp index 74f58fa12360..8fb2ec52a9ee 100644 --- a/test/SemaCXX/array-bound-merge.cpp +++ b/test/SemaCXX/array-bound-merge.cpp @@ -7,3 +7,5 @@ extern int b[10]; int b[]; extern int c[1]; int c[] = {1,2}; // expected-error {{excess elements in array initializer}} + +int d[1][]; // expected-error {{array has incomplete element type 'int []'}} diff --git a/test/SemaCXX/arrow-operator.cpp b/test/SemaCXX/arrow-operator.cpp index 6535a0a2f201..173ff729fc1b 100644 --- a/test/SemaCXX/arrow-operator.cpp +++ b/test/SemaCXX/arrow-operator.cpp @@ -36,3 +36,31 @@ void f() Line_Segment(node1->Location()); // expected-error {{not a structure or union}} } } + + +namespace arrow_suggest { + +template <typename T> +class wrapped_ptr { + public: + wrapped_ptr(T* ptr) : ptr_(ptr) {} + T* operator->() { return ptr_; } + void Check(); // expected-note {{'Check' declared here}} + private: + T *ptr_; +}; + +class Worker { + public: + void DoSomething(); + void Chuck(); +}; + +void test() { + wrapped_ptr<Worker> worker(new Worker); + worker.DoSomething(); // expected-error {{no member named 'DoSomething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean to use '->' instead of '.'?}} + worker.DoSamething(); // expected-error {{no member named 'DoSamething' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'}} + worker.Chuck(); // expected-error {{no member named 'Chuck' in 'arrow_suggest::wrapped_ptr<arrow_suggest::Worker>'; did you mean 'Check'?}} +} + +} // namespace arrow_suggest diff --git a/test/SemaCXX/attr-deprecated.cpp b/test/SemaCXX/attr-deprecated.cpp index 46568aabd677..f3d818a75f35 100644 --- a/test/SemaCXX/attr-deprecated.cpp +++ b/test/SemaCXX/attr-deprecated.cpp @@ -1,10 +1,10 @@ // RUN: %clang_cc1 %s -verify -fsyntax-only class A { - void f() __attribute__((deprecated)); + void f() __attribute__((deprecated)); // expected-note 2 {{declared here}} void g(A* a); void h(A* a) __attribute__((deprecated)); - int b __attribute__((deprecated)); + int b __attribute__((deprecated)); // expected-note 2 {{declared here}} }; void A::g(A* a) @@ -26,7 +26,7 @@ void A::h(A* a) } struct B { - virtual void f() __attribute__((deprecated)); + virtual void f() __attribute__((deprecated)); // expected-note 4 {{declared here}} void g(); }; @@ -68,20 +68,20 @@ void f(D* d) { // Overloaded namespace members. namespace test1 { - void foo(int) __attribute__((deprecated)); + void foo(int) __attribute__((deprecated)); // expected-note {{declared here}} void test1() { foo(10); } // expected-warning {{deprecated}} - void foo(short) __attribute__((deprecated)); + void foo(short) __attribute__((deprecated)); // expected-note {{declared here}} void test2(short s) { foo(s); } // expected-warning {{deprecated}} void foo(long); void test3(long l) { foo(l); } struct A { - friend void foo(A*) __attribute__((deprecated)); + friend void foo(A*) __attribute__((deprecated)); // expected-note {{declared here}} }; void test4(A *a) { foo(a); } // expected-warning {{deprecated}} namespace ns { struct Foo {}; - void foo(const Foo &f) __attribute__((deprecated)); + void foo(const Foo &f) __attribute__((deprecated)); // expected-note {{declared here}} } void test5() { foo(ns::Foo()); // expected-warning {{deprecated}} @@ -91,9 +91,9 @@ namespace test1 { // Overloaded class members. namespace test2 { struct A { - void foo(int) __attribute__((deprecated)); + void foo(int) __attribute__((deprecated)); // expected-note 2 {{declared here}} void foo(long); - static void bar(int) __attribute__((deprecated)); + static void bar(int) __attribute__((deprecated)); // expected-note 3 {{declared here}} static void bar(long); void test2(int i, long l); @@ -120,12 +120,12 @@ namespace test2 { namespace test3 { struct A { void operator*(const A &); - void operator*(int) __attribute__((deprecated)); + void operator*(int) __attribute__((deprecated)); // expected-note {{declared here}} void operator-(const A &) const; }; void operator+(const A &, const A &); - void operator+(const A &, int) __attribute__((deprecated)); - void operator-(const A &, int) __attribute__((deprecated)); + void operator+(const A &, int) __attribute__((deprecated)); // expected-note {{declared here}} + void operator-(const A &, int) __attribute__((deprecated)); // expected-note {{declared here}} void test() { A a, b; @@ -143,9 +143,9 @@ namespace test4 { struct A { typedef void (*intfn)(int); typedef void (*unintfn)(unsigned); - operator intfn() __attribute__((deprecated)); + operator intfn() __attribute__((deprecated)); // expected-note {{declared here}} operator unintfn(); - void operator ()(A &) __attribute__((deprecated)); + void operator ()(A &) __attribute__((deprecated)); // expected-note {{declared here}} void operator ()(const A &); }; @@ -163,7 +163,7 @@ namespace test4 { namespace test5 { struct A { - operator int() __attribute__((deprecated)); + operator int() __attribute__((deprecated)); // expected-note 3 {{declared here}} operator long(); }; void test1(A a) { @@ -193,8 +193,8 @@ namespace test5 { // rdar://problem/8518751 namespace test6 { - enum __attribute__((deprecated)) A { - a0 + enum __attribute__((deprecated)) A { // expected-note {{declared here}} + a0 // expected-note {{declared here}} }; void testA() { A x; // expected-warning {{'A' is deprecated}} @@ -202,7 +202,7 @@ namespace test6 { } enum B { - b0 __attribute__((deprecated)), + b0 __attribute__((deprecated)), // expected-note {{declared here}} b1 }; void testB() { @@ -212,8 +212,8 @@ namespace test6 { } template <class T> struct C { - enum __attribute__((deprecated)) Enum { - c0 + enum __attribute__((deprecated)) Enum { // expected-note {{declared here}} + c0 // expected-note {{declared here}} }; }; void testC() { @@ -224,7 +224,7 @@ namespace test6 { template <class T> struct D { enum Enum { d0, - d1 __attribute__((deprecated)), + d1 __attribute__((deprecated)), // expected-note {{declared here}} }; }; void testD() { diff --git a/test/SemaCXX/attr-visibility.cpp b/test/SemaCXX/attr-visibility.cpp new file mode 100644 index 000000000000..05aa5a33c72e --- /dev/null +++ b/test/SemaCXX/attr-visibility.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +template <class Element> +void foo() { +} +template <> + __attribute__((visibility("hidden"))) // expected-note {{previous attribute is here}} +void foo<int>(); + +template <> +void foo<int>(); + +template <> + __attribute__((visibility("default"))) // expected-error {{visibility does not match previous declaration}} +void foo<int>() { +} + +struct x3 { + static int y; +} __attribute((visibility("default"))); // expected-warning {{attribute 'visibility' after definition is ignored}} diff --git a/test/SemaCXX/bool.cpp b/test/SemaCXX/bool.cpp index 2b3ab68848eb..f027186735b3 100644 --- a/test/SemaCXX/bool.cpp +++ b/test/SemaCXX/bool.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion %s // Bool literals can be enum values. enum { diff --git a/test/SemaCXX/condition.cpp b/test/SemaCXX/condition.cpp index 993f8e1d7761..ec5eb17b08f3 100644 --- a/test/SemaCXX/condition.cpp +++ b/test/SemaCXX/condition.cpp @@ -7,7 +7,7 @@ void test() { typedef int arr[10]; while (arr x=0) ; // expected-error {{an array type is not allowed here}} expected-error {{array initializer must be an initializer list}} - while (int f()=0) ; // expected-warning {{interpreted as a function declaration}} expected-note {{initializer}} expected-error {{a function type is not allowed here}} + while (int f()=0) ; // expected-error {{a function type is not allowed here}} struct S {} s; if (s) ++x; // expected-error {{value of type 'struct S' is not contextually convertible to 'bool'}} diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp index 4aee913277e5..a80eda416f4e 100644 --- a/test/SemaCXX/conditional-expr.cpp +++ b/test/SemaCXX/conditional-expr.cpp @@ -2,7 +2,7 @@ // C++ rules for ?: are a lot stricter than C rules, and have to take into // account more conversion options. -// This test runs in C++0x mode for the contextual conversion of the condition. +// This test runs in C++11 mode for the contextual conversion of the condition. struct ToBool { explicit operator bool(); }; @@ -328,3 +328,27 @@ namespace PR9236 { (void)(true ? (void*)0 : A()); // expected-error{{incompatible operand types}} } } + +namespace DR587 { + template<typename T> + const T *f(bool b) { + static T t1 = T(); + static const T t2 = T(); + return &(b ? t1 : t2); + } + struct S {}; + template const int *f(bool); + template const S *f(bool); + + extern bool b; + int i = 0; + const int ci = 0; + volatile int vi = 0; + const volatile int cvi = 0; + + const int &cir = b ? i : ci; + volatile int &vir = b ? vi : i; + const volatile int &cvir1 = b ? ci : cvi; + const volatile int &cvir2 = b ? cvi : vi; + const volatile int &cvir3 = b ? ci : vi; // expected-error{{volatile lvalue reference to type 'const volatile int' cannot bind to a temporary of type 'int'}} +} diff --git a/test/SemaCXX/constant-expression-cxx11.cpp b/test/SemaCXX/constant-expression-cxx11.cpp index 9f80e7169bb1..a3ead79a8456 100644 --- a/test/SemaCXX/constant-expression-cxx11.cpp +++ b/test/SemaCXX/constant-expression-cxx11.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i686-linux -Wno-string-plus-int -fsyntax-only -verify -std=c++11 -pedantic %s -Wno-comment +// RUN: %clang_cc1 -triple i686-linux -Wno-string-plus-int -fsyntax-only -fcxx-exceptions -verify -std=c++11 -pedantic %s -Wno-comment namespace StaticAssertFoldTest { @@ -494,6 +494,27 @@ struct ArrayRVal { }; static_assert(ArrayRVal().elems[3].f() == 0, ""); +constexpr int selfref[2][2][2] = { + selfref[1][1][1] + 1, selfref[0][0][0] + 1, + selfref[1][0][1] + 1, selfref[0][1][0] + 1, + selfref[1][0][0] + 1, selfref[0][1][1] + 1 }; +static_assert(selfref[0][0][0] == 1, ""); +static_assert(selfref[0][0][1] == 2, ""); +static_assert(selfref[0][1][0] == 1, ""); +static_assert(selfref[0][1][1] == 2, ""); +static_assert(selfref[1][0][0] == 1, ""); +static_assert(selfref[1][0][1] == 3, ""); +static_assert(selfref[1][1][0] == 0, ""); +static_assert(selfref[1][1][1] == 0, ""); + +struct TrivialDefCtor { int n; }; +typedef TrivialDefCtor TDCArray[2][2]; +static_assert(TDCArray{}[1][1].n == 0, ""); + +struct NonAggregateTDC : TrivialDefCtor {}; +typedef NonAggregateTDC NATDCArray[2][2]; +static_assert(NATDCArray{}[1][1].n == 0, ""); + } namespace DependentValues { @@ -689,10 +710,16 @@ static_assert(&ok2 == pok2, ""); static_assert((Base2*)(Derived*)(Base*)pb1 == pok2, ""); static_assert((Derived*)(Base*)pb1 == (Derived*)pok2, ""); -constexpr Base *nullB = 42 - 6 * 7; +constexpr Base *nullB = 42 - 6 * 7; // expected-warning {{expression which evaluates to zero treated as a null pointer constant of type 'Class::Base *const'}} static_assert((Bottom*)nullB == 0, ""); static_assert((Derived*)nullB == 0, ""); static_assert((void*)(Bottom*)nullB == (void*)(Derived*)nullB, ""); +Base * nullB2 = '\0'; // expected-warning {{expression which evaluates to zero treated as a null pointer constant of type 'Class::Base *'}} +Base * nullB3 = (0); +// We suppress the warning in unevaluated contexts to workaround some gtest +// behavior. Once this becomes an error this isn't a problem anymore. +static_assert(nullB == (1 - 1), ""); + namespace ConversionOperators { @@ -1213,6 +1240,17 @@ namespace RecursiveOpaqueExpr { constexpr int arr2[] = { 1, 0, 0, 3, 0, 2, 0, 4, 0, 5 }; static_assert(LastNonzero(begin(arr2), end(arr2)) == 5, ""); + + constexpr int arr3[] = { + 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, + 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, + 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, + 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, + 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, + 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, + 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + static_assert(LastNonzero(begin(arr3), end(arr3)) == 2, ""); } namespace VLASizeof { @@ -1248,3 +1286,91 @@ namespace Vector { } constexpr auto v2 = g(4); } + +// PR12626, redux +namespace InvalidClasses { + void test0() { + struct X; // expected-note {{forward declaration}} + struct Y { bool b; X x; }; // expected-error {{field has incomplete type}} + Y y; + auto& b = y.b; + } +} + +// Constructors can be implicitly constexpr, even for a non-literal type. +namespace ImplicitConstexpr { + struct Q { Q() = default; Q(const Q&) = default; Q(Q&&) = default; ~Q(); }; // expected-note 3{{here}} + struct R { constexpr R() noexcept; constexpr R(const R&) noexcept; constexpr R(R&&) noexcept; ~R() noexcept; }; + struct S { R r; }; // expected-note 3{{here}} + struct T { T(const T&) noexcept; T(T &&) noexcept; ~T() noexcept; }; + struct U { T t; }; // expected-note 3{{here}} + static_assert(!__is_literal_type(Q), ""); + static_assert(!__is_literal_type(R), ""); + static_assert(!__is_literal_type(S), ""); + static_assert(!__is_literal_type(T), ""); + static_assert(!__is_literal_type(U), ""); + struct Test { + friend Q::Q() noexcept; // expected-error {{follows constexpr}} + friend Q::Q(Q&&) noexcept; // expected-error {{follows constexpr}} + friend Q::Q(const Q&) noexcept; // expected-error {{follows constexpr}} + friend S::S() noexcept; // expected-error {{follows constexpr}} + friend S::S(S&&) noexcept; // expected-error {{follows constexpr}} + friend S::S(const S&) noexcept; // expected-error {{follows constexpr}} + friend constexpr U::U() noexcept; // expected-error {{follows non-constexpr}} + friend constexpr U::U(U&&) noexcept; // expected-error {{follows non-constexpr}} + friend constexpr U::U(const U&) noexcept; // expected-error {{follows non-constexpr}} + }; +} + +// Indirectly test that an implicit lvalue to xvalue conversion performed for +// an NRVO move operation isn't implemented as CK_LValueToRValue. +namespace PR12826 { + struct Foo {}; + constexpr Foo id(Foo x) { return x; } + constexpr Foo res(id(Foo())); +} + +namespace PR13273 { + struct U { + int t; + U() = default; + }; + + struct S : U { + S() = default; + }; + + // S's default constructor isn't constexpr, because U's default constructor + // doesn't initialize 't', but it's trivial, so value-initialization doesn't + // actually call it. + static_assert(S{}.t == 0, ""); +} + +namespace PR12670 { + struct S { + constexpr S(int a0) : m(a0) {} + constexpr S() : m(6) {} + int m; + }; + constexpr S x[3] = { {4}, 5 }; + static_assert(x[0].m == 4, ""); + static_assert(x[1].m == 5, ""); + static_assert(x[2].m == 6, ""); +} + +// Indirectly test that an implicit lvalue-to-rvalue conversion is performed +// when a conditional operator has one argument of type void and where the other +// is a glvalue of class type. +namespace ConditionalLValToRVal { + struct A { + constexpr A(int a) : v(a) {} + int v; + }; + + constexpr A f(const A &a) { + return a.v == 0 ? throw a : a; + } + + constexpr A a(4); + static_assert(f(a).v == 4, ""); +} diff --git a/test/SemaCXX/constant-expression.cpp b/test/SemaCXX/constant-expression.cpp index 23a4dda70838..ec50cb7d92fc 100644 --- a/test/SemaCXX/constant-expression.cpp +++ b/test/SemaCXX/constant-expression.cpp @@ -115,5 +115,12 @@ int array2[recurse2]; // expected-warning {{variable length array}} expected-war namespace FloatConvert { typedef int a[(int)42.3]; typedef int a[(int)42.997]; - typedef int b[(int)4e10]; // expected-warning {{variable length}} expected-error {{variable length}} + typedef int b[(long long)4e20]; // expected-warning {{variable length}} expected-error {{variable length}} expected-warning {{'long long' is an extension}} +} + +// PR12626 +namespace test3 { + struct X; // expected-note {{forward declaration of 'test3::X'}} + struct Y { bool b; X x; }; // expected-error {{field has incomplete type 'test3::X'}} + int f() { return Y().b; } } diff --git a/test/SemaCXX/constexpr-many-arguments.cpp b/test/SemaCXX/constexpr-many-arguments.cpp new file mode 100644 index 000000000000..3b5e974b3328 --- /dev/null +++ b/test/SemaCXX/constexpr-many-arguments.cpp @@ -0,0 +1,42 @@ +// RUN: %clang_cc1 -std=c++11 -fsyntax-only %s +// PR13197 + +struct type1 +{ + constexpr type1(int a0) : my_data{a0} {} + int my_data[1]; +}; + +struct type2 +{ + typedef type1 T; + constexpr type2(T a00, T a01, T a02, T a03, T a04, T a05, T a06, T a07, T a08, T a09, + T a10, T a11, T a12, T a13, T a14, T a15, T a16, T a17, T a18, T a19, + T a20, T a21, T a22) + : my_data{a00, a01, a02, a03, a04, a05, a06, a07, a08, a09, + a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, + a20, a21, a22} + {} + type1 my_data[23]; +}; + +struct type3 +{ + constexpr type3(type2 a0, type2 a1) : my_data{a0, a1} {} + type2 my_data[2]; +}; + +constexpr type3 g +{ + { + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, + {0},{0},{0} + }, + { + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, + {0},{0},{0},{0},{0},{0},{0},{0},{0},{0}, + {0},{0},{0} + } +}; + diff --git a/test/SemaCXX/constructor-initializer.cpp b/test/SemaCXX/constructor-initializer.cpp index e8b7f0b6760b..f503d01f360d 100644 --- a/test/SemaCXX/constructor-initializer.cpp +++ b/test/SemaCXX/constructor-initializer.cpp @@ -126,21 +126,24 @@ struct Q { // A silly class used to demonstrate field-is-uninitialized in constructors with // multiple params. +int IntParam(int i) { return 0; }; class TwoInOne { public: TwoInOne(TwoInOne a, TwoInOne b) {} }; class InitializeUsingSelfTest { bool A; char* B; int C; TwoInOne D; - InitializeUsingSelfTest(int E) + int E; + InitializeUsingSelfTest(int F) : A(A), // expected-warning {{field is uninitialized when used here}} B((((B)))), // expected-warning {{field is uninitialized when used here}} C(A && InitializeUsingSelfTest::C), // expected-warning {{field is uninitialized when used here}} D(D, // expected-warning {{field is uninitialized when used here}} - D) {} // expected-warning {{field is uninitialized when used here}} + D), // expected-warning {{field is uninitialized when used here}} + E(IntParam(E)) {} // expected-warning {{field is uninitialized when used here}} }; -int IntWrapper(int i) { return 0; }; +int IntWrapper(int &i) { return 0; }; class InitializeUsingSelfExceptions { int A; int B; @@ -229,13 +232,13 @@ namespace PR7402 { // <rdar://problem/8308215>: don't crash. // Lots of questionable recovery here; errors can change. namespace test3 { - class A : public std::exception {}; // expected-error {{undeclared identifier}} expected-error {{expected class name}} expected-note 3 {{candidate}} expected-note {{passing argument}} + class A : public std::exception {}; // expected-error {{undeclared identifier}} expected-error {{expected class name}} expected-note 2 {{candidate}} class B : public A { public: B(const String& s, int e=0) // expected-error {{unknown type name}} : A(e), m_String(s) , m_ErrorStr(__null) {} // expected-error {{no matching constructor}} expected-error {{does not name}} B(const B& e) - : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error {{no viable conversion}} expected-error {{does not name}} + : A(e), m_String(e.m_String), m_ErrorStr(__null) { // expected-error {{does not name}} expected-error {{no member named 'm_String' in 'test3::B'}} } }; } diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp index a7a178244c80..6fca0503ba72 100644 --- a/test/SemaCXX/conversion-function.cpp +++ b/test/SemaCXX/conversion-function.cpp @@ -392,3 +392,14 @@ namespace PR8800 { A& a4 = (A&)c; } } + +namespace PR12712 { + struct A {}; + struct B { + operator A(); + operator A() const; + }; + struct C : B {}; + + A f(const C c) { return c; } +} diff --git a/test/SemaCXX/conversion.cpp b/test/SemaCXX/conversion.cpp index a64b18721a5f..ac235cc7feaf 100644 --- a/test/SemaCXX/conversion.cpp +++ b/test/SemaCXX/conversion.cpp @@ -65,19 +65,69 @@ void test3() { int c = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to 'int'}} int d; d = ((((NULL)))); // expected-warning {{implicit conversion of NULL constant to 'int'}} - bool bl = NULL; // FIXME: this should warn but we currently suppress a bunch of conversion-to-bool warnings including this one + bool bl = NULL; // expected-warning {{implicit conversion of NULL constant to 'bool'}} char ch = NULL; // expected-warning {{implicit conversion of NULL constant to 'char'}} unsigned char uch = NULL; // expected-warning {{implicit conversion of NULL constant to 'unsigned char'}} short sh = NULL; // expected-warning {{implicit conversion of NULL constant to 'short'}} + double dbl = NULL; // expected-warning {{implicit conversion of NULL constant to 'double'}} // Use FileCheck to ensure we don't get any unnecessary macro-expansion notes // (that don't appear as 'real' notes & can't be seen/tested by -verify) // CHECK-NOT: note: - // CHECK: note: expanded from macro 'FNULL' -#define FNULL NULL - int a2 = FNULL; // expected-warning {{implicit conversion of NULL constant to 'int'}} - // CHECK-NOT: note: // CHECK: note: expanded from macro 'FINIT' #define FINIT int a3 = NULL; FINIT // expected-warning {{implicit conversion of NULL constant to 'int'}} + + // we don't catch the case of #define FOO NULL ... int i = FOO; but that seems a bit narrow anyway + // and avoiding that helps us skip these cases: +#define NULL_COND(cond) ((cond) ? &a : NULL) + bool bl2 = NULL_COND(true); // don't warn on NULL conversion through the conditional operator across a macro boundary + if (NULL_COND(true)) + ; + while (NULL_COND(true)) + ; + for (; NULL_COND(true); ) + ; + do ; + while(NULL_COND(true)); + int *ip = NULL; + int (*fp)() = NULL; + struct foo { + int n; + void func(); + }; + int foo::*datamem = NULL; + int (foo::*funmem)() = NULL; +} + +namespace test4 { + // FIXME: We should warn for non-dependent args (only when the param type is also non-dependent) only once + // not once for the template + once for every instantiation + template<typename T> + void tmpl(char c = NULL, // expected-warning 4 {{implicit conversion of NULL constant to 'char'}} + T a = NULL, // expected-warning {{implicit conversion of NULL constant to 'char'}} \ + expected-warning 2 {{implicit conversion of NULL constant to 'int'}} + T b = 1024) { // expected-warning {{implicit conversion from 'int' to 'char' changes value from 1024 to 0}} + } + + template<typename T> + void tmpl2(T t = NULL) { + } + + void func() { + tmpl<char>(); // expected-note 2 {{in instantiation of default function argument expression for 'tmpl<char>' required here}} + tmpl<int>(); // expected-note 2 {{in instantiation of default function argument expression for 'tmpl<int>' required here}} + // FIXME: We should warn only once for each template instantiation - not once for each call + tmpl<int>(); // expected-note 2 {{in instantiation of default function argument expression for 'tmpl<int>' required here}} + tmpl2<int*>(); + } +} + +namespace test5 { + template<int I> + void func() { + bool b = I; + } + + template void func<3>(); } diff --git a/test/SemaCXX/crashes.cpp b/test/SemaCXX/crashes.cpp index b77248ef4104..d02704c87c74 100644 --- a/test/SemaCXX/crashes.cpp +++ b/test/SemaCXX/crashes.cpp @@ -104,3 +104,35 @@ namespace PR10270 { return; } } + +namespace rdar11806334 { + +class cc_YCbCr; + +class cc_rgb +{ + public: + cc_rgb( uint p ); // expected-error {{unknown type name}} + cc_rgb( cc_YCbCr v_in ); +}; + +class cc_hsl +{ + public: + cc_rgb rgb(); + cc_YCbCr YCbCr(); +}; + +class cc_YCbCr +{ + public: + cc_YCbCr( const cc_rgb v_in ); +}; + +cc_YCbCr cc_hsl::YCbCr() +{ + cc_YCbCr v_out = cc_YCbCr( rgb()); + return v_out; +} + +} diff --git a/test/SemaCXX/cxx0x-cursory-default-delete.cpp b/test/SemaCXX/cxx0x-cursory-default-delete.cpp index 32905956169b..641760e7e540 100644 --- a/test/SemaCXX/cxx0x-cursory-default-delete.cpp +++ b/test/SemaCXX/cxx0x-cursory-default-delete.cpp @@ -7,11 +7,14 @@ struct non_copiable { }; struct non_const_copy { - non_const_copy(non_const_copy&) = default; // expected-note {{not viable}} - non_const_copy& operator = (non_const_copy&) & = default; // expected-note {{not viable}} - non_const_copy& operator = (non_const_copy&) && = default; // expected-note {{not viable}} + non_const_copy(non_const_copy&); + non_const_copy& operator = (non_const_copy&) &; + non_const_copy& operator = (non_const_copy&) &&; non_const_copy() = default; // expected-note {{not viable}} }; +non_const_copy::non_const_copy(non_const_copy&) = default; // expected-note {{not viable}} +non_const_copy& non_const_copy::operator = (non_const_copy&) & = default; // expected-note {{not viable}} +non_const_copy& non_const_copy::operator = (non_const_copy&) && = default; // expected-note {{not viable}} void fn1 () { non_copiable nc; @@ -21,7 +24,8 @@ void fn1 () { non_const_copy ncc; non_const_copy ncc2 = ncc; ncc = ncc2; - const non_const_copy cncc; + const non_const_copy cncc{}; + const non_const_copy cncc1; // expected-error {{default initialization of an object of const type 'const non_const_copy' requires a user-provided default constructor}} non_const_copy ncc3 = cncc; // expected-error {{no matching}} ncc = cncc; // expected-error {{no viable overloaded}} }; @@ -32,9 +36,9 @@ struct non_const_derived : non_const_copy { }; struct bad_decls { - bad_decls(volatile bad_decls&) = default; // expected-error {{may not be volatile}} - bad_decls&& operator = (bad_decls) = default; // expected-error 2{{lvalue reference}} - bad_decls& operator = (volatile bad_decls&) = default; // expected-error {{may not be volatile}} + bad_decls(volatile bad_decls&) = default; // expected-error {{may not be volatile}} expected-error {{must be defaulted outside the class}} + bad_decls&& operator = (bad_decls) = default; // expected-error {{lvalue reference}} expected-error {{must return 'bad_decls &'}} + bad_decls& operator = (volatile bad_decls&) = default; // expected-error {{may not be volatile}} expected-error {{must be defaulted outside the class}} bad_decls& operator = (const bad_decls&) const = default; // expected-error {{may not have 'const', 'constexpr' or 'volatile' qualifiers}} }; @@ -66,10 +70,9 @@ struct except_spec_d_mismatch : except_spec_a, except_spec_b { }; struct except_spec_d_match : except_spec_a, except_spec_b { except_spec_d_match() throw(A, B) = default; -}; +}; // gcc-compatibility: allow attributes on default definitions // (but not normal definitions) struct S { S(); }; S::S() __attribute((pure)) = default; - diff --git a/test/SemaCXX/cxx0x-defaulted-functions.cpp b/test/SemaCXX/cxx0x-defaulted-functions.cpp index 2e4107c13e2d..ce7ee672ea19 100644 --- a/test/SemaCXX/cxx0x-defaulted-functions.cpp +++ b/test/SemaCXX/cxx0x-defaulted-functions.cpp @@ -6,26 +6,26 @@ struct foo { foo() = default; foo(const foo&) = default; - foo(foo&) = default; + foo(foo&&) = default; foo& operator = (const foo&) = default; - foo& operator = (foo&) = default; + foo& operator = (foo&&) = default; ~foo() = default; }; struct bar { bar(); bar(const bar&); - bar(bar&); + bar(bar&&); bar& operator = (const bar&); - bar& operator = (bar&); + bar& operator = (bar&&); ~bar(); }; bar::bar() = default; bar::bar(const bar&) = default; -bar::bar(bar&) = default; +bar::bar(bar&&) = default; bar& bar::operator = (const bar&) = default; -bar& bar::operator = (bar&) = default; +bar& bar::operator = (bar&&) = default; bar::~bar() = default; static_assert(__is_trivial(foo), "foo should be trivial"); @@ -51,3 +51,101 @@ template<typename T> struct S : T { struct lit { constexpr lit() {} }; S<lit> s_lit; // ok S<bar> s_bar; // ok + +struct Friends { + friend S<bar>::S(); + friend S<bar>::S(const S&); + friend S<bar>::S(S&&); +}; + +namespace DefaultedFnExceptionSpec { + // DR1330: The exception-specification of an implicitly-declared special + // member function is evaluated as needed. + template<typename T> T &&declval(); + template<typename T> struct pair { + pair(const pair&) noexcept(noexcept(T(declval<T>()))); + }; + + struct Y; + struct X { X(); X(const Y&); }; + struct Y { pair<X> p; }; + + template<typename T> + struct A { + pair<T> p; + }; + struct B { + B(); + B(const A<B>&); + }; + + // Don't crash here. + void f() { + X x = X(); + (void)noexcept(B(declval<B>())); + } + + template<typename T> + struct Error { + // FIXME: Type canonicalization causes all the errors to point at the first + // declaration which has the type 'void () noexcept (T::error)'. We should + // get one error for 'Error<int>::Error()' and one for 'Error<int>::~Error()'. + void f() noexcept(T::error); // expected-error 2{{has no members}} + + Error() noexcept(T::error); + Error(const Error&) noexcept(T::error); + Error(Error&&) noexcept(T::error); + Error &operator=(const Error&) noexcept(T::error); + Error &operator=(Error&&) noexcept(T::error); + ~Error() noexcept(T::error); + }; + + struct DelayImplicit { + Error<int> e; + }; + + // Don't instantiate the exception specification here. + void test1(decltype(declval<DelayImplicit>() = DelayImplicit(DelayImplicit()))); + void test2(decltype(declval<DelayImplicit>() = declval<const DelayImplicit>())); + void test3(decltype(DelayImplicit(declval<const DelayImplicit>()))); + + // Any odr-use causes the exception specification to be evaluated. + struct OdrUse { // \ + expected-note {{instantiation of exception specification for 'Error'}} \ + expected-note {{instantiation of exception specification for '~Error'}} + Error<int> e; + }; + OdrUse use; // expected-note {{implicit default constructor for 'DefaultedFnExceptionSpec::OdrUse' first required here}} +} + +namespace PR13527 { + struct X { + X() = delete; // expected-note {{here}} + X(const X&) = delete; // expected-note {{here}} + X(X&&) = delete; // expected-note {{here}} + X &operator=(const X&) = delete; // expected-note {{here}} + X &operator=(X&&) = delete; // expected-note {{here}} + ~X() = delete; // expected-note {{here}} + }; + X::X() = default; // expected-error {{redefinition}} + X::X(const X&) = default; // expected-error {{redefinition}} + X::X(X&&) = default; // expected-error {{redefinition}} + X &X::operator=(const X&) = default; // expected-error {{redefinition}} + X &X::operator=(X&&) = default; // expected-error {{redefinition}} + X::~X() = default; // expected-error {{redefinition}} + + struct Y { + Y() = default; + Y(const Y&) = default; + Y(Y&&) = default; + Y &operator=(const Y&) = default; + Y &operator=(Y&&) = default; + ~Y() = default; + }; + Y::Y() = default; // expected-error {{definition of explicitly defaulted}} + Y::Y(const Y&) = default; // expected-error {{definition of explicitly defaulted}} + Y::Y(Y&&) = default; // expected-error {{definition of explicitly defaulted}} + Y &Y::operator=(const Y&) = default; // expected-error {{definition of explicitly defaulted}} + Y &Y::operator=(Y&&) = default; // expected-error {{definition of explicitly defaulted}} + Y::~Y() = default; // expected-error {{definition of explicitly defaulted}} +} diff --git a/test/SemaCXX/cxx0x-initializer-aggregates.cpp b/test/SemaCXX/cxx0x-initializer-aggregates.cpp index 801a82f57065..c83058a5e196 100644 --- a/test/SemaCXX/cxx0x-initializer-aggregates.cpp +++ b/test/SemaCXX/cxx0x-initializer-aggregates.cpp @@ -87,3 +87,32 @@ namespace array_explicit_conversion { (void)test4{{{1}}}; // expected-note {{in instantiation of template class 'array_explicit_conversion::A<-1>' requested here}} } } + +namespace sub_constructor { + struct DefaultConstructor { // expected-note 2 {{not viable}} + DefaultConstructor(); // expected-note {{not viable}} + int x; + }; + struct NoDefaultConstructor1 { // expected-note 2 {{not viable}} + NoDefaultConstructor1(int); // expected-note {{not viable}} + int x; + }; + struct NoDefaultConstructor2 { // expected-note 4 {{not viable}} + NoDefaultConstructor2(int,int); // expected-note 2 {{not viable}} + int x; + }; + + struct Aggr { + DefaultConstructor a; + NoDefaultConstructor1 b; + NoDefaultConstructor2 c; + }; + + Aggr ok1 { {}, {0} , {0,0} }; + Aggr ok2 = { {}, {0} , {0,0} }; + Aggr too_many { {0} , {0} , {0,0} }; // expected-error {{no matching constructor for initialization}} + Aggr too_few { {} , {0} , {0} }; // expected-error {{no matching constructor for initialization}} + Aggr invalid { {} , {&ok1} , {0,0} }; // expected-error {{no matching constructor for initialization}} + NoDefaultConstructor2 array_ok[] = { {0,0} , {0,1} }; + NoDefaultConstructor2 array_error[] = { {0,0} , {0} }; // expected-error {{no matching constructor for initialization}} +}
\ No newline at end of file diff --git a/test/SemaCXX/cxx0x-initializer-constructor.cpp b/test/SemaCXX/cxx0x-initializer-constructor.cpp index 09aca24b704b..223e140ffc02 100644 --- a/test/SemaCXX/cxx0x-initializer-constructor.cpp +++ b/test/SemaCXX/cxx0x-initializer-constructor.cpp @@ -279,5 +279,28 @@ namespace PR12498 { { c->foo({ nullptr, 1 }); // expected-error{{initialization of incomplete type 'const PR12498::ArrayRef'}} } +} + +namespace explicit_default { + struct A { + explicit A(); // expected-note{{here}} + }; + A a {}; // ok + // This is copy-list-initialization, and we choose an explicit constructor + // (even though we do so via value-initialization), so the initialization is + // ill-formed. + A b = {}; // expected-error{{chosen constructor is explicit}} +} +namespace init_list_default { + struct A { + A(std::initializer_list<int>); + }; + A a {}; // calls initializer list constructor + + struct B { + B(); + B(std::initializer_list<int>) = delete; + }; + B b {}; // calls default constructor } diff --git a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp index 7384309f97da..f11e19ae6f2c 100644 --- a/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp +++ b/test/SemaCXX/cxx0x-initializer-stdinitializerlist.cpp @@ -175,3 +175,15 @@ namespace PR12436 { X x({}, 17); } + +namespace rdar11948732 { + template<typename T> struct X {}; + + struct XCtorInit { + XCtorInit(std::initializer_list<X<int>>); + }; + + void f(X<int> &xi) { + XCtorInit xc = { xi, xi }; + } +} diff --git a/test/SemaCXX/cxx98-compat-pedantic.cpp b/test/SemaCXX/cxx98-compat-pedantic.cpp index 00532d5ac073..c07f64e614d2 100644 --- a/test/SemaCXX/cxx98-compat-pedantic.cpp +++ b/test/SemaCXX/cxx98-compat-pedantic.cpp @@ -9,7 +9,7 @@ #line 32768 // expected-warning {{#line number greater than 32767 is incompatible with C++98}} #define VA_MACRO(x, ...) x // expected-warning {{variadic macros are incompatible with C++98}} -VA_MACRO(,x) // expected-warning {{empty macro argument list is incompatible with C++98}} +VA_MACRO(,x) // expected-warning {{empty macro arguments are incompatible with C++98}} ; // expected-warning {{extra ';' outside of a function is incompatible with C++98}} diff --git a/test/SemaCXX/cxx98-compat.cpp b/test/SemaCXX/cxx98-compat.cpp index 82a9dc8042c4..37341f885619 100644 --- a/test/SemaCXX/cxx98-compat.cpp +++ b/test/SemaCXX/cxx98-compat.cpp @@ -1,7 +1,15 @@ // RUN: %clang_cc1 -fsyntax-only -std=c++11 -Wc++98-compat -verify %s // RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -namespace std { struct type_info; } +namespace std { + struct type_info; + using size_t = decltype(sizeof(0)); // expected-warning {{decltype}} expected-warning {{alias}} + template<typename T> struct initializer_list { + initializer_list(T*, size_t); + T *p; + size_t n; + }; +} template<typename ...T> // expected-warning {{variadic templates are incompatible with C++98}} class Variadic1 {}; @@ -39,6 +47,14 @@ void Lambda() { []{}(); // expected-warning {{lambda expressions are incompatible with C++98}} } +struct Ctor { + Ctor(int, char); + Ctor(double, long); +}; +struct InitListCtor { + InitListCtor(std::initializer_list<bool>); +}; + int InitList(int i = {}) { // expected-warning {{generalized initializer lists are incompatible with C++98}} \ // expected-warning {{scalar initialized from empty initializer list is incompatible with C++98}} (void)new int {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} \ @@ -48,6 +64,14 @@ int InitList(int i = {}) { // expected-warning {{generalized initializer lists a int x { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}} S<int> s = {}; // ok, aggregate s = {}; // expected-warning {{generalized initializer lists are incompatible with C++98}} + std::initializer_list<int> xs = { 1, 2, 3 }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}} + auto ys = { 1, 2, 3 }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}} \ + // expected-warning {{'auto' type specifier is incompatible with C++98}} + Ctor c1 = { 1, 2 }; // expected-warning {{constructor call from initializer list is incompatible with C++98}} + Ctor c2 = { 3.0, 4l }; // expected-warning {{constructor call from initializer list is incompatible with C++98}} + InitListCtor ilc = { true, false }; // expected-warning {{initialization of initializer_list object is incompatible with C++98}} + const int &r = { 0 }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}} + struct { int a; const int &r; } rr = { 0, {{0}} }; // expected-warning {{reference initialized from initializer list is incompatible with C++98}} return { 0 }; // expected-warning {{generalized initializer lists are incompatible with C++98}} } struct DelayedDefaultArgumentParseInitList { @@ -303,3 +327,38 @@ namespace NonTypeTemplateArgs { S<const int&, k> s1; // expected-warning {{non-type template argument referring to object 'k' with internal linkage is incompatible with C++98}} S<void(&)(), f> s2; // expected-warning {{non-type template argument referring to function 'f' with internal linkage is incompatible with C++98}} } + +namespace NullPointerTemplateArg { + struct A {}; + template<int*> struct X {}; + template<int A::*> struct Y {}; + X<(int*)0> x; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}} + Y<(int A::*)0> y; // expected-warning {{use of null pointer as non-type template argument is incompatible with C++98}} +} + +namespace PR13480 { + struct basic_iterator { + basic_iterator(const basic_iterator &it) {} + basic_iterator(basic_iterator &it) {} // expected-note {{because type 'PR13480::basic_iterator' has a user-declared copy constructor}} + }; + + union test { + basic_iterator it; // expected-warning {{union member 'it' with a non-trivial copy constructor is incompatible with C++98}} + }; +} + +namespace AssignOpUnion { + struct a { + void operator=(const a &it) {} + void operator=(a &it) {} // expected-note {{because type 'AssignOpUnion::a' has a user-declared copy assignment operator}} + }; + + struct b { + void operator=(const b &it) {} // expected-note {{because type 'AssignOpUnion::b' has a user-declared copy assignment operator}} + }; + + union test1 { + a x; // expected-warning {{union member 'x' with a non-trivial copy assignment operator is incompatible with C++98}} + b y; // expected-warning {{union member 'y' with a non-trivial copy assignment operator is incompatible with C++98}} + }; +} diff --git a/test/SemaCXX/dcl_ambig_res.cpp b/test/SemaCXX/dcl_ambig_res.cpp index fa71b11ba160..08867c0ea2f5 100644 --- a/test/SemaCXX/dcl_ambig_res.cpp +++ b/test/SemaCXX/dcl_ambig_res.cpp @@ -10,9 +10,9 @@ int returns_an_int(); void foo(double a) { - S w(int(a)); // expected-warning{{disambiguated}} + S w(int(a)); // expected-warning{{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}} w(17); - S x1(int()); // expected-warning{{disambiguated}} + S x1(int()); // expected-warning{{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}} x1(&returns_an_int); S y((int)a); y.bar(); @@ -69,7 +69,7 @@ struct S5 { static bool const value = false; }; int foo8() { - int v(int(S5::value)); // expected-warning{{disambiguated}} expected-error{{parameter declarator cannot be qualified}} + int v(int(S5::value)); // expected-warning{{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}} expected-error{{parameter declarator cannot be qualified}} } template<typename T> diff --git a/test/SemaCXX/dcl_init_aggr.cpp b/test/SemaCXX/dcl_init_aggr.cpp index bd3de9eb7e19..8c5e654fca2e 100644 --- a/test/SemaCXX/dcl_init_aggr.cpp +++ b/test/SemaCXX/dcl_init_aggr.cpp @@ -15,7 +15,7 @@ struct NonAggregate { }; NonAggregate non_aggregate_test = { 1, 2 }; // expected-error{{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}} -NonAggregate non_aggregate_test2[2] = { { 1, 2 }, { 3, 4 } }; // expected-error 2 {{initialization of non-aggregate type 'NonAggregate' with an initializer list}} +NonAggregate non_aggregate_test2[2] = { { 1, 2 }, { 3, 4 } }; // expected-error 2 {{non-aggregate type 'NonAggregate' cannot be initialized with an initializer list}} // C++ [dcl.init.aggr]p3 diff --git a/test/SemaCXX/decl-expr-ambiguity.cpp b/test/SemaCXX/decl-expr-ambiguity.cpp index 6f4d08cc686c..0980c40cbfd5 100644 --- a/test/SemaCXX/decl-expr-ambiguity.cpp +++ b/test/SemaCXX/decl-expr-ambiguity.cpp @@ -22,10 +22,10 @@ void f() { (int())1; // expected-error {{C-style cast from 'int' to 'int ()' is not allowed}} // Declarations. - int fd(T(a)); // expected-warning {{parentheses were disambiguated as a function declarator}} - T(*d)(int(p)); // expected-warning {{parentheses were disambiguated as a function declarator}} expected-note {{previous definition is here}} - typedef T(*td)(int(p)); - extern T(*tp)(int(p)); + int fd(T(a)); // expected-warning {{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}} + T(*d)(int(p)); // expected-note {{previous}} + typedef T td(int(p)); + extern T tp(int(p)); T d3(); // expected-warning {{empty parentheses interpreted as a function declaration}} expected-note {{replace parentheses with an initializer}} T d3v(void); typedef T d3t(); @@ -49,6 +49,7 @@ struct RAII { }; void func(); +void func2(short); namespace N { struct S; @@ -59,6 +60,10 @@ namespace N { S s(); // expected-warning {{function declaration}} } + void nonEmptyParens() { + int f = 0, // g = 0; expected-note {{change this ',' to a ';' to call 'func2'}} + func2(short(f)); // expected-warning {{function declaration}} expected-note {{add a pair of parentheses}} + } } class C { }; @@ -70,3 +75,23 @@ void foo() { fn(1); // expected-error {{no matching function}} fn(g); // OK } + +namespace PR11874 { +void foo(); // expected-note 3 {{class 'foo' is hidden by a non-type declaration of 'foo' here}} +class foo {}; +class bar { + bar() { + const foo* f1 = 0; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}} + foo* f2 = 0; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}} + foo f3; // expected-error {{must use 'class' tag to refer to type 'foo' in this scope}} + } +}; + +int baz; // expected-note 2 {{class 'baz' is hidden by a non-type declaration of 'baz' here}} +class baz {}; +void fizbin() { + const baz* b1 = 0; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}} + baz* b2; // expected-error {{use of undeclared identifier 'b2'}} + baz b3; // expected-error {{must use 'class' tag to refer to type 'baz' in this scope}} +} +} diff --git a/test/SemaCXX/default1.cpp b/test/SemaCXX/default1.cpp index ae6ef9791c2a..c8c197e153d4 100644 --- a/test/SemaCXX/default1.cpp +++ b/test/SemaCXX/default1.cpp @@ -47,6 +47,13 @@ int i () { void j (int f = 4); { void j (int f); // expected-note{{'j' declared here}} - j(); // expected-error{{too few arguments to function call, expected 1, have 0}} + j(); // expected-error{{too few arguments to function call, single argument 'f' was not specified}} + } +} + +int i2() { + void j(int f = 4); // expected-note{{'j' declared here}} + { + j(2, 3); // expected-error{{too many arguments to function call, expected at most single argument 'f', have 2}} } } diff --git a/test/SemaCXX/deleted-function.cpp b/test/SemaCXX/deleted-function.cpp index d13fd0eb7b4f..e78e7edc7199 100644 --- a/test/SemaCXX/deleted-function.cpp +++ b/test/SemaCXX/deleted-function.cpp @@ -55,3 +55,13 @@ struct Z : virtual DelDtor { ~Z() {} // expected-error {{attempt to use a deleted function}} }; DelDtor dd; // expected-error {{attempt to use a deleted function}} + +template<typename> void test2() = delete; +template void test2<int>(); + +template<typename> void test3() = delete; +template<typename> void test3(); +template void test3<int>(); + +void test4() {} // expected-note {{previous definition is here}} +void test4() = delete; // expected-error {{redefinition of 'test4'}} diff --git a/test/SemaCXX/deleted-operator.cpp b/test/SemaCXX/deleted-operator.cpp index 0e0282ad12cc..9f53e71d456c 100644 --- a/test/SemaCXX/deleted-operator.cpp +++ b/test/SemaCXX/deleted-operator.cpp @@ -8,8 +8,8 @@ struct PR10757 { int PR10757f() { PR10757 a1; // FIXME: We get a ridiculous number of "built-in candidate" notes here... - if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 6 {{built-in candidate}} - if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 81 {{built-in candidate}} + if(~a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 8 {{built-in candidate}} + if(a1==a1) {} // expected-error {{overload resolution selected deleted operator}} expected-note 121 {{built-in candidate}} } struct DelOpDel { diff --git a/test/SemaCXX/elaborated-type-specifier.cpp b/test/SemaCXX/elaborated-type-specifier.cpp index 760079f3b0bc..1b1770a89f85 100644 --- a/test/SemaCXX/elaborated-type-specifier.cpp +++ b/test/SemaCXX/elaborated-type-specifier.cpp @@ -19,7 +19,7 @@ bool test_elab(S1 *s1, struct S2 *s2, struct S3 *s3) { namespace NS { class X { public: - void test_elab2(struct S4 *s4); + void test_elab2(struct S4 *s4); // expected-note{{'NS::S4' declared here}} }; void X::test_elab2(S4 *s4) { } // expected-note{{passing argument to parameter 's4' here}} @@ -35,8 +35,7 @@ namespace NS { } void test_S5_scope() { - S4 *s4; // expected-error{{use of undeclared identifier 'S4'}} \ - // expected-error{{use of undeclared identifier 's4'}} + S4 *s4; // expected-error{{unknown type name 'S4'; did you mean 'NS::S4'?}} } int test_funcparam_scope(struct S5 * s5) { @@ -44,5 +43,3 @@ int test_funcparam_scope(struct S5 * s5) { if (s5 == s5_2) return 1; // expected-error {{comparison of distinct pointer types ('struct S5 *' and 'struct S5 *')}} return 0; } - - diff --git a/test/SemaCXX/enum-scoped.cpp b/test/SemaCXX/enum-scoped.cpp index ebe924535850..a1f911d79d39 100644 --- a/test/SemaCXX/enum-scoped.cpp +++ b/test/SemaCXX/enum-scoped.cpp @@ -245,3 +245,10 @@ namespace test10 { int m = g<int>(); int n = g<short>(); // expected-note {{here}} } + +namespace pr13128 { + // This should compile cleanly + class C { + enum class E { C }; + }; +} diff --git a/test/SemaCXX/expressions.cpp b/test/SemaCXX/expressions.cpp index 355833e693fa..2635fb8d176a 100644 --- a/test/SemaCXX/expressions.cpp +++ b/test/SemaCXX/expressions.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-constant-conversion %s void choice(int); int choice(bool); diff --git a/test/SemaCXX/format-strings-0x.cpp b/test/SemaCXX/format-strings-0x.cpp index e7c5904c66e3..7b3aef1ee5da 100644 --- a/test/SemaCXX/format-strings-0x.cpp +++ b/test/SemaCXX/format-strings-0x.cpp @@ -12,4 +12,16 @@ void f(char **sp, float *fp) { scanf("%afoobar", fp); printf(nullptr); printf(*sp); // expected-warning {{not a string literal}} + + // PR13099 + printf( + R"foobar(%)foobar" + R"bazquux(d)bazquux" // expected-warning {{more '%' conversions than data arguments}} + R"xyzzy()xyzzy"); + + printf(u8"this is %d test", 0); // ok + printf(u8R"foo( + \u1234\U0010fffe + %d)foo" // expected-warning {{more '%' conversions than data arguments}} + ); } diff --git a/test/SemaCXX/function-extern-c.cpp b/test/SemaCXX/function-extern-c.cpp index f20cd38a3cb0..16dbbb26fc66 100644 --- a/test/SemaCXX/function-extern-c.cpp +++ b/test/SemaCXX/function-extern-c.cpp @@ -36,3 +36,5 @@ extern "C" void f7( U u ); extern "C" double f8(void); extern "C" long long f11( void ); extern "C" A *f10( void ); + +extern "C" struct mypodstruct f12(); // expected-warning {{'f12' has C-linkage specified, but returns incomplete type 'struct mypodstruct' which could be incompatible with C}} diff --git a/test/SemaCXX/function-redecl.cpp b/test/SemaCXX/function-redecl.cpp index 0eb109d2633b..b9d1f23af402 100644 --- a/test/SemaCXX/function-redecl.cpp +++ b/test/SemaCXX/function-redecl.cpp @@ -76,12 +76,9 @@ class Crash { void GetCart(int count) const; }; // This out-of-line definition was fine... -void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}} \ - // expected-note {{'cart' declared here}} \ - // expected-note {{previous definition is here}} +void Crash::cart(int count) const {} // expected-error {{out-of-line definition of 'cart' does not match any declaration in 'Crash'}} // ...while this one crashed clang -void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'; did you mean 'cart'?}} \ - // expected-error {{redefinition of 'cart'}} +void Crash::chart(int count) const {} // expected-error {{out-of-line definition of 'chart' does not match any declaration in 'Crash'}} class TestConst { public: @@ -98,3 +95,24 @@ void TestConst::setit(int) const { // expected-error {{out-of-line definition of struct J { int typo() const; }; int J::typo_() { return 3; } // expected-error {{out-of-line definition of 'typo_' does not match any declaration in 'J'}} + +// Ensure we correct the redecl of Foo::isGood to Bar::Foo::isGood and not +// Foo::IsGood even though Foo::IsGood is technically a closer match since it +// already has a body. Also make sure Foo::beEvil is corrected to Foo::BeEvil +// since it is a closer match than Bar::Foo::beEvil and neither have a body. +namespace redecl_typo { +namespace Foo { + bool IsGood() { return false; } + void BeEvil(); // expected-note {{'BeEvil' declared here}} +} +namespace Bar { + namespace Foo { + bool isGood(); // expected-note {{'Bar::Foo::isGood' declared here}} + void beEvil(); + } +} +bool Foo::isGood() { // expected-error {{out-of-line definition of 'isGood' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'Bar::Foo::isGood'?}} + return true; +} +void Foo::beEvil() {} // expected-error {{out-of-line definition of 'beEvil' does not match any declaration in namespace 'redecl_typo::Foo'; did you mean 'BeEvil'?}} +} diff --git a/test/SemaCXX/implicit-exception-spec.cpp b/test/SemaCXX/implicit-exception-spec.cpp index 25316f8d51ee..b29cff5c5d12 100644 --- a/test/SemaCXX/implicit-exception-spec.cpp +++ b/test/SemaCXX/implicit-exception-spec.cpp @@ -17,7 +17,7 @@ namespace InClassInitializers { // is false. bool ThrowSomething() noexcept(false); struct ConstExpr { - bool b = noexcept(ConstExpr()) && ThrowSomething(); // expected-error {{exception specification is not available until end of class definition}} + bool b = noexcept(ConstExpr()) && ThrowSomething(); // expected-error {{cannot be used by non-static data member initializer}} }; // We can use it now. bool w = noexcept(ConstExpr()); @@ -25,18 +25,27 @@ namespace InClassInitializers { // Much more obviously broken: we can't parse the initializer without already // knowing whether it produces a noexcept expression. struct TemplateArg { - int n = ExceptionIf<noexcept(TemplateArg())>::f(); // expected-error {{exception specification is not available until end of class definition}} + int n = ExceptionIf<noexcept(TemplateArg())>::f(); // expected-error {{cannot be used by non-static data member initializer}} }; bool x = noexcept(TemplateArg()); // And within a nested class. + // FIXME: The diagnostic location is terrible here. struct Nested { struct Inner { - int n = ExceptionIf<noexcept(Nested())>::f(); // expected-error {{exception specification is not available until end of class definition}} - } inner; + int n = ExceptionIf<noexcept(Nested())>::f(); + } inner; // expected-error {{cannot be used by non-static data member initializer}} }; bool y = noexcept(Nested()); bool z = noexcept(Nested::Inner()); + + struct Nested2 { + struct Inner; + int n = Inner().n; // expected-error {{cannot be used by non-static data member initializer}} + struct Inner { + int n = ExceptionIf<noexcept(Nested())>::f(); + } inner; + }; } namespace ExceptionSpecification { diff --git a/test/SemaCXX/invalid-member-expr.cpp b/test/SemaCXX/invalid-member-expr.cpp index 287d9af13094..87da79a27c0c 100644 --- a/test/SemaCXX/invalid-member-expr.cpp +++ b/test/SemaCXX/invalid-member-expr.cpp @@ -37,3 +37,34 @@ namespace test3 { string::iterator i = s.foo(); // expected-error {{no member named 'foo'}} } } + + +// Make sure we don't crash. +namespace rdar11293995 { + +struct Length { + explicit Length(PassRefPtr<CalculationValue>); // expected-error {{unknown type name}} \ + expected-error {{expected ')'}} \ + expected-note {{to match this '('}} +}; + +struct LengthSize { + Length m_width; + Length m_height; +}; + +enum EFillSizeType { Contain, Cover, SizeLength, SizeNone }; + +struct FillSize { + EFillSizeType type; + LengthSize size; +}; + +class FillLayer { +public: + void setSize(FillSize f) { m_sizeType = f.type;} +private: + unsigned m_sizeType : 2; +}; + +} diff --git a/test/SemaCXX/lambda-expressions.cpp b/test/SemaCXX/lambda-expressions.cpp index e91dee92edb1..0fd634502bc9 100644 --- a/test/SemaCXX/lambda-expressions.cpp +++ b/test/SemaCXX/lambda-expressions.cpp @@ -17,74 +17,71 @@ namespace ExplicitCapture { [this](){(void)Member;}; [this]{[this]{};}; []{[this]{};};// expected-error {{'this' cannot be implicitly captured in this context}} - []{Overload(3);}; - []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}} + []{Overload(3);}; + []{Overload();}; // expected-error {{'this' cannot be implicitly captured in this context}} []{(void)typeid(Overload());}; - []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}} + []{(void)typeid(Overload(.5f));};// expected-error {{'this' cannot be implicitly captured in this context}} } }; void f() { - [this] () {}; // expected-error {{'this' cannot be captured in this context}} + [this] () {}; // expected-error {{'this' cannot be captured in this context}} } } namespace ReturnDeduction { void test() { - [](){ return 1; }; - [](){ return 1; }; - [](){ return ({return 1; 1;}); }; - [](){ return ({return 'c'; 1;}); }; // expected-error {{must match previous return type}} \ - // expected-warning{{omitted result type}} - []()->int{ return 'c'; return 1; }; + [](){ return 1; }; + [](){ return 1; }; + [](){ return ({return 1; 1;}); }; + [](){ return ({return 'c'; 1;}); }; // expected-error {{must match previous return type}} + []()->int{ return 'c'; return 1; }; [](){ return 'c'; return 1; }; // expected-error {{must match previous return type}} - []() { return; return (void)0; }; - [](){ return 1; return 1; }; // expected-warning{{omitted result type}} + []() { return; return (void)0; }; + [](){ return 1; return 1; }; } } namespace ImplicitCapture { void test() { int a = 0; // expected-note 5 {{declared}} - []() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}} - [&]() { return a; }; - [=]() { return a; }; - [=]() { int* b = &a; }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}} + []() { return a; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{begins here}} + [&]() { return a; }; + [=]() { return a; }; + [=]() { int* b = &a; }; // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const int *'}} [=]() { return [&]() { return a; }; }; - []() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} - []() { return ^{ return a; }; };// expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} - []() { return [&a] { return a; }; }; // expected-error 2 {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note 2 {{lambda expression begins here}} - [=]() { return [&a] { return a; }; }; // + []() { return [&]() { return a; }; }; // expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} + []() { return ^{ return a; }; };// expected-error {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} + []() { return [&a] { return a; }; }; // expected-error 2 {{variable 'a' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note 2 {{lambda expression begins here}} + [=]() { return [&a] { return a; }; }; // const int b = 2; - []() { return b; }; + []() { return b; }; union { // expected-note {{declared}} int c; float d; }; d = 3; - [=]() { return c; }; // expected-error {{unnamed variable cannot be implicitly captured in a lambda expression}} + [=]() { return c; }; // expected-error {{unnamed variable cannot be implicitly captured in a lambda expression}} __block int e; // expected-note 3 {{declared}} - [&]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}} - [&e]() { return e; }; // expected-error 2 {{__block variable 'e' cannot be captured in a lambda expression}} + [&]() { return e; }; // expected-error {{__block variable 'e' cannot be captured in a lambda expression}} + [&e]() { return e; }; // expected-error 2 {{__block variable 'e' cannot be captured in a lambda expression}} int f[10]; // expected-note {{declared}} - [&]() { return f[2]; }; + [&]() { return f[2]; }; (void) ^{ return []() { return f[2]; }; }; // expected-error {{variable 'f' cannot be implicitly captured in a lambda with no capture-default specified}} \ // expected-note{{lambda expression begins here}} struct G { G(); G(G&); int a; }; // expected-note 6 {{not viable}} G g; - [=]() { const G* gg = &g; return gg->a; }; // expected-warning{{omitted result type}} - [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'ImplicitCapture::G'}} \ - // expected-warning{{omitted result type}} - (void)^{ return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error 2 {{no matching constructor for initialization of 'const ImplicitCapture::G'}} \ - // expected-warning{{omitted result type}} + [=]() { const G* gg = &g; return gg->a; }; + [=]() { return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error {{no matching constructor for initialization of 'ImplicitCapture::G'}} + (void)^{ return [=]{ const G* gg = &g; return gg->a; }(); }; // expected-error 2 {{no matching constructor for initialization of 'const ImplicitCapture::G'}} const int h = a; // expected-note {{declared}} - []() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} + []() { return h; }; // expected-error {{variable 'h' cannot be implicitly captured in a lambda with no capture-default specified}} expected-note {{lambda expression begins here}} // The exemption for variables which can appear in constant expressions // applies only to objects (and not to references). @@ -120,16 +117,16 @@ namespace NullPtr { const int m = 0; [=] { - int &k = f(m); // a null pointer constant + int &k = f(m); // expected-warning{{expression which evaluates to zero treated as a null pointer constant of type 'int *'}} } (); [=] () -> bool { - int &k = f(m); // a null pointer constant + int &k = f(m); // expected-warning{{expression which evaluates to zero treated as a null pointer constant of type 'int *'}} return &m == 0; } (); [m] { - int &k = f(m); // a null pointer constant + int &k = f(m); // expected-warning{{expression which evaluates to zero treated as a null pointer constant of type 'int *'}} } (); } } @@ -148,3 +145,79 @@ namespace ModifyingCapture { }; } } + +namespace VariadicPackExpansion { + template<typename T, typename U> using Fst = T; + template<typename...Ts> bool g(Fst<bool, Ts> ...bools); + template<typename...Ts> bool f(Ts &&...ts) { + return g<Ts...>([&ts] { + if (!ts) + return false; + --ts; + return true; + } () ...); + } + void h() { + int a = 5, b = 2, c = 3; + while (f(a, b, c)) { + } + } + + struct sink { + template<typename...Ts> sink(Ts &&...) {} + }; + + template<typename...Ts> void local_class() { + sink { + [] (Ts t) { + struct S : Ts { + void f(Ts t) { + Ts &that = *this; + that = t; + } + Ts g() { return *this; }; + }; + S s; + s.f(t); + return s; + } (Ts()).g() ... + }; + }; + struct X {}; struct Y {}; + template void local_class<X, Y>(); + + template<typename...Ts> void nested(Ts ...ts) { + f( + // Each expansion of this lambda implicitly captures all of 'ts', because + // the inner lambda also expands 'ts'. + [&] { + return ts + [&] { return f(ts...); } (); + } () ... + ); + } + template void nested(int, int, int); + + template<typename...Ts> void nested2(Ts ...ts) { // expected-note 2{{here}} + // Capture all 'ts', use only one. + f([&ts...] { return ts; } ()...); + // Capture each 'ts', use it. + f([&ts] { return ts; } ()...); + // Capture all 'ts', use all of them. + f([&ts...] { return (int)f(ts...); } ()); + // Capture each 'ts', use all of them. Ill-formed. In more detail: + // + // We instantiate two lambdas here; the first captures ts$0, the second + // captures ts$1. Both of them reference both ts parameters, so both are + // ill-formed because ts can't be implicitly captured. + // + // FIXME: This diagnostic does not explain what's happening. We should + // specify which 'ts' we're referring to in its diagnostic name. We should + // also say which slice of the pack expansion is being performed in the + // instantiation backtrace. + f([&ts] { return (int)f(ts...); } ()...); // \ + // expected-error 2{{'ts' cannot be implicitly captured}} \ + // expected-note 2{{lambda expression begins here}} + } + template void nested2(int); // ok + template void nested2(int, int); // expected-note {{in instantiation of}} +} diff --git a/test/SemaCXX/literal-operators.cpp b/test/SemaCXX/literal-operators.cpp index 7f68cd393cad..f4c5c35a2bcb 100644 --- a/test/SemaCXX/literal-operators.cpp +++ b/test/SemaCXX/literal-operators.cpp @@ -41,3 +41,4 @@ void operator "" _cv_good (volatile const char *, const size_t); // expected-err template <char...> void operator "" _good (); // FIXME: Test some invalid decls that might crop up. +template <typename...> void operator "" _invalid(); // expected-error {{parameter declaration for literal operator 'operator "" _invalid' is not valid}} diff --git a/test/SemaCXX/long-virtual-inheritance-chain.cpp b/test/SemaCXX/long-virtual-inheritance-chain.cpp new file mode 100644 index 000000000000..85995971d240 --- /dev/null +++ b/test/SemaCXX/long-virtual-inheritance-chain.cpp @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -fsyntax-only %s + +class test0 { virtual void f(); }; +class test1 : virtual test0 { virtual void f(); }; +class test2 : virtual test1 { virtual void f(); }; +class test3 : virtual test2 { virtual void f(); }; +class test4 : virtual test3 { virtual void f(); }; +class test5 : virtual test4 { virtual void f(); }; +class test6 : virtual test5 { virtual void f(); }; +class test7 : virtual test6 { virtual void f(); }; +class test8 : virtual test7 { virtual void f(); }; +class test9 : virtual test8 { virtual void f(); }; +class test10 : virtual test9 { virtual void f(); }; +class test11 : virtual test10 { virtual void f(); }; +class test12 : virtual test11 { virtual void f(); }; +class test13 : virtual test12 { virtual void f(); }; +class test14 : virtual test13 { virtual void f(); }; +class test15 : virtual test14 { virtual void f(); }; +class test16 : virtual test15 { virtual void f(); }; +class test17 : virtual test16 { virtual void f(); }; +class test18 : virtual test17 { virtual void f(); }; +class test19 : virtual test18 { virtual void f(); }; +class test20 : virtual test19 { virtual void f(); }; +class test21 : virtual test20 { virtual void f(); }; +class test22 : virtual test21 { virtual void f(); }; +class test23 : virtual test22 { virtual void f(); }; +class test24 : virtual test23 { virtual void f(); }; +class test25 : virtual test24 { virtual void f(); }; +class test26 : virtual test25 { virtual void f(); }; +class test27 : virtual test26 { virtual void f(); }; +class test28 : virtual test27 { virtual void f(); }; +class test29 : virtual test28 { virtual void f(); }; +class test30 : virtual test29 { virtual void f(); }; +class test31 : virtual test30 { virtual void f(); }; +class test32 : virtual test31 { virtual void f(); }; +class test33 : virtual test32 { virtual void f(); }; +class test34 : virtual test33 { virtual void f(); }; +class test35 : virtual test34 { virtual void f(); }; +class test36 : virtual test35 { virtual void f(); }; +class test37 : virtual test36 { virtual void f(); }; +class test38 : virtual test37 { virtual void f(); }; +class test39 : virtual test38 { virtual void f(); }; +class test40 : virtual test39 { virtual void f(); }; +class test41 : virtual test40 { virtual void f(); }; +class test42 : virtual test41 { virtual void f(); }; +class test43 : virtual test42 { virtual void f(); }; +class test44 : virtual test43 { virtual void f(); }; +class test45 : virtual test44 { virtual void f(); }; +class test46 : virtual test45 { virtual void f(); }; +class test47 : virtual test46 { virtual void f(); }; +class test48 : virtual test47 { virtual void f(); }; +class test49 : virtual test48 { virtual void f(); }; +class test50 : virtual test49 { virtual void f(); }; diff --git a/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp index dbddd1c2e3e1..763f9c754c1e 100644 --- a/test/SemaCXX/member-expr.cpp +++ b/test/SemaCXX/member-expr.cpp @@ -157,3 +157,13 @@ namespace FuncInMemberExpr { Vec fun3(int x = 0); int test3() { return fun3.size(); } // expected-error {{base of member reference is a function; perhaps you meant to call it with no arguments}} } + +namespace DotForSemiTypo { +void f(int i) { + // If the programmer typo'd '.' for ';', make sure we point at the '.' rather + // than the "field name" (whatever the first token on the next line happens to + // be). + int j = i. // expected-error {{member reference base type 'int' is not a structure or union}} + j = 0; +} +} diff --git a/test/SemaCXX/member-init.cpp b/test/SemaCXX/member-init.cpp index c93c85bbf89a..a13941fce5d8 100644 --- a/test/SemaCXX/member-init.cpp +++ b/test/SemaCXX/member-init.cpp @@ -14,7 +14,7 @@ public: bool b(); int k; struct Recurse { - int &n = b() ? Recurse().n : k; // ok + int &n = b() ? Recurse().n : k; // expected-error {{defaulted default constructor of 'Recurse' cannot be used by non-static data member initializer which appears before end of class definition}} }; struct UnknownBound { @@ -28,7 +28,7 @@ template<> struct T<2> { template<int C, int D> using B = int; }; const int C = 0, D = 0; struct S { int as[] = { decltype(x)::B<C, D>(0) }; // expected-error {{array bound cannot be deduced from an in-class initializer}} - T<sizeof(as) / sizeof(int)> x; // expected-error {{requires a type specifier}} + T<sizeof(as) / sizeof(int)> x; // test that we handle invalid array bound deductions without crashing when the declarator name is itself invalid operator int[](){}; // expected-error {{'operator int' cannot be the name of a variable or data member}} \ // expected-error {{array bound cannot be deduced from an in-class initializer}} diff --git a/test/SemaCXX/member-operator-expr.cpp b/test/SemaCXX/member-operator-expr.cpp index ae5f8bb0ddb6..c98ef7399709 100644 --- a/test/SemaCXX/member-operator-expr.cpp +++ b/test/SemaCXX/member-operator-expr.cpp @@ -27,3 +27,8 @@ void test2() { x->operator float(); // expected-error{{no member named 'operator float'}} x->operator; // expected-error{{expected a type}} } + +namespace pr13157 { + class A { public: void operator()(int x, int y = 2, ...) {} }; + void f() { A()(1); } +}
\ No newline at end of file diff --git a/test/SemaCXX/microsoft-cxx0x.cpp b/test/SemaCXX/microsoft-cxx0x.cpp index 3b9bbefc0cd6..79bd7c39e5a5 100644 --- a/test/SemaCXX/microsoft-cxx0x.cpp +++ b/test/SemaCXX/microsoft-cxx0x.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wc++11-narrowing -Wmicrosoft -verify -fms-extensions -std=c++11 +// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -Wc++11-narrowing -Wmicrosoft -verify -fms-extensions -std=c++11 -fms-compatibility -DMS_COMPAT struct A { @@ -6,3 +7,16 @@ struct A { }; int b = 3; A var = { b }; // expected-warning {{ cannot be narrowed }} expected-note {{override}} + + +namespace PR13433 { + struct S; + S make(); + + template<typename F> auto x(F f) -> decltype(f(make())); +#ifndef MS_COMPAT +// expected-error@-2{{calling 'make' with incomplete return type 'PR13433::S'}} +// expected-note@-5{{'make' declared here}} +// expected-note@-7{{forward declaration of 'PR13433::S'}} +#endif +} diff --git a/test/SemaCXX/neon-vector-types.cpp b/test/SemaCXX/neon-vector-types.cpp index aa82b11e8cd7..336fcd4f18d6 100644 --- a/test/SemaCXX/neon-vector-types.cpp +++ b/test/SemaCXX/neon-vector-types.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify "-triple" "thumbv7-apple-ios3.0.0" %s // rdar://9208404 typedef int MP4Err; @@ -25,3 +25,20 @@ MP4Err autoCorrelation2nd_Neon(Float32 *alphar, Float32 *alphai, return 0; } +namespace rdar11688587 { + typedef float float32_t; + typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t; + + template<int I> + float test() + { + extern float32x4_t vec; + return __extension__ ({ + float32x4_t __a = (vec); + (float32_t)__builtin_neon_vgetq_lane_f32(__a, I); // expected-error{{argument should be a value from 0 to 3}} + }); + } + + template float test<1>(); + template float test<4>(); // expected-note{{in instantiation of function template specialization 'rdar11688587::test<4>' requested here}} +} diff --git a/test/SemaCXX/nested-name-spec.cpp b/test/SemaCXX/nested-name-spec.cpp index b31763484489..4e1abc5e5bc8 100644 --- a/test/SemaCXX/nested-name-spec.cpp +++ b/test/SemaCXX/nested-name-spec.cpp @@ -143,7 +143,7 @@ namespace A { void g(int&); // expected-note{{type of 1st parameter of member declaration does not match definition ('int &' vs 'const int &')}} } -void A::f() {} // expected-error{{out-of-line definition of 'f' does not match any declaration in namespace 'A'}} +void A::f() {} // expected-error-re{{out-of-line definition of 'f' does not match any declaration in namespace 'A'$}} void A::g(const int&) { } // expected-error{{out-of-line definition of 'g' does not match any declaration in namespace 'A'}} @@ -286,3 +286,15 @@ protected: template <typename T> struct A2<T>::B::C; // expected-error {{no struct named 'C'}} } + +namespace PR13033 { +namespace NS { + int a; // expected-note {{'NS::a' declared here}} + int longer_b; //expected-note {{'NS::longer_b' declared here}} +} + +// Suggest adding a namespace qualifier to both variable names even though one +// is only a single character long. +int foobar = a + longer_b; // expected-error {{use of undeclared identifier 'a'; did you mean 'NS::a'?}} \ + // expected-error {{use of undeclared identifier 'longer_b'; did you mean 'NS::longer_b'?}} +} diff --git a/test/SemaCXX/no-rtti.cpp b/test/SemaCXX/no-rtti.cpp new file mode 100644 index 000000000000..75167050dca2 --- /dev/null +++ b/test/SemaCXX/no-rtti.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -fno-rtti %s + +namespace std { + class type_info; +} + +void f() +{ + (void)typeid(int); // expected-error {{cannot use typeid with -fno-rtti}} +} diff --git a/test/SemaCXX/nullptr.cpp b/test/SemaCXX/nullptr.cpp index e3136039f425..d148f76698ec 100644 --- a/test/SemaCXX/nullptr.cpp +++ b/test/SemaCXX/nullptr.cpp @@ -33,8 +33,10 @@ nullptr_t f(nullptr_t null) // Operators (void)(null == nullptr); (void)(null <= nullptr); + (void)(null == 0); (void)(null == (void*)0); (void)((void*)0 == nullptr); + (void)(null <= 0); (void)(null <= (void*)0); (void)((void*)0 <= nullptr); (void)(0 == nullptr); @@ -44,7 +46,7 @@ nullptr_t f(nullptr_t null) (void)(1 > nullptr); // expected-error {{invalid operands to binary expression}} (void)(1 != nullptr); // expected-error {{invalid operands to binary expression}} (void)(1 + nullptr); // expected-error {{invalid operands to binary expression}} - (void)(0 ? nullptr : 0); // expected-error {{non-pointer operand type 'int' incompatible with nullptr}} + (void)(0 ? nullptr : 0); (void)(0 ? nullptr : (void*)0); (void)(0 ? nullptr : A()); // expected-error {{non-pointer operand type 'A' incompatible with nullptr}} (void)(0 ? A() : nullptr); // expected-error {{non-pointer operand type 'A' incompatible with nullptr}} diff --git a/test/SemaCXX/offsetof-0x.cpp b/test/SemaCXX/offsetof-0x.cpp new file mode 100644 index 000000000000..610d919c1af1 --- /dev/null +++ b/test/SemaCXX/offsetof-0x.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -std=c++11 -verify %s -Winvalid-offsetof + +struct NonPOD { + virtual void f(); + int m; +}; + +struct P { + NonPOD fieldThatPointsToANonPODType; +}; + +void f() { + int i = __builtin_offsetof(P, fieldThatPointsToANonPODType.m); // expected-warning{{offset of on non-standard-layout type 'P'}} +} + +struct StandardLayout { + int x; + StandardLayout() {} +}; +int o = __builtin_offsetof(StandardLayout, x); // no-warning diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp index b5e121486621..615b10a43971 100644 --- a/test/SemaCXX/overload-call.cpp +++ b/test/SemaCXX/overload-call.cpp @@ -233,7 +233,7 @@ float* intref(const int&); void intref_test() { float* ir1 = intref(5); - float* ir2 = intref(5.5); // expected-warning{{implicit conversion turns literal floating-point number into integer}} + float* ir2 = intref(5.5); // expected-warning{{implicit conversion from 'double' to 'int' changes value from 5.5 to 5}} } void derived5(C&); // expected-note{{candidate function not viable: cannot bind base class object of type 'A' to derived class reference 'C &' for 1st argument}} @@ -260,14 +260,12 @@ struct Z : X, Y { }; int& cvqual_subsume(X&); // expected-note{{candidate function}} float& cvqual_subsume(const Y&); // expected-note{{candidate function}} -int& cvqual_subsume2(const X&); // expected-note{{candidate function}} -float& cvqual_subsume2(const volatile Y&); // expected-note{{candidate function}} - -Z get_Z(); +int& cvqual_subsume2(X&); // expected-note{{candidate function}} +float& cvqual_subsume2(volatile Y&); // expected-note{{candidate function}} void cvqual_subsume_test(Z z) { cvqual_subsume(z); // expected-error{{call to 'cvqual_subsume' is ambiguous}} - int& x = cvqual_subsume2(get_Z()); // expected-error{{call to 'cvqual_subsume2' is ambiguous}} + cvqual_subsume2(z); // expected-error{{call to 'cvqual_subsume2' is ambiguous}} } // Test overloading with cv-qualification differences in reference @@ -319,14 +317,20 @@ namespace PR5756 { namespace test1 { template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}} void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'char' for 2nd argument}} - void foo(int n); // expected-note {{candidate function not viable: requires 1 argument, but 2 were provided}} - void foo(unsigned n = 10); // expected-note {{candidate function not viable: requires at most 1 argument, but 2 were provided}} void foo(int n, const char *s, int t); // expected-note {{candidate function not viable: requires 3 arguments, but 2 were provided}} void foo(int n, const char *s, int t, ...); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}} void foo(int n, const char *s, int t, int u = 0); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}} + // PR 11857 + void foo(int n); // expected-note {{candidate function not viable: requires single argument 'n', but 2 arguments were provided}} + void foo(unsigned n = 10); // expected-note {{candidate function not viable: allows at most single argument 'n', but 2 arguments were provided}} + void bar(int n, int u = 0); // expected-note {{candidate function not viable: requires at least argument 'n', but no arguments were provided}} + void baz(int n = 0, int u = 0); // expected-note {{candidate function not viable: requires at most 2 arguments, but 3 were provided}} + void test() { foo(4, "hello"); //expected-error {{no matching function for call to 'foo'}} + bar(); //expected-error {{no matching function for call to 'bar'}} + baz(3, 4, 5); // expected-error {{no matching function for call to 'baz'}} } } @@ -438,10 +442,10 @@ namespace PR6078 { namespace PR6177 { struct String { String(char const*); }; - void f(bool const volatile&); // expected-note{{passing argument to parameter here}} - void f(String); + void f(bool const volatile&); + int &f(String); - void g() { f(""); } // expected-error{{volatile lvalue reference to type 'const volatile bool' cannot bind to a value of unrelated type 'const char [1]'}} + void g() { int &r = f(""); } } namespace PR7095 { @@ -568,3 +572,11 @@ namespace PR12142 { void fun(int (*x)[10]); // expected-note{{candidate function not viable: 1st argument ('const int (*)[10]') would lose const qualifier}} void g() { fun((const int(*)[10])0); } // expected-error{{no matching function for call to 'fun'}} } + +// DR1152: Take 'volatile' into account when handling reference bindings in +// overload resolution. +namespace PR12931 { + void f(const int &, ...); + void f(const volatile int &, int); + void g() { f(0, 0); } +} diff --git a/test/SemaCXX/overload-member-call.cpp b/test/SemaCXX/overload-member-call.cpp index 37c955201a98..09586201e561 100644 --- a/test/SemaCXX/overload-member-call.cpp +++ b/test/SemaCXX/overload-member-call.cpp @@ -72,8 +72,6 @@ namespace test1 { class A { template <class T> void foo(T t, unsigned N); // expected-note {{candidate function [with T = int] not viable: no known conversion from 'const char [6]' to 'unsigned int' for 2nd argument}} void foo(int n, char N); // expected-note {{candidate function not viable: no known conversion from 'const char [6]' to 'char' for 2nd argument}} - void foo(int n); // expected-note {{candidate function not viable: requires 1 argument, but 2 were provided}} - void foo(unsigned n = 10); // expected-note {{candidate function not viable: requires at most 1 argument, but 2 were provided}} void foo(int n, const char *s, int t); // expected-note {{candidate function not viable: requires 3 arguments, but 2 were provided}} void foo(int n, const char *s, int t, ...); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}} void foo(int n, const char *s, int t, int u = 0); // expected-note {{candidate function not viable: requires at least 3 arguments, but 2 were provided}} @@ -83,6 +81,14 @@ namespace test1 { void baz(A &d); // expected-note {{candidate function not viable: 1st argument ('const test1::A') would lose const qualifier}} void baz(int i); // expected-note {{candidate function not viable: no known conversion from 'const test1::A' to 'int' for 1st argument}} + + // PR 11857 + void foo(int n); // expected-note {{candidate function not viable: requires single argument 'n', but 2 arguments were provided}} + void foo(unsigned n = 10); // expected-note {{candidate function not viable: allows at most single argument 'n', but 2 arguments were provided}} + void rab(double n, int u = 0); // expected-note {{candidate function not viable: requires at least argument 'n', but no arguments were provided}} + void rab(int n, int u = 0); // expected-note {{candidate function not viable: requires at least argument 'n', but no arguments were provided}} + void zab(double n = 0.0, int u = 0); // expected-note {{candidate function not viable: requires at most 2 arguments, but 3 were provided}} + void zab(int n = 0, int u = 0); // expected-note {{candidate function not viable: requires at most 2 arguments, but 3 were provided}} }; void test() { @@ -93,6 +99,9 @@ namespace test1 { b.bar(0); //expected-error {{no matching member function for call to 'bar'}} a.baz(b); //expected-error {{no matching member function for call to 'baz'}} + + a.rab(); //expected-error {{no matching member function for call to 'rab'}} + a.zab(3, 4, 5); //expected-error {{no matching member function for call to 'zab'}} } } diff --git a/test/SemaCXX/overloaded-builtin-operators.cpp b/test/SemaCXX/overloaded-builtin-operators.cpp index b3c08085a695..ac110a3c0561 100644 --- a/test/SemaCXX/overloaded-builtin-operators.cpp +++ b/test/SemaCXX/overloaded-builtin-operators.cpp @@ -174,7 +174,7 @@ void test_dr425(A a) { // FIXME: lots of candidates here! (void)(1.0f * a); // expected-error{{ambiguous}} \ // expected-note 4{{candidate}} \ - // expected-note {{remaining 77 candidates omitted; pass -fshow-overloads=all to show them}} + // expected-note {{remaining 117 candidates omitted; pass -fshow-overloads=all to show them}} } // pr5432 @@ -237,3 +237,34 @@ namespace PR7851 { (void)(x - x); } } + +namespace PR12854 { + enum { size = 1 }; + void plus_equals() { + int* __restrict py; + py += size; + } + + struct RestrictInt { + operator int* __restrict &(); + }; + + void user_conversions(RestrictInt ri) { + ++ri; + --ri; + ri++; + ri--; + } +} + +namespace PR12964 { + struct X { operator __int128() const; } x; + bool a = x == __int128(0); + bool b = x == 0; + + struct Y { operator unsigned __int128() const; } y; + bool c = y == __int128(0); + bool d = y == 0; + + bool e = x == y; +} diff --git a/test/SemaCXX/pr13353.cpp b/test/SemaCXX/pr13353.cpp new file mode 100644 index 000000000000..8fb5443fe623 --- /dev/null +++ b/test/SemaCXX/pr13353.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only %s +struct foo { + virtual void bar() ; +}; +template<typename T> +class zed : public foo { +}; +template<typename T> +class bah : public zed<T> { + void f() { + const_cast<foo *>(this->g())->bar(); + } +}; diff --git a/test/SemaCXX/pr13394-crash-on-invalid.cpp b/test/SemaCXX/pr13394-crash-on-invalid.cpp new file mode 100644 index 000000000000..413c52af858c --- /dev/null +++ b/test/SemaCXX/pr13394-crash-on-invalid.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// Don't crash (PR13394). + +namespace stretch_v1 { + struct closure_t { + const stretch_v1::ops_t* d_methods; // expected-error {{no type named 'ops_t' in namespace 'stretch_v1'}} + }; +} +namespace gatekeeper_v1 { + namespace gatekeeper_factory_v1 { + struct closure_t { // expected-note {{'closure_t' declared here}} + gatekeeper_v1::closure_t* create(); // expected-error {{no type named 'closure_t' in namespace 'gatekeeper_v1'; did you mean 'closure_t'?}} + }; + } + gatekeeper_v1::closure_t *x; // expected-error {{no type named 'closure_t' in namespace 'gatekeeper_v1}} +} diff --git a/test/SemaCXX/printf-block.cpp b/test/SemaCXX/printf-block.cpp new file mode 100644 index 000000000000..4a580037e731 --- /dev/null +++ b/test/SemaCXX/printf-block.cpp @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -Wformat -verify %s -Wno-error=non-pod-varargs + +int (^block) (int, const char *,...) __attribute__((__format__(__printf__,2,3))) = ^ __attribute__((__format__(__printf__,2,3))) (int arg, const char *format,...) {return 5;}; + +class HasNoCStr { + const char *str; + public: + HasNoCStr(const char *s): str(s) { } + const char *not_c_str() {return str;} +}; + +void test_block() { + const char str[] = "test"; + HasNoCStr hncs(str); + int n = 4; + block(n, "%s %d", str, n); // no-warning + block(n, "%s %s", hncs, n); // expected-warning{{cannot pass non-POD object of type 'HasNoCStr' to variadic block; expected type from format string was 'char *'}} expected-warning{{format specifies type 'char *' but the argument has type 'int'}} +} diff --git a/test/SemaCXX/printf-cstr.cpp b/test/SemaCXX/printf-cstr.cpp new file mode 100644 index 000000000000..a7eeb06b9c0e --- /dev/null +++ b/test/SemaCXX/printf-cstr.cpp @@ -0,0 +1,53 @@ +// RUN: %clang_cc1 -fsyntax-only -Wformat -verify %s -Wno-error=non-pod-varargs + +#include <stdarg.h> + +extern "C" { +extern int printf(const char *restrict, ...); +extern int sprintf(char *, const char *restrict, ...); +} + +class HasCStr { + const char *str; + public: + HasCStr(const char *s): str(s) { } + const char *c_str() {return str;} +}; + +class HasNoCStr { + const char *str; + public: + HasNoCStr(const char *s): str(s) { } + const char *not_c_str() {return str;} +}; + +extern const char extstr[16]; +void pod_test() { + char str[] = "test"; + char dest[32]; + char formatString[] = "non-const %s %s"; + HasCStr hcs(str); + HasNoCStr hncs(str); + int n = 10; + + printf("%d: %s\n", n, hcs.c_str()); + printf("%d: %s\n", n, hcs); // expected-warning{{cannot pass non-POD object of type 'HasCStr' to variadic function; expected type from format string was 'char *'}} expected-note{{did you mean to call the c_str() method?}} + printf("%d: %s\n", n, hncs); // expected-warning{{cannot pass non-POD object of type 'HasNoCStr' to variadic function; expected type from format string was 'char *'}} + sprintf(str, "%d: %s", n, hcs); // expected-warning{{cannot pass non-POD object of type 'HasCStr' to variadic function; expected type from format string was 'char *'}} expected-note{{did you mean to call the c_str() method?}} + + printf(formatString, hcs, hncs); // expected-warning{{cannot pass object of non-POD type 'HasCStr' through variadic function}} expected-warning{{cannot pass object of non-POD type 'HasNoCStr' through variadic function}} + printf(extstr, hcs, n); // expected-warning{{cannot pass object of non-POD type 'HasCStr' through variadic function}} +} + +struct Printf { + Printf(); + Printf(const Printf&); + Printf(const char *,...) __attribute__((__format__(__printf__,2,3))); +}; + +void constructor_test() { + const char str[] = "test"; + HasCStr hcs(str); + Printf p("%s %d %s", str, 10, 10); // expected-warning {{format specifies type 'char *' but the argument has type 'int'}} + Printf q("%s %d", hcs, 10); // expected-warning {{cannot pass non-POD object of type 'HasCStr' to variadic constructor; expected type from format string was 'char *'}} expected-note{{did you mean to call the c_str() method?}} +} diff --git a/test/SemaCXX/qualified-id-lookup.cpp b/test/SemaCXX/qualified-id-lookup.cpp index d65a4684e629..a14193cc7ac8 100644 --- a/test/SemaCXX/qualified-id-lookup.cpp +++ b/test/SemaCXX/qualified-id-lookup.cpp @@ -86,14 +86,15 @@ namespace a { namespace a { namespace a { // A1 namespace a { // A2 - int i; + int i; // expected-note{{'::a::a::a::i' declared here}} } } } void test_a() { - a::a::i = 3; // expected-error{{no member named 'i'}} + a::a::i = 3; // expected-error{{no member named 'i' in namespace 'a::a'; did you mean '::a::a::a::i'?}} a::a::a::i = 4; + a::a::j = 3; // expected-error-re{{no member named 'j' in namespace 'a::a'$}} } struct Undef { // expected-note{{definition of 'Undef' is not complete until the closing '}'}} diff --git a/test/SemaCXX/reinterpret-cast.cpp b/test/SemaCXX/reinterpret-cast.cpp index 7f41b93a46e4..a4bc4325e655 100644 --- a/test/SemaCXX/reinterpret-cast.cpp +++ b/test/SemaCXX/reinterpret-cast.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding -Wundefined-reinterpret-cast %s +// RUN: %clang_cc1 -fsyntax-only -verify -ffreestanding -Wundefined-reinterpret-cast -Wno-unused-volatile-lvalue %s #include <stdint.h> diff --git a/test/SemaCXX/static-assert.cpp b/test/SemaCXX/static-assert.cpp index 364e4e4bef37..4a7560ba5b6a 100644 --- a/test/SemaCXX/static-assert.cpp +++ b/test/SemaCXX/static-assert.cpp @@ -34,3 +34,17 @@ static_assert(false, u"\U000317FF"); // expected-error {{static_assert failed u" static_assert(false, u8"Ω"); // expected-error {{static_assert failed u8"\316\251"}} static_assert(false, L"\u1234"); // expected-error {{static_assert failed L"\x1234"}} static_assert(false, L"\x1ff" "0\x123" "fx\xfffff" "goop"); // expected-error {{static_assert failed L"\x1FF""0\x123""fx\xFFFFFgoop"}} + +template<typename T> struct AlwaysFails { + // Only give one error here. + static_assert(false, ""); // expected-error {{static_assert failed}} +}; +AlwaysFails<int> alwaysFails; + +template<typename T> struct StaticAssertProtected { + static_assert(__is_literal(T), ""); // expected-error {{static_assert failed}} + static constexpr T t = {}; // no error here +}; +struct X { ~X(); }; +StaticAssertProtected<int> sap1; +StaticAssertProtected<X> sap2; // expected-note {{instantiation}} diff --git a/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp b/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp new file mode 100644 index 000000000000..14ffcef704d9 --- /dev/null +++ b/test/SemaCXX/switch-implicit-fallthrough-cxx98.cpp @@ -0,0 +1,119 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -Wimplicit-fallthrough %s + + +int fallthrough(int n) { + switch (n / 10) { + if (n - 1) { + n = 100; + } else if (n - 2) { + n = 101; + } else if (n - 3) { + n = 102; + } + case -1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}} + ; + case 0: {// expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}} + } + case 1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}} + n += 100 ; + case 3: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}} + if (n > 0) + n += 200; + case 4: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}} + if (n < 0) + ; + case 5: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}} + switch (n) { + case 111: + break; + case 112: + break; + case 113: + break ; + } + case 6: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}} + n += 300; + } + switch (n / 30) { + case 11: + case 12: // no warning here, intended fall-through, no statement between labels + n += 1600; + } + switch (n / 40) { + case 13: + if (n % 2 == 0) { + return 1; + } else { + return 2; + } + case 15: // no warning here, there's no fall-through + n += 3200; + } + switch (n / 50) { + case 17: { + if (n % 2 == 0) { + return 1; + } else { + return 2; + } + } + case 19: { // no warning here, there's no fall-through + n += 6400; + return 3; + } + case 21: { // no warning here, there's no fall-through + break; + } + case 23: // no warning here, there's no fall-through + n += 128000; + break; + case 25: // no warning here, there's no fall-through + break; + } + + return n; +} + +class ClassWithDtor { +public: + ~ClassWithDtor() {} +}; + +void fallthrough2(int n) { + switch (n) { + case 0: + { + ClassWithDtor temp; + break; + } + default: // no warning here, there's no fall-through + break; + } +} + +#define MY_SWITCH(X, Y, Z, U, V) switch (X) { case Y: Z; case U: V; } +#define MY_SWITCH2(X, Y, Z) switch (X) { Y; Z; } +#define MY_CASE(X, Y) case X: Y +#define MY_CASE2(X, Y, U, V) case X: Y; case U: V + +int fallthrough_macro1(int n) { + MY_SWITCH(n, 13, n *= 2, 14, break) // expected-warning{{unannotated fall-through between switch labels}} + + switch (n + 1) { + MY_CASE(33, n += 2); + MY_CASE(44, break); // expected-warning{{unannotated fall-through between switch labels}} + MY_CASE(55, n += 3); + } + + switch (n + 3) { + MY_CASE(333, return 333); + MY_CASE2(444, n += 44, 4444, break); // expected-warning{{unannotated fall-through between switch labels}} + MY_CASE(555, n += 33); + } + + MY_SWITCH2(n + 4, MY_CASE(17, n *= 3), MY_CASE(19, break)) // expected-warning{{unannotated fall-through between switch labels}} + + MY_SWITCH2(n + 5, MY_CASE(21, break), MY_CASE2(23, n *= 7, 25, break)) // expected-warning{{unannotated fall-through between switch labels}} + + return n; +} diff --git a/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp b/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp new file mode 100644 index 000000000000..7c52e5138b71 --- /dev/null +++ b/test/SemaCXX/switch-implicit-fallthrough-per-method.cpp @@ -0,0 +1,51 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough-per-function %s + + +int fallthrough(int n) { + switch (n / 10) { + case 0: + n += 100; + case 1: // expected-warning{{unannotated fall-through}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + switch (n) { + case 111: + n += 111; + [[clang::fallthrough]]; + case 112: + n += 112; + case 113: // expected-warning{{unannotated fall-through}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + n += 113; + break ; + } + } + return n; +} + +int fallthrough2(int n) { + switch (n / 10) { + case 0: + n += 100; + case 1: // no warning, as we didn't "opt-in" for it in this method + switch (n) { + case 111: + n += 111; + case 112: // no warning, as we didn't "opt-in" for it in this method + n += 112; + case 113: // no warning, as we didn't "opt-in" for it in this method + n += 113; + break ; + } + } + return n; +} + +void unscoped(int n) { + switch (n % 2) { + case 0: + // FIXME: This should be typo-corrected, probably. + [[fallthrough]]; + case 2: // expected-warning{{unannotated fall-through}} expected-note{{clang::fallthrough}} expected-note{{break;}} + [[clang::fallthrough]]; + case 1: + break; + } +} diff --git a/test/SemaCXX/switch-implicit-fallthrough.cpp b/test/SemaCXX/switch-implicit-fallthrough.cpp new file mode 100644 index 000000000000..cfc29c237c2d --- /dev/null +++ b/test/SemaCXX/switch-implicit-fallthrough.cpp @@ -0,0 +1,197 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wimplicit-fallthrough %s + + +int fallthrough(int n) { + switch (n / 10) { + if (n - 1) { + n = 100; + } else if (n - 2) { + n = 101; + } else if (n - 3) { + n = 102; + } + case -1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + ; + case 0: {// expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + } + case 1: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + n += 100 ; + case 3: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + if (n > 0) + n += 200; + case 4: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + if (n < 0) + ; + case 5: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + switch (n) { + case 111: + break; + case 112: + break; + case 113: + break ; + } + case 6: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + n += 300; + case 66: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert 'break;' to avoid fall-through}} + break; + } + switch (n / 20) { + case 7: + n += 400; + [[clang::fallthrough]]; + case 9: // no warning here, intended fall-through marked with an attribute + n += 800; + [[clang::fallthrough]]; + default: { // no warning here, intended fall-through marked with an attribute + if (n % 2 == 0) { + return 1; + } else { + [[clang::fallthrough]]; + } + } + case 10: // no warning here, intended fall-through marked with an attribute + if (n % 3 == 0) { + n %= 3; + } else { + [[clang::fallthrough]]; + } + case 110: // expected-warning{{unannotated fall-through between switch labels}} but no fix-it hint as we have one fall-through annotation! + n += 800; + } + switch (n / 30) { + case 11: + case 12: // no warning here, intended fall-through, no statement between labels + n += 1600; + } + switch (n / 40) { + case 13: + if (n % 2 == 0) { + return 1; + } else { + return 2; + } + case 15: // no warning here, there's no fall-through + n += 3200; + } + switch (n / 50) { + case 17: { + if (n % 2 == 0) { + return 1; + } else { + return 2; + } + } + case 19: { // no warning here, there's no fall-through + n += 6400; + return 3; + } + case 21: { // no warning here, there's no fall-through + break; + } + case 23: // no warning here, there's no fall-through + n += 128000; + break; + case 25: // no warning here, there's no fall-through + break; + } + + return n; +} + +class ClassWithDtor { +public: + ~ClassWithDtor() {} +}; + +void fallthrough2(int n) { + switch (n) { + case 0: + { + ClassWithDtor temp; + break; + } + default: // no warning here, there's no fall-through + break; + } +} + +#define MY_SWITCH(X, Y, Z, U, V) switch (X) { case Y: Z; case U: V; } +#define MY_SWITCH2(X, Y, Z) switch (X) { Y; Z; } +#define MY_CASE(X, Y) case X: Y +#define MY_CASE2(X, Y, U, V) case X: Y; case U: V + +int fallthrough_macro1(int n) { + MY_SWITCH(n, 13, n *= 2, 14, break) // expected-warning{{unannotated fall-through between switch labels}} + + switch (n + 1) { + MY_CASE(33, n += 2); + MY_CASE(44, break); // expected-warning{{unannotated fall-through between switch labels}} + MY_CASE(55, n += 3); + } + + switch (n + 3) { + MY_CASE(333, return 333); + MY_CASE2(444, n += 44, 4444, break); // expected-warning{{unannotated fall-through between switch labels}} + MY_CASE(555, n += 33); + } + + MY_SWITCH2(n + 4, MY_CASE(17, n *= 3), MY_CASE(19, break)) // expected-warning{{unannotated fall-through between switch labels}} + + MY_SWITCH2(n + 5, MY_CASE(21, break), MY_CASE2(23, n *= 7, 25, break)) // expected-warning{{unannotated fall-through between switch labels}} + + return n; +} + +int fallthrough_position(int n) { + switch (n) { + [[clang::fallthrough]]; // expected-warning{{fallthrough annotation in unreachable code}} + case 221: + [[clang::fallthrough]]; // expected-warning{{fallthrough annotation does not directly precede switch label}} + return 1; + [[clang::fallthrough]]; // expected-warning{{fallthrough annotation in unreachable code}} + case 222: + [[clang::fallthrough]]; // expected-warning{{fallthrough annotation does not directly precede switch label}} + n += 400; + case 223: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}} + [[clang::fallthrough]]; // expected-warning{{fallthrough annotation does not directly precede switch label}} + } + + // TODO: uncomment this test after CFG gets more options to deal with + // unreachable code: + // http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20120507/057370.html +#if 0 + long p = static_cast<long>(n) * n; + switch (sizeof(p)) { + case 9: // this test will not work on compilers with 72-bit long + n += static_cast<int>(p >> 32); + [[clang::fallthrough]]; // no warning here + case 5: // it is not intended to work on compilers with 40-bit long as well + n += static_cast<int>(p); + break; + default: + break; + } +#endif + + return n; +} + +int fallthrough_targets(int n) { + [[clang::fallthrough]]; // expected-error{{fallthrough annotation is outside switch statement}} + + [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}} + switch (n) { + case 121: + n += 400; + [[clang::fallthrough]]; // no warning here, correct target + case 123: + [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}} + n += 800; + break; + [[clang::fallthrough]] // expected-error{{fallthrough attribute is only allowed on empty statements}} expected-note{{did you forget ';'?}} + case 125: + n += 1600; + } + return n; +} diff --git a/test/SemaCXX/type-traits.cpp b/test/SemaCXX/type-traits.cpp index f53939ac1790..54294bcbb8b1 100644 --- a/test/SemaCXX/type-traits.cpp +++ b/test/SemaCXX/type-traits.cpp @@ -131,25 +131,25 @@ void is_pod() { int arr[T(__is_pod(HasAnonymousUnion))]; } { int arr[T(__is_pod(Vector))]; } { int arr[T(__is_pod(VectorExt))]; } + { int arr[T(__is_pod(Derives))]; } + { int arr[T(__is_pod(DerivesAr))]; } + { int arr[T(__is_pod(DerivesArNB))]; } + { int arr[T(__is_pod(DerivesEmpty))]; } + { int arr[T(__is_pod(HasPriv))]; } + { int arr[T(__is_pod(HasProt))]; } + { int arr[T(__is_pod(DerivesHasPriv))]; } + { int arr[T(__is_pod(DerivesHasProt))]; } - { int arr[F(__is_pod(Derives))]; } - { int arr[F(__is_pod(DerivesAr))]; } - { int arr[F(__is_pod(DerivesArNB))]; } - { int arr[F(__is_pod(DerivesEmpty))]; } { int arr[F(__is_pod(HasCons))]; } { int arr[F(__is_pod(HasCopyAssign))]; } { int arr[F(__is_pod(HasMoveAssign))]; } { int arr[F(__is_pod(HasDest))]; } - { int arr[F(__is_pod(HasPriv))]; } - { int arr[F(__is_pod(HasProt))]; } { int arr[F(__is_pod(HasRef))]; } { int arr[F(__is_pod(HasVirt))]; } { int arr[F(__is_pod(DerivesHasCons))]; } { int arr[F(__is_pod(DerivesHasCopyAssign))]; } { int arr[F(__is_pod(DerivesHasMoveAssign))]; } { int arr[F(__is_pod(DerivesHasDest))]; } - { int arr[F(__is_pod(DerivesHasPriv))]; } - { int arr[F(__is_pod(DerivesHasProt))]; } { int arr[F(__is_pod(DerivesHasRef))]; } { int arr[F(__is_pod(DerivesHasVirt))]; } { int arr[F(__is_pod(NonPOD))]; } @@ -1223,10 +1223,10 @@ void has_trivial_copy_constructor() { { int arr[T(__has_trivial_copy(const Int))]; } { int arr[T(__has_trivial_copy(AllDefaulted))]; } { int arr[T(__has_trivial_copy(AllDeleted))]; } + { int arr[T(__has_trivial_copy(DerivesAr))]; } { int arr[F(__has_trivial_copy(HasCopy))]; } { int arr[F(__has_trivial_copy(HasTemplateCons))]; } - { int arr[F(__has_trivial_copy(DerivesAr))]; } { int arr[F(__has_trivial_copy(VirtAr))]; } { int arr[F(__has_trivial_copy(void))]; } { int arr[F(__has_trivial_copy(cvoid))]; } @@ -1250,13 +1250,13 @@ void has_trivial_copy_assignment() { { int arr[T(__has_trivial_assign(HasMoveAssign))]; } { int arr[T(__has_trivial_assign(AllDefaulted))]; } { int arr[T(__has_trivial_assign(AllDeleted))]; } + { int arr[T(__has_trivial_assign(DerivesAr))]; } { int arr[F(__has_trivial_assign(IntRef))]; } { int arr[F(__has_trivial_assign(HasCopyAssign))]; } { int arr[F(__has_trivial_assign(const Int))]; } { int arr[F(__has_trivial_assign(ConstIntAr))]; } { int arr[F(__has_trivial_assign(ConstIntArAr))]; } - { int arr[F(__has_trivial_assign(DerivesAr))]; } { int arr[F(__has_trivial_assign(VirtAr))]; } { int arr[F(__has_trivial_assign(void))]; } { int arr[F(__has_trivial_assign(cvoid))]; } @@ -1338,6 +1338,7 @@ void has_nothrow_assign() { { int arr[T(__has_nothrow_assign(HasVirtDest))]; } { int arr[T(__has_nothrow_assign(AllPrivate))]; } { int arr[T(__has_nothrow_assign(UsingAssign))]; } + { int arr[T(__has_nothrow_assign(DerivesAr))]; } { int arr[F(__has_nothrow_assign(IntRef))]; } { int arr[F(__has_nothrow_assign(HasCopyAssign))]; } @@ -1345,7 +1346,6 @@ void has_nothrow_assign() { { int arr[F(__has_nothrow_assign(const Int))]; } { int arr[F(__has_nothrow_assign(ConstIntAr))]; } { int arr[F(__has_nothrow_assign(ConstIntArAr))]; } - { int arr[F(__has_nothrow_assign(DerivesAr))]; } { int arr[F(__has_nothrow_assign(VirtAr))]; } { int arr[F(__has_nothrow_assign(void))]; } { int arr[F(__has_nothrow_assign(cvoid))]; } @@ -1375,18 +1375,15 @@ void has_nothrow_copy() { { int arr[T(__has_nothrow_copy(HasVirtDest))]; } { int arr[T(__has_nothrow_copy(HasTemplateCons))]; } { int arr[T(__has_nothrow_copy(AllPrivate))]; } + { int arr[T(__has_nothrow_copy(DerivesAr))]; } { int arr[F(__has_nothrow_copy(HasCopy))]; } { int arr[F(__has_nothrow_copy(HasMultipleCopy))]; } - { int arr[F(__has_nothrow_copy(DerivesAr))]; } { int arr[F(__has_nothrow_copy(VirtAr))]; } { int arr[F(__has_nothrow_copy(void))]; } { int arr[F(__has_nothrow_copy(cvoid))]; } } -template<bool b> struct assert_expr; -template<> struct assert_expr<true> {}; - void has_nothrow_constructor() { { int arr[T(__has_nothrow_constructor(Int))]; } { int arr[T(__has_nothrow_constructor(IntAr))]; } @@ -1415,11 +1412,6 @@ void has_nothrow_constructor() { { int arr[F(__has_nothrow_constructor(void))]; } { int arr[F(__has_nothrow_constructor(cvoid))]; } { int arr[F(__has_nothrow_constructor(HasTemplateCons))]; } - - // While parsing an in-class initializer, the constructor is not known to be - // non-throwing yet. - struct HasInClassInit { int n = (assert_expr<!__has_nothrow_constructor(HasInClassInit)>(), 0); }; - { int arr[T(__has_nothrow_constructor(HasInClassInit))]; } } void has_virtual_destructor() { @@ -1582,6 +1574,8 @@ struct X0 { template<typename U> X0(const X0<U>&); }; +struct Abstract { virtual void f() = 0; }; + void is_convertible_to() { { int arr[T(__is_convertible_to(Int, Int))]; } { int arr[F(__is_convertible_to(Int, IntAr))]; } @@ -1606,6 +1600,7 @@ void is_convertible_to() { { int arr[F(__is_convertible_to(Function, Function))]; } { int arr[F(__is_convertible_to(PrivateCopy, PrivateCopy))]; } { int arr[T(__is_convertible_to(X0<int>, X0<float>))]; } + { int arr[F(__is_convertible_to(Abstract, Abstract))]; } } namespace is_convertible_to_instantiate { diff --git a/test/SemaCXX/typo-correction.cpp b/test/SemaCXX/typo-correction.cpp index b1e8d91d450d..893f08a422ca 100644 --- a/test/SemaCXX/typo-correction.cpp +++ b/test/SemaCXX/typo-correction.cpp @@ -190,3 +190,47 @@ namespace test1 { }; test1::FooBar *b; // expected-error{{no type named 'FooBar' in namespace 'test1'; did you mean 'Foobar'?}} } + +namespace ImplicitInt { + void f(int, unsinged); // expected-error{{did you mean 'unsigned'}} + struct S { + unsinged : 4; // expected-error{{did you mean 'unsigned'}} + }; +} + +namespace PR12951 { +// If there are two corrections that have the same identifier and edit distance +// and only differ by their namespaces, don't suggest either as a correction +// since both are equally likely corrections. +namespace foobar { struct Thing {}; } +namespace bazquux { struct Thing {}; } +void f() { Thing t; } // expected-error{{unknown type name 'Thing'}} +} + +namespace PR13051 { + template<typename T> struct S { + template<typename U> void f(); + operator bool() const; + }; + + void f() { + f(&S<int>::tempalte f<int>); // expected-error{{did you mean 'template'?}} + f(&S<int>::opeartor bool); // expected-error{{did you mean 'operator'?}} + f(&S<int>::foo); // expected-error-re{{no member named 'foo' in 'PR13051::S<int>'$}} + } +} + +namespace PR6325 { +class foo { }; // expected-note{{'foo' declared here}} +// Note that for this example (pulled from the PR), if keywords are not excluded +// as correction candidates then no suggestion would be given; correcting +// 'boo' to 'bool' is the same edit distance as correcting 'boo' to 'foo'. +class bar : boo { }; // expected-error{{unknown class name 'boo'; did you mean 'foo'?}} +} + +namespace bogus_keyword_suggestion { +void test() { + status = "OK"; // expected-error-re{{use of undeclared identifier 'status'$}} + return status; // expected-error-re{{use of undeclared identifier 'status'$}} + } +} diff --git a/test/SemaCXX/uninit-variables.cpp b/test/SemaCXX/uninit-variables.cpp index eb6428d631f2..687bfd2638d4 100644 --- a/test/SemaCXX/uninit-variables.cpp +++ b/test/SemaCXX/uninit-variables.cpp @@ -141,3 +141,9 @@ void test_bitcasts_2() { int y = (float &)x; // expected-warning {{uninitialized when used here}} } +void consume_const_ref(const int &n); +int test_const_ref() { + int n; // expected-note {{variable}} + consume_const_ref(n); + return n; // expected-warning {{uninitialized when used here}} +} diff --git a/test/SemaCXX/uninitialized.cpp b/test/SemaCXX/uninitialized.cpp index 7879e7c7531f..13d287bf1af6 100644 --- a/test/SemaCXX/uninitialized.cpp +++ b/test/SemaCXX/uninitialized.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -std=c++11 -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wall -Wuninitialized -Wno-unused-value -std=c++11 -verify %s int foo(int x); int bar(int* x); @@ -10,9 +10,6 @@ int far(const int& x); int a = a; // no-warning: used to signal intended lack of initialization. int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} int c = (c + c); // expected-warning 2 {{variable 'c' is uninitialized when used within its own initialization}} -void test() { - int d = ({ d + d ;}); // expected-warning {{variable 'd' is uninitialized when used within its own initialization}} -} int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} @@ -24,6 +21,51 @@ int i = boo(i); int j = far(j); int k = __alignof__(k); +int l = k ? l : l; // expected-warning 2{{variable 'l' is uninitialized when used within its own initialization}} +int m = 1 + (k ? m : m); // expected-warning 2{{variable 'm' is uninitialized when used within its own initialization}} +int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} + +void test_stuff () { + int a = a; // no-warning: used to signal intended lack of initialization. + int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} + int c = (c + c); // expected-warning {{variable 'c' is uninitialized when used within its own initialization}} + int d = ({ d + d ;}); // expected-warning {{variable 'd' is uninitialized when used within its own initialization}} + int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} + int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} + + // Thes don't warn as they don't require the value. + int g = sizeof(g); + void* ptr = &ptr; + int h = bar(&h); + int i = boo(i); + int j = far(j); + int k = __alignof__(k); + + int l = k ? l : l; // FIXME: warn here + int m = 1 + (k ? m : m); // FIXME: warn here + int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} + + for (;;) { + int a = a; // no-warning: used to signal intended lack of initialization. + int b = b + 1; // expected-warning {{variable 'b' is uninitialized when used within its own initialization}} + int c = (c + c); // expected-warning {{variable 'c' is uninitialized when used within its own initialization}} + int d = ({ d + d ;}); // expected-warning {{variable 'd' is uninitialized when used within its own initialization}} + int e = static_cast<long>(e) + 1; // expected-warning {{variable 'e' is uninitialized when used within its own initialization}} + int f = foo(f); // expected-warning {{variable 'f' is uninitialized when used within its own initialization}} + + // Thes don't warn as they don't require the value. + int g = sizeof(g); + void* ptr = &ptr; + int h = bar(&h); + int i = boo(i); + int j = far(j); + int k = __alignof__(k); + + int l = k ? l : l; // FIXME: warn here + int m = 1 + (k ? m : m); // FIXME: warn here + int n = -n; // expected-warning {{variable 'n' is uninitialized when used within its own initialization}} + } +} // Test self-references with record types. class A { @@ -48,8 +90,9 @@ class A { A getA() { return A(); } A getA(int x) { return A(); } A getA(A* a) { return A(); } +A getA(A a) { return A(); } -void setupA() { +void setupA(bool x) { A a1; a1.set(a1.get()); A a2(a1.get()); @@ -69,8 +112,33 @@ void setupA() { A a15 = getA(a15.num); // expected-warning {{variable 'a15' is uninitialized when used within its own initialization}} A a16(&a16.num); // expected-warning {{variable 'a16' is uninitialized when used within its own initialization}} A a17(a17.get2()); // expected-warning {{variable 'a17' is uninitialized when used within its own initialization}} + A a18 = x ? a18 : a17; // expected-warning {{variable 'a18' is uninitialized when used within its own initialization}} + A a19 = getA(x ? a19 : a17); // expected-warning {{variable 'a19' is uninitialized when used within its own initialization}} } +bool x; + +A a1; +A a2(a1.get()); +A a3(a1); +A a4(&a4); +A a5(a5.zero()); +A a6(a6.ONE); +A a7 = getA(); +A a8 = getA(a8.TWO); +A a9 = getA(&a9); +A a10(a10.count); + +A a11(a11); // expected-warning {{variable 'a11' is uninitialized when used within its own initialization}} +A a12(a12.get()); // expected-warning {{variable 'a12' is uninitialized when used within its own initialization}} +A a13(a13.num); // expected-warning {{variable 'a13' is uninitialized when used within its own initialization}} +A a14 = A(a14); // expected-warning {{variable 'a14' is uninitialized when used within its own initialization}} +A a15 = getA(a15.num); // expected-warning {{variable 'a15' is uninitialized when used within its own initialization}} +A a16(&a16.num); // expected-warning {{variable 'a16' is uninitialized when used within its own initialization}} +A a17(a17.get2()); // expected-warning {{variable 'a17' is uninitialized when used within its own initialization}} +A a18 = x ? a18 : a17; // expected-warning {{variable 'a18' is uninitialized when used within its own initialization}} +A a19 = getA(x ? a19 : a17); // expected-warning {{variable 'a19' is uninitialized when used within its own initialization}} + struct B { // POD struct. int x; @@ -97,6 +165,7 @@ void setupB() { B b7(b7); // expected-warning {{variable 'b7' is uninitialized when used within its own initialization}} B b8 = getB(b8.x); // expected-warning {{variable 'b8' is uninitialized when used within its own initialization}} B b9 = getB(b9.y); // expected-warning {{variable 'b9' is uninitialized when used within its own initialization}} + B b10 = getB(-b10.x); // expected-warning {{variable 'b10' is uninitialized when used within its own initialization}} } // Also test similar constructs in a field's initializer. @@ -106,9 +175,9 @@ struct S { S(bool (*)[1]) : x(x) {} // expected-warning {{field is uninitialized when used here}} S(bool (*)[2]) : x(x + 1) {} // expected-warning {{field is uninitialized when used here}} - S(bool (*)[3]) : x(x + x) {} // expected-warning {{field is uninitialized when used here}} + S(bool (*)[3]) : x(x + x) {} // expected-warning 2{{field is uninitialized when used here}} S(bool (*)[4]) : x(static_cast<long>(x) + 1) {} // expected-warning {{field is uninitialized when used here}} - S(bool (*)[5]) : x(foo(x)) {} // FIXME: This should warn! + S(bool (*)[5]) : x(foo(x)) {} // expected-warning {{field is uninitialized when used here}} // These don't actually require the value of x and so shouldn't warn. S(char (*)[1]) : x(sizeof(x)) {} // rdar://8610363 @@ -164,6 +233,86 @@ int pr12325(int params) { // Test lambda expressions with -Wuninitialized int test_lambda() { - auto f1 = [] (int x, int y) { int z; return x + y + z; }; // expected-warning {{C++11 requires lambda with omitted result type to consist of a single return statement}} expected-warning{{variable 'z' is uninitialized when used here}} expected-note {{initialize the variable 'z' to silence this warning}} + auto f1 = [] (int x, int y) { int z; return x + y + z; }; // expected-warning{{variable 'z' is uninitialized when used here}} expected-note {{initialize the variable 'z' to silence this warning}} return f1(1, 2); } + +namespace { + struct A { + enum { A1 }; + static int A2() {return 5;} + int A3; + int A4() { return 5;} + }; + + struct B { + A a; + }; + + struct C { + C() {} + C(int x) {} + static A a; + B b; + }; + A C::a = A(); + + // Accessing non-static members will give a warning. + struct D { + C c; + D(char (*)[1]) : c(c.b.a.A1) {} + D(char (*)[2]) : c(c.b.a.A2()) {} + D(char (*)[3]) : c(c.b.a.A3) {} // expected-warning {{field is uninitialized when used here}} + D(char (*)[4]) : c(c.b.a.A4()) {} // expected-warning {{field is uninitialized when used here}} + + // c::a is static, so it is already initialized + D(char (*)[5]) : c(c.a.A1) {} + D(char (*)[6]) : c(c.a.A2()) {} + D(char (*)[7]) : c(c.a.A3) {} + D(char (*)[8]) : c(c.a.A4()) {} + }; + + struct E { + int a, b, c; + E(char (*)[1]) : a(a ? b : c) {} // expected-warning {{field is uninitialized when used here}} + E(char (*)[2]) : a(b ? a : a) {} // expected-warning 2{{field is uninitialized when used here}} + E(char (*)[3]) : a(b ? (a) : c) {} // expected-warning {{field is uninitialized when used here}} + E(char (*)[4]) : a(b ? c : (a+c)) {} // expected-warning {{field is uninitialized when used here}} + E(char (*)[5]) : a(b ? c : b) {} + + E(char (*)[6]) : a(a ?: a) {} // expected-warning 2{{field is uninitialized when used here}} + E(char (*)[7]) : a(b ?: a) {} // expected-warning {{field is uninitialized when used here}} + E(char (*)[8]) : a(a ?: c) {} // expected-warning {{field is uninitialized when used here}} + E(char (*)[9]) : a(b ?: c) {} + + E(char (*)[10]) : a((a, a, b)) {} + E(char (*)[11]) : a((c + a, a + 1, b)) {} // expected-warning 2{{field is uninitialized when used here}} + E(char (*)[12]) : a((b + c, c, a)) {} // expected-warning {{field is uninitialized when used here}} + E(char (*)[13]) : a((a, a, a, a)) {} // expected-warning {{field is uninitialized when used here}} + E(char (*)[14]) : a((b, c, c)) {} + }; + + struct F { + int a; + F* f; + F(int) {} + F() {} + }; + + int F::*ptr = &F::a; + F* F::*f_ptr = &F::f; + struct G { + F f1, f2; + F *f3, *f4; + G(char (*)[1]) : f1(f1) {} // expected-warning {{field is uninitialized when used here}} + G(char (*)[2]) : f2(f1) {} + G(char (*)[3]) : f2(F()) {} + + G(char (*)[4]) : f1(f1.*ptr) {} // expected-warning {{field is uninitialized when used here}} + G(char (*)[5]) : f2(f1.*ptr) {} + + G(char (*)[6]) : f3(f3) {} // expected-warning {{field is uninitialized when used here}} + G(char (*)[7]) : f3(f3->*f_ptr) {} // expected-warning {{field is uninitialized when used here}} + G(char (*)[8]) : f3(new F(f3->*ptr)) {} // expected-warning {{field is uninitialized when used here}} + }; +} diff --git a/test/SemaCXX/unknown-type-name.cpp b/test/SemaCXX/unknown-type-name.cpp index 5f8d8caae698..893e0cc5dc86 100644 --- a/test/SemaCXX/unknown-type-name.cpp +++ b/test/SemaCXX/unknown-type-name.cpp @@ -20,6 +20,13 @@ struct A { typedef T type; type f(); + + type g(); + + static int n; + static type m; + static int h(T::type, int); // expected-error{{missing 'typename'}} + static int h(T::type x, char); // expected-error{{missing 'typename'}} }; template<typename T> @@ -27,3 +34,52 @@ A<T>::type g(T t) { return t; } // expected-error{{missing 'typename'}} template<typename T> A<T>::type A<T>::f() { return type(); } // expected-error{{missing 'typename'}} + +template<typename T> +void f(T::type) { } // expected-error{{missing 'typename'}} + +template<typename T> +void g(T::type x) { } // expected-error{{missing 'typename'}} + +template<typename T> +void f(T::type, int) { } // expected-error{{missing 'typename'}} + +template<typename T> +void f(T::type x, char) { } // expected-error{{missing 'typename'}} + +template<typename T> +void f(int, T::type) { } // expected-error{{missing 'typename'}} + +template<typename T> +void f(char, T::type x) { } // expected-error{{missing 'typename'}} + +template<typename T> +void f(int, T::type, int) { } // expected-error{{missing 'typename'}} + +template<typename T> +void f(int, T::type x, char) { } // expected-error{{missing 'typename'}} + +template<typename T> int A<T>::n(T::value); // ok +template<typename T> +A<T>::type // expected-error{{missing 'typename'}} +A<T>::m(T::value, 0); // ok + +template<typename T> int A<T>::h(T::type, int) {} // expected-error{{missing 'typename'}} +template<typename T> int A<T>::h(T::type x, char) {} // expected-error{{missing 'typename'}} + +template<typename T> int h(T::type, int); // expected-error{{missing 'typename'}} +template<typename T> int h(T::type x, char); // expected-error{{missing 'typename'}} + +template<typename T> int junk1(T::junk); // expected-error{{declared as a template}} +template<typename T> int junk2(T::junk) throw(); // expected-error{{missing 'typename'}} +template<typename T> int junk3(T::junk) = delete; // expected-error{{missing 'typename'}} expected-warning{{C++11}} +template<typename T> int junk4(T::junk j); // expected-error{{missing 'typename'}} + +// FIXME: We can tell this was intended to be a function because it does not +// have a dependent nested name specifier. +template<typename T> int i(T::type, int()); // expected-error{{variable 'i' declared as a template}} + +// FIXME: We know which type specifier should have been specified here. Provide +// a fix-it to add 'typename A<T>::type' +template<typename T> +A<T>::g() { } // expected-error{{requires a type specifier}} diff --git a/test/SemaCXX/unused.cpp b/test/SemaCXX/unused.cpp index 88783ce1a6b3..54898c828ec6 100644 --- a/test/SemaCXX/unused.cpp +++ b/test/SemaCXX/unused.cpp @@ -1,24 +1,36 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s + // PR4103 : Make sure we don't get a bogus unused expression warning -class APInt { - char foo; -}; -class APSInt : public APInt { - char bar; -public: - APSInt &operator=(const APSInt &RHS); -}; +namespace PR4103 { + class APInt { + char foo; + }; + class APSInt : public APInt { + char bar; + public: + APSInt &operator=(const APSInt &RHS); + }; -APSInt& APSInt::operator=(const APSInt &RHS) { - APInt::operator=(RHS); - return *this; -} + APSInt& APSInt::operator=(const APSInt &RHS) { + APInt::operator=(RHS); + return *this; + } -template<typename T> -struct X { - X(); -}; + template<typename T> + struct X { + X(); + }; + + void test() { + X<int>(); + } +} -void test() { - X<int>(); +namespace derefvolatile { + void f(volatile char* x) { + *x; // expected-warning {{expression result unused; assign into a variable to force a volatile load}} + (void)*x; // expected-warning {{expression result unused; assign into a variable to force a volatile load}} + volatile char y = 10; + (void)y; // don't warn here, because it's a common pattern. + } } diff --git a/test/SemaCXX/user-defined-conversions.cpp b/test/SemaCXX/user-defined-conversions.cpp index 43ec5a3d4ab9..284a31069288 100644 --- a/test/SemaCXX/user-defined-conversions.cpp +++ b/test/SemaCXX/user-defined-conversions.cpp @@ -69,7 +69,7 @@ void test_conversion(ConvertibleToBase ctb, ConvertibleToDerived ctd, } struct X1 { - X1(X1&); // expected-note{{candidate constructor not viable: no known conversion from 'X1' to 'X1 &' for 1st argument}} + X1(X1&); // expected-note{{candidate constructor not viable: expects an l-value for 1st argument}} }; struct X2 { diff --git a/test/SemaCXX/virtuals.cpp b/test/SemaCXX/virtuals.cpp index ea7d203ca70f..a340e9d86b65 100644 --- a/test/SemaCXX/virtuals.cpp +++ b/test/SemaCXX/virtuals.cpp @@ -30,7 +30,7 @@ A fn(A) // expected-error{{parameter type 'A' is an abstract class}} \ // expected-error{{return type 'A' is an abstract class}} { A a; // expected-error{{variable type 'A' is an abstract class}} - (void)static_cast<A>(0); + (void)static_cast<A>(0); // expected-error{{allocating an object of abstract class type 'A'}} try { } catch(A) { // expected-error{{variable type 'A' is an abstract class}} } diff --git a/test/SemaCXX/warn-deprecated-header.cpp b/test/SemaCXX/warn-deprecated-header.cpp index f6ac2cb6393a..015e7751b93a 100644 --- a/test/SemaCXX/warn-deprecated-header.cpp +++ b/test/SemaCXX/warn-deprecated-header.cpp @@ -1,6 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -fdeprecated-macro -verify %s // RUN: %clang_cc1 -fsyntax-only -Werror %s +// expected-warning@+2 {{This file is deprecated.}} #ifdef __DEPRECATED -#warning This file is deprecated. // expected-warning {{This file is deprecated.}} +#warning This file is deprecated. #endif diff --git a/test/SemaCXX/warn-literal-conversion.cpp b/test/SemaCXX/warn-literal-conversion.cpp index 5fcae5dc80e6..d7bec4c73e5b 100644 --- a/test/SemaCXX/warn-literal-conversion.cpp +++ b/test/SemaCXX/warn-literal-conversion.cpp @@ -5,29 +5,29 @@ void foo(int y); // Warn when a literal float or double is assigned or bound to an integer. void test0() { // Float - int y0 = 1.2222F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y1 = (1.2222F); // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y2 = (((1.2222F))); // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y3 = 12E-1F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y4 = 1.23E1F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} + int y0 = 1.2222F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2222 to 1}} + int y1 = (1.2222F); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2222 to 1}} + int y2 = (((1.2222F))); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2222 to 1}} + int y3 = 12E-1F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2 to 1}} + int y4 = 1.23E1F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 12.3 to 12}} // Double - int y5 = 1.2222; // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y6 = 12E-1; // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y7 = 1.23E1; // expected-warning {{implicit conversion turns literal floating-point number into integer}} - int y8 = (1.23E1); // expected-warning {{implicit conversion turns literal floating-point number into integer}} + int y5 = 1.2222; // expected-warning {{implicit conversion from 'double' to 'int' changes value from 1.2222 to 1}} + int y6 = 12E-1; // expected-warning {{implicit conversion from 'double' to 'int' changes value from 1.2 to 1}} + int y7 = 1.23E1; // expected-warning {{implicit conversion from 'double' to 'int' changes value from 12.3 to 12}} + int y8 = (1.23E1); // expected-warning {{implicit conversion from 'double' to 'int' changes value from 12.3 to 12}} // Test assignment to an existing variable. - y8 = 2.22F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} + y8 = 2.22F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 2.22 to 2}} // Test direct initialization. - int y9(1.23F); // expected-warning {{implicit conversion turns literal floating-point number into integer}} + int y9(1.23F); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.23 to 1}} // Test passing a literal floating-point value to a function that takes an integer. - foo(1.2F); // expected-warning {{implicit conversion turns literal floating-point number into integer}} + foo(1.2F); // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2 to 1}} - int y10 = -1.2F; // expected-warning {{implicit conversion turns literal floating-point number into integer}} + int y10 = -1.2F; // expected-warning {{implicit conversion from 'float' to 'int' changes value from 1.2 to 1}} - // -Wconversion-literal does NOT catch const values. + // -Wliteral-conversion does NOT catch const values. // (-Wconversion DOES catch them.) static const float sales_tax_rate = .095F; int z = sales_tax_rate; diff --git a/test/SemaCXX/warn-loop-analysis.cpp b/test/SemaCXX/warn-loop-analysis.cpp new file mode 100644 index 000000000000..627bc51d1b0f --- /dev/null +++ b/test/SemaCXX/warn-loop-analysis.cpp @@ -0,0 +1,154 @@ +// RUN: %clang_cc1 -fsyntax-only -Wloop-analysis -verify %s + +struct S { + bool stop() { return false; } + bool keep_running; +}; + +void by_ref(int &value) { } +void by_value(int value) { } +void by_pointer(int *value) {} + +void test1() { + S s; + for (; !s.stop();) {} + for (; s.keep_running;) {} + for (int i; i < 1; ++i) {} + for (int i; i < 1; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (int i; i < 1; ) { ++i; } + for (int i; i < 1; ) { return; } + for (int i; i < 1; ) { break; } + for (int i; i < 1; ) { goto exit_loop; } +exit_loop: + for (int i; i < 1; ) { by_ref(i); } + for (int i; i < 1; ) { by_value(i); } // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (int i; i < 1; ) { by_pointer(&i); } + + for (int i; i < 1; ++i) + for (int j; j < 1; ++j) + { } + for (int i; i < 1; ++i) + for (int j; j < 1; ++i) // expected-warning {{variable 'j' used in loop condition not modified in loop body}} + { } + for (int i; i < 1; ++i) + for (int j; i < 1; ++j) // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + { } + + for (int *i, *j; i < j; ++i) {} + for (int *i, *j; i < j;) {} // expected-warning {{variables 'i' and 'j' used in loop condition not modified in loop body}} + + // Dereferencing pointers is ignored for now. + for (int *i; *i; ) {} +} + +void test2() { + int i, j, k; + int *ptr; + + // Testing CastExpr + for (; i; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (; i; ) { i = 5; } + + // Testing BinaryOperator + for (; i < j; ) {} // expected-warning {{variables 'i' and 'j' used in loop condition not modified in loop body}} + for (; i < j; ) { i = 5; } + for (; i < j; ) { j = 5; } + + // Testing IntegerLiteral + for (; i < 5; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (; i < 5; ) { i = 5; } + + // Testing FloatingLiteral + for (; i < 5.0; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (; i < 5.0; ) { i = 5; } + + // Testing CharacterLiteral + for (; i == 'a'; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (; i == 'a'; ) { i = 5; } + + // Testing CXXBoolLiteralExpr + for (; i == true; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (; i == true; ) { i = 5; } + + // Testing GNUNullExpr + for (; ptr == __null; ) {} // expected-warning {{variable 'ptr' used in loop condition not modified in loop body}} + for (; ptr == __null; ) { ptr = &i; } + + // Testing UnaryOperator + for (; -i > 5; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (; -i > 5; ) { ++i; } + + // Testing ImaginaryLiteral + for (; i != 3i; ) {} // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (; i != 3i; ) { ++i; } + + // Testing ConditionalOperator + for (; i ? j : k; ) {} // expected-warning {{variables 'i', 'j', and 'k' used in loop condition not modified in loop body}} + for (; i ? j : k; ) { ++i; } + for (; i ? j : k; ) { ++j; } + for (; i ? j : k; ) { ++k; } + for (; i; ) { j = i ? i : i; } // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (; i; ) { j = (i = 1) ? i : i; } + for (; i; ) { j = i ? i : ++i; } + + // Testing BinaryConditionalOperator + for (; i ?: j; ) {} // expected-warning {{variables 'i' and 'j' used in loop condition not modified in loop body}} + for (; i ?: j; ) { ++i; } + for (; i ?: j; ) { ++j; } + for (; i; ) { j = i ?: i; } // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + + // Testing ParenExpr + for (; (i); ) { } // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (; (i); ) { ++i; } + + // Testing non-evaluated variables + for (; i < sizeof(j); ) { } // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (; i < sizeof(j); ) { ++j; } // expected-warning {{variable 'i' used in loop condition not modified in loop body}} + for (; i < sizeof(j); ) { ++i; } +} + +// False positive and how to silence. +void test3() { + int x; + int *ptr = &x; + for (;x<5;) { *ptr = 6; } // expected-warning {{variable 'x' used in loop condition not modified in loop body}} + + for (;x<5;) { + *ptr = 6; + (void)x; + } +} + +// Check ordering and printing of variables. Max variables is currently 4. +void test4() { + int a, b, c, d, e, f; + for (; a;); // expected-warning {{variable 'a' used in loop condition not modified in loop body}} + for (; a + b;); // expected-warning {{variables 'a' and 'b' used in loop condition not modified in loop body}} + for (; a + b + c;); // expected-warning {{variables 'a', 'b', and 'c' used in loop condition not modified in loop body}} + for (; a + b + c + d;); // expected-warning {{variables 'a', 'b', 'c', and 'd' used in loop condition not modified in loop body}} + for (; a + b + c + d + e;); // expected-warning {{variables used in loop condition not modified in loop body}} + for (; a + b + c + d + e + f;); // expected-warning {{variables used in loop condition not modified in loop body}} + for (; a + c + d + b;); // expected-warning {{variables 'a', 'c', 'd', and 'b' used in loop condition not modified in loop body}} + for (; d + c + b + a;); // expected-warning {{variables 'd', 'c', 'b', and 'a' used in loop condition not modified in loop body}} +} + +// Ensure that the warning doesn't fail when lots of variables are used +// in the conditional. +void test5() { + for (int a; a+a+a+a+a+a+a+a+a+a;); // \ + // expected-warning {{variable 'a' used in loop condition not modified in loop body}} + for (int a; a+a+a+a+a+a+a+a+a+a+a;); // \ + // expected-warning {{variable 'a' used in loop condition not modified in loop body}} + for (int a; a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a;); // \ + // expected-warning {{variable 'a' used in loop condition not modified in loop body}} + for (int a; a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a+a;);//\ + // expected-warning {{variable 'a' used in loop condition not modified in loop body}} +} + +// Ignore global variables and static variables. +int x6; +void test6() { + static int y; + for (;x6;); + for (;y;); +} diff --git a/test/SemaCXX/warn-memset-bad-sizeof.cpp b/test/SemaCXX/warn-memset-bad-sizeof.cpp index e0d28da3d589..e388634e8840 100644 --- a/test/SemaCXX/warn-memset-bad-sizeof.cpp +++ b/test/SemaCXX/warn-memset-bad-sizeof.cpp @@ -35,27 +35,27 @@ void f(Mat m, const Foo& const_foo, char *buffer) { /* Should warn */ memset(&s, 0, sizeof(&s)); // \ - // expected-warning {{argument to 'sizeof' in 'memset' call is the same expression as the destination}} + // expected-warning {{'memset' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to remove the addressof in the argument to 'sizeof' (and multiply it by the number of elements)?}} memset(ps, 0, sizeof(ps)); // \ - // expected-warning {{argument to 'sizeof' in 'memset' call is the same expression as the destination}} + // expected-warning {{'memset' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?}} memset(ps2, 0, sizeof(ps2)); // \ - // expected-warning {{argument to 'sizeof' in 'memset' call is the same expression as the destination}} + // expected-warning {{'memset' call operates on objects of type 'S' while the size is based on a different type 'PS' (aka 'S *')}} expected-note{{did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?}} memset(ps2, 0, sizeof(typeof(ps2))); // \ // expected-warning {{argument to 'sizeof' in 'memset' call is the same pointer type}} memset(ps2, 0, sizeof(PS)); // \ // expected-warning {{argument to 'sizeof' in 'memset' call is the same pointer type}} memset(heap_buffer, 0, sizeof(heap_buffer)); // \ - // expected-warning {{argument to 'sizeof' in 'memset' call is the same expression as the destination}} + // expected-warning {{'memset' call operates on objects of type 'char' while the size is based on a different type 'char *'}} expected-note{{did you mean to provide an explicit length?}} memcpy(&s, 0, sizeof(&s)); // \ - // expected-warning {{argument to 'sizeof' in 'memcpy' call is the same expression as the destination}} + // expected-warning {{'memcpy' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to remove the addressof in the argument to 'sizeof' (and multiply it by the number of elements)?}} memcpy(0, &s, sizeof(&s)); // \ - // expected-warning {{argument to 'sizeof' in 'memcpy' call is the same expression as the source}} + // expected-warning {{'memcpy' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to remove the addressof in the argument to 'sizeof' (and multiply it by the number of elements)?}} memmove(ps, 0, sizeof(ps)); // \ - // expected-warning {{argument to 'sizeof' in 'memmove' call is the same expression as the destination}} + // expected-warning {{'memmove' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?}} memcmp(ps, 0, sizeof(ps)); // \ - // expected-warning {{argument to 'sizeof' in 'memcmp' call is the same expression as the destination}} + // expected-warning {{'memcmp' call operates on objects of type 'S' while the size is based on a different type 'S *'}} expected-note{{did you mean to dereference the argument to 'sizeof' (and multiply it by the number of elements)?}} /* Shouldn't warn */ memset((void*)&s, 0, sizeof(&s)); @@ -132,14 +132,14 @@ void strcpy_and_friends() { const char* BAR = "<- this, too"; strncmp(FOO, BAR, sizeof(FOO)); // \ - // expected-warning {{argument to 'sizeof' in 'strncmp' call is the same expression as the destination}} + // expected-warning {{'strncmp' call operates on objects of type 'const char' while the size is based on a different type 'const char *'}} expected-note{{did you mean to provide an explicit length?}} strncasecmp(FOO, BAR, sizeof(FOO)); // \ - // expected-warning {{argument to 'sizeof' in 'strncasecmp' call is the same expression as the destination}} + // expected-warning {{'strncasecmp' call operates on objects of type 'const char' while the size is based on a different type 'const char *'}} expected-note{{did you mean to provide an explicit length?}} char buff[80]; strncpy(buff, BAR, sizeof(BAR)); // \ - // expected-warning {{argument to 'sizeof' in 'strncpy' call is the same expression as the source}} + // expected-warning {{'strncpy' call operates on objects of type 'const char' while the size is based on a different type 'const char *'}} expected-note{{did you mean to provide an explicit length?}} strndup(FOO, sizeof(FOO)); // \ - // expected-warning {{argument to 'sizeof' in 'strndup' call is the same expression as the source}} + // expected-warning {{'strndup' call operates on objects of type 'const char' while the size is based on a different type 'const char *'}} expected-note{{did you mean to provide an explicit length?}} } diff --git a/test/SemaCXX/warn-static-function-inheader.cpp b/test/SemaCXX/warn-static-function-inheader.cpp new file mode 100644 index 000000000000..30386d9a258c --- /dev/null +++ b/test/SemaCXX/warn-static-function-inheader.cpp @@ -0,0 +1,12 @@ +#include "warn-static-function-inheader.h" +// RUN: %clang_cc1 -fsyntax-only -verify -Wall %s +// rdar://11202617 + +static void another(void) { // expected-warning {{function 'another' is not needed and will not be emitted}} +} + +template <typename T> +void foo(void) { + thing(); + another(); +} diff --git a/test/SemaCXX/warn-static-function-inheader.h b/test/SemaCXX/warn-static-function-inheader.h new file mode 100644 index 000000000000..1c9e00b8bd22 --- /dev/null +++ b/test/SemaCXX/warn-static-function-inheader.h @@ -0,0 +1,3 @@ +static void thing(void) { // expected-warning {{'static' function 'thing' declared in header file should be declared 'static inline'}} +} + diff --git a/test/SemaCXX/warn-thread-safety-analysis.cpp b/test/SemaCXX/warn-thread-safety-analysis.cpp index 566e5c1b843b..17a1931c1594 100644 --- a/test/SemaCXX/warn-thread-safety-analysis.cpp +++ b/test/SemaCXX/warn-thread-safety-analysis.cpp @@ -1,4 +1,7 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 %s + +// FIXME: should also run %clang_cc1 -fsyntax-only -verify -Wthread-safety -std=c++11 -Wc++98-compat %s +// FIXME: should also run %clang_cc1 -fsyntax-only -verify -Wthread-safety %s #define LOCKABLE __attribute__ ((lockable)) #define SCOPED_LOCKABLE __attribute__ ((scoped_lockable)) @@ -48,6 +51,30 @@ class __attribute__((scoped_lockable)) ReaderMutexLock { ~ReaderMutexLock() __attribute__((unlock_function)); }; +class SCOPED_LOCKABLE ReleasableMutexLock { + public: + ReleasableMutexLock(Mutex *mu) EXCLUSIVE_LOCK_FUNCTION(mu); + ~ReleasableMutexLock() UNLOCK_FUNCTION(); + + void Release() UNLOCK_FUNCTION(); +}; + + +template<class T> +class SmartPtr { +public: + SmartPtr(T* p) : ptr_(p) { } + SmartPtr(const SmartPtr<T>& p) : ptr_(p.ptr_) { } + ~SmartPtr(); + + T* get() const { return ptr_; } + T* operator->() const { return ptr_; } + T& operator*() const { return *ptr_; } + +private: + T* ptr_; +}; + Mutex sls_mu; @@ -177,14 +204,11 @@ void sls_fun_bad_3() { void sls_fun_bad_4() { if (getBool()) - sls_mu.Lock(); // \ - expected-warning{{mutex 'sls_mu2' is not locked on every path through here}} \ - expected-note{{mutex acquired here}} - + sls_mu.Lock(); // expected-note{{mutex acquired here}} else - sls_mu2.Lock(); // \ - expected-note{{mutex acquired here}} -} // expected-warning{{mutex 'sls_mu' is not locked on every path through here}} + sls_mu2.Lock(); // expected-note{{mutex acquired here}} +} // expected-warning{{mutex 'sls_mu' is not locked on every path through here}} \ + // expected-warning{{mutex 'sls_mu2' is not locked on every path through here}} void sls_fun_bad_5() { sls_mu.Lock(); // expected-note {{mutex acquired here}} @@ -225,15 +249,14 @@ void sls_fun_bad_7() { void sls_fun_bad_8() { sls_mu.Lock(); // expected-note{{mutex acquired here}} - // FIXME: TERRIBLE SOURCE LOCATION! - do { // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}} - sls_mu.Unlock(); + do { + sls_mu.Unlock(); // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}} } while (getBool()); } void sls_fun_bad_9() { do { - sls_mu.Lock(); // \ + sls_mu.Lock(); // \ // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}} \ // expected-note{{mutex acquired here}} } while (getBool()); @@ -241,15 +264,15 @@ void sls_fun_bad_9() { } void sls_fun_bad_10() { - sls_mu.Lock(); // expected-note 2{{mutex acquired here}} - while(getBool()) { - sls_mu.Unlock(); // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}} + sls_mu.Lock(); // expected-note 2{{mutex acquired here}} + while(getBool()) { // expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}} + sls_mu.Unlock(); } } // expected-warning{{mutex 'sls_mu' is still locked at the end of function}} void sls_fun_bad_11() { while (getBool()) { // \ - expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}} + expected-warning{{expecting mutex 'sls_mu' to be locked at start of each loop}} sls_mu.Lock(); // expected-note {{mutex acquired here}} } sls_mu.Unlock(); // \ @@ -506,7 +529,7 @@ void late_bad_0() { LateFoo fooB; fooA.mu.Lock(); fooB.a = 5; // \ - // expected-warning{{writing variable 'a' requires locking 'mu' exclusively}} + // expected-warning{{writing variable 'a' requires locking 'fooB.mu' exclusively}} fooA.mu.Unlock(); } @@ -516,7 +539,7 @@ void late_bad_1() { b1.mu1_.Lock(); int res = b1.a_ + b3->b_; b3->b_ = *b1.q; // \ - // expected-warning{{reading the value pointed to by 'q' requires locking 'mu'}} + // expected-warning{{reading the value pointed to by 'q' requires locking 'b1.mu'}} b1.mu1_.Unlock(); b1.b_ = res; mu.Unlock(); @@ -526,7 +549,7 @@ void late_bad_2() { LateBar BarA; BarA.FooPointer->mu.Lock(); BarA.Foo.a = 2; // \ - // expected-warning{{writing variable 'a' requires locking 'mu' exclusively}} + // expected-warning{{writing variable 'a' requires locking 'BarA.Foo.mu' exclusively}} BarA.FooPointer->mu.Unlock(); } @@ -534,7 +557,7 @@ void late_bad_3() { LateBar BarA; BarA.Foo.mu.Lock(); BarA.FooPointer->a = 2; // \ - // expected-warning{{writing variable 'a' requires locking 'mu' exclusively}} + // expected-warning{{writing variable 'a' requires locking 'BarA.FooPointer->mu' exclusively}} BarA.Foo.mu.Unlock(); } @@ -542,7 +565,7 @@ void late_bad_4() { LateBar BarA; BarA.Foo.mu.Lock(); BarA.Foo2.a = 2; // \ - // expected-warning{{writing variable 'a' requires locking 'mu' exclusively}} + // expected-warning{{writing variable 'a' requires locking 'BarA.Foo2.mu' exclusively}} BarA.Foo.mu.Unlock(); } @@ -1176,13 +1199,13 @@ void main() { Foo f1, *f2; f1.mu_.Lock(); - f1.bar(); // expected-warning {{cannot call function 'bar' while mutex 'mu_' is locked}} + f1.bar(); // expected-warning {{cannot call function 'bar' while mutex 'f1.mu_' is locked}} mu2.Lock(); f1.foo(); mu2.Unlock(); f1.mu_.Unlock(); f2->mu_.Lock(); - f2->bar(); // expected-warning {{cannot call function 'bar' while mutex 'mu_' is locked}} + f2->bar(); // expected-warning {{cannot call function 'bar' while mutex 'f2->mu_' is locked}} f2->mu_.Unlock(); mu2.Lock(); w = 2; @@ -1210,7 +1233,7 @@ void func() { b1->MyLock(); b1->a_ = 5; - b2->a_ = 3; // expected-warning {{writing variable 'a_' requires locking 'mu1_' exclusively}} + b2->a_ = 3; // expected-warning {{writing variable 'a_' requires locking 'b2->mu1_' exclusively}} b2->MyLock(); b2->MyUnlock(); b1->MyUnlock(); @@ -1239,12 +1262,12 @@ int func(int i) { int x; b3->mu1_.Lock(); - res = b1.a_ + b3->b_; // expected-warning {{reading variable 'a_' requires locking 'mu1_'}} \ + res = b1.a_ + b3->b_; // expected-warning {{reading variable 'a_' requires locking 'b1.mu1_'}} \ // expected-warning {{writing variable 'res' requires locking 'mu' exclusively}} *p = i; // expected-warning {{reading variable 'p' requires locking 'mu'}} \ // expected-warning {{writing the value pointed to by 'p' requires locking 'mu' exclusively}} b1.a_ = res + b3->b_; // expected-warning {{reading variable 'res' requires locking 'mu'}} \ - // expected-warning {{writing variable 'a_' requires locking 'mu1_' exclusively}} + // expected-warning {{writing variable 'a_' requires locking 'b1.mu1_' exclusively}} b3->b_ = *b1.q; // expected-warning {{reading the value pointed to by 'q' requires locking 'mu'}} b3->mu1_.Unlock(); b1.b_ = res; // expected-warning {{reading variable 'res' requires locking 'mu'}} @@ -1269,8 +1292,8 @@ class Foo { child->Func(new_foo); // There shouldn't be any warning here as the // acquired lock is not in child. - child->bar(7); // expected-warning {{calling function 'bar' requires exclusive lock on 'lock_'}} - child->a_ = 5; // expected-warning {{writing variable 'a_' requires locking 'lock_' exclusively}} + child->bar(7); // expected-warning {{calling function 'bar' requires exclusive lock on 'child->lock_'}} + child->a_ = 5; // expected-warning {{writing variable 'a_' requires locking 'child->lock_' exclusively}} lock_.Unlock(); } @@ -1307,7 +1330,7 @@ void Foo::Func(Foo* child) { lock_.Lock(); child->lock_.Lock(); - child->Func(new_foo); // expected-warning {{cannot call function 'Func' while mutex 'lock_' is locked}} + child->Func(new_foo); // expected-warning {{cannot call function 'Func' while mutex 'child->lock_' is locked}} child->bar(7); child->a_ = 5; child->lock_.Unlock(); @@ -1355,8 +1378,8 @@ Foo *foo; void func() { - foo->f1(); // expected-warning {{calling function 'f1' requires exclusive lock on 'mu2'}} \ - // expected-warning {{calling function 'f1' requires exclusive lock on 'mu1'}} + foo->f1(); // expected-warning {{calling function 'f1' requires exclusive lock on 'foo->mu2'}} \ + // expected-warning {{calling function 'f1' requires exclusive lock on 'foo->mu1'}} } } // end namespace thread_annot_lock_42 @@ -1379,14 +1402,14 @@ void main() { Child *c; Base *b = c; - b->func1(); // expected-warning {{calling function 'func1' requires exclusive lock on 'mu_'}} + b->func1(); // expected-warning {{calling function 'func1' requires exclusive lock on 'b->mu_'}} b->mu_.Lock(); - b->func2(); // expected-warning {{cannot call function 'func2' while mutex 'mu_' is locked}} + b->func2(); // expected-warning {{cannot call function 'func2' while mutex 'b->mu_' is locked}} b->mu_.Unlock(); - c->func1(); // expected-warning {{calling function 'func1' requires exclusive lock on 'mu_'}} + c->func1(); // expected-warning {{calling function 'func1' requires exclusive lock on 'c->mu_'}} c->mu_.Lock(); - c->func2(); // expected-warning {{cannot call function 'func2' while mutex 'mu_' is locked}} + c->func2(); // expected-warning {{cannot call function 'func2' while mutex 'c->mu_' is locked}} c->mu_.Unlock(); } } // end namespace thread_annot_lock_46 @@ -1413,9 +1436,9 @@ int Foo::method1(int i) { void main() { Foo a; - a.method1(1); // expected-warning {{calling function 'method1' requires shared lock on 'mu1'}} \ + a.method1(1); // expected-warning {{calling function 'method1' requires shared lock on 'a.mu1'}} \ // expected-warning {{calling function 'method1' requires shared lock on 'mu'}} \ - // expected-warning {{calling function 'method1' requires shared lock on 'mu2'}} \ + // expected-warning {{calling function 'method1' requires shared lock on 'a.mu2'}} \ // expected-warning {{calling function 'method1' requires shared lock on 'mu3'}} } } // end namespace thread_annot_lock_67_modified @@ -1461,14 +1484,14 @@ namespace substitution_test { DataLocker dlr; dlr.lockData(d1); // expected-note {{mutex acquired here}} dlr.unlockData(d2); // \ - // expected-warning {{unlocking 'mu' that was not locked}} - } // expected-warning {{mutex 'mu' is still locked at the end of function}} + // expected-warning {{unlocking 'd2->mu' that was not locked}} + } // expected-warning {{mutex 'd1->mu' is still locked at the end of function}} void bar4(MyData* d1, MyData* d2) { DataLocker dlr; dlr.lockData(d1); foo(d2); // \ - // expected-warning {{calling function 'foo' requires exclusive lock on 'mu'}} + // expected-warning {{calling function 'foo' requires exclusive lock on 'd2->mu'}} dlr.unlockData(d1); } }; @@ -1527,7 +1550,7 @@ namespace template_member_test { struct IndirectLock { int DoNaughtyThings(T *t) { u->n = 0; // expected-warning {{reading variable 'u' requires locking 'm'}} - return t->s->n; // expected-warning {{reading variable 's' requires locking 'm'}} + return t->s->n; // expected-warning {{reading variable 's' requires locking 't->m'}} } }; @@ -1543,7 +1566,7 @@ namespace template_member_test { template<typename U> struct W { V v; void f(U u) { - v.p->f(u); // expected-warning {{reading variable 'p' requires locking 'm'}} + v.p->f(u); // expected-warning {{reading variable 'p' requires locking 'v.m'}} } }; template struct W<int>; // expected-note {{here}} @@ -1581,7 +1604,7 @@ struct TestScopedLockable { MutexLock mulock_a(&mu1); MutexLock mulock_b(&mu1); // \ // expected-warning {{locking 'mu1' that is already locked}} - } // expected-warning {{unlocking 'mu1' that was not locked}} + } void foo4() { MutexLock mulock1(&mu1), mulock2(&mu2); @@ -1606,7 +1629,7 @@ Foo fooObj; void foo() EXCLUSIVE_LOCKS_REQUIRED(fooObj.mu_); void bar() { - foo(); // expected-warning {{calling function 'foo' requires exclusive lock on 'mu_'}} + foo(); // expected-warning {{calling function 'foo' requires exclusive lock on 'fooObj.mu_'}} fooObj.mu_.Lock(); foo(); fooObj.mu_.Unlock(); @@ -1679,7 +1702,7 @@ struct TestTryLock { bool b2 = b; if (cond) b = true; - if (b) { // b should be unknown at this point, becuase of the join point + if (b) { // b should be unknown at this point, because of the join point a = 8; // expected-warning {{writing variable 'a' requires locking 'mu' exclusively}} } if (b2) { // b2 should be known at this point. @@ -1806,7 +1829,7 @@ void test() { f1.mu_.Unlock(); bt.barTD(&f1); // \ - // expected-warning {{calling function 'barTD' requires exclusive lock on 'mu_'}} + // expected-warning {{calling function 'barTD' requires exclusive lock on 'f1.mu_'}} bt.fooBase.mu_.Unlock(); bt.fooBaseT.mu_.Unlock(); @@ -1814,7 +1837,7 @@ void test() { Cell<int> cell; cell.data = 0; // \ - // expected-warning {{writing variable 'data' requires locking 'mu_' exclusively}} + // expected-warning {{writing variable 'data' requires locking 'cell.mu_' exclusively}} cell.foo(); cell.mu_.Lock(); cell.fooEx(); @@ -1883,7 +1906,7 @@ void Foo::foo1(Foo *f_defined) { void test() { Foo myfoo; myfoo.foo1(&myfoo); // \ - // expected-warning {{calling function 'foo1' requires exclusive lock on 'mu_'}} + // expected-warning {{calling function 'foo1' requires exclusive lock on 'myfoo.mu_'}} myfoo.mu_.Lock(); myfoo.foo1(&myfoo); myfoo.mu_.Unlock(); @@ -1998,29 +2021,28 @@ void test() { Foo myFoo; myFoo.foo2(); // \ - // expected-warning {{calling function 'foo2' requires exclusive lock on 'mu_'}} + // expected-warning {{calling function 'foo2' requires exclusive lock on 'myFoo.mu_'}} myFoo.foo3(&myFoo); // \ - // expected-warning {{calling function 'foo3' requires exclusive lock on 'mu_'}} + // expected-warning {{calling function 'foo3' requires exclusive lock on 'myFoo.mu_'}} myFoo.fooT1(dummy); // \ - // expected-warning {{calling function 'fooT1' requires exclusive lock on 'mu_'}} + // expected-warning {{calling function 'fooT1' requires exclusive lock on 'myFoo.mu_'}} - // FIXME: uncomment with template instantiation of attributes patch - // myFoo.fooT2(dummy); // expected warning + myFoo.fooT2(dummy); // \ + // expected-warning {{calling function 'fooT2' requires exclusive lock on 'myFoo.mu_'}} fooF1(&myFoo); // \ - // expected-warning {{calling function 'fooF1' requires exclusive lock on 'mu_'}} + // expected-warning {{calling function 'fooF1' requires exclusive lock on 'myFoo.mu_'}} fooF2(&myFoo); // \ - // expected-warning {{calling function 'fooF2' requires exclusive lock on 'mu_'}} + // expected-warning {{calling function 'fooF2' requires exclusive lock on 'myFoo.mu_'}} fooF3(&myFoo); // \ - // expected-warning {{calling function 'fooF3' requires exclusive lock on 'mu_'}} + // expected-warning {{calling function 'fooF3' requires exclusive lock on 'myFoo.mu_'}} myFoo.mu_.Lock(); myFoo.foo2(); myFoo.foo3(&myFoo); myFoo.fooT1(dummy); - // FIXME: uncomment with template instantiation of attributes patch - // myFoo.fooT2(dummy); + myFoo.fooT2(dummy); fooF1(&myFoo); fooF2(&myFoo); @@ -2029,7 +2051,7 @@ void test() { FooT<int> myFooT; myFooT.foo(); // \ - // expected-warning {{calling function 'foo' requires exclusive lock on 'mu_'}} + // expected-warning {{calling function 'foo' requires exclusive lock on 'myFooT.mu_'}} } } // end namespace FunctionDefinitionTest @@ -2213,31 +2235,887 @@ void test() { bar.getFoo().mu_.Lock(); bar.getFooey().a = 0; // \ - // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + // expected-warning {{writing variable 'a' requires locking 'bar.getFooey().mu_' exclusively}} bar.getFoo().mu_.Unlock(); bar.getFoo2(a).mu_.Lock(); bar.getFoo2(b).a = 0; // \ - // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + // expected-warning {{writing variable 'a' requires locking 'bar.getFoo2(b).mu_' exclusively}} bar.getFoo2(a).mu_.Unlock(); bar.getFoo3(a, b).mu_.Lock(); bar.getFoo3(a, c).a = 0; // \ - // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + // expected-warning {{writing variable 'a' requires locking 'bar.getFoo3(a,c).mu_' exclusively}} bar.getFoo3(a, b).mu_.Unlock(); getBarFoo(bar, a).mu_.Lock(); getBarFoo(bar, b).a = 0; // \ - // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + // expected-warning {{writing variable 'a' requires locking 'getBarFoo(bar,b).mu_' exclusively}} getBarFoo(bar, a).mu_.Unlock(); (a > 0 ? fooArray[1] : fooArray[b]).mu_.Lock(); (a > 0 ? fooArray[b] : fooArray[c]).a = 0; // \ - // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + // expected-warning {{writing variable 'a' requires locking '((a#_)#_#fooArray[b]).mu_' exclusively}} (a > 0 ? fooArray[1] : fooArray[b]).mu_.Unlock(); } -} // end namespace +} // end namespace MoreLockExpressions + + +namespace TrylockJoinPoint { + +class Foo { + Mutex mu; + bool c; + + void foo() { + if (c) { + if (!mu.TryLock()) + return; + } else { + mu.Lock(); + } + mu.Unlock(); + } +}; + +} // end namespace TrylockJoinPoint + + +namespace LockReturned { + +class Foo { +public: + int a GUARDED_BY(mu_); + void foo() EXCLUSIVE_LOCKS_REQUIRED(mu_); + void foo2(Foo* f) EXCLUSIVE_LOCKS_REQUIRED(mu_, f->mu_); + + static void sfoo(Foo* f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_); + + Mutex* getMu() LOCK_RETURNED(mu_); + + Mutex mu_; + + static Mutex* getMu(Foo* f) LOCK_RETURNED(f->mu_); +}; + + +// Calls getMu() directly to lock and unlock +void test1(Foo* f1, Foo* f2) { + f1->a = 0; // expected-warning {{writing variable 'a' requires locking 'f1->mu_' exclusively}} + f1->foo(); // expected-warning {{calling function 'foo' requires exclusive lock on 'f1->mu_'}} + + f1->foo2(f2); // expected-warning {{calling function 'foo2' requires exclusive lock on 'f1->mu_'}} \ + // expected-warning {{calling function 'foo2' requires exclusive lock on 'f2->mu_'}} + Foo::sfoo(f1); // expected-warning {{calling function 'sfoo' requires exclusive lock on 'f1->mu_'}} + + f1->getMu()->Lock(); + + f1->a = 0; + f1->foo(); + f1->foo2(f2); // expected-warning {{calling function 'foo2' requires exclusive lock on 'f2->mu_'}} + + Foo::getMu(f2)->Lock(); + f1->foo2(f2); + Foo::getMu(f2)->Unlock(); + + Foo::sfoo(f1); + + f1->getMu()->Unlock(); +} + + +Mutex* getFooMu(Foo* f) LOCK_RETURNED(Foo::getMu(f)); + +class Bar : public Foo { +public: + int b GUARDED_BY(getMu()); + void bar() EXCLUSIVE_LOCKS_REQUIRED(getMu()); + void bar2(Bar* g) EXCLUSIVE_LOCKS_REQUIRED(getMu(this), g->getMu()); + + static void sbar(Bar* g) EXCLUSIVE_LOCKS_REQUIRED(g->getMu()); + static void sbar2(Bar* g) EXCLUSIVE_LOCKS_REQUIRED(getFooMu(g)); +}; + + + +// Use getMu() within other attributes. +// This requires at lest levels of substitution, more in the case of +void test2(Bar* b1, Bar* b2) { + b1->b = 0; // expected-warning {{writing variable 'b' requires locking 'b1->mu_' exclusively}} + b1->bar(); // expected-warning {{calling function 'bar' requires exclusive lock on 'b1->mu_'}} + b1->bar2(b2); // expected-warning {{calling function 'bar2' requires exclusive lock on 'b1->mu_'}} \ + // expected-warning {{calling function 'bar2' requires exclusive lock on 'b2->mu_'}} + Bar::sbar(b1); // expected-warning {{calling function 'sbar' requires exclusive lock on 'b1->mu_'}} + Bar::sbar2(b1); // expected-warning {{calling function 'sbar2' requires exclusive lock on 'b1->mu_'}} + + b1->getMu()->Lock(); + + b1->b = 0; + b1->bar(); + b1->bar2(b2); // expected-warning {{calling function 'bar2' requires exclusive lock on 'b2->mu_'}} + + b2->getMu()->Lock(); + b1->bar2(b2); + + b2->getMu()->Unlock(); + + Bar::sbar(b1); + Bar::sbar2(b1); + + b1->getMu()->Unlock(); +} + + +// Sanity check -- lock the mutex directly, but use attributes that call getMu() +// Also lock the mutex using getFooMu, which calls a lock_returned function. +void test3(Bar* b1, Bar* b2) { + b1->mu_.Lock(); + b1->b = 0; + b1->bar(); + + getFooMu(b2)->Lock(); + b1->bar2(b2); + getFooMu(b2)->Unlock(); + + Bar::sbar(b1); + Bar::sbar2(b1); + + b1->mu_.Unlock(); +} + +} // end namespace LockReturned + + +namespace ReleasableScopedLock { + +class Foo { + Mutex mu_; + bool c; + int a GUARDED_BY(mu_); + + void test1(); + void test2(); + void test3(); + void test4(); + void test5(); +}; + + +void Foo::test1() { + ReleasableMutexLock rlock(&mu_); + rlock.Release(); +} + +void Foo::test2() { + ReleasableMutexLock rlock(&mu_); + if (c) { // test join point -- held/not held during release + rlock.Release(); + } +} + +void Foo::test3() { + ReleasableMutexLock rlock(&mu_); + a = 0; + rlock.Release(); + a = 1; // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} +} + +void Foo::test4() { + ReleasableMutexLock rlock(&mu_); + rlock.Release(); + rlock.Release(); // expected-warning {{unlocking 'mu_' that was not locked}} +} + +void Foo::test5() { + ReleasableMutexLock rlock(&mu_); + if (c) { + rlock.Release(); + } + // no warning on join point for managed lock. + rlock.Release(); // expected-warning {{unlocking 'mu_' that was not locked}} +} + + +} // end namespace ReleasableScopedLock + + +namespace TrylockFunctionTest { + +class Foo { +public: + Mutex mu1_; + Mutex mu2_; + bool c; + + bool lockBoth() EXCLUSIVE_TRYLOCK_FUNCTION(true, mu1_, mu2_); +}; + +bool Foo::lockBoth() { + if (!mu1_.TryLock()) + return false; + + mu2_.Lock(); + if (!c) { + mu1_.Unlock(); + mu2_.Unlock(); + return false; + } + + return true; +} + + +} // end namespace TrylockFunctionTest + + + +namespace DoubleLockBug { + +class Foo { +public: + Mutex mu_; + int a GUARDED_BY(mu_); + + void foo1() EXCLUSIVE_LOCKS_REQUIRED(mu_); + int foo2() SHARED_LOCKS_REQUIRED(mu_); +}; + + +void Foo::foo1() EXCLUSIVE_LOCKS_REQUIRED(mu_) { + a = 0; +} + +int Foo::foo2() SHARED_LOCKS_REQUIRED(mu_) { + return a; +} + +} + + + +namespace UnlockBug { + +class Foo { +public: + Mutex mutex_; + + void foo1() EXCLUSIVE_LOCKS_REQUIRED(mutex_) { // expected-note {{mutex acquired here}} + mutex_.Unlock(); + } // expected-warning {{expecting mutex 'mutex_' to be locked at the end of function}} + + + void foo2() SHARED_LOCKS_REQUIRED(mutex_) { // expected-note {{mutex acquired here}} + mutex_.Unlock(); + } // expected-warning {{expecting mutex 'mutex_' to be locked at the end of function}} +}; + +} // end namespace UnlockBug + + + +namespace FoolishScopedLockableBug { + +class SCOPED_LOCKABLE WTF_ScopedLockable { +public: + WTF_ScopedLockable(Mutex* mu) EXCLUSIVE_LOCK_FUNCTION(mu); + + // have to call release() manually; + ~WTF_ScopedLockable(); + + void release() UNLOCK_FUNCTION(); +}; + + +class Foo { + Mutex mu_; + int a GUARDED_BY(mu_); + bool c; + + void doSomething(); + + void test1() { + WTF_ScopedLockable wtf(&mu_); + wtf.release(); + } + + void test2() { + WTF_ScopedLockable wtf(&mu_); // expected-note {{mutex acquired here}} + } // expected-warning {{mutex 'mu_' is still locked at the end of function}} + + void test3() { + if (c) { + WTF_ScopedLockable wtf(&mu_); + wtf.release(); + } + } + + void test4() { + if (c) { + doSomething(); + } + else { + WTF_ScopedLockable wtf(&mu_); + wtf.release(); + } + } + + void test5() { + if (c) { + WTF_ScopedLockable wtf(&mu_); // expected-note {{mutex acquired here}} + } + } // expected-warning {{mutex 'mu_' is not locked on every path through here}} + + void test6() { + if (c) { + doSomething(); + } + else { + WTF_ScopedLockable wtf(&mu_); // expected-note {{mutex acquired here}} + } + } // expected-warning {{mutex 'mu_' is not locked on every path through here}} +}; + + +} // end namespace FoolishScopedLockableBug + + + +namespace TemporaryCleanupExpr { + +class Foo { + int a GUARDED_BY(getMutexPtr().get()); + + SmartPtr<Mutex> getMutexPtr(); + + void test(); +}; + + +void Foo::test() { + { + ReaderMutexLock lock(getMutexPtr().get()); + int b = a; + } + int b = a; // expected-warning {{reading variable 'a' requires locking 'getMutexPtr()'}} +} + +} // end namespace TemporaryCleanupExpr + + + +namespace SmartPointerTests { + +class Foo { +public: + SmartPtr<Mutex> mu_; + int a GUARDED_BY(mu_); + int b GUARDED_BY(mu_.get()); + int c GUARDED_BY(*mu_); + + void Lock() EXCLUSIVE_LOCK_FUNCTION(mu_); + void Unlock() UNLOCK_FUNCTION(mu_); + + void test0(); + void test1(); + void test2(); + void test3(); + void test4(); + void test5(); + void test6(); + void test7(); + void test8(); +}; + +void Foo::test0() { + a = 0; // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + b = 0; // expected-warning {{writing variable 'b' requires locking 'mu_' exclusively}} + c = 0; // expected-warning {{writing variable 'c' requires locking 'mu_' exclusively}} +} + +void Foo::test1() { + mu_->Lock(); + a = 0; + b = 0; + c = 0; + mu_->Unlock(); +} + +void Foo::test2() { + (*mu_).Lock(); + a = 0; + b = 0; + c = 0; + (*mu_).Unlock(); +} + + +void Foo::test3() { + mu_.get()->Lock(); + a = 0; + b = 0; + c = 0; + mu_.get()->Unlock(); +} + + +void Foo::test4() { + MutexLock lock(mu_.get()); + a = 0; + b = 0; + c = 0; +} + + +void Foo::test5() { + MutexLock lock(&(*mu_)); + a = 0; + b = 0; + c = 0; +} + + +void Foo::test6() { + Lock(); + a = 0; + b = 0; + c = 0; + Unlock(); +} + + +void Foo::test7() { + { + Lock(); + mu_->Unlock(); + } + { + mu_->Lock(); + Unlock(); + } + { + mu_.get()->Lock(); + mu_->Unlock(); + } + { + mu_->Lock(); + mu_.get()->Unlock(); + } + { + mu_.get()->Lock(); + (*mu_).Unlock(); + } + { + (*mu_).Lock(); + mu_->Unlock(); + } +} + + +void Foo::test8() { + mu_->Lock(); + mu_.get()->Lock(); // expected-warning {{locking 'mu_' that is already locked}} + (*mu_).Lock(); // expected-warning {{locking 'mu_' that is already locked}} + mu_.get()->Unlock(); + Unlock(); // expected-warning {{unlocking 'mu_' that was not locked}} +} + + +class Bar { + SmartPtr<Foo> foo; + + void test0(); + void test1(); + void test2(); + void test3(); +}; + + +void Bar::test0() { + foo->a = 0; // expected-warning {{writing variable 'a' requires locking 'foo->mu_' exclusively}} + (*foo).b = 0; // expected-warning {{writing variable 'b' requires locking 'foo->mu_' exclusively}} + foo.get()->c = 0; // expected-warning {{writing variable 'c' requires locking 'foo->mu_' exclusively}} +} + + +void Bar::test1() { + foo->mu_->Lock(); + foo->a = 0; + (*foo).b = 0; + foo.get()->c = 0; + foo->mu_->Unlock(); +} + + +void Bar::test2() { + (*foo).mu_->Lock(); + foo->a = 0; + (*foo).b = 0; + foo.get()->c = 0; + foo.get()->mu_->Unlock(); +} + + +void Bar::test3() { + MutexLock lock(foo->mu_.get()); + foo->a = 0; + (*foo).b = 0; + foo.get()->c = 0; +} + +} // end namespace SmartPointerTests + + + +namespace DuplicateAttributeTest { + +class LOCKABLE Foo { +public: + Mutex mu1_; + Mutex mu2_; + Mutex mu3_; + int a GUARDED_BY(mu1_); + int b GUARDED_BY(mu2_); + int c GUARDED_BY(mu3_); + + void lock() EXCLUSIVE_LOCK_FUNCTION(); + void unlock() UNLOCK_FUNCTION(); + + void lock1() EXCLUSIVE_LOCK_FUNCTION(mu1_); + void slock1() SHARED_LOCK_FUNCTION(mu1_); + void lock3() EXCLUSIVE_LOCK_FUNCTION(mu1_, mu2_, mu3_); + void locklots() + EXCLUSIVE_LOCK_FUNCTION(mu1_) + EXCLUSIVE_LOCK_FUNCTION(mu2_) + EXCLUSIVE_LOCK_FUNCTION(mu1_, mu2_, mu3_); + + void unlock1() UNLOCK_FUNCTION(mu1_); + void unlock3() UNLOCK_FUNCTION(mu1_, mu2_, mu3_); + void unlocklots() + UNLOCK_FUNCTION(mu1_) + UNLOCK_FUNCTION(mu2_) + UNLOCK_FUNCTION(mu1_, mu2_, mu3_); +}; + + +void Foo::lock() EXCLUSIVE_LOCK_FUNCTION() { } +void Foo::unlock() UNLOCK_FUNCTION() { } + +void Foo::lock1() EXCLUSIVE_LOCK_FUNCTION(mu1_) { + mu1_.Lock(); +} + +void Foo::slock1() SHARED_LOCK_FUNCTION(mu1_) { + mu1_.Lock(); +} + +void Foo::lock3() EXCLUSIVE_LOCK_FUNCTION(mu1_, mu2_, mu3_) { + mu1_.Lock(); + mu2_.Lock(); + mu3_.Lock(); +} + +void Foo::locklots() + EXCLUSIVE_LOCK_FUNCTION(mu1_, mu2_) + EXCLUSIVE_LOCK_FUNCTION(mu2_, mu3_) { + mu1_.Lock(); + mu2_.Lock(); + mu3_.Lock(); +} + +void Foo::unlock1() UNLOCK_FUNCTION(mu1_) { + mu1_.Unlock(); +} + +void Foo::unlock3() UNLOCK_FUNCTION(mu1_, mu2_, mu3_) { + mu1_.Unlock(); + mu2_.Unlock(); + mu3_.Unlock(); +} + +void Foo::unlocklots() + UNLOCK_FUNCTION(mu1_, mu2_) + UNLOCK_FUNCTION(mu2_, mu3_) { + mu1_.Unlock(); + mu2_.Unlock(); + mu3_.Unlock(); +} + + +void test0() { + Foo foo; + foo.lock(); + foo.unlock(); + + foo.lock(); + foo.lock(); // expected-warning {{locking 'foo' that is already locked}} + foo.unlock(); + foo.unlock(); // expected-warning {{unlocking 'foo' that was not locked}} +} + + +void test1() { + Foo foo; + foo.lock1(); + foo.a = 0; + foo.unlock1(); + + foo.lock1(); + foo.lock1(); // expected-warning {{locking 'foo.mu1_' that is already locked}} + foo.a = 0; + foo.unlock1(); + foo.unlock1(); // expected-warning {{unlocking 'foo.mu1_' that was not locked}} +} + + +int test2() { + Foo foo; + foo.slock1(); + int d1 = foo.a; + foo.unlock1(); + + foo.slock1(); + foo.slock1(); // expected-warning {{locking 'foo.mu1_' that is already locked}} + int d2 = foo.a; + foo.unlock1(); + foo.unlock1(); // expected-warning {{unlocking 'foo.mu1_' that was not locked}} + return d1 + d2; +} + + +void test3() { + Foo foo; + foo.lock3(); + foo.a = 0; + foo.b = 0; + foo.c = 0; + foo.unlock3(); + + foo.lock3(); + foo.lock3(); // \ + // expected-warning {{locking 'foo.mu1_' that is already locked}} \ + // expected-warning {{locking 'foo.mu2_' that is already locked}} \ + // expected-warning {{locking 'foo.mu3_' that is already locked}} + foo.a = 0; + foo.b = 0; + foo.c = 0; + foo.unlock3(); + foo.unlock3(); // \ + // expected-warning {{unlocking 'foo.mu1_' that was not locked}} \ + // expected-warning {{unlocking 'foo.mu2_' that was not locked}} \ + // expected-warning {{unlocking 'foo.mu3_' that was not locked}} +} + + +void testlots() { + Foo foo; + foo.locklots(); + foo.a = 0; + foo.b = 0; + foo.c = 0; + foo.unlocklots(); + + foo.locklots(); + foo.locklots(); // \ + // expected-warning {{locking 'foo.mu1_' that is already locked}} \ + // expected-warning {{locking 'foo.mu2_' that is already locked}} \ + // expected-warning {{locking 'foo.mu3_' that is already locked}} + foo.a = 0; + foo.b = 0; + foo.c = 0; + foo.unlocklots(); + foo.unlocklots(); // \ + // expected-warning {{unlocking 'foo.mu1_' that was not locked}} \ + // expected-warning {{unlocking 'foo.mu2_' that was not locked}} \ + // expected-warning {{unlocking 'foo.mu3_' that was not locked}} +} + +} // end namespace DuplicateAttributeTest + + + +namespace TryLockEqTest { + +class Foo { + Mutex mu_; + int a GUARDED_BY(mu_); + bool c; + + int tryLockMutexI() EXCLUSIVE_TRYLOCK_FUNCTION(1, mu_); + Mutex* tryLockMutexP() EXCLUSIVE_TRYLOCK_FUNCTION(1, mu_); + void unlock() UNLOCK_FUNCTION(mu_); + + void test1(); + void test2(); +}; + + +void Foo::test1() { + if (tryLockMutexP() == 0) { + a = 0; // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + return; + } + a = 0; + unlock(); + + if (tryLockMutexP() != 0) { + a = 0; + unlock(); + } + + if (0 != tryLockMutexP()) { + a = 0; + unlock(); + } + + if (!(tryLockMutexP() == 0)) { + a = 0; + unlock(); + } + + if (tryLockMutexI() == 0) { + a = 0; // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + return; + } + a = 0; + unlock(); + + if (0 == tryLockMutexI()) { + a = 0; // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + return; + } + a = 0; + unlock(); + + if (tryLockMutexI() == 1) { + a = 0; + unlock(); + } + + if (mu_.TryLock() == false) { + a = 0; // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + return; + } + a = 0; + unlock(); + + if (mu_.TryLock() == true) { + a = 0; + unlock(); + } + else { + a = 0; // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + } + +#if __has_feature(cxx_nullptr) + if (tryLockMutexP() == nullptr) { + a = 0; // expected-warning {{writing variable 'a' requires locking 'mu_' exclusively}} + return; + } + a = 0; + unlock(); +#endif +} + + +void Foo::test2() { +/* FIXME: these tests depend on changes to the CFG. + * + if (mu_.TryLock() && c) { + a = 0; + unlock(); + } + else return; + + if (c && mu_.TryLock()) { + a = 0; + unlock(); + } + else return; + + if (!(mu_.TryLock() && c)) + return; + a = 0; + unlock(); + + if (!(c && mu_.TryLock())) + return; + a = 0; + unlock(); + + if (!(mu_.TryLock() == 0) && c) { + a = 0; + unlock(); + } + + if (!mu_.TryLock() || c) + return; + a = 0; + unlock(); +*/ +} + +} // end namespace TryLockEqTest + + +namespace ExistentialPatternMatching { + +class Graph { +public: + Mutex mu_; +}; + +void LockAllGraphs() EXCLUSIVE_LOCK_FUNCTION(&Graph::mu_); +void UnlockAllGraphs() UNLOCK_FUNCTION(&Graph::mu_); + +class Node { +public: + int a GUARDED_BY(&Graph::mu_); + + void foo() EXCLUSIVE_LOCKS_REQUIRED(&Graph::mu_) { + a = 0; + } + void foo2() LOCKS_EXCLUDED(&Graph::mu_); +}; + +void test() { + Graph g1; + Graph g2; + Node n1; + + n1.a = 0; // expected-warning {{writing variable 'a' requires locking '&ExistentialPatternMatching::Graph::mu_' exclusively}} + n1.foo(); // expected-warning {{calling function 'foo' requires exclusive lock on '&ExistentialPatternMatching::Graph::mu_'}} + n1.foo2(); + + g1.mu_.Lock(); + n1.a = 0; + n1.foo(); + n1.foo2(); // expected-warning {{cannot call function 'foo2' while mutex '&ExistentialPatternMatching::Graph::mu_' is locked}} + g1.mu_.Unlock(); + + g2.mu_.Lock(); + n1.a = 0; + n1.foo(); + n1.foo2(); // expected-warning {{cannot call function 'foo2' while mutex '&ExistentialPatternMatching::Graph::mu_' is locked}} + g2.mu_.Unlock(); + + LockAllGraphs(); + n1.a = 0; + n1.foo(); + n1.foo2(); // expected-warning {{cannot call function 'foo2' while mutex '&ExistentialPatternMatching::Graph::mu_' is locked}} + UnlockAllGraphs(); + + LockAllGraphs(); + g1.mu_.Unlock(); + + LockAllGraphs(); + g2.mu_.Unlock(); + + LockAllGraphs(); + g1.mu_.Lock(); // expected-warning {{locking 'g1.mu_' that is already locked}} + g1.mu_.Unlock(); +} +} // end namespace ExistentialPatternMatching diff --git a/test/SemaCXX/warn-thread-safety-parsing.cpp b/test/SemaCXX/warn-thread-safety-parsing.cpp index c2fa1d77a01a..3f8a7359088d 100644 --- a/test/SemaCXX/warn-thread-safety-parsing.cpp +++ b/test/SemaCXX/warn-thread-safety-parsing.cpp @@ -22,7 +22,7 @@ #define NO_THREAD_SAFETY_ANALYSIS __attribute__ ((no_thread_safety_analysis)) -class __attribute__((lockable)) Mu { +class LOCKABLE Mutex { public: void Lock(); }; @@ -32,11 +32,11 @@ class UnlockableMu{ class MuWrapper { public: - Mu mu; - Mu getMu() { + Mutex mu; + Mutex getMu() { return mu; } - Mu * getMuPointer() { + Mutex * getMuPointer() { return μ } }; @@ -50,32 +50,32 @@ class MuDoubleWrapper { } }; -Mu mu1; +Mutex mu1; UnlockableMu umu; -Mu mu2; +Mutex mu2; MuWrapper muWrapper; MuDoubleWrapper muDoubleWrapper; -Mu* muPointer; -Mu ** muDoublePointer = & muPointer; -Mu& muRef = mu1; +Mutex* muPointer; +Mutex** muDoublePointer = & muPointer; +Mutex& muRef = mu1; //---------------------------------------// // Scoping tests //--------------------------------------// class Foo { - Mu foomu; - void needLock() __attribute__((exclusive_lock_function(foomu))); + Mutex foomu; + void needLock() EXCLUSIVE_LOCK_FUNCTION(foomu); }; class Foo2 { - void needLock() __attribute__((exclusive_lock_function(foomu))); - Mu foomu; + void needLock() EXCLUSIVE_LOCK_FUNCTION(foomu); + Mutex foomu; }; class Bar { - Mu barmu; - Mu barmu2 __attribute__((acquired_after(barmu))); + Mutex barmu; + Mutex barmu2 ACQUIRED_AFTER(barmu); }; @@ -90,34 +90,34 @@ class Bar { #error "Should support no_thread_safety_analysis attribute" #endif -void noanal_fun() __attribute__((no_thread_safety_analysis)); +void noanal_fun() NO_THREAD_SAFETY_ANALYSIS; void noanal_fun_args() __attribute__((no_thread_safety_analysis(1))); // \ // expected-error {{attribute takes no arguments}} -int noanal_testfn(int y) __attribute__((no_thread_safety_analysis)); +int noanal_testfn(int y) NO_THREAD_SAFETY_ANALYSIS; int noanal_testfn(int y) { - int x __attribute__((no_thread_safety_analysis)) = y; // \ + int x NO_THREAD_SAFETY_ANALYSIS = y; // \ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}} return x; }; -int noanal_test_var __attribute__((no_thread_safety_analysis)); // \ +int noanal_test_var NO_THREAD_SAFETY_ANALYSIS; // \ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}} class NoanalFoo { private: - int test_field __attribute__((no_thread_safety_analysis)); // \ + int test_field NO_THREAD_SAFETY_ANALYSIS; // \ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}} - void test_method() __attribute__((no_thread_safety_analysis)); + void test_method() NO_THREAD_SAFETY_ANALYSIS; }; -class __attribute__((no_thread_safety_analysis)) NoanalTestClass { // \ +class NO_THREAD_SAFETY_ANALYSIS NoanalTestClass { // \ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}} }; -void noanal_fun_params(int lvar __attribute__((no_thread_safety_analysis))); // \ +void noanal_fun_params(int lvar NO_THREAD_SAFETY_ANALYSIS); // \ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}} @@ -129,30 +129,30 @@ void noanal_fun_params(int lvar __attribute__((no_thread_safety_analysis))); // #error "Should support guarded_var attribute" #endif -int gv_var_noargs __attribute__((guarded_var)); +int gv_var_noargs GUARDED_VAR; int gv_var_args __attribute__((guarded_var(1))); // \ // expected-error {{attribute takes no arguments}} class GVFoo { private: - int gv_field_noargs __attribute__((guarded_var)); + int gv_field_noargs GUARDED_VAR; int gv_field_args __attribute__((guarded_var(1))); // \ // expected-error {{attribute takes no arguments}} }; -class __attribute__((guarded_var)) GV { // \ +class GUARDED_VAR GV { // \ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}} }; -void gv_function() __attribute__((guarded_var)); // \ +void gv_function() GUARDED_VAR; // \ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}} -void gv_function_params(int gv_lvar __attribute__((guarded_var))); // \ +void gv_function_params(int gv_lvar GUARDED_VAR); // \ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}} int gv_testfn(int y){ - int x __attribute__((guarded_var)) = y; // \ + int x GUARDED_VAR = y; // \ // expected-warning {{'guarded_var' attribute only applies to fields and global variables}} return x; } @@ -167,21 +167,21 @@ int gv_testfn(int y){ #error "Should support pt_guarded_var attribute" #endif -int *pgv_pt_var_noargs __attribute__((pt_guarded_var)); +int *pgv_pt_var_noargs PT_GUARDED_VAR; -int pgv_var_noargs __attribute__((pt_guarded_var)); // \ +int pgv_var_noargs PT_GUARDED_VAR; // \ // expected-warning {{'pt_guarded_var' only applies to pointer types; type here is 'int'}} class PGVFoo { private: - int *pt_field_noargs __attribute__((pt_guarded_var)); - int field_noargs __attribute__((pt_guarded_var)); // \ + int *pt_field_noargs PT_GUARDED_VAR; + int field_noargs PT_GUARDED_VAR; // \ // expected-warning {{'pt_guarded_var' only applies to pointer types; type here is 'int'}} int *gv_field_args __attribute__((pt_guarded_var(1))); // \ // expected-error {{attribute takes no arguments}} }; -class __attribute__((pt_guarded_var)) PGV { // \ +class PT_GUARDED_VAR PGV { // \ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}} }; @@ -189,14 +189,14 @@ int *pgv_var_args __attribute__((pt_guarded_var(1))); // \ // expected-error {{attribute takes no arguments}} -void pgv_function() __attribute__((pt_guarded_var)); // \ +void pgv_function() PT_GUARDED_VAR; // \ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}} -void pgv_function_params(int *gv_lvar __attribute__((pt_guarded_var))); // \ +void pgv_function_params(int *gv_lvar PT_GUARDED_VAR); // \ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}} void pgv_testfn(int y){ - int *x __attribute__((pt_guarded_var)) = new int(0); // \ + int *x PT_GUARDED_VAR = new int(0); // \ // expected-warning {{'pt_guarded_var' attribute only applies to fields and global variables}} delete x; } @@ -211,35 +211,35 @@ void pgv_testfn(int y){ #error "Should support lockable attribute" #endif -class __attribute__((lockable)) LTestClass { +class LOCKABLE LTestClass { }; class __attribute__((lockable (1))) LTestClass_args { // \ // expected-error {{attribute takes no arguments}} }; -void l_test_function() __attribute__((lockable)); // \ +void l_test_function() LOCKABLE; // \ // expected-warning {{'lockable' attribute only applies to classes}} int l_testfn(int y) { - int x __attribute__((lockable)) = y; // \ + int x LOCKABLE = y; // \ // expected-warning {{'lockable' attribute only applies to classes}} return x; } -int l_test_var __attribute__((lockable)); // \ +int l_test_var LOCKABLE; // \ // expected-warning {{'lockable' attribute only applies to classes}} class LFoo { private: - int test_field __attribute__((lockable)); // \ + int test_field LOCKABLE; // \ // expected-warning {{'lockable' attribute only applies to classes}} - void test_method() __attribute__((lockable)); // \ + void test_method() LOCKABLE; // \ // expected-warning {{'lockable' attribute only applies to classes}} }; -void l_function_params(int lvar __attribute__((lockable))); // \ +void l_function_params(int lvar LOCKABLE); // \ // expected-warning {{'lockable' attribute only applies to classes}} @@ -251,35 +251,35 @@ void l_function_params(int lvar __attribute__((lockable))); // \ #error "Should support scoped_lockable attribute" #endif -class __attribute__((scoped_lockable)) SLTestClass { +class SCOPED_LOCKABLE SLTestClass { }; class __attribute__((scoped_lockable (1))) SLTestClass_args { // \ // expected-error {{attribute takes no arguments}} }; -void sl_test_function() __attribute__((scoped_lockable)); // \ +void sl_test_function() SCOPED_LOCKABLE; // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} int sl_testfn(int y) { - int x __attribute__((scoped_lockable)) = y; // \ + int x SCOPED_LOCKABLE = y; // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} return x; } -int sl_test_var __attribute__((scoped_lockable)); // \ +int sl_test_var SCOPED_LOCKABLE; // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} class SLFoo { private: - int test_field __attribute__((scoped_lockable)); // \ + int test_field SCOPED_LOCKABLE; // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} - void test_method() __attribute__((scoped_lockable)); // \ + void test_method() SCOPED_LOCKABLE; // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} }; -void sl_function_params(int lvar __attribute__((scoped_lockable))); // \ +void sl_function_params(int lvar SCOPED_LOCKABLE); // \ // expected-warning {{'scoped_lockable' attribute only applies to classes}} @@ -295,7 +295,7 @@ void sl_function_params(int lvar __attribute__((scoped_lockable))); // \ //1. Check applied to the right types & argument number -int gb_var_arg __attribute__((guarded_by(mu1))); +int gb_var_arg GUARDED_BY(mu1); int gb_var_args __attribute__((guarded_by(mu1, mu2))); // \ // expected-error {{attribute takes one argument}} @@ -307,21 +307,21 @@ class GBFoo { private: int gb_field_noargs __attribute__((guarded_by)); // \ // expected-error {{attribute takes one argument}} - int gb_field_args __attribute__((guarded_by(mu1))); + int gb_field_args GUARDED_BY(mu1); }; -class __attribute__((guarded_by(mu1))) GB { // \ +class GUARDED_BY(mu1) GB { // \ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}} }; -void gb_function() __attribute__((guarded_by(mu1))); // \ +void gb_function() GUARDED_BY(mu1); // \ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}} -void gb_function_params(int gv_lvar __attribute__((guarded_by(mu1)))); // \ +void gb_function_params(int gv_lvar GUARDED_BY(mu1)); // \ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}} int gb_testfn(int y){ - int x __attribute__((guarded_by(mu1))) = y; // \ + int x GUARDED_BY(mu1) = y; // \ // expected-warning {{'guarded_by' attribute only applies to fields and global variables}} return x; } @@ -329,24 +329,24 @@ int gb_testfn(int y){ //2. Check argument parsing. // legal attribute arguments -int gb_var_arg_1 __attribute__((guarded_by(muWrapper.mu))); -int gb_var_arg_2 __attribute__((guarded_by(muDoubleWrapper.muWrapper->mu))); -int gb_var_arg_3 __attribute__((guarded_by(muWrapper.getMu()))); -int gb_var_arg_4 __attribute__((guarded_by(*muWrapper.getMuPointer()))); -int gb_var_arg_5 __attribute__((guarded_by(&mu1))); -int gb_var_arg_6 __attribute__((guarded_by(muRef))); -int gb_var_arg_7 __attribute__((guarded_by(muDoubleWrapper.getWrapper()->getMu()))); -int gb_var_arg_8 __attribute__((guarded_by(muPointer))); +int gb_var_arg_1 GUARDED_BY(muWrapper.mu); +int gb_var_arg_2 GUARDED_BY(muDoubleWrapper.muWrapper->mu); +int gb_var_arg_3 GUARDED_BY(muWrapper.getMu()); +int gb_var_arg_4 GUARDED_BY(*muWrapper.getMuPointer()); +int gb_var_arg_5 GUARDED_BY(&mu1); +int gb_var_arg_6 GUARDED_BY(muRef); +int gb_var_arg_7 GUARDED_BY(muDoubleWrapper.getWrapper()->getMu()); +int gb_var_arg_8 GUARDED_BY(muPointer); // illegal attribute arguments -int gb_var_arg_bad_1 __attribute__((guarded_by(1))); // \ +int gb_var_arg_bad_1 GUARDED_BY(1); // \ // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'int'}} -int gb_var_arg_bad_2 __attribute__((guarded_by("mu"))); // \ - // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'const char [3]'}} -int gb_var_arg_bad_3 __attribute__((guarded_by(muDoublePointer))); // \ - // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'class Mu **'}} -int gb_var_arg_bad_4 __attribute__((guarded_by(umu))); // \ +int gb_var_arg_bad_2 GUARDED_BY("mu"); // \ + // expected-warning {{ignoring 'guarded_by' attribute because its argument is invalid}} +int gb_var_arg_bad_3 GUARDED_BY(muDoublePointer); // \ + // expected-warning {{'guarded_by' attribute requires arguments that are class type or point to class type; type here is 'class Mutex **'}} +int gb_var_arg_bad_4 GUARDED_BY(umu); // \ // expected-warning {{'guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute; type here is 'class UnlockableMu'}} //3. @@ -366,33 +366,33 @@ int gb_var_arg_bad_4 __attribute__((guarded_by(umu))); // \ int *pgb_var_noargs __attribute__((pt_guarded_by)); // \ // expected-error {{attribute takes one argument}} -int *pgb_ptr_var_arg __attribute__((pt_guarded_by(mu1))); +int *pgb_ptr_var_arg PT_GUARDED_BY(mu1); -int *pgb_ptr_var_args __attribute__((guarded_by(mu1, mu2))); // \ +int *pgb_ptr_var_args __attribute__((pt_guarded_by(mu1, mu2))); // \ // expected-error {{attribute takes one argument}} -int pgb_var_args __attribute__((pt_guarded_by(mu1))); // \ +int pgb_var_args PT_GUARDED_BY(mu1); // \ // expected-warning {{'pt_guarded_by' only applies to pointer types; type here is 'int'}} class PGBFoo { private: int *pgb_field_noargs __attribute__((pt_guarded_by)); // \ // expected-error {{attribute takes one argument}} - int *pgb_field_args __attribute__((pt_guarded_by(mu1))); + int *pgb_field_args PT_GUARDED_BY(mu1); }; -class __attribute__((pt_guarded_by(mu1))) PGB { // \ +class PT_GUARDED_BY(mu1) PGB { // \ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}} }; -void pgb_function() __attribute__((pt_guarded_by(mu1))); // \ +void pgb_function() PT_GUARDED_BY(mu1); // \ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}} -void pgb_function_params(int gv_lvar __attribute__((pt_guarded_by(mu1)))); // \ +void pgb_function_params(int gv_lvar PT_GUARDED_BY(mu1)); // \ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}} void pgb_testfn(int y){ - int *x __attribute__((pt_guarded_by(mu1))) = new int(0); // \ + int *x PT_GUARDED_BY(mu1) = new int(0); // \ // expected-warning {{'pt_guarded_by' attribute only applies to fields and global variables}} delete x; } @@ -400,24 +400,24 @@ void pgb_testfn(int y){ //2. Check argument parsing. // legal attribute arguments -int * pgb_var_arg_1 __attribute__((pt_guarded_by(muWrapper.mu))); -int * pgb_var_arg_2 __attribute__((pt_guarded_by(muDoubleWrapper.muWrapper->mu))); -int * pgb_var_arg_3 __attribute__((pt_guarded_by(muWrapper.getMu()))); -int * pgb_var_arg_4 __attribute__((pt_guarded_by(*muWrapper.getMuPointer()))); -int * pgb_var_arg_5 __attribute__((pt_guarded_by(&mu1))); -int * pgb_var_arg_6 __attribute__((pt_guarded_by(muRef))); -int * pgb_var_arg_7 __attribute__((pt_guarded_by(muDoubleWrapper.getWrapper()->getMu()))); -int * pgb_var_arg_8 __attribute__((pt_guarded_by(muPointer))); +int * pgb_var_arg_1 PT_GUARDED_BY(muWrapper.mu); +int * pgb_var_arg_2 PT_GUARDED_BY(muDoubleWrapper.muWrapper->mu); +int * pgb_var_arg_3 PT_GUARDED_BY(muWrapper.getMu()); +int * pgb_var_arg_4 PT_GUARDED_BY(*muWrapper.getMuPointer()); +int * pgb_var_arg_5 PT_GUARDED_BY(&mu1); +int * pgb_var_arg_6 PT_GUARDED_BY(muRef); +int * pgb_var_arg_7 PT_GUARDED_BY(muDoubleWrapper.getWrapper()->getMu()); +int * pgb_var_arg_8 PT_GUARDED_BY(muPointer); // illegal attribute arguments -int * pgb_var_arg_bad_1 __attribute__((pt_guarded_by(1))); // \ +int * pgb_var_arg_bad_1 PT_GUARDED_BY(1); // \ // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}} -int * pgb_var_arg_bad_2 __attribute__((pt_guarded_by("mu"))); // \ +int * pgb_var_arg_bad_2 PT_GUARDED_BY("mu"); // \ + // expected-warning {{ignoring 'pt_guarded_by' attribute because its argument is invalid}} +int * pgb_var_arg_bad_3 PT_GUARDED_BY(muDoublePointer); // \ // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}} -int * pgb_var_arg_bad_3 __attribute__((pt_guarded_by(muDoublePointer))); // \ - // expected-warning {{'pt_guarded_by' attribute requires arguments that are class type or point to class type}} -int * pgb_var_arg_bad_4 __attribute__((pt_guarded_by(umu))); // \ +int * pgb_var_arg_bad_4 PT_GUARDED_BY(umu); // \ // expected-warning {{'pt_guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute}} @@ -431,56 +431,56 @@ int * pgb_var_arg_bad_4 __attribute__((pt_guarded_by(umu))); // \ #error "Should support acquired_after attribute" #endif -Mu mu_aa __attribute__((acquired_after(mu1))); +Mutex mu_aa ACQUIRED_AFTER(mu1); -Mu aa_var_noargs __attribute__((acquired_after)); // \ +Mutex aa_var_noargs __attribute__((acquired_after)); // \ // expected-error {{attribute takes at least 1 argument}} class AAFoo { private: - Mu aa_field_noargs __attribute__((acquired_after)); // \ + Mutex aa_field_noargs __attribute__((acquired_after)); // \ // expected-error {{attribute takes at least 1 argument}} - Mu aa_field_args __attribute__((acquired_after(mu1))); + Mutex aa_field_args ACQUIRED_AFTER(mu1); }; -class __attribute__((acquired_after(mu1))) AA { // \ +class ACQUIRED_AFTER(mu1) AA { // \ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}} }; -void aa_function() __attribute__((acquired_after(mu1))); // \ +void aa_function() ACQUIRED_AFTER(mu1); // \ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}} -void aa_function_params(int gv_lvar __attribute__((acquired_after(mu1)))); // \ +void aa_function_params(int gv_lvar ACQUIRED_AFTER(mu1)); // \ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}} void aa_testfn(int y){ - Mu x __attribute__((acquired_after(mu1))) = Mu(); // \ + Mutex x ACQUIRED_AFTER(mu1) = Mutex(); // \ // expected-warning {{'acquired_after' attribute only applies to fields and global variables}} } //Check argument parsing. // legal attribute arguments -Mu aa_var_arg_1 __attribute__((acquired_after(muWrapper.mu))); -Mu aa_var_arg_2 __attribute__((acquired_after(muDoubleWrapper.muWrapper->mu))); -Mu aa_var_arg_3 __attribute__((acquired_after(muWrapper.getMu()))); -Mu aa_var_arg_4 __attribute__((acquired_after(*muWrapper.getMuPointer()))); -Mu aa_var_arg_5 __attribute__((acquired_after(&mu1))); -Mu aa_var_arg_6 __attribute__((acquired_after(muRef))); -Mu aa_var_arg_7 __attribute__((acquired_after(muDoubleWrapper.getWrapper()->getMu()))); -Mu aa_var_arg_8 __attribute__((acquired_after(muPointer))); +Mutex aa_var_arg_1 ACQUIRED_AFTER(muWrapper.mu); +Mutex aa_var_arg_2 ACQUIRED_AFTER(muDoubleWrapper.muWrapper->mu); +Mutex aa_var_arg_3 ACQUIRED_AFTER(muWrapper.getMu()); +Mutex aa_var_arg_4 ACQUIRED_AFTER(*muWrapper.getMuPointer()); +Mutex aa_var_arg_5 ACQUIRED_AFTER(&mu1); +Mutex aa_var_arg_6 ACQUIRED_AFTER(muRef); +Mutex aa_var_arg_7 ACQUIRED_AFTER(muDoubleWrapper.getWrapper()->getMu()); +Mutex aa_var_arg_8 ACQUIRED_AFTER(muPointer); // illegal attribute arguments -Mu aa_var_arg_bad_1 __attribute__((acquired_after(1))); // \ - // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}} -Mu aa_var_arg_bad_2 __attribute__((acquired_after("mu"))); // \ +Mutex aa_var_arg_bad_1 ACQUIRED_AFTER(1); // \ // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}} -Mu aa_var_arg_bad_3 __attribute__((acquired_after(muDoublePointer))); // \ +Mutex aa_var_arg_bad_2 ACQUIRED_AFTER("mu"); // \ + // expected-warning {{ignoring 'acquired_after' attribute because its argument is invalid}} +Mutex aa_var_arg_bad_3 ACQUIRED_AFTER(muDoublePointer); // \ // expected-warning {{'acquired_after' attribute requires arguments that are class type or point to class type}} -Mu aa_var_arg_bad_4 __attribute__((acquired_after(umu))); // \ +Mutex aa_var_arg_bad_4 ACQUIRED_AFTER(umu); // \ // expected-warning {{'acquired_after' attribute requires arguments whose type is annotated with 'lockable' attribute}} -UnlockableMu aa_var_arg_bad_5 __attribute__((acquired_after(mu_aa))); // \ +UnlockableMu aa_var_arg_bad_5 ACQUIRED_AFTER(mu_aa); // \ // expected-warning {{'acquired_after' attribute can only be applied in a context annotated with 'lockable' attribute}} //-----------------------------------------// @@ -491,59 +491,59 @@ UnlockableMu aa_var_arg_bad_5 __attribute__((acquired_after(mu_aa))); // \ #error "Should support acquired_before attribute" #endif -Mu mu_ab __attribute__((acquired_before(mu1))); +Mutex mu_ab ACQUIRED_BEFORE(mu1); -Mu ab_var_noargs __attribute__((acquired_before)); // \ +Mutex ab_var_noargs __attribute__((acquired_before)); // \ // expected-error {{attribute takes at least 1 argument}} class ABFoo { private: - Mu ab_field_noargs __attribute__((acquired_before)); // \ + Mutex ab_field_noargs __attribute__((acquired_before)); // \ // expected-error {{attribute takes at least 1 argument}} - Mu ab_field_args __attribute__((acquired_before(mu1))); + Mutex ab_field_args ACQUIRED_BEFORE(mu1); }; -class __attribute__((acquired_before(mu1))) AB { // \ +class ACQUIRED_BEFORE(mu1) AB { // \ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}} }; -void ab_function() __attribute__((acquired_before(mu1))); // \ +void ab_function() ACQUIRED_BEFORE(mu1); // \ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}} -void ab_function_params(int gv_lvar __attribute__((acquired_before(mu1)))); // \ +void ab_function_params(int gv_lvar ACQUIRED_BEFORE(mu1)); // \ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}} void ab_testfn(int y){ - Mu x __attribute__((acquired_before(mu1))) = Mu(); // \ + Mutex x ACQUIRED_BEFORE(mu1) = Mutex(); // \ // expected-warning {{'acquired_before' attribute only applies to fields and global variables}} } -// Note: illegal int ab_int __attribute__((acquired_before(mu1))) will +// Note: illegal int ab_int ACQUIRED_BEFORE(mu1) will // be taken care of by warnings that ab__int is not lockable. //Check argument parsing. // legal attribute arguments -Mu ab_var_arg_1 __attribute__((acquired_before(muWrapper.mu))); -Mu ab_var_arg_2 __attribute__((acquired_before(muDoubleWrapper.muWrapper->mu))); -Mu ab_var_arg_3 __attribute__((acquired_before(muWrapper.getMu()))); -Mu ab_var_arg_4 __attribute__((acquired_before(*muWrapper.getMuPointer()))); -Mu ab_var_arg_5 __attribute__((acquired_before(&mu1))); -Mu ab_var_arg_6 __attribute__((acquired_before(muRef))); -Mu ab_var_arg_7 __attribute__((acquired_before(muDoubleWrapper.getWrapper()->getMu()))); -Mu ab_var_arg_8 __attribute__((acquired_before(muPointer))); +Mutex ab_var_arg_1 ACQUIRED_BEFORE(muWrapper.mu); +Mutex ab_var_arg_2 ACQUIRED_BEFORE(muDoubleWrapper.muWrapper->mu); +Mutex ab_var_arg_3 ACQUIRED_BEFORE(muWrapper.getMu()); +Mutex ab_var_arg_4 ACQUIRED_BEFORE(*muWrapper.getMuPointer()); +Mutex ab_var_arg_5 ACQUIRED_BEFORE(&mu1); +Mutex ab_var_arg_6 ACQUIRED_BEFORE(muRef); +Mutex ab_var_arg_7 ACQUIRED_BEFORE(muDoubleWrapper.getWrapper()->getMu()); +Mutex ab_var_arg_8 ACQUIRED_BEFORE(muPointer); // illegal attribute arguments -Mu ab_var_arg_bad_1 __attribute__((acquired_before(1))); // \ +Mutex ab_var_arg_bad_1 ACQUIRED_BEFORE(1); // \ // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}} -Mu ab_var_arg_bad_2 __attribute__((acquired_before("mu"))); // \ +Mutex ab_var_arg_bad_2 ACQUIRED_BEFORE("mu"); // \ + // expected-warning {{ignoring 'acquired_before' attribute because its argument is invalid}} +Mutex ab_var_arg_bad_3 ACQUIRED_BEFORE(muDoublePointer); // \ // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}} -Mu ab_var_arg_bad_3 __attribute__((acquired_before(muDoublePointer))); // \ - // expected-warning {{'acquired_before' attribute requires arguments that are class type or point to class type}} -Mu ab_var_arg_bad_4 __attribute__((acquired_before(umu))); // \ +Mutex ab_var_arg_bad_4 ACQUIRED_BEFORE(umu); // \ // expected-warning {{'acquired_before' attribute requires arguments whose type is annotated with 'lockable' attribute}} -UnlockableMu ab_var_arg_bad_5 __attribute__((acquired_before(mu_ab))); // \ +UnlockableMu ab_var_arg_bad_5 ACQUIRED_BEFORE(mu_ab); // \ // expected-warning {{'acquired_before' attribute can only be applied in a context annotated with 'lockable' attribute}} @@ -557,65 +557,65 @@ UnlockableMu ab_var_arg_bad_5 __attribute__((acquired_before(mu_ab))); // \ // takes zero or more arguments, all locks (vars/fields) -void elf_function() __attribute__((exclusive_lock_function)); +void elf_function() EXCLUSIVE_LOCK_FUNCTION(); -void elf_function_args() __attribute__((exclusive_lock_function(mu1, mu2))); +void elf_function_args() EXCLUSIVE_LOCK_FUNCTION(mu1, mu2); -int elf_testfn(int y) __attribute__((exclusive_lock_function)); +int elf_testfn(int y) EXCLUSIVE_LOCK_FUNCTION(); int elf_testfn(int y) { - int x __attribute__((exclusive_lock_function)) = y; // \ + int x EXCLUSIVE_LOCK_FUNCTION() = y; // \ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}} return x; }; -int elf_test_var __attribute__((exclusive_lock_function)); // \ +int elf_test_var EXCLUSIVE_LOCK_FUNCTION(); // \ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}} class ElfFoo { private: - int test_field __attribute__((exclusive_lock_function)); // \ + int test_field EXCLUSIVE_LOCK_FUNCTION(); // \ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}} - void test_method() __attribute__((exclusive_lock_function)); + void test_method() EXCLUSIVE_LOCK_FUNCTION(); }; -class __attribute__((exclusive_lock_function)) ElfTestClass { // \ +class EXCLUSIVE_LOCK_FUNCTION() ElfTestClass { // \ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}} }; -void elf_fun_params(int lvar __attribute__((exclusive_lock_function))); // \ +void elf_fun_params(int lvar EXCLUSIVE_LOCK_FUNCTION()); // \ // expected-warning {{'exclusive_lock_function' attribute only applies to functions and methods}} // Check argument parsing. // legal attribute arguments -int elf_function_1() __attribute__((exclusive_lock_function(muWrapper.mu))); -int elf_function_2() __attribute__((exclusive_lock_function(muDoubleWrapper.muWrapper->mu))); -int elf_function_3() __attribute__((exclusive_lock_function(muWrapper.getMu()))); -int elf_function_4() __attribute__((exclusive_lock_function(*muWrapper.getMuPointer()))); -int elf_function_5() __attribute__((exclusive_lock_function(&mu1))); -int elf_function_6() __attribute__((exclusive_lock_function(muRef))); -int elf_function_7() __attribute__((exclusive_lock_function(muDoubleWrapper.getWrapper()->getMu()))); -int elf_function_8() __attribute__((exclusive_lock_function(muPointer))); -int elf_function_9(Mu x) __attribute__((exclusive_lock_function(1))); -int elf_function_9(Mu x, Mu y) __attribute__((exclusive_lock_function(1,2))); +int elf_function_1() EXCLUSIVE_LOCK_FUNCTION(muWrapper.mu); +int elf_function_2() EXCLUSIVE_LOCK_FUNCTION(muDoubleWrapper.muWrapper->mu); +int elf_function_3() EXCLUSIVE_LOCK_FUNCTION(muWrapper.getMu()); +int elf_function_4() EXCLUSIVE_LOCK_FUNCTION(*muWrapper.getMuPointer()); +int elf_function_5() EXCLUSIVE_LOCK_FUNCTION(&mu1); +int elf_function_6() EXCLUSIVE_LOCK_FUNCTION(muRef); +int elf_function_7() EXCLUSIVE_LOCK_FUNCTION(muDoubleWrapper.getWrapper()->getMu()); +int elf_function_8() EXCLUSIVE_LOCK_FUNCTION(muPointer); +int elf_function_9(Mutex x) EXCLUSIVE_LOCK_FUNCTION(1); +int elf_function_9(Mutex x, Mutex y) EXCLUSIVE_LOCK_FUNCTION(1,2); // illegal attribute arguments -int elf_function_bad_2() __attribute__((exclusive_lock_function("mu"))); // \ - // expected-warning {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}} -int elf_function_bad_3() __attribute__((exclusive_lock_function(muDoublePointer))); // \ +int elf_function_bad_2() EXCLUSIVE_LOCK_FUNCTION("mu"); // \ + // expected-warning {{ignoring 'exclusive_lock_function' attribute because its argument is invalid}} +int elf_function_bad_3() EXCLUSIVE_LOCK_FUNCTION(muDoublePointer); // \ // expected-warning {{'exclusive_lock_function' attribute requires arguments that are class type or point to class type}} -int elf_function_bad_4() __attribute__((exclusive_lock_function(umu))); // \ +int elf_function_bad_4() EXCLUSIVE_LOCK_FUNCTION(umu); // \ // expected-warning {{'exclusive_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}} -int elf_function_bad_1() __attribute__((exclusive_lock_function(1))); // \ +int elf_function_bad_1() EXCLUSIVE_LOCK_FUNCTION(1); // \ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}} -int elf_function_bad_5(Mu x) __attribute__((exclusive_lock_function(0))); // \ +int elf_function_bad_5(Mutex x) EXCLUSIVE_LOCK_FUNCTION(0); // \ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: can only be 1, since there is one parameter}} -int elf_function_bad_6(Mu x, Mu y) __attribute__((exclusive_lock_function(0))); // \ +int elf_function_bad_6(Mutex x, Mutex y) EXCLUSIVE_LOCK_FUNCTION(0); // \ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: must be between 1 and 2}} -int elf_function_bad_7() __attribute__((exclusive_lock_function(0))); // \ +int elf_function_bad_7() EXCLUSIVE_LOCK_FUNCTION(0); // \ // expected-error {{'exclusive_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}} @@ -629,65 +629,65 @@ int elf_function_bad_7() __attribute__((exclusive_lock_function(0))); // \ // takes zero or more arguments, all locks (vars/fields) -void slf_function() __attribute__((shared_lock_function)); +void slf_function() SHARED_LOCK_FUNCTION(); -void slf_function_args() __attribute__((shared_lock_function(mu1, mu2))); +void slf_function_args() SHARED_LOCK_FUNCTION(mu1, mu2); -int slf_testfn(int y) __attribute__((shared_lock_function)); +int slf_testfn(int y) SHARED_LOCK_FUNCTION(); int slf_testfn(int y) { - int x __attribute__((shared_lock_function)) = y; // \ + int x SHARED_LOCK_FUNCTION() = y; // \ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}} return x; }; -int slf_test_var __attribute__((shared_lock_function)); // \ +int slf_test_var SHARED_LOCK_FUNCTION(); // \ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}} -void slf_fun_params(int lvar __attribute__((shared_lock_function))); // \ +void slf_fun_params(int lvar SHARED_LOCK_FUNCTION()); // \ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}} class SlfFoo { private: - int test_field __attribute__((shared_lock_function)); // \ + int test_field SHARED_LOCK_FUNCTION(); // \ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}} - void test_method() __attribute__((shared_lock_function)); + void test_method() SHARED_LOCK_FUNCTION(); }; -class __attribute__((shared_lock_function)) SlfTestClass { // \ +class SHARED_LOCK_FUNCTION() SlfTestClass { // \ // expected-warning {{'shared_lock_function' attribute only applies to functions and methods}} }; // Check argument parsing. // legal attribute arguments -int slf_function_1() __attribute__((shared_lock_function(muWrapper.mu))); -int slf_function_2() __attribute__((shared_lock_function(muDoubleWrapper.muWrapper->mu))); -int slf_function_3() __attribute__((shared_lock_function(muWrapper.getMu()))); -int slf_function_4() __attribute__((shared_lock_function(*muWrapper.getMuPointer()))); -int slf_function_5() __attribute__((shared_lock_function(&mu1))); -int slf_function_6() __attribute__((shared_lock_function(muRef))); -int slf_function_7() __attribute__((shared_lock_function(muDoubleWrapper.getWrapper()->getMu()))); -int slf_function_8() __attribute__((shared_lock_function(muPointer))); -int slf_function_9(Mu x) __attribute__((shared_lock_function(1))); -int slf_function_9(Mu x, Mu y) __attribute__((shared_lock_function(1,2))); +int slf_function_1() SHARED_LOCK_FUNCTION(muWrapper.mu); +int slf_function_2() SHARED_LOCK_FUNCTION(muDoubleWrapper.muWrapper->mu); +int slf_function_3() SHARED_LOCK_FUNCTION(muWrapper.getMu()); +int slf_function_4() SHARED_LOCK_FUNCTION(*muWrapper.getMuPointer()); +int slf_function_5() SHARED_LOCK_FUNCTION(&mu1); +int slf_function_6() SHARED_LOCK_FUNCTION(muRef); +int slf_function_7() SHARED_LOCK_FUNCTION(muDoubleWrapper.getWrapper()->getMu()); +int slf_function_8() SHARED_LOCK_FUNCTION(muPointer); +int slf_function_9(Mutex x) SHARED_LOCK_FUNCTION(1); +int slf_function_9(Mutex x, Mutex y) SHARED_LOCK_FUNCTION(1,2); // illegal attribute arguments -int slf_function_bad_2() __attribute__((shared_lock_function("mu"))); // \ +int slf_function_bad_2() SHARED_LOCK_FUNCTION("mu"); // \ + // expected-warning {{ignoring 'shared_lock_function' attribute because its argument is invalid}} +int slf_function_bad_3() SHARED_LOCK_FUNCTION(muDoublePointer); // \ // expected-warning {{'shared_lock_function' attribute requires arguments that are class type or point to class type}} -int slf_function_bad_3() __attribute__((shared_lock_function(muDoublePointer))); // \ - // expected-warning {{'shared_lock_function' attribute requires arguments that are class type or point to class type}} -int slf_function_bad_4() __attribute__((shared_lock_function(umu))); // \ +int slf_function_bad_4() SHARED_LOCK_FUNCTION(umu); // \ // expected-warning {{'shared_lock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}} -int slf_function_bad_1() __attribute__((shared_lock_function(1))); // \ +int slf_function_bad_1() SHARED_LOCK_FUNCTION(1); // \ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}} -int slf_function_bad_5(Mu x) __attribute__((shared_lock_function(0))); // \ +int slf_function_bad_5(Mutex x) SHARED_LOCK_FUNCTION(0); // \ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: can only be 1, since there is one parameter}} -int slf_function_bad_6(Mu x, Mu y) __attribute__((shared_lock_function(0))); // \ +int slf_function_bad_6(Mutex x, Mutex y) SHARED_LOCK_FUNCTION(0); // \ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: must be between 1 and 2}} -int slf_function_bad_7() __attribute__((shared_lock_function(0))); // \ +int slf_function_bad_7() SHARED_LOCK_FUNCTION(0); // \ // expected-error {{'shared_lock_function' attribute parameter 1 is out of bounds: no parameters to index into}} @@ -705,62 +705,62 @@ int slf_function_bad_7() __attribute__((shared_lock_function(0))); // \ void etf_function() __attribute__((exclusive_trylock_function)); // \ // expected-error {{attribute takes at least 1 argument}} -void etf_function_args() __attribute__((exclusive_trylock_function(1, mu2))); +void etf_function_args() EXCLUSIVE_TRYLOCK_FUNCTION(1, mu2); -void etf_function_arg() __attribute__((exclusive_trylock_function(1))); +void etf_function_arg() EXCLUSIVE_TRYLOCK_FUNCTION(1); -int etf_testfn(int y) __attribute__((exclusive_trylock_function(1))); +int etf_testfn(int y) EXCLUSIVE_TRYLOCK_FUNCTION(1); int etf_testfn(int y) { - int x __attribute__((exclusive_trylock_function(1))) = y; // \ + int x EXCLUSIVE_TRYLOCK_FUNCTION(1) = y; // \ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}} return x; }; -int etf_test_var __attribute__((exclusive_trylock_function(1))); // \ +int etf_test_var EXCLUSIVE_TRYLOCK_FUNCTION(1); // \ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}} class EtfFoo { private: - int test_field __attribute__((exclusive_trylock_function(1))); // \ + int test_field EXCLUSIVE_TRYLOCK_FUNCTION(1); // \ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}} - void test_method() __attribute__((exclusive_trylock_function(1))); + void test_method() EXCLUSIVE_TRYLOCK_FUNCTION(1); }; -class __attribute__((exclusive_trylock_function(1))) EtfTestClass { // \ +class EXCLUSIVE_TRYLOCK_FUNCTION(1) EtfTestClass { // \ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}} }; -void etf_fun_params(int lvar __attribute__((exclusive_trylock_function(1)))); // \ +void etf_fun_params(int lvar EXCLUSIVE_TRYLOCK_FUNCTION(1)); // \ // expected-warning {{'exclusive_trylock_function' attribute only applies to functions and methods}} // Check argument parsing. // legal attribute arguments -int etf_function_1() __attribute__((exclusive_trylock_function(1, muWrapper.mu))); -int etf_function_2() __attribute__((exclusive_trylock_function(1, muDoubleWrapper.muWrapper->mu))); -int etf_function_3() __attribute__((exclusive_trylock_function(1, muWrapper.getMu()))); -int etf_function_4() __attribute__((exclusive_trylock_function(1, *muWrapper.getMuPointer()))); -int etf_function_5() __attribute__((exclusive_trylock_function(1, &mu1))); -int etf_function_6() __attribute__((exclusive_trylock_function(1, muRef))); -int etf_function_7() __attribute__((exclusive_trylock_function(1, muDoubleWrapper.getWrapper()->getMu()))); -int etf_functetfn_8() __attribute__((exclusive_trylock_function(1, muPointer))); -int etf_function_9() __attribute__((exclusive_trylock_function(true))); +int etf_function_1() EXCLUSIVE_TRYLOCK_FUNCTION(1, muWrapper.mu); +int etf_function_2() EXCLUSIVE_TRYLOCK_FUNCTION(1, muDoubleWrapper.muWrapper->mu); +int etf_function_3() EXCLUSIVE_TRYLOCK_FUNCTION(1, muWrapper.getMu()); +int etf_function_4() EXCLUSIVE_TRYLOCK_FUNCTION(1, *muWrapper.getMuPointer()); +int etf_function_5() EXCLUSIVE_TRYLOCK_FUNCTION(1, &mu1); +int etf_function_6() EXCLUSIVE_TRYLOCK_FUNCTION(1, muRef); +int etf_function_7() EXCLUSIVE_TRYLOCK_FUNCTION(1, muDoubleWrapper.getWrapper()->getMu()); +int etf_functetfn_8() EXCLUSIVE_TRYLOCK_FUNCTION(1, muPointer); +int etf_function_9() EXCLUSIVE_TRYLOCK_FUNCTION(true); // illegal attribute arguments -int etf_function_bad_1() __attribute__((exclusive_trylock_function(mu1))); // \ +int etf_function_bad_1() EXCLUSIVE_TRYLOCK_FUNCTION(mu1); // \ // expected-error {{'exclusive_trylock_function' attribute first argument must be of int or bool type}} -int etf_function_bad_2() __attribute__((exclusive_trylock_function("mu"))); // \ +int etf_function_bad_2() EXCLUSIVE_TRYLOCK_FUNCTION("mu"); // \ // expected-error {{'exclusive_trylock_function' attribute first argument must be of int or bool type}} -int etf_function_bad_3() __attribute__((exclusive_trylock_function(muDoublePointer))); // \ +int etf_function_bad_3() EXCLUSIVE_TRYLOCK_FUNCTION(muDoublePointer); // \ // expected-error {{'exclusive_trylock_function' attribute first argument must be of int or bool type}} -int etf_function_bad_4() __attribute__((exclusive_trylock_function(1, "mu"))); // \ - // expected-warning {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}} -int etf_function_bad_5() __attribute__((exclusive_trylock_function(1, muDoublePointer))); // \ +int etf_function_bad_4() EXCLUSIVE_TRYLOCK_FUNCTION(1, "mu"); // \ + // expected-warning {{ignoring 'exclusive_trylock_function' attribute because its argument is invalid}} +int etf_function_bad_5() EXCLUSIVE_TRYLOCK_FUNCTION(1, muDoublePointer); // \ // expected-warning {{'exclusive_trylock_function' attribute requires arguments that are class type or point to class type}} -int etf_function_bad_6() __attribute__((exclusive_trylock_function(1, umu))); // \ +int etf_function_bad_6() EXCLUSIVE_TRYLOCK_FUNCTION(1, umu); // \ // expected-warning {{'exclusive_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}} @@ -778,63 +778,63 @@ int etf_function_bad_6() __attribute__((exclusive_trylock_function(1, umu))); // void stf_function() __attribute__((shared_trylock_function)); // \ // expected-error {{attribute takes at least 1 argument}} -void stf_function_args() __attribute__((shared_trylock_function(1, mu2))); +void stf_function_args() SHARED_TRYLOCK_FUNCTION(1, mu2); -void stf_function_arg() __attribute__((shared_trylock_function(1))); +void stf_function_arg() SHARED_TRYLOCK_FUNCTION(1); -int stf_testfn(int y) __attribute__((shared_trylock_function(1))); +int stf_testfn(int y) SHARED_TRYLOCK_FUNCTION(1); int stf_testfn(int y) { - int x __attribute__((shared_trylock_function(1))) = y; // \ + int x SHARED_TRYLOCK_FUNCTION(1) = y; // \ // expected-warning {{'shared_trylock_function' attribute only applies to functions and methods}} return x; }; -int stf_test_var __attribute__((shared_trylock_function(1))); // \ +int stf_test_var SHARED_TRYLOCK_FUNCTION(1); // \ // expected-warning {{'shared_trylock_function' attribute only applies to functions and methods}} -void stf_fun_params(int lvar __attribute__((shared_trylock_function(1)))); // \ +void stf_fun_params(int lvar SHARED_TRYLOCK_FUNCTION(1)); // \ // expected-warning {{'shared_trylock_function' attribute only applies to functions and methods}} class StfFoo { private: - int test_field __attribute__((shared_trylock_function(1))); // \ + int test_field SHARED_TRYLOCK_FUNCTION(1); // \ // expected-warning {{'shared_trylock_function' attribute only applies to functions and methods}} - void test_method() __attribute__((shared_trylock_function(1))); + void test_method() SHARED_TRYLOCK_FUNCTION(1); }; -class __attribute__((shared_trylock_function(1))) StfTestClass { // \ +class SHARED_TRYLOCK_FUNCTION(1) StfTestClass { // \ // expected-warning {{'shared_trylock_function' attribute only applies to functions and methods}} }; // Check argument parsing. // legal attribute arguments -int stf_function_1() __attribute__((shared_trylock_function(1, muWrapper.mu))); -int stf_function_2() __attribute__((shared_trylock_function(1, muDoubleWrapper.muWrapper->mu))); -int stf_function_3() __attribute__((shared_trylock_function(1, muWrapper.getMu()))); -int stf_function_4() __attribute__((shared_trylock_function(1, *muWrapper.getMuPointer()))); -int stf_function_5() __attribute__((shared_trylock_function(1, &mu1))); -int stf_function_6() __attribute__((shared_trylock_function(1, muRef))); -int stf_function_7() __attribute__((shared_trylock_function(1, muDoubleWrapper.getWrapper()->getMu()))); -int stf_function_8() __attribute__((shared_trylock_function(1, muPointer))); -int stf_function_9() __attribute__((shared_trylock_function(true))); +int stf_function_1() SHARED_TRYLOCK_FUNCTION(1, muWrapper.mu); +int stf_function_2() SHARED_TRYLOCK_FUNCTION(1, muDoubleWrapper.muWrapper->mu); +int stf_function_3() SHARED_TRYLOCK_FUNCTION(1, muWrapper.getMu()); +int stf_function_4() SHARED_TRYLOCK_FUNCTION(1, *muWrapper.getMuPointer()); +int stf_function_5() SHARED_TRYLOCK_FUNCTION(1, &mu1); +int stf_function_6() SHARED_TRYLOCK_FUNCTION(1, muRef); +int stf_function_7() SHARED_TRYLOCK_FUNCTION(1, muDoubleWrapper.getWrapper()->getMu()); +int stf_function_8() SHARED_TRYLOCK_FUNCTION(1, muPointer); +int stf_function_9() SHARED_TRYLOCK_FUNCTION(true); // illegal attribute arguments -int stf_function_bad_1() __attribute__((shared_trylock_function(mu1))); // \ +int stf_function_bad_1() SHARED_TRYLOCK_FUNCTION(mu1); // \ // expected-error {{'shared_trylock_function' attribute first argument must be of int or bool type}} -int stf_function_bad_2() __attribute__((shared_trylock_function("mu"))); // \ +int stf_function_bad_2() SHARED_TRYLOCK_FUNCTION("mu"); // \ // expected-error {{'shared_trylock_function' attribute first argument must be of int or bool type}} -int stf_function_bad_3() __attribute__((shared_trylock_function(muDoublePointer))); // \ +int stf_function_bad_3() SHARED_TRYLOCK_FUNCTION(muDoublePointer); // \ // expected-error {{'shared_trylock_function' attribute first argument must be of int or bool type}} -int stf_function_bad_4() __attribute__((shared_trylock_function(1, "mu"))); // \ +int stf_function_bad_4() SHARED_TRYLOCK_FUNCTION(1, "mu"); // \ + // expected-warning {{ignoring 'shared_trylock_function' attribute because its argument is invalid}} +int stf_function_bad_5() SHARED_TRYLOCK_FUNCTION(1, muDoublePointer); // \ // expected-warning {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}} -int stf_function_bad_5() __attribute__((shared_trylock_function(1, muDoublePointer))); // \ - // expected-warning {{'shared_trylock_function' attribute requires arguments that are class type or point to class type}} -int stf_function_bad_6() __attribute__((shared_trylock_function(1, umu))); // \ +int stf_function_bad_6() SHARED_TRYLOCK_FUNCTION(1, umu); // \ // expected-warning {{'shared_trylock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}} @@ -848,65 +848,65 @@ int stf_function_bad_6() __attribute__((shared_trylock_function(1, umu))); // \ // takes zero or more arguments, all locks (vars/fields) -void uf_function() __attribute__((unlock_function)); +void uf_function() UNLOCK_FUNCTION(); -void uf_function_args() __attribute__((unlock_function(mu1, mu2))); +void uf_function_args() UNLOCK_FUNCTION(mu1, mu2); -int uf_testfn(int y) __attribute__((unlock_function)); +int uf_testfn(int y) UNLOCK_FUNCTION(); int uf_testfn(int y) { - int x __attribute__((unlock_function)) = y; // \ + int x UNLOCK_FUNCTION() = y; // \ // expected-warning {{'unlock_function' attribute only applies to functions and methods}} return x; }; -int uf_test_var __attribute__((unlock_function)); // \ +int uf_test_var UNLOCK_FUNCTION(); // \ // expected-warning {{'unlock_function' attribute only applies to functions and methods}} class UfFoo { private: - int test_field __attribute__((unlock_function)); // \ + int test_field UNLOCK_FUNCTION(); // \ // expected-warning {{'unlock_function' attribute only applies to functions and methods}} - void test_method() __attribute__((unlock_function)); + void test_method() UNLOCK_FUNCTION(); }; -class __attribute__((no_thread_safety_analysis)) UfTestClass { // \ +class NO_THREAD_SAFETY_ANALYSIS UfTestClass { // \ // expected-warning {{'no_thread_safety_analysis' attribute only applies to functions and methods}} }; -void uf_fun_params(int lvar __attribute__((unlock_function))); // \ +void uf_fun_params(int lvar UNLOCK_FUNCTION()); // \ // expected-warning {{'unlock_function' attribute only applies to functions and methods}} // Check argument parsing. // legal attribute arguments -int uf_function_1() __attribute__((unlock_function(muWrapper.mu))); -int uf_function_2() __attribute__((unlock_function(muDoubleWrapper.muWrapper->mu))); -int uf_function_3() __attribute__((unlock_function(muWrapper.getMu()))); -int uf_function_4() __attribute__((unlock_function(*muWrapper.getMuPointer()))); -int uf_function_5() __attribute__((unlock_function(&mu1))); -int uf_function_6() __attribute__((unlock_function(muRef))); -int uf_function_7() __attribute__((unlock_function(muDoubleWrapper.getWrapper()->getMu()))); -int uf_function_8() __attribute__((unlock_function(muPointer))); -int uf_function_9(Mu x) __attribute__((unlock_function(1))); -int uf_function_9(Mu x, Mu y) __attribute__((unlock_function(1,2))); +int uf_function_1() UNLOCK_FUNCTION(muWrapper.mu); +int uf_function_2() UNLOCK_FUNCTION(muDoubleWrapper.muWrapper->mu); +int uf_function_3() UNLOCK_FUNCTION(muWrapper.getMu()); +int uf_function_4() UNLOCK_FUNCTION(*muWrapper.getMuPointer()); +int uf_function_5() UNLOCK_FUNCTION(&mu1); +int uf_function_6() UNLOCK_FUNCTION(muRef); +int uf_function_7() UNLOCK_FUNCTION(muDoubleWrapper.getWrapper()->getMu()); +int uf_function_8() UNLOCK_FUNCTION(muPointer); +int uf_function_9(Mutex x) UNLOCK_FUNCTION(1); +int uf_function_9(Mutex x, Mutex y) UNLOCK_FUNCTION(1,2); // illegal attribute arguments -int uf_function_bad_2() __attribute__((unlock_function("mu"))); // \ - // expected-warning {{'unlock_function' attribute requires arguments that are class type or point to class type}} -int uf_function_bad_3() __attribute__((unlock_function(muDoublePointer))); // \ +int uf_function_bad_2() UNLOCK_FUNCTION("mu"); // \ + // expected-warning {{ignoring 'unlock_function' attribute because its argument is invalid}} +int uf_function_bad_3() UNLOCK_FUNCTION(muDoublePointer); // \ // expected-warning {{'unlock_function' attribute requires arguments that are class type or point to class type}} -int uf_function_bad_4() __attribute__((unlock_function(umu))); // \ +int uf_function_bad_4() UNLOCK_FUNCTION(umu); // \ // expected-warning {{'unlock_function' attribute requires arguments whose type is annotated with 'lockable' attribute}} -int uf_function_bad_1() __attribute__((unlock_function(1))); // \ +int uf_function_bad_1() UNLOCK_FUNCTION(1); // \ // expected-error {{'unlock_function' attribute parameter 1 is out of bounds: no parameters to index into}} -int uf_function_bad_5(Mu x) __attribute__((unlock_function(0))); // \ +int uf_function_bad_5(Mutex x) UNLOCK_FUNCTION(0); // \ // expected-error {{'unlock_function' attribute parameter 1 is out of bounds: can only be 1, since there is one parameter}} -int uf_function_bad_6(Mu x, Mu y) __attribute__((unlock_function(0))); // \ +int uf_function_bad_6(Mutex x, Mutex y) UNLOCK_FUNCTION(0); // \ // expected-error {{'unlock_function' attribute parameter 1 is out of bounds: must be between 1 and 2}} -int uf_function_bad_7() __attribute__((unlock_function(0))); // \ +int uf_function_bad_7() UNLOCK_FUNCTION(0); // \ // expected-error {{'unlock_function' attribute parameter 1 is out of bounds: no parameters to index into}} @@ -923,57 +923,57 @@ int uf_function_bad_7() __attribute__((unlock_function(0))); // \ void lr_function() __attribute__((lock_returned)); // \ // expected-error {{attribute takes one argument}} -void lr_function_arg() __attribute__((lock_returned(mu1))); +void lr_function_arg() LOCK_RETURNED(mu1); void lr_function_args() __attribute__((lock_returned(mu1, mu2))); // \ // expected-error {{attribute takes one argument}} -int lr_testfn(int y) __attribute__((lock_returned(mu1))); +int lr_testfn(int y) LOCK_RETURNED(mu1); int lr_testfn(int y) { - int x __attribute__((lock_returned(mu1))) = y; // \ + int x LOCK_RETURNED(mu1) = y; // \ // expected-warning {{'lock_returned' attribute only applies to functions and methods}} return x; }; -int lr_test_var __attribute__((lock_returned(mu1))); // \ +int lr_test_var LOCK_RETURNED(mu1); // \ // expected-warning {{'lock_returned' attribute only applies to functions and methods}} -void lr_fun_params(int lvar __attribute__((lock_returned(mu1)))); // \ +void lr_fun_params(int lvar LOCK_RETURNED(mu1)); // \ // expected-warning {{'lock_returned' attribute only applies to functions and methods}} class LrFoo { private: - int test_field __attribute__((lock_returned(mu1))); // \ + int test_field LOCK_RETURNED(mu1); // \ // expected-warning {{'lock_returned' attribute only applies to functions and methods}} - void test_method() __attribute__((lock_returned(mu1))); + void test_method() LOCK_RETURNED(mu1); }; -class __attribute__((lock_returned(mu1))) LrTestClass { // \ +class LOCK_RETURNED(mu1) LrTestClass { // \ // expected-warning {{'lock_returned' attribute only applies to functions and methods}} }; // Check argument parsing. // legal attribute arguments -int lr_function_1() __attribute__((lock_returned(muWrapper.mu))); -int lr_function_2() __attribute__((lock_returned(muDoubleWrapper.muWrapper->mu))); -int lr_function_3() __attribute__((lock_returned(muWrapper.getMu()))); -int lr_function_4() __attribute__((lock_returned(*muWrapper.getMuPointer()))); -int lr_function_5() __attribute__((lock_returned(&mu1))); -int lr_function_6() __attribute__((lock_returned(muRef))); -int lr_function_7() __attribute__((lock_returned(muDoubleWrapper.getWrapper()->getMu()))); -int lr_function_8() __attribute__((lock_returned(muPointer))); +int lr_function_1() LOCK_RETURNED(muWrapper.mu); +int lr_function_2() LOCK_RETURNED(muDoubleWrapper.muWrapper->mu); +int lr_function_3() LOCK_RETURNED(muWrapper.getMu()); +int lr_function_4() LOCK_RETURNED(*muWrapper.getMuPointer()); +int lr_function_5() LOCK_RETURNED(&mu1); +int lr_function_6() LOCK_RETURNED(muRef); +int lr_function_7() LOCK_RETURNED(muDoubleWrapper.getWrapper()->getMu()); +int lr_function_8() LOCK_RETURNED(muPointer); // illegal attribute arguments -int lr_function_bad_1() __attribute__((lock_returned(1))); // \ +int lr_function_bad_1() LOCK_RETURNED(1); // \ // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}} -int lr_function_bad_2() __attribute__((lock_returned("mu"))); // \ +int lr_function_bad_2() LOCK_RETURNED("mu"); // \ + // expected-warning {{ignoring 'lock_returned' attribute because its argument is invalid}} +int lr_function_bad_3() LOCK_RETURNED(muDoublePointer); // \ // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}} -int lr_function_bad_3() __attribute__((lock_returned(muDoublePointer))); // \ - // expected-warning {{'lock_returned' attribute requires arguments that are class type or point to class type}} -int lr_function_bad_4() __attribute__((lock_returned(umu))); // \ +int lr_function_bad_4() LOCK_RETURNED(umu); // \ // expected-warning {{'lock_returned' attribute requires arguments whose type is annotated with 'lockable' attribute}} @@ -991,56 +991,56 @@ int lr_function_bad_4() __attribute__((lock_returned(umu))); // \ void le_function() __attribute__((locks_excluded)); // \ // expected-error {{attribute takes at least 1 argument}} -void le_function_arg() __attribute__((locks_excluded(mu1))); +void le_function_arg() LOCKS_EXCLUDED(mu1); -void le_function_args() __attribute__((locks_excluded(mu1, mu2))); +void le_function_args() LOCKS_EXCLUDED(mu1, mu2); -int le_testfn(int y) __attribute__((locks_excluded(mu1))); +int le_testfn(int y) LOCKS_EXCLUDED(mu1); int le_testfn(int y) { - int x __attribute__((locks_excluded(mu1))) = y; // \ + int x LOCKS_EXCLUDED(mu1) = y; // \ // expected-warning {{'locks_excluded' attribute only applies to functions and methods}} return x; }; -int le_test_var __attribute__((locks_excluded(mu1))); // \ +int le_test_var LOCKS_EXCLUDED(mu1); // \ // expected-warning {{'locks_excluded' attribute only applies to functions and methods}} -void le_fun_params(int lvar __attribute__((locks_excluded(mu1)))); // \ +void le_fun_params(int lvar LOCKS_EXCLUDED(mu1)); // \ // expected-warning {{'locks_excluded' attribute only applies to functions and methods}} class LeFoo { private: - int test_field __attribute__((locks_excluded(mu1))); // \ + int test_field LOCKS_EXCLUDED(mu1); // \ // expected-warning {{'locks_excluded' attribute only applies to functions and methods}} - void test_method() __attribute__((locks_excluded(mu1))); + void test_method() LOCKS_EXCLUDED(mu1); }; -class __attribute__((locks_excluded(mu1))) LeTestClass { // \ +class LOCKS_EXCLUDED(mu1) LeTestClass { // \ // expected-warning {{'locks_excluded' attribute only applies to functions and methods}} }; // Check argument parsing. // legal attribute arguments -int le_function_1() __attribute__((locks_excluded(muWrapper.mu))); -int le_function_2() __attribute__((locks_excluded(muDoubleWrapper.muWrapper->mu))); -int le_function_3() __attribute__((locks_excluded(muWrapper.getMu()))); -int le_function_4() __attribute__((locks_excluded(*muWrapper.getMuPointer()))); -int le_function_5() __attribute__((locks_excluded(&mu1))); -int le_function_6() __attribute__((locks_excluded(muRef))); -int le_function_7() __attribute__((locks_excluded(muDoubleWrapper.getWrapper()->getMu()))); -int le_function_8() __attribute__((locks_excluded(muPointer))); +int le_function_1() LOCKS_EXCLUDED(muWrapper.mu); +int le_function_2() LOCKS_EXCLUDED(muDoubleWrapper.muWrapper->mu); +int le_function_3() LOCKS_EXCLUDED(muWrapper.getMu()); +int le_function_4() LOCKS_EXCLUDED(*muWrapper.getMuPointer()); +int le_function_5() LOCKS_EXCLUDED(&mu1); +int le_function_6() LOCKS_EXCLUDED(muRef); +int le_function_7() LOCKS_EXCLUDED(muDoubleWrapper.getWrapper()->getMu()); +int le_function_8() LOCKS_EXCLUDED(muPointer); // illegal attribute arguments -int le_function_bad_1() __attribute__((locks_excluded(1))); // \ - // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}} -int le_function_bad_2() __attribute__((locks_excluded("mu"))); // \ +int le_function_bad_1() LOCKS_EXCLUDED(1); // \ // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}} -int le_function_bad_3() __attribute__((locks_excluded(muDoublePointer))); // \ +int le_function_bad_2() LOCKS_EXCLUDED("mu"); // \ + // expected-warning {{ignoring 'locks_excluded' attribute because its argument is invalid}} +int le_function_bad_3() LOCKS_EXCLUDED(muDoublePointer); // \ // expected-warning {{'locks_excluded' attribute requires arguments that are class type or point to class type}} -int le_function_bad_4() __attribute__((locks_excluded(umu))); // \ +int le_function_bad_4() LOCKS_EXCLUDED(umu); // \ // expected-warning {{'locks_excluded' attribute requires arguments whose type is annotated with 'lockable' attribute}} @@ -1058,56 +1058,56 @@ int le_function_bad_4() __attribute__((locks_excluded(umu))); // \ void elr_function() __attribute__((exclusive_locks_required)); // \ // expected-error {{attribute takes at least 1 argument}} -void elr_function_arg() __attribute__((exclusive_locks_required(mu1))); +void elr_function_arg() EXCLUSIVE_LOCKS_REQUIRED(mu1); -void elr_function_args() __attribute__((exclusive_locks_required(mu1, mu2))); +void elr_function_args() EXCLUSIVE_LOCKS_REQUIRED(mu1, mu2); -int elr_testfn(int y) __attribute__((exclusive_locks_required(mu1))); +int elr_testfn(int y) EXCLUSIVE_LOCKS_REQUIRED(mu1); int elr_testfn(int y) { - int x __attribute__((exclusive_locks_required(mu1))) = y; // \ + int x EXCLUSIVE_LOCKS_REQUIRED(mu1) = y; // \ // expected-warning {{'exclusive_locks_required' attribute only applies to functions and methods}} return x; }; -int elr_test_var __attribute__((exclusive_locks_required(mu1))); // \ +int elr_test_var EXCLUSIVE_LOCKS_REQUIRED(mu1); // \ // expected-warning {{'exclusive_locks_required' attribute only applies to functions and methods}} -void elr_fun_params(int lvar __attribute__((exclusive_locks_required(mu1)))); // \ +void elr_fun_params(int lvar EXCLUSIVE_LOCKS_REQUIRED(mu1)); // \ // expected-warning {{'exclusive_locks_required' attribute only applies to functions and methods}} class ElrFoo { private: - int test_field __attribute__((exclusive_locks_required(mu1))); // \ + int test_field EXCLUSIVE_LOCKS_REQUIRED(mu1); // \ // expected-warning {{'exclusive_locks_required' attribute only applies to functions and methods}} - void test_method() __attribute__((exclusive_locks_required(mu1))); + void test_method() EXCLUSIVE_LOCKS_REQUIRED(mu1); }; -class __attribute__((exclusive_locks_required(mu1))) ElrTestClass { // \ +class EXCLUSIVE_LOCKS_REQUIRED(mu1) ElrTestClass { // \ // expected-warning {{'exclusive_locks_required' attribute only applies to functions and methods}} }; // Check argument parsing. // legal attribute arguments -int elr_function_1() __attribute__((exclusive_locks_required(muWrapper.mu))); -int elr_function_2() __attribute__((exclusive_locks_required(muDoubleWrapper.muWrapper->mu))); -int elr_function_3() __attribute__((exclusive_locks_required(muWrapper.getMu()))); -int elr_function_4() __attribute__((exclusive_locks_required(*muWrapper.getMuPointer()))); -int elr_function_5() __attribute__((exclusive_locks_required(&mu1))); -int elr_function_6() __attribute__((exclusive_locks_required(muRef))); -int elr_function_7() __attribute__((exclusive_locks_required(muDoubleWrapper.getWrapper()->getMu()))); -int elr_function_8() __attribute__((exclusive_locks_required(muPointer))); +int elr_function_1() EXCLUSIVE_LOCKS_REQUIRED(muWrapper.mu); +int elr_function_2() EXCLUSIVE_LOCKS_REQUIRED(muDoubleWrapper.muWrapper->mu); +int elr_function_3() EXCLUSIVE_LOCKS_REQUIRED(muWrapper.getMu()); +int elr_function_4() EXCLUSIVE_LOCKS_REQUIRED(*muWrapper.getMuPointer()); +int elr_function_5() EXCLUSIVE_LOCKS_REQUIRED(&mu1); +int elr_function_6() EXCLUSIVE_LOCKS_REQUIRED(muRef); +int elr_function_7() EXCLUSIVE_LOCKS_REQUIRED(muDoubleWrapper.getWrapper()->getMu()); +int elr_function_8() EXCLUSIVE_LOCKS_REQUIRED(muPointer); // illegal attribute arguments -int elr_function_bad_1() __attribute__((exclusive_locks_required(1))); // \ +int elr_function_bad_1() EXCLUSIVE_LOCKS_REQUIRED(1); // \ // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}} -int elr_function_bad_2() __attribute__((exclusive_locks_required("mu"))); // \ +int elr_function_bad_2() EXCLUSIVE_LOCKS_REQUIRED("mu"); // \ + // expected-warning {{ignoring 'exclusive_locks_required' attribute because its argument is invalid}} +int elr_function_bad_3() EXCLUSIVE_LOCKS_REQUIRED(muDoublePointer); // \ // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}} -int elr_function_bad_3() __attribute__((exclusive_locks_required(muDoublePointer))); // \ - // expected-warning {{'exclusive_locks_required' attribute requires arguments that are class type or point to class type}} -int elr_function_bad_4() __attribute__((exclusive_locks_required(umu))); // \ +int elr_function_bad_4() EXCLUSIVE_LOCKS_REQUIRED(umu); // \ // expected-warning {{'exclusive_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}} @@ -1126,56 +1126,56 @@ int elr_function_bad_4() __attribute__((exclusive_locks_required(umu))); // \ void slr_function() __attribute__((shared_locks_required)); // \ // expected-error {{attribute takes at least 1 argument}} -void slr_function_arg() __attribute__((shared_locks_required(mu1))); +void slr_function_arg() SHARED_LOCKS_REQUIRED(mu1); -void slr_function_args() __attribute__((shared_locks_required(mu1, mu2))); +void slr_function_args() SHARED_LOCKS_REQUIRED(mu1, mu2); -int slr_testfn(int y) __attribute__((shared_locks_required(mu1))); +int slr_testfn(int y) SHARED_LOCKS_REQUIRED(mu1); int slr_testfn(int y) { - int x __attribute__((shared_locks_required(mu1))) = y; // \ + int x SHARED_LOCKS_REQUIRED(mu1) = y; // \ // expected-warning {{'shared_locks_required' attribute only applies to functions and methods}} return x; }; -int slr_test_var __attribute__((shared_locks_required(mu1))); // \ +int slr_test_var SHARED_LOCKS_REQUIRED(mu1); // \ // expected-warning {{'shared_locks_required' attribute only applies to functions and methods}} -void slr_fun_params(int lvar __attribute__((shared_locks_required(mu1)))); // \ +void slr_fun_params(int lvar SHARED_LOCKS_REQUIRED(mu1)); // \ // expected-warning {{'shared_locks_required' attribute only applies to functions and methods}} class SlrFoo { private: - int test_field __attribute__((shared_locks_required(mu1))); // \ + int test_field SHARED_LOCKS_REQUIRED(mu1); // \ // expected-warning {{'shared_locks_required' attribute only applies to functions and methods}} - void test_method() __attribute__((shared_locks_required(mu1))); + void test_method() SHARED_LOCKS_REQUIRED(mu1); }; -class __attribute__((shared_locks_required(mu1))) SlrTestClass { // \ +class SHARED_LOCKS_REQUIRED(mu1) SlrTestClass { // \ // expected-warning {{'shared_locks_required' attribute only applies to functions and methods}} }; // Check argument parsing. // legal attribute arguments -int slr_function_1() __attribute__((shared_locks_required(muWrapper.mu))); -int slr_function_2() __attribute__((shared_locks_required(muDoubleWrapper.muWrapper->mu))); -int slr_function_3() __attribute__((shared_locks_required(muWrapper.getMu()))); -int slr_function_4() __attribute__((shared_locks_required(*muWrapper.getMuPointer()))); -int slr_function_5() __attribute__((shared_locks_required(&mu1))); -int slr_function_6() __attribute__((shared_locks_required(muRef))); -int slr_function_7() __attribute__((shared_locks_required(muDoubleWrapper.getWrapper()->getMu()))); -int slr_function_8() __attribute__((shared_locks_required(muPointer))); +int slr_function_1() SHARED_LOCKS_REQUIRED(muWrapper.mu); +int slr_function_2() SHARED_LOCKS_REQUIRED(muDoubleWrapper.muWrapper->mu); +int slr_function_3() SHARED_LOCKS_REQUIRED(muWrapper.getMu()); +int slr_function_4() SHARED_LOCKS_REQUIRED(*muWrapper.getMuPointer()); +int slr_function_5() SHARED_LOCKS_REQUIRED(&mu1); +int slr_function_6() SHARED_LOCKS_REQUIRED(muRef); +int slr_function_7() SHARED_LOCKS_REQUIRED(muDoubleWrapper.getWrapper()->getMu()); +int slr_function_8() SHARED_LOCKS_REQUIRED(muPointer); // illegal attribute arguments -int slr_function_bad_1() __attribute__((shared_locks_required(1))); // \ - // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}} -int slr_function_bad_2() __attribute__((shared_locks_required("mu"))); // \ +int slr_function_bad_1() SHARED_LOCKS_REQUIRED(1); // \ // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}} -int slr_function_bad_3() __attribute__((shared_locks_required(muDoublePointer))); // \ +int slr_function_bad_2() SHARED_LOCKS_REQUIRED("mu"); // \ + // expected-warning {{ignoring 'shared_locks_required' attribute because its argument is invalid}} +int slr_function_bad_3() SHARED_LOCKS_REQUIRED(muDoublePointer); // \ // expected-warning {{'shared_locks_required' attribute requires arguments that are class type or point to class type}} -int slr_function_bad_4() __attribute__((shared_locks_required(umu))); // \ +int slr_function_bad_4() SHARED_LOCKS_REQUIRED(umu); // \ // expected-warning {{'shared_locks_required' attribute requires arguments whose type is annotated with 'lockable' attribute}} @@ -1240,43 +1240,43 @@ struct Foomgoper { // Parsing of member variables and function parameters //------------------------------------------------------ -Mu gmu; +Mutex gmu; class StaticMu { - static Mu statmu; + static Mutex statmu; }; class FooLate { public: - void foo1() __attribute__((exclusive_locks_required(gmu))) { } - void foo2() __attribute__((exclusive_locks_required(mu))) { } - void foo3(Mu *m) __attribute__((exclusive_locks_required(m))) { } - void foo3(FooLate *f) __attribute__((exclusive_locks_required(f->mu))) { } - void foo4(FooLate *f) __attribute__((exclusive_locks_required(f->mu))); + void foo1() EXCLUSIVE_LOCKS_REQUIRED(gmu) { } + void foo2() EXCLUSIVE_LOCKS_REQUIRED(mu) { } + void foo3(Mutex *m) EXCLUSIVE_LOCKS_REQUIRED(m) { } + void foo3(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu) { } + void foo4(FooLate *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu); - static void foo5() __attribute__((exclusive_locks_required(mu))); // \ + static void foo5() EXCLUSIVE_LOCKS_REQUIRED(mu); // \ // expected-error {{'this' cannot be implicitly used in a static member function declaration}} template <class T> - void foo6() __attribute__((exclusive_locks_required(T::statmu))) { } + void foo6() EXCLUSIVE_LOCKS_REQUIRED(T::statmu) { } template <class T> - void foo7(T* f) __attribute__((exclusive_locks_required(f->mu))) { } + void foo7(T* f) EXCLUSIVE_LOCKS_REQUIRED(f->mu) { } - int a __attribute__((guarded_by(gmu))); - int b __attribute__((guarded_by(mu))); - int c __attribute__((guarded_by(this->mu))); + int a GUARDED_BY(gmu); + int b GUARDED_BY(mu); + int c GUARDED_BY(this->mu); - Mu mu; + Mutex mu; }; //------------------------- // Empty argument lists //------------------------- -class __attribute__((lockable)) EmptyArgListsTest { - void lock() __attribute__((exclusive_lock_function())) { } - void unlock() __attribute__((unlock_function())) { } +class LOCKABLE EmptyArgListsTest { + void lock() EXCLUSIVE_LOCK_FUNCTION() { } + void unlock() UNLOCK_FUNCTION() { } }; @@ -1285,7 +1285,7 @@ namespace FunctionDefinitionParseTest { class Foo { public: - Mu mu_; + Mutex mu_; void foo1(); void foo2(Foo *f); }; @@ -1293,17 +1293,17 @@ public: template <class T> class Bar { public: - Mu mu_; + Mutex mu_; void bar(); }; -void Foo::foo1() __attribute__((exclusive_locks_required(mu_))) { } -void Foo::foo2(Foo *f) __attribute__((exclusive_locks_required(f->mu_))) { } +void Foo::foo1() EXCLUSIVE_LOCKS_REQUIRED(mu_) { } +void Foo::foo2(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_) { } template <class T> -void Bar<T>::bar() __attribute__((exclusive_locks_required(mu_))) { } +void Bar<T>::bar() EXCLUSIVE_LOCKS_REQUIRED(mu_) { } -void baz(Foo *f) __attribute__((exclusive_locks_required(f->mu_))) { } +void baz(Foo *f) EXCLUSIVE_LOCKS_REQUIRED(f->mu_) { } } // end namespace @@ -1312,13 +1312,15 @@ namespace TestMultiDecl { class Foo { public: - int __attribute__((guarded_by(mu_))) a; - int __attribute__((guarded_by(mu_))) b, c; + int GUARDED_BY(mu_) a; + int GUARDED_BY(mu_) b, c; private: - Mu mu_; + Mutex mu_; }; +} // end namespace TestMultiDecl + namespace NestedClassLateDecl { @@ -1331,15 +1333,100 @@ class Foo { void bar2(Bar* b) EXCLUSIVE_LOCKS_REQUIRED(b->mu) { b->a = 0; } void bar3(Foo* f) EXCLUSIVE_LOCKS_REQUIRED(f->fooMu) { f->a = 0; } - Mu mu; + Mutex mu; }; int a GUARDED_BY(fooMu); - Mu fooMu; - static Mu fooMuStatic; + Mutex fooMu; + static Mutex fooMuStatic; }; } -} // end namespace TestMultiDecl +namespace PointerToMemberTest { + +// Empty string should be ignored. +int testEmptyAttribute GUARDED_BY(""); +void testEmptyAttributeFunction() EXCLUSIVE_LOCKS_REQUIRED(""); + +class Graph { +public: + Mutex mu_; + + static Mutex* get_static_mu() LOCK_RETURNED(&Graph::mu_); +}; + +class Node { +public: + void foo() EXCLUSIVE_LOCKS_REQUIRED(&Graph::mu_); + int a GUARDED_BY(&Graph::mu_); +}; + +} + + +namespace SmartPointerTest { + +template<class T> +class smart_ptr { + public: + T* operator->() { return ptr_; } + T& operator*() { return ptr_; } + + private: + T* ptr_; +}; + + +Mutex gmu; +smart_ptr<int> gdat PT_GUARDED_BY(gmu); + + +class MyClass { +public: + Mutex mu_; + smart_ptr<Mutex> smu_; + + + smart_ptr<int> a PT_GUARDED_BY(mu_); + int b GUARDED_BY(smu_); +}; + +} + + +namespace InheritanceTest { + +class LOCKABLE Base { + public: + void lock() EXCLUSIVE_LOCK_FUNCTION(); + void unlock() UNLOCK_FUNCTION(); +}; + +class Base2 { }; + +class Derived1 : public Base { }; + +class Derived2 : public Base2, public Derived1 { }; + +class Derived3 : public Base2 { }; + +class Foo { + Derived1 mu1_; + Derived2 mu2_; + Derived3 mu3_; + int a GUARDED_BY(mu1_); + int b GUARDED_BY(mu2_); + int c GUARDED_BY(mu3_); // \ + // expected-warning {{'guarded_by' attribute requires arguments whose type is annotated with 'lockable' attribute; type here is 'class InheritanceTest::Derived3'}} + + void foo() EXCLUSIVE_LOCKS_REQUIRED(mu1_, mu2_) { + a = 0; + b = 0; + } +}; + +} + + diff --git a/test/SemaCXX/warn-unique-enum.cpp b/test/SemaCXX/warn-unique-enum.cpp new file mode 100644 index 000000000000..59a127807172 --- /dev/null +++ b/test/SemaCXX/warn-unique-enum.cpp @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 %s -fsyntax-only -verify -Wunique-enum +enum A { A1 = 1, A2 = 1, A3 = 1 }; // expected-warning {{all elements of 'A' are initialized with literals to value 1}} \ +// expected-note {{initialize the last element with the previous element to silence this warning}} +enum { B1 = 1, B2 = 1, B3 = 1 }; // no warning +enum C { // expected-warning {{all elements of 'C' are initialized with literals to value 1}} + C1 = true, + C2 = true // expected-note {{initialize the last element with the previous element to silence this warning}} +}; +enum D { D1 = 5, D2 = 5L, D3 = 5UL, D4 = 5LL, D5 = 5ULL }; // expected-warning {{all elements of 'D' are initialized with literals to value 5}} \ +// expected-note {{initialize the last element with the previous element to silence this warning}} + +// Don't warn on enums with less than 2 elements. +enum E { E1 = 4 }; +enum F { F1 }; +enum G {}; + +// Don't warn when integer literals do not initialize the elements. +enum H { H1 = 4, H_MAX = H1, H_MIN = H1 }; +enum I { I1 = H1, I2 = 4 }; +enum J { J1 = 4, J2 = I2 }; +enum K { K1, K2, K3, K4 }; + +// Don't crash or warn on this one. +// rdar://11875995 +enum L { + L1 = 0x8000000000000000ULL, L2 = 0x0000000000000001ULL +}; diff --git a/test/SemaCXX/warn-unused-private-field.cpp b/test/SemaCXX/warn-unused-private-field.cpp new file mode 100644 index 000000000000..661442db9e9d --- /dev/null +++ b/test/SemaCXX/warn-unused-private-field.cpp @@ -0,0 +1,246 @@ +// RUN: %clang_cc1 -fsyntax-only -Wunused-private-field -Wused-but-marked-unused -verify -std=c++11 %s + +class NotFullyDefined { + public: + NotFullyDefined(); + private: + int y; +}; + +class HasUndefinedNestedClass { + class Undefined; + int unused_; +}; + +class HasUndefinedPureVirtualDestructor { + virtual ~HasUndefinedPureVirtualDestructor() = 0; + int unused_; +}; + +class HasDefinedNestedClasses { + class DefinedHere {}; + class DefinedOutside; + int unused_; // expected-warning{{private field 'unused_' is not used}} +}; +class HasDefinedNestedClasses::DefinedOutside {}; + +class HasUndefinedFriendFunction { + friend void undefinedFriendFunction(); + int unused_; +}; + +class HasUndefinedFriendClass { + friend class NotFullyDefined; + friend class NotDefined; + int unused_; +}; + +class HasFriend { + friend class FriendClass; + friend void friendFunction(HasFriend f); + int unused_; // expected-warning{{private field 'unused_' is not used}} + int used_by_friend_class_; + int used_by_friend_function_; +}; + +class ClassWithTemplateFriend { + template <typename T> friend class TemplateFriend; + int used_by_friend_; + int unused_; +}; + +template <typename T> class TemplateFriend { +public: + TemplateFriend(ClassWithTemplateFriend my_friend) { + int var = my_friend.used_by_friend_; + } +}; + +class FriendClass { + HasFriend my_friend_; + void use() { + my_friend_.used_by_friend_class_ = 42; + } +}; + +void friendFunction(HasFriend my_friend) { + my_friend.used_by_friend_function_ = 42; +} + +class NonTrivialConstructor { + public: + NonTrivialConstructor() {} +}; + +class NonTrivialDestructor { + public: + ~NonTrivialDestructor() {} +}; + +class Trivial { + public: + Trivial() = default; + Trivial(int a) {} +}; + +int side_effect() { + return 42; +} + +class A { + public: + A() : primitive_type_(42), default_initializer_(), other_initializer_(42), + trivial_(), user_constructor_(42), + initialized_with_side_effect_(side_effect()) { + used_ = 42; + attr_used_ = 42; // expected-warning{{'attr_used_' was marked unused but was used}} + } + + A(int x, A* a) : pointer_(a) {} + + private: + int primitive_type_; // expected-warning{{private field 'primitive_type_' is not used}} + A* pointer_; // expected-warning{{private field 'pointer_' is not used}} + int no_initializer_; // expected-warning{{private field 'no_initializer_' is not used}} + int default_initializer_; // expected-warning{{private field 'default_initializer_' is not used}} + int other_initializer_; // expected-warning{{private field 'other_initializer_' is not used}} + int used_, unused_; // expected-warning{{private field 'unused_' is not used}} + int in_class_initializer_ = 42; // expected-warning{{private field 'in_class_initializer_' is not used}} + int in_class_initializer_with_side_effect_ = side_effect(); + Trivial trivial_initializer_ = Trivial(); // expected-warning{{private field 'trivial_initializer_' is not used}} + Trivial non_trivial_initializer_ = Trivial(42); + int initialized_with_side_effect_; + static int static_fields_are_ignored_; + + Trivial trivial_; // expected-warning{{private field 'trivial_' is not used}} + Trivial user_constructor_; + NonTrivialConstructor non_trivial_constructor_; + NonTrivialDestructor non_trivial_destructor_; + + int attr_ __attribute__((unused)); + int attr_used_ __attribute__((unused)); +}; + +class EverythingUsed { + public: + EverythingUsed() : as_array_index_(0), var_(by_initializer_) { + var_ = sizeof(sizeof_); + int *use = &by_reference_; + int test[2]; + test[as_array_index_] = 42; + } + + template<class T> + void useStuff(T t) { + by_template_function_ = 42; + } + + private: + int var_; + int sizeof_; + int by_reference_; + int by_template_function_; + int as_array_index_; + int by_initializer_; +}; + +class HasFeatureTest { +#if __has_feature(attribute_unused_on_fields) + int unused_; // expected-warning{{private field 'unused_' is not used}} + int unused2_ __attribute__((unused)); // no-warning +#endif +}; + +namespace templates { +class B { + template <typename T> void f(T t); + int a; +}; +} // namespace templates + +namespace mutual_friends { +// Undefined methods make mutual friends undefined. +class A { + int a; + friend class B; + void doSomethingToAOrB(); +}; +class B { + int b; + friend class A; +}; + +// Undefined friends do not make a mutual friend undefined. +class C { + int c; + void doSomethingElse() {} + friend class E; + friend class D; +}; +class D { + int d; // expected-warning{{private field 'd' is not used}} + friend class C; +}; + +// Undefined nested classes make mutual friends undefined. +class F { + int f; + class G; + friend class H; +}; +class H { + int h; + friend class F; +}; +} // namespace mutual_friends + +namespace anonymous_structs_unions { +class A { + private: + // FIXME: Look at the DeclContext for anonymous structs/unions. + union { + int *Aligner; + unsigned char Data[8]; + }; +}; +union S { + private: + int *Aligner; + unsigned char Data[8]; +}; +} // namespace anonymous_structs_unions + +namespace pr13413 { +class A { + A() : p_(__null), b_(false), a_(this), p2_(nullptr) {} + void* p_; // expected-warning{{private field 'p_' is not used}} + bool b_; // expected-warning{{private field 'b_' is not used}} + A* a_; // expected-warning{{private field 'a_' is not used}} + void* p2_; // expected-warning{{private field 'p2_' is not used}} +}; +} + +namespace pr13543 { + void f(int); + void f(char); + struct S { + S() : p(&f) {} + private: + void (*p)(int); // expected-warning{{private field 'p' is not used}} + }; + + struct A { int n; }; + struct B { + B() : a(A()) {} + B(char) {} + B(int n) : a{n}, b{(f(n), 0)} {} + private: + A a = A(); // expected-warning{{private field 'a' is not used}} + A b; + }; + + struct X { ~X(); }; + class C { + X x[4]; // no-warning + }; +} diff --git a/test/SemaCXX/warn-unused-value.cpp b/test/SemaCXX/warn-unused-value.cpp index 1c0263c581c1..072ee60f1f35 100644 --- a/test/SemaCXX/warn-unused-value.cpp +++ b/test/SemaCXX/warn-unused-value.cpp @@ -12,7 +12,7 @@ namespace test0 { // pointer to volatile has side effect (thus no warning) Box* box = new Box; box->i; // expected-warning {{expression result unused}} - box->j; + box->j; // expected-warning {{expression result unused}} } } diff --git a/test/SemaObjC/arc-bridged-cast.m b/test/SemaObjC/arc-bridged-cast.m index 56efe81d608b..b5ec36af3838 100644 --- a/test/SemaObjC/arc-bridged-cast.m +++ b/test/SemaObjC/arc-bridged-cast.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s typedef const void *CFTypeRef; CFTypeRef CFBridgingRetain(id X); @@ -32,13 +33,32 @@ void to_cf(id obj) { // rdar://problem/9629566 - temporary workaround CFTypeRef cf5 = (__bridge_retain CFTypeRef)CreateSomething(); // expected-error {{unknown cast annotation __bridge_retain; did you mean __bridge_retained?}} + // CHECK: fix-it:"{{.*}}":{35:20-35:35}:"__bridge_retained" } -void fixits() { +CFTypeRef fixits() { id obj1 = (id)CFCreateSomething(); // expected-error{{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \ - // expected-note{{use __bridge to convert directly (no change in ownership)}} \ - // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}} + // expected-note{{use __bridge to convert directly (no change in ownership)}} expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}} + // CHECK: fix-it:"{{.*}}":{40:17-40:17}:"CFBridgingRelease(" + // CHECK: fix-it:"{{.*}}":{40:36-40:36}:")" + CFTypeRef cf1 = (CFTypeRef)CreateSomething(); // expected-error{{cast of Objective-C pointer type 'id' to C pointer type 'CFTypeRef' (aka 'const void *') requires a bridged cast}} \ // expected-note{{use __bridge to convert directly (no change in ownership)}} \ // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}} + // CHECK: fix-it:"{{.*}}":{45:30-45:30}:"CFBridgingRetain(" + // CHECK: fix-it:"{{.*}}":{45:47-45:47}:")" + + return (obj1); // expected-error{{implicit conversion of Objective-C pointer type 'id' to C pointer type 'CFTypeRef' (aka 'const void *') requires a bridged cast}} \ + // expected-note{{use __bridge to convert directly (no change in ownership)}} \ + // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}} + // CHECK: fix-it:"{{.*}}":{51:10-51:10}:"(__bridge CFTypeRef)" + // CHECK: fix-it:"{{.*}}":{51:10-51:10}:"CFBridgingRetain" +} + +CFTypeRef fixitsWithSpace(id obj) { + return(obj); // expected-error{{implicit conversion of Objective-C pointer type 'id' to C pointer type 'CFTypeRef' (aka 'const void *') requires a bridged cast}} \ + // expected-note{{use __bridge to convert directly (no change in ownership)}} \ + // expected-note{{use CFBridgingRetain call to make an ARC object available as a +1 'CFTypeRef' (aka 'const void *')}} + // CHECK: fix-it:"{{.*}}":{59:9-59:9}:"(__bridge CFTypeRef)" + // CHECK: fix-it:"{{.*}}":{59:9-59:9}:" CFBridgingRetain" } diff --git a/test/SemaObjC/arc-cf.m b/test/SemaObjC/arc-cf.m index 69662ea61078..57547208c6c5 100644 --- a/test/SemaObjC/arc-cf.m +++ b/test/SemaObjC/arc-cf.m @@ -10,11 +10,13 @@ id CFBridgingRelease(CFTypeRef); typedef const struct __CFString *CFStringRef; extern CFStringRef CFMakeString0(void); +#pragma clang arc_cf_code_audited begin extern CFStringRef CFCreateString0(void); +#pragma clang arc_cf_code_audited end void test0() { id x; x = (id) CFMakeString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}} - x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}} + x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{CFBridgingRelease call to transfer}} } extern CFStringRef CFMakeString1(void) __attribute__((cf_returns_not_retained)); @@ -22,7 +24,7 @@ extern CFStringRef CFCreateString1(void) __attribute__((cf_returns_retained)); void test1() { id x; x = (id) CFMakeString1(); - x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}} + x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{CFBridgingRelease call to transfer}} } #define CF_AUDIT_BEGIN _Pragma("clang arc_cf_code_audited begin") @@ -40,6 +42,6 @@ void test2() { id x; x = (id) CFMakeString2(); x = (id) CFCreateString2(); - x = (id) CFMakeString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}} - x = (id) CFCreateString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}} + x = (id) CFMakeString3(); // expected-error {{requires a bridged cast}} expected-note {{CFBridgingRelease call to transfer}} + x = (id) CFCreateString3(); // expected-error {{requires a bridged cast}} expected-note {{CFBridgingRelease call to transfer}} } diff --git a/test/SemaObjC/arc-dict-bridged-cast.m b/test/SemaObjC/arc-dict-bridged-cast.m new file mode 100644 index 000000000000..ea648401af0c --- /dev/null +++ b/test/SemaObjC/arc-dict-bridged-cast.m @@ -0,0 +1,46 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// rdar://11913153 + +typedef const struct __CFString * CFStringRef; +typedef struct __CFString * CFMutableStringRef; +typedef signed long CFIndex; +typedef const struct __CFAllocator * CFAllocatorRef; + +extern const CFStringRef kCFBundleNameKey; + +@protocol NSCopying @end + +@interface NSDictionary +- (id)objectForKeyedSubscript:(id<NSCopying>)key; +@end + +#pragma clang arc_cf_code_audited begin +extern +CFMutableStringRef CFStringCreateMutable(CFAllocatorRef alloc, CFIndex maxLength); +#pragma clang arc_cf_code_audited end + +typedef const void * CFTypeRef; + +id CFBridgingRelease(CFTypeRef __attribute__((cf_consumed)) X); + +@interface NSMutableString @end + +NSMutableString *test() { + NSDictionary *infoDictionary; + infoDictionary[kCFBundleNameKey] = 0; // expected-error {{indexing expression is invalid because subscript type 'CFStringRef' (aka 'const struct __CFString *') is not an integral or Objective-C pointer type}} \ + // expected-error {{implicit conversion of C pointer type 'CFStringRef' (aka 'const struct __CFString *') to Objective-C pointer type '__strong id<NSCopying>' requires a bridged cast}} \ + // expected-note {{use __bridge to convert directly (no change in ownership)}} \ + // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFStringRef' (aka 'const struct __CFString *') into ARC}} + return infoDictionary[CFStringCreateMutable(((void*)0), 100)]; // expected-error {{indexing expression is invalid because subscript type 'CFMutableStringRef' (aka 'struct __CFString *') is not an integral or Objective-C pointer type}} \ + // expected-error {{implicit conversion of C pointer type 'CFMutableStringRef' (aka 'struct __CFString *') to Objective-C pointer type '__strong id<NSCopying>' requires a bridged cast}} \ + // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFMutableStringRef' (aka 'struct __CFString *') into ARC}} + +} + +// CHECK: fix-it:"{{.*}}":{31:18-31:18}:"(__bridge __strong id<NSCopying>)(" +// CHECK: fix-it:"{{.*}}":{31:34-31:34}:")" +// CHECK: fix-it:"{{.*}}":{31:18-31:18}:"CFBridgingRelease(" +// CHECK: fix-it:"{{.*}}":{31:34-31:34}:")" +// CHECK: fix-it:"{{.*}}":{35:25-35:25}:"CFBridgingRelease(" +// CHECK: fix-it:"{{.*}}":{35:63-35:63}:")" diff --git a/test/SemaObjC/arc-no-runtime.m b/test/SemaObjC/arc-no-runtime.m index b75064f77651..c5820d4321d5 100644 --- a/test/SemaObjC/arc-no-runtime.m +++ b/test/SemaObjC/arc-no-runtime.m @@ -3,7 +3,7 @@ // rdar://problem/9150784 void test(void) { __weak id x; // expected-error {{the current deployment target does not support automated __weak references}} - __weak void *v; // expected-warning {{'__weak' only applies to objective-c object or block pointer types}} + __weak void *v; // expected-warning {{'__weak' only applies to Objective-C object or block pointer types}} } @interface A diff --git a/test/SemaObjC/arc-property-lifetime.m b/test/SemaObjC/arc-property-lifetime.m index fad37ccbf463..bd393e0bf51f 100644 --- a/test/SemaObjC/arc-property-lifetime.m +++ b/test/SemaObjC/arc-property-lifetime.m @@ -168,3 +168,8 @@ void foo(Baz *f) { f.realy_strong_attr_prop = [[Baz alloc] init]; f.implicit = [[Baz alloc] init]; } + +// rdar://11253688 +@interface Boom +@property (readonly) const void * innerPointer __attribute__((objc_returns_inner_pointer)); // expected-error {{'objc_returns_inner_pointer' attribute only applies to methods}} +@end diff --git a/test/SemaObjC/arc-property.m b/test/SemaObjC/arc-property.m index 2599fb9848f2..41d8e8723961 100644 --- a/test/SemaObjC/arc-property.m +++ b/test/SemaObjC/arc-property.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -fobjc-exceptions -verify -Wno-objc-root-class %s // rdar://9309489 @interface MyClass { @@ -55,3 +55,11 @@ @implementation Test2 @synthesize test2; @end + +// rdar://problem/11144407 +@interface Test3 +@property (strong) id exception; +@end +void test3(Test3 *t3) { + @throw t3.exception; +} diff --git a/test/SemaObjC/arc-unbridged-cast.m b/test/SemaObjC/arc-unbridged-cast.m index 7d5a6b007b38..6a39e707717e 100644 --- a/test/SemaObjC/arc-unbridged-cast.m +++ b/test/SemaObjC/arc-unbridged-cast.m @@ -44,10 +44,10 @@ void test1(int cond) { x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} - x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} - x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} - x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} - x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} + x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}} + x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}} + x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}} + x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}} x = (id) [object property]; x = (id) (cond ? [object property] : (void*) 0); diff --git a/test/SemaObjC/arc.m b/test/SemaObjC/arc.m index 9c3b298cb561..bd30715a6b33 100644 --- a/test/SemaObjC/arc.m +++ b/test/SemaObjC/arc.m @@ -641,7 +641,7 @@ void test35(void) { test36_helper(&y); ^{ test36_helper(&y); }(); - __strong int non_objc_type; // expected-warning {{'__strong' only applies to objective-c object or block pointer types}} + __strong int non_objc_type; // expected-warning {{'__strong' only applies to Objective-C object or block pointer types}} } void test36(int first, ...) { @@ -696,3 +696,24 @@ void _NSCalcBeze(NSColor* color, NSColor* bezelColors[]); // expected-error {{mu } @end +// rdar://11814185 +@interface Radar11814185 +@property (nonatomic, weak) Radar11814185* picker1; ++ alloc; +- init; +@end + +@implementation Radar11814185 + +@synthesize picker1; + +- (void)viewDidLoad +{ + picker1 = [[Radar11814185 alloc] init]; // expected-warning {{assigning retained object to weak variable; object will be released after assignment}} + self.picker1 = [[Radar11814185 alloc] init]; // expected-warning {{assigning retained object to weak property; object will be released after assignment}} +} + ++ alloc { return 0; } +- init { return 0; } +@end + diff --git a/test/SemaObjC/assign-rvalue-message.m b/test/SemaObjC/assign-rvalue-message.m index 1105d5e743a9..a90cc50cdd35 100644 --- a/test/SemaObjC/assign-rvalue-message.m +++ b/test/SemaObjC/assign-rvalue-message.m @@ -19,6 +19,6 @@ struct Bar { - (void)baz { bar.x = 0; - [self bar].x = 10; // expected-error {{assigning to 'readonly' return result of an objective-c message not allowed}} + [self bar].x = 10; // expected-error {{assigning to 'readonly' return result of an Objective-C message not allowed}} } @end diff --git a/test/SemaObjC/at-defs.m b/test/SemaObjC/at-defs.m index 4c0c586fe838..73316ca283c8 100644 --- a/test/SemaObjC/at-defs.m +++ b/test/SemaObjC/at-defs.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-fragile-abi %s -fsyntax-only +// RUN: %clang_cc1 -triple i386-unknown-unknown -fobjc-runtime=macosx-fragile-10.5 %s -fsyntax-only @interface Test { double a; diff --git a/test/SemaObjC/attr-availability.m b/test/SemaObjC/attr-availability.m index d857bda77234..7c9ff0f13d90 100644 --- a/test/SemaObjC/attr-availability.m +++ b/test/SemaObjC/attr-availability.m @@ -1,13 +1,21 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin9.0.0 -fsyntax-only -verify %s -@interface A -- (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); + +@protocol P +- (void)proto_method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note 2 {{method 'proto_method' declared here}} +@end + +@interface A <P> +- (void)method __attribute__((availability(macosx,introduced=10.1,deprecated=10.2))); // expected-note {{method 'method' declared here}} @end +// rdar://11475360 @interface B : A -- (void)method; +- (void)method; // expected-note {{method 'method' declared here}} @end void f(A *a, B *b) { [a method]; // expected-warning{{'method' is deprecated: first deprecated in Mac OS X 10.2}} - [b method]; + [b method]; // expected-warning {{'method' is deprecated: first deprecated in Mac OS X 10.2}} + [a proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in Mac OS X 10.2}} + [b proto_method]; // expected-warning{{'proto_method' is deprecated: first deprecated in Mac OS X 10.2}} } diff --git a/test/SemaObjC/attr-deprecated.m b/test/SemaObjC/attr-deprecated.m index db0b958f8dd4..260462abc0b8 100644 --- a/test/SemaObjC/attr-deprecated.m +++ b/test/SemaObjC/attr-deprecated.m @@ -1,10 +1,10 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s @interface A { - int X __attribute__((deprecated)); + int X __attribute__((deprecated)); // expected-note 2 {{declared here}} } -+ (void)F __attribute__((deprecated)); -- (void)f __attribute__((deprecated)); ++ (void)F __attribute__((deprecated)); // expected-note 2 {{declared here}} +- (void)f __attribute__((deprecated)); // expected-note 4 {{declared here}} @end @implementation A @@ -42,7 +42,7 @@ @end @protocol P -- (void)p __attribute__((deprecated)); +- (void)p __attribute__((deprecated)); // expected-note {{declared here}} @end void t1(A *a) @@ -71,7 +71,7 @@ void t4(Class c) @interface Bar -@property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated)); +@property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated)); // expected-note 2 {{declared here}} - (void) MySetter : (int) value; @end @@ -83,7 +83,7 @@ int t5() { __attribute ((deprecated)) -@interface DEPRECATED { +@interface DEPRECATED { // expected-note 2 {{declared here}} @public int ivar; DEPRECATED *ivar2; // no warning. } @@ -107,7 +107,7 @@ __attribute ((deprecated)) @interface Test2 -@property int test2 __attribute__((deprecated)); +@property int test2 __attribute__((deprecated)); // expected-note 4 {{declared here}} @end void test(Test2 *foo) { @@ -121,3 +121,16 @@ void test(Test2 *foo) { __attribute__((deprecated)) @interface A(Blah) // expected-error{{attributes may not be specified on a category}} @end + + +typedef struct { + int x; +} footype __attribute((deprecated)); // expected-note 2 {{declared here}} + +@interface foo { + footype a; // expected-warning {{'footype' is deprecated}} + footype b __attribute((deprecated)); +} +@property footype c; // expected-warning {{'footype' is deprecated}} +@property footype d __attribute((deprecated)); +@end diff --git a/test/SemaObjC/blocks.m b/test/SemaObjC/blocks.m index 7beec19ea789..9926b0835f53 100644 --- a/test/SemaObjC/blocks.m +++ b/test/SemaObjC/blocks.m @@ -73,3 +73,124 @@ void foo10() { NSLog(@"%@", myBlock); } + +// In C, enum constants have the type of the underlying integer type, not the +// enumeration they are part of. We pretend the constants have enum type when +// they are mixed with other expressions of enum type. +enum CStyleEnum { + CSE_Value = 1 +}; +enum CStyleEnum getCSE(); +typedef enum CStyleEnum (^cse_block_t)(); + +void testCStyleEnumInference(bool arg) { + cse_block_t a; + + // No warnings here. + a = ^{ return getCSE(); }; + + a = ^{ // expected-error {{incompatible block pointer types assigning to 'cse_block_t' (aka 'enum CStyleEnum (^)()') from 'int (^)(void)'}} + return 1; + }; + a = ^{ // expected-error {{incompatible block pointer types assigning to 'cse_block_t' (aka 'enum CStyleEnum (^)()') from 'int (^)(void)'}} + return CSE_Value; + }; + + // No warnings here. + a = ^{ if (arg) return CSE_Value; else return getCSE(); }; + a = ^{ if (arg) return getCSE(); else return CSE_Value; }; + + // These two blocks actually return 'int' + a = ^{ // expected-error {{incompatible block pointer types assigning to 'cse_block_t' (aka 'enum CStyleEnum (^)()') from 'int (^)(void)'}} + if (arg) + return 1; + else + return CSE_Value; + }; + + a = ^{ // expected-error {{incompatible block pointer types assigning to 'cse_block_t' (aka 'enum CStyleEnum (^)()') from 'int (^)(void)'}} + if (arg) + return CSE_Value; + else + return 1; + }; +} + + +enum FixedTypeEnum : unsigned { + FTE_Value = 1U +}; +enum FixedTypeEnum getFTE(); +typedef enum FixedTypeEnum (^fte_block_t)(); + +void testFixedTypeEnumInference(bool arg) { + fte_block_t a; + + // No warnings here. + a = ^{ return getFTE(); }; + + // Since we fixed the underlying type of the enum, this is considered a + // compatible block type. + a = ^{ + return 1U; + }; + a = ^{ + return FTE_Value; + }; + + // No warnings here. + a = ^{ if (arg) return FTE_Value; else return FTE_Value; }; + a = ^{ if (arg) return getFTE(); else return getFTE(); }; + a = ^{ if (arg) return FTE_Value; else return getFTE(); }; + a = ^{ if (arg) return getFTE(); else return FTE_Value; }; + + // These two blocks actually return 'unsigned'. + a = ^{ + if (arg) + return 1U; + else + return FTE_Value; + }; + + a = ^{ + if (arg) + return FTE_Value; + else + return 1U; + }; +} + + +enum { + AnonymousValue = 1 +}; + +enum : short { + FixedAnonymousValue = 1 +}; + +typedef enum { + TDE_Value +} TypeDefEnum; +TypeDefEnum getTDE(); + +typedef enum : short { + TDFTE_Value +} TypeDefFixedTypeEnum; +TypeDefFixedTypeEnum getTDFTE(); + +typedef int (^int_block_t)(); +typedef short (^short_block_t)(); +void testAnonymousEnumTypes(int arg) { + int_block_t IB; + IB = ^{ return AnonymousValue; }; + IB = ^{ if (arg) return TDE_Value; else return getTDE(); }; // expected-error {{incompatible block pointer}} + IB = ^{ if (arg) return getTDE(); else return TDE_Value; }; // expected-error {{incompatible block pointer}} + + // Since we fixed the underlying type of the enum, these are considered + // compatible block types anyway. + short_block_t SB; + SB = ^{ return FixedAnonymousValue; }; + SB = ^{ if (arg) return TDFTE_Value; else return getTDFTE(); }; + SB = ^{ if (arg) return getTDFTE(); else return TDFTE_Value; }; +} diff --git a/test/SemaObjC/boxing-illegal-types.m b/test/SemaObjC/boxing-illegal-types.m new file mode 100644 index 000000000000..ad45b11f2d9c --- /dev/null +++ b/test/SemaObjC/boxing-illegal-types.m @@ -0,0 +1,58 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wattributes %s + +typedef long NSInteger; +typedef unsigned long NSUInteger; +typedef signed char BOOL; + +@interface NSNumber +@end +@interface NSNumber (NSNumberCreation) ++ (NSNumber *)numberWithChar:(char)value; ++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; ++ (NSNumber *)numberWithShort:(short)value; ++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; ++ (NSNumber *)numberWithInt:(int)value; ++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; ++ (NSNumber *)numberWithLong:(long)value; ++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; ++ (NSNumber *)numberWithLongLong:(long long)value; ++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; ++ (NSNumber *)numberWithFloat:(float)value; ++ (NSNumber *)numberWithDouble:(double)value; ++ (NSNumber *)numberWithBool:(BOOL)value; ++ (NSNumber *)numberWithInteger:(NSInteger)value; ++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; +@end + +typedef struct { + int x, y, z; +} point; + +void testStruct() { + point p = { 0, 0, 0 }; + id boxed = @(p); // expected-error {{illegal type 'point' used in a boxed expression}} +} + +void testPointers() { + void *null = 0; + id boxed_null = @(null); // expected-error {{illegal type 'void *' used in a boxed expression}} + int numbers[] = { 0, 1, 2 }; + id boxed_numbers = @(numbers); // expected-error {{illegal type 'int *' used in a boxed expression}} +} + +void testInvalid() { + @(not_defined); // expected-error {{use of undeclared identifier 'not_defined'}} +} + +enum MyEnum { + ME_foo +}; + +enum ForwE; + +void testEnum(void *p) { + enum MyEnum myen; + id box = @(myen); + box = @(ME_foo); + box = @(*(enum ForwE*)p); // expected-error {{incomplete type 'enum ForwE' used in a boxed expression}} +} diff --git a/test/SemaObjC/category-1.m b/test/SemaObjC/category-1.m index f8422782d78b..a7e69651ade0 100644 --- a/test/SemaObjC/category-1.m +++ b/test/SemaObjC/category-1.m @@ -99,3 +99,12 @@ @class I; // expected-note {{forward declaration}} @implementation I(cat) // expected-error{{cannot find interface declaration}} @end + +// <rdar://problem/11478173> +@interface Unrelated +- foo; +@end + +@interface Blah (Blarg) // expected-error{{cannot find interface declaration for 'Blah'}} +- foo; +@end diff --git a/test/SemaObjC/class-bitfield.m b/test/SemaObjC/class-bitfield.m index ae12e0498eea..4b13d9a25693 100644 --- a/test/SemaObjC/class-bitfield.m +++ b/test/SemaObjC/class-bitfield.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fobjc-fragile-abi -fsyntax-only -verify +// RUN: %clang_cc1 %s -fobjc-runtime=macosx-fragile-10.5 -fsyntax-only -verify @interface X { diff --git a/test/SemaObjC/cocoa-api-usage.m b/test/SemaObjC/cocoa-api-usage.m index 85e21154a9e3..bed7ecde0601 100644 --- a/test/SemaObjC/cocoa-api-usage.m +++ b/test/SemaObjC/cocoa-api-usage.m @@ -1,9 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -fsyntax-only -Wobjc-cocoa-api -verify // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %s -fsyntax-only -Wobjc-cocoa-api -verify -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %s.fixed -fsyntax-only -// RUN: cp %s %t.m -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %t.m -fixit -Wobjc-cocoa-api -// RUN: diff %s.fixed %t.m +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -x objective-c %s.fixed -fsyntax-only // RUN: cp %s %t.m // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %t.m -fixit -Wobjc-cocoa-api // RUN: diff %s.fixed %t.m @@ -82,7 +78,7 @@ typedef signed char BOOL; void foo() { NSString *str = M([NSString stringWithString:@"foo"]); // expected-warning {{redundant}} - str = [[NSString alloc] initWithString:@"foo"]; + str = [[NSString alloc] initWithString:@"foo"]; // expected-warning {{redundant}} NSArray *arr = [NSArray arrayWithArray:@[str]]; // expected-warning {{redundant}} NSDictionary *dict = [NSDictionary dictionaryWithDictionary:@{str: arr}]; // expected-warning {{redundant}} } diff --git a/test/SemaObjC/cocoa-api-usage.m.fixed b/test/SemaObjC/cocoa-api-usage.m.fixed index 55e060a068b1..f472cf1a3043 100644 --- a/test/SemaObjC/cocoa-api-usage.m.fixed +++ b/test/SemaObjC/cocoa-api-usage.m.fixed @@ -1,9 +1,5 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %s -fsyntax-only -Wobjc-cocoa-api -verify // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %s -fsyntax-only -Wobjc-cocoa-api -verify -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -x objective-c %s.fixed -fsyntax-only -// RUN: cp %s %t.m -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 %t.m -fixit -Wobjc-cocoa-api -// RUN: diff %s.fixed %t.m +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc -x objective-c %s.fixed -fsyntax-only // RUN: cp %s %t.m // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-arc %t.m -fixit -Wobjc-cocoa-api // RUN: diff %s.fixed %t.m @@ -82,7 +78,7 @@ typedef signed char BOOL; void foo() { NSString *str = M(@"foo"); // expected-warning {{redundant}} - str = [[NSString alloc] initWithString:@"foo"]; + str = @"foo"; // expected-warning {{redundant}} NSArray *arr = @[str]; // expected-warning {{redundant}} NSDictionary *dict = @{str: arr}; // expected-warning {{redundant}} } diff --git a/test/SemaObjC/conflicting-ivar-test-1.m b/test/SemaObjC/conflicting-ivar-test-1.m index a7c1d353a608..a5c09d83aeec 100644 --- a/test/SemaObjC/conflicting-ivar-test-1.m +++ b/test/SemaObjC/conflicting-ivar-test-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-fragile-abi -fsyntax-only -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -fsyntax-only -verify -Wno-objc-root-class %s @interface INTF { diff --git a/test/SemaObjC/continuation-class-err.m b/test/SemaObjC/continuation-class-err.m index d691f124e8a5..ceb8ee90c9f5 100644 --- a/test/SemaObjC/continuation-class-err.m +++ b/test/SemaObjC/continuation-class-err.m @@ -11,9 +11,9 @@ @end @interface ReadOnly () -@property(readwrite, copy) id object; // expected-warning {{property attribute in continuation class does not match the primary class}} -@property(readonly) id object1; // expected-error {{illegal redeclaration of property in continuation class 'ReadOnly' (attribute must be 'readwrite', while its primary must be 'readonly')}} -@property (readwrite, assign) int indentLevel; // OK. assign the the default in any case. +@property(readwrite, copy) id object; // expected-warning {{property attribute in class extension does not match the primary class}} +@property(readonly) id object1; // expected-error {{illegal redeclaration of property in class extension 'ReadOnly' (attribute must be 'readwrite', while its primary must be 'readonly')}} +@property (readwrite, assign) int indentLevel; // OK. assign the default in any case. @end @protocol Proto @@ -31,8 +31,8 @@ @end @interface Bar () -@property (copy) id foo; // expected-error {{illegal redeclaration of property in continuation class 'Bar' (attribute must be 'readwrite', while its primary must be 'readonly')}} -@property (copy) id fee; // expected-error {{illegal redeclaration of property in continuation class 'Bar' (attribute must be 'readwrite', while its primary must be 'readonly')}} +@property (copy) id foo; // expected-error {{illegal redeclaration of property in class extension 'Bar' (attribute must be 'readwrite', while its primary must be 'readonly')}} +@property (copy) id fee; // expected-error {{illegal redeclaration of property in class extension 'Bar' (attribute must be 'readwrite', while its primary must be 'readonly')}} @end @implementation Bar diff --git a/test/SemaObjC/continuation-class-property.m b/test/SemaObjC/continuation-class-property.m index 7d95424a06c8..2a8e5085fe7f 100644 --- a/test/SemaObjC/continuation-class-property.m +++ b/test/SemaObjC/continuation-class-property.m @@ -38,8 +38,8 @@ typedef struct { @end @interface MyClass () -@property (readwrite) NSString *foo; // expected-error {{type of property 'NSString *' in continuation class does not match property type in primary class}} -@property (readwrite, strong) NSRect bar; // expected-error {{type of property 'NSRect' in continuation class does not match property type in primary class}} +@property (readwrite) NSString *foo; // expected-error {{type of property 'NSString *' in class extension does not match property type in primary class}} +@property (readwrite, strong) NSRect bar; // expected-error {{type of property 'NSRect' in class extension does not match property type in primary class}} @end // rdar://10655530 diff --git a/test/SemaObjC/dealloc.m b/test/SemaObjC/dealloc.m new file mode 100644 index 000000000000..feafafd3753f --- /dev/null +++ b/test/SemaObjC/dealloc.m @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s +// rdar://11987838 + +@protocol NSObject +- dealloc; // expected-error {{return type must be correctly specified as 'void' under ARC, instead of 'id'}} +// CHECK: fix-it:"{{.*}}":{6:3-6:3}:"(void)" +@end + +@protocol Foo <NSObject> @end + +@interface Root <Foo> +@end + +@interface Baz : Root { +} +@end + +@implementation Baz +- (id) dealloc { // expected-error {{return type must be correctly specified as 'void' under ARC, instead of 'id'}} +// CHECK: fix-it:"{{.*}}":{20:5-20:7}:"void" +} + +@end + diff --git a/test/SemaObjC/default-synthesize-1.m b/test/SemaObjC/default-synthesize-1.m index c201e747090b..5aaca9a1c291 100644 --- a/test/SemaObjC/default-synthesize-1.m +++ b/test/SemaObjC/default-synthesize-1.m @@ -1,4 +1,5 @@ -// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -Wobjc-missing-property-synthesis -verify -Wno-objc-root-class %s +// rdar://11295716 @interface NSObject - (void) release; @@ -7,21 +8,21 @@ @class NSString; @interface SynthItAll : NSObject -@property int howMany; -@property (retain) NSString* what; +@property int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} +@property (retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} @end -@implementation SynthItAll +@implementation SynthItAll // expected-note 2 {{detected while default synthesizing properties in class implementation}} //@synthesize howMany, what; @end @interface SynthSetter : NSObject -@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair -@property (nonatomic, retain) NSString* what; +@property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} +@property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} @end -@implementation SynthSetter +@implementation SynthSetter // expected-note 2 {{detected while default synthesizing properties in class implementation}} //@synthesize howMany, what; - (int) howMany { @@ -37,11 +38,11 @@ @interface SynthGetter : NSObject -@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair -@property (nonatomic, retain) NSString* what; +@property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} +@property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} @end -@implementation SynthGetter +@implementation SynthGetter // expected-note 2 {{detected while default synthesizing properties in class implementation}} //@synthesize howMany, what; // - (int) howMany @@ -114,3 +115,12 @@ } @end +@interface rdar11333367 +@property enum A x; // expected-note {{forward declaration of 'enum A'}} expected-note {{property declared here}} +@property struct B y; // expected-note {{forward declaration of 'struct B'}} expected-note {{property declared here}} \ + // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} +@end +@implementation rdar11333367 // expected-error {{cannot synthesize property 'y' with incomplete type 'struct B'}} \ + // expected-note {{detected while default synthesizing properties in class implementation}} +@synthesize x; // expected-error {{cannot synthesize property 'x' with incomplete type 'enum A'}} +@end diff --git a/test/SemaObjC/default-synthesize-2.m b/test/SemaObjC/default-synthesize-2.m index b95f263c32d2..3756413bd83f 100644 --- a/test/SemaObjC/default-synthesize-2.m +++ b/test/SemaObjC/default-synthesize-2.m @@ -41,12 +41,13 @@ // Test3 @interface Test3 { - id uid; + id uid; // expected-note {{ivar is declared here}} } -@property (readwrite, assign) id uid; +@property (readwrite, assign) id uid; // expected-note {{property declared here}} @end -@implementation Test3 +// rdar://11671080 +@implementation Test3 // expected-warning {{autosynthesized property 'uid' will use synthesized instance variable '_uid', not existing instance variable 'uid'}} // Oops, forgot to write @synthesize! will be default synthesized - (void) myMethod { self.uid = 0; // Use of the “setter” @@ -114,3 +115,15 @@ int* _object; } @end +// rdar://11671080 +@interface Test8 +{ + id _y; + id y; // expected-note {{ivar is declared here}} +} +@property(copy) id y; // expected-note {{property declared here}} +@end + + +@implementation Test8 @end // expected-warning {{autosynthesized property 'y' will use instance variable '_y', not existing instance variable 'y'}} + diff --git a/test/SemaObjC/delay-parsing-cfunctions.m b/test/SemaObjC/delay-parsing-cfunctions.m new file mode 100644 index 000000000000..a6f66fe1bd38 --- /dev/null +++ b/test/SemaObjC/delay-parsing-cfunctions.m @@ -0,0 +1,43 @@ +// RUN: %clang_cc1 -fsyntax-only -Werror -verify -Wno-objc-root-class %s +// rdar://10387088 + +@interface MyClass +- (void)someMethod; +@end + +@implementation MyClass +- (void)someMethod { + [self privateMethod]; // clang already does not warn here +} + +int bar(MyClass * myObject) { + [myObject privateMethod]; + return gorfbar(myObject); +} +- (void)privateMethod { } + +int gorfbar(MyClass * myObject) { + [myObject privateMethod]; + [myObject privateMethod1]; + return getMe + bar(myObject); +} + +int KR(myObject) +MyClass * myObject; +{ + [myObject privateMethod]; + [myObject privateMethod1]; + return getMe + bar(myObject); +} + +- (void)privateMethod1 { + getMe = getMe+1; +} + +static int getMe; + +static int test() { + return 0; +} + +@end diff --git a/test/SemaObjC/direct-synthesized-ivar-access.m b/test/SemaObjC/direct-synthesized-ivar-access.m index 54b71109c335..dc1491173aae 100644 --- a/test/SemaObjC/direct-synthesized-ivar-access.m +++ b/test/SemaObjC/direct-synthesized-ivar-access.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -Wnonfragile-abi2 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s // rdar://8673791 // rdar://9943851 diff --git a/test/SemaObjC/duplicate-property-class-extension.m b/test/SemaObjC/duplicate-property-class-extension.m index bf48ed61d863..696768d470bc 100644 --- a/test/SemaObjC/duplicate-property-class-extension.m +++ b/test/SemaObjC/duplicate-property-class-extension.m @@ -9,7 +9,7 @@ @interface Foo () @property (readwrite) char foo; // expected-note 2 {{property declared here}} @property (readwrite) char NewProperty; // expected-note 2 {{property declared here}} -@property (readwrite) char bar; // expected-error{{illegal redeclaration of 'readwrite' property in continuation class 'Foo' (perhaps you intended this to be a 'readwrite' redeclaration of a 'readonly' public property?)}} +@property (readwrite) char bar; // expected-error{{illegal redeclaration of 'readwrite' property in class extension 'Foo' (perhaps you intended this to be a 'readwrite' redeclaration of a 'readonly' public property?)}} @end @interface Foo () diff --git a/test/SemaObjC/error-implicit-property.m b/test/SemaObjC/error-implicit-property.m index ea0587a7449a..7e795c718829 100644 --- a/test/SemaObjC/error-implicit-property.m +++ b/test/SemaObjC/error-implicit-property.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -Wno-objc-root-class -verify %s // rdar://11273060 @interface I diff --git a/test/SemaObjC/format-strings-objc.m b/test/SemaObjC/format-strings-objc.m index 987889bc232f..7faa995002db 100644 --- a/test/SemaObjC/format-strings-objc.m +++ b/test/SemaObjC/format-strings-objc.m @@ -31,6 +31,12 @@ extern void *_NSConstantStringClassReference; typedef const struct __CFString * CFStringRef; extern void CFStringCreateWithFormat(CFStringRef format, ...) __attribute__((format(CFString, 1, 2))); +#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr "")) + +// This function is used instead of the builtin if -fno-constant-cfstrings. +// The definition on Mac OS X is NOT annotated with format_arg as of 10.8, +// but clang will implicitly add the attribute if it's not written. +extern CFStringRef __CFStringMakeConstantString(const char *); int printf(const char * restrict, ...) ; @@ -52,6 +58,7 @@ void rdar_7068334() { long long test = 500; printf("%i ",test); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}} NSLog(@"%i ",test); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}} + CFStringCreateWithFormat(CFSTR("%i"),test); // expected-warning{{format specifies type 'int' but the argument has type 'long long'}} } // <rdar://problem/7697748> @@ -72,7 +79,7 @@ extern void MyCFStringCreateWithFormat(CFStringRef format, ...) __attribute__((f void check_mylog() { MyNSLog(@"%@"); // expected-warning {{more '%' conversions than data arguments}} - // FIXME: find a way to test CFString too, but I don't know how to create constant CFString. + MyCFStringCreateWithFormat(CFSTR("%@")); // expected-warning {{more '%' conversions than data arguments}} } // PR 10275 - format function attribute isn't checked in Objective-C methods @@ -111,11 +118,20 @@ NSString *test_literal_propagation(void) { } // Do not emit warnings when using NSLocalizedString -extern NSString *GetLocalizedString(NSString *str); -#define NSLocalizedString(key) GetLocalizedString(key) +#include "format-strings-system.h" + +// Test it inhibits diag only for macros in system headers +#define MyNSLocalizedString(key) GetLocalizedString(key) +#define MyNSAssert(fmt, arg) NSLog(fmt, arg, 0, 0) void check_NSLocalizedString() { [Foo fooWithFormat:NSLocalizedString(@"format"), @"arg"]; // no-warning + [Foo fooWithFormat:MyNSLocalizedString(@"format"), @"arg"]; // expected-warning {{format string is not a string literal}}} +} + +void check_NSAssert() { + NSAssert(@"Hello %@", @"World"); // no-warning + MyNSAssert(@"Hello %@", @"World"); // expected-warning {{data argument not used by format string}} } typedef __WCHAR_TYPE__ wchar_t; @@ -150,8 +166,12 @@ void test_percent_C() { } // Test that %@ works with toll-free bridging (<rdar://problem/10814120>). -void test_toll_free_bridging(CFStringRef x) { +void test_toll_free_bridging(CFStringRef x, id y) { NSLog(@"%@", x); // no-warning + CFStringCreateWithFormat(CFSTR("%@"), x); // no-warning + + NSLog(@"%@", y); // no-warning + CFStringCreateWithFormat(CFSTR("%@"), y); // no-warning } @interface Bar @@ -186,3 +206,32 @@ int rdar11049844() { printf("%p", x); // no-warning } +void test_nonBuiltinCFStrings() { + CFStringCreateWithFormat(__CFStringMakeConstantString("%@"), 1); // expected-warning{{format specifies type 'id' but the argument has type 'int'}} +} + + +// Don't crash on an invalid argument expression. +// <rdar://problem/11890818> +@interface NSDictionary : NSObject +- (id)objectForKeyedSubscript:(id)key; +@end + +void testInvalidFormatArgument(NSDictionary *dict) { + NSLog(@"no specifiers", dict[CFSTR("abc")]); // expected-error{{indexing expression is invalid because subscript type 'CFStringRef' (aka 'const struct __CFString *') is not an integral or Objective-C pointer type}} + NSLog(@"%@", dict[CFSTR("abc")]); // expected-error{{indexing expression is invalid because subscript type 'CFStringRef' (aka 'const struct __CFString *') is not an integral or Objective-C pointer type}} + NSLog(@"%@ %@", dict[CFSTR("abc")]); // expected-error{{indexing expression is invalid because subscript type 'CFStringRef' (aka 'const struct __CFString *') is not an integral or Objective-C pointer type}} + + [Foo fooWithFormat:@"no specifiers", dict[CFSTR("abc")]]; // expected-error{{indexing expression is invalid because subscript type 'CFStringRef' (aka 'const struct __CFString *') is not an integral or Objective-C pointer type}} + [Foo fooWithFormat:@"%@", dict[CFSTR("abc")]]; // expected-error{{indexing expression is invalid because subscript type 'CFStringRef' (aka 'const struct __CFString *') is not an integral or Objective-C pointer type}} + [Foo fooWithFormat:@"%@ %@", dict[CFSTR("abc")]]; // expected-error{{indexing expression is invalid because subscript type 'CFStringRef' (aka 'const struct __CFString *') is not an integral or Objective-C pointer type}} expected-warning{{more '%' conversions than data arguments}} +} + + +// <rdar://problem/11825593> +void testByValueObjectInFormat(Foo *obj) { + printf("%d %d %d", 1L, *obj, 1L); // expected-error {{cannot pass object with interface type 'Foo' by value to variadic function; expected type from format string was 'int'}} expected-warning 2 {{format specifies type 'int' but the argument has type 'long'}} + + [Bar log2:@"%d", *obj]; // expected-error {{cannot pass object with interface type 'Foo' by value to variadic method; expected type from format string was 'int'}} +} + diff --git a/test/SemaObjC/format-strings-system.h b/test/SemaObjC/format-strings-system.h new file mode 100644 index 000000000000..73b776845cbb --- /dev/null +++ b/test/SemaObjC/format-strings-system.h @@ -0,0 +1,10 @@ + +#pragma clang system_header + +@class NSString; + +// Do not emit warnings when using NSLocalizedString +extern NSString *GetLocalizedString(NSString *str); +#define NSLocalizedString(key) GetLocalizedString(key) + +#define NSAssert(fmt, arg) NSLog(fmt, arg, 0, 0) diff --git a/test/SemaObjC/getter-setter-defined-in-category-of-parent.m b/test/SemaObjC/getter-setter-defined-in-category-of-parent.m new file mode 100644 index 000000000000..71c3237425bd --- /dev/null +++ b/test/SemaObjC/getter-setter-defined-in-category-of-parent.m @@ -0,0 +1,26 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s + +@interface MyParent { + int X; +} +@end +@implementation MyParent +@end + +@interface MyParent(AA) { +} +@end +@implementation MyParent (AA) +- (void) setX: (int)in {X = in - 2;} +- (int) X {return X;} +@end + +@interface MyClass : MyParent +@end +@implementation MyClass +@end + +int foo(MyClass *o) { + o.X = 2; + return o.X; +}
\ No newline at end of file diff --git a/test/SemaObjC/iboutlet.m b/test/SemaObjC/iboutlet.m new file mode 100644 index 000000000000..a29915c393a1 --- /dev/null +++ b/test/SemaObjC/iboutlet.m @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -Wno-objc-root-class -verify %s +// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -fobjc-default-synthesize-properties -Wno-objc-root-class -verify %s +// rdar://11448209 + +#define READONLY readonly + +@class NSView; + +#define IBOutlet __attribute__((iboutlet)) + +@interface I +@property (getter = MyGetter, readonly, assign) IBOutlet NSView *myView; // expected-note {{property declared here}} \ + // expected-note {{readonly IBOutlet property should be changed to be readwrite}} + +@property (readonly) IBOutlet NSView *myView1; // expected-note {{readonly IBOutlet property should be changed to be readwrite}} \ + // expected-note {{property declared here}} + +@property (getter = MyGetter, READONLY) IBOutlet NSView *myView2; // expected-note {{property declared here}} + +@end + +@implementation I // expected-warning 3 {{readonly IBOutlet property when auto-synthesized may not work correctly with 'nib' loader}} +@end diff --git a/test/SemaObjC/id.m b/test/SemaObjC/id.m index 27b84dedf8e6..ced406ebd29b 100644 --- a/test/SemaObjC/id.m +++ b/test/SemaObjC/id.m @@ -16,6 +16,16 @@ void foo() { } // Test attempt to redefine 'id' in an incompatible fashion. -typedef int id; // FIXME: Decide how we want to deal with this (now that 'id' is more of a built-in type). +// rdar://11356439 +typedef int id; // expected-error {{typedef redefinition with different types ('int' vs 'id')}} id b; +typedef double id; // expected-error {{typedef redefinition with different types ('double' vs 'id')}} + +typedef char *id; // expected-error {{typedef redefinition with different types ('char *' vs 'id')}} + +typedef union U{ int iu; } *id; // expected-error {{typedef redefinition with different types ('union U *' vs 'id')}} + +void test11356439(id o) { + o->x; // expected-error {{member reference base type 'id' is not a structure or union}} +} diff --git a/test/SemaObjC/interface-1.m b/test/SemaObjC/interface-1.m index 87c230742e35..79fbad8ba4bf 100644 --- a/test/SemaObjC/interface-1.m +++ b/test/SemaObjC/interface-1.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi %s -fsyntax-only -verify +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 %s -fsyntax-only -verify // rdar://5957506 @interface NSWhatever : diff --git a/test/SemaObjC/interface-layout.m b/test/SemaObjC/interface-layout.m index a8a93f0a6eb3..336605a7812e 100644 --- a/test/SemaObjC/interface-layout.m +++ b/test/SemaObjC/interface-layout.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -triple i386-apple-darwin9 -fobjc-fragile-abi +// RUN: %clang_cc1 %s -fsyntax-only -verify -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 typedef struct objc_object {} *id; typedef signed char BOOL; typedef unsigned int NSUInteger; diff --git a/test/SemaObjC/ivar-in-class-extension-error.m b/test/SemaObjC/ivar-in-class-extension-error.m index cecaa33bcfcc..b22b7984cc2d 100644 --- a/test/SemaObjC/ivar-in-class-extension-error.m +++ b/test/SemaObjC/ivar-in-class-extension-error.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fobjc-fragile-abi -fsyntax-only -verify %s +// RUN: %clang_cc1 -fobjc-runtime=macosx-fragile-10.5 -fsyntax-only -verify %s // rdar://6812436 @interface A @end diff --git a/test/SemaObjC/method-bad-param.m b/test/SemaObjC/method-bad-param.m index 9505cb44a346..d44b53614aa4 100644 --- a/test/SemaObjC/method-bad-param.m +++ b/test/SemaObjC/method-bad-param.m @@ -26,7 +26,7 @@ foo somefunc2() {} // expected-error {{interface type 'foo' cannot be returned b // rdar://6780761 void f0(foo *a0) { extern void g0(int x, ...); - g0(1, *(foo*)a0); // expected-error {{cannot pass object with interface type 'foo' by-value through variadic function}} + g0(1, *(foo*)a0); // expected-error {{cannot pass object with interface type 'foo' by value through variadic function}} } // rdar://8421082 diff --git a/test/SemaObjC/method-prototype-scope.m b/test/SemaObjC/method-prototype-scope.m index 0bebd9b029d7..c581500d02c8 100644 --- a/test/SemaObjC/method-prototype-scope.m +++ b/test/SemaObjC/method-prototype-scope.m @@ -7,7 +7,7 @@ int object; @class NSString, NSArray; @interface Test -- Func:(int)XXXX, id object; +- Func:(int)XXXX, id object; // expected-warning {{use of C-style parameters in Objective-C method declarations is deprecated}} - doSomethingElseWith:(id)object; @@ -23,7 +23,7 @@ int object; return object; // expected-warning {{incompatible pointer types returning 'NSArray *' from a function with result type 'NSString *'}} } -- Func:(int)XXXX, id object { return object; } +- Func:(int)XXXX, id object { return object; } // expected-warning {{use of C-style parameters in Objective-C method declarations is deprecated}} - doSomethingElseWith:(id)object { return object; } diff --git a/test/SemaObjC/mismatched-undefined-method.m b/test/SemaObjC/mismatched-undefined-method.m new file mode 100644 index 000000000000..c41d142a4085 --- /dev/null +++ b/test/SemaObjC/mismatched-undefined-method.m @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-declarations -verify %s +// rdar://11460990 + +typedef unsigned int CGDirectDisplayID; + +@interface NSObject @end + +@interface BrightnessAssistant : NSObject {} +- (void)BrightnessAssistantUnregisterForNotifications:(void*) observer; // expected-note {{previous definition is here}} +@end +@implementation BrightnessAssistant // expected-note {{implementation started here}} +- (void)BrightnessAssistantUnregisterForNotifications:(CGDirectDisplayID) displayID, void* observer // expected-warning {{conflicting parameter types in implementation of 'BrightnessAssistantUnregisterForNotifications:': 'void *' vs 'CGDirectDisplayID'}} +@end // expected-error {{expected method body}} // expected-error {{missing '@end'}} diff --git a/test/SemaObjC/narrow-property-type-in-cont-class.m b/test/SemaObjC/narrow-property-type-in-cont-class.m index 3ba848f03ad0..0f73b1e8f02f 100644 --- a/test/SemaObjC/narrow-property-type-in-cont-class.m +++ b/test/SemaObjC/narrow-property-type-in-cont-class.m @@ -14,6 +14,6 @@ @interface GKTurnBasedMatchMakerKVO () @property(nonatomic,readwrite,retain) NSMutableArray* outline; -@property(nonatomic,readwrite,retain) NSArray* err_outline; // expected-error {{type of property 'NSArray *' in continuation class does not match property type in primary class}} +@property(nonatomic,readwrite,retain) NSArray* err_outline; // expected-error {{type of property 'NSArray *' in class extension does not match property type in primary class}} @end diff --git a/test/SemaObjC/no-ivar-in-interface-block.m b/test/SemaObjC/no-ivar-in-interface-block.m new file mode 100644 index 000000000000..215db6150e53 --- /dev/null +++ b/test/SemaObjC/no-ivar-in-interface-block.m @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -Wobjc-interface-ivars %s +// rdar://10763173 + +@interface I +{ + @protected int P_IVAR; // expected-warning {{declaration of ivars in the interface is deprecated}} + + @public int PU_IVAR; // expected-warning {{declaration of ivars in the interface is deprecated}} + + @private int PRV_IVAR; // expected-warning {{declaration of ivars in the interface is deprecated}} +} +@end + +@interface I() +{ + int I1; + int I2; +} +@end + +@interface I() +{ + int I3, I4; +} +@end + +@implementation I +{ + int I5; + int I6; +} +@end diff --git a/test/SemaObjC/nowarn-superclass-method-mismatch.m b/test/SemaObjC/nowarn-superclass-method-mismatch.m new file mode 100644 index 000000000000..b211cdea37b0 --- /dev/null +++ b/test/SemaObjC/nowarn-superclass-method-mismatch.m @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -Wsuper-class-method-mismatch -verify %s +// rdar://11793793 + +@class NSString; + +@interface Super +@property (nonatomic) NSString *thingy; +@property () __weak id PROP; +@end + +@interface Sub : Super +@end + +@implementation Sub +- (void)setThingy:(NSString *)val +{ + [super setThingy:val]; +} +@synthesize PROP; +@end diff --git a/test/SemaObjC/nsobject-attribute.m b/test/SemaObjC/nsobject-attribute.m index f41df8932887..e3f28740dc8f 100644 --- a/test/SemaObjC/nsobject-attribute.m +++ b/test/SemaObjC/nsobject-attribute.m @@ -46,9 +46,19 @@ int main(int argc, char *argv[]) { __attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}} } // <rdar://problem/10930507> -@property (nonatomic, retain) __attribute__((NSObject)) void * color; // // no-warning +@property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color; // // no-warning @end void test_10453342() { char* __attribute__((NSObject)) string2 = 0; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}} } +// rdar://11569860 +@interface A { int i; } +@property(retain) __attribute__((NSObject)) int i; // expected-error {{__attribute ((NSObject)) is for pointer types only}} \ + // expected-error {{property with 'retain (or strong)' attribute must be of object type}} +@end + +@implementation A +@synthesize i; +@end + diff --git a/test/SemaObjC/objc-container-subscripting-2.m b/test/SemaObjC/objc-container-subscripting-2.m index 3c0081b72a76..62320fcebb77 100644 --- a/test/SemaObjC/objc-container-subscripting-2.m +++ b/test/SemaObjC/objc-container-subscripting-2.m @@ -16,8 +16,8 @@ typedef unsigned int size_t; id func() { NSMutableArray *array; float f; - array[f] = array; // expected-error {{indexing expression is invalid because subscript type 'float' is not an integral or objective-C pointer type}} - return array[3.14]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or objective-C pointer type}} + array[f] = array; // expected-error {{indexing expression is invalid because subscript type 'float' is not an integral or Objective-C pointer type}} + return array[3.14]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or Objective-C pointer type}} } void test_unused() { diff --git a/test/SemaObjC/objc-container-subscripting-3.m b/test/SemaObjC/objc-container-subscripting-3.m index 5fd1a10915f7..2f716d6f7911 100644 --- a/test/SemaObjC/objc-container-subscripting-3.m +++ b/test/SemaObjC/objc-container-subscripting-3.m @@ -14,7 +14,7 @@ int main() { Test *array; int i = array[10]; // expected-error {{method for accessing array element must have Objective-C object return type instead of 'int'}} - array[2] = i; // expected-error {{cannot assign to this array because assigning method's 2nd parameter of type 'int' is not an objective-C pointer type}} + array[2] = i; // expected-error {{cannot assign to this array because assigning method's 2nd parameter of type 'int' is not an Objective-C pointer type}} NSMutableDictionary *dict; id key, val; diff --git a/test/SemaObjC/objc-container-subscripting.m b/test/SemaObjC/objc-container-subscripting.m index 4125bc634a7f..3bbd7d404bb5 100644 --- a/test/SemaObjC/objc-container-subscripting.m +++ b/test/SemaObjC/objc-container-subscripting.m @@ -14,15 +14,15 @@ int main() { NSMutableArray<P> * array; id oldObject = array[10]; // expected-error {{method index parameter type 'double' is not integral type}} array[3] = 0; // expected-error {{method index parameter type 'void *' is not integral type}} \ - // expected-error {{cannot assign to this array because assigning method's 2nd parameter of type 'id *' is not an objective-C pointer type}} + // expected-error {{cannot assign to this array because assigning method's 2nd parameter of type 'id *' is not an Objective-C pointer type}} I* iarray; iarray[3] = 0; // expected-error {{expected method to write array element not found on object of type 'I *'}} I* p = iarray[4]; // expected-error {{expected method to read array element not found on object of type 'I *'}} - oldObject = array[10]++; // expected-error {{illegal operation on objective-c container subscripting}} - oldObject = array[10]--; // expected-error {{illegal operation on objective-c container subscripting}} - oldObject = --array[10]; // expected-error {{illegal operation on objective-c container subscripting}} + oldObject = array[10]++; // expected-error {{illegal operation on Objective-C container subscripting}} + oldObject = array[10]--; // expected-error {{illegal operation on Objective-C container subscripting}} + oldObject = --array[10]; // expected-error {{illegal operation on Objective-C container subscripting}} } @interface NSMutableDictionary diff --git a/test/SemaObjC/objc-cstyle-args-in-methods.m b/test/SemaObjC/objc-cstyle-args-in-methods.m index d37b5897b114..ebc7192f0f5a 100644 --- a/test/SemaObjC/objc-cstyle-args-in-methods.m +++ b/test/SemaObjC/objc-cstyle-args-in-methods.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-declarations -verify -Wno-objc-root-class %s @interface Foo - (id)test:(id)one, id two; diff --git a/test/SemaObjC/objc-dictionary-literal.m b/test/SemaObjC/objc-dictionary-literal.m index 2acbc39e3885..0b6da4a77ba4 100644 --- a/test/SemaObjC/objc-dictionary-literal.m +++ b/test/SemaObjC/objc-dictionary-literal.m @@ -27,7 +27,7 @@ int main() { NSDictionary *dict = @{ @"name":@666 }; dict[@"name"] = @666; - dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an objective-C pointer}} + dict["name"] = @666; // expected-error {{indexing expression is invalid because subscript type 'char *' is not an Objective-C pointer}} return 0; } diff --git a/test/SemaObjC/objc-literal-comparison.m b/test/SemaObjC/objc-literal-comparison.m new file mode 100644 index 000000000000..f1aa8ecd91e2 --- /dev/null +++ b/test/SemaObjC/objc-literal-comparison.m @@ -0,0 +1,96 @@ +// RUN: %clang_cc1 -fsyntax-only -Wno-everything -Wobjc-literal-compare "-Dnil=((id)0)" -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-everything -Wobjc-literal-compare "-Dnil=(id)0" -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-everything -Wobjc-literal-compare "-Dnil=0" -verify %s + +// (test the warning flag as well) + +typedef signed char BOOL; + +@interface BaseObject ++ (instancetype)new; +@end + +@interface NSObject : BaseObject +- (BOOL)isEqual:(id)other; +@end + +@interface NSNumber : NSObject ++ (NSNumber *)numberWithInt:(int)value; ++ (NSNumber *)numberWithDouble:(double)value; ++ (NSNumber *)numberWithBool:(BOOL)value; +@end + +@interface NSArray : NSObject ++ (id)arrayWithObjects:(const id [])objects count:(unsigned long)cnt; +@end + +@interface NSDictionary : NSObject ++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt; +@end + +@interface NSString : NSObject +@end + +void testComparisonsWithFixits(id obj) { + if (obj == @"") return; // expected-warning{{direct comparison of a string literal has undefined behavior}} expected-note{{use 'isEqual:' instead}} + if (obj != @"") return; // expected-warning{{direct comparison of a string literal has undefined behavior}} expected-note{{use 'isEqual:' instead}} + if (@"" == obj) return; // expected-warning{{direct comparison of a string literal has undefined behavior}} expected-note{{use 'isEqual:' instead}} + if (@"" == @"") return; // expected-warning{{direct comparison of a string literal has undefined behavior}} expected-note{{use 'isEqual:' instead}} + + if (@[] == obj) return; // expected-warning{{direct comparison of an array literal has undefined behavior}} expected-note{{use 'isEqual:' instead}} + if (@{} == obj) return; // expected-warning{{direct comparison of a dictionary literal has undefined behavior}} expected-note{{use 'isEqual:' instead}} + if (@12 == obj) return; // expected-warning{{direct comparison of a numeric literal has undefined behavior}} expected-note{{use 'isEqual:' instead}} + if (@1.0 == obj) return; // expected-warning{{direct comparison of a numeric literal has undefined behavior}} expected-note{{use 'isEqual:' instead}} + if (@__objc_yes == obj) return; // expected-warning{{direct comparison of a numeric literal has undefined behavior}} expected-note{{use 'isEqual:' instead}} + if (@(1+1) == obj) return; // expected-warning{{direct comparison of a boxed expression has undefined behavior}} expected-note{{use 'isEqual:' instead}} +} + + +@interface BadEqualReturnString : NSString +- (void)isEqual:(id)other; +@end + +@interface BadEqualArgString : NSString +- (BOOL)isEqual:(int)other; +@end + + +void testComparisonsWithoutFixits() { + if ([BaseObject new] == @"") return; // expected-warning{{direct comparison of a string literal has undefined behavior}} + + if ([BadEqualReturnString new] == @"") return; // expected-warning{{direct comparison of a string literal has undefined behavior}} + if ([BadEqualArgString new] == @"") return; // expected-warning{{direct comparison of a string literal has undefined behavior}} + + if (@"" < @"") return; // expected-warning{{direct comparison of a string literal has undefined behavior}} + if (@"" > @"") return; // expected-warning{{direct comparison of a string literal has undefined behavior}} + if (@"" <= @"") return; // expected-warning{{direct comparison of a string literal has undefined behavior}} + if (@"" >= @"") return; // expected-warning{{direct comparison of a string literal has undefined behavior}} +} + + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wobjc-string-compare" + +void testWarningFlags(id obj) { + if (obj == @"") return; // no-warning + if (@"" == obj) return; // no-warning + + if (obj == @1) return; // expected-warning{{direct comparison of a numeric literal has undefined behavior}} expected-note{{use 'isEqual:' instead}} + if (@1 == obj) return; // expected-warning{{direct comparison of a numeric literal has undefined behavior}} expected-note{{use 'isEqual:' instead}} +} + +#pragma clang diagnostic pop + + +void testNilComparison() { + // Don't warn when comparing to nil in a macro. +#define RETURN_IF_NIL(x) if (x == nil || nil == x) return + RETURN_IF_NIL(@""); + RETURN_IF_NIL(@1); + RETURN_IF_NIL(@1.0); + RETURN_IF_NIL(@[]); + RETURN_IF_NIL(@{}); + RETURN_IF_NIL(@__objc_yes); + RETURN_IF_NIL(@(1+1)); +} + diff --git a/test/SemaObjC/objc-literal-nsnumber.m b/test/SemaObjC/objc-literal-nsnumber.m index 6635bea72e7f..26bca189d1f6 100644 --- a/test/SemaObjC/objc-literal-nsnumber.m +++ b/test/SemaObjC/objc-literal-nsnumber.m @@ -83,3 +83,7 @@ typedef float BOOL; BOOL radar11231426() { return __objc_yes; } + +id stringBoxingNoSuchMethod(const char *str) { + return @(str); // expected-error {{declaration of 'stringWithUTF8String:' is missing in NSString class}} +} diff --git a/test/SemaObjC/objc-literal-sig.m b/test/SemaObjC/objc-literal-sig.m index fb5c79fd8437..86f42d3abcab 100644 --- a/test/SemaObjC/objc-literal-sig.m +++ b/test/SemaObjC/objc-literal-sig.m @@ -16,25 +16,36 @@ typedef _Bool BOOL; + (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; + (NSNumber *)numberWithFloat:(float)value; + (NSNumber *)numberWithDouble:(double)value; -+ (int)numberWithBool:(BOOL)value; // expected-note{{method returns unexpected type 'int' (should be an object type)}} ++ (int)numberWithBool:(BOOL)value; // expected-note 2 {{method returns unexpected type 'int' (should be an object type)}} +@end + +@interface NSString ++ (char)stringWithUTF8String:(const char *)value; // expected-note 2 {{method returns unexpected type 'char' (should be an object type)}} @end @interface NSArray @end @interface NSArray (NSArrayCreation) -+ (id)arrayWithObjects:(const int [])objects // expected-note{{first parameter has unexpected type 'const int *' (should be 'const id *')}} ++ (id)arrayWithObjects:(const int [])objects // expected-note 2 {{first parameter has unexpected type 'const int *' (should be 'const id *')}} count:(unsigned long)cnt; @end @interface NSDictionary + (id)dictionaryWithObjects:(const id [])objects - forKeys:(const int [])keys // expected-note{{second parameter has unexpected type 'const int *' (should be 'const id *')}} + forKeys:(const int [])keys // expected-note 2 {{second parameter has unexpected type 'const int *' (should be 'const id *')}} count:(unsigned long)cnt; @end +// All tests are doubled to make sure that a bad method is not saved +// and then used un-checked. void test_sig() { (void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}} + (void)@__objc_yes; // expected-error{{literal construction method 'numberWithBool:' has incompatible signature}} id array = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}} + id array2 = @[ @17 ]; // expected-error{{literal construction method 'arrayWithObjects:count:' has incompatible signature}} id dict = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}} + id dict2 = @{ @"hello" : @17 }; // expected-error{{literal construction method 'dictionaryWithObjects:forKeys:count:' has incompatible signature}} + id str = @("hello"); // expected-error{{literal construction method 'stringWithUTF8String:' has incompatible signature}} + id str2 = @("hello"); // expected-error{{literal construction method 'stringWithUTF8String:' has incompatible signature}} } diff --git a/test/SemaObjC/property-10.m b/test/SemaObjC/property-10.m index 51eb39c9e7cd..8cb8ec63a916 100644 --- a/test/SemaObjC/property-10.m +++ b/test/SemaObjC/property-10.m @@ -24,7 +24,7 @@ @property(unsafe_unretained, copy, retain) id p4_3; // expected-error {{property attributes 'unsafe_unretained' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'unsafe_unretained' and 'retain' are mutually exclusive}} @property(unsafe_unretained, copy, strong) id s4_3; // expected-error {{property attributes 'unsafe_unretained' and 'copy' are mutually exclusive}}, expected-error {{property attributes 'unsafe_unretained' and 'strong' are mutually exclusive}} -@property id p4; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-gc object}} +@property id p4; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-GC object}} @property(nonatomic,copy) int (^includeMailboxCondition)(); @property(nonatomic,copy) int (*includeMailboxCondition2)(); // expected-error {{property with 'copy' attribute must be of object type}} diff --git a/test/SemaObjC/property-12.m b/test/SemaObjC/property-12.m index cd0fccf0e383..c4a755555629 100644 --- a/test/SemaObjC/property-12.m +++ b/test/SemaObjC/property-12.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -Wreadonly-setter-attrs -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-objc-root-class -Wreadonly-setter-attrs -verify %s @protocol P0 @property(readonly,assign) id X; // expected-warning {{property attributes 'readonly' and 'assign' are mutually exclusive}} @@ -29,4 +29,39 @@ @end +// rdar://11656982 +@interface I0 <P0> @end +@implementation I0 +@synthesize X; +@end + +@interface I1 <P1> @end +@implementation I1 +@synthesize X; +@end + +@interface I2 <P2> @end +@implementation I2 +@synthesize X; +@end + +@interface I3 <P3> @end +@implementation I3 +@synthesize X; +@end + +@interface I4 <P4> @end +@implementation I4 +@synthesize X; +@end + +@interface I5 <P5> @end +@implementation I5 +@synthesize X; +@end + +@interface I6 <P6> @end +@implementation I6 +@synthesize X; +@end diff --git a/test/SemaObjC/property-impl-misuse.m b/test/SemaObjC/property-impl-misuse.m index c3cedb05ed61..939909e9b279 100644 --- a/test/SemaObjC/property-impl-misuse.m +++ b/test/SemaObjC/property-impl-misuse.m @@ -30,7 +30,20 @@ @synthesize gradientStyle = _gradientStyle; - (void)setGradientStyle:(id)value { } -+ (void)_componentCellWithRepresentedObject { - self.gradientStyle; // expected-error {{property 'gradientStyle' not found on object of type 'Class'}} ++ (id)_componentCellWithRepresentedObject { + return self.gradientStyle; } @end + +// rdar://11054153 +@interface rdar11054153 +@property int P; // expected-error {{type of property 'P' ('int') does not match type of accessor 'P' ('void')}} +- (void)P; // expected-note {{declared here}} + +@property int P1; // expected-warning {{type of property 'P1' does not match type of accessor 'P1'}} +- (double) P1; // expected-note {{declared here}} + +@property int P2; // expected-error {{type of property 'P2' ('int') does not match type of accessor 'P2' ('double *')}} +- (double*)P2; // expected-note {{declared here}} + +@end diff --git a/test/SemaObjC/property-ivar-mismatch.m b/test/SemaObjC/property-ivar-mismatch.m index 6abd6e662d72..a0d1c9da7b80 100644 --- a/test/SemaObjC/property-ivar-mismatch.m +++ b/test/SemaObjC/property-ivar-mismatch.m @@ -12,3 +12,15 @@ @synthesize prop = ivar; // expected-error {{type of property 'prop' ('int') does not match type of ivar 'ivar' ('char')}} @end + +@interface Test5 +{ + void * _P; // expected-note {{ivar is declared here}} +} +@property int P; +@end + +@implementation Test5 +@synthesize P=_P; // expected-error {{ype of property 'P' ('int') does not match type of ivar '_P' ('void *')}} +@end + diff --git a/test/SemaObjC/property-typecheck-1.m b/test/SemaObjC/property-typecheck-1.m index f71e4a0f1c7f..58d0f215cd92 100644 --- a/test/SemaObjC/property-typecheck-1.m +++ b/test/SemaObjC/property-typecheck-1.m @@ -73,10 +73,10 @@ typedef void (F)(void); NSArray* first; } -@property (readonly) NSArray* pieces; // expected-warning {{type of property 'pieces' does not match type of accessor 'pieces'}} -@property (readonly) NSMutableArray* first; +@property (readonly) NSArray* pieces; // expected-warning {{type of property 'pieces' does not match type of accessor 'pieces'}} +@property (readonly) NSMutableArray* first; -- (NSMutableArray*) pieces; // expected-note {{declared here}} // expected-note {{declared here}} +- (NSMutableArray*) pieces; // expected-note 2 {{declared here}} - (NSArray*) first; @end @@ -95,7 +95,7 @@ typedef void (F)(void); - (id)firstPeice { - return container.first; + return container.first; } @end diff --git a/test/SemaObjC/property-user-setter.m b/test/SemaObjC/property-user-setter.m index 7d4e544f0332..9ebad6048df8 100644 --- a/test/SemaObjC/property-user-setter.m +++ b/test/SemaObjC/property-user-setter.m @@ -102,3 +102,55 @@ int main (void) { abort (); return 0; } + +// rdar://11363363 +@interface rdar11363363 +{ + id R; +} +@property (copy) id p; +@property (copy) id r; +@property (copy) id Q; +@property (copy) id t; // expected-note 2 {{property declared here}} +@property (copy) id T; // expected-note 2 {{property declared here}} +@property (copy) id Pxyz; // expected-note 2 {{property declared here}} +@property (copy) id pxyz; // expected-note 2 {{property declared here}} +@end + +@implementation rdar11363363 +@synthesize p; +@synthesize r; +@synthesize Q; +@synthesize t, T; +@synthesize Pxyz, pxyz; +- (id) Meth { + self.P = 0; + self.q = 0; +// rdar://11528439 + self.t = 0; // expected-error {{synthesized properties 't' and 'T' both claim setter 'setT:'}} + self.T = 0; // expected-error {{synthesized properties 'T' and 't' both claim setter 'setT:'}} + self.Pxyz = 0; // expected-error {{synthesized properties 'Pxyz' and 'pxyz' both claim setter 'setPxyz:'}} + self.pxyz = 0; // expected-error {{synthesized properties 'pxyz' and 'Pxyz' both claim setter 'setPxyz:'}} + self.R = 0; + return self.R; // expected-error {{expected getter method not found on object of type 'rdar11363363 *'}} +} +@end + +// rdar://11499742 +@class BridgeFormatter; + +@interface FMXBridgeFormatter + +@property(assign, readwrite, getter=formatter, setter=setFormatter:) BridgeFormatter* cppFormatter; + +@end + +@implementation FMXBridgeFormatter +@synthesize cppFormatter; + +- (void) dealloc +{ + self.formatter = 0; +} +@end + diff --git a/test/SemaObjC/property.m b/test/SemaObjC/property.m index a9487412c19d..d6495b42308d 100644 --- a/test/SemaObjC/property.m +++ b/test/SemaObjC/property.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-fragile-abi -fsyntax-only -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-runtime=macosx-fragile-10.5 -fsyntax-only -verify -Wno-objc-root-class %s @interface I { @@ -6,7 +6,7 @@ int name; } @property int d1; -@property id prop_id; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-gc object}} +@property id prop_id; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}}, expected-warning {{default property attribute 'assign' not appropriate for non-GC object}} @property int name; @end diff --git a/test/SemaObjC/protocol-attribute.m b/test/SemaObjC/protocol-attribute.m index 178774c6640f..b2aecc209f1b 100644 --- a/test/SemaObjC/protocol-attribute.m +++ b/test/SemaObjC/protocol-attribute.m @@ -6,7 +6,7 @@ __attribute ((unavailable)) Class <FwProto> cFw = 0; // expected-error {{'FwProto' is unavailable}} -__attribute ((deprecated)) @protocol MyProto1 +__attribute ((deprecated)) @protocol MyProto1 // expected-note 7 {{declared here}} @end @protocol Proto2 <MyProto1> // expected-warning {{'MyProto1' is deprecated}} diff --git a/test/SemaObjC/protocols.m b/test/SemaObjC/protocols.m index ca38f20fbd01..eb2734100769 100644 --- a/test/SemaObjC/protocols.m +++ b/test/SemaObjC/protocols.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-declarations -verify %s @interface INTF1 @required // expected-error {{directive may only be specified in protocols only}} diff --git a/test/SemaObjC/provisional-ivar-lookup.m b/test/SemaObjC/provisional-ivar-lookup.m index 2ec23a55c37c..7460fc2e2067 100644 --- a/test/SemaObjC/provisional-ivar-lookup.m +++ b/test/SemaObjC/provisional-ivar-lookup.m @@ -36,7 +36,7 @@ @synthesize PROP=PROP; - (void)setPROP:(int)value { - PROP = PROP; // OK + PROP = value; // OK } @end diff --git a/test/SemaObjC/related-result-type-inference.m b/test/SemaObjC/related-result-type-inference.m index 124767cd6654..b1d77dc17277 100644 --- a/test/SemaObjC/related-result-type-inference.m +++ b/test/SemaObjC/related-result-type-inference.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -verify -Wno-deprecated-declarations -Wno-objc-root-class %s @interface Unrelated @end @@ -178,3 +178,9 @@ void test_inference() { return (id)self; // expected-warning {{returning 'Fail *' from a function with incompatible result type 'id<X>'}} } @end + +// <rdar://problem/11460990> + +@interface WeirdNSString : NSString +- (id)initWithCString:(const char*)string, void *blah; +@end diff --git a/test/SemaObjC/sizeof-interface.m b/test/SemaObjC/sizeof-interface.m index 7304b6c2c8a6..db765b79b4d8 100644 --- a/test/SemaObjC/sizeof-interface.m +++ b/test/SemaObjC/sizeof-interface.m @@ -23,7 +23,7 @@ void *g3(I0 *P) { @end // size == 4 -int g1[ sizeof(I0) // expected-error {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}} +int g1[ sizeof(I0) // expected-error {{application of 'sizeof' to interface 'I0' is not supported on this architecture and platform}} == 4 ? 1 : -1]; @implementation I0 @@ -32,7 +32,7 @@ int g1[ sizeof(I0) // expected-error {{invalid application of 'sizeof' to in // size == 4 (we do not include extended properties in the // sizeof). -int g2[ sizeof(I0) // expected-error {{invalid application of 'sizeof' to interface 'I0' in non-fragile ABI}} +int g2[ sizeof(I0) // expected-error {{application of 'sizeof' to interface 'I0' is not supported on this architecture and platform}} == 4 ? 1 : -1]; @interface I1 @@ -43,7 +43,7 @@ int g2[ sizeof(I0) // expected-error {{invalid application of 'sizeof' to inte @synthesize p0 = _p0; @end -typedef struct { @defs(I1); } I1_defs; // expected-error {{invalid application of @defs in non-fragile ABI}} +typedef struct { @defs(I1); } I1_defs; // expected-error {{use of @defs is not supported on this architecture and platform}} // FIXME: This is currently broken due to the way the record layout we // create is tied to whether we have seen synthesized properties. Ugh. @@ -51,9 +51,9 @@ typedef struct { @defs(I1); } I1_defs; // expected-error {{invalid application o // rdar://6821047 int bar(I0 *P) { - P = P+5; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size in non-fragile ABI}} - P = 5+P; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size in non-fragile ABI}} - P = P-5; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size in non-fragile ABI}} + P = P+5; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size for this architecture and platform}} + P = 5+P; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size for this architecture and platform}} + P = P-5; // expected-error {{arithmetic on pointer to interface 'I0', which is not a constant size for this architecture and platform}} return P[4].x[2]; // expected-error {{expected method to read array element not found on object of type 'I0 *'}} } @@ -64,7 +64,7 @@ int bar(I0 *P) { @interface XCAttributeRunDirectNode { @public - unsigned long attributeRuns[1024 + sizeof(I)]; // expected-error {{invalid application of 'sizeof' to interface 'I' in non-fragile ABI}} + unsigned long attributeRuns[1024 + sizeof(I)]; // expected-error {{application of 'sizeof' to interface 'I' is not supported on this architecture and platform}} int i; } @end @@ -85,6 +85,6 @@ int foo() Foo *f; // Both of these crash clang nicely - ++f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size in non-fragile ABI}} - --f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size in non-fragile ABI}} + ++f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size for this architecture and platform}} + --f; // expected-error {{arithmetic on pointer to interface 'Foo', which is not a constant size for this architecture and platform}} } diff --git a/test/SemaObjC/special-dep-unavail-warning.m b/test/SemaObjC/special-dep-unavail-warning.m index 754bf5f4cb63..a179647ebccd 100644 --- a/test/SemaObjC/special-dep-unavail-warning.m +++ b/test/SemaObjC/special-dep-unavail-warning.m @@ -45,7 +45,7 @@ void test(C *c) { // rdar://10268422 __attribute ((deprecated)) -@interface DEPRECATED +@interface DEPRECATED // expected-note {{declared here}} +(id)new; @end diff --git a/test/SemaObjC/tentative-property-decl.m b/test/SemaObjC/tentative-property-decl.m new file mode 100644 index 000000000000..f69ac6dace43 --- /dev/null +++ b/test/SemaObjC/tentative-property-decl.m @@ -0,0 +1,47 @@ +// RUN: %clang_cc1 -fsyntax-only -Weverything -verify %s +// rdar://11656982 +/** Normally, a property cannot be both 'readonly' and having a "write" attribute + (copy/retain/etc.). But, property declaration in primary class and protcols + are tentative as they may be overridden into a 'readwrite' property in class + extensions. Postpone diagnosing such warnings until the class implementation + is seen. +*/ + +@interface Super { +} +@end + +@class NSString; + +@interface MyClass : Super +@property(nonatomic, copy, readonly) NSString *prop; +@property(nonatomic, copy, readonly) id warnProp; // expected-warning {{property attributes 'readonly' and 'copy' are mutually exclusive}} +@end + +@interface MyClass () +@property(nonatomic, copy, readwrite) NSString *prop; +@end + +@implementation MyClass +@synthesize prop; +@synthesize warnProp; +@end + + +@protocol P +@property(nonatomic, copy, readonly) NSString *prop; +@property(nonatomic, copy, readonly) id warnProp; // expected-warning {{property attributes 'readonly' and 'copy' are mutually exclusive}} +@end + +@interface YourClass : Super <P> +@end + +@interface YourClass () +@property(nonatomic, copy, readwrite) NSString *prop; +@end + +@implementation YourClass +@synthesize prop; +@synthesize warnProp; +@end + diff --git a/test/SemaObjC/unused.m b/test/SemaObjC/unused.m index 975b9a96a773..5c7542bf4738 100644 --- a/test/SemaObjC/unused.m +++ b/test/SemaObjC/unused.m @@ -51,3 +51,5 @@ void test2() { } @end +// rdar://10777111 +static NSString *x = @"hi"; // expected-warning {{unused variable 'x'}} diff --git a/test/SemaObjC/warn-deprecated-implementations.m b/test/SemaObjC/warn-deprecated-implementations.m index 919b2211ddc4..5f7c2fd88f6a 100644 --- a/test/SemaObjC/warn-deprecated-implementations.m +++ b/test/SemaObjC/warn-deprecated-implementations.m @@ -20,7 +20,7 @@ @end __attribute__((deprecated)) -@interface CL // expected-note 2 {{class declared here}} +@interface CL // expected-note 2 {{class declared here}} // expected-note 2 {{declared here}} @end @implementation CL // expected-warning {{Implementing deprecated class}} diff --git a/test/SemaObjC/warn-direct-ivar-access.m b/test/SemaObjC/warn-direct-ivar-access.m new file mode 100644 index 000000000000..d2295f47655e --- /dev/null +++ b/test/SemaObjC/warn-direct-ivar-access.m @@ -0,0 +1,56 @@ +// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -Wdirect-ivar-access -verify -Wno-objc-root-class %s +// rdar://6505197 + +__attribute__((objc_root_class)) @interface MyObject { +@public + id _myMaster; + id _isTickledPink; + int _myIntProp; +} +@property(retain) id myMaster; +@property(assign) id isTickledPink; // expected-note {{property declared here}} +@property int myIntProp; +@end + +@implementation MyObject + +@synthesize myMaster = _myMaster; +@synthesize isTickledPink = _isTickledPink; // expected-error {{existing ivar '_isTickledPink' for property 'isTickledPink'}} +@synthesize myIntProp = _myIntProp; + +- (void) doSomething { + _myMaster = _isTickledPink; // expected-warning {{instance variable '_myMaster' is being directly accessed}} \ + // expected-warning {{instance variable '_isTickledPink' is being directly accessed}} +} + +- (id) init { + _myMaster=0; + return _myMaster; +} +- (void) dealloc { _myMaster = 0; } +@end + +MyObject * foo () +{ + MyObject* p=0; + p.isTickledPink = p.myMaster; // ok + p->_isTickledPink = (*p)._myMaster; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}} \ + // expected-warning {{instance variable '_myMaster' is being directly accessed}} + if (p->_myIntProp) // expected-warning {{instance variable '_myIntProp' is being directly accessed}} + p->_myIntProp = 0; // expected-warning {{instance variable '_myIntProp' is being directly accessed}} + return p->_isTickledPink; // expected-warning {{instance variable '_isTickledPink' is being directly accessed}} +} + +@interface ITest32 { +@public + id ivar; +} +@end + +id Test32(__weak ITest32 *x) { + __weak ITest32 *y; + x->ivar = 0; // expected-error {{dereferencing a __weak pointer is not allowed}} + return y ? y->ivar // expected-error {{dereferencing a __weak pointer is not allowed}} + : (*x).ivar; // expected-error {{dereferencing a __weak pointer is not allowed}} +} + diff --git a/test/SemaObjC/id-isa-ref.m b/test/SemaObjC/warn-isa-ref.m index c2debb0bc3c3..1932a029b0c7 100644 --- a/test/SemaObjC/id-isa-ref.m +++ b/test/SemaObjC/warn-isa-ref.m @@ -5,6 +5,7 @@ typedef struct objc_object { } *id; @interface NSObject { + id firstobj; struct objc_class *isa; } @end @@ -33,3 +34,50 @@ static void func() { expected-warning{{receiver type 'struct objc_class *' is not 'id' or interface pointer, consider casting it to 'id'}} \ expected-warning{{method '-self' not found (return type defaults to 'id')}} } + +// rdar://11702488 +// If an ivar is (1) the first ivar in a root class and (2) named `isa`, +// then it should get the same warnings that id->isa gets. + +@interface BaseClass { +@public + Class isa; // expected-note 3 {{ivar is declared here}} +} +@end + +@interface OtherClass { +@public + id firstIvar; + Class isa; // note, not first ivar; +} +@end + +@interface Subclass : BaseClass @end + +@interface SiblingClass : BaseClass @end + +@interface Root @end + +@interface hasIsa : Root { +@public + Class isa; // note, isa is not in root class +} +@end + +@implementation Subclass +-(void)method { + hasIsa *u; + id v; + BaseClass *w; + Subclass *x; + SiblingClass *y; + OtherClass *z; + (void)v->isa; // expected-warning {{direct access to objective-c's isa is deprecated}} + (void)w->isa; // expected-warning {{direct access to objective-c's isa is deprecated}} + (void)x->isa; // expected-warning {{direct access to objective-c's isa is deprecated}} + (void)y->isa; // expected-warning {{direct access to objective-c's isa is deprecated}} + (void)z->isa; + (void)u->isa; +} +@end + diff --git a/test/SemaObjC/warn-protocol-method-deprecated.m b/test/SemaObjC/warn-protocol-method-deprecated.m new file mode 100644 index 000000000000..928694db2528 --- /dev/null +++ b/test/SemaObjC/warn-protocol-method-deprecated.m @@ -0,0 +1,32 @@ +// RUN: %clang_cc1 -fsyntax-only -Wno-objc-root-class -verify %s +// rdar://11618852 + +@protocol TestProtocol +- (void)newProtocolMethod; +- (void)deprecatedProtocolMethod __attribute__((deprecated)); // expected-note 2 {{method 'deprecatedProtocolMethod' declared here}} +@end + +@interface NSObject @end + +@interface TestClass : NSObject <TestProtocol> + +- (void)newInstanceMethod; +- (void)deprecatedInstanceMethod __attribute__((deprecated)); // expected-note {{method 'deprecatedInstanceMethod' declared here}} + +@end + +int main(int argc, const char * argv[]) +{ + + TestClass *testObj = (TestClass*)0; + [testObj newInstanceMethod]; + [testObj deprecatedInstanceMethod]; // expected-warning {{'deprecatedInstanceMethod' is deprecated}} + + [testObj newProtocolMethod]; + [testObj deprecatedProtocolMethod]; // expected-warning {{'deprecatedProtocolMethod' is deprecated}} + + id <TestProtocol> testProto = testObj; + [testProto newProtocolMethod]; + [testProto deprecatedProtocolMethod]; // expected-warning {{'deprecatedProtocolMethod' is deprecated}} + return 0; +} diff --git a/test/SemaObjC/arc-retain-block-property.m b/test/SemaObjC/warn-retain-block-property.m index 3b66d149302c..3a54baf0f5a9 100644 --- a/test/SemaObjC/arc-retain-block-property.m +++ b/test/SemaObjC/warn-retain-block-property.m @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -fblocks -fobjc-arc -verify -Wno-objc-root-class %s // rdar://9829425 +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -Wno-objc-root-class %s +// rdar://11761511 extern void doSomething(); diff --git a/test/SemaObjC/weak-receiver-warn.m b/test/SemaObjC/weak-receiver-warn.m index f3955da3bc28..547f0087bc40 100644 --- a/test/SemaObjC/weak-receiver-warn.m +++ b/test/SemaObjC/weak-receiver-warn.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wreceiver-is-weak -verify %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -Wreceiver-is-weak -verify %s // rdar://10225276 @interface Test0 @@ -15,5 +15,66 @@ void test0(Test0 *x) { [weakx addBlock: ^{ [x actNow]; }]; // expected-warning {{weak receiver may be unpredictably null in ARC mode}} [weakx setBlock: ^{ [x actNow]; }]; // expected-warning {{weak receiver may be unpredictably null in ARC mode}} - weakx.block = ^{ [x actNow]; }; + weakx.block = ^{ [x actNow]; }; // expected-warning {{weak receiver may be unpredictably null in ARC mode}} } + +@interface Test +{ + __weak Test* weak_prop; +} +- (void) Meth; +@property __weak Test* weak_prop; // expected-note {{property declared here}} +@property (weak, atomic) id weak_atomic_prop; // expected-note {{property declared here}} +- (__weak id) P; // expected-note {{method 'P' declared here}} +@end + +@implementation Test +- (void) Meth { + if (self.weak_prop) { + self.weak_prop = 0; + } + if (self.weak_atomic_prop) { + self.weak_atomic_prop = 0; + } + [self.weak_prop Meth]; // expected-warning {{weak property may be unpredictably null in ARC mode}} + id pi = self.P; + + [self.weak_atomic_prop Meth]; // expected-warning {{weak property may be unpredictably null in ARC mode}} + + [self.P Meth]; // expected-warning {{weak implicit property may be unpredictably null in ARC mode}} +} + +- (__weak id) P { return 0; } +@dynamic weak_prop, weak_atomic_prop; +@end + + +@interface MyClass { + __weak MyClass *_parent; +} +@property (weak) MyClass *parent; // expected-note 2 {{property declared here}} +@end + +@implementation MyClass +@synthesize parent = _parent; + +- (void)doSomething +{ + [[self parent] doSomething]; // expected-warning {{weak property may be unpredictably null in ARC mode}} + + (void)self.parent.doSomething; // expected-warning {{weak property may be unpredictably null in ARC mode}} +} + +@end + + +// Weak properties on protocols can be synthesized by an adopting class. +@protocol MyProtocol +@property (weak) id object; // expected-note 2 {{property declared here}} +@end + +void testProtocol(id <MyProtocol> input) { + [[input object] Meth]; // expected-warning {{weak property may be unpredictably null in ARC mode}} + [input.object Meth]; // expected-warning {{weak property may be unpredictably null in ARC mode}} +} + diff --git a/test/SemaObjCXX/arc-0x.mm b/test/SemaObjCXX/arc-0x.mm index 28eec51775bd..e24b9602fb7f 100644 --- a/test/SemaObjCXX/arc-0x.mm +++ b/test/SemaObjCXX/arc-0x.mm @@ -11,6 +11,9 @@ void move_it(__strong id &&from) { - init; @end +// <rdar://problem/12031870>: don't warn about this +extern "C" A* MakeA(); + // Ensure that deduction works with lifetime qualifiers. void deduction(id obj) { auto a = [[A alloc] init]; @@ -22,7 +25,7 @@ void deduction(id obj) { __strong id *idp = new auto(obj); __strong id array[17]; - for (auto x : array) { + for (auto x : array) { // expected-warning{{'auto' deduced as 'id' in declaration of 'x'}} __strong id *xPtr = &x; } @@ -51,3 +54,30 @@ void test1c() { (void) ^{ (void) p; }; (void) ^{ (void) v; }; // expected-error {{cannot capture __autoreleasing variable in a block}} } + + +// <rdar://problem/11319689> +// warn when initializing an 'auto' variable with an 'id' initializer expression + +void testAutoId(id obj) { + auto x = obj; // expected-warning{{'auto' deduced as 'id' in declaration of 'x'}} +} + +@interface Array ++ (instancetype)new; +- (id)objectAtIndex:(int)index; +@end + +// ...but don't warn if it's coming from a template parameter. +template<typename T, int N> +void autoTemplateFunction(T param, id obj, Array *arr) { + auto x = param; // no-warning + auto y = obj; // expected-warning{{'auto' deduced as 'id' in declaration of 'y'}} + auto z = [arr objectAtIndex:N]; // expected-warning{{'auto' deduced as 'id' in declaration of 'z'}} +} + +void testAutoIdTemplate(id obj) { + autoTemplateFunction<id, 2>(obj, obj, [Array new]); // no-warning +} + + diff --git a/test/SemaObjCXX/arc-templates.mm b/test/SemaObjCXX/arc-templates.mm index 9eca84648f6a..80092729d34e 100644 --- a/test/SemaObjCXX/arc-templates.mm +++ b/test/SemaObjCXX/arc-templates.mm @@ -3,6 +3,8 @@ @interface A @end +@class NSString; + template<typename T, typename U> struct is_same { static const bool value = false; @@ -266,3 +268,18 @@ namespace rdar9828157 { float &fr = (f)(ap); } } + +namespace rdar10862386 { + // More deduction with lifetime qualifiers. + template <typename T> + int testing(const T &) { + return 1; + } + + void test() { + testing(1); + testing("hi"); + testing<NSString *>(@"hi"); + testing(@"hi"); + } +} diff --git a/test/SemaObjCXX/arc-type-traits.mm b/test/SemaObjCXX/arc-type-traits.mm index 9877870f9447..67bab00cf978 100644 --- a/test/SemaObjCXX/arc-type-traits.mm +++ b/test/SemaObjCXX/arc-type-traits.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -std=c++11 %s // Check the results of the various type-trait query functions on // lifetime-qualified types in ARC. @@ -9,48 +9,75 @@ #define TRAIT_IS_TRUE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? 1 : -1] #define TRAIT_IS_FALSE(Trait, Type) char JOIN2(Trait,__LINE__)[Trait(Type)? -1 : 1] +#define TRAIT_IS_TRUE_2(Trait, Type1, Type2) char JOIN2(Trait,__LINE__)[Trait(Type1, Type2)? 1 : -1] +#define TRAIT_IS_FALSE_2(Trait, Type1, Type2) char JOIN2(Trait,__LINE__)[Trait(Type1, Type2)? -1 : 1] +struct HasStrong { id obj; }; +struct HasWeak { __weak id obj; }; +struct HasUnsafeUnretained { __unsafe_unretained id obj; }; + // __has_nothrow_assign TRAIT_IS_TRUE(__has_nothrow_assign, __strong id); TRAIT_IS_TRUE(__has_nothrow_assign, __weak id); TRAIT_IS_TRUE(__has_nothrow_assign, __autoreleasing id); TRAIT_IS_TRUE(__has_nothrow_assign, __unsafe_unretained id); +TRAIT_IS_TRUE(__has_nothrow_assign, HasStrong); +TRAIT_IS_TRUE(__has_nothrow_assign, HasWeak); +TRAIT_IS_TRUE(__has_nothrow_assign, HasUnsafeUnretained); // __has_nothrow_copy TRAIT_IS_TRUE(__has_nothrow_copy, __strong id); TRAIT_IS_TRUE(__has_nothrow_copy, __weak id); TRAIT_IS_TRUE(__has_nothrow_copy, __autoreleasing id); TRAIT_IS_TRUE(__has_nothrow_copy, __unsafe_unretained id); +TRAIT_IS_TRUE(__has_nothrow_copy, HasStrong); +TRAIT_IS_TRUE(__has_nothrow_copy, HasWeak); +TRAIT_IS_TRUE(__has_nothrow_copy, HasUnsafeUnretained); // __has_nothrow_constructor TRAIT_IS_TRUE(__has_nothrow_constructor, __strong id); TRAIT_IS_TRUE(__has_nothrow_constructor, __weak id); TRAIT_IS_TRUE(__has_nothrow_constructor, __autoreleasing id); TRAIT_IS_TRUE(__has_nothrow_constructor, __unsafe_unretained id); +TRAIT_IS_TRUE(__has_nothrow_constructor, HasStrong); +TRAIT_IS_TRUE(__has_nothrow_constructor, HasWeak); +TRAIT_IS_TRUE(__has_nothrow_constructor, HasUnsafeUnretained); // __has_trivial_assign TRAIT_IS_FALSE(__has_trivial_assign, __strong id); TRAIT_IS_FALSE(__has_trivial_assign, __weak id); TRAIT_IS_FALSE(__has_trivial_assign, __autoreleasing id); TRAIT_IS_TRUE(__has_trivial_assign, __unsafe_unretained id); +TRAIT_IS_FALSE(__has_trivial_assign, HasStrong); +TRAIT_IS_FALSE(__has_trivial_assign, HasWeak); +TRAIT_IS_TRUE(__has_trivial_assign, HasUnsafeUnretained); // __has_trivial_copy TRAIT_IS_FALSE(__has_trivial_copy, __strong id); TRAIT_IS_FALSE(__has_trivial_copy, __weak id); TRAIT_IS_FALSE(__has_trivial_copy, __autoreleasing id); TRAIT_IS_TRUE(__has_trivial_copy, __unsafe_unretained id); +TRAIT_IS_FALSE(__has_trivial_copy, HasStrong); +TRAIT_IS_FALSE(__has_trivial_copy, HasWeak); +TRAIT_IS_TRUE(__has_trivial_copy, HasUnsafeUnretained); // __has_trivial_constructor TRAIT_IS_FALSE(__has_trivial_constructor, __strong id); TRAIT_IS_FALSE(__has_trivial_constructor, __weak id); TRAIT_IS_FALSE(__has_trivial_constructor, __autoreleasing id); TRAIT_IS_TRUE(__has_trivial_constructor, __unsafe_unretained id); +TRAIT_IS_FALSE(__has_trivial_constructor, HasStrong); +TRAIT_IS_FALSE(__has_trivial_constructor, HasWeak); +TRAIT_IS_TRUE(__has_trivial_constructor, HasUnsafeUnretained); // __has_trivial_destructor TRAIT_IS_FALSE(__has_trivial_destructor, __strong id); TRAIT_IS_FALSE(__has_trivial_destructor, __weak id); TRAIT_IS_TRUE(__has_trivial_destructor, __autoreleasing id); TRAIT_IS_TRUE(__has_trivial_destructor, __unsafe_unretained id); +TRAIT_IS_FALSE(__has_trivial_destructor, HasStrong); +TRAIT_IS_FALSE(__has_trivial_destructor, HasWeak); +TRAIT_IS_TRUE(__has_trivial_destructor, HasUnsafeUnretained); // __is_literal TRAIT_IS_TRUE(__is_literal, __strong id); @@ -69,12 +96,18 @@ TRAIT_IS_FALSE(__is_pod, __strong id); TRAIT_IS_FALSE(__is_pod, __weak id); TRAIT_IS_FALSE(__is_pod, __autoreleasing id); TRAIT_IS_TRUE(__is_pod, __unsafe_unretained id); +TRAIT_IS_FALSE(__is_pod, HasStrong); +TRAIT_IS_FALSE(__is_pod, HasWeak); +TRAIT_IS_TRUE(__is_pod, HasUnsafeUnretained); // __is_trivial TRAIT_IS_FALSE(__is_trivial, __strong id); TRAIT_IS_FALSE(__is_trivial, __weak id); TRAIT_IS_FALSE(__is_trivial, __autoreleasing id); TRAIT_IS_TRUE(__is_trivial, __unsafe_unretained id); +TRAIT_IS_FALSE(__is_trivial, HasStrong); +TRAIT_IS_FALSE(__is_trivial, HasWeak); +TRAIT_IS_TRUE(__is_trivial, HasUnsafeUnretained); // __is_scalar TRAIT_IS_FALSE(__is_scalar, __strong id); @@ -88,3 +121,94 @@ TRAIT_IS_TRUE(__is_standard_layout, __weak id); TRAIT_IS_TRUE(__is_standard_layout, __autoreleasing id); TRAIT_IS_TRUE(__is_standard_layout, __unsafe_unretained id); +// __is_trivally_assignable +TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __strong id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __weak id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __autoreleasing id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __unsafe_unretained id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __strong id&&); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __weak id&&); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __autoreleasing id&&); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __strong id&, __unsafe_unretained id&&); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __strong id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __weak id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __autoreleasing id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __unsafe_unretained id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __strong id&&); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __weak id&&); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __autoreleasing id&&); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __weak id&, __unsafe_unretained id&&); + +TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __strong id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __weak id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __autoreleasing id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __unsafe_unretained id); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __strong id&&); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __weak id&&); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __autoreleasing id&&); +TRAIT_IS_FALSE_2(__is_trivially_assignable, __autoreleasing id&, __unsafe_unretained id&&); + +TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __strong id); +TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __weak id); +TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __autoreleasing id); +TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __unsafe_unretained id); +TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __strong id&&); +TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __weak id&&); +TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __autoreleasing id&&); +TRAIT_IS_TRUE_2(__is_trivially_assignable, __unsafe_unretained id&, __unsafe_unretained id&&); + +TRAIT_IS_FALSE_2(__is_trivially_assignable, HasStrong&, HasStrong); +TRAIT_IS_FALSE_2(__is_trivially_assignable, HasStrong&, HasStrong&&); +TRAIT_IS_FALSE_2(__is_trivially_assignable, HasWeak&, HasWeak); +TRAIT_IS_FALSE_2(__is_trivially_assignable, HasWeak&, HasWeak&&); +TRAIT_IS_TRUE_2(__is_trivially_assignable, HasUnsafeUnretained&, HasUnsafeUnretained); +TRAIT_IS_TRUE_2(__is_trivially_assignable, HasUnsafeUnretained&, HasUnsafeUnretained&&); + +// __is_trivally_constructible +TRAIT_IS_FALSE(__is_trivially_constructible, __strong id); +TRAIT_IS_FALSE(__is_trivially_constructible, __weak id); +TRAIT_IS_FALSE(__is_trivially_constructible, __autoreleasing id); +TRAIT_IS_TRUE(__is_trivially_constructible, __unsafe_unretained id); + +TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __strong id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __weak id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __autoreleasing id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __unsafe_unretained id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __strong id&&); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __weak id&&); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __autoreleasing id&&); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __strong id, __unsafe_unretained id&&); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __strong id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __weak id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __autoreleasing id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __unsafe_unretained id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __strong id&&); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __weak id&&); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __autoreleasing id&&); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __weak id, __unsafe_unretained id&&); + +TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __strong id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __weak id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __autoreleasing id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __unsafe_unretained id); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __strong id&&); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __weak id&&); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __autoreleasing id&&); +TRAIT_IS_FALSE_2(__is_trivially_constructible, __autoreleasing id, __unsafe_unretained id&&); + +TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __strong id); +TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __weak id); +TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __autoreleasing id); +TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __unsafe_unretained id); +TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __strong id&&); +TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __weak id&&); +TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __autoreleasing id&&); +TRAIT_IS_TRUE_2(__is_trivially_constructible, __unsafe_unretained id, __unsafe_unretained id&&); + +TRAIT_IS_FALSE_2(__is_trivially_constructible, HasStrong, HasStrong); +TRAIT_IS_FALSE_2(__is_trivially_constructible, HasStrong, HasStrong&&); +TRAIT_IS_FALSE_2(__is_trivially_constructible, HasWeak, HasWeak); +TRAIT_IS_FALSE_2(__is_trivially_constructible, HasWeak, HasWeak&&); +TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained); +TRAIT_IS_TRUE_2(__is_trivially_constructible, HasUnsafeUnretained, HasUnsafeUnretained&&); + diff --git a/test/SemaObjCXX/arc-unbridged-cast.mm b/test/SemaObjCXX/arc-unbridged-cast.mm index 0b3ba07eef3e..f7d239148704 100644 --- a/test/SemaObjCXX/arc-unbridged-cast.mm +++ b/test/SemaObjCXX/arc-unbridged-cast.mm @@ -44,10 +44,10 @@ void test1(int cond) { x = (id) (cond ? (void*) 0 : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} x = (id) (cond ? (CFStringRef) @"help" : unauditedString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} - x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} - x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} - x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} - x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use __bridge to}} expected-note {{use CFBridgingRelease call to}} + x = (id) auditedCreateString(); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}} + x = (id) (cond ? auditedCreateString() : (void*) 0); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}} + x = (id) (cond ? (void*) 0 : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}} + x = (id) (cond ? (CFStringRef) @"help" : auditedCreateString()); // expected-error {{requires a bridged cast}} expected-note {{use CFBridgingRelease call to}} x = (id) [object property]; x = (id) (cond ? [object property] : (void*) 0); diff --git a/test/SemaObjCXX/boxing-illegal-types.mm b/test/SemaObjCXX/boxing-illegal-types.mm new file mode 100644 index 000000000000..7729753fb90e --- /dev/null +++ b/test/SemaObjCXX/boxing-illegal-types.mm @@ -0,0 +1,58 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wattributes %s + +typedef long NSInteger; +typedef unsigned long NSUInteger; +typedef signed char BOOL; + +@interface NSNumber +@end +@interface NSNumber (NSNumberCreation) ++ (NSNumber *)numberWithChar:(char)value; ++ (NSNumber *)numberWithUnsignedChar:(unsigned char)value; ++ (NSNumber *)numberWithShort:(short)value; ++ (NSNumber *)numberWithUnsignedShort:(unsigned short)value; ++ (NSNumber *)numberWithInt:(int)value; ++ (NSNumber *)numberWithUnsignedInt:(unsigned int)value; ++ (NSNumber *)numberWithLong:(long)value; ++ (NSNumber *)numberWithUnsignedLong:(unsigned long)value; ++ (NSNumber *)numberWithLongLong:(long long)value; ++ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value; ++ (NSNumber *)numberWithFloat:(float)value; ++ (NSNumber *)numberWithDouble:(double)value; ++ (NSNumber *)numberWithBool:(BOOL)value; ++ (NSNumber *)numberWithInteger:(NSInteger)value; ++ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value; +@end + +typedef struct { + int x, y, z; +} point; + +void testStruct() { + point p = { 0, 0, 0 }; + id boxed = @(p); // expected-error {{illegal type 'point' used in a boxed expression}} +} + +void testPointers() { + void *null = 0; + id boxed_null = @(null); // expected-error {{illegal type 'void *' used in a boxed expression}} + int numbers[] = { 0, 1, 2 }; + id boxed_numbers = @(numbers); // expected-error {{illegal type 'int *' used in a boxed expression}} +} + +void testInvalid() { + @(not_defined); // expected-error {{use of undeclared identifier 'not_defined'}} +} + +enum MyEnum { + ME_foo +}; + +enum ForwE; // expected-error {{ISO C++ forbids forward references to 'enum' types}} + +void testEnum(void *p) { + enum MyEnum myen; + id box = @(myen); + box = @(ME_foo); + box = @(*(enum ForwE*)p); // expected-error {{incomplete type 'enum ForwE' used in a boxed expression}} +} diff --git a/test/SemaObjCXX/crash.mm b/test/SemaObjCXX/crash.mm new file mode 100644 index 000000000000..345f72e6093e --- /dev/null +++ b/test/SemaObjCXX/crash.mm @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fsyntax-only %s -verify + +// <rdar://problem/11286701> +namespace std { + template<typename T, typename U> class pair; +} + +@interface NSObject +@end + +@interface Test : NSObject +@end + +@implementation Test + +struct EvilStruct { +} // note the missing semicolon + + typedef std::pair<int, int> IntegerPair; // expected-error{{typedef declarator cannot be qualified}} \ +// expected-error{{typedef name must be an identifier}} \ +// expected-error{{expected ';' after top level declarator}} + +@end diff --git a/test/SemaObjCXX/delay-parsing-cfunctions.mm b/test/SemaObjCXX/delay-parsing-cfunctions.mm new file mode 100644 index 000000000000..fa65dbea9ece --- /dev/null +++ b/test/SemaObjCXX/delay-parsing-cfunctions.mm @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -x objective-c++ -std=c++11 -fsyntax-only -Werror -verify -Wno-objc-root-class %s +// rdar://10387088 + +struct X { +X(); +void SortWithCollator(); +}; + +@interface MyClass +- (void)someMethod; +@end + +@implementation MyClass +- (void)someMethod { + [self privateMethod]; // clang already does not warn here +} + +int bar(MyClass * myObject) { + [myObject privateMethod]; + return gorfbar(myObject); +} +- (void)privateMethod { } + +int gorfbar(MyClass * myObject) { + [myObject privateMethod]; + [myObject privateMethod1]; + return getMe + bar(myObject); +} + +- (void)privateMethod1 { + getMe = getMe+1; +} + +static int getMe; + +static int test() { + return 0; +} + +int x{17}; + +X::X() = default; +void X::SortWithCollator() {} +// pr13418 +namespace { + int CurrentTabId() {return 0;} +} +@end diff --git a/test/SemaObjCXX/delay-parsing-cplusfuncs.mm b/test/SemaObjCXX/delay-parsing-cplusfuncs.mm new file mode 100644 index 000000000000..b0227099c1e2 --- /dev/null +++ b/test/SemaObjCXX/delay-parsing-cplusfuncs.mm @@ -0,0 +1,52 @@ +// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -Werror -verify -Wno-objc-root-class %s +// rdar://10387088 + +@interface MyClass +- (void)someMethod; +@end + +struct S { + int bar(MyClass * myObject); + + int gorfbar(MyClass * myObject); + + S(); + S(MyClass *O1, MyClass *O2); + S(MyClass *O1); + + MyClass * Obj1, *Obj2; + +}; + +@implementation MyClass +- (void)someMethod { + [self privateMethod]; // clang already does not warn here +} + +int S::bar(MyClass * myObject) { + [myObject privateMethod]; + return gorfbar(myObject); +} +- (void)privateMethod { } + +int S::gorfbar(MyClass * myObject) { + [myObject privateMethod]; + [myObject privateMethod1]; + return getMe + bar(myObject); +} + +S::S(MyClass *O1, MyClass *O2) : Obj1(O1), Obj2(O2) { + [O1 privateMethod]; + [O2 privateMethod1]; +} +S::S(MyClass *O1) : Obj1(O1){ Obj2 = 0; } + +S::S() {} + +- (void)privateMethod1 { + getMe = getMe+1; +} + +static int getMe; + +@end diff --git a/test/SemaObjCXX/delay-parsing-func-tryblock.mm b/test/SemaObjCXX/delay-parsing-func-tryblock.mm new file mode 100644 index 000000000000..8cf615ec3264 --- /dev/null +++ b/test/SemaObjCXX/delay-parsing-func-tryblock.mm @@ -0,0 +1,66 @@ +// RUN: %clang_cc1 -x objective-c++ -fcxx-exceptions -fsyntax-only -Werror -verify -Wno-objc-root-class %s +// rdar://10387088 + +@interface MyClass +- (void)someMethod; +@end + +struct BadReturn { + BadReturn(MyClass * myObject); + int bar(MyClass * myObject); + void MemFunc(MyClass * myObject); + int i; + MyClass *CObj; +}; + +@implementation MyClass +- (void)someMethod { + [self privateMethod]; // clang already does not warn here +} + +int BadReturn::bar(MyClass * myObject) { + [myObject privateMethod]; + return 0; +} + +BadReturn::BadReturn(MyClass * myObject) try : CObj(myObject) { +} catch(...) { + try { + [myObject privateMethod]; + [myObject privateMethod1]; + getMe = bar(myObject); + [CObj privateMethod1]; + } catch(int ei) { + i = ei; + } catch(...) { + { + i = 0; + } + } +} + +void BadReturn::MemFunc(MyClass * myObject) try { +} catch(...) { + try { + [myObject privateMethod]; + [myObject privateMethod1]; + getMe = bar(myObject); + [CObj privateMethod1]; + } catch(int ei) { + i = ei; + } catch(...) { + { + i = 0; + } + } +} + +- (void)privateMethod { } + +- (void)privateMethod1 { + getMe = getMe+1; +} + +static int getMe; + +@end diff --git a/test/SemaObjCXX/exceptions-fragile.mm b/test/SemaObjCXX/exceptions-fragile.mm index 91b70774e401..54d9f83ed5a1 100644 --- a/test/SemaObjCXX/exceptions-fragile.mm +++ b/test/SemaObjCXX/exceptions-fragile.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fobjc-fragile-abi -fsyntax-only -verify %s +// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fobjc-runtime=macosx-fragile-10.5 -fsyntax-only -verify %s @interface NSException @end void opaque(); diff --git a/test/SemaObjCXX/foreach.mm b/test/SemaObjCXX/foreach.mm new file mode 100644 index 000000000000..3c4b908eab94 --- /dev/null +++ b/test/SemaObjCXX/foreach.mm @@ -0,0 +1,61 @@ +// RUN: %clang_cc1 -fsyntax-only -fblocks -verify -std=c++11 %s +// rdar://9293227 + +@class NSArray; + +void f(NSArray *a) { + id keys; + for (int i : a); // expected-error{{selector element type 'int' is not a valid object}} + for ((id)2 : a); // expected-error {{for range declaration must declare a variable}} \ + // expected-warning {{expression result unused}} + for (2 : a); // expected-error {{for range declaration must declare a variable}} \ + // expected-warning {{expression result unused}} + + for (id thisKey : keys); +} + +/* // rdar://9072298 */ +@protocol NSObject @end + +@interface NSObject <NSObject> { + Class isa; +} +@end + +typedef struct { + unsigned long state; + id *itemsPtr; + unsigned long *mutationsPtr; + unsigned long extra[5]; +} NSFastEnumerationState; + +@protocol NSFastEnumeration + +- (unsigned long)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(unsigned long)len; + +@end + +int main () +{ + NSObject<NSFastEnumeration>* collection = 0; + for (id thing : collection) { } + + id array; + for (int (^b)(void) : array) { + if (b() == 10000) { + return 1; + } + } + return 0; +} + +/* rdar://problem/11068137 */ +@interface Test2 +@property (assign) id prop; +@end +void test2(NSObject<NSFastEnumeration> *collection) { + Test2 *obj; + for (obj.prop : collection) { // expected-error {{for range declaration must declare a variable}} \ + // expected-warning {{property access result unused - getters should not be used for side effects}} + } +} diff --git a/test/SemaObjCXX/fragile-abi-object-assign.m b/test/SemaObjCXX/fragile-abi-object-assign.m index 5bb3ac6f6f50..b3504e96346f 100644 --- a/test/SemaObjCXX/fragile-abi-object-assign.m +++ b/test/SemaObjCXX/fragile-abi-object-assign.m @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-fragile-abi -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class %s // rdar://10731065 @interface MyView {} diff --git a/test/SemaObjCXX/instantiate-stmt.mm b/test/SemaObjCXX/instantiate-stmt.mm index ff72858afd3f..7575f7ad1a8f 100644 --- a/test/SemaObjCXX/instantiate-stmt.mm +++ b/test/SemaObjCXX/instantiate-stmt.mm @@ -38,20 +38,20 @@ template<typename T> void eat(T); template<typename E, typename T> void fast_enumeration_test(T collection) { for (E element in collection) { // expected-error{{selector element type 'int' is not a valid object}} \ - // expected-error{{collection expression type 'vector' is not a valid object}} + // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}} eat(element); } E element; for (element in collection) // expected-error{{selector element type 'int' is not a valid object}} \ - // expected-error{{collection expression type 'vector' is not a valid object}} + // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}} eat(element); - for (NSString *str in collection) // expected-error{{collection expression type 'vector' is not a valid object}} + for (NSString *str in collection) // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}} eat(str); NSString *str; - for (str in collection) // expected-error{{collection expression type 'vector' is not a valid object}} + for (str in collection) // expected-error{{the type 'vector' is not a pointer to a fast-enumerable object}} eat(str); } diff --git a/test/SemaObjCXX/message.mm b/test/SemaObjCXX/message.mm index 5ac2f40db849..7d8520cc52ac 100644 --- a/test/SemaObjCXX/message.mm +++ b/test/SemaObjCXX/message.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -fobjc-fragile-abi -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class %s @interface I1 - (int*)method; @end diff --git a/test/SemaObjCXX/objc-container-subscripting.mm b/test/SemaObjCXX/objc-container-subscripting.mm index c835cbe53c61..537e1520df5c 100644 --- a/test/SemaObjCXX/objc-container-subscripting.mm +++ b/test/SemaObjCXX/objc-container-subscripting.mm @@ -32,8 +32,8 @@ template void test_dictionary_subscripts(NSMutableDictionary*, id, int); // expe template<typename T, typename U, typename O> void test_array_subscripts(T base, U index, O obj) { - base[index] = obj; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or objective-C pointer type}} - obj = base[index]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or objective-C pointer type}} + base[index] = obj; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or Objective-C pointer type}} + obj = base[index]; // expected-error {{indexing expression is invalid because subscript type 'double' is not an integral or Objective-C pointer type}} } template void test_array_subscripts(NSMutableArray *, int, id); diff --git a/test/SemaObjCXX/property-synthesis-error.mm b/test/SemaObjCXX/property-synthesis-error.mm index 4b726d8ca64a..4f64a3a3385e 100644 --- a/test/SemaObjCXX/property-synthesis-error.mm +++ b/test/SemaObjCXX/property-synthesis-error.mm @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class -fobjc-default-synthesize-properties %s // rdar: //8550657 @interface NSArray @end @@ -72,3 +72,14 @@ private: @synthesize tcppObject = _tcppObject; @end + +struct IncompleteStruct; // expected-note 2 {{forward declaration of 'IncompleteStruct'}} +struct ConvertToIncomplete { operator IncompleteStruct&(); }; +@interface SynthIncompleteRef +@property (readonly, nonatomic) IncompleteStruct& x; // expected-note {{property declared here}} +@property (readonly, nonatomic) IncompleteStruct& y; // expected-note {{property declared here}} +@end + +@implementation SynthIncompleteRef // expected-error {{cannot synthesize property 'x' with incomplete type 'IncompleteStruct'}} +@synthesize y; // expected-error {{cannot synthesize property 'y' with incomplete type 'IncompleteStruct'}} +@end diff --git a/test/SemaObjCXX/protocol-lookup.mm b/test/SemaObjCXX/protocol-lookup.mm index bd8444c0ad68..e8abf6c1a9b7 100644 --- a/test/SemaObjCXX/protocol-lookup.mm +++ b/test/SemaObjCXX/protocol-lookup.mm @@ -52,5 +52,5 @@ void rdar8575095(id a) { [id<NSObject>(a) retain]; id<NSObject> x(id<NSObject>(0)); - id<NSObject> x2(id<NSObject>(y)); // expected-warning{{parentheses were disambiguated as a function declarator}} + id<NSObject> x2(id<NSObject>(y)); // expected-warning{{disambiguated as a function declaration}} expected-note{{add a pair of parentheses}} } diff --git a/test/SemaObjCXX/warn-missing-super.mm b/test/SemaObjCXX/warn-missing-super.mm new file mode 100644 index 000000000000..cd2a6cca767a --- /dev/null +++ b/test/SemaObjCXX/warn-missing-super.mm @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s +// PR13401 + +__attribute((objc_root_class)) @interface NSObject +@end + +@interface Dummy : NSObject +@end + +template<typename T> struct shared_ptr { + constexpr shared_ptr() {} +}; + +@implementation Dummy +- (void)dealloc +{ + constexpr shared_ptr<int> dummy; +} // expected-warning {{method possibly missing a [super dealloc] call}} +@end diff --git a/test/SemaOpenCL/storageclass.cl b/test/SemaOpenCL/storageclass.cl new file mode 100644 index 000000000000..c78e7cd436a3 --- /dev/null +++ b/test/SemaOpenCL/storageclass.cl @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only -cl-std=CL1.2 + +static int A; + +// static is not allowed at local scope. +void kernel foo() { + static int X = 5; // expected-error{{variables in function scope cannot be declared static}} + auto int Y = 7; // expected-error{{OpenCL does not support the 'auto' storage class specifier}} +} + +static void kernel bar() { // expected-error{{kernel functions cannot be declared static}} +} diff --git a/test/SemaOpenCL/warn-missing-prototypes.cl b/test/SemaOpenCL/warn-missing-prototypes.cl new file mode 100644 index 000000000000..487cb28399a3 --- /dev/null +++ b/test/SemaOpenCL/warn-missing-prototypes.cl @@ -0,0 +1,6 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -Wmissing-prototypes %s + +void f() { } // expected-warning {{no previous prototype for function 'f'}} + +// Don't warn about kernel functions. +kernel void g() { } diff --git a/test/SemaTemplate/alias-templates.cpp b/test/SemaTemplate/alias-templates.cpp index 75615ee29517..20ba6e0cb7bc 100644 --- a/test/SemaTemplate/alias-templates.cpp +++ b/test/SemaTemplate/alias-templates.cpp @@ -73,19 +73,38 @@ namespace PR11848 { template<typename T> using U = int; template<typename T, typename ...Ts> - void f(U<T> i, U<Ts> ...is) { // expected-error {{type 'U<Ts>' (aka 'int') of function parameter pack does not contain any unexpanded parameter packs}} - return i + f<Ts...>(is...); // expected-error {{pack expansion does not contain any unexpanded parameter packs}} + void f1(U<T> i, U<Ts> ...is) { // expected-note 2{{couldn't infer template argument 'T'}} + return i + f1<Ts...>(is...); + } + + // FIXME: This note is technically correct, but could be better. We + // should really say that we couldn't infer template argument 'Ts'. + template<typename ...Ts> + void f2(U<Ts> ...is) { } // expected-note {{requires 0 arguments, but 1 was provided}} + + template<typename...> struct type_tuple {}; + template<typename ...Ts> + void f3(type_tuple<Ts...>, U<Ts> ...is) {} // expected-note {{requires 4 arguments, but 3 were provided}} + + void g() { + f1(U<void>()); // expected-error {{no match}} + f1(1, 2, 3, 4, 5); // expected-error {{no match}} + f2(); // ok + f2(1); // expected-error {{no match}} + f3(type_tuple<>()); + f3(type_tuple<void, void, void>(), 1, 2); // expected-error {{no match}} + f3(type_tuple<void, void, void>(), 1, 2, 3); } template<typename ...Ts> struct S { - S(U<Ts>...ts); // expected-error {{does not contain any unexpanded parameter packs}} + S(U<Ts>...ts); }; template<typename T> struct Hidden1 { template<typename ...Ts> - Hidden1(typename T::template U<Ts> ...ts); // expected-error{{type 'typename Hide::U<Ts>' (aka 'int') of function parameter pack does not contain any unexpanded parameter packs}} + Hidden1(typename T::template U<Ts> ...ts); }; template<typename T, typename ...Ts> @@ -97,6 +116,53 @@ namespace PR11848 { template<typename T> using U = int; }; - Hidden1<Hide> h1; // expected-note{{in instantiation of template class 'PR11848::Hidden1<PR11848::Hide>' requested here}} + Hidden1<Hide> h1; Hidden2<Hide, double, char> h2(1, 2); } + +namespace Core22036 { + struct X {}; + void h(...); + template<typename T> using Y = X; + template<typename T, typename ...Ts> struct S { + // An expression can contain an unexpanded pack without being type or + // value dependent. This is true even if the expression's type is a pack + // expansion type. + void f1(Y<T> a) { h(g(a)); } // expected-error {{undeclared identifier 'g'}} + void f2(Y<Ts>...as) { h(g(as)...); } // expected-error {{undeclared identifier 'g'}} + void f3(Y<Ts>...as) { g(as...); } // ok + void f4(Ts ...ts) { h(g(sizeof(ts))...); } // expected-error {{undeclared identifier 'g'}} + // FIXME: We can reject this, since it has no valid instantiations because + // 'g' never has any associated namespaces. + void f5(Ts ...ts) { g(sizeof(ts)...); } // ok + }; +} + +namespace PR13243 { + template<typename A> struct X {}; + template<int I> struct C {}; + template<int I> using Ci = C<I>; + + template<typename A, int I> void f(X<A>, Ci<I>) {} + template void f(X<int>, C<0>); +} + +namespace PR13136 { + template <typename T, T... Numbers> + struct NumberTuple { }; + + template <unsigned int... Numbers> + using MyNumberTuple = NumberTuple<unsigned int, Numbers...>; + + template <typename U, unsigned int... Numbers> + void foo(U&&, MyNumberTuple<Numbers...>); + + template <typename U, unsigned int... Numbers> + void bar(U&&, NumberTuple<unsigned int, Numbers...>); + + int main() { + foo(1, NumberTuple<unsigned int, 0, 1>()); + bar(1, NumberTuple<unsigned int, 0, 1>()); + return 0; + } +} diff --git a/test/SemaTemplate/class-template-decl.cpp b/test/SemaTemplate/class-template-decl.cpp index ec4e0163855c..fe23d9241108 100644 --- a/test/SemaTemplate/class-template-decl.cpp +++ b/test/SemaTemplate/class-template-decl.cpp @@ -95,3 +95,45 @@ namespace rdar9676205 { }; } +namespace redecl { + int A; // expected-note {{here}} + template<typename T> struct A; // expected-error {{different kind of symbol}} + + int B; // expected-note {{here}} + template<typename T> struct B { // expected-error {{different kind of symbol}} + }; + + template<typename T> struct F; + template<typename T> struct K; + + int G, H; // expected-note {{here}} + + struct S { + int C; // expected-note {{here}} + template<typename T> struct C; // expected-error {{different kind of symbol}} + + int D; // expected-note {{here}} + template<typename T> struct D { // expected-error {{different kind of symbol}} + }; + + int E; + template<typename T> friend struct E { // expected-error {{cannot define a type in a friend}} + }; + + int F; + template<typename T> friend struct F; // ok, redecl::F + + template<typename T> struct G; // ok + + template<typename T> friend struct H; // expected-error {{different kind of symbol}} + + int I, J, K; + + struct U { + template<typename T> struct I; // ok + template<typename T> struct J { // ok + }; + template<typename T> friend struct K; // ok, redecl::K + }; + }; +} diff --git a/test/SemaTemplate/delegating-constructors.cpp b/test/SemaTemplate/delegating-constructors.cpp index e177b50375f0..852b89d809fa 100644 --- a/test/SemaTemplate/delegating-constructors.cpp +++ b/test/SemaTemplate/delegating-constructors.cpp @@ -29,3 +29,21 @@ namespace PR10457 { Foo f(1, 1); } } + +namespace PR12890 { + class Document + { + public: + Document() = default; + + template <class T> + explicit + Document(T&& t) : Document() + { + } + }; + void f() + { + Document d(1); + } +} diff --git a/test/SemaTemplate/dependent-base-classes.cpp b/test/SemaTemplate/dependent-base-classes.cpp index 895eacc87edd..1853511bfc8f 100644 --- a/test/SemaTemplate/dependent-base-classes.cpp +++ b/test/SemaTemplate/dependent-base-classes.cpp @@ -32,8 +32,7 @@ namespace PR6031 { template <class TT> struct FI2 { - C<typename FI2::type> a; // expected-error{{no type named 'type' in 'FI2<TT>'}} \ - // expected-error{{C++ requires a type specifier for all declarations}} + C<typename FI2::type> a; // expected-error{{no type named 'type' in 'FI2<TT>'}} }; template<typename T> diff --git a/test/SemaTemplate/explicit-instantiation.cpp b/test/SemaTemplate/explicit-instantiation.cpp index 13d76befe289..e3e77d082844 100644 --- a/test/SemaTemplate/explicit-instantiation.cpp +++ b/test/SemaTemplate/explicit-instantiation.cpp @@ -14,7 +14,7 @@ struct X0 { T f0(T x) { return x + 1; // expected-error{{invalid operands}} } - T* f0(T*, T*) { return T(); } + T* f0(T*, T*) { return T(); } // expected-warning{{expression which evaluates to zero treated as a null pointer constant of type 'int *'}} template<typename U> T f0(T, U) { return T(); } @@ -32,7 +32,7 @@ struct NotDefaultConstructible { // expected-note{{candidate constructor (the im template NotDefaultConstructible X0<NotDefaultConstructible>::value; // expected-note{{instantiation}} template int X0<int>::f0(int); -template int* X0<int>::f0(int*, int*); +template int* X0<int>::f0(int*, int*); // expected-note{{in instantiation of member function 'X0<int>::f0' requested here}} template int X0<int>::f0(int, float); template int X0<int>::f0(int) const; // expected-error{{does not refer}} diff --git a/test/SemaTemplate/friend-template.cpp b/test/SemaTemplate/friend-template.cpp index 9c95fa0151c1..9acbfdcea29a 100644 --- a/test/SemaTemplate/friend-template.cpp +++ b/test/SemaTemplate/friend-template.cpp @@ -243,3 +243,62 @@ namespace rdar11147355 { A<double>::B<double> ab; } + +namespace RedeclUnrelated { + struct S { + int packaged_task; + template<typename> class future { + template<typename> friend class packaged_task; + }; + future<void> share; + }; +} + +namespace PR12557 { + template <typename> + struct Foo; + + template <typename Foo_> + struct Bar { + typedef Foo_ Foo; // expected-note {{previous}} + + template <typename> friend struct Foo; // expected-error {{redefinition of 'Foo' as different kind of symbol}} + }; + + Bar<int> b; +} + +namespace PR12585 { + struct A { }; + template<typename> struct B { + template<typename> friend class A::does_not_exist; // \ + // expected-error {{friend declaration of 'does_not_exist' does not match any declaration in 'PR12585::A'}} + }; + + struct C { + template<typename> struct D; + }; + template<typename> class E { + int n; + template<typename> friend struct C::D; + }; + template<typename T> struct C::D { + int f() { + return E<int>().n; + } + }; + int n = C::D<void*>().f(); + + struct F { + template<int> struct G; + }; + template<typename T> struct H { + // FIXME: As with cases above, the note here is on an unhelpful declaration, + // and should point to the declaration of G within F. + template<T> friend struct F::G; // \ + // expected-error {{different type 'char' in template redeclaration}} \ + // expected-note {{previous}} + }; + H<int> h1; // ok + H<char> h2; // expected-note {{instantiation}} +} diff --git a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp index 8a6f9efa68ec..c560c6ba2a3b 100644 --- a/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp +++ b/test/SemaTemplate/instantiate-exception-spec-cxx11.cpp @@ -131,3 +131,17 @@ template<typename T> struct Derived : Base { Derived<Exc1> d1; // ok Derived<Exc2> d2; // expected-note {{in instantiation of}} + +// If the vtable for a derived class is used, the exception specification of +// any member function which ends up in that vtable is needed, even if it was +// declared in a base class. +namespace PR12763 { + template<bool *B> struct T { + virtual void f() noexcept (*B); // expected-error {{constant expression}} expected-note {{read of non-const}} + }; + bool b; // expected-note {{here}} + struct X : public T<&b> { + virtual void g(); + }; + void X::g() {} // expected-note {{in instantiation of}} +} diff --git a/test/SemaTemplate/instantiate-expr-1.cpp b/test/SemaTemplate/instantiate-expr-1.cpp index 9395117e9ce4..e7772435865d 100644 --- a/test/SemaTemplate/instantiate-expr-1.cpp +++ b/test/SemaTemplate/instantiate-expr-1.cpp @@ -127,7 +127,7 @@ void test_call_operator(CallOperator call_op, int i, double d) { template<typename T> void test_asm(T t) { - asm ("nop" : "=a"(*t) : "r"(*t)); // expected-error {{indirection requires pointer operand ('int' invalid)}} + asm ("nop" : "=r"(*t) : "r"(*t)); // expected-error {{indirection requires pointer operand ('int' invalid)}} } void test_asm() { diff --git a/test/SemaTemplate/instantiate-init.cpp b/test/SemaTemplate/instantiate-init.cpp index f0ca9a5b21e9..612a0b7f621c 100644 --- a/test/SemaTemplate/instantiate-init.cpp +++ b/test/SemaTemplate/instantiate-init.cpp @@ -1,6 +1,6 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -struct X0 { // expected-note 4{{candidate}} +struct X0 { // expected-note 8{{candidate}} X0(int*, float*); // expected-note 4{{candidate}} }; @@ -107,3 +107,14 @@ namespace PR7985 { array_lengthof(Description<float*>::data); // expected-error{{no matching function for call to 'array_lengthof'}} } } + +namespace PR13064 { + // Ensure that in-class direct-initialization is instantiated as + // direct-initialization and likewise copy-initialization is instantiated as + // copy-initialization. + struct A { explicit A(int); }; // expected-note{{here}} + template<typename T> struct B { T a { 0 }; }; + B<A> b; + template<typename T> struct C { T a = { 0 }; }; // expected-error{{explicit}} + C<A> c; // expected-note{{here}} +} diff --git a/test/SemaTemplate/instantiate-member-class.cpp b/test/SemaTemplate/instantiate-member-class.cpp index bb6427670c3e..7b42a27d6b2c 100644 --- a/test/SemaTemplate/instantiate-member-class.cpp +++ b/test/SemaTemplate/instantiate-member-class.cpp @@ -124,19 +124,20 @@ namespace rdar10397846 { { struct B { - struct C { C() { int *ptr = I; } }; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} + struct C { C() { int *ptr = I; } }; // expected-error{{cannot initialize a variable of type 'int *' with an rvalue of type 'int'}} \ + expected-warning{{expression which evaluates to zero treated as a null pointer constant of type 'int *'}} }; }; template<int N> void foo() { - class A<N>::B::C X; // expected-note{{in instantiation of member function}} + class A<N>::B::C X; // expected-note 2 {{in instantiation of member function}} int A<N+1>::B::C::*member = 0; } void bar() { - foo<0>(); + foo<0>(); // expected-note{{in instantiation of function template}} foo<1>(); // expected-note{{in instantiation of function template}} } } diff --git a/test/SemaTemplate/instantiate-method.cpp b/test/SemaTemplate/instantiate-method.cpp index 363115d1844e..5e9da3f688e8 100644 --- a/test/SemaTemplate/instantiate-method.cpp +++ b/test/SemaTemplate/instantiate-method.cpp @@ -173,5 +173,12 @@ namespace PR7022 { typedef X2<> X2_type; X2_type c; } +} +namespace SameSignatureAfterInstantiation { + template<typename T> struct S { + void f(T *); // expected-note {{previous}} + void f(const T*); // expected-error {{multiple overloads of 'f' instantiate to the same signature 'void (const int *)'}} + }; + S<const int> s; // expected-note {{instantiation}} } diff --git a/test/SemaTemplate/instantiate-objc-1.mm b/test/SemaTemplate/instantiate-objc-1.mm index 2780f8e57978..f8b97eb3ef43 100644 --- a/test/SemaTemplate/instantiate-objc-1.mm +++ b/test/SemaTemplate/instantiate-objc-1.mm @@ -46,3 +46,24 @@ template <typename T> struct EncodeTest { template struct EncodeTest<int>; template struct EncodeTest<double>; template struct EncodeTest<wchar_t>; + +// @() boxing expressions. +template <typename T> struct BoxingTest { + static id box(T value) { + return @(value); // expected-error {{illegal type 'int *' used in a boxed expression}} \ + // expected-error {{illegal type 'long double' used in a boxed expression}} + } +}; + +@interface NSNumber ++ (NSNumber *)numberWithInt:(int)value; +@end + +@interface NSString ++ (id)stringWithUTF8String:(const char *)str; +@end + +template struct BoxingTest<int>; +template struct BoxingTest<const char *>; +template struct BoxingTest<int *>; // expected-note {{in instantiation of member function 'BoxingTest<int *>::box' requested here}} +template struct BoxingTest<long double>; // expected-note {{in instantiation of member function 'BoxingTest<long double>::box' requested here}} diff --git a/test/SemaTemplate/instantiation-backtrace.cpp b/test/SemaTemplate/instantiation-backtrace.cpp index 21456e902ae5..f640836b7681 100644 --- a/test/SemaTemplate/instantiation-backtrace.cpp +++ b/test/SemaTemplate/instantiation-backtrace.cpp @@ -30,3 +30,22 @@ struct G : A<T>, // expected-error{{implicit instantiation of undefined template void h() { (void)sizeof(G<int>); // expected-note{{in instantiation of template class 'G<int>' requested here}} } + +namespace PR13365 { + template <class T> class ResultTy { // expected-warning {{does not declare any constructor}} + T t; // expected-note {{reference member 't' will never be initialized}} + }; + + template <class T1, class T2> + typename ResultTy<T2>::error Deduce( void (T1::*member)(T2) ) {} // \ + // expected-note {{instantiation of template class 'PR13365::ResultTy<int &>'}} \ + // expected-note {{substituting deduced template arguments into function template 'Deduce' [with T1 = PR13365::Cls, T2 = int &]}} \ + // expected-note {{substitution failure [with T1 = PR13365::Cls, T2 = int &]}} + + struct Cls { + void method(int&); + }; + void test() { + Deduce(&Cls::method); // expected-error {{no matching function}} + } +} diff --git a/test/SemaTemplate/instantiation-depth-defarg.cpp b/test/SemaTemplate/instantiation-depth-defarg.cpp new file mode 100644 index 000000000000..6550987de784 --- /dev/null +++ b/test/SemaTemplate/instantiation-depth-defarg.cpp @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 128 -ftemplate-backtrace-limit 4 %s + +template<int N> struct S { + typedef typename S<N-1>::type type; + static int f(int n = S<N-1>::f()); // \ +// expected-error{{recursive template instantiation exceeded maximum depth of 128}} \ +// expected-note 3 {{instantiation of default function argument}} \ +// expected-note {{skipping 125 contexts in backtrace}} \ +// expected-note {{use -ftemplate-depth=N to increase recursive template instantiation depth}} + +}; +template<> struct S<0> { + typedef int type; +}; + +// Incrementally instantiate up to S<2048>. +template struct S<128>; +template struct S<256>; +template struct S<384>; +template struct S<512>; +template struct S<640>; +template struct S<768>; +template struct S<896>; +template struct S<1024>; +template struct S<1152>; +template struct S<1280>; +template struct S<1408>; +template struct S<1536>; +template struct S<1664>; +template struct S<1792>; +template struct S<1920>; +template struct S<2048>; + +// Check that we actually bail out when we hit the instantiation depth limit for +// the default arguments. +void g() { S<2048>::f(); } // expected-note {{required here}} diff --git a/test/SemaTemplate/instantiation-depth-subst-2.cpp b/test/SemaTemplate/instantiation-depth-subst-2.cpp new file mode 100644 index 000000000000..a29d6b5a1b4c --- /dev/null +++ b/test/SemaTemplate/instantiation-depth-subst-2.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -verify %s -ftemplate-depth 2 + +template<int N> struct S { }; +// FIXME: We produce the same 'instantiation depth' error here many times +// (2^(depth+1) in total), due to additional lookups performed as part of +// error recovery in DiagnoseTwoPhaseOperatorLookup. +template<typename T> S<T() + T()> operator+(T, T); // expected-error 8{{}} expected-note 10{{}} +S<0> s; +int k = s + s; // expected-error {{invalid operands to binary expression}} diff --git a/test/SemaTemplate/instantiation-depth-subst.cpp b/test/SemaTemplate/instantiation-depth-subst.cpp new file mode 100644 index 000000000000..58e637411c66 --- /dev/null +++ b/test/SemaTemplate/instantiation-depth-subst.cpp @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -std=c++11 -verify %s -ftemplate-depth 2 + +// PR9793 +template<typename T> auto f(T t) -> decltype(f(t)); // \ +// expected-error {{recursive template instantiation exceeded maximum depth of 2}} \ +// expected-note 3 {{while substituting}} \ +// expected-note {{candidate}} + +int k = f(0); // expected-error {{no matching function for call to 'f'}} diff --git a/test/SemaTemplate/instantiation-depth.cpp b/test/SemaTemplate/instantiation-depth.cpp index 8e1b80368d18..c0b8bb2a1245 100644 --- a/test/SemaTemplate/instantiation-depth.cpp +++ b/test/SemaTemplate/instantiation-depth.cpp @@ -2,12 +2,30 @@ // RUN: %clang -fsyntax-only -Xclang -verify -ftemplate-depth-5 -ftemplate-backtrace-limit=4 %s // RUN: %clang -fsyntax-only -Xclang -verify -ftemplate-depth=5 -ftemplate-backtrace-limit=4 %s +#ifndef NOEXCEPT + template<typename T> struct X : X<T*> { }; \ // expected-error{{recursive template instantiation exceeded maximum depth of 5}} \ // expected-note 3 {{instantiation of template class}} \ // expected-note {{skipping 2 contexts in backtrace}} \ // expected-note {{use -ftemplate-depth=N to increase recursive template instantiation depth}} -void test() { +void test() { (void)sizeof(X<int>); // expected-note {{instantiation of template class}} } + +#else + +// RUN: %clang_cc1 -fsyntax-only -verify -ftemplate-depth 5 -ftemplate-backtrace-limit 4 -std=c++11 -DNOEXCEPT %s + +template<typename T> struct S { + S() noexcept(noexcept(T())); +}; +struct T : S<T> {}; \ +// expected-error{{recursive template instantiation exceeded maximum depth of 5}} \ +// expected-note 4 {{in instantiation of exception spec}} \ +// expected-note {{skipping 2 contexts in backtrace}} \ +// expected-note {{use -ftemplate-depth=N to increase recursive template instantiation depth}} +T t; // expected-note {{implicit default constructor for 'T' first required here}} + +#endif diff --git a/test/SemaTemplate/member-template-access-expr.cpp b/test/SemaTemplate/member-template-access-expr.cpp index c95b57d4b4fd..f105ba8e84b5 100644 --- a/test/SemaTemplate/member-template-access-expr.cpp +++ b/test/SemaTemplate/member-template-access-expr.cpp @@ -60,7 +60,7 @@ struct X1 { void test_X1(X1 x1) { float *fp1 = x1.f1<>(17); - float *fp2 = x1.f1<int>(3.14); // expected-warning {{implicit conversion turns literal floating-point number into integer}} + float *fp2 = x1.f1<int>(3.14); // expected-warning {{implicit conversion from 'double' to 'int' changes value from 3.14 to 3}} int *ip1 = x1.f1(17); float *ip2 = x1.f1(3.14); diff --git a/test/SemaTemplate/ms-function-specialization-class-scope.cpp b/test/SemaTemplate/ms-function-specialization-class-scope.cpp index bda87f99c9a1..131922bbfbaa 100644 --- a/test/SemaTemplate/ms-function-specialization-class-scope.cpp +++ b/test/SemaTemplate/ms-function-specialization-class-scope.cpp @@ -69,3 +69,24 @@ void test2() b.f(100); } + +namespace PR12709 { + +template<class T> +class TemplateClass { + void member_function() { + specialized_member_template<false>(); + } + + template<bool b> + void specialized_member_template() {} + + template<> + void specialized_member_template<false>() {} // expected-warning{{explicit specialization of 'specialized_member_template' within class scope is a Microsoft extension}} +}; + +void f() { + TemplateClass<int> t; +} + +} diff --git a/test/SemaTemplate/ms-lookup-template-base-classes.cpp b/test/SemaTemplate/ms-lookup-template-base-classes.cpp index 2c422dc7e3f7..8f80cb59e8ab 100644 --- a/test/SemaTemplate/ms-lookup-template-base-classes.cpp +++ b/test/SemaTemplate/ms-lookup-template-base-classes.cpp @@ -143,3 +143,32 @@ public: template class A<C>; } + +namespace PR12701 { + +class A {}; +class B {}; + +template <class T> +class Base { + public: + bool base_fun(void* p) { return false; } // expected-note {{must qualify identifier to find this declaration in dependent base clas}} + operator T*() const { return 0; } +}; + +template <class T> +class Container : public Base<T> { + public: + template <typename S> + bool operator=(const Container<S>& rhs) { + return base_fun(rhs); // expected-warning {{use of identifier 'base_fun' found via unqualified lookup into dependent bases of class templates is a Microsoft extension}} + } +}; + +void f() { + Container<A> text_provider; + Container<B> text_provider2; + text_provider2 = text_provider; // expected-note {{in instantiation of function template specialization}} +} + +} // namespace PR12701 diff --git a/test/SemaTemplate/overload-candidates.cpp b/test/SemaTemplate/overload-candidates.cpp index 8762cc80630a..dc6d2a51ec2e 100644 --- a/test/SemaTemplate/overload-candidates.cpp +++ b/test/SemaTemplate/overload-candidates.cpp @@ -24,7 +24,9 @@ void test_get(void *ptr) { } template<typename T> - typename T::type get_type(const T&); // expected-note{{candidate template ignored: substitution failure [with T = int *]}} + typename T::type get_type(const T&); // expected-note{{candidate template ignored: substitution failure [with T = int *]: type 'int *' cannot be used prior to '::'}} +template<typename T> + void get_type(T *, int[(int)sizeof(T) - 9] = 0); // expected-note{{candidate template ignored: substitution failure [with T = int]: array size is negative}} void test_get_type(int *ptr) { (void)get_type(ptr); // expected-error{{no matching function for call to 'get_type'}} @@ -38,3 +40,25 @@ struct X { void test_X_min(X x) { (void)x.min(1, 2l); // expected-error{{no matching member function for call to 'min'}} } + +namespace boost { + template<bool, typename = void> struct enable_if {}; + template<typename T> struct enable_if<true, T> { typedef T type; }; +} +template<typename T> typename boost::enable_if<sizeof(T) == 4, int>::type if_size_4(); // expected-note{{candidate template ignored: disabled by 'enable_if' [with T = char]}} +int k = if_size_4<char>(); // expected-error{{no matching function}} + +namespace llvm { + template<typename Cond, typename T = void> struct enable_if : boost::enable_if<Cond::value, T> {}; +} +template<typename T> struct is_int { enum { value = false }; }; +template<> struct is_int<int> { enum { value = true }; }; +template<typename T> typename llvm::enable_if<is_int<T> >::type if_int(); // expected-note{{candidate template ignored: disabled by 'enable_if' [with T = char]}} +void test_if_int() { + if_int<char>(); // expected-error{{no matching function}} +} + +template<typename T> struct NonTemplateFunction { + typename boost::enable_if<sizeof(T) == 4, int>::type f(); // expected-error{{no type named 'type' in 'boost::enable_if<false, int>'; 'enable_if' cannot be used to disable this declaration}} +}; +NonTemplateFunction<char> NTFC; // expected-note{{here}} diff --git a/test/SemaTemplate/recovery-crash.cpp b/test/SemaTemplate/recovery-crash.cpp index 0ed3258b683b..61e880bf5b03 100644 --- a/test/SemaTemplate/recovery-crash.cpp +++ b/test/SemaTemplate/recovery-crash.cpp @@ -1,7 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -// We don't expect a fix-it to be applied in this case. Clang used to crash -// trying to recover while adding 'this->' before Work(x); +// Clang used to crash trying to recover while adding 'this->' before Work(x); template <typename> struct A { static void Work(int); // expected-note{{must qualify identifier}} diff --git a/test/SemaTemplate/typename-specifier.cpp b/test/SemaTemplate/typename-specifier.cpp index 9eb4f33de0b9..733dc7fa184e 100644 --- a/test/SemaTemplate/typename-specifier.cpp +++ b/test/SemaTemplate/typename-specifier.cpp @@ -22,8 +22,8 @@ typename N::C::type *ip3 = &i; // expected-error{{typename specifier refers to n // expected-warning{{'typename' occurs outside of a template}} void test(double d) { - typename N::A::type f(typename N::A::type(a)); // expected-warning{{parentheses were disambiguated as a function declarator}} \ - // expected-warning 2{{'typename' occurs outside of a template}} + typename N::A::type f(typename N::A::type(a)); // expected-warning{{disambiguated as a function declaration}} \ + // expected-note{{add a pair of parentheses}} expected-warning 2{{'typename' occurs outside of a template}} int five = f(5); using namespace N; @@ -115,3 +115,40 @@ namespace PR10925 { using typename BasicGeometry<mydim, int>::operator[]; // expected-error {{typename is allowed for identifiers only}} }; } + + +namespace missing_typename { +template <class T1, class T2> struct pair {}; // expected-note 7 {{template parameter is declared here}} + +template <class T1, class T2> +struct map { + typedef T1* iterator; +}; + +template <class T> +class ExampleClass1 { + struct ExampleItem; + + + struct ExampleItemSet { + typedef ExampleItem* iterator; + ExampleItem* operator[](unsigned); + }; + + void foo() { + pair<ExampleItemSet::iterator, int> i; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}} + pair<this->ExampleItemSet::iterator, int> i; // expected-error-re {{template argument for template type parameter must be a type$}} + pair<ExampleItemSet::operator[], int> i; // expected-error-re {{template argument for template type parameter must be a type$}} + } + pair<ExampleItemSet::iterator, int> elt; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}} + + + typedef map<int, ExampleItem*> ExampleItemMap; + + static void bar() { + pair<ExampleItemMap::iterator, int> i; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}} + } + pair<ExampleItemMap::iterator, int> entry; // expected-error {{template argument for template type parameter must be a type; did you forget 'typename'?}} + pair<bar, int> foobar; // expected-error {{template argument for template type parameter must be a type}} +}; +} // namespace missing_typename diff --git a/test/Tooling/Inputs/lit.local.cfg b/test/Tooling/Inputs/lit.local.cfg new file mode 100644 index 000000000000..e6f55eef7af5 --- /dev/null +++ b/test/Tooling/Inputs/lit.local.cfg @@ -0,0 +1 @@ +config.suffixes = [] diff --git a/test/Tooling/Inputs/pch-fail.h b/test/Tooling/Inputs/pch-fail.h new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Tooling/Inputs/pch-fail.h diff --git a/test/Tooling/Inputs/pch.cpp b/test/Tooling/Inputs/pch.cpp new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Tooling/Inputs/pch.cpp diff --git a/test/Tooling/Inputs/pch.h b/test/Tooling/Inputs/pch.h new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/test/Tooling/Inputs/pch.h diff --git a/test/Tooling/auto-detect-from-source-parent-of-cwd.cpp b/test/Tooling/auto-detect-from-source-parent-of-cwd.cpp new file mode 100644 index 000000000000..9692edcd4f1f --- /dev/null +++ b/test/Tooling/auto-detect-from-source-parent-of-cwd.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t/abc/def/ijk/qwe +// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/abc/def/ijk/qwe/test.cpp\",\"file\":\"%t/abc/def/ijk/qwe/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json +// RUN: cp "%s" "%t/abc/def/ijk/qwe/test.cpp" +// RUN: PWD="%t/abc/def" clang-check "ijk/qwe/test.cpp" 2>&1 | FileCheck %s + +// CHECK: C++ requires +invalid; + +// REQUIRES: shell diff --git a/test/Tooling/auto-detect-from-source-parent.cpp b/test/Tooling/auto-detect-from-source-parent.cpp new file mode 100644 index 000000000000..ea7eb158be22 --- /dev/null +++ b/test/Tooling/auto-detect-from-source-parent.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t/abc/def/ijk/qwe +// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/abc/def/ijk/qwe/test.cpp\",\"file\":\"%t/abc/def/ijk/qwe/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json +// RUN: cp "%s" "%t/abc/def/ijk/qwe/test.cpp" +// RUN: clang-check "%t/abc/def/ijk/qwe/test.cpp" 2>&1 | FileCheck %s + +// CHECK: C++ requires +invalid; + +// REQUIRES: shell diff --git a/test/Tooling/auto-detect-from-source.cpp b/test/Tooling/auto-detect-from-source.cpp new file mode 100644 index 000000000000..d8e82e77545f --- /dev/null +++ b/test/Tooling/auto-detect-from-source.cpp @@ -0,0 +1,10 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/test.cpp\",\"file\":\"%t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json +// RUN: cp "%s" "%t/test.cpp" +// RUN: clang-check "%t/test.cpp" 2>&1 | FileCheck %s + +// CHECK: C++ requires +invalid; + +// REQUIRES: shell diff --git a/test/Tooling/clang-check-args.cpp b/test/Tooling/clang-check-args.cpp index a14fc7bcd647..9ba5d45f5088 100644 --- a/test/Tooling/clang-check-args.cpp +++ b/test/Tooling/clang-check-args.cpp @@ -1,8 +1,7 @@ -// RUN: clang-check . "%s" -- -c 2>&1 | FileCheck %s +// RUN: clang-check "%s" -- -c 2>&1 | FileCheck %s // CHECK: C++ requires invalid; -// FIXME: JSON doesn't like path separator '\', on Win32 hosts. -// FIXME: clang-check doesn't like gcc driver on cygming. -// XFAIL: cygwin,mingw32,win32 +// FIXME: This is incompatible to -fms-compatibility. +// XFAIL: win32 diff --git a/test/Tooling/clang-check-ast-dump.cpp b/test/Tooling/clang-check-ast-dump.cpp new file mode 100644 index 000000000000..86533af3e11d --- /dev/null +++ b/test/Tooling/clang-check-ast-dump.cpp @@ -0,0 +1,35 @@ +// RUN: clang-check -ast-dump "%s" -- 2>&1 | FileCheck %s +// CHECK: namespace test_namespace +// CHECK-NEXT: class TheClass +// CHECK: int theMethod(int x) (CompoundStmt +// CHECK-NEXT: (ReturnStmt +// CHECK-NEXT: (BinaryOperator +// +// RUN: clang-check -ast-dump -ast-dump-filter test_namespace::TheClass::theMethod "%s" -- 2>&1 | FileCheck -check-prefix CHECK-FILTER %s +// CHECK-FILTER-NOT: namespace test_namespace +// CHECK-FILTER-NOT: class TheClass +// CHECK-FILTER: int theMethod(int x) (CompoundStmt +// CHECK-FILTER-NEXT: (ReturnStmt +// CHECK-FILTER-NEXT: (BinaryOperator +// +// RUN: clang-check -ast-print "%s" -- 2>&1 | FileCheck -check-prefix CHECK-PRINT %s +// CHECK-PRINT: namespace test_namespace +// CHECK-PRINT: class TheClass +// CHECK-PRINT: int theMethod(int x) +// +// RUN: clang-check -ast-list "%s" -- 2>&1 | FileCheck -check-prefix CHECK-LIST %s +// CHECK-LIST: test_namespace +// CHECK-LIST-NEXT: test_namespace::TheClass +// CHECK-LIST-NEXT: test_namespace::TheClass::theMethod +// CHECK-LIST-NEXT: x + +namespace test_namespace { + +class TheClass { +public: + int theMethod(int x) { + return x + x; + } +}; + +} diff --git a/test/Tooling/clang-check-autodetect-dir.cpp b/test/Tooling/clang-check-autodetect-dir.cpp new file mode 100644 index 000000000000..2c395043bf05 --- /dev/null +++ b/test/Tooling/clang-check-autodetect-dir.cpp @@ -0,0 +1,11 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t/abc/def +// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/test.cpp\",\"file\":\"%t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json +// RUN: cp "%s" "%t/test.cpp" +// RUN: clang-check -p "%t/abc/def" "%t/test.cpp" 2>&1|FileCheck %s +// FIXME: Make the above easier. + +// CHECK: C++ requires +invalid; + +// REQUIRES: shell diff --git a/test/Tooling/clang-check-builtin-headers.cpp b/test/Tooling/clang-check-builtin-headers.cpp new file mode 100644 index 000000000000..504d197ea9af --- /dev/null +++ b/test/Tooling/clang-check-builtin-headers.cpp @@ -0,0 +1,15 @@ +// RUN: rm -rf %t +// RUN: mkdir %t +// Add a path that doesn't exist as argv[0] for the compile command line: +// RUN: echo '[{"directory":".","command":"/random/tool -c %t/test.cpp","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json +// RUN: cp "%s" "%t/test.cpp" +// RUN: clang-check -p "%t" "%t/test.cpp" 2>&1|FileCheck %s +// FIXME: Make the above easier. + +#include <stddef.h> + +// CHECK: C++ requires +invalid; + +// FIXME: This is incompatible to -fms-compatibility. +// XFAIL: win32 diff --git a/test/Tooling/clang-check-chdir.cpp b/test/Tooling/clang-check-chdir.cpp new file mode 100644 index 000000000000..29b5abb4c946 --- /dev/null +++ b/test/Tooling/clang-check-chdir.cpp @@ -0,0 +1,17 @@ +// Verifies that paths are resolved relatively to the directory specified in the +// compilation database. +// RUN: rm -rf %t +// RUN: mkdir %t +// RUN: echo "[{\"directory\":\"%t\",\"command\":\"clang -c test.cpp -I.\",\"file\":\"%t/test.cpp\"}]" | sed -e 's/\\/\//g' > %t/compile_commands.json +// RUN: cp "%s" "%t/test.cpp" +// RUN: touch "%t/clang-check-test.h" +// RUN: clang-check -p "%t" "%t/test.cpp" 2>&1|FileCheck %s +// FIXME: Make the above easier. + +#include "clang-check-test.h" + +// CHECK: C++ requires +invalid; + +// FIXME: This is incompatible to -fms-compatibility. +// XFAIL: win32 diff --git a/test/Tooling/clang-check-pwd.cpp b/test/Tooling/clang-check-pwd.cpp index cb943442037d..374c579245b7 100644 --- a/test/Tooling/clang-check-pwd.cpp +++ b/test/Tooling/clang-check-pwd.cpp @@ -1,13 +1,11 @@ // RUN: rm -rf %t // RUN: mkdir %t -// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/test.cpp\",\"file\":\"%t/test.cpp\"}]" > %t/compile_commands.json +// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %t/test.cpp\",\"file\":\"%t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json // RUN: cp "%s" "%t/test.cpp" -// RUN: PWD="%t" clang-check "%t" "test.cpp" 2>&1|FileCheck %s +// RUN: PWD="%t" clang-check -p "%t" "test.cpp" 2>&1|FileCheck %s // FIXME: Make the above easier. // CHECK: C++ requires invalid; -// FIXME: JSON doesn't like path separator '\', on Win32 hosts. -// FIXME: clang-check doesn't like gcc driver on cygming. -// XFAIL: cygwin,mingw32,win32 +// REQUIRES: shell diff --git a/test/Tooling/clang-check.cpp b/test/Tooling/clang-check.cpp index de10e4a4fb9f..91ab01b01be5 100644 --- a/test/Tooling/clang-check.cpp +++ b/test/Tooling/clang-check.cpp @@ -1,13 +1,12 @@ // RUN: rm -rf %t // RUN: mkdir %t -// RUN: echo '[{"directory":".","command":"clang++ -c %t/test.cpp","file":"%t/test.cpp"}]' > %t/compile_commands.json +// RUN: echo '[{"directory":".","command":"clang++ -c %t/test.cpp","file":"%t/test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json // RUN: cp "%s" "%t/test.cpp" -// RUN: clang-check "%t" "%t/test.cpp" 2>&1|FileCheck %s +// RUN: clang-check -p "%t" "%t/test.cpp" 2>&1|FileCheck %s // FIXME: Make the above easier. // CHECK: C++ requires invalid; -// FIXME: JSON doesn't like path separator '\', on Win32 hosts. -// FIXME: clang-check doesn't like gcc driver on cygming. -// XFAIL: cygwin,mingw32,win32 +// FIXME: This is incompatible to -fms-compatibility. +// XFAIL: win32 diff --git a/test/Tooling/multi-jobs.cpp b/test/Tooling/multi-jobs.cpp new file mode 100644 index 000000000000..a3eb7039c04f --- /dev/null +++ b/test/Tooling/multi-jobs.cpp @@ -0,0 +1,7 @@ +// RUN: clang-check "%s" -- -no-integrated-as -c 2>&1 | FileCheck %s + +// CHECK: C++ requires +invalid; + +// FIXME: This is incompatible to -fms-compatibility. +// XFAIL: win32 diff --git a/test/Tooling/pch.cpp b/test/Tooling/pch.cpp new file mode 100644 index 000000000000..715c95dd5541 --- /dev/null +++ b/test/Tooling/pch.cpp @@ -0,0 +1,17 @@ +// This is a regression test for handling of stat caches within the tooling +// infrastructure. This test reproduces the problem under valgrind: + +// First, create a pch that we can later load. Loading the pch will insert +// a stat cache into the FileManager: +// RUN: %clang -x c++-header %S/Inputs/pch.h -o %t1 + +// Use the generated pch and enforce a subsequent stat miss by using +// the test file with an unrelated include as second translation unit: +// Do not directly pipe into FileCheck, as that would hide errors from +// valgrind due to pipefail not being set in lit. +// RUN: clang-check "%S/Inputs/pch.cpp" "%s" -- -include-pch %t1 -I "%S" -c >%t2 2>&1 +// RUN: FileCheck %s < %t2 + +#include "Inputs/pch-fail.h" + +// CHECK: Processing diff --git a/test/lit.cfg b/test/lit.cfg index 738dc38e5bd5..7bc9620926fa 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -222,6 +222,10 @@ if platform.system() not in ['FreeBSD']: if platform.system() not in ['Windows'] or lit.getBashPath() != '': config.available_features.add('shell') +# ANSI escape sequences in non-dump terminal +if platform.system() not in ['Windows']: + config.available_features.add('ansi-escape-sequences') + # Registered Targets def get_llc_props(tool): set_of_targets = set() @@ -255,3 +259,7 @@ else: if llc_props['enable_assertions']: config.available_features.add('asserts') + +if lit.util.which('xmllint'): + config.available_features.add('xmllint') + |