Do not assign the hidden field when processing init list initialization for objective c

Reviewed By: dulmarod

Differential Revision: D5394094

fbshipit-source-id: 77bc90a
master
Jia Chen 8 years ago committed by Facebook Github Bot
parent 1531a3d538
commit 0b641edaac

@ -753,7 +753,9 @@ let var_or_zero_in_init_list tenv e typ ~return_zero =
match Tenv.lookup tenv tn with
| Some {fields}
-> let lh_exprs =
List.map ~f:(fun (fieldname, _, _) -> Exp.Lfield (e, fieldname, typ)) fields
List.filter_map fields ~f:(fun (fieldname, _, _) ->
if Typ.Fieldname.is_hidden fieldname then None
else Some (Exp.Lfield (e, fieldname, typ)) )
in
let lh_types = List.map ~f:(fun (_, fieldtype, _) -> fieldtype) fields in
let exp_types = zip lh_exprs lh_types in

@ -8,6 +8,7 @@
*/
#import <Foundation/NSObject.h>
#import <UIKit/UIKit.h>
int main() {
int z;
@ -23,3 +24,7 @@ int test() {
C* c2 = [C alloc];
C* a[3] = {[c1 init], c1, c2};
}
CGAffineTransform struct_init_test() {
return (CGAffineTransform){.a = -1, .b = 0, .c = -0, .d = -1};
}

@ -1,33 +1,44 @@
/* @generated */
digraph iCFG {
"main.fad58de7366495db4650cfefac2fcd61_1" [label="1: Start main\nFormals: \nLocals: a:int[3*32][2*96] z:int \n DECLARE_LOCALS(&return,&a,&z); [line 12]\n " color=yellow style=filled]
"main.fad58de7366495db4650cfefac2fcd61_1" [label="1: Start main\nFormals: \nLocals: a:int[3*32][2*96] z:int \n DECLARE_LOCALS(&return,&a,&z); [line 13]\n " color=yellow style=filled]
"main.fad58de7366495db4650cfefac2fcd61_1" -> "main.fad58de7366495db4650cfefac2fcd61_3" ;
"main.fad58de7366495db4650cfefac2fcd61_2" [label="2: Exit main \n " color=yellow style=filled]
"main.fad58de7366495db4650cfefac2fcd61_3" [label="3: DeclStmt \n n$0=*&z:int [line 14]\n *&a[0][0]:int=(n$0 + 1) [line 14]\n *&a[0][1]:int=2 [line 14]\n *&a[0][2]:int=3 [line 14]\n *&a[1][0]:int=5 [line 14]\n *&a[1][1]:int=6 [line 14]\n *&a[1][2]:int=7 [line 14]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_3" [label="3: DeclStmt \n n$0=*&z:int [line 15]\n *&a[0][0]:int=(n$0 + 1) [line 15]\n *&a[0][1]:int=2 [line 15]\n *&a[0][2]:int=3 [line 15]\n *&a[1][0]:int=5 [line 15]\n *&a[1][1]:int=6 [line 15]\n *&a[1][2]:int=7 [line 15]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_3" -> "main.fad58de7366495db4650cfefac2fcd61_2" ;
"test.098f6bcd4621d373cade4e832627b4f6_1" [label="1: Start test\nFormals: \nLocals: a:C*[3*64] c2:C* c1:C* \n DECLARE_LOCALS(&return,&a,&c2,&c1); [line 21]\n " color=yellow style=filled]
"test.098f6bcd4621d373cade4e832627b4f6_1" [label="1: Start test\nFormals: \nLocals: a:C*[3*64] c2:C* c1:C* \n DECLARE_LOCALS(&return,&a,&c2,&c1); [line 22]\n " color=yellow style=filled]
"test.098f6bcd4621d373cade4e832627b4f6_1" -> "test.098f6bcd4621d373cade4e832627b4f6_5" ;
"test.098f6bcd4621d373cade4e832627b4f6_2" [label="2: Exit test \n " color=yellow style=filled]
"test.098f6bcd4621d373cade4e832627b4f6_3" [label="3: DeclStmt \n n$2=*&c1:C* [line 24]\n n$3=_fun_NSObject_init(n$2:C*) virtual [line 24]\n n$1=*&c1:C* [line 24]\n n$0=*&c2:C* [line 24]\n *&a[0]:C*=n$3 [line 24]\n *&a[1]:C*=n$1 [line 24]\n *&a[2]:C*=n$0 [line 24]\n " shape="box"]
"test.098f6bcd4621d373cade4e832627b4f6_3" [label="3: DeclStmt \n n$2=*&c1:C* [line 25]\n n$3=_fun_NSObject_init(n$2:C*) virtual [line 25]\n n$1=*&c1:C* [line 25]\n n$0=*&c2:C* [line 25]\n *&a[0]:C*=n$3 [line 25]\n *&a[1]:C*=n$1 [line 25]\n *&a[2]:C*=n$0 [line 25]\n " shape="box"]
"test.098f6bcd4621d373cade4e832627b4f6_3" -> "test.098f6bcd4621d373cade4e832627b4f6_2" ;
"test.098f6bcd4621d373cade4e832627b4f6_4" [label="4: DeclStmt \n n$4=_fun___objc_alloc_no_fail(sizeof(C):unsigned long) [line 23]\n *&c2:C*=n$4 [line 23]\n " shape="box"]
"test.098f6bcd4621d373cade4e832627b4f6_4" [label="4: DeclStmt \n n$4=_fun___objc_alloc_no_fail(sizeof(C):unsigned long) [line 24]\n *&c2:C*=n$4 [line 24]\n " shape="box"]
"test.098f6bcd4621d373cade4e832627b4f6_4" -> "test.098f6bcd4621d373cade4e832627b4f6_3" ;
"test.098f6bcd4621d373cade4e832627b4f6_5" [label="5: DeclStmt \n n$5=_fun___objc_alloc_no_fail(sizeof(C):unsigned long) [line 22]\n *&c1:C*=n$5 [line 22]\n " shape="box"]
"test.098f6bcd4621d373cade4e832627b4f6_5" [label="5: DeclStmt \n n$5=_fun___objc_alloc_no_fail(sizeof(C):unsigned long) [line 23]\n *&c1:C*=n$5 [line 23]\n " shape="box"]
"test.098f6bcd4621d373cade4e832627b4f6_5" -> "test.098f6bcd4621d373cade4e832627b4f6_4" ;
"struct_init_test.b3909a459f16e15611cc425c52c74b0c_1" [label="1: Start struct_init_test\nFormals: __return_param:CGAffineTransform*\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled]
"struct_init_test.b3909a459f16e15611cc425c52c74b0c_1" -> "struct_init_test.b3909a459f16e15611cc425c52c74b0c_3" ;
"struct_init_test.b3909a459f16e15611cc425c52c74b0c_2" [label="2: Exit struct_init_test \n " color=yellow style=filled]
"struct_init_test.b3909a459f16e15611cc425c52c74b0c_3" [label="3: Return Stmt \n n$0=*&__return_param:CGAffineTransform* [line 29]\n *n$0.a:double=-1 [line 29]\n *n$0.b:double=0 [line 29]\n *n$0.c:double=-0 [line 29]\n *n$0.d:double=-1 [line 29]\n *n$0.tx:double=0.000000 [line 29]\n *n$0.ty:double=0.000000 [line 29]\n n$1=*n$0:CGAffineTransform [line 29]\n " shape="box"]
"struct_init_test.b3909a459f16e15611cc425c52c74b0c_3" -> "struct_init_test.b3909a459f16e15611cc425c52c74b0c_2" ;
}

Loading…
Cancel
Save