1f4a2713aSLionel Sambuc// RUN: %clang_cc1 -emit-llvm -triple x86_64-apple-darwin -o - %s | FileCheck %s 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuctypedef unsigned int size_t; 4f4a2713aSLionel Sambuc@protocol P @end 5f4a2713aSLionel Sambuc 6f4a2713aSLionel Sambuc@interface NSMutableArray 7f4a2713aSLionel Sambuc- (id)objectAtIndexedSubscript:(size_t)index; 8f4a2713aSLionel Sambuc- (void)setObject:(id)object atIndexedSubscript:(size_t)index; 9f4a2713aSLionel Sambuc@end 10f4a2713aSLionel Sambuc 11f4a2713aSLionel Sambuc@interface NSMutableDictionary 12f4a2713aSLionel Sambuc- (id)objectForKeyedSubscript:(id)key; 13f4a2713aSLionel Sambuc- (void)setObject:(id)object forKeyedSubscript:(id)key; 14f4a2713aSLionel Sambuc@end 15f4a2713aSLionel Sambuc 16f4a2713aSLionel Sambucint main() { 17f4a2713aSLionel Sambuc NSMutableArray *array; 18f4a2713aSLionel Sambuc id val; 19f4a2713aSLionel Sambuc 20f4a2713aSLionel Sambuc id oldObject = array[10]; 21f4a2713aSLionel Sambuc// CHECK: [[ARR:%.*]] = load {{%.*}} [[array:%.*]], align 8 22*0a6a1f1dSLionel Sambuc// CHECK-NEXT: [[SEL:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_ 23f4a2713aSLionel Sambuc// CHECK-NEXT: [[ARRC:%.*]] = bitcast {{%.*}} [[ARR]] to i8* 24f4a2713aSLionel Sambuc// CHECK-NEXT: [[CALL:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i32)*)(i8* [[ARRC]], i8* [[SEL]], i32 10) 25f4a2713aSLionel Sambuc// CHECK-NEXT: store i8* [[CALL]], i8** [[OLDOBJ:%.*]], align 8 26f4a2713aSLionel Sambuc 27f4a2713aSLionel Sambuc val = (array[10] = oldObject); 28f4a2713aSLionel Sambuc// CHECK: [[THREE:%.*]] = load {{%.*}} [[array:%.*]], align 8 29f4a2713aSLionel Sambuc// CHECK-NEXT: [[FOUR:%.*]] = load i8** [[oldObject:%.*]], align 8 30*0a6a1f1dSLionel Sambuc// CHECK-NEXT: [[FIVE:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_2 31f4a2713aSLionel Sambuc// CHECK-NEXT: [[SIX:%.*]] = bitcast {{%.*}} [[THREE]] to i8* 32f4a2713aSLionel Sambuc// CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*, i32)*)(i8* [[SIX]], i8* [[FIVE]], i8* [[FOUR]], i32 10) 33f4a2713aSLionel Sambuc// CHECK-NEXT: store i8* [[FOUR]], i8** [[val:%.*]] 34f4a2713aSLionel Sambuc 35f4a2713aSLionel Sambuc NSMutableDictionary *dictionary; 36f4a2713aSLionel Sambuc id key; 37f4a2713aSLionel Sambuc id newObject; 38f4a2713aSLionel Sambuc oldObject = dictionary[key]; 39f4a2713aSLionel Sambuc// CHECK: [[SEVEN:%.*]] = load {{%.*}} [[DICTIONARY:%.*]], align 8 40f4a2713aSLionel Sambuc// CHECK-NEXT: [[EIGHT:%.*]] = load i8** [[KEY:%.*]], align 8 41*0a6a1f1dSLionel Sambuc// CHECK-NEXT: [[TEN:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_4 42f4a2713aSLionel Sambuc// CHECK-NEXT: [[ELEVEN:%.*]] = bitcast {{%.*}} [[SEVEN]] to i8* 43f4a2713aSLionel Sambuc// CHECK-NEXT: [[CALL1:%.*]] = call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*, i8*)*)(i8* [[ELEVEN]], i8* [[TEN]], i8* [[EIGHT]]) 44f4a2713aSLionel Sambuc// CHECK-NEXT: store i8* [[CALL1]], i8** [[oldObject:%.*]], align 8 45f4a2713aSLionel Sambuc 46f4a2713aSLionel Sambuc 47f4a2713aSLionel Sambuc val = (dictionary[key] = newObject); 48f4a2713aSLionel Sambuc// CHECK: [[TWELVE:%.*]] = load {{%.*}} [[DICTIONARY]], align 8 49f4a2713aSLionel Sambuc// CHECK-NEXT: [[THIRTEEN:%.*]] = load i8** [[KEY]], align 8 50f4a2713aSLionel Sambuc// CHECK-NEXT: [[FOURTEEN:%.*]] = load i8** [[NEWOBJECT:%.*]], align 8 51*0a6a1f1dSLionel Sambuc// CHECK-NEXT: [[SIXTEEN:%.*]] = load i8** @OBJC_SELECTOR_REFERENCES_6 52f4a2713aSLionel Sambuc// CHECK-NEXT: [[SEVENTEEN:%.*]] = bitcast {{%.*}} [[TWELVE]] to i8* 53f4a2713aSLionel Sambuc// CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*, i8*)*)(i8* [[SEVENTEEN]], i8* [[SIXTEEN]], i8* [[FOURTEEN]], i8* [[THIRTEEN]]) 54f4a2713aSLionel Sambuc// CHECK-NEXT: store i8* [[FOURTEEN]], i8** [[val:%.*]] 55f4a2713aSLionel Sambuc} 56f4a2713aSLionel Sambuc 57