Update facebook clang plugin after adding more info about ObjC properties

Reviewed By: akotulski

Differential Revision: D2729019

fb-gh-sync-id: ab67fde
master
Dulma Rodriguez 9 years ago committed by facebook-github-bot-5
parent 47c0f36156
commit 4b82e208ff

@ -1 +1 @@
Subproject commit 48b57c1e897bf70fb2aab68e95628c4c7de42570
Subproject commit b329dde55a6dfe5cb58c861a5d702f3a99fd91e9

@ -219,10 +219,10 @@ struct
| `Unsafe_unretained, `Unsafe_unretained -> 0
| `Unsafe_unretained, _ -> -1
| _, `Unsafe_unretained -> 1
| `Getter _, `Getter _ -> 0
| `Getter _, _ -> -1
| _, `Getter _ -> 1
| `Setter _, `Setter _ -> 0
| `ExplicitGetter, `ExplicitGetter -> 0
| `ExplicitGetter, _ -> -1
| _, `ExplicitGetter -> 1
| `ExplicitSetter, `ExplicitSetter -> 0
let property_attribute_eq att1 att2 =
property_attribute_compare att1 att2 = 0
@ -297,6 +297,11 @@ struct
| Some decl_ptr -> get_decl decl_ptr
| None -> None
let get_decl_opt_with_decl_ref decl_ref_opt =
match decl_ref_opt with
| Some decl_ref -> get_decl decl_ref.Clang_ast_t.dr_decl_pointer
| None -> None
let update_sil_types_map type_ptr sil_type =
CFrontend_config.sil_types_map :=
Clang_ast_types.TypePointerMap.add type_ptr sil_type !CFrontend_config.sil_types_map

@ -52,12 +52,6 @@ sig
val property_attribute_eq : Clang_ast_t.property_attribute -> Clang_ast_t.property_attribute -> bool
val getter_attribute_opt : Clang_ast_t.property_attribute list ->
Clang_ast_t.named_decl_info option
val setter_attribute_opt : Clang_ast_t.property_attribute list ->
Clang_ast_t.named_decl_info option
val get_memory_management_attributes : unit -> Clang_ast_t.property_attribute list
val is_retain : Clang_ast_t.property_attribute option -> bool
@ -81,6 +75,8 @@ sig
val get_decl_opt : Clang_ast_t.pointer option -> Clang_ast_t.decl option
val get_decl_opt_with_decl_ref : Clang_ast_t.decl_ref option -> Clang_ast_t.decl option
val update_sil_types_map : Clang_ast_t.type_ptr -> Sil.typ -> unit
val update_enum_map : Clang_ast_t.pointer -> Sil.exp -> unit

@ -54,7 +54,7 @@ sig
val replace_property : property_key -> property_type -> unit
val add_property : property_key -> Clang_ast_t.type_ptr -> Clang_ast_t.property_attribute list ->
val add_property : property_key -> Clang_ast_t.type_ptr -> Clang_ast_t.obj_c_property_decl_info ->
Clang_ast_t.decl_info -> unit
val print_property_table : unit -> unit
@ -142,23 +142,23 @@ struct
else properties in
PropertyTableHash.fold find_properties property_table []
let get_getter_name prop_name attributes =
match Ast_utils.getter_attribute_opt attributes with
| Some name -> name.Clang_ast_t.ni_name
| None -> prop_name.Clang_ast_t.ni_name
let get_setter_name prop_name attributes =
let open Clang_ast_t in
match Ast_utils.setter_attribute_opt attributes with
| Some name -> name.Clang_ast_t.ni_name
| None -> "set" ^ (String.capitalize prop_name.ni_name) ^ ":"
let add_property (curr_class, property_name) tp attributes decl_info =
let add_property (curr_class, property_name) tp ocpdi decl_info =
let key = (curr_class, property_name) in
let getter_name = get_getter_name property_name attributes in
let setter_name = get_setter_name property_name attributes in
let attributes = ocpdi.Clang_ast_t.opdi_property_attributes in
let getter = Ast_utils.get_decl_opt_with_decl_ref ocpdi.Clang_ast_t.opdi_getter_method in
let setter = Ast_utils.get_decl_opt_with_decl_ref ocpdi.Clang_ast_t.opdi_setter_method in
let getter_decl =
match getter with
| Some (Clang_ast_t.ObjCMethodDecl (_, getter_name, getter_ocmdi) as getter_d) ->
getter_name.Clang_ast_t.ni_name, Some (getter_d, false)
| _ -> "", None in (* TODO refactor property map so that this is not needed t9330897 *)
let setter_decl =
match setter with
| Some (Clang_ast_t.ObjCMethodDecl (_, setter_name, setter_ocmdi) as setter_d) ->
setter_name.Clang_ast_t.ni_name, Some (setter_d, false)
| _ -> "", None in (* TODO refactor property map so that this is not needed t9330897 *)
PropertyTableHash.add property_table key
(tp, attributes, decl_info, (getter_name, None), (setter_name, None), None)
(tp, attributes, decl_info, getter_decl, setter_decl, None)
end
let reset_property_table = Property.reset_property_table
@ -355,7 +355,7 @@ let add_properties_to_table curr_class decl_list =
Printing.log_out "ADDING: ObjCPropertyDecl for property '%s' " pname;
Printing.log_out " pointer= '%s' \n" decl_info.Clang_ast_t.di_pointer;
Property.add_property (curr_class, name_info) pdi.Clang_ast_t.opdi_type_ptr
pdi.Clang_ast_t.opdi_property_attributes decl_info;
pdi decl_info;
| _ -> () in
IList.iter add_property_to_table decl_list

@ -36,7 +36,7 @@ sig
val replace_property : property_key -> property_type -> unit
val add_property : property_key -> Clang_ast_t.type_ptr -> Clang_ast_t.property_attribute list ->
val add_property : property_key -> Clang_ast_t.type_ptr -> Clang_ast_t.obj_c_property_decl_info ->
Clang_ast_t.decl_info -> unit
val print_property_table : unit -> unit

@ -1,5 +1,5 @@
digraph iCFG {
49 [label="49: Return Stmt \n n$0=_fun_createAndGetVal<struct X3>() [line 72]\n n$1=_fun_createAndGetVal<struct X1>() [line 72]\n *&return:int =(n$0 / n$1) [line 72]\n REMOVE_TEMPS(n$0,n$1); [line 72]\n APPLY_ABSTRACTION; [line 72]\n " shape="box"]
49 [label="49: Return Stmt \n n$0=_fun_createAndGetVal<X3>() [line 72]\n n$1=_fun_createAndGetVal<X1>() [line 72]\n *&return:int =(n$0 / n$1) [line 72]\n REMOVE_TEMPS(n$0,n$1); [line 72]\n APPLY_ABSTRACTION; [line 72]\n " shape="box"]
49 -> 48 ;
@ -10,7 +10,7 @@ digraph iCFG {
47 -> 49 ;
46 [label="46: Return Stmt \n n$0=_fun_createAndGetVal<struct X1>() [line 68]\n n$1=_fun_createAndGetVal<struct X3>() [line 68]\n *&return:int =(n$0 / n$1) [line 68]\n REMOVE_TEMPS(n$0,n$1); [line 68]\n APPLY_ABSTRACTION; [line 68]\n " shape="box"]
46 [label="46: Return Stmt \n n$0=_fun_createAndGetVal<X1>() [line 68]\n n$1=_fun_createAndGetVal<X3>() [line 68]\n *&return:int =(n$0 / n$1) [line 68]\n REMOVE_TEMPS(n$0,n$1); [line 68]\n APPLY_ABSTRACTION; [line 68]\n " shape="box"]
46 -> 45 ;
@ -29,7 +29,7 @@ digraph iCFG {
42 -> 41 ;
41 [label="41: Return Stmt \n n$0=_fun_getVal<struct X3>(&x3:class X3 &) [line 64]\n n$1=_fun_getVal<struct X1>(&x1:class X1 &) [line 64]\n *&return:int =(n$0 / n$1) [line 64]\n REMOVE_TEMPS(n$0,n$1); [line 64]\n NULLIFY(&x1,false); [line 64]\n NULLIFY(&x3,false); [line 64]\n APPLY_ABSTRACTION; [line 64]\n " shape="box"]
41 [label="41: Return Stmt \n n$0=_fun_getVal<X3>(&x3:class X3 &) [line 64]\n n$1=_fun_getVal<X1>(&x1:class X1 &) [line 64]\n *&return:int =(n$0 / n$1) [line 64]\n REMOVE_TEMPS(n$0,n$1); [line 64]\n NULLIFY(&x1,false); [line 64]\n NULLIFY(&x3,false); [line 64]\n APPLY_ABSTRACTION; [line 64]\n " shape="box"]
41 -> 40 ;
@ -48,7 +48,7 @@ digraph iCFG {
37 -> 36 ;
36 [label="36: Return Stmt \n n$0=_fun_getVal<struct X1>(&x1:class X1 &) [line 58]\n n$1=_fun_getVal<struct X3>(&x3:class X3 &) [line 58]\n *&return:int =(n$0 / n$1) [line 58]\n REMOVE_TEMPS(n$0,n$1); [line 58]\n NULLIFY(&x1,false); [line 58]\n NULLIFY(&x3,false); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"]
36 [label="36: Return Stmt \n n$0=_fun_getVal<X1>(&x1:class X1 &) [line 58]\n n$1=_fun_getVal<X3>(&x3:class X3 &) [line 58]\n *&return:int =(n$0 / n$1) [line 58]\n REMOVE_TEMPS(n$0,n$1); [line 58]\n NULLIFY(&x1,false); [line 58]\n NULLIFY(&x3,false); [line 58]\n APPLY_ABSTRACTION; [line 58]\n " shape="box"]
36 -> 35 ;
@ -59,25 +59,25 @@ digraph iCFG {
34 -> 38 ;
33 [label="33: Return Stmt \n n$0=_fun_createAndGetVal<struct X1>() [line 41]\n *&return:int =(1 / n$0) [line 41]\n REMOVE_TEMPS(n$0); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"]
33 [label="33: Return Stmt \n n$0=_fun_createAndGetVal<X1>() [line 41]\n *&return:int =(1 / n$0) [line 41]\n REMOVE_TEMPS(n$0); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"]
33 -> 32 ;
32 [label="32: Exit createAndDiv<struct X1> \n " color=yellow style=filled]
32 [label="32: Exit createAndDiv<X1> \n " color=yellow style=filled]
31 [label="31: Start createAndDiv<struct X1>\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled]
31 [label="31: Start createAndDiv<X1>\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled]
31 -> 33 ;
30 [label="30: Return Stmt \n n$0=_fun_createAndGetVal<struct X3>() [line 41]\n *&return:int =(1 / n$0) [line 41]\n REMOVE_TEMPS(n$0); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"]
30 [label="30: Return Stmt \n n$0=_fun_createAndGetVal<X3>() [line 41]\n *&return:int =(1 / n$0) [line 41]\n REMOVE_TEMPS(n$0); [line 41]\n APPLY_ABSTRACTION; [line 41]\n " shape="box"]
30 -> 29 ;
29 [label="29: Exit createAndDiv<struct X3> \n " color=yellow style=filled]
29 [label="29: Exit createAndDiv<X3> \n " color=yellow style=filled]
28 [label="28: Start createAndDiv<struct X3>\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled]
28 [label="28: Start createAndDiv<X3>\nFormals: \nLocals: \n DECLARE_LOCALS(&return); [line 40]\n " color=yellow style=filled]
28 -> 30 ;
@ -85,14 +85,14 @@ digraph iCFG {
27 -> 26 ;
26 [label="26: Return Stmt \n n$0=_fun_getVal<struct X1>(&x:class X1 &) [line 36]\n *&return:int =n$0 [line 36]\n REMOVE_TEMPS(n$0); [line 36]\n NULLIFY(&x,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"]
26 [label="26: Return Stmt \n n$0=_fun_getVal<X1>(&x:class X1 &) [line 36]\n *&return:int =n$0 [line 36]\n REMOVE_TEMPS(n$0); [line 36]\n NULLIFY(&x,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"]
26 -> 25 ;
25 [label="25: Exit createAndGetVal<struct X1> \n " color=yellow style=filled]
25 [label="25: Exit createAndGetVal<X1> \n " color=yellow style=filled]
24 [label="24: Start createAndGetVal<struct X1>\nFormals: \nLocals: x:class X1 \n DECLARE_LOCALS(&return,&x); [line 34]\n " color=yellow style=filled]
24 [label="24: Start createAndGetVal<X1>\nFormals: \nLocals: x:class X1 \n DECLARE_LOCALS(&return,&x); [line 34]\n " color=yellow style=filled]
24 -> 27 ;
@ -100,14 +100,14 @@ digraph iCFG {
23 -> 22 ;
22 [label="22: Return Stmt \n n$0=_fun_getVal<struct X3>(&x:class X3 &) [line 36]\n *&return:int =n$0 [line 36]\n REMOVE_TEMPS(n$0); [line 36]\n NULLIFY(&x,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"]
22 [label="22: Return Stmt \n n$0=_fun_getVal<X3>(&x:class X3 &) [line 36]\n *&return:int =n$0 [line 36]\n REMOVE_TEMPS(n$0); [line 36]\n NULLIFY(&x,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"]
22 -> 21 ;
21 [label="21: Exit createAndGetVal<struct X3> \n " color=yellow style=filled]
21 [label="21: Exit createAndGetVal<X3> \n " color=yellow style=filled]
20 [label="20: Start createAndGetVal<struct X3>\nFormals: \nLocals: x:class X3 \n DECLARE_LOCALS(&return,&x); [line 34]\n " color=yellow style=filled]
20 [label="20: Start createAndGetVal<X3>\nFormals: \nLocals: x:class X3 \n DECLARE_LOCALS(&return,&x); [line 34]\n " color=yellow style=filled]
20 -> 23 ;
@ -115,10 +115,10 @@ digraph iCFG {
19 -> 18 ;
18 [label="18: Exit getVal<struct X3> \n " color=yellow style=filled]
18 [label="18: Exit getVal<X3> \n " color=yellow style=filled]
17 [label="17: Start getVal<struct X3>\nFormals: x:class X3 &\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled]
17 [label="17: Start getVal<X3>\nFormals: x:class X3 &\nLocals: \n DECLARE_LOCALS(&return); [line 28]\n " color=yellow style=filled]
17 -> 19 ;
@ -126,10 +126,10 @@ digraph iCFG {
16 -> 15 ;
15 [label="15: Exit getVal<struct X1> \n " color=yellow style=filled]
15 [label="15: Exit getVal<X1> \n " color=yellow style=filled]
14 [label="14: Start getVal<struct X1>\nFormals: x:class X1 &\nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled]
14 [label="14: Start getVal<X1>\nFormals: x:class X1 &\nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled]
14 -> 16 ;

@ -50,7 +50,7 @@ public class FunctionTemplateTest {
String[] procedures = {
"div0_get_val",
"div0_create_and_get_val",
"createAndDiv<struct X3>",
"createAndDiv<X3>",
};
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
assertThat(

Loading…
Cancel
Save