Drop ti_raw field from clang_ast_t.type_info

Summary:
ti_raw field tends to grow exponensially for template instantiations.
ASTexporter no longer gives this bit of information and infer needs to stop using it.

Reviewed By: jvillard

Differential Revision: D3798192

fbshipit-source-id: ba7cbb9
master
Andrzej Kotulski 8 years ago committed by Facebook Github Bot 3
parent 21ecba2d17
commit ad325d5047

@ -1 +1 @@
Subproject commit e265f1c643f4cc3db1c252ed9c04c97b62f7474e
Subproject commit 33f4a5b5c4b213998e5c19af48728a3a695884ae

@ -163,7 +163,7 @@ let assign_pointer_warning _ decl_info pname obj_c_property_decl_info =
let raw_ptr = Clang_ast_types.type_ptr_to_clang_pointer type_ptr in
match Clang_ast_main.PointerMap.find raw_ptr !CFrontend_config.pointer_type_index with
| MemberPointerType _ | ObjCObjectPointerType _ | BlockPointerType _ -> true
| TypedefType (type_info, _) -> type_info.ti_raw = "id"
| TypedefType (_, tti) -> (Ast_utils.name_of_typedef_type_info tti) = CFrontend_config.id_cl
| exception Not_found -> false
| _ -> false in
has_assign_property() && is_pointer_type () in

@ -278,12 +278,19 @@ struct
| Some AttributedType (_, attr_info) -> attr_info.ati_attr_kind = `Nullable
| _ -> false
let string_of_type_ptr type_ptr =
match get_desugared_type type_ptr with
| Some typ ->
let type_info = Clang_ast_proj.get_type_tuple typ in
type_info.Clang_ast_t.ti_raw
| None -> ""
let string_of_type_ptr type_ptr = Clang_ast_j.string_of_type_ptr type_ptr
let name_of_typedef_type_info {Clang_ast_t.tti_decl_ptr} =
match get_decl tti_decl_ptr with
| Some TypedefDecl (_, name_decl_info, _, _, _) ->
get_qualified_name name_decl_info
| _ -> ""
let name_opt_of_typedef_type_ptr type_ptr =
match get_type type_ptr with
| Some Clang_ast_t.TypedefType (_, typedef_type_info) ->
Some (name_of_typedef_type_info typedef_type_info)
| _ -> None
let string_of_qual_type {Clang_ast_t.qt_type_ptr; qt_is_const} =
Printf.sprintf "%s%s" (if qt_is_const then "is_const " else "") (string_of_type_ptr qt_type_ptr)
@ -696,7 +703,7 @@ struct
let mk_sil_var name decl_info_type_ptr_opt procname outer_procname =
let name_string = Ast_utils.get_qualified_name name in
match decl_info_type_ptr_opt with
| Some (decl_info, type_ptr, var_decl_info, should_be_mangled) ->
| Some (decl_info, _, var_decl_info, should_be_mangled) ->
let name_string, simple_name = get_var_name_mangled name var_decl_info in
if var_decl_info.Clang_ast_t.vdi_is_global then
let global_mangled_name =
@ -706,11 +713,10 @@ struct
Pvar.mk_global global_mangled_name
else if not should_be_mangled then Pvar.mk simple_name procname
else
let type_name = Ast_utils.string_of_type_ptr type_ptr in
let start_location = fst decl_info.Clang_ast_t.di_source_range in
let line_opt = start_location.Clang_ast_t.sl_line in
let line_str = match line_opt with | Some line -> string_of_int line | None -> "" in
let mangled = string_crc_hex32 (type_name ^ line_str) in
let mangled = string_crc_hex32 line_str in
let mangled_name = Mangled.mangled name_string mangled in
Pvar.mk mangled_name procname
| None -> Pvar.mk (Mangled.from_string name_string) procname

@ -92,7 +92,14 @@ sig
NOTE: this function needs extending to handle objC types *)
val get_decl_from_typ_ptr : Clang_ast_t.type_ptr -> Clang_ast_t.decl option
(** returns string representation of type_ptr
NOTE: this doesn't expand type, it only converts type_ptr to string *)
val string_of_type_ptr : Clang_ast_t.type_ptr -> string
val name_of_typedef_type_info : Clang_ast_t.typedef_type_info -> string
(** returns name of typedef if type_ptr points to Typedef, None otherwise *)
val name_opt_of_typedef_type_ptr : Clang_ast_t.type_ptr -> string option
val string_of_qual_type : Clang_ast_t.qual_type -> string
val make_name_decl : string -> Clang_ast_t.named_decl_info

@ -352,8 +352,9 @@ struct
let objCSelectorExpr_trans trans_state expr_info selector =
stringLiteral_trans trans_state expr_info selector
let objCEncodeExpr_trans trans_state expr_info type_ptr =
stringLiteral_trans trans_state expr_info (Ast_utils.string_of_type_ptr type_ptr)
let objCEncodeExpr_trans trans_state expr_info objc_encode_expr_info =
let type_raw = objc_encode_expr_info.Clang_ast_t.oeei_raw in
stringLiteral_trans trans_state expr_info type_raw
let objCProtocolExpr_trans trans_state expr_info decl_ref =
let name = (match decl_ref.Clang_ast_t.dr_name with
@ -2504,8 +2505,8 @@ struct
| ObjCSelectorExpr(_, _, expr_info, selector) ->
objCSelectorExpr_trans trans_state expr_info selector
| ObjCEncodeExpr(_, _, expr_info, type_ptr) ->
objCEncodeExpr_trans trans_state expr_info type_ptr
| ObjCEncodeExpr(_, _, expr_info, objc_encode_expr_info) ->
objCEncodeExpr_trans trans_state expr_info objc_encode_expr_info
| ObjCProtocolExpr(_, _, expr_info, decl_ref) ->
objCProtocolExpr_trans trans_state expr_info decl_ref

@ -69,17 +69,25 @@ let is_modeled_builtin funct =
let is_modeled_attribute attr_name =
IList.mem string_equal attr_name CFrontend_config.modeled_function_attributes
let get_first_param_typedef_string_opt type_ptr =
match Ast_utils.get_desugared_type type_ptr with
| Some Clang_ast_t.FunctionProtoType (_, _, {pti_params_type = [param_ptr]}) ->
Ast_utils.name_opt_of_typedef_type_ptr param_ptr
| _ -> None
let is_release_builtin funct fun_type =
let pn = Procname.from_string_c_fun funct in
let typ = Ast_utils.string_of_type_ptr fun_type in
if Specs.summary_exists pn then false
else is_release_predefined_model typ pn
else match get_first_param_typedef_string_opt fun_type with
| Some typ -> is_release_predefined_model typ pn
| _ -> false
let is_retain_builtin funct fun_type =
let pn = Procname.from_string_c_fun funct in
let typ = Ast_utils.string_of_type_ptr fun_type in
if Specs.summary_exists pn then false
else is_retain_predefined_model typ pn
else match get_first_param_typedef_string_opt fun_type with
| Some typ -> is_retain_predefined_model typ pn
| _ -> false
let is_assert_log_s funct =
funct = CFrontend_config.assert_rtn ||

Loading…
Cancel
Save