diff --git a/infer/src/clang/cArithmetic_trans.ml b/infer/src/clang/cArithmetic_trans.ml index 7dfa97c12..3747dec96 100644 --- a/infer/src/clang/cArithmetic_trans.ml +++ b/infer/src/clang/cArithmetic_trans.ml @@ -135,7 +135,6 @@ let binary_operation_instruction boi e1 typ e2 loc rhs_owning_method = (Exp.minus_one, []) let unary_operation_instruction translation_unit_context uoi e typ loc = - let uok = Clang_ast_j.string_of_unary_operator_kind (uoi.Clang_ast_t.uoi_kind) in let un_exp op = Exp.UnOp(op, e, Some typ) in match uoi.Clang_ast_t.uoi_kind with @@ -176,6 +175,7 @@ let unary_operation_instruction translation_unit_context uoi e typ loc = (e, []) | `AddrOf -> (e, []) | `Real | `Imag | `Extension | `Coawait -> + let uok = Clang_ast_j.string_of_unary_operator_kind (uoi.Clang_ast_t.uoi_kind) in Logging.out "\nWARNING: Missing translation for Unary Operator Kind %s. The construct has been ignored...\n" uok; (e, []) diff --git a/infer/src/clang/cAst_utils.ml b/infer/src/clang/cAst_utils.ml index 6558089da..791370f5f 100644 --- a/infer/src/clang/cAst_utils.ml +++ b/infer/src/clang/cAst_utils.ml @@ -17,45 +17,6 @@ module F = Format type type_ptr_to_sil_type = Tenv.t -> Clang_ast_t.type_ptr -> Typ.t -let string_of_decl decl = - let name = Clang_ast_proj.get_decl_kind_string decl in - let info = Clang_ast_proj.get_decl_tuple decl in - Printf.sprintf "<\"%s\"> '%d'" name info.Clang_ast_t.di_pointer - -let string_of_unary_operator_kind = function - | `PostInc -> "PostInc" - | `PostDec -> "PostDec" - | `PreInc -> "PreInc" - | `PreDec -> "PreDec" - | `AddrOf -> "AddrOf" - | `Deref -> "Deref" - | `Plus -> "Plus" - | `Minus -> "Minus" - | `Not -> "Not" - | `LNot -> "LNot" - | `Real -> "Real" - | `Imag -> "Imag" - | `Extension -> "Extension" - | `Coawait -> "Coawait" - -let string_of_stmt stmt = - let name = Clang_ast_proj.get_stmt_kind_string stmt in - let info, _ = Clang_ast_proj.get_stmt_tuple stmt in - Printf.sprintf "<\"%s\"> '%d'" name info.Clang_ast_t.si_pointer - -let get_stmts_from_stmt stmt = - let open Clang_ast_t in - match stmt with - | OpaqueValueExpr (_, lstmt, _, opaque_value_expr_info) -> - (match opaque_value_expr_info.Clang_ast_t.ovei_source_expr with - | Some stmt -> lstmt @ [stmt] - | _ -> lstmt) - (* given that this has not been translated, looking up for variables *) - (* inside leads to inconsistencies *) - | ObjCAtCatchStmt _ -> - [] - | _ -> snd (Clang_ast_proj.get_stmt_tuple stmt) - let fold_qual_name qual_name_list = match qual_name_list with | [] -> "" @@ -88,44 +49,6 @@ let make_qual_name_decl class_name_quals name = { ni_qual_name = name :: class_name_quals; } -let property_name property_impl_decl_info = - let no_property_name = make_name_decl "WARNING_NO_PROPERTY_NAME" in - match property_impl_decl_info.Clang_ast_t.opidi_property_decl with - | Some decl_ref -> - (match decl_ref.Clang_ast_t.dr_name with - | Some n -> n - | _ -> no_property_name) - | None -> no_property_name - -let generated_ivar_name property_name = - match property_name.Clang_ast_t.ni_qual_name with - | [name; class_name] -> - let ivar_name = "_" ^ name in - { Clang_ast_t.ni_name = ivar_name; - ni_qual_name = [ivar_name; class_name] - } - | _ -> make_name_decl property_name.Clang_ast_t.ni_name - -let get_memory_management_attributes () = - [`Assign; `Retain; `Copy; `Weak; `Strong; `Unsafe_unretained] - -let is_retain attribute_opt = - match attribute_opt with - | Some attribute -> - attribute = `Retain || attribute = `Strong - | _ -> false - -let is_copy attribute_opt = - match attribute_opt with - | Some attribute -> - attribute = `Copy - | _ -> false - -let name_opt_of_name_info_opt name_info_opt = - match name_info_opt with - | Some name_info -> Some (get_qualified_name name_info) - | None -> None - let pointer_counter = ref 0 let get_fresh_pointer () = diff --git a/infer/src/clang/cAst_utils.mli b/infer/src/clang/cAst_utils.mli index b17f86a0f..18b7587ab 100644 --- a/infer/src/clang/cAst_utils.mli +++ b/infer/src/clang/cAst_utils.mli @@ -11,27 +11,6 @@ open! IStd (** Functions for transformations of ast nodes *) -val string_of_stmt : Clang_ast_t.stmt -> string - -val get_stmts_from_stmt : Clang_ast_t.stmt -> Clang_ast_t.stmt list - -val string_of_decl : Clang_ast_t.decl -> string - -val string_of_unary_operator_kind : Clang_ast_t.unary_operator_kind -> string - -val name_opt_of_name_info_opt : Clang_ast_t.named_decl_info option -> string option - -val property_name : Clang_ast_t.obj_c_property_impl_decl_info -> Clang_ast_t.named_decl_info - -val generated_ivar_name : - Clang_ast_t.named_decl_info -> Clang_ast_t.named_decl_info - -val get_memory_management_attributes : unit -> Clang_ast_t.property_attribute list - -val is_retain : Clang_ast_t.property_attribute option -> bool - -val is_copy : Clang_ast_t.property_attribute option -> bool - val is_type_nonnull : Clang_ast_t.type_ptr -> bool val get_fresh_pointer : unit -> Clang_ast_t.pointer diff --git a/infer/src/clang/cFrontend_checkers_main.ml b/infer/src/clang/cFrontend_checkers_main.ml index 13076ffc9..f127ed669 100644 --- a/infer/src/clang/cFrontend_checkers_main.ml +++ b/infer/src/clang/cFrontend_checkers_main.ml @@ -156,8 +156,18 @@ let rec do_frontend_checks_stmt (context:CLintersContext.context) stmt = (* ...and here we analyze the stmt inside the if with the context extended with the condition of the if *) do_all_checks_on_stmts inside_if_stmt_context inside_if_stmt + | OpaqueValueExpr (_, lstmt, _, opaque_value_expr_info) -> + let stmts = (match opaque_value_expr_info.Clang_ast_t.ovei_source_expr with + | Some stmt -> lstmt @ [stmt] + | _ -> lstmt) + in + List.iter ~f:(do_all_checks_on_stmts context) stmts + (* given that this has not been translated, looking up for variables *) + (* inside leads to inconsistencies *) + | ObjCAtCatchStmt _ -> + () | _ -> - let stmts = CAst_utils.get_stmts_from_stmt stmt in + let stmts = snd (Clang_ast_proj.get_stmt_tuple stmt) in List.iter ~f:(do_all_checks_on_stmts context) stmts and do_frontend_checks_decl (context: CLintersContext.context) decl = diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index 2ed6328c8..6e6f8c9be 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -126,7 +126,7 @@ struct | _ -> Logging.out "\nWARNING: found Method Declaration '%s' skipped. NEED TO BE FIXED\n\n" - (CAst_utils.string_of_decl dec); + (Clang_ast_proj.get_decl_kind_string dec); () let process_methods trans_unit_ctx tenv cg cfg curr_class decl_list = @@ -223,7 +223,7 @@ struct let curr_class = CContext.ContextClsDeclPtr parent_ptr in process_methods trans_unit_ctx tenv cg cfg curr_class [dec] | Some dec -> - Logging.out "Methods of %s skipped\n" (CAst_utils.string_of_decl dec) + Logging.out "Methods of %s skipped\n" (Clang_ast_proj.get_decl_kind_string dec) | None -> ()) | VarDecl (decl_info, named_decl_info, qt, ({ vdi_is_global; vdi_init_expr } as vdi)) when vdi_is_global && Option.is_some vdi_init_expr -> diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 026e51cd4..3fb8e4f57 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -2587,7 +2587,7 @@ struct | CXXTryStmt (_, stmts) -> (Logging.out "\n!!!!WARNING: found statement %s. \nTranslation need to be improved.... \n" - (CAst_utils.string_of_stmt instr); + (Clang_ast_proj.get_stmt_kind_string instr); compoundStmt_trans trans_state stmts) | ObjCAtThrowStmt (stmt_info, stmts) @@ -2674,7 +2674,7 @@ struct | s -> (Logging.out "\n!!!!WARNING: found statement %s. \nACTION REQUIRED: \ Translation need to be defined. Statement ignored.... \n" - (CAst_utils.string_of_stmt s); + (Clang_ast_proj.get_stmt_kind_string s); assert false) (* Function similar to instruction function, but it takes C++ constructor initializer as diff --git a/infer/src/clang/objcInterface_decl.ml b/infer/src/clang/objcInterface_decl.ml index 71fa547ea..ac8f173cf 100644 --- a/infer/src/clang/objcInterface_decl.ml +++ b/infer/src/clang/objcInterface_decl.ml @@ -25,7 +25,7 @@ let is_pointer_to_objc_class typ = let get_super_interface_decl otdi_super = match otdi_super with - | Some dr -> CAst_utils.name_opt_of_name_info_opt dr.Clang_ast_t.dr_name + | Some dr -> Option.map ~f:CAst_utils.get_qualified_name dr.Clang_ast_t.dr_name | _ -> None let get_protocols protocols =