summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenObjC/parameterized_classes.m
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CodeGenObjC/parameterized_classes.m')
-rw-r--r--clang/test/CodeGenObjC/parameterized_classes.m63
1 files changed, 63 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjC/parameterized_classes.m b/clang/test/CodeGenObjC/parameterized_classes.m
new file mode 100644
index 00000000000..1d8e9a25993
--- /dev/null
+++ b/clang/test/CodeGenObjC/parameterized_classes.m
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fblocks -fobjc-arc -emit-llvm -o - %s | FileCheck %s
+
+// Parameterized classes have no effect on code generation; this test
+// mainly verifies that CodeGen doesn't assert when substituted types
+// in uses of methods don't line up exactly with the parameterized
+// types in the method declarations due to type erasure. "Not crash"
+// is the only interesting criteria here.
+
+@protocol NSObject
+@end
+
+@protocol NSCopying
+@end
+
+__attribute__((objc_root_class))
+@interface NSObject <NSObject>
+@end
+
+@interface NSString : NSObject <NSCopying>
+@end
+
+@interface NSMutableArray<T> : NSObject <NSCopying>
+@property (copy,nonatomic) T firstObject;
+- (void)addObject:(T)object;
+- (void)sortWithFunction:(int (*)(T, T))function;
+- (void)getObjects:(T __strong *)objects length:(unsigned*)length;
+@end
+
+NSString *getFirstObjectProp(NSMutableArray<NSString *> *array) {
+ return array.firstObject;
+}
+
+NSString *getFirstObjectMethod(NSMutableArray<NSString *> *array) {
+ return [array firstObject];
+}
+
+void addObject(NSMutableArray<NSString *> *array, NSString *obj) {
+ [array addObject: obj];
+}
+
+int compareStrings(NSString *x, NSString *y) { return 0; }
+int compareBlocks(NSString * (^x)(NSString *),
+ NSString * (^y)(NSString *)) { return 0; }
+
+void sortTest(NSMutableArray<NSString *> *array,
+ NSMutableArray<NSString * (^)(NSString *)> *array2) {
+ [array sortWithFunction: &compareStrings];
+ [array2 sortWithFunction: &compareBlocks];
+}
+
+void getObjectsTest(NSMutableArray<NSString *> *array) {
+ NSString * __strong *objects;
+ unsigned length;
+ [array getObjects: objects length: &length];
+}
+
+void printMe(NSString *name) { }
+
+// CHECK-LABEL: define void @blockTest
+void blockTest(NSMutableArray<void (^)(void)> *array, NSString *name) {
+ // CHECK: call i8* @objc_retainBlock
+ [array addObject: ^ { printMe(name); }];
+}
OpenPOWER on IntegriCloud