diff options
Diffstat (limited to 'test/CodeGenObjC')
-rw-r--r-- | test/CodeGenObjC/assign.m | 36 | ||||
-rw-r--r-- | test/CodeGenObjC/bitfield_encoding.m | 12 | ||||
-rw-r--r-- | test/CodeGenObjC/blocks-5.m | 37 | ||||
-rw-r--r-- | test/CodeGenObjC/category-class.m | 17 | ||||
-rw-r--r-- | test/CodeGenObjC/dot-syntax-2.m | 27 | ||||
-rw-r--r-- | test/CodeGenObjC/exceptions.m | 29 | ||||
-rw-r--r-- | test/CodeGenObjC/metadata_symbols.m | 4 | ||||
-rw-r--r-- | test/CodeGenObjC/property-category-impl.m | 20 |
8 files changed, 176 insertions, 6 deletions
diff --git a/test/CodeGenObjC/assign.m b/test/CodeGenObjC/assign.m new file mode 100644 index 0000000..87e3834 --- /dev/null +++ b/test/CodeGenObjC/assign.m @@ -0,0 +1,36 @@ +// RUN: %clang_cc1 -triple x86_64 -emit-llvm -o - %s | FileCheck %s + +struct s0 { + int x; +}; + +@interface C0 +@property int x0; +@property _Complex int x1; +@property struct s0 x2; +@end + +// Check that we get exactly the message sends we expect, and no more. +// +// CHECK: define void @f0 +void f0(C0 *a) { +// CHECK: objc_msgSend + int l0 = (a.x0 = 1); + +// CHECK: objc_msgSend + _Complex int l1 = (a.x1 = 1); + +// CHECK: objc_msgSend + struct s0 l2 = (a.x2 = (struct s0) { 1 }); + +// CHECK: objc_msgSend +// CHECK: objc_msgSend + int l3 = (a.x0 += 1); + +// CHECK: objc_msgSend +// CHECK: objc_msgSend + _Complex int l4 = (a.x1 += 1); + +// CHECK-NOT: objc_msgSend +// CHECK: } +} diff --git a/test/CodeGenObjC/bitfield_encoding.m b/test/CodeGenObjC/bitfield_encoding.m new file mode 100644 index 0000000..03cf9bf --- /dev/null +++ b/test/CodeGenObjC/bitfield_encoding.m @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm -o %t %s +// RUN: grep "ib1b14" %t | count 1 +// RUN: %clang_cc1 -triple i386-unknown-unknown -fgnu-runtime -emit-llvm -o %t %s +// RUN: grep "ib32i1b33i14" %t | count 1 + +struct foo{ + int a; + int b:1; + int c:14; +}; + +const char *encoding = @encode(struct foo); diff --git a/test/CodeGenObjC/blocks-5.m b/test/CodeGenObjC/blocks-5.m new file mode 100644 index 0000000..2d48b46 --- /dev/null +++ b/test/CodeGenObjC/blocks-5.m @@ -0,0 +1,37 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -emit-llvm -fblocks -o %t %s + +// rdar: // 8064140 + +@interface IDEWorkspaceDocument +{ + id _defaultEditorStateTree; +} +- (void)enumerateKeysAndObjectsUsingBlock:(void (^)(id key, id obj, unsigned char *stop))block ; +@end + + + +int foo(); +extern void DVT (volatile const void * object, volatile const void * selector, const char * functionName); +@implementation IDEWorkspaceDocument + +- (void)stateSavingDefaultEditorStatesForURLs { + [_defaultEditorStateTree enumerateKeysAndObjectsUsingBlock:^(id identifier, id urlsToEditorStates, unsigned char *stop) { + do{ +if (foo() ) + DVT(&self,&_cmd,__PRETTY_FUNCTION__); + +}while(0); + + do{ + DVT(&self,&_cmd,__PRETTY_FUNCTION__); + }while(0); + + + }]; + +} + +- (void)enumerateKeysAndObjectsUsingBlock:(void (^)(id key, id obj, unsigned char *stop))block {} + +@end diff --git a/test/CodeGenObjC/category-class.m b/test/CodeGenObjC/category-class.m new file mode 100644 index 0000000..22d1973 --- /dev/null +++ b/test/CodeGenObjC/category-class.m @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -triple i386-apple-darwin9 -emit-llvm -o - %s | FileCheck %s +// PR7431 + +// CHECK: module asm "\09.lazy_reference .objc_class_name_A" +// CHECK: module asm "\09.objc_category_name_A_foo=0" +// CHECK: module asm "\09.globl .objc_category_name_A_foo" + +@interface A +@end +@interface A(foo) +- (void)foo_myStuff; +@end +@implementation A(foo) +- (void)foo_myStuff { +} +@end + diff --git a/test/CodeGenObjC/dot-syntax-2.m b/test/CodeGenObjC/dot-syntax-2.m new file mode 100644 index 0000000..020868a --- /dev/null +++ b/test/CodeGenObjC/dot-syntax-2.m @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -emit-llvm -o %t %s +// rdar: // 8062778 + +@interface NSDictionary @end + +@interface NSMutableDictionary : NSDictionary +@end + +@interface MutableMyClass +- (NSMutableDictionary *)myDict; +- (void)setMyDict:(NSDictionary *)myDict; + +- (NSMutableDictionary *)myLang; +- (void)setMyLang:(NSDictionary *)myLang; +@end + +@interface AnotherClass @end + +@implementation AnotherClass +- (void)foo +{ + MutableMyClass * myObject; + NSDictionary * newDict; + myObject.myDict = newDict; + myObject.myLang = newDict; +} +@end diff --git a/test/CodeGenObjC/exceptions.m b/test/CodeGenObjC/exceptions.m index a74dee9..5be6959 100644 --- a/test/CodeGenObjC/exceptions.m +++ b/test/CodeGenObjC/exceptions.m @@ -1,11 +1,8 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fexceptions -O2 -o - %s | FileCheck %s // // <rdar://problem/7471679> [irgen] [eh] Exception code built with clang (x86_64) crashes // Just check that we don't emit any dead blocks. -// -// RUN: grep 'No predecessors' %t | count 0 - @interface NSArray @end void f0() { @try { @@ -16,3 +13,27 @@ void f0() { } @catch (id e) { } } + +// CHECK: define void @f1() +void f1() { + extern void foo(void); + + while (1) { + // CHECK: call void @objc_exception_try_enter + // CHECK-NEXT: getelementptr + // CHECK-NEXT: call i32 @_setjmp( + // CHECK-NEXT: icmp + // CHECK-NEXT: br i1 + @try { + // CHECK: call void @foo() + foo(); + // CHECK: call void @objc_exception_try_exit + // CHECK-NEXT: ret void + + // CHECK: call i8* @objc_exception_extract + // CHECK-NEXT: ret void + } @finally { + break; + } + } +} diff --git a/test/CodeGenObjC/metadata_symbols.m b/test/CodeGenObjC/metadata_symbols.m index 921168c..59441e5 100644 --- a/test/CodeGenObjC/metadata_symbols.m +++ b/test/CodeGenObjC/metadata_symbols.m @@ -33,8 +33,8 @@ // CHECK-ARMV6: @"OBJC_EHTYPE_$_EH2" = external global // CHECK-ARMV6: @"OBJC_EHTYPE_$_EH3" = global {{.*}}, section "__DATA,__objc_const", align 4 // CHECK-ARMV6: @"\01L_OBJC_LABEL_CLASS_$" = internal global {{.*}}, section "__DATA, __objc_classlist, regular, no_dead_strip", align 4 -// CHECK-ARMV6: define internal arm_apcscc void @"\01-[A im0]" -// CHECK-ARMV6: define internal arm_apcscc void @"\01-[A(Cat) im1]" +// CHECK-ARMV6: define internal void @"\01-[A im0]" +// CHECK-ARMV6: define internal void @"\01-[A(Cat) im1]" @interface A @end diff --git a/test/CodeGenObjC/property-category-impl.m b/test/CodeGenObjC/property-category-impl.m new file mode 100644 index 0000000..80a18cb --- /dev/null +++ b/test/CodeGenObjC/property-category-impl.m @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fobjc-nonfragile-abi -emit-llvm -o - %s | FileCheck %s + +// rdar : // 8093297 + +@interface Foo @end + +@protocol Proto +@property (readonly) int proto_property; +@end + +@interface Foo (Category) <Proto> @end + +@implementation Foo (Category) +-(int)proto_property { return 0; } +@end + + +// CHECK: l_OBJC_$_PROP_LIST_Foo_$_Category" = internal global +// CHECK: l_OBJC_$_CATEGORY_Foo_$_Category" = internal global +// CHECK: l_OBJC_$_PROP_LIST_Foo_$_Category |