diff options
Diffstat (limited to 'test/CodeGenObjC')
26 files changed, 192 insertions, 7 deletions
diff --git a/test/CodeGenObjC/atomic-aggregate-property.m b/test/CodeGenObjC/atomic-aggregate-property.m index 2896d379e75a..93eeca820117 100644 --- a/test/CodeGenObjC/atomic-aggregate-property.m +++ b/test/CodeGenObjC/atomic-aggregate-property.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix LP64 %s // rdar: // 7849824 struct s { diff --git a/test/CodeGenObjC/blocks-1.m b/test/CodeGenObjC/blocks-1.m index 76bfd59e41d1..1ac9c30c8a00 100644 --- a/test/CodeGenObjC/blocks-1.m +++ b/test/CodeGenObjC/blocks-1.m @@ -8,6 +8,16 @@ // 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 +// RUN: grep "_Block_object_dispose" %t | count 6 +// RUN: grep "__copy_helper_block_" %t | count 4 +// RUN: grep "__destroy_helper_block_" %t | count 4 +// RUN: grep "__Block_byref_id_object_copy_" %t | count 2 +// RUN: grep "__Block_byref_id_object_dispose_" %t | count 2 +// RUN: grep "i32 135)" %t | count 0 +// RUN: grep "_Block_object_assign" %t | count 4 +// RUN: grep "objc_read_weak" %t | count 2 +// RUN: grep "objc_assign_weak" %t | count 3 @interface NSDictionary @end diff --git a/test/CodeGenObjC/blocks-2.m b/test/CodeGenObjC/blocks-2.m index 15160cc52b06..0062e842648b 100644 --- a/test/CodeGenObjC/blocks-2.m +++ b/test/CodeGenObjC/blocks-2.m @@ -1,5 +1,7 @@ // RUN: %clang_cc1 %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 // RUN: grep "objc_assign_strongCast" %t | count 2 +// RUN: %clang_cc1 -x objective-c++ %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 +// RUN: grep "objc_assign_strongCast" %t | count 2 // This should generate a strong cast. diff --git a/test/CodeGenObjC/blocks-ivar-debug.m b/test/CodeGenObjC/blocks-ivar-debug.m new file mode 100644 index 000000000000..d0cf1f10f729 --- /dev/null +++ b/test/CodeGenObjC/blocks-ivar-debug.m @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -g %s -fblocks -S -o %t +// Radar 7959934 + +@interface NSObject { + struct objc_object *isa; +} +@end +@interface Foo : NSObject { + int _prop; +} +@end + +@implementation Foo +- (int)doSomething { + int (^blk)(void) = ^{ return _prop; }; + return blk(); +} + +@end + diff --git a/test/CodeGenObjC/blocks.m b/test/CodeGenObjC/blocks.m index 8ba319eefee1..b96a8d942fac 100644 --- a/test/CodeGenObjC/blocks.m +++ b/test/CodeGenObjC/blocks.m @@ -19,7 +19,7 @@ void foo(T *P) { -(void) im0; @end -// RUN: grep 'define internal i32 @"__-\[A im0\]_block_invoke_"' %t +// RUN: grep 'define internal i32 @"__8-\[A im0\]_block_invoke_0"' %t @implementation A -(void) im0 { (void) ^{ return 1; }(); @@ -31,5 +31,11 @@ void foo(T *P) { -(void) im1 { ^(void) { [self im0]; }(); } +-(void) im2 { + ^{ [super im0]; }(); +} +-(void) im3 { + ^{ ^{[super im0];}(); }(); +} @end diff --git a/test/CodeGenObjC/default-property-synthesis.m b/test/CodeGenObjC/default-property-synthesis.m new file mode 100644 index 000000000000..b3eeb22004ae --- /dev/null +++ b/test/CodeGenObjC/default-property-synthesis.m @@ -0,0 +1,38 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi2 -emit-llvm -o %t %s +// rdar://7923851. + +// Superclass declares property. Subclass redeclares the same property. +// Do not @synthesize-by-default in the subclass. P1 +// Superclass declares a property. Subclass declares a different property with the same name +// (such as different type or attributes). Do not @synthesize-by-default in the subclass. P2 +// Superclass conforms to a protocol that declares a property. Subclass redeclares the +// same property. Do not @synthesize-by-default in the subclass. P3 +// Superclass conforms to a protocol that declares a property. Subclass conforms to the +// same protocol or a derived protocol. Do not @synthesize-by-default in the subclass. P4 + + +@protocol PROTO + @property int P3; + @property int P4; +@end + +@protocol PROTO1 <PROTO> + @property int IMP1; +@end + +@interface Super <PROTO> + @property int P1; + @property (copy) id P2; +@end + +@interface Sub : Super <PROTO1> + @property int P1; + @property (nonatomic, retain) id P2; // expected-warning {{property 'P2' 'copy' attribute does not match the property inherited from 'Super'}} \ + // expected-warning {{property 'P2' 'atomic' attribute does not match the property inherited from 'Super'}} + @property int P3; + @property int IMP2; +@end + +@implementation Sub +@end + diff --git a/test/CodeGenObjC/ivar-layout-64-bitfields.m b/test/CodeGenObjC/ivar-layout-64-bitfields.m index 1b6a16b1b8be..9710e16172df 100644 --- a/test/CodeGenObjC/ivar-layout-64-bitfields.m +++ b/test/CodeGenObjC/ivar-layout-64-bitfields.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-gc -emit-llvm -o %t %s @interface I { struct { diff --git a/test/CodeGenObjC/ivar-layout-64.m b/test/CodeGenObjC/ivar-layout-64.m index 60ce1dff57de..f227bfc30d36 100644 --- a/test/CodeGenObjC/ivar-layout-64.m +++ b/test/CodeGenObjC/ivar-layout-64.m @@ -4,6 +4,12 @@ // RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"\\11q\\10\\00"' %t // RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"!q\\00"' %t // RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"\\01\\14\\00"' %t +// RUNX: llvm-gcc -ObjC++ -m64 -fobjc-gc -emit-llvm -S -o %t %s && +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fobjc-gc -emit-llvm -o %t %s +// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"A\\00"' %t +// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"\\11q\\10\\00"' %t +// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"!q\\00"' %t +// RUN: grep '@"\\01L_OBJC_CLASS_NAME_.*" = internal global .* c"\\01\\14\\00"' %t /* diff --git a/test/CodeGenObjC/ivar-layout-no-optimize.m b/test/CodeGenObjC/ivar-layout-no-optimize.m index e7fd1301b810..7760f94a50ab 100644 --- a/test/CodeGenObjC/ivar-layout-no-optimize.m +++ b/test/CodeGenObjC/ivar-layout-no-optimize.m @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -fobjc-gc -triple x86_64-apple-darwin -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 -O0 -S %s -o %t-64.s +// RUN: FileCheck -check-prefix LP64 --input-file=%t-64.s %s @interface NSObject { id isa; diff --git a/test/CodeGenObjC/objc-gc-aggr-assign.m b/test/CodeGenObjC/objc-gc-aggr-assign.m new file mode 100644 index 000000000000..9fd64d5645c8 --- /dev/null +++ b/test/CodeGenObjC/objc-gc-aggr-assign.m @@ -0,0 +1,62 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix C %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o - %s | FileCheck -check-prefix CP %s + +static int count; + +typedef struct S { + int ii; +} SS; + +struct type_s { + SS may_recurse; + id id_val; +}; + +@interface NamedObject +{ + struct type_s type_s_ivar; +} +- (void) setSome : (struct type_s) arg; +- (struct type_s) getSome; +@property(assign) struct type_s aggre_prop; +@end + +@implementation NamedObject +- (void) setSome : (struct type_s) arg + { + type_s_ivar = arg; + } +- (struct type_s) getSome + { + return type_s_ivar; + } +@synthesize aggre_prop = type_s_ivar; +@end + +struct type_s some = {{1234}, (id)0}; + +struct type_s get(void) +{ + return some; +} + +void f(const struct type_s *in, struct type_s *out) { + *out = *in; +} + +#ifdef __cplusplus +struct Derived : type_s { }; + +void foo(Derived* src, Derived* dest) { + *dest = *src; +} +#endif + +// CHECK-C: call i8* @objc_memmove_collectable +// CHECK-C: call i8* @objc_memmove_collectable +// CHECK-C: call i8* @objc_memmove_collectable + +// CHECK-CP: call i8* @objc_memmove_collectable +// CHECK-CP: call i8* @objc_memmove_collectable +// CHECK-CP: call i8* @objc_memmove_collectable +// CHECK-CP: call i8* @objc_memmove_collectable diff --git a/test/CodeGenObjC/objc2-new-gc-api-strongcast.m b/test/CodeGenObjC/objc2-new-gc-api-strongcast.m index 1ff2dd3d8de2..0413910855e5 100644 --- a/test/CodeGenObjC/objc2-new-gc-api-strongcast.m +++ b/test/CodeGenObjC/objc2-new-gc-api-strongcast.m @@ -1,9 +1,11 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -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 -fblocks -fobjc-gc -emit-llvm -o %t %s +// RUN: grep -F '@objc_assign_strongCast' %t | count 4 @interface DSATextSearch @end -DSATextSearch **_uniqueIdToIdentifierArray = ((void *)0); +DSATextSearch **_uniqueIdToIdentifierArray = (0); void foo (int _nextId) { _uniqueIdToIdentifierArray[_nextId] = 0; // objc_assign_strongCast diff --git a/test/CodeGenObjC/objc2-no-write-barrier.m b/test/CodeGenObjC/objc2-no-write-barrier.m index 544c329c5e20..a0ebc100fb2f 100644 --- a/test/CodeGenObjC/objc2-no-write-barrier.m +++ b/test/CodeGenObjC/objc2-no-write-barrier.m @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -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-gc -emit-llvm -o %t %s +// RUN: grep 'objc_assign' %t | count 0 typedef struct { int ival; diff --git a/test/CodeGenObjC/objc2-retain-codegen.m b/test/CodeGenObjC/objc2-retain-codegen.m index 2c3317a4854d..9f6620619ecd 100644 --- a/test/CodeGenObjC/objc2-retain-codegen.m +++ b/test/CodeGenObjC/objc2-retain-codegen.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-gc-only -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -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 509f21a342ae..b79f8a00f7a3 100644 --- a/test/CodeGenObjC/objc2-strong-cast-1.m +++ b/test/CodeGenObjC/objc2-strong-cast-1.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-unknown-unknown -fobjc-gc -emit-llvm -o %t %s @interface I { __attribute__((objc_gc(strong))) int *i_IdocumentIDs; diff --git a/test/CodeGenObjC/objc2-strong-cast.m b/test/CodeGenObjC/objc2-strong-cast.m index 9ef463c0df10..7291c4e8d2d4 100644 --- a/test/CodeGenObjC/objc2-strong-cast.m +++ b/test/CodeGenObjC/objc2-strong-cast.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -fobjc-gc -emit-llvm -o %t %s @interface I { __attribute__((objc_gc(strong))) signed long *_documentIDs; diff --git a/test/CodeGenObjC/objc2-weak-assign.m b/test/CodeGenObjC/objc2-weak-assign.m index 42fa7738f44e..74c0c00c7caa 100644 --- a/test/CodeGenObjC/objc2-weak-assign.m +++ b/test/CodeGenObjC/objc2-weak-assign.m @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -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-gc -emit-llvm -o %t %s +// RUN: grep -e "objc_assign_weak" %t | grep -e "call" | count 6 __weak id* x; id* __weak y; diff --git a/test/CodeGenObjC/objc2-weak-compare.m b/test/CodeGenObjC/objc2-weak-compare.m index cb8ca5ff4c07..8cba1a986094 100644 --- a/test/CodeGenObjC/objc2-weak-compare.m +++ b/test/CodeGenObjC/objc2-weak-compare.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -fobjc-gc -emit-llvm -o %t %s @interface PBXTarget { @@ -10,6 +11,7 @@ PBXTarget * result; - Meth; @end +extern void foo(); @implementation PBXTarget - Meth { if (_lastKnownTarget != result) diff --git a/test/CodeGenObjC/objc2-weak-ivar-debug.m b/test/CodeGenObjC/objc2-weak-ivar-debug.m index a6fb7fa2751f..8f7acd7619ac 100644 --- a/test/CodeGenObjC/objc2-weak-ivar-debug.m +++ b/test/CodeGenObjC/objc2-weak-ivar-debug.m @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-gc -g -emit-llvm -o - %s // RUN: %clang_cc1 -triple i386-apple-darwin9 -fobjc-gc -g -emit-llvm -o - %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -fobjc-gc -g -emit-llvm -o - %s +// RUN: %clang_cc1 -x objective-c++ -triple i386-apple-darwin9 -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 cfe1e95952fe..8c91a80b6863 100644 --- a/test/CodeGenObjC/objc2-weak-ivar.m +++ b/test/CodeGenObjC/objc2-weak-ivar.m @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fobjc-gc -emit-llvm -o %t %s +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin9 -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 9a76c6eb8208..74cd7eafad4f 100644 --- a/test/CodeGenObjC/objc2-write-barrier-2.m +++ b/test/CodeGenObjC/objc2-write-barrier-2.m @@ -2,6 +2,10 @@ // 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-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 extern id **somefunc(void); extern id *somefunc2(void); diff --git a/test/CodeGenObjC/objc2-write-barrier-3.m b/test/CodeGenObjC/objc2-write-barrier-3.m index 626083b1c42d..cb72cc06e55c 100644 --- a/test/CodeGenObjC/objc2-write-barrier-3.m +++ b/test/CodeGenObjC/objc2-write-barrier-3.m @@ -1,6 +1,9 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fblocks -fobjc-gc -emit-llvm -o %t %s // RUN: grep objc_assign_ivar %t | count 3 // RUN: grep objc_assign_strongCast %t | count 6 +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -fblocks -fobjc-gc -emit-llvm -o %t %s +// RUN: grep objc_assign_ivar %t | count 3 +// RUN: grep objc_assign_strongCast %t | count 6 struct Slice { void *__strong * items; diff --git a/test/CodeGenObjC/objc2-write-barrier-4.m b/test/CodeGenObjC/objc2-write-barrier-4.m index 11b4ab4e9604..ab30649bec2b 100644 --- a/test/CodeGenObjC/objc2-write-barrier-4.m +++ b/test/CodeGenObjC/objc2-write-barrier-4.m @@ -1,6 +1,9 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -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-gc -emit-llvm -o %t %s +// RUN: grep objc_assign_global %t | count 3 +// RUN: grep objc_assign_strongCast %t | count 2 @interface A @end diff --git a/test/CodeGenObjC/objc2-write-barrier-5.m b/test/CodeGenObjC/objc2-write-barrier-5.m index babe26d55a53..373df0cc16b9 100644 --- a/test/CodeGenObjC/objc2-write-barrier-5.m +++ b/test/CodeGenObjC/objc2-write-barrier-5.m @@ -1,6 +1,9 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s // RUN: grep objc_assign_ivar %t | count 0 // RUN: grep objc_assign_strongCast %t | count 5 +// RUN: %clang_cc1 -x objective-c++ -triple x86_64-apple-darwin10 -fobjc-gc -emit-llvm -o %t %s +// RUN: grep objc_assign_ivar %t | count 0 +// RUN: grep objc_assign_strongCast %t | count 5 @interface TestUnarchiver { diff --git a/test/CodeGenObjC/objc2-write-barrier.m b/test/CodeGenObjC/objc2-write-barrier.m index 0934e0a46ac3..08b65deaa38d 100644 --- a/test/CodeGenObjC/objc2-write-barrier.m +++ b/test/CodeGenObjC/objc2-write-barrier.m @@ -1,6 +1,9 @@ // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -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-gc -emit-llvm -o %t %s +// RUN: grep -F '@objc_assign_global' %t | count 21 +// RUN: grep -F '@objc_assign_ivar' %t | count 11 typedef const struct __CFDictionary * CFDictionaryRef; @@ -49,9 +52,9 @@ struct_with_ids_t GlobalStructArray[10]; // The test cases -void *rhs = 0; +void* rhs = 0; -#define ASSIGNTEST(expr, global) expr = rhs +#define ASSIGNTEST(expr, global) expr = (typeof(expr))rhs int testGlobals() { // Everything in this function generates assign_global intercepts diff --git a/test/CodeGenObjC/property-complex.m b/test/CodeGenObjC/property-complex.m index 59200eba0905..071d0b1d24d2 100644 --- a/test/CodeGenObjC/property-complex.m +++ b/test/CodeGenObjC/property-complex.m @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -S -o - %s -// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -S -o - %s +// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -o %t %s @interface I0 { @public diff --git a/test/CodeGenObjC/protocols.m b/test/CodeGenObjC/protocols.m index 0f24a1cd1fc1..6dadb11273dc 100644 --- a/test/CodeGenObjC/protocols.m +++ b/test/CodeGenObjC/protocols.m @@ -1,8 +1,9 @@ -// RUN: %clang_cc1 -emit-llvm %s -o %t +// RUN: %clang_cc1 -emit-llvm-only %s void p(const char*, ...); @interface Root ++(int) maxValue; -(int) conformsTo: (id) x; @end @@ -48,3 +49,9 @@ int main() { return 0; } + +// rdar://problem/7992749 +typedef Root<P1> P1Object; +int test10() { + return [P1Object maxValue]; +} |
