[refactor] Rename CTypes and CTypes_decl modules

Summary: Avoid collision with ocaml-ctypes library.

Reviewed By: jvillard

Differential Revision: D4115581

fbshipit-source-id: a09cb1e
master
Josh Berdine 8 years ago committed by Facebook Github Bot
parent 9968245a43
commit e747d21e0c

@ -27,14 +27,14 @@ let add_predefined_basic_types () =
let sil_type = CType_to_sil_type.sil_type_of_builtin_type_kind basic_type_kind in let sil_type = CType_to_sil_type.sil_type_of_builtin_type_kind basic_type_kind in
Ast_utils.update_sil_types_map tp sil_type in Ast_utils.update_sil_types_map tp sil_type in
let add_pointer_type tp sil_type = let add_pointer_type tp sil_type =
let pointer_type = CTypes.add_pointer_to_typ sil_type in let pointer_type = CType.add_pointer_to_typ sil_type in
Ast_utils.update_sil_types_map tp pointer_type in Ast_utils.update_sil_types_map tp pointer_type in
let add_function_type tp return_type = let add_function_type tp return_type =
(* We translate function types as the return type of the function *) (* We translate function types as the return type of the function *)
Ast_utils.update_sil_types_map tp return_type in Ast_utils.update_sil_types_map tp return_type in
let sil_void_type = CType_to_sil_type.sil_type_of_builtin_type_kind `Void in let sil_void_type = CType_to_sil_type.sil_type_of_builtin_type_kind `Void in
let sil_char_type = CType_to_sil_type.sil_type_of_builtin_type_kind `Char_S in let sil_char_type = CType_to_sil_type.sil_type_of_builtin_type_kind `Char_S in
let sil_nsarray_type = Typ.Tstruct (CTypes.mk_classname CFrontend_config.nsarray_cl Csu.Objc) in let sil_nsarray_type = Typ.Tstruct (CType.mk_classname CFrontend_config.nsarray_cl Csu.Objc) in
let sil_id_type = CType_to_sil_type.get_builtin_objc_type `ObjCId in let sil_id_type = CType_to_sil_type.get_builtin_objc_type `ObjCId in
add_basic_type create_int_type `Int; add_basic_type create_int_type `Int;
add_basic_type create_void_type `Void; add_basic_type create_void_type `Void;

@ -31,7 +31,7 @@ let fields_superclass tenv interface_decl_info ck =
| Some dr -> | Some dr ->
(match dr.Clang_ast_t.dr_name with (match dr.Clang_ast_t.dr_name with
| Some sc -> | Some sc ->
let classname = CTypes.mk_classname (Ast_utils.get_qualified_name sc) ck in let classname = CType.mk_classname (Ast_utils.get_qualified_name sc) ck in
get_fields_super_classes tenv classname get_fields_super_classes tenv classname
| _ -> []) | _ -> [])
| _ -> [] | _ -> []

@ -41,7 +41,7 @@ let init_global_state_capture () =
let do_source_file translation_unit_context ast = let do_source_file translation_unit_context ast =
let tenv = Tenv.create () in let tenv = Tenv.create () in
CTypes_decl.add_predefined_types tenv; CType_decl.add_predefined_types tenv;
init_global_state_capture (); init_global_state_capture ();
let source_file = translation_unit_context.CFrontend_config.source_file in let source_file = translation_unit_context.CFrontend_config.source_file in
Config.nLOC := FileLOC.file_get_loc (DB.source_file_to_string source_file); Config.nLOC := FileLOC.file_get_loc (DB.source_file_to_string source_file);

@ -177,31 +177,31 @@ struct
let name = Ast_utils.get_qualified_name name_info in let name = Ast_utils.get_qualified_name name_info in
let curr_class = ObjcInterface_decl.get_curr_class name oi_decl_info in let curr_class = ObjcInterface_decl.get_curr_class name oi_decl_info in
ignore ignore
(ObjcInterface_decl.interface_declaration CTypes_decl.type_ptr_to_sil_type tenv dec); (ObjcInterface_decl.interface_declaration CType_decl.type_ptr_to_sil_type tenv dec);
process_methods trans_unit_ctx tenv cg cfg curr_class decl_list process_methods trans_unit_ctx tenv cg cfg curr_class decl_list
| ObjCProtocolDecl(_, name_info, decl_list, _, _) -> | ObjCProtocolDecl(_, name_info, decl_list, _, _) ->
let name = Ast_utils.get_qualified_name name_info in let name = Ast_utils.get_qualified_name name_info in
let curr_class = CContext.ContextProtocol name in let curr_class = CContext.ContextProtocol name in
ignore (ObjcProtocol_decl.protocol_decl CTypes_decl.type_ptr_to_sil_type tenv dec); ignore (ObjcProtocol_decl.protocol_decl CType_decl.type_ptr_to_sil_type tenv dec);
process_methods trans_unit_ctx tenv cg cfg curr_class decl_list process_methods trans_unit_ctx tenv cg cfg curr_class decl_list
| ObjCCategoryDecl(_, name_info, decl_list, _, ocdi) -> | ObjCCategoryDecl(_, name_info, decl_list, _, ocdi) ->
let name = Ast_utils.get_qualified_name name_info in let name = Ast_utils.get_qualified_name name_info in
let curr_class = ObjcCategory_decl.get_curr_class_from_category_decl name ocdi in let curr_class = ObjcCategory_decl.get_curr_class_from_category_decl name ocdi in
ignore (ObjcCategory_decl.category_decl CTypes_decl.type_ptr_to_sil_type tenv dec); ignore (ObjcCategory_decl.category_decl CType_decl.type_ptr_to_sil_type tenv dec);
process_methods trans_unit_ctx tenv cg cfg curr_class decl_list process_methods trans_unit_ctx tenv cg cfg curr_class decl_list
| ObjCCategoryImplDecl(_, name_info, decl_list, _, ocidi) -> | ObjCCategoryImplDecl(_, name_info, decl_list, _, ocidi) ->
let name = Ast_utils.get_qualified_name name_info in let name = Ast_utils.get_qualified_name name_info in
let curr_class = ObjcCategory_decl.get_curr_class_from_category_impl name ocidi in let curr_class = ObjcCategory_decl.get_curr_class_from_category_impl name ocidi in
ignore (ObjcCategory_decl.category_impl_decl CTypes_decl.type_ptr_to_sil_type tenv dec); ignore (ObjcCategory_decl.category_impl_decl CType_decl.type_ptr_to_sil_type tenv dec);
process_methods trans_unit_ctx tenv cg cfg curr_class decl_list; process_methods trans_unit_ctx tenv cg cfg curr_class decl_list;
| ObjCImplementationDecl(decl_info, _, decl_list, _, idi) -> | ObjCImplementationDecl(decl_info, _, decl_list, _, idi) ->
let curr_class = ObjcInterface_decl.get_curr_class_impl idi in let curr_class = ObjcInterface_decl.get_curr_class_impl idi in
let class_name = CContext.get_curr_class_name curr_class in let class_name = CContext.get_curr_class_name curr_class in
let type_ptr_to_sil_type = CTypes_decl.type_ptr_to_sil_type in let type_ptr_to_sil_type = CType_decl.type_ptr_to_sil_type in
ignore (ObjcInterface_decl.interface_impl_declaration type_ptr_to_sil_type tenv dec); ignore (ObjcInterface_decl.interface_impl_declaration type_ptr_to_sil_type tenv dec);
CMethod_trans.add_default_method_for_class trans_unit_ctx class_name decl_info; CMethod_trans.add_default_method_for_class trans_unit_ctx class_name decl_info;
process_methods trans_unit_ctx tenv cg cfg curr_class decl_list; process_methods trans_unit_ctx tenv cg cfg curr_class decl_list;
@ -258,7 +258,7 @@ struct
| _ -> false in | _ -> false in
let method_decls, no_method_decls = IList.partition is_method_decl decl_list in let method_decls, no_method_decls = IList.partition is_method_decl decl_list in
IList.iter translate no_method_decls; IList.iter translate no_method_decls;
ignore (CTypes_decl.add_types_from_decl_to_tenv tenv dec); ignore (CType_decl.add_types_from_decl_to_tenv tenv dec);
IList.iter translate method_decls IList.iter translate method_decls
| EnumDecl _ -> ignore (CEnum_decl.enum_decl dec) | EnumDecl _ -> ignore (CEnum_decl.enum_decl dec)
| LinkageSpecDecl (_, decl_list, _) -> | LinkageSpecDecl (_, decl_list, _) ->

@ -45,7 +45,7 @@ let get_original_return_type function_method_decl_info =
match function_method_decl_info with match function_method_decl_info with
| Func_decl_info (_, typ) | Func_decl_info (_, typ)
| Cpp_Meth_decl_info (_, _, _, typ) | Cpp_Meth_decl_info (_, _, _, typ)
| Block_decl_info (_, typ, _) -> CTypes.return_type_of_function_type typ | Block_decl_info (_, typ, _) -> CType.return_type_of_function_type typ
| ObjC_Meth_decl_info (method_decl_info, _) -> method_decl_info.Clang_ast_t.omdi_result_type | ObjC_Meth_decl_info (method_decl_info, _) -> method_decl_info.Clang_ast_t.omdi_result_type
let get_class_param function_method_decl_info = let get_class_param function_method_decl_info =
@ -74,7 +74,7 @@ let is_objc_method function_method_decl_info =
let get_return_param tenv function_method_decl_info = let get_return_param tenv function_method_decl_info =
let is_objc_method = is_objc_method function_method_decl_info in let is_objc_method = is_objc_method function_method_decl_info in
let return_type_ptr = get_original_return_type function_method_decl_info in let return_type_ptr = get_original_return_type function_method_decl_info in
let return_typ = CTypes_decl.type_ptr_to_sil_type tenv return_type_ptr in let return_typ = CType_decl.type_ptr_to_sil_type tenv return_type_ptr in
if should_add_return_param return_typ ~is_objc_method then if should_add_return_param return_typ ~is_objc_method then
[(Mangled.from_string CFrontend_config.return_param, [(Mangled.from_string CFrontend_config.return_param,
Ast_expressions.create_pointer_qual_type ~is_const:false return_type_ptr)] Ast_expressions.create_pointer_qual_type ~is_const:false return_type_ptr)]
@ -110,7 +110,7 @@ let get_parameters trans_unit_ctx tenv function_method_decl_info =
match par with match par with
| Clang_ast_t.ParmVarDecl (_, name_info, qt, var_decl_info) -> | Clang_ast_t.ParmVarDecl (_, name_info, qt, var_decl_info) ->
let _, mangled = General_utils.get_var_name_mangled name_info var_decl_info in let _, mangled = General_utils.get_var_name_mangled name_info var_decl_info in
let param_typ = CTypes_decl.type_ptr_to_sil_type tenv qt.Clang_ast_t.qt_type_ptr in let param_typ = CType_decl.type_ptr_to_sil_type tenv qt.Clang_ast_t.qt_type_ptr in
let qt_type_ptr = let qt_type_ptr =
match param_typ with match param_typ with
| Typ.Tstruct _ when General_utils.is_cpp_translation trans_unit_ctx -> | Typ.Tstruct _ when General_utils.is_cpp_translation trans_unit_ctx ->
@ -124,7 +124,7 @@ let get_parameters trans_unit_ctx tenv function_method_decl_info =
(** get return type of the function and optionally type of function's return parameter *) (** get return type of the function and optionally type of function's return parameter *)
let get_return_val_and_param_types tenv function_method_decl_info = let get_return_val_and_param_types tenv function_method_decl_info =
let return_type_ptr = get_original_return_type function_method_decl_info in let return_type_ptr = get_original_return_type function_method_decl_info in
let return_typ = CTypes_decl.type_ptr_to_sil_type tenv return_type_ptr in let return_typ = CType_decl.type_ptr_to_sil_type tenv return_type_ptr in
let is_objc_method = is_objc_method function_method_decl_info in let is_objc_method = is_objc_method function_method_decl_info in
if should_add_return_param return_typ ~is_objc_method then if should_add_return_param return_typ ~is_objc_method then
Ast_expressions.create_void_type, Some (Typ.Tptr (return_typ, Typ.Pk_pointer)) Ast_expressions.create_void_type, Some (Typ.Tptr (return_typ, Typ.Pk_pointer))
@ -215,7 +215,7 @@ let get_method_name_from_clang tenv ms_opt =
| Some decl -> | Some decl ->
if ObjcProtocol_decl.is_protocol decl then None if ObjcProtocol_decl.is_protocol decl then None
else else
(ignore (CTypes_decl.add_types_from_decl_to_tenv tenv decl); (ignore (CType_decl.add_types_from_decl_to_tenv tenv decl);
match ObjcCategory_decl.get_base_class_name_from_category decl with match ObjcCategory_decl.get_base_class_name_from_category decl with
| Some class_name -> | Some class_name ->
let procname = CMethod_signature.ms_get_name ms in let procname = CMethod_signature.ms_get_name ms in
@ -267,12 +267,12 @@ let get_class_name_method_call_from_clang trans_unit_ctx tenv obj_c_message_expr
let get_class_name_method_call_from_receiver_kind context obj_c_message_expr_info act_params = let get_class_name_method_call_from_receiver_kind context obj_c_message_expr_info act_params =
match obj_c_message_expr_info.Clang_ast_t.omei_receiver_kind with match obj_c_message_expr_info.Clang_ast_t.omei_receiver_kind with
| `Class tp -> | `Class tp ->
let sil_type = CTypes_decl.type_ptr_to_sil_type context.CContext.tenv tp in let sil_type = CType_decl.type_ptr_to_sil_type context.CContext.tenv tp in
(CTypes.classname_of_type sil_type) (CType.classname_of_type sil_type)
| `Instance -> | `Instance ->
(match act_params with (match act_params with
| (_, Typ.Tptr(t, _)):: _ | (_, Typ.Tptr(t, _)):: _
| (_, t):: _ -> CTypes.classname_of_type t | (_, t):: _ -> CType.classname_of_type t
| _ -> assert false) | _ -> assert false)
| `SuperInstance ->get_superclass_curr_class_objc context | `SuperInstance ->get_superclass_curr_class_objc context
| `SuperClass -> get_superclass_curr_class_objc context | `SuperClass -> get_superclass_curr_class_objc context
@ -307,13 +307,13 @@ let get_formal_parameters tenv ms =
let tp = if should_add_pointer (Mangled.to_string mangled) ms then let tp = if should_add_pointer (Mangled.to_string mangled) ms then
(Ast_expressions.create_pointer_type qt_type_ptr) (Ast_expressions.create_pointer_type qt_type_ptr)
else qt_type_ptr in else qt_type_ptr in
let typ = CTypes_decl.type_ptr_to_sil_type tenv tp in let typ = CType_decl.type_ptr_to_sil_type tenv tp in
(mangled, typ):: defined_parameters pl' in (mangled, typ):: defined_parameters pl' in
defined_parameters (CMethod_signature.ms_get_args ms) defined_parameters (CMethod_signature.ms_get_args ms)
let get_return_type tenv ms = let get_return_type tenv ms =
let return_type = CMethod_signature.ms_get_ret_type ms in let return_type = CMethod_signature.ms_get_ret_type ms in
CTypes_decl.type_ptr_to_sil_type tenv return_type CType_decl.type_ptr_to_sil_type tenv return_type
let sil_func_attributes_of_attributes attrs = let sil_func_attributes_of_attributes attrs =
let rec do_translation acc al = match al with let rec do_translation acc al = match al with

@ -93,7 +93,7 @@ struct
let objc_exp_of_type_block fun_exp_stmt = let objc_exp_of_type_block fun_exp_stmt =
match fun_exp_stmt with match fun_exp_stmt with
| Clang_ast_t.ImplicitCastExpr(_, _, ei, _) | Clang_ast_t.ImplicitCastExpr(_, _, ei, _)
when CTypes.is_block_type ei.Clang_ast_t.ei_type_ptr -> true when CType.is_block_type ei.Clang_ast_t.ei_type_ptr -> true
| _ -> false | _ -> false
(* This function add in tenv a class representing an objc block. *) (* This function add in tenv a class representing an objc block. *)
@ -194,7 +194,7 @@ struct
f trans_state stmt f trans_state stmt
with Self.SelfClassException class_name -> with Self.SelfClassException class_name ->
let typ = let typ =
CTypes_decl.objc_class_name_to_sil_type trans_state.context.CContext.tenv class_name in CType_decl.objc_class_name_to_sil_type trans_state.context.CContext.tenv class_name in
{ empty_res_trans with { empty_res_trans with
exps = [(Exp.Sizeof (typ, None, Subtype.exact), Tint IULong)] } exps = [(Exp.Sizeof (typ, None, Subtype.exact), Tint IULong)] }
@ -249,7 +249,7 @@ struct
let mk_temp_sil_var_for_expr tenv procdesc var_name_prefix expr_info = let mk_temp_sil_var_for_expr tenv procdesc var_name_prefix expr_info =
let type_ptr = expr_info.Clang_ast_t.ei_type_ptr in let type_ptr = expr_info.Clang_ast_t.ei_type_ptr in
let typ = CTypes_decl.type_ptr_to_sil_type tenv type_ptr in let typ = CType_decl.type_ptr_to_sil_type tenv type_ptr in
(mk_temp_sil_var procdesc var_name_prefix, typ) (mk_temp_sil_var procdesc var_name_prefix, typ)
let create_var_exp_tmp_var trans_state expr_info var_name = let create_var_exp_tmp_var trans_state expr_info var_name =
@ -310,7 +310,7 @@ struct
| _ -> assert false | _ -> assert false
let stringLiteral_trans trans_state expr_info str = let stringLiteral_trans trans_state expr_info str =
let typ = CTypes_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in let typ = CType_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in
let exp = Exp.Const (Const.Cstr (str)) in let exp = Exp.Const (Const.Cstr (str)) in
{ empty_res_trans with exps = [(exp, typ)]} { empty_res_trans with exps = [(exp, typ)]}
@ -323,12 +323,12 @@ struct
(* (which is an integer that may not match the size of a pointer)". (* (which is an integer that may not match the size of a pointer)".
So we implement it as the constant zero *) So we implement it as the constant zero *)
let gNUNullExpr_trans trans_state expr_info = let gNUNullExpr_trans trans_state expr_info =
let typ = CTypes_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in let typ = CType_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in
let exp = Exp.Const (Const.Cint (IntLit.zero)) in let exp = Exp.Const (Const.Cint (IntLit.zero)) in
{ empty_res_trans with exps = [(exp, typ)]} { empty_res_trans with exps = [(exp, typ)]}
let nullPtrExpr_trans trans_state expr_info = let nullPtrExpr_trans trans_state expr_info =
let typ = CTypes_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in let typ = CType_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in
{ empty_res_trans with exps = [(Exp.null, typ)]} { empty_res_trans with exps = [(Exp.null, typ)]}
let objCSelectorExpr_trans trans_state expr_info selector = let objCSelectorExpr_trans trans_state expr_info selector =
@ -345,7 +345,7 @@ struct
stringLiteral_trans trans_state expr_info name stringLiteral_trans trans_state expr_info name
let characterLiteral_trans trans_state expr_info n = let characterLiteral_trans trans_state expr_info n =
let typ = CTypes_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in let typ = CType_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in
let exp = Exp.Const (Const.Cint (IntLit.of_int n)) in let exp = Exp.Const (Const.Cint (IntLit.of_int n)) in
{ empty_res_trans with exps = [(exp, typ)]} { empty_res_trans with exps = [(exp, typ)]}
@ -353,14 +353,14 @@ struct
characterLiteral_trans trans_state expr_info (Utils.int_of_bool b) characterLiteral_trans trans_state expr_info (Utils.int_of_bool b)
let floatingLiteral_trans trans_state expr_info float_string = let floatingLiteral_trans trans_state expr_info float_string =
let typ = CTypes_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in let typ = CType_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in
let exp = Exp.Const (Const.Cfloat (float_of_string float_string)) in let exp = Exp.Const (Const.Cfloat (float_of_string float_string)) in
{ empty_res_trans with exps = [(exp, typ)]} { empty_res_trans with exps = [(exp, typ)]}
(* Note currently we don't have support for different qual *) (* Note currently we don't have support for different qual *)
(* type like long, unsigned long, etc *) (* type like long, unsigned long, etc *)
and integerLiteral_trans trans_state expr_info integer_literal_info = and integerLiteral_trans trans_state expr_info integer_literal_info =
let typ = CTypes_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in let typ = CType_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in
let exp = let exp =
try try
let i = Int64.of_string integer_literal_info.Clang_ast_t.ili_value in let i = Int64.of_string integer_literal_info.Clang_ast_t.ili_value in
@ -376,7 +376,7 @@ struct
} }
let cxxScalarValueInitExpr_trans trans_state expr_info = let cxxScalarValueInitExpr_trans trans_state expr_info =
let typ = CTypes_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in let typ = CType_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in
(* constant will be different depending on type *) (* constant will be different depending on type *)
let zero_opt = match typ with let zero_opt = match typ with
| Typ.Tfloat _ | Typ.Tptr _ | Typ.Tint _ -> Some (Sil.zero_value_of_numerical_type typ) | Typ.Tfloat _ | Typ.Tptr _ | Typ.Tint _ -> Some (Sil.zero_value_of_numerical_type typ)
@ -389,7 +389,7 @@ struct
let implicitValueInitExpr_trans trans_state expr_info = let implicitValueInitExpr_trans trans_state expr_info =
let (var_exp, _) = extract_var_exp_or_fail trans_state in let (var_exp, _) = extract_var_exp_or_fail trans_state in
let tenv = trans_state.context.CContext.tenv in let tenv = trans_state.context.CContext.tenv in
let typ = CTypes_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in let typ = CType_decl.get_type_from_expr_info expr_info trans_state.context.CContext.tenv in
let exps = var_or_zero_in_init_list tenv var_exp typ ~return_zero:true in let exps = var_or_zero_in_init_list tenv var_exp typ ~return_zero:true in
{ empty_res_trans with exps = exps } { empty_res_trans with exps = exps }
@ -399,7 +399,7 @@ struct
(* The stmt seems to be always empty *) (* The stmt seems to be always empty *)
let unaryExprOrTypeTraitExpr_trans trans_state expr_info unary_expr_or_type_trait_expr_info = let unaryExprOrTypeTraitExpr_trans trans_state expr_info unary_expr_or_type_trait_expr_info =
let tenv = trans_state.context.CContext.tenv in let tenv = trans_state.context.CContext.tenv in
let typ = CTypes_decl.type_ptr_to_sil_type tenv expr_info.Clang_ast_t.ei_type_ptr in let typ = CType_decl.type_ptr_to_sil_type tenv expr_info.Clang_ast_t.ei_type_ptr in
match unary_expr_or_type_trait_expr_info.Clang_ast_t.uttei_kind with match unary_expr_or_type_trait_expr_info.Clang_ast_t.uttei_kind with
| `SizeOf -> | `SizeOf ->
let tp = let tp =
@ -407,7 +407,7 @@ struct
unary_expr_or_type_trait_expr_info in unary_expr_or_type_trait_expr_info in
let sizeof_typ = let sizeof_typ =
match tp with match tp with
| Some tp -> CTypes_decl.type_ptr_to_sil_type tenv tp | Some tp -> CType_decl.type_ptr_to_sil_type tenv tp
| None -> typ (* Some default type since the type is missing *) in | None -> typ (* Some default type since the type is missing *) in
{ empty_res_trans with { empty_res_trans with
exps = [(Exp.Sizeof (sizeof_typ, None, Subtype.exact), sizeof_typ)] } exps = [(Exp.Sizeof (sizeof_typ, None, Subtype.exact), sizeof_typ)] }
@ -461,7 +461,7 @@ struct
let decl_opt = Ast_utils.get_function_decl_with_body decl_ptr in let decl_opt = Ast_utils.get_function_decl_with_body decl_ptr in
Option.may (call_translation context) decl_opt; Option.may (call_translation context) decl_opt;
let name = Ast_utils.get_qualified_name name_info in let name = Ast_utils.get_qualified_name name_info in
let typ = CTypes_decl.type_ptr_to_sil_type context.tenv type_ptr in let typ = CType_decl.type_ptr_to_sil_type context.tenv type_ptr in
let pname = let pname =
match get_builtin_pname_opt context.translation_unit_context name decl_opt type_ptr with match get_builtin_pname_opt context.translation_unit_context name decl_opt type_ptr with
| Some builtin_pname -> builtin_pname | Some builtin_pname -> builtin_pname
@ -474,7 +474,7 @@ struct
let sil_loc = CLocation.get_sil_location stmt_info context in let sil_loc = CLocation.get_sil_location stmt_info context in
let name_info, _, type_ptr = Ast_utils.get_info_from_decl_ref decl_ref in let name_info, _, type_ptr = Ast_utils.get_info_from_decl_ref decl_ref in
Logging.out_debug "!!!!! Dealing with field '%s' @." name_info.Clang_ast_t.ni_name; Logging.out_debug "!!!!! Dealing with field '%s' @." name_info.Clang_ast_t.ni_name;
let field_typ = CTypes_decl.type_ptr_to_sil_type context.tenv type_ptr in let field_typ = CType_decl.type_ptr_to_sil_type context.tenv type_ptr in
let (obj_sil, class_typ) = extract_exp_from_list pre_trans_result.exps let (obj_sil, class_typ) = extract_exp_from_list pre_trans_result.exps
"WARNING: in Field dereference we expect to know the object\n" in "WARNING: in Field dereference we expect to know the object\n" in
let is_pointer_typ = match class_typ with let is_pointer_typ = match class_typ with
@ -495,7 +495,7 @@ struct
(* it's done in var_deref_trans. The only exception is during field initialization in*) (* it's done in var_deref_trans. The only exception is during field initialization in*)
(* constructor's initializer list (when reference itself is initialized) *) (* constructor's initializer list (when reference itself is initialized) *)
let should_add_deref = (not is_pointer_typ) || let should_add_deref = (not is_pointer_typ) ||
(not is_constructor_init && CTypes.is_reference_type type_ptr) in (not is_constructor_init && CType.is_reference_type type_ptr) in
let exp, deref_instrs = if should_add_deref then let exp, deref_instrs = if should_add_deref then
let id = Ident.create_fresh Ident.knormal in let id = Ident.create_fresh Ident.knormal in
let deref_instr = Sil.Load (id, field_exp, field_typ, sil_loc) in let deref_instr = Sil.Load (id, field_exp, field_typ, sil_loc) in
@ -515,7 +515,7 @@ struct
let method_name = Ast_utils.get_unqualified_name name_info in let method_name = Ast_utils.get_unqualified_name name_info in
let class_name = Ast_utils.get_class_name_from_member name_info in let class_name = Ast_utils.get_class_name_from_member name_info in
Logging.out_debug "!!!!! Dealing with method '%s' @." method_name; Logging.out_debug "!!!!! Dealing with method '%s' @." method_name;
let method_typ = CTypes_decl.type_ptr_to_sil_type context.tenv type_ptr in let method_typ = CType_decl.type_ptr_to_sil_type context.tenv type_ptr in
let ms_opt = CMethod_trans.method_signature_of_pointer let ms_opt = CMethod_trans.method_signature_of_pointer
context.translation_unit_context context.tenv decl_ptr in context.translation_unit_context context.tenv decl_ptr in
let is_instance_method = match ms_opt with let is_instance_method = match ms_opt with
@ -581,7 +581,7 @@ struct
let name = CFrontend_config.this in let name = CFrontend_config.this in
let pvar = Pvar.mk (Mangled.from_string name) procname in let pvar = Pvar.mk (Mangled.from_string name) procname in
let exp = Exp.Lvar pvar in let exp = Exp.Lvar pvar in
let typ = CTypes_decl.type_ptr_to_sil_type context.CContext.tenv class_type_ptr in let typ = CType_decl.type_ptr_to_sil_type context.CContext.tenv class_type_ptr in
let exps = [(exp, typ)] in let exps = [(exp, typ)] in
(* there is no cast operation in AST, but backend needs it *) (* there is no cast operation in AST, but backend needs it *)
dereference_value_from_result sil_loc { empty_res_trans with exps = exps } ~strip_pointer:false dereference_value_from_result sil_loc { empty_res_trans with exps = exps } ~strip_pointer:false
@ -606,7 +606,7 @@ struct
and var_deref_trans trans_state stmt_info (decl_ref : Clang_ast_t.decl_ref) = and var_deref_trans trans_state stmt_info (decl_ref : Clang_ast_t.decl_ref) =
let context = trans_state.context in let context = trans_state.context in
let _, _, type_ptr = Ast_utils.get_info_from_decl_ref decl_ref in let _, _, type_ptr = Ast_utils.get_info_from_decl_ref decl_ref in
let ast_typ = CTypes_decl.type_ptr_to_sil_type context.tenv type_ptr in let ast_typ = CType_decl.type_ptr_to_sil_type context.tenv type_ptr in
let typ = let typ =
match ast_typ with match ast_typ with
| Tstruct _ when decl_ref.dr_kind = `ParmVar -> | Tstruct _ when decl_ref.dr_kind = `ParmVar ->
@ -643,10 +643,10 @@ struct
else empty_res_trans in else empty_res_trans in
let exps = if Self.is_var_self pvar (CContext.is_objc_method context) then let exps = if Self.is_var_self pvar (CContext.is_objc_method context) then
let curr_class = CContext.get_curr_class context in let curr_class = CContext.get_curr_class context in
if (CTypes.is_class typ) then if (CType.is_class typ) then
raise (Self.SelfClassException (CContext.get_curr_class_name curr_class)) raise (Self.SelfClassException (CContext.get_curr_class_name curr_class))
else else
let typ = CTypes.add_pointer_to_typ (CTypes_decl.get_type_curr_class_objc curr_class) in let typ = CType.add_pointer_to_typ (CType_decl.get_type_curr_class_objc curr_class) in
[(var_exp, typ)] [(var_exp, typ)]
else [(var_exp, typ)] in else [(var_exp, typ)] in
Logging.out_debug "\n\n PVAR ='%s'\n\n" (Pvar.to_string pvar); Logging.out_debug "\n\n PVAR ='%s'\n\n" (Pvar.to_string pvar);
@ -719,13 +719,13 @@ struct
and enum_constant_trans trans_state decl_ref = and enum_constant_trans trans_state decl_ref =
let context = trans_state.context in let context = trans_state.context in
let _, _, type_ptr = Ast_utils.get_info_from_decl_ref decl_ref in let _, _, type_ptr = Ast_utils.get_info_from_decl_ref decl_ref in
let typ = CTypes_decl.type_ptr_to_sil_type context.CContext.tenv type_ptr in let typ = CType_decl.type_ptr_to_sil_type context.CContext.tenv type_ptr in
let const_exp = get_enum_constant_expr context decl_ref.Clang_ast_t.dr_decl_pointer in let const_exp = get_enum_constant_expr context decl_ref.Clang_ast_t.dr_decl_pointer in
{ empty_res_trans with exps = [(const_exp, typ)] } { empty_res_trans with exps = [(const_exp, typ)] }
and arraySubscriptExpr_trans trans_state expr_info stmt_list = and arraySubscriptExpr_trans trans_state expr_info stmt_list =
let context = trans_state.context in let context = trans_state.context in
let typ = CTypes_decl.get_type_from_expr_info expr_info context.tenv in let typ = CType_decl.get_type_from_expr_info expr_info context.tenv in
let array_stmt, idx_stmt = (match stmt_list with let array_stmt, idx_stmt = (match stmt_list with
| [a; i] -> a, i (* Assumption: the statement list contains 2 elements, | [a; i] -> a, i (* Assumption: the statement list contains 2 elements,
the first is the array expr and the second the index *) the first is the array expr and the second the index *)
@ -775,7 +775,7 @@ struct
let trans_state' = { trans_state_pri with succ_nodes = [] } in let trans_state' = { trans_state_pri with succ_nodes = [] } in
let sil_loc = CLocation.get_sil_location stmt_info context in let sil_loc = CLocation.get_sil_location stmt_info context in
let typ = let typ =
CTypes_decl.type_ptr_to_sil_type context.CContext.tenv expr_info.Clang_ast_t.ei_type_ptr in CType_decl.type_ptr_to_sil_type context.CContext.tenv expr_info.Clang_ast_t.ei_type_ptr in
match stmt_list with match stmt_list with
| [s1; s2] -> (* Assumption: We expect precisely 2 stmt corresponding to the 2 operands*) | [s1; s2] -> (* Assumption: We expect precisely 2 stmt corresponding to the 2 operands*)
let rhs_owning_method = CTrans_utils.is_owning_method s2 in let rhs_owning_method = CTrans_utils.is_owning_method s2 in
@ -830,7 +830,7 @@ struct
and callExpr_trans trans_state si stmt_list expr_info = and callExpr_trans trans_state si stmt_list expr_info =
let context = trans_state.context in let context = trans_state.context in
let fn_type_no_ref = CTypes_decl.get_type_from_expr_info expr_info context.CContext.tenv in let fn_type_no_ref = CType_decl.get_type_from_expr_info expr_info context.CContext.tenv in
let function_type = add_reference_if_glvalue fn_type_no_ref expr_info in let function_type = add_reference_if_glvalue fn_type_no_ref expr_info in
let procname = Cfg.Procdesc.get_proc_name context.CContext.procdesc in let procname = Cfg.Procdesc.get_proc_name context.CContext.procdesc in
let sil_loc = CLocation.get_sil_location si context in let sil_loc = CLocation.get_sil_location si context in
@ -959,7 +959,7 @@ struct
let trans_state_callee = { trans_state_pri with succ_nodes = [] } in let trans_state_callee = { trans_state_pri with succ_nodes = [] } in
let result_trans_callee = instruction trans_state_callee fun_exp_stmt in let result_trans_callee = instruction trans_state_callee fun_exp_stmt in
let is_cpp_call_virtual = result_trans_callee.is_cpp_call_virtual in let is_cpp_call_virtual = result_trans_callee.is_cpp_call_virtual in
let fn_type_no_ref = CTypes_decl.get_type_from_expr_info expr_info context.CContext.tenv in let fn_type_no_ref = CType_decl.get_type_from_expr_info expr_info context.CContext.tenv in
let function_type = add_reference_if_glvalue fn_type_no_ref expr_info in let function_type = add_reference_if_glvalue fn_type_no_ref expr_info in
cxx_method_construct_call_trans trans_state_pri result_trans_callee params_stmt cxx_method_construct_call_trans trans_state_pri result_trans_callee params_stmt
si function_type is_cpp_call_virtual empty_res_trans si function_type is_cpp_call_virtual empty_res_trans
@ -974,7 +974,7 @@ struct
| None -> | None ->
let procdesc = trans_state.context.CContext.procdesc in let procdesc = trans_state.context.CContext.procdesc in
let pvar = Pvar.mk_tmp "__temp_construct_" (Cfg.Procdesc.get_proc_name procdesc) in let pvar = Pvar.mk_tmp "__temp_construct_" (Cfg.Procdesc.get_proc_name procdesc) in
let class_type = CTypes_decl.get_type_from_expr_info ei context.CContext.tenv in let class_type = CType_decl.get_type_from_expr_info ei context.CContext.tenv in
Cfg.Procdesc.append_locals procdesc [(Pvar.get_name pvar, class_type)]; Cfg.Procdesc.append_locals procdesc [(Pvar.get_name pvar, class_type)];
Exp.Lvar pvar, class_type in Exp.Lvar pvar, class_type in
let this_type = Typ.Tptr (class_type, Typ.Pk_pointer) in let this_type = Typ.Tptr (class_type, Typ.Pk_pointer) in
@ -1011,7 +1011,7 @@ struct
let receiver_kind = obj_c_message_expr_info.Clang_ast_t.omei_receiver_kind in let receiver_kind = obj_c_message_expr_info.Clang_ast_t.omei_receiver_kind in
let selector = obj_c_message_expr_info.Clang_ast_t.omei_selector in let selector = obj_c_message_expr_info.Clang_ast_t.omei_selector in
(* class method *) (* class method *)
if selector = CFrontend_config.class_method && CTypes.is_class method_type then if selector = CFrontend_config.class_method && CType.is_class method_type then
let class_name = CMethod_trans.get_class_name_method_call_from_receiver_kind context let class_name = CMethod_trans.get_class_name_method_call_from_receiver_kind context
obj_c_message_expr_info act_params in obj_c_message_expr_info act_params in
raise (Self.SelfClassException class_name) raise (Self.SelfClassException class_name)
@ -1056,7 +1056,7 @@ struct
(string_of_bool (PriorityNode.is_priority_free trans_state)); (string_of_bool (PriorityNode.is_priority_free trans_state));
let context = trans_state.context in let context = trans_state.context in
let sil_loc = CLocation.get_sil_location si context in let sil_loc = CLocation.get_sil_location si context in
let method_type_no_ref = CTypes_decl.get_type_from_expr_info expr_info context.CContext.tenv in let method_type_no_ref = CType_decl.get_type_from_expr_info expr_info context.CContext.tenv in
let method_type = add_reference_if_glvalue method_type_no_ref expr_info in let method_type = add_reference_if_glvalue method_type_no_ref expr_info in
let trans_state_pri = PriorityNode.try_claim_priority_node trans_state si in let trans_state_pri = PriorityNode.try_claim_priority_node trans_state si in
let trans_state_param = { trans_state_pri with succ_nodes = []; var_exp_typ = None } in let trans_state_param = { trans_state_pri with succ_nodes = []; var_exp_typ = None } in
@ -1137,7 +1137,7 @@ struct
(match stmt_list with (match stmt_list with
| [cond; exp1; exp2] -> | [cond; exp1; exp2] ->
let typ = let typ =
CTypes_decl.type_ptr_to_sil_type CType_decl.type_ptr_to_sil_type
context.CContext.tenv expr_info.Clang_ast_t.ei_type_ptr in context.CContext.tenv expr_info.Clang_ast_t.ei_type_ptr in
let var_typ = add_reference_if_glvalue typ expr_info in let var_typ = add_reference_if_glvalue typ expr_info in
let join_node = create_node (Cfg.Node.Join_node) [] sil_loc context in let join_node = create_node (Cfg.Node.Join_node) [] sil_loc context in
@ -1620,7 +1620,7 @@ struct
let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in
let sil_loc = CLocation.get_sil_location stmt_info context in let sil_loc = CLocation.get_sil_location stmt_info context in
let var_type = let var_type =
CTypes_decl.type_ptr_to_sil_type context.CContext.tenv expr_info.Clang_ast_t.ei_type_ptr in CType_decl.type_ptr_to_sil_type context.CContext.tenv expr_info.Clang_ast_t.ei_type_ptr in
let lh = var_or_zero_in_init_list tenv var_exp var_type ~return_zero:false in let lh = var_or_zero_in_init_list tenv var_exp var_type ~return_zero:false in
let res_trans_subexpr_list = let res_trans_subexpr_list =
initListExpr_initializers_trans trans_state var_exp 0 stmts typ false stmt_info in initListExpr_initializers_trans trans_state var_exp 0 stmts typ false stmt_info in
@ -1721,7 +1721,7 @@ struct
let do_var_dec (di, var_name, qual_type, vdi) next_node = let do_var_dec (di, var_name, qual_type, vdi) next_node =
let var_decl = VarDecl (di, var_name, qual_type, vdi) in let var_decl = VarDecl (di, var_name, qual_type, vdi) in
let pvar = CVar_decl.sil_var_of_decl context var_decl procname in let pvar = CVar_decl.sil_var_of_decl context var_decl procname in
let typ = CTypes_decl.type_ptr_to_sil_type let typ = CType_decl.type_ptr_to_sil_type
context.CContext.tenv context.CContext.tenv
qual_type.Clang_ast_t.qt_type_ptr in qual_type.Clang_ast_t.qt_type_ptr in
CVar_decl.add_var_to_locals procdesc var_decl typ pvar; CVar_decl.add_var_to_locals procdesc var_decl typ pvar;
@ -1823,7 +1823,7 @@ struct
"WARNING: In CastExpr There must be only one stmt defining the expression to be cast.\n" in "WARNING: In CastExpr There must be only one stmt defining the expression to be cast.\n" in
let res_trans_stmt = instruction trans_state stmt in let res_trans_stmt = instruction trans_state stmt in
let typ = let typ =
CTypes_decl.type_ptr_to_sil_type context.CContext.tenv expr_info.Clang_ast_t.ei_type_ptr in CType_decl.type_ptr_to_sil_type context.CContext.tenv expr_info.Clang_ast_t.ei_type_ptr in
let cast_kind = cast_expr_info.Clang_ast_t.cei_cast_kind in let cast_kind = cast_expr_info.Clang_ast_t.cei_cast_kind in
(* This gives the differnece among cast operations kind*) (* This gives the differnece among cast operations kind*)
let is_objc_bridged_cast_expr _ stmt = let is_objc_bridged_cast_expr _ stmt =
@ -1871,7 +1871,7 @@ struct
extract_exp_from_list res_trans_stmt.exps extract_exp_from_list res_trans_stmt.exps
"\nWARNING: Missing operand in unary operator. NEED FIXING.\n" in "\nWARNING: Missing operand in unary operator. NEED FIXING.\n" in
let ret_typ = let ret_typ =
CTypes_decl.type_ptr_to_sil_type CType_decl.type_ptr_to_sil_type
context.CContext.tenv expr_info.Clang_ast_t.ei_type_ptr in context.CContext.tenv expr_info.Clang_ast_t.ei_type_ptr in
let exp_op, instr_op = let exp_op, instr_op =
CArithmetic_trans.unary_operation_instruction CArithmetic_trans.unary_operation_instruction
@ -1952,7 +1952,7 @@ struct
and objCBoxedExpr_trans trans_state info sel stmt_info stmts = and objCBoxedExpr_trans trans_state info sel stmt_info stmts =
let typ = let typ =
CTypes_decl.class_from_pointer_type CType_decl.class_from_pointer_type
trans_state.context.CContext.tenv info.Clang_ast_t.ei_type_ptr in trans_state.context.CContext.tenv info.Clang_ast_t.ei_type_ptr in
let obj_c_message_expr_info = Ast_expressions.make_obj_c_message_expr_info_class sel typ None in let obj_c_message_expr_info = Ast_expressions.make_obj_c_message_expr_info_class sel typ None in
let message_stmt = let message_stmt =
@ -1961,7 +1961,7 @@ struct
and objCArrayLiteral_trans trans_state info stmt_info stmts = and objCArrayLiteral_trans trans_state info stmt_info stmts =
let typ = let typ =
CTypes_decl.class_from_pointer_type CType_decl.class_from_pointer_type
trans_state.context.CContext.tenv info.Clang_ast_t.ei_type_ptr in trans_state.context.CContext.tenv info.Clang_ast_t.ei_type_ptr in
let meth = CFrontend_config.array_with_objects_count_m in let meth = CFrontend_config.array_with_objects_count_m in
let obj_c_mes_expr_info = Ast_expressions.make_obj_c_message_expr_info_class meth typ None in let obj_c_mes_expr_info = Ast_expressions.make_obj_c_message_expr_info_class meth typ None in
@ -1971,7 +1971,7 @@ struct
and objCDictionaryLiteral_trans trans_state info stmt_info stmts = and objCDictionaryLiteral_trans trans_state info stmt_info stmts =
let typ = let typ =
CTypes_decl.class_from_pointer_type CType_decl.class_from_pointer_type
trans_state.context.CContext.tenv info.Clang_ast_t.ei_type_ptr in trans_state.context.CContext.tenv info.Clang_ast_t.ei_type_ptr in
let dictionary_literal_pname = BuiltinDecl.__objc_dictionary_literal in let dictionary_literal_pname = BuiltinDecl.__objc_dictionary_literal in
let dictionary_literal_s = Procname.get_method dictionary_literal_pname in let dictionary_literal_s = Procname.get_method dictionary_literal_pname in
@ -1988,7 +1988,7 @@ struct
let stmts = [Ast_expressions.create_implicit_cast_expr stmt_info stmts let stmts = [Ast_expressions.create_implicit_cast_expr stmt_info stmts
Ast_expressions.create_char_star_type `ArrayToPointerDecay] in Ast_expressions.create_char_star_type `ArrayToPointerDecay] in
let typ = let typ =
CTypes_decl.class_from_pointer_type CType_decl.class_from_pointer_type
trans_state.context.CContext.tenv info.Clang_ast_t.ei_type_ptr in trans_state.context.CContext.tenv info.Clang_ast_t.ei_type_ptr in
let meth = CFrontend_config.string_with_utf8_m in let meth = CFrontend_config.string_with_utf8_m in
let obj_c_mess_expr_info = Ast_expressions.make_obj_c_message_expr_info_class meth typ None in let obj_c_mess_expr_info = Ast_expressions.make_obj_c_message_expr_info_class meth typ None in
@ -2042,7 +2042,7 @@ struct
let open CContext in let open CContext in
let type_ptr = expr_info.Clang_ast_t.ei_type_ptr in let type_ptr = expr_info.Clang_ast_t.ei_type_ptr in
let block_pname = CFrontend_utils.General_utils.mk_fresh_block_procname procname in let block_pname = CFrontend_utils.General_utils.mk_fresh_block_procname procname in
let typ = CTypes_decl.type_ptr_to_sil_type context.tenv type_ptr in let typ = CType_decl.type_ptr_to_sil_type context.tenv type_ptr in
(* We need to set the explicit dependency between the newly created block and the *) (* We need to set the explicit dependency between the newly created block and the *)
(* defining procedure. We add an edge in the call graph.*) (* defining procedure. We add an edge in the call graph.*)
Cg.add_edge context.cg procname block_pname; Cg.add_edge context.cg procname block_pname;
@ -2100,7 +2100,7 @@ struct
call_translation context decl; call_translation context decl;
let procname = Cfg.Procdesc.get_proc_name context.procdesc in let procname = Cfg.Procdesc.get_proc_name context.procdesc in
let lambda_pname = CMethod_trans.get_procname_from_cpp_lambda context decl in let lambda_pname = CMethod_trans.get_procname_from_cpp_lambda context decl in
let typ = CTypes_decl.type_ptr_to_sil_type context.tenv type_ptr in let typ = CType_decl.type_ptr_to_sil_type context.tenv type_ptr in
(* We need to set the explicit dependency between the newly created lambda and the *) (* We need to set the explicit dependency between the newly created lambda and the *)
(* defining procedure. We add an edge in the call graph.*) (* defining procedure. We add an edge in the call graph.*)
Cg.add_edge context.cg procname lambda_pname; Cg.add_edge context.cg procname lambda_pname;
@ -2110,7 +2110,7 @@ struct
and cxxNewExpr_trans trans_state stmt_info expr_info cxx_new_expr_info = and cxxNewExpr_trans trans_state stmt_info expr_info cxx_new_expr_info =
let context = trans_state.context in let context = trans_state.context in
let typ = CTypes_decl.get_type_from_expr_info expr_info context.tenv in let typ = CType_decl.get_type_from_expr_info expr_info context.tenv in
let sil_loc = CLocation.get_sil_location stmt_info context in let sil_loc = CLocation.get_sil_location stmt_info context in
let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in
let is_dyn_array = cxx_new_expr_info.Clang_ast_t.xnei_is_array in let is_dyn_array = cxx_new_expr_info.Clang_ast_t.xnei_is_array in
@ -2219,7 +2219,7 @@ struct
let subtypes = Subtype.subtypes_cast in let subtypes = Subtype.subtypes_cast in
let tenv = context.CContext.tenv in let tenv = context.CContext.tenv in
let sil_loc = CLocation.get_sil_location stmt_info context in let sil_loc = CLocation.get_sil_location stmt_info context in
let cast_type = CTypes_decl.type_ptr_to_sil_type tenv cast_type_ptr in let cast_type = CType_decl.type_ptr_to_sil_type tenv cast_type_ptr in
let sizeof_expr = match cast_type with let sizeof_expr = match cast_type with
| Typ.Tptr (typ, _) -> Exp.Sizeof (typ, None, subtypes) | Typ.Tptr (typ, _) -> Exp.Sizeof (typ, None, subtypes)
| _ -> assert false in | _ -> assert false in
@ -2272,7 +2272,7 @@ struct
and cxxTypeidExpr_trans trans_state stmt_info stmts expr_info = and cxxTypeidExpr_trans trans_state stmt_info stmts expr_info =
let tenv = trans_state.context.CContext.tenv in let tenv = trans_state.context.CContext.tenv in
let typ = CTypes_decl.get_type_from_expr_info expr_info tenv in let typ = CType_decl.get_type_from_expr_info expr_info tenv in
let sil_loc = CLocation.get_sil_location stmt_info trans_state.context in let sil_loc = CLocation.get_sil_location stmt_info trans_state.context in
let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in
let res_trans_subexpr = let res_trans_subexpr =
@ -2304,7 +2304,7 @@ struct
let tenv = context.CContext.tenv in let tenv = context.CContext.tenv in
let sil_loc = CLocation.get_sil_location stmt_info trans_state.context in let sil_loc = CLocation.get_sil_location stmt_info trans_state.context in
let type_pointer = expr_info.Clang_ast_t.ei_type_ptr in let type_pointer = expr_info.Clang_ast_t.ei_type_ptr in
let typ = CTypes_decl.type_ptr_to_sil_type tenv type_pointer in let typ = CType_decl.type_ptr_to_sil_type tenv type_pointer in
let fun_name = Procname.from_string_c_fun CFrontend_config.infer_skip_fun in let fun_name = Procname.from_string_c_fun CFrontend_config.infer_skip_fun in
let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in let trans_state_pri = PriorityNode.try_claim_priority_node trans_state stmt_info in
let trans_state_param = { trans_state_pri with succ_nodes = [] } in let trans_state_param = { trans_state_pri with succ_nodes = [] } in
@ -2325,7 +2325,7 @@ struct
and objCBridgedCastExpr_trans trans_state stmts expr_info = and objCBridgedCastExpr_trans trans_state stmts expr_info =
let stmt = extract_stmt_from_singleton stmts "" in let stmt = extract_stmt_from_singleton stmts "" in
let tenv = trans_state.context.CContext.tenv in let tenv = trans_state.context.CContext.tenv in
let typ = CTypes_decl.get_type_from_expr_info expr_info tenv in let typ = CType_decl.get_type_from_expr_info expr_info tenv in
let trans_state' = { trans_state with obj_bridged_cast_typ = Some typ } in let trans_state' = { trans_state with obj_bridged_cast_typ = Some typ } in
instruction trans_state' stmt instruction trans_state' stmt
@ -2353,7 +2353,7 @@ struct
and trans_into_undefined_expr trans_state expr_info = and trans_into_undefined_expr trans_state expr_info =
let tenv = trans_state.context.CContext.tenv in let tenv = trans_state.context.CContext.tenv in
let typ = CTypes_decl.get_type_from_expr_info expr_info tenv in let typ = CType_decl.get_type_from_expr_info expr_info tenv in
{ empty_res_trans with exps = [CTrans_utils.undefined_expression (), typ] } { empty_res_trans with exps = [CTrans_utils.undefined_expression (), typ] }
(* Translates a clang instruction into SIL instructions. It takes a *) (* Translates a clang instruction into SIL instructions. It takes a *)

@ -350,11 +350,11 @@ let objc_new_trans trans_state loc stmt_info cls_name function_type =
let new_or_alloc_trans trans_state loc stmt_info type_ptr class_name_opt selector = let new_or_alloc_trans trans_state loc stmt_info type_ptr class_name_opt selector =
let tenv = trans_state.context.CContext.tenv in let tenv = trans_state.context.CContext.tenv in
let function_type = CTypes_decl.type_ptr_to_sil_type tenv type_ptr in let function_type = CType_decl.type_ptr_to_sil_type tenv type_ptr in
let class_name = let class_name =
match class_name_opt with match class_name_opt with
| Some class_name -> class_name | Some class_name -> class_name
| None -> CTypes.classname_of_type function_type in | None -> CType.classname_of_type function_type in
if selector = CFrontend_config.alloc then if selector = CFrontend_config.alloc then
alloc_trans trans_state loc stmt_info function_type true None alloc_trans trans_state loc stmt_info function_type true None
else if selector = CFrontend_config.new_str then else if selector = CFrontend_config.new_str then
@ -373,7 +373,7 @@ let cpp_new_trans sil_loc function_type size_exp_opt =
let create_cast_instrs exp cast_from_typ cast_to_typ sil_loc = let create_cast_instrs exp cast_from_typ cast_to_typ sil_loc =
let ret_id = Ident.create_fresh Ident.knormal in let ret_id = Ident.create_fresh Ident.knormal in
let ret_id_typ = Some (ret_id, cast_to_typ) in let ret_id_typ = Some (ret_id, cast_to_typ) in
let typ = CTypes.remove_pointer_to_typ cast_to_typ in let typ = CType.remove_pointer_to_typ cast_to_typ in
let sizeof_exp = Exp.Sizeof (typ, None, Subtype.exact) in let sizeof_exp = Exp.Sizeof (typ, None, Subtype.exact) in
let pname = BuiltinDecl.__objc_cast in let pname = BuiltinDecl.__objc_cast in
let args = [(exp, cast_from_typ); (sizeof_exp, Typ.Tint Typ.IULong)] in let args = [(exp, cast_from_typ); (sizeof_exp, Typ.Tint Typ.IULong)] in
@ -584,8 +584,8 @@ struct
if is_superinstance mei then if is_superinstance mei then
let typ, self_expr, ins = let typ, self_expr, ins =
let t' = let t' =
CTypes.add_pointer_to_typ CType.add_pointer_to_typ
(CTypes_decl.get_type_curr_class_objc context.CContext.curr_class) in (CType_decl.get_type_curr_class_objc context.CContext.curr_class) in
let e = Exp.Lvar (Pvar.mk (Mangled.from_string CFrontend_config.self) procname) in let e = Exp.Lvar (Pvar.mk (Mangled.from_string CFrontend_config.self) procname) in
let id = Ident.create_fresh Ident.knormal in let id = Ident.create_fresh Ident.knormal in
t', Exp.Var id, [Sil.Load (id, e, t', loc)] in t', Exp.Var id, [Sil.Load (id, e, t', loc)] in
@ -662,7 +662,7 @@ let rec contains_opaque_value_expr s =
(* checks if a unary operator is a logic negation applied to integers*) (* checks if a unary operator is a logic negation applied to integers*)
let is_logical_negation_of_int tenv ei uoi = let is_logical_negation_of_int tenv ei uoi =
match CTypes_decl.type_ptr_to_sil_type tenv ei.Clang_ast_t.ei_type_ptr, uoi.Clang_ast_t.uoi_kind with match CType_decl.type_ptr_to_sil_type tenv ei.Clang_ast_t.ei_type_ptr, uoi.Clang_ast_t.uoi_kind with
| Typ.Tint _,`LNot -> true | Typ.Tint _,`LNot -> true
| _, _ -> false | _, _ -> false
@ -672,7 +672,7 @@ let rec is_block_stmt stmt =
| BlockExpr _ -> true | BlockExpr _ -> true
| DeclRefExpr (_, _, expr_info, _) -> | DeclRefExpr (_, _, expr_info, _) ->
let tp = expr_info.Clang_ast_t.ei_type_ptr in let tp = expr_info.Clang_ast_t.ei_type_ptr in
CTypes.is_block_type tp CType.is_block_type tp
| _ -> (match snd (Clang_ast_proj.get_stmt_tuple stmt) with | _ -> (match snd (Clang_ast_proj.get_stmt_tuple stmt) with
| [sub_stmt] -> is_block_stmt sub_stmt | [sub_stmt] -> is_block_stmt sub_stmt
| _ -> false) | _ -> false)

@ -182,7 +182,7 @@ and type_ptr_to_sil_type translate_decl tenv type_ptr =
Typ.Tptr (sil_typ, Typ.Pk_reference) Typ.Tptr (sil_typ, Typ.Pk_reference)
| `ClassType (name, lang) -> | `ClassType (name, lang) ->
let kind = match lang with `OBJC -> Csu.Objc | `CPP -> Csu.CPP in let kind = match lang with `OBJC -> Csu.Objc | `CPP -> Csu.CPP in
Typ.Tstruct (CTypes.mk_classname name kind) Typ.Tstruct (CType.mk_classname name kind)
| `StructType name -> Typ.Tstruct (CTypes.mk_structname name) | `StructType name -> Typ.Tstruct (CType.mk_structname name)
| `DeclPtr ptr -> decl_ptr_to_sil_type translate_decl tenv ptr | `DeclPtr ptr -> decl_ptr_to_sil_type translate_decl tenv ptr
| `ErrorType -> Typ.Tvoid | `ErrorType -> Typ.Tvoid

@ -72,7 +72,7 @@ let rec compute_autorelease_pool_vars context stmts =
| Some decl_ref -> | Some decl_ref ->
(match decl_ref.Clang_ast_t.dr_type_ptr with (match decl_ref.Clang_ast_t.dr_type_ptr with
| Some type_ptr when decl_ref.Clang_ast_t.dr_kind = `Var -> | Some type_ptr when decl_ref.Clang_ast_t.dr_kind = `Var ->
let typ = CTypes_decl.type_ptr_to_sil_type context.CContext.tenv type_ptr in let typ = CType_decl.type_ptr_to_sil_type context.CContext.tenv type_ptr in
let pvar = sil_var_of_decl_ref context decl_ref procname in let pvar = sil_var_of_decl_ref context decl_ref procname in
if Pvar.is_local pvar then if Pvar.is_local pvar then
General_utils.append_no_duplicateds [(Exp.Lvar pvar, typ)] res General_utils.append_no_duplicateds [(Exp.Lvar pvar, typ)] res
@ -97,7 +97,7 @@ let captured_vars_from_block_info context cvl =
vars vars
else else
let pvar = sil_var_of_decl_ref context dr procname in let pvar = sil_var_of_decl_ref context dr procname in
let typ = CTypes_decl.type_ptr_to_sil_type context.CContext.tenv type_ptr in let typ = CType_decl.type_ptr_to_sil_type context.CContext.tenv type_ptr in
(pvar, typ) :: vars (pvar, typ) :: vars
| _ -> assert false) | _ -> assert false)
| _ -> assert false in | _ -> assert false in

@ -97,7 +97,7 @@ let create_supers_fields type_ptr_to_sil_type tenv curr_class decl_list
let add_class_to_tenv type_ptr_to_sil_type tenv curr_class decl_info name_info decl_list ocidi = let add_class_to_tenv type_ptr_to_sil_type tenv curr_class decl_info name_info decl_list ocidi =
let class_name = Ast_utils.get_qualified_name name_info in let class_name = Ast_utils.get_qualified_name name_info in
Logging.out_debug "ADDING: ObjCInterfaceDecl for '%s'\n" class_name; Logging.out_debug "ADDING: ObjCInterfaceDecl for '%s'\n" class_name;
let interface_name = CTypes.mk_classname class_name Csu.Objc in let interface_name = CType.mk_classname class_name Csu.Objc in
let decl_key = `DeclPtr decl_info.Clang_ast_t.di_pointer in let decl_key = `DeclPtr decl_info.Clang_ast_t.di_pointer in
Ast_utils.update_sil_types_map decl_key (Typ.Tstruct interface_name); Ast_utils.update_sil_types_map decl_key (Typ.Tstruct interface_name);
let supers, fields = let supers, fields =

Loading…
Cancel
Save