qual_type fields are namespaced now

Summary: Update fcp and make the clang frontend compile.

Reviewed By: akotulski

Differential Revision: D3711709

fbshipit-source-id: fe32923
master
Jules Villard 8 years ago committed by Facebook Github Bot 4
parent b7ec110ea3
commit 7603395ee9

@ -1 +1 @@
Subproject commit cf8bd8235837075d6b5699ec8ce4f985460526ee Subproject commit 02753b33ffcdc9607907270b3d555c4c50738b95

@ -81,7 +81,7 @@ let mutable_local_vars_advice context decl =
&& is_in_main_file decl && is_in_main_file decl
&& (is_objc () || is_objcpp ()) && (is_objc () || is_objcpp ())
&& (not (is_global_var decl)) && (not (is_global_var decl))
&& (not qual_type.is_const) in && (not qual_type.qt_is_const) in
if condition then if condition then
Some { Some {
CIssue.issue = CIssue.Mutable_local_variable_in_component_file; CIssue.issue = CIssue.Mutable_local_variable_in_component_file;

@ -65,6 +65,9 @@ let stmt_info_with_fresh_pointer stmt_info = {
si_source_range = stmt_info.Clang_ast_t.si_source_range; si_source_range = stmt_info.Clang_ast_t.si_source_range;
} }
let create_qual_type ?(is_const=false) qt_type_ptr =
{ Clang_ast_t.qt_type_ptr; qt_is_const=is_const }
let new_constant_type_ptr () = let new_constant_type_ptr () =
let pointer = Ast_utils.get_fresh_pointer () in let pointer = Ast_utils.get_fresh_pointer () in
`Prebuilt pointer `Prebuilt pointer
@ -110,8 +113,6 @@ let create_struct_type struct_name = `StructType struct_name
let create_pointer_type typ = `PointerOf typ let create_pointer_type typ = `PointerOf typ
let create_qual_type ?(is_const=false) type_ptr = { Clang_ast_t.type_ptr; is_const }
let create_reference_type typ = `ReferenceOf typ let create_reference_type typ = `ReferenceOf typ
let create_integer_literal n = let create_integer_literal n =
@ -277,7 +278,7 @@ let make_next_object_exp stmt_info item items =
let var_decl_ref, var_type = let var_decl_ref, var_type =
match item with match item with
| Clang_ast_t.DeclStmt (_, _, [Clang_ast_t.VarDecl(di, name_info, var_qual_type, _)]) -> | Clang_ast_t.DeclStmt (_, _, [Clang_ast_t.VarDecl(di, name_info, var_qual_type, _)]) ->
let var_type = var_qual_type.Clang_ast_t.type_ptr in let var_type = var_qual_type.Clang_ast_t.qt_type_ptr in
let decl_ptr = di.Clang_ast_t.di_pointer in let decl_ptr = di.Clang_ast_t.di_pointer in
let decl_ref = make_decl_ref_tp `Var decl_ptr name_info false var_type in let decl_ref = make_decl_ref_tp `Var decl_ptr name_info false var_type in
let stmt_info_var = { let stmt_info_var = {
@ -401,7 +402,7 @@ let translate_block_enumerate block_name stmt_info stmt_list ei =
| Clang_ast_t.ParmVarDecl (di_idx, name_idx, qt_idx, vdi) -> | Clang_ast_t.ParmVarDecl (di_idx, name_idx, qt_idx, vdi) ->
let zero = create_integer_literal "0" in let zero = create_integer_literal "0" in
(* qt_idx idx = 0; *) (* qt_idx idx = 0; *)
let tp_idx = qt_idx.Clang_ast_t.type_ptr in let tp_idx = qt_idx.Clang_ast_t.qt_type_ptr in
let idx_decl_stmt = make_DeclStmt (fresh_stmt_info stmt_info) di_idx tp_idx let idx_decl_stmt = make_DeclStmt (fresh_stmt_info stmt_info) di_idx tp_idx
name_idx vdi (Some zero) in name_idx vdi (Some zero) in
let idx_ei = make_expr_info tp_idx in let idx_ei = make_expr_info tp_idx in
@ -434,7 +435,7 @@ let translate_block_enumerate block_name stmt_info stmt_list ei =
let stmt_info = fresh_stmt_info stmt_info in let stmt_info = fresh_stmt_info stmt_info in
let malloc_name = Ast_utils.make_name_decl CFrontend_config.malloc in let malloc_name = Ast_utils.make_name_decl CFrontend_config.malloc in
let malloc = create_call stmt_info pointer malloc_name tp_fun [parameter] in let malloc = create_call stmt_info pointer malloc_name tp_fun [parameter] in
let tp = qt.Clang_ast_t.type_ptr in let tp = qt.Clang_ast_t.qt_type_ptr in
let init_exp = create_implicit_cast_expr (fresh_stmt_info stmt_info) [malloc] tp `BitCast in let init_exp = create_implicit_cast_expr (fresh_stmt_info stmt_info) [malloc] tp `BitCast in
make_DeclStmt (fresh_stmt_info stmt_info) di tp name vdi (Some init_exp) make_DeclStmt (fresh_stmt_info stmt_info) di tp name vdi (Some init_exp)
| _ -> assert false in | _ -> assert false in
@ -443,7 +444,7 @@ let translate_block_enumerate block_name stmt_info stmt_list ei =
let stop_equal_no pstop = let stop_equal_no pstop =
match pstop with match pstop with
| Clang_ast_t.ParmVarDecl (di, name, qt, _) -> | Clang_ast_t.ParmVarDecl (di, name, qt, _) ->
let tp = qt.Clang_ast_t.type_ptr in let tp = qt.Clang_ast_t.qt_type_ptr in
let decl_ref = make_decl_ref_tp `Var di.Clang_ast_t.di_pointer name false tp in let decl_ref = make_decl_ref_tp `Var di.Clang_ast_t.di_pointer name false tp in
let cast = cast_expr decl_ref tp in let cast = cast_expr decl_ref tp in
let postfix_deref = { Clang_ast_t.uoi_kind = `Deref; uoi_is_postfix = true } in let postfix_deref = { Clang_ast_t.uoi_kind = `Deref; uoi_is_postfix = true } in
@ -457,7 +458,7 @@ let translate_block_enumerate block_name stmt_info stmt_list ei =
let free_stop pstop = let free_stop pstop =
match pstop with match pstop with
| Clang_ast_t.ParmVarDecl (di, name, qt, _) -> | Clang_ast_t.ParmVarDecl (di, name, qt, _) ->
let tp = qt.Clang_ast_t.type_ptr in let tp = qt.Clang_ast_t.qt_type_ptr in
let tp_fun = create_void_void_type in let tp_fun = create_void_void_type in
let decl_ref = make_decl_ref_tp `Var di.Clang_ast_t.di_pointer name false tp in let decl_ref = make_decl_ref_tp `Var di.Clang_ast_t.di_pointer name false tp in
let cast = cast_expr decl_ref tp in let cast = cast_expr decl_ref tp in
@ -492,7 +493,7 @@ let translate_block_enumerate block_name stmt_info stmt_list ei =
let open Clang_ast_t in let open Clang_ast_t in
match pobj with match pobj with
| ParmVarDecl(di_obj, name_obj, qt_obj, _) -> | ParmVarDecl(di_obj, name_obj, qt_obj, _) ->
let tp_obj = qt_obj.Clang_ast_t.type_ptr in let tp_obj = qt_obj.Clang_ast_t.qt_type_ptr in
let poe_ei = make_general_expr_info tp_obj `RValue `Ordinary in let poe_ei = make_general_expr_info tp_obj `RValue `Ordinary in
let ei_array = get_ei_from_cast decl_ref_expr_array in let ei_array = get_ei_from_cast decl_ref_expr_array in
let ove_array = build_OpaqueValueExpr (fresh_stmt_info stmt_info) decl_ref_expr_array ei_array in let ove_array = build_OpaqueValueExpr (fresh_stmt_info stmt_info) decl_ref_expr_array ei_array in
@ -523,7 +524,7 @@ let translate_block_enumerate block_name stmt_info stmt_list ei =
let make_object_cast_decl_ref_expr objects = let make_object_cast_decl_ref_expr objects =
match objects with match objects with
| Clang_ast_t.DeclStmt (si, _, [Clang_ast_t.VarDecl (_, name, qt, _)]) -> | Clang_ast_t.DeclStmt (si, _, [Clang_ast_t.VarDecl (_, name, qt, _)]) ->
let tp = qt.Clang_ast_t.type_ptr in let tp = qt.Clang_ast_t.qt_type_ptr in
let decl_ref = make_decl_ref_tp `Var si.Clang_ast_t.si_pointer name false tp in let decl_ref = make_decl_ref_tp `Var si.Clang_ast_t.si_pointer name false tp in
cast_expr decl_ref tp cast_expr decl_ref tp
| _ -> assert false in | _ -> assert false in
@ -531,7 +532,7 @@ let translate_block_enumerate block_name stmt_info stmt_list ei =
let build_cast_decl_ref_expr_from_parm p = let build_cast_decl_ref_expr_from_parm p =
match p with match p with
| Clang_ast_t.ParmVarDecl (di, name, qt, _) -> | Clang_ast_t.ParmVarDecl (di, name, qt, _) ->
let tp = qt.Clang_ast_t.type_ptr in let tp = qt.Clang_ast_t.qt_type_ptr in
let decl_ref = make_decl_ref_tp `Var di.Clang_ast_t.di_pointer name false tp in let decl_ref = make_decl_ref_tp `Var di.Clang_ast_t.di_pointer name false tp in
cast_expr decl_ref tp cast_expr decl_ref tp
| _ -> assert false in | _ -> assert false in

@ -58,7 +58,7 @@ let rec get_fields type_ptr_to_sil_type tenv curr_class decl_list =
let add_field name_info qt attributes decl_list' = let add_field name_info qt attributes decl_list' =
let fields = get_fields type_ptr_to_sil_type tenv curr_class decl_list' in let fields = get_fields type_ptr_to_sil_type tenv curr_class decl_list' in
let field_tuple = build_sil_field type_ptr_to_sil_type tenv let field_tuple = build_sil_field type_ptr_to_sil_type tenv
name_info qt.Clang_ast_t.type_ptr attributes in name_info qt.Clang_ast_t.qt_type_ptr attributes in
General_utils.append_no_duplicates_fields [field_tuple] fields in General_utils.append_no_duplicates_fields [field_tuple] fields in
match decl_list with match decl_list with
| [] -> [] | [] -> []

@ -144,7 +144,7 @@ let captured_variables_cxx_ref captured_vars =
| Some VarDecl (_, named_decl_info, qual_type, _) | Some VarDecl (_, named_decl_info, qual_type, _)
| Some ParmVarDecl (_, named_decl_info, qual_type, _) | Some ParmVarDecl (_, named_decl_info, qual_type, _)
| Some ImplicitParamDecl (_, named_decl_info, qual_type, _) -> | Some ImplicitParamDecl (_, named_decl_info, qual_type, _) ->
(match Ast_utils.get_desugared_type qual_type.Clang_ast_t.type_ptr with (match Ast_utils.get_desugared_type qual_type.Clang_ast_t.qt_type_ptr with
| Some RValueReferenceType _ | Some LValueReferenceType _ -> | Some RValueReferenceType _ | Some LValueReferenceType _ ->
named_decl_info::reference_captured_vars named_decl_info::reference_captured_vars
| _ -> reference_captured_vars) | _ -> reference_captured_vars)

@ -110,7 +110,7 @@ let get_parameters 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 type_ptr = qt.Clang_ast_t.type_ptr in let type_ptr = qt.Clang_ast_t.qt_type_ptr in
let param_typ = CTypes_decl.type_ptr_to_sil_type tenv type_ptr in let param_typ = CTypes_decl.type_ptr_to_sil_type tenv type_ptr in
let type_ptr' = match param_typ with let type_ptr' = match param_typ with
| Typ.Tstruct _ when General_utils.is_cpp_translation Config.clang_lang -> | Typ.Tstruct _ when General_utils.is_cpp_translation Config.clang_lang ->
@ -146,9 +146,9 @@ let build_method_signature tenv decl_info procname function_method_decl_info
let get_assume_not_null_calls param_decls = let get_assume_not_null_calls param_decls =
let do_one_param decl = match decl with let do_one_param decl = match decl with
| Clang_ast_t.ParmVarDecl (decl_info, name, qt, _) | Clang_ast_t.ParmVarDecl (decl_info, name, qt, _)
when CFrontend_utils.Ast_utils.is_type_nonnull qt.Clang_ast_t.type_ptr -> when CFrontend_utils.Ast_utils.is_type_nonnull qt.Clang_ast_t.qt_type_ptr ->
let assume_call = Ast_expressions.create_assume_not_null_call let assume_call = Ast_expressions.create_assume_not_null_call
decl_info name qt.Clang_ast_t.type_ptr in decl_info name qt.Clang_ast_t.qt_type_ptr in
[(`ClangStmt assume_call)] [(`ClangStmt assume_call)]
| _ -> [] in | _ -> [] in
IList.flatten (IList.map do_one_param param_decls) IList.flatten (IList.map do_one_param param_decls)
@ -162,7 +162,7 @@ let method_signature_of_decl tenv meth_decl block_data_opt =
match meth_decl, block_data_opt with match meth_decl, block_data_opt with
| FunctionDecl (decl_info, _, qt, fdi), _ -> | FunctionDecl (decl_info, _, qt, fdi), _ ->
let language = Config.clang_lang in let language = Config.clang_lang in
let func_decl = Func_decl_info (fdi, qt.Clang_ast_t.type_ptr, language) in let func_decl = Func_decl_info (fdi, qt.Clang_ast_t.qt_type_ptr, language) in
let procname = General_utils.procname_of_decl meth_decl in let procname = General_utils.procname_of_decl meth_decl in
let ms = build_method_signature tenv decl_info procname func_decl None None in let ms = build_method_signature tenv decl_info procname func_decl None None in
let extra_instrs = get_assume_not_null_calls fdi.Clang_ast_t.fdi_parameters in let extra_instrs = get_assume_not_null_calls fdi.Clang_ast_t.fdi_parameters in
@ -173,7 +173,7 @@ let method_signature_of_decl tenv meth_decl block_data_opt =
| CXXDestructorDecl (decl_info, _, qt, fdi, mdi), _ -> | CXXDestructorDecl (decl_info, _, qt, fdi, mdi), _ ->
let procname = General_utils.procname_of_decl meth_decl in let procname = General_utils.procname_of_decl meth_decl in
let parent_ptr = Option.get decl_info.di_parent_pointer in let parent_ptr = Option.get decl_info.di_parent_pointer in
let method_decl = Cpp_Meth_decl_info (fdi, mdi, parent_ptr, qt.Clang_ast_t.type_ptr) in let method_decl = Cpp_Meth_decl_info (fdi, mdi, parent_ptr, qt.Clang_ast_t.qt_type_ptr) in
let parent_pointer = decl_info.Clang_ast_t.di_parent_pointer in let parent_pointer = decl_info.Clang_ast_t.di_parent_pointer in
let ms = build_method_signature tenv decl_info procname method_decl parent_pointer None in let ms = build_method_signature tenv decl_info procname method_decl parent_pointer None in
let non_null_instrs = get_assume_not_null_calls fdi.Clang_ast_t.fdi_parameters in let non_null_instrs = get_assume_not_null_calls fdi.Clang_ast_t.fdi_parameters in
@ -329,10 +329,10 @@ let sil_func_attributes_of_attributes attrs =
let should_create_procdesc cfg procname defined = let should_create_procdesc cfg procname defined =
match Cfg.Procdesc.find_from_name cfg procname with match Cfg.Procdesc.find_from_name cfg procname with
| Some prevoius_procdesc -> | Some previous_procdesc ->
let is_defined_previous = Cfg.Procdesc.is_defined prevoius_procdesc in let is_defined_previous = Cfg.Procdesc.is_defined previous_procdesc in
if defined && (not is_defined_previous) then if defined && (not is_defined_previous) then
(Cfg.Procdesc.remove cfg (Cfg.Procdesc.get_proc_name prevoius_procdesc) true; (Cfg.Procdesc.remove cfg (Cfg.Procdesc.get_proc_name previous_procdesc) true;
true) true)
else false else false
| None -> true | None -> true

@ -628,7 +628,7 @@ struct
(* Do not convert a global struct to a local because SIL (* Do not convert a global struct to a local because SIL
values do not include structs, they must all be heap-allocated *) values do not include structs, they must all be heap-allocated *)
false, None false, None
| _ -> vdi.vdi_is_global && qual_type.is_const, vdi.vdi_init_expr) | _ -> vdi.vdi_is_global && qual_type.qt_is_const, vdi.vdi_init_expr)
| _ -> false, None in | _ -> false, None in
if is_global_const then if is_global_const then
init_expr_trans trans_state (var_exp, typ) stmt_info init_expr init_expr_trans trans_state (var_exp, typ) stmt_info init_expr
@ -1702,7 +1702,7 @@ struct
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 = CTypes_decl.type_ptr_to_sil_type
context.CContext.tenv context.CContext.tenv
qual_type.Clang_ast_t.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;
let trans_state' = { trans_state with succ_nodes = next_node } in let trans_state' = { trans_state with succ_nodes = next_node } in
init_expr_trans trans_state' (Exp.Lvar pvar, typ) stmt_info vdi.Clang_ast_t.vdi_init_expr in init_expr_trans trans_state' (Exp.Lvar pvar, typ) stmt_info vdi.Clang_ast_t.vdi_init_expr in

@ -157,7 +157,7 @@ let rec get_struct_fields tenv decl =
let do_one_decl decl = match decl with let do_one_decl decl = match decl with
| FieldDecl (_, name_info, qt, _) -> | FieldDecl (_, name_info, qt, _) ->
let id = General_utils.mk_class_field_name name_info in let id = General_utils.mk_class_field_name name_info in
let typ = type_ptr_to_sil_type tenv qt.Clang_ast_t.type_ptr in let typ = type_ptr_to_sil_type tenv qt.Clang_ast_t.qt_type_ptr in
let annotation_items = [] in (* For the moment we don't use them*) let annotation_items = [] in (* For the moment we don't use them*)
[(id, typ, annotation_items)] [(id, typ, annotation_items)]
| _ -> [] in | _ -> [] in

@ -27,11 +27,11 @@ let sil_var_of_decl context var_decl procname =
let shoud_be_mangled = let shoud_be_mangled =
not (is_custom_var_pointer decl_info.Clang_ast_t.di_pointer) in not (is_custom_var_pointer decl_info.Clang_ast_t.di_pointer) in
let var_decl_details = Some let var_decl_details = Some
(decl_info, qual_type.Clang_ast_t.type_ptr, var_decl_info, shoud_be_mangled) in (decl_info, qual_type.Clang_ast_t.qt_type_ptr, var_decl_info, shoud_be_mangled) in
General_utils.mk_sil_var name_info var_decl_details procname outer_procname General_utils.mk_sil_var name_info var_decl_details procname outer_procname
| ParmVarDecl (decl_info, name_info, qual_type, var_decl_info) -> | ParmVarDecl (decl_info, name_info, qual_type, var_decl_info) ->
let var_decl_details = Some let var_decl_details = Some
(decl_info, qual_type.Clang_ast_t.type_ptr, var_decl_info, false) in (decl_info, qual_type.Clang_ast_t.qt_type_ptr, var_decl_info, false) in
General_utils.mk_sil_var name_info var_decl_details procname outer_procname General_utils.mk_sil_var name_info var_decl_details procname outer_procname
| _ -> assert false | _ -> assert false

Loading…
Cancel
Save