r243018 - Add missing files for objc_boxable feature.

John McCall rjmccall at apple.com
Thu Jul 23 10:44:00 PDT 2015


> On Jul 23, 2015, at 7:53 AM, AlexDenisov <1101.debian at gmail.com> wrote:
> Initial patch was missing tests, because I didn’t ’svn-add’ new files.
> Can you please apply it on release_37 branch?
> 
> My apologies for this fault.

Approved for the branch.

John.

> 
>> On 23 Jul 2015, at 16:45, Alex Denisov <1101.debian at gmail.com> wrote:
>> 
>> Author: alexdenisov
>> Date: Thu Jul 23 09:45:41 2015
>> New Revision: 243018
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=243018&view=rev
>> Log:
>> Add missing files for objc_boxable feature.
>> 
>> Original patch [r240761] is missing all new files because of committer's mistake.
>> 
>> 
>> Added:
>>   cfe/trunk/test/CodeGenObjC/Inputs/nsvalue-boxed-expressions-support.h
>>   cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios-arc.m
>>   cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios.m
>>   cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac-arc.m
>>   cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac.m
>>   cfe/trunk/test/Lexer/has_attribute_objc_boxable.m
>>   cfe/trunk/test/Lexer/has_feature_boxed_nsvalue_expressions.m
>>   cfe/trunk/test/PCH/objc_boxable.m
>>   cfe/trunk/test/PCH/objc_boxable_record.h
>>   cfe/trunk/test/PCH/objc_boxable_record_attr.h
>>   cfe/trunk/test/SemaObjC/objc-boxed-expressions-nsvalue.m
>>   cfe/trunk/test/SemaObjCXX/objc-boxed-expressions-nsvalue.mm
>> 
>> Added: cfe/trunk/test/CodeGenObjC/Inputs/nsvalue-boxed-expressions-support.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/Inputs/nsvalue-boxed-expressions-support.h?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/CodeGenObjC/Inputs/nsvalue-boxed-expressions-support.h (added)
>> +++ cfe/trunk/test/CodeGenObjC/Inputs/nsvalue-boxed-expressions-support.h Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,63 @@
>> +#ifndef NSVALUE_BOXED_EXPRESSIONS_SUPPORT_H
>> +#define NSVALUE_BOXED_EXPRESSIONS_SUPPORT_H
>> +
>> +#define BOXABLE __attribute__((objc_boxable))
>> +
>> +typedef unsigned long NSUInteger;
>> +typedef double CGFloat;
>> +
>> +typedef struct BOXABLE _NSRange {
>> +    NSUInteger location;
>> +    NSUInteger length;
>> +} NSRange;
>> +
>> +typedef struct BOXABLE _NSPoint {
>> +    CGFloat x;
>> +    CGFloat y;
>> +} NSPoint;
>> +
>> +typedef struct BOXABLE _NSSize {
>> +    CGFloat width;
>> +    CGFloat height;
>> +} NSSize;
>> +
>> +typedef struct BOXABLE _NSRect {
>> +    NSPoint origin;
>> +    NSSize size;
>> +} NSRect;
>> +
>> +struct CGPoint {
>> +  CGFloat x;
>> +  CGFloat y;
>> +};
>> +typedef struct BOXABLE CGPoint CGPoint;
>> +
>> +struct CGSize {
>> +  CGFloat width;
>> +  CGFloat height;
>> +};
>> +typedef struct BOXABLE CGSize CGSize;
>> +
>> +struct CGRect {
>> +  CGPoint origin;
>> +  CGSize size;
>> +};
>> +typedef struct BOXABLE CGRect CGRect;
>> +
>> +struct NSEdgeInsets {
>> +  CGFloat top;
>> +  CGFloat left;
>> +  CGFloat bottom;
>> +  CGFloat right;
>> +};
>> +typedef struct BOXABLE NSEdgeInsets NSEdgeInsets;
>> +
>> + at interface NSValue
>> +
>> ++ (NSValue *)valueWithBytes:(const void *)value objCType:(const char *)type;
>> +
>> + at end
>> +
>> +NSRange getRange();
>> +
>> +#endif // NSVALUE_BOXED_EXPRESSIONS_SUPPORT_H
>> 
>> Added: cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios-arc.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios-arc.m?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios-arc.m (added)
>> +++ cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios-arc.m Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,126 @@
>> +// RUN: %clang_cc1 -I %S/Inputs -triple armv7-apple-ios8.0.0 -emit-llvm -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s
>> +
>> +#import "nsvalue-boxed-expressions-support.h"
>> +
>> +// CHECK:      [[CLASS:@.*]]        = external global %struct._class_t
>> +// CHECK:      [[NSVALUE:@.*]]      = {{.*}}[[CLASS]]{{.*}}
>> +// CHECK:      [[RANGE_STR:.*]]     = {{.*}}_NSRange=II{{.*}}
>> +// CHECK:      [[METH:@.*]]         = private global{{.*}}valueWithBytes:objCType:{{.*}}
>> +// CHECK:      [[VALUE_SEL:@.*]]    = {{.*}}[[METH]]{{.*}}
>> +// CHECK:      [[POINT_STR:.*]]     = {{.*}}CGPoint=dd{{.*}}
>> +// CHECK:      [[SIZE_STR:.*]]      = {{.*}}CGSize=dd{{.*}}
>> +// CHECK:      [[RECT_STR:.*]]      = {{.*}}CGRect={CGPoint=dd}{CGSize=dd}}{{.*}}
>> +// CHECK:      [[EDGE_STR:.*]]      = {{.*}}NSEdgeInsets=dddd{{.*}}
>> +
>> +// CHECK-LABEL: define void @doRange()
>> +void doRange() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSRange{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSRange{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSRange* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSRange ns_range = { .location = 0, .length = 42 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}})
>> +  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *range = @(ns_range);
>> +  // CHECK:      call void @objc_release
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doPoint()
>> +void doPoint() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.CGPoint{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.CGPoint{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.CGPoint* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.CGPoint* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.CGPoint* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  CGPoint cg_point = { .x = 42, .y = 24 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[POINT_STR]]{{.*}})
>> +  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *point = @(cg_point);
>> +  // CHECK:      call void @objc_release
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doSize()
>> +void doSize() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.CGSize{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.CGSize{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.CGSize* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.CGSize* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.CGSize* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  CGSize cg_size = { .width = 42, .height = 24 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[SIZE_STR]]{{.*}})
>> +  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *size = @(cg_size);
>> +  // CHECK:      call void @objc_release
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doRect()
>> +void doRect() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.CGRect{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.CGRect{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.CGRect* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.CGRect* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.CGRect* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  CGPoint cg_point = { .x = 42, .y = 24 };
>> +  CGSize cg_size = { .width = 42, .height = 24 };
>> +  CGRect cg_rect = { .origin = cg_point, .size = cg_size };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[RECT_STR]]{{.*}})
>> +  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *rect = @(cg_rect);
>> +  // CHECK:      call void @objc_release
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doNSEdgeInsets()
>> +void doNSEdgeInsets() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.NSEdgeInsets{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.NSEdgeInsets{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSEdgeInsets ns_edge_insets;
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[EDGE_STR]]{{.*}})
>> +  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *edge_insets = @(ns_edge_insets);
>> +  // CHECK:      call void @objc_release
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doRangeRValue()
>> +void doRangeRValue() {
>> +  // CHECK:     [[COERCE:%.*]]          = alloca %struct._NSRange{{.*}}
>> +  // CHECK:     [[RECV_PTR:%.*]]        = load {{.*}} [[NSVALUE]]
>> +  // CHECK:     call {{.*}} @getRange {{.*}} [[COERCE]]{{.*}}
>> +  // CHECK:     [[COERCE_CAST:%.*]]     = bitcast %struct._NSRange* [[COERCE]]{{.*}}
>> +  // CHECK:     [[SEL:%.*]]             = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:     [[RECV:%.*]]            = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  // CHECK:     call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[COERCE_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}})
>> +  // CHECK:     call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *range_rvalue = @(getRange());
>> +  // CHECK:     call void @objc_release
>> +  // CHECK:     ret void
>> +}
>> +
>> 
>> Added: cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios.m?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios.m (added)
>> +++ cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-ios.m Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,114 @@
>> +// RUN: %clang_cc1 -I %S/Inputs -triple armv7-apple-ios8.0.0 -emit-llvm -O2 -disable-llvm-optzns -o - %s | FileCheck %s
>> +
>> +#import "nsvalue-boxed-expressions-support.h"
>> +
>> +// CHECK:      [[CLASS:@.*]]        = external global %struct._class_t
>> +// CHECK:      [[NSVALUE:@.*]]      = {{.*}}[[CLASS]]{{.*}}
>> +// CHECK:      [[RANGE_STR:.*]]     = {{.*}}_NSRange=II{{.*}}
>> +// CHECK:      [[METH:@.*]]         = private global{{.*}}valueWithBytes:objCType:{{.*}}
>> +// CHECK:      [[VALUE_SEL:@.*]]    = {{.*}}[[METH]]{{.*}}
>> +// CHECK:      [[POINT_STR:.*]]     = {{.*}}CGPoint=dd{{.*}}
>> +// CHECK:      [[SIZE_STR:.*]]      = {{.*}}CGSize=dd{{.*}}
>> +// CHECK:      [[RECT_STR:.*]]      = {{.*}}CGRect={CGPoint=dd}{CGSize=dd}}{{.*}}
>> +// CHECK:      [[EDGE_STR:.*]]      = {{.*}}NSEdgeInsets=dddd{{.*}}
>> +
>> +// CHECK-LABEL: define void @doRange()
>> +void doRange() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSRange{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSRange{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSRange* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSRange ns_range = { .location = 0, .length = 42 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}})
>> +  NSValue *range = @(ns_range);
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doPoint()
>> +void doPoint() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.CGPoint{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.CGPoint{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.CGPoint* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.CGPoint* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.CGPoint* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  CGPoint cg_point = { .x = 42, .y = 24 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[POINT_STR]]{{.*}})
>> +  NSValue *point = @(cg_point);
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doSize()
>> +void doSize() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.CGSize{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.CGSize{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.CGSize* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.CGSize* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.CGSize* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  CGSize cg_size = { .width = 42, .height = 24 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[SIZE_STR]]{{.*}})
>> +  NSValue *size = @(cg_size);
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doRect()
>> +void doRect() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.CGRect{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.CGRect{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.CGRect* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.CGRect* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.CGRect* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  CGPoint cg_point = { .x = 42, .y = 24 };
>> +  CGSize cg_size = { .width = 42, .height = 24 };
>> +  CGRect cg_rect = { .origin = cg_point, .size = cg_size };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[RECT_STR]]{{.*}})
>> +  NSValue *rect = @(cg_rect);
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doNSEdgeInsets()
>> +void doNSEdgeInsets() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.NSEdgeInsets{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.NSEdgeInsets{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSEdgeInsets ns_edge_insets;
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[EDGE_STR]]{{.*}})
>> +  NSValue *edge_insets = @(ns_edge_insets);
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doRangeRValue()
>> +void doRangeRValue() {
>> +  // CHECK:     [[COERCE:%.*]]          = alloca %struct._NSRange{{.*}}
>> +  // CHECK:     [[RECV_PTR:%.*]]        = load {{.*}} [[NSVALUE]]
>> +  // CHECK:     call {{.*}} @getRange {{.*}} [[COERCE]]{{.*}}
>> +  // CHECK:     [[COERCE_CAST:%.*]]     = bitcast %struct._NSRange* [[COERCE]]{{.*}}
>> +  // CHECK:     [[SEL:%.*]]             = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:     [[RECV:%.*]]            = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  // CHECK:     call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[COERCE_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}})
>> +  NSValue *range_rvalue = @(getRange());
>> +  // CHECK: ret void
>> +}
>> +
>> 
>> Added: cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac-arc.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac-arc.m?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac-arc.m (added)
>> +++ cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac-arc.m Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,130 @@
>> +// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-macosx -emit-llvm -fobjc-arc -O2 -disable-llvm-optzns -o - %s | FileCheck %s
>> +
>> +#import "nsvalue-boxed-expressions-support.h"
>> +
>> +// CHECK:      [[CLASS:@.*]]        = external global %struct._class_t
>> +// CHECK:      [[NSVALUE:@.*]]      = {{.*}}[[CLASS]]{{.*}}
>> +// CHECK:      [[RANGE_STR:.*]]     = {{.*}}_NSRange=QQ{{.*}}
>> +// CHECK:      [[METH:@.*]]         = private global{{.*}}valueWithBytes:objCType:{{.*}}
>> +// CHECK:      [[VALUE_SEL:@.*]]    = {{.*}}[[METH]]{{.*}}
>> +// CHECK:      [[POINT_STR:.*]]     = {{.*}}_NSPoint=dd{{.*}}
>> +// CHECK:      [[SIZE_STR:.*]]      = {{.*}}_NSSize=dd{{.*}}
>> +// CHECK:      [[RECT_STR:.*]]      = {{.*}}_NSRect={_NSPoint=dd}{_NSSize=dd}}{{.*}}
>> +// CHECK:      [[EDGE_STR:.*]]      = {{.*}}NSEdgeInsets=dddd{{.*}}
>> +
>> +// CHECK-LABEL: define void @doRange()
>> +void doRange() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSRange{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSRange{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSRange* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSRange ns_range = { .location = 0, .length = 42 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}})
>> +  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *range = @(ns_range);
>> +  // CHECK:      call void @objc_release
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doPoint()
>> +void doPoint() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSPoint{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSPoint{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSPoint* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSPoint* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSPoint* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSPoint ns_point = { .x = 42, .y = 24 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[POINT_STR]]{{.*}})
>> +  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *point = @(ns_point);
>> +  // CHECK:      call void @objc_release
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doSize()
>> +void doSize() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSSize{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSSize{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSSize* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSSize* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSSize* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSSize ns_size = { .width = 42, .height = 24 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[SIZE_STR]]{{.*}})
>> +  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *size = @(ns_size);
>> +  // CHECK:      call void @objc_release
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doRect()
>> +void doRect() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSRect{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSRect{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSRect* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSRect* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSRect* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSPoint ns_point = { .x = 42, .y = 24 };
>> +  NSSize ns_size = { .width = 42, .height = 24 };
>> +  NSRect ns_rect = { .origin = ns_point, .size = ns_size };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[RECT_STR]]{{.*}})
>> +  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *rect = @(ns_rect);
>> +  // CHECK:      call void @objc_release
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doNSEdgeInsets()
>> +void doNSEdgeInsets() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.NSEdgeInsets{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.NSEdgeInsets{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSEdgeInsets ns_edge_insets;
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[EDGE_STR]]{{.*}})
>> +  // CHECK:      call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *edge_insets = @(ns_edge_insets);
>> +  // CHECK:      call void @objc_release
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doRangeRValue()
>> +void doRangeRValue() {
>> +  // CHECK:     [[COERCE:%.*]]          = alloca %struct._NSRange{{.*}}
>> +  // CHECK:     [[RECV_PTR:%.*]]        = load {{.*}} [[NSVALUE]]
>> +  // CHECK:     [[RVAL:%.*]]            = call {{.*}} @getRange()
>> +  // CHECK:     [[COERCE_CAST:%.*]]     = bitcast %struct._NSRange* [[COERCE]]{{.*}}
>> +  // CHECK:     [[COERCE_CAST_PTR:%.*]] = getelementptr {{.*}} [[COERCE_CAST]], {{.*}}
>> +  // CHECK:     [[EXTR_RVAL:%.*]]       = extractvalue {{.*}} [[RVAL]]{{.*}}
>> +  // CHECK:     store {{.*}}[[EXTR_RVAL]]{{.*}}[[COERCE_CAST_PTR]]{{.*}}
>> +  // CHECK:     [[COERCE_CAST:%.*]]     = bitcast %struct._NSRange* [[COERCE]]{{.*}}
>> +  // CHECK:     [[SEL:%.*]]             = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:     [[RECV:%.*]]            = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  // CHECK:     call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[COERCE_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}})
>> +  // CHECK:     call i8* @objc_retainAutoreleasedReturnValue
>> +  NSValue *range_rvalue = @(getRange());
>> +  // CHECK:     call void @objc_release
>> +  // CHECK:     ret void
>> +}
>> +
>> 
>> Added: cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac.m?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac.m (added)
>> +++ cfe/trunk/test/CodeGenObjC/nsvalue-objc-boxable-mac.m Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,118 @@
>> +// RUN: %clang_cc1 -I %S/Inputs -triple x86_64-apple-macosx -emit-llvm -O2 -disable-llvm-optzns -o - %s | FileCheck %s
>> +
>> +#import "nsvalue-boxed-expressions-support.h"
>> +
>> +// CHECK:      [[CLASS:@.*]]        = external global %struct._class_t
>> +// CHECK:      [[NSVALUE:@.*]]      = {{.*}}[[CLASS]]{{.*}}
>> +// CHECK:      [[RANGE_STR:.*]]     = {{.*}}_NSRange=QQ{{.*}}
>> +// CHECK:      [[METH:@.*]]         = private global{{.*}}valueWithBytes:objCType:{{.*}}
>> +// CHECK:      [[VALUE_SEL:@.*]]    = {{.*}}[[METH]]{{.*}}
>> +// CHECK:      [[POINT_STR:.*]]     = {{.*}}_NSPoint=dd{{.*}}
>> +// CHECK:      [[SIZE_STR:.*]]      = {{.*}}_NSSize=dd{{.*}}
>> +// CHECK:      [[RECT_STR:.*]]      = {{.*}}_NSRect={_NSPoint=dd}{_NSSize=dd}}{{.*}}
>> +// CHECK:      [[EDGE_STR:.*]]      = {{.*}}NSEdgeInsets=dddd{{.*}}
>> +
>> +// CHECK-LABEL: define void @doRange()
>> +void doRange() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSRange{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSRange{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSRange* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSRange* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSRange ns_range = { .location = 0, .length = 42 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}})
>> +  NSValue *range = @(ns_range);
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doPoint()
>> +void doPoint() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSPoint{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSPoint{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSPoint* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSPoint* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSPoint* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSPoint ns_point = { .x = 42, .y = 24 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[POINT_STR]]{{.*}})
>> +  NSValue *point = @(ns_point);
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doSize()
>> +void doSize() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSSize{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSSize{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSSize* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSSize* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSSize* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSSize ns_size = { .width = 42, .height = 24 };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8* {{.*}}[[SIZE_STR]]{{.*}})
>> +  NSValue *size = @(ns_size);
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doRect()
>> +void doRect() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct._NSRect{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct._NSRect{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct._NSRect* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct._NSRect* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct._NSRect* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSPoint ns_point = { .x = 42, .y = 24 };
>> +  NSSize ns_size = { .width = 42, .height = 24 };
>> +  NSRect ns_rect = { .origin = ns_point, .size = ns_size };
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[RECT_STR]]{{.*}})
>> +  NSValue *rect = @(ns_rect);
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doNSEdgeInsets()
>> +void doNSEdgeInsets() {
>> +  // CHECK:      [[LOCAL_VAR:%.*]]  = alloca %struct.NSEdgeInsets{{.*}}
>> +  // CHECK:      [[TEMP_VAR:%.*]]   = alloca %struct.NSEdgeInsets{{.*}}
>> +  // CHECK:      [[RECV_PTR:%.*]]   = load {{.*}} [[NSVALUE]]
>> +  // CHECK:      [[TEMP_CAST:%.*]]  = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[LOCAL_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[LOCAL_VAR]]{{.*}}
>> +  // CHECK:      call void @llvm.memcpy{{.*}} [[TEMP_CAST]]{{.*}} [[LOCAL_CAST]]{{.*}}
>> +  // CHECK:      [[PARAM_CAST:%.*]] = bitcast %struct.NSEdgeInsets* [[TEMP_VAR]]{{.*}}
>> +  // CHECK:      [[SEL:%.*]]        = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:      [[RECV:%.*]]       = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  NSEdgeInsets ns_edge_insets;
>> +  // CHECK:      call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[PARAM_CAST]], i8*{{.*}}[[EDGE_STR]]{{.*}})
>> +  NSValue *edge_insets = @(ns_edge_insets);
>> +  // CHECK:      ret void
>> +}
>> +
>> +// CHECK-LABEL: define void @doRangeRValue()
>> +void doRangeRValue() {
>> +  // CHECK:     [[COERCE:%.*]]          = alloca %struct._NSRange{{.*}}
>> +  // CHECK:     [[RECV_PTR:%.*]]        = load {{.*}} [[NSVALUE]]
>> +  // CHECK:     [[RVAL:%.*]]            = call {{.*}} @getRange()
>> +  // CHECK:     [[COERCE_CAST:%.*]]     = bitcast %struct._NSRange* [[COERCE]]{{.*}}
>> +  // CHECK:     [[COERCE_CAST_PTR:%.*]] = getelementptr {{.*}} [[COERCE_CAST]], {{.*}}
>> +  // CHECK:     [[EXTR_RVAL:%.*]]       = extractvalue {{.*}} [[RVAL]]{{.*}}
>> +  // CHECK:     store {{.*}}[[EXTR_RVAL]]{{.*}}[[COERCE_CAST_PTR]]{{.*}}
>> +  // CHECK:     [[COERCE_CAST:%.*]]     = bitcast %struct._NSRange* [[COERCE]]{{.*}}
>> +  // CHECK:     [[SEL:%.*]]             = load i8*, i8** [[VALUE_SEL]]
>> +  // CHECK:     [[RECV:%.*]]            = bitcast %struct._class_t* [[RECV_PTR]] to i8*
>> +  // CHECK:     call {{.*objc_msgSend.*}}(i8* [[RECV]], i8* [[SEL]], i8* [[COERCE_CAST]], i8* {{.*}}[[RANGE_STR]]{{.*}})
>> +  NSValue *range_rvalue = @(getRange());
>> +  // CHECK: ret void
>> +}
>> +
>> 
>> Added: cfe/trunk/test/Lexer/has_attribute_objc_boxable.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_attribute_objc_boxable.m?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/Lexer/has_attribute_objc_boxable.m (added)
>> +++ cfe/trunk/test/Lexer/has_attribute_objc_boxable.m Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,8 @@
>> +// RUN: %clang_cc1 -E %s -o - | FileCheck %s
>> +
>> +#if __has_attribute(objc_boxable)
>> +int has_objc_boxable_attribute();
>> +#endif
>> +
>> +// CHECK: has_objc_boxable_attribute
>> +
>> 
>> Added: cfe/trunk/test/Lexer/has_feature_boxed_nsvalue_expressions.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/has_feature_boxed_nsvalue_expressions.m?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/Lexer/has_feature_boxed_nsvalue_expressions.m (added)
>> +++ cfe/trunk/test/Lexer/has_feature_boxed_nsvalue_expressions.m Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,8 @@
>> +// RUN: %clang_cc1 -E %s -o - | FileCheck %s
>> +
>> +#if __has_feature(objc_boxed_nsvalue_expressions)
>> +int has_objc_boxed_nsvalue_expressions();
>> +#endif
>> +
>> +// CHECK: has_objc_boxed_nsvalue_expressions
>> +
>> 
>> Added: cfe/trunk/test/PCH/objc_boxable.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/objc_boxable.m?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/PCH/objc_boxable.m (added)
>> +++ cfe/trunk/test/PCH/objc_boxable.m Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,17 @@
>> +// Test objc_boxable update record
>> +
>> +// RUN: %clang_cc1 -x objective-c %S/objc_boxable_record.h -emit-pch -o %t1
>> +// RUN: %clang_cc1 -x objective-c %S/objc_boxable_record_attr.h -include-pch %t1 -emit-pch -o %t2
>> +// RUN: %clang_cc1 %s -include-pch %t2 -fsyntax-only -verify
>> +
>> +// expected-no-diagnostics
>> +
>> +__attribute__((objc_root_class))
>> + at interface NSValue
>> ++ (NSValue *)valueWithBytes:(const void *)bytes objCType:(const char *)type;
>> + at end
>> +
>> +void doStuff(struct boxable b) {
>> +  id v = @(b);
>> +}
>> +
>> 
>> Added: cfe/trunk/test/PCH/objc_boxable_record.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/objc_boxable_record.h?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/PCH/objc_boxable_record.h (added)
>> +++ cfe/trunk/test/PCH/objc_boxable_record.h Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,5 @@
>> +// used with objc_boxable.m test
>> +struct boxable {
>> +  int dummy;
>> +};
>> +
>> 
>> Added: cfe/trunk/test/PCH/objc_boxable_record_attr.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/objc_boxable_record_attr.h?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/PCH/objc_boxable_record_attr.h (added)
>> +++ cfe/trunk/test/PCH/objc_boxable_record_attr.h Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,3 @@
>> +// used with objc_boxable.m test
>> +typedef struct __attribute((objc_boxable)) boxable boxable;
>> +
>> 
>> Added: cfe/trunk/test/SemaObjC/objc-boxed-expressions-nsvalue.m
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/objc-boxed-expressions-nsvalue.m?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/SemaObjC/objc-boxed-expressions-nsvalue.m (added)
>> +++ cfe/trunk/test/SemaObjC/objc-boxed-expressions-nsvalue.m Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,101 @@
>> +// RUN: %clang_cc1  -fsyntax-only -triple x86_64-apple-macosx10.9 -verify %s
>> +
>> +#define BOXABLE __attribute__((objc_boxable))
>> +
>> +typedef struct BOXABLE _NSPoint {
>> +  int dummy;
>> +} NSPoint;
>> +
>> +typedef struct BOXABLE _NSSize {
>> +  int dummy;
>> +} NSSize;
>> +
>> +typedef struct BOXABLE _NSRect {
>> +  int dummy;
>> +} NSRect;
>> +
>> +typedef struct BOXABLE _CGPoint {
>> +  int dummy;
>> +} CGPoint;
>> +
>> +typedef struct BOXABLE _CGSize {
>> +  int dummy;
>> +} CGSize;
>> +
>> +typedef struct BOXABLE _CGRect {
>> +  int dummy;
>> +} CGRect;
>> +
>> +typedef struct BOXABLE _NSRange {
>> +  int dummy;
>> +} NSRange;
>> +
>> +struct _NSEdgeInsets {
>> +  int dummy;
>> +};
>> +
>> +typedef struct BOXABLE _NSEdgeInsets NSEdgeInsets;
>> +
>> +typedef struct _SomeStruct {
>> +  double d;
>> +} SomeStruct;
>> +
>> +typedef union BOXABLE _BoxableUnion {
>> +  int dummy;
>> +} BoxableUnion;
>> +
>> +void checkNSValueDiagnostic() {
>> +  NSRect rect;
>> +  id value = @(rect); // expected-error{{NSValue must be available to use Objective-C boxed expressions}}
>> +}
>> +
>> + at interface NSValue
>> ++ (NSValue *)valueWithBytes:(const void *)value objCType:(const char *)type;
>> + at end
>> +
>> +int main() {
>> +  NSPoint ns_point;
>> +  id ns_point_value = @(ns_point);
>> +
>> +  NSSize ns_size;
>> +  id ns_size_value = @(ns_size);
>> +
>> +  NSRect ns_rect;
>> +  id ns_rect_value = @(ns_rect);
>> +
>> +  CGPoint cg_point;
>> +  id cg_point_value = @(cg_point);
>> +
>> +  CGSize cg_size;
>> +  id cg_size_value = @(cg_size);
>> +
>> +  CGRect cg_rect;
>> +  id cg_rect_value = @(cg_rect);
>> +
>> +  NSRange ns_range;
>> +  id ns_range_value = @(ns_range);
>> +
>> +  NSEdgeInsets edge_insets;
>> +  id edge_insets_object = @(edge_insets);
>> +
>> +  BoxableUnion boxable_union;
>> +  id boxed_union = @(boxable_union);
>> +
>> +  SomeStruct s;
>> +  id err = @(s); // expected-error{{illegal type 'SomeStruct' (aka 'struct _SomeStruct') used in a boxed expression}}
>> +}
>> +
>> +CGRect getRect() {
>> +  CGRect r;
>> +  return r;
>> +}
>> +
>> +SomeStruct getSomeStruct() {
>> +  SomeStruct s;
>> +  return s;
>> +}
>> +
>> +void rvalue() {
>> +  id rv_rect = @(getRect());
>> +  id rv_some_struct = @(getSomeStruct()); // expected-error {{illegal type 'SomeStruct' (aka 'struct _SomeStruct') used in a boxed expression}}
>> +}
>> 
>> Added: cfe/trunk/test/SemaObjCXX/objc-boxed-expressions-nsvalue.mm
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/objc-boxed-expressions-nsvalue.mm?rev=243018&view=auto
>> ==============================================================================
>> --- cfe/trunk/test/SemaObjCXX/objc-boxed-expressions-nsvalue.mm (added)
>> +++ cfe/trunk/test/SemaObjCXX/objc-boxed-expressions-nsvalue.mm Thu Jul 23 09:45:41 2015
>> @@ -0,0 +1,118 @@
>> +// RUN: %clang_cc1  -fsyntax-only -triple x86_64-apple-macosx10.9 -verify %s
>> +
>> +#define BOXABLE __attribute__((objc_boxable))
>> +
>> +typedef struct BOXABLE _NSPoint {
>> +  int dummy;
>> +} NSPoint;
>> +
>> +typedef struct BOXABLE _NSSize {
>> +  int dummy;
>> +} NSSize;
>> +
>> +typedef struct BOXABLE _NSRect {
>> +  int dummy;
>> +} NSRect;
>> +
>> +typedef struct BOXABLE _CGPoint {
>> +  int dummy;
>> +} CGPoint;
>> +
>> +typedef struct BOXABLE _CGSize {
>> +  int dummy;
>> +} CGSize;
>> +
>> +typedef struct BOXABLE _CGRect {
>> +  int dummy;
>> +} CGRect;
>> +
>> +typedef struct BOXABLE _NSRange {
>> +  int dummy;
>> +} NSRange;
>> +
>> +typedef struct BOXABLE _NSEdgeInsets {
>> +  int dummy;
>> +} NSEdgeInsets;
>> +
>> +typedef struct BOXABLE _NSEdgeInsets NSEdgeInsets;
>> +
>> +typedef struct _SomeStruct {
>> +  double d;
>> +} SomeStruct;
>> +
>> +struct BOXABLE NonTriviallyCopyable {
>> +  double d;
>> +  NonTriviallyCopyable() {}
>> +  NonTriviallyCopyable(const NonTriviallyCopyable &obj) {}
>> +};
>> +
>> +void checkNSValueDiagnostic() {
>> +  NSRect rect;
>> +  id value = @(rect); // expected-error{{NSValue must be available to use Objective-C boxed expressions}}
>> +}
>> +
>> + at interface NSValue
>> ++ (NSValue *)valueWithBytes:(const void *)value objCType:(const char *)type;
>> + at end
>> +
>> +int main() {
>> +  NSPoint ns_point;
>> +  id ns_point_value = @(ns_point);
>> +
>> +  NSSize ns_size;
>> +  id ns_size_value = @(ns_size);
>> +
>> +  NSRect ns_rect;
>> +  id ns_rect_value = @(ns_rect);
>> +
>> +  CGPoint cg_point;
>> +  id cg_point_value = @(cg_point);
>> +
>> +  CGSize cg_size;
>> +  id cg_size_value = @(cg_size);
>> +
>> +  CGRect cg_rect;
>> +  id cg_rect_value = @(cg_rect);
>> +
>> +  NSRange ns_range;
>> +  id ns_range_value = @(ns_range);
>> +
>> +  NSEdgeInsets edge_insets;
>> +  id edge_insets_object = @(edge_insets);
>> +
>> +  SomeStruct s;
>> +  id err = @(s); // expected-error{{illegal type 'SomeStruct' (aka '_SomeStruct') used in a boxed expression}}
>> +
>> +  NonTriviallyCopyable ntc;
>> +  id ntcErr = @(ntc); // expected-error{{non-trivially copyable type 'NonTriviallyCopyable' cannot be used in a boxed expression}}
>> +}
>> +
>> +CGRect getRect() {
>> +  CGRect r;
>> +  return r;
>> +}
>> +
>> +SomeStruct getSomeStruct() {
>> +  SomeStruct s;
>> +  return s;
>> +}
>> +
>> +void rvalue() {
>> +  id rv_rect = @(getRect());
>> +  id rv_some_struct = @(getSomeStruct()); // expected-error {{illegal type 'SomeStruct' (aka '_SomeStruct') used in a boxed expression}}
>> +}
>> +
>> +template <class T> id box(T value) { return @(value); } // expected-error{{non-trivially copyable type 'NonTriviallyCopyable' cannot be used in a boxed expression}}
>> +void test_template_1(NSRect rect, NonTriviallyCopyable ntc) {
>> + id x = box(rect);
>> + id y = box(ntc);  // expected-note{{in instantiation of function template specialization 'box<NonTriviallyCopyable>' requested here}}
>> +}
>> +
>> +template <unsigned i> id boxRect(NSRect rect) { return @(rect); }
>> +template <unsigned i> id boxNTC(NonTriviallyCopyable ntc) { return @(ntc); }  // expected-error{{non-trivially copyable type 'NonTriviallyCopyable' cannot be used in a boxed expression}}
>> +void test_template_2(NSRect rect, NonTriviallyCopyable ntc) {
>> + id x = boxRect<0>(rect);
>> + id y = boxNTC<0>(ntc);
>> +}
>> +
>> +
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 





More information about the cfe-commits mailing list