diff --git a/facebook-clang-plugins b/facebook-clang-plugins index cf8bd8235..02753b33f 160000 --- a/facebook-clang-plugins +++ b/facebook-clang-plugins @@ -1 +1 @@ -Subproject commit cf8bd8235837075d6b5699ec8ce4f985460526ee +Subproject commit 02753b33ffcdc9607907270b3d555c4c50738b95 diff --git a/infer/src/clang/ComponentKit.ml b/infer/src/clang/ComponentKit.ml index 9b3f09729..352ba10b8 100644 --- a/infer/src/clang/ComponentKit.ml +++ b/infer/src/clang/ComponentKit.ml @@ -81,7 +81,7 @@ let mutable_local_vars_advice context decl = && is_in_main_file decl && (is_objc () || is_objcpp ()) && (not (is_global_var decl)) - && (not qual_type.is_const) in + && (not qual_type.qt_is_const) in if condition then Some { CIssue.issue = CIssue.Mutable_local_variable_in_component_file; diff --git a/infer/src/clang/ast_expressions.ml b/infer/src/clang/ast_expressions.ml index 8077b736f..b9ffcf9cc 100644 --- a/infer/src/clang/ast_expressions.ml +++ b/infer/src/clang/ast_expressions.ml @@ -65,6 +65,9 @@ let stmt_info_with_fresh_pointer stmt_info = { 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 pointer = Ast_utils.get_fresh_pointer () in `Prebuilt pointer @@ -110,8 +113,6 @@ let create_struct_type struct_name = `StructType struct_name 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_integer_literal n = @@ -277,7 +278,7 @@ let make_next_object_exp stmt_info item items = let var_decl_ref, var_type = match item with | 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_ref = make_decl_ref_tp `Var decl_ptr name_info false var_type in 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) -> let zero = create_integer_literal "0" in (* 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 name_idx vdi (Some zero) 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 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 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 make_DeclStmt (fresh_stmt_info stmt_info) di tp name vdi (Some init_exp) | _ -> assert false in @@ -443,7 +444,7 @@ let translate_block_enumerate block_name stmt_info stmt_list ei = let stop_equal_no pstop = match pstop with | 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 cast = cast_expr decl_ref tp 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 = match pstop with | 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 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 @@ -492,7 +493,7 @@ let translate_block_enumerate block_name stmt_info stmt_list ei = let open Clang_ast_t in match pobj with | 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 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 @@ -523,7 +524,7 @@ let translate_block_enumerate block_name stmt_info stmt_list ei = let make_object_cast_decl_ref_expr objects = match objects with | 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 cast_expr decl_ref tp | _ -> 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 = match p with | 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 cast_expr decl_ref tp | _ -> assert false in diff --git a/infer/src/clang/cField_decl.ml b/infer/src/clang/cField_decl.ml index c07faf4a1..11065054f 100644 --- a/infer/src/clang/cField_decl.ml +++ b/infer/src/clang/cField_decl.ml @@ -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 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 - 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 match decl_list with | [] -> [] diff --git a/infer/src/clang/cFrontend_checkers.ml b/infer/src/clang/cFrontend_checkers.ml index 3101e7406..8e00d5c87 100644 --- a/infer/src/clang/cFrontend_checkers.ml +++ b/infer/src/clang/cFrontend_checkers.ml @@ -144,7 +144,7 @@ let captured_variables_cxx_ref captured_vars = | Some VarDecl (_, named_decl_info, qual_type, _) | Some ParmVarDecl (_, 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 _ -> named_decl_info::reference_captured_vars | _ -> reference_captured_vars) diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index b06933972..ffcc4f112 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -110,7 +110,7 @@ let get_parameters tenv function_method_decl_info = match par with | 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 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 type_ptr' = match param_typ with | 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 do_one_param decl = match decl with | 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 - decl_info name qt.Clang_ast_t.type_ptr in + decl_info name qt.Clang_ast_t.qt_type_ptr in [(`ClangStmt assume_call)] | _ -> [] in 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 | FunctionDecl (decl_info, _, qt, fdi), _ -> 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 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 @@ -173,7 +173,7 @@ let method_signature_of_decl tenv meth_decl block_data_opt = | CXXDestructorDecl (decl_info, _, qt, fdi, mdi), _ -> let procname = General_utils.procname_of_decl meth_decl 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 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 @@ -329,10 +329,10 @@ let sil_func_attributes_of_attributes attrs = let should_create_procdesc cfg procname defined = match Cfg.Procdesc.find_from_name cfg procname with - | Some prevoius_procdesc -> - let is_defined_previous = Cfg.Procdesc.is_defined prevoius_procdesc in + | Some previous_procdesc -> + let is_defined_previous = Cfg.Procdesc.is_defined previous_procdesc in 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) else false | None -> true diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 5722250be..d746d6baf 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -628,7 +628,7 @@ struct (* Do not convert a global struct to a local because SIL values do not include structs, they must all be heap-allocated *) 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 if is_global_const then 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 typ = CTypes_decl.type_ptr_to_sil_type 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; 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 diff --git a/infer/src/clang/cTypes_decl.ml b/infer/src/clang/cTypes_decl.ml index 1cce9894e..3bb7fd356 100644 --- a/infer/src/clang/cTypes_decl.ml +++ b/infer/src/clang/cTypes_decl.ml @@ -157,7 +157,7 @@ let rec get_struct_fields tenv decl = let do_one_decl decl = match decl with | FieldDecl (_, name_info, qt, _) -> 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*) [(id, typ, annotation_items)] | _ -> [] in diff --git a/infer/src/clang/cVar_decl.ml b/infer/src/clang/cVar_decl.ml index 3f9c2f93e..20e3f9c73 100644 --- a/infer/src/clang/cVar_decl.ml +++ b/infer/src/clang/cVar_decl.ml @@ -27,11 +27,11 @@ let sil_var_of_decl context var_decl procname = let shoud_be_mangled = not (is_custom_var_pointer decl_info.Clang_ast_t.di_pointer) in 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 | ParmVarDecl (decl_info, name_info, qual_type, var_decl_info) -> 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 | _ -> assert false