diff --git a/infer/src/al/ALIssues.ml b/infer/src/al/ALIssues.ml index ef4993b33..ab89a31a7 100644 --- a/infer/src/al/ALIssues.ml +++ b/infer/src/al/ALIssues.ml @@ -499,7 +499,7 @@ let fill_issue_desc_info_and_log context ~witness ~current_node (issue_desc : CI let suggestion = Option.map ~f:process_message issue_desc.suggestion in let issue_desc' = {issue_desc with description; loc; suggestion} in try log_frontend_issue context.CLintersContext.current_method witness issue_desc' - with CFrontend_config.IncorrectAssumption e -> + with CFrontend_errors.IncorrectAssumption e -> let trans_unit_ctx = context.CLintersContext.translation_unit_context in ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position e.source_range e.ast_node diff --git a/infer/src/al/ComponentKit.ml b/infer/src/al/ComponentKit.ml index b6d400856..2321ee619 100644 --- a/infer/src/al/ComponentKit.ml +++ b/infer/src/al/ComponentKit.ml @@ -162,7 +162,7 @@ let mutable_local_vars_advice context an = | _ -> None else None - with CFrontend_config.IncorrectAssumption e -> + with CFrontend_errors.IncorrectAssumption e -> let trans_unit_ctx = context.CLintersContext.translation_unit_context in ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position e.source_range e.ast_node ; diff --git a/infer/src/al/cTL.ml b/infer/src/al/cTL.ml index 4999607b1..303fec23e 100644 --- a/infer/src/al/cTL.ml +++ b/infer/src/al/cTL.ml @@ -1386,7 +1386,7 @@ and eval_formula f an lcxt : Ctl_parser_types.ast_node option = None | Atomic (name, params) -> ( try if eval_Atomic name params an lcxt then Some an else None - with CFrontend_config.IncorrectAssumption e -> + with CFrontend_errors.IncorrectAssumption e -> let trans_unit_ctx = lcxt.CLintersContext.translation_unit_context in ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position e.source_range e.ast_node ; diff --git a/infer/src/clang/CMethodProperties.ml b/infer/src/clang/CMethodProperties.ml index ce9d3894a..dcfa3dce5 100644 --- a/infer/src/clang/CMethodProperties.ml +++ b/infer/src/clang/CMethodProperties.ml @@ -25,7 +25,7 @@ let get_method_kind meth_decl = | BlockDecl _ -> ClangMethodKind.BLOCK | _ -> - raise CFrontend_config.Invalid_declaration + raise CFrontend_errors.Invalid_declaration let rec is_inside_objc_class_method meth_decl = @@ -55,7 +55,7 @@ let get_return_type method_decl = | ObjCMethodDecl (_, _, omdi) -> omdi.omdi_result_type | _ -> - raise CFrontend_config.Invalid_declaration + raise CFrontend_errors.Invalid_declaration let get_param_decls method_decl = @@ -72,7 +72,7 @@ let get_param_decls method_decl = | BlockDecl (_, block_decl_info) -> block_decl_info.bdi_parameters | _ -> - raise CFrontend_config.Invalid_declaration + raise CFrontend_errors.Invalid_declaration let get_method_body method_decl = @@ -89,7 +89,7 @@ let get_method_body method_decl = | BlockDecl (_, block_decl_info) -> block_decl_info.bdi_body | _ -> - raise CFrontend_config.Invalid_declaration + raise CFrontend_errors.Invalid_declaration let is_cpp_virtual method_decl = @@ -161,7 +161,7 @@ let is_variadic method_decl = | BlockDecl (_, block_decl_info) -> block_decl_info.bdi_is_variadic | _ -> - raise CFrontend_config.Invalid_declaration + raise CFrontend_errors.Invalid_declaration let get_block_captured_variables method_decl = diff --git a/infer/src/clang/CType_decl.ml b/infer/src/clang/CType_decl.ml index 069bb1e82..bdad6a1ac 100644 --- a/infer/src/clang/CType_decl.ml +++ b/infer/src/clang/CType_decl.ml @@ -50,7 +50,7 @@ module BuildMethodSignature = struct | _ -> None ) | _ -> - raise CFrontend_config.Invalid_declaration + raise CFrontend_errors.Invalid_declaration let should_add_return_param return_type ~is_objc_method = @@ -98,7 +98,7 @@ module BuildMethodSignature = struct let annot = CAst_utils.sil_annot_of_type qt in CMethodSignature.mk_param_type name typ ~is_pointer_to_const ~annot | _ -> - raise CFrontend_config.Invalid_declaration + raise CFrontend_errors.Invalid_declaration in let params = List.map ~f:par_to_ms_par (CMethodProperties.get_param_decls method_decl) in let return_param = @@ -614,7 +614,7 @@ and get_class_typename ?tenv method_decl_info = | Some class_decl -> get_record_typename ?tenv class_decl | None -> - CFrontend_config.incorrect_assumption __POS__ method_decl_info.Clang_ast_t.di_source_range + CFrontend_errors.incorrect_assumption __POS__ method_decl_info.Clang_ast_t.di_source_range "Expecting class declaration when getting the class typename" diff --git a/infer/src/clang/ast_expressions.ml b/infer/src/clang/ast_expressions.ml index dbe90a324..01ff50488 100644 --- a/infer/src/clang/ast_expressions.ml +++ b/infer/src/clang/ast_expressions.ml @@ -165,7 +165,7 @@ let make_next_object_exp stmt_info item items = | [stmt] -> get_decl_ref stmt | _ -> - CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range "unexpected item %a" (Pp.to_string ~f:Clang_ast_j.string_of_stmt) item ) diff --git a/infer/src/clang/cArithmetic_trans.ml b/infer/src/clang/cArithmetic_trans.ml index a31741bae..5c62d7a42 100644 --- a/infer/src/clang/cArithmetic_trans.ml +++ b/infer/src/clang/cArithmetic_trans.ml @@ -59,7 +59,7 @@ let binary_operation_instruction source_range boi ((e1, t1) as e1_with_typ) typ but the translation of the argument expressions does not compute such offsets and instead passes the member pointer at type 'void'. *) | `PtrMemD | `PtrMemI -> - CFrontend_config.unimplemented __POS__ source_range + CFrontend_errors.unimplemented __POS__ source_range "Pointer-to-member constructs are unsupported. Got '%a'." (Pp.to_string ~f:Clang_ast_j.string_of_binary_operator_info) boi @@ -106,7 +106,7 @@ let binary_operation_instruction source_range boi ((e1, t1) as e1_with_typ) typ | `Assign -> (e1, [Sil.Store (e1, typ, e2, loc)]) | `Cmp -> - CFrontend_config.unimplemented __POS__ source_range "C++20 spaceship operator <=>" + CFrontend_errors.unimplemented __POS__ source_range "C++20 spaceship operator <=>" (* C++20 spaceship operator <=>, TODO *) | `Comma -> (e2, []) (* C99 6.5.17-2 *) diff --git a/infer/src/clang/cAst_utils.ml b/infer/src/clang/cAst_utils.ml index 5f22c14a9..da53d80b6 100644 --- a/infer/src/clang/cAst_utils.ml +++ b/infer/src/clang/cAst_utils.ml @@ -110,7 +110,7 @@ let get_decl_opt decl_ptr_opt = let get_stmt stmt_ptr source_range = let stmt = Int.Table.find ClangPointers.pointer_stmt_table stmt_ptr in if Option.is_none stmt then - CFrontend_config.incorrect_assumption __POS__ source_range "stmt with pointer %d not found@\n" + CFrontend_errors.incorrect_assumption __POS__ source_range "stmt with pointer %d not found@\n" stmt_ptr ; stmt diff --git a/infer/src/clang/cContext.ml b/infer/src/clang/cContext.ml index ef3780cd4..e9c09e139 100644 --- a/infer/src/clang/cContext.ml +++ b/infer/src/clang/cContext.ml @@ -73,7 +73,7 @@ let get_curr_class_decl_ptr stmt_info curr_class = | ContextClsDeclPtr ptr -> ptr | _ -> - CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range "current class is not ContextClsDeclPtr" diff --git a/infer/src/clang/cFrontend_config.ml b/infer/src/clang/cFrontend_config.ml index e579081eb..c2e503e66 100644 --- a/infer/src/clang/cFrontend_config.ml +++ b/infer/src/clang/cFrontend_config.ml @@ -6,7 +6,6 @@ *) open! IStd -module F = Format (** Module that contains constants and global state used in the frontend *) @@ -18,29 +17,9 @@ let string_of_clang_lang (lang : clang_lang) : string = let equal_clang_lang = [%compare.equal: clang_lang] -type exception_details = - { msg: string - ; position: Logging.ocaml_pos - ; source_range: Clang_ast_t.source_range - ; ast_node: string option } - -exception Unimplemented of exception_details - -let unimplemented position source_range ?ast_node fmt = - F.kasprintf (fun msg -> raise (Unimplemented {msg; position; source_range; ast_node})) fmt - - -exception IncorrectAssumption of exception_details - -let incorrect_assumption position source_range ?ast_node fmt = - F.kasprintf (fun msg -> raise (IncorrectAssumption {msg; position; source_range; ast_node})) fmt - - type translation_unit_context = {lang: clang_lang; source_file: SourceFile.t; integer_type_widths: Typ.IntegerWidths.t} -exception Invalid_declaration - (** Constants *) let alloc = "alloc" diff --git a/infer/src/clang/cFrontend_config.mli b/infer/src/clang/cFrontend_config.mli index e6a6f0617..620c843ba 100644 --- a/infer/src/clang/cFrontend_config.mli +++ b/infer/src/clang/cFrontend_config.mli @@ -15,39 +15,9 @@ val string_of_clang_lang : clang_lang -> string val equal_clang_lang : clang_lang -> clang_lang -> bool -type exception_details = - { msg: string - ; position: Logging.ocaml_pos - ; source_range: Clang_ast_t.source_range - ; ast_node: string option } - -exception Unimplemented of exception_details - -val unimplemented : - Logging.ocaml_pos - -> Clang_ast_t.source_range - -> ?ast_node:string - -> ('a, Format.formatter, unit, _) format4 - -> 'a -(** Raise Unimplemented. This is caught at the level of translating a method and makes the frontend - give up on that method. *) - -exception IncorrectAssumption of exception_details - -val incorrect_assumption : - Logging.ocaml_pos - -> Clang_ast_t.source_range - -> ?ast_node:string - -> ('a, Format.formatter, unit, _) format4 - -> 'a -(** Used to mark places in the frontend that incorrectly assume something to be - impossible. TODO(t21762295) get rid of all instances of this. *) - type translation_unit_context = {lang: clang_lang; source_file: SourceFile.t; integer_type_widths: Typ.IntegerWidths.t} -exception Invalid_declaration - (** Constants *) val alloc : string diff --git a/infer/src/clang/cFrontend_decl.ml b/infer/src/clang/cFrontend_decl.ml index 31ce1ae1b..6d42458b5 100644 --- a/infer/src/clang/cFrontend_decl.ml +++ b/infer/src/clang/cFrontend_decl.ml @@ -22,11 +22,11 @@ let protect ~f ~recover ~pp_context (trans_unit_ctx : CFrontend_config.translati (* Always keep going in case of known limitations of the frontend, crash otherwise (by not catching the exception) unless `--keep-going` was passed. Print errors we should fix (t21762295) to the console. *) - | CFrontend_config.Unimplemented e -> + | CFrontend_errors.Unimplemented e -> ClangLogging.log_caught_exception trans_unit_ctx "Unimplemented" e.position e.source_range e.ast_node ; log_and_recover ~print:false "Unimplemented feature:@\n %s@\n" e.msg - | CFrontend_config.IncorrectAssumption e -> + | CFrontend_errors.IncorrectAssumption e -> (* FIXME(t21762295): we do not expect this to happen but it does *) ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position e.source_range e.ast_node ; @@ -122,7 +122,7 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron return_param_typ_opt outer_context_opt extra_instrs | None -> () - with CFrontend_config.IncorrectAssumption e -> + with CFrontend_errors.IncorrectAssumption e -> ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position e.source_range e.ast_node @@ -170,7 +170,7 @@ module CFrontend_decl_funct (T : CModule_type.CTranslation) : CModule_type.CFron ignore (CMethod_trans.create_local_procdesc ~set_objc_accessor_attr trans_unit_ctx cfg tenv ms [] []) - with CFrontend_config.IncorrectAssumption e -> + with CFrontend_errors.IncorrectAssumption e -> ClangLogging.log_caught_exception trans_unit_ctx "IncorrectAssumption" e.position e.source_range e.ast_node diff --git a/infer/src/clang/cFrontend_errors.ml b/infer/src/clang/cFrontend_errors.ml new file mode 100644 index 000000000..70b9f507d --- /dev/null +++ b/infer/src/clang/cFrontend_errors.ml @@ -0,0 +1,28 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open! IStd +module F = Format + +type exception_details = + { msg: string + ; position: Logging.ocaml_pos + ; source_range: Clang_ast_t.source_range + ; ast_node: string option } + +exception Unimplemented of exception_details + +exception IncorrectAssumption of exception_details + +exception Invalid_declaration + +let unimplemented position source_range ?ast_node fmt = + F.kasprintf (fun msg -> raise (Unimplemented {msg; position; source_range; ast_node})) fmt + + +let incorrect_assumption position source_range ?ast_node fmt = + F.kasprintf (fun msg -> raise (IncorrectAssumption {msg; position; source_range; ast_node})) fmt diff --git a/infer/src/clang/cFrontend_errors.mli b/infer/src/clang/cFrontend_errors.mli new file mode 100644 index 000000000..6c7d03929 --- /dev/null +++ b/infer/src/clang/cFrontend_errors.mli @@ -0,0 +1,38 @@ +(* + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + *) + +open! IStd + +type exception_details = + { msg: string + ; position: Logging.ocaml_pos + ; source_range: Clang_ast_t.source_range + ; ast_node: string option } + +exception Unimplemented of exception_details + +exception IncorrectAssumption of exception_details + +exception Invalid_declaration + +val unimplemented : + Logging.ocaml_pos + -> Clang_ast_t.source_range + -> ?ast_node:string + -> ('a, Format.formatter, unit, _) format4 + -> 'a +(** Raise Unimplemented. This is caught at the level of translating a method and makes the frontend + give up on that method. *) + +val incorrect_assumption : + Logging.ocaml_pos + -> Clang_ast_t.source_range + -> ?ast_node:string + -> ('a, Format.formatter, unit, _) format4 + -> 'a +(** Used to mark places in the frontend that incorrectly assume something to be + impossible. TODO(t21762295) get rid of all instances of this. *) diff --git a/infer/src/clang/cGeneral_utils.ml b/infer/src/clang/cGeneral_utils.ml index 4a8e91257..30599ebc6 100644 --- a/infer/src/clang/cGeneral_utils.ml +++ b/infer/src/clang/cGeneral_utils.ml @@ -86,7 +86,7 @@ let get_var_name_mangled decl_info name_info var_decl_info = | "", Some index -> "__param_" ^ string_of_int index | "", None -> - CFrontend_config.incorrect_assumption __POS__ decl_info.Clang_ast_t.di_source_range + CFrontend_errors.incorrect_assumption __POS__ decl_info.Clang_ast_t.di_source_range "Got both empty clang_name and None for param_idx in get_var_name_mangled (%a) (%a)" (Pp.to_string ~f:Clang_ast_j.string_of_named_decl_info) name_info diff --git a/infer/src/clang/cMethod_trans.ml b/infer/src/clang/cMethod_trans.ml index bdcc6cd95..1bebcf32b 100644 --- a/infer/src/clang/cMethod_trans.ml +++ b/infer/src/clang/cMethod_trans.ml @@ -29,7 +29,7 @@ let method_signature_of_pointer tenv pointer = Some ms | None -> None - with CFrontend_config.Invalid_declaration -> None + with CFrontend_errors.Invalid_declaration -> None let get_method_name_from_clang tenv ms_opt = diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 0ce85078d..59c14e982 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -165,7 +165,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s ei | None -> let stmt_info, _ = Clang_ast_proj.get_stmt_tuple stmt in - CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range "Clang_ast_proj.get_expr_tuple stmt returns None, stmt is %a" (Pp.to_string ~f:Clang_ast_j.string_of_stmt) stmt @@ -425,13 +425,13 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s let instrs = [Sil.Store (exp, typ, zero_exp, sil_loc)] in mk_trans_result (exp, typ) {empty_control with instrs} | Tfun _ | Tvoid | Tarray _ | TVar _ -> - CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range "fill_typ_with_zero on type %a" (Typ.pp Pp.text) typ in let res_trans = fill_typ_with_zero var_exp_typ in {res_trans with control= {res_trans.control with initd_exps= [fst var_exp_typ]}} | None -> - CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range "Retrieving var from non-InitListExpr parent" @@ -534,7 +534,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s assert false ) | _ as decl -> (* FIXME(t21762295): we do not expect this to happen but it does *) - CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range "di_parent_pointer should be always set for fields/ivars, but got %a" (Pp.option (Pp.to_string ~f:Clang_ast_j.string_of_decl)) decl @@ -807,7 +807,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | (`CXXMethod | `CXXConversion | `CXXConstructor | `CXXDestructor), _ -> method_deref_trans trans_state ~context decl_ref stmt_info decl_kind | _ -> - CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range "Decl ref expression %a with pointer %d still needs to be translated" (Pp.to_string ~f:Clang_ast_j.string_of_decl_kind) decl_kind decl_ref.Clang_ast_t.dr_decl_pointer @@ -1593,7 +1593,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s if root_nodes <> [] then {op_res_trans with control= {op_res_trans.control with root_nodes}} else op_res_trans | _ -> - CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range "BinaryConditionalOperator not translated" @@ -2200,7 +2200,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | [stmt] -> [init_expr_trans trans_state (var_exp, var_typ) stmt_info (Some stmt)] | _ -> - CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range "InitListExpression for var %a type %a with multiple init statements" Exp.pp var_exp (Typ.pp_full Pp.text) var_typ @@ -2245,7 +2245,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | Tint _ | Tfloat _ | Tptr _ -> initListExpr_builtin_trans trans_state_pri init_stmt_info stmts var_exp var_typ | _ -> - CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range "InitListExp for var %a of type %a" Exp.pp var_exp (Typ.pp Pp.text) var_typ in let res_trans = @@ -2408,7 +2408,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s :: _ -> mk_trans_result (mk_fresh_void_exp_typ ()) empty_control | decl :: _ -> - CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range "In DeclStmt found an unknown declaration type %s" (Clang_ast_j.string_of_decl decl) | [] -> assert false @@ -2431,7 +2431,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | Some stmt -> instruction trans_state stmt | None -> - CFrontend_config.incorrect_assumption __POS__ source_range + CFrontend_errors.incorrect_assumption __POS__ source_range "Expected source expression for OpaqueValueExpr" ) @@ -2793,7 +2793,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | Clang_ast_t.VarDecl (_, _, _, {vdi_init_expr}) -> init_expr_trans trans_state (Exp.Lvar pvar, typ) stmt_info vdi_init_expr | _ -> - CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range "Capture-init statement without var decl" in let translate_normal_capture ~is_by_ref ((pvar, typ) as pvar_typ) @@ -2851,7 +2851,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s translate_normal_capture ~is_by_ref this_typ acc else acc | None, Some _ -> - CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range "Capture-init with init, but no capture" in let lei_captures = CMethod_trans.get_captures_from_cpp_lambda lei_lambda_decl in @@ -3200,12 +3200,12 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | NullStmt _, `FallThroughAttr _ -> no_op_trans trans_state.succ_nodes | _ -> - CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range "attributedStmt [stmt] [attr] with:@\nstmt=%s@\nattr=%s@\n" (Clang_ast_j.string_of_stmt stmt) (Clang_ast_j.string_of_attribute attr) ) | _ -> - CFrontend_config.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.unimplemented __POS__ stmt_info.Clang_ast_t.si_source_range "attributedStmt with:@\nstmts=[%a]@\nattrs=[%a]@\n" (Pp.semicolon_seq (Pp.to_string ~f:Clang_ast_j.string_of_stmt)) stmts @@ -3223,7 +3223,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | Some {control= {root_nodes= []}} | None -> mk_trans_result (mk_fresh_void_exp_typ ()) {empty_control with root_nodes= bn.break} ) | None (* t21762295 *) -> - CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range "Break stmt without continuation: %a" (Pp.to_string ~f:Clang_ast_j.string_of_stmt_info) stmt_info @@ -3240,7 +3240,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s mk_trans_result (mk_fresh_void_exp_typ ()) {empty_control with root_nodes= bn.continue} ) | None (* t21762295 *) -> - CFrontend_config.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range + CFrontend_errors.incorrect_assumption __POS__ stmt_info.Clang_ast_t.si_source_range "Continue stmt without continuation: %a" (Pp.to_string ~f:Clang_ast_j.string_of_stmt_info) stmt_info @@ -3325,7 +3325,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s Config.debug_level_capture >= 1 || match e with - | CFrontend_config.Unimplemented _ | CFrontend_config.IncorrectAssumption _ -> + | CFrontend_errors.Unimplemented _ | CFrontend_errors.IncorrectAssumption _ -> (* these are caught by default, do not print messages unless asked to do so *) false | _ -> @@ -3609,7 +3609,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s (* Infer somehow ended up in templated non instantiated code - right now it's not supported and failure in those cases is expected. *) | CXXDependentScopeMemberExpr ({Clang_ast_t.si_source_range}, _, _) -> - CFrontend_config.unimplemented __POS__ si_source_range + CFrontend_errors.unimplemented __POS__ si_source_range ~ast_node:(Clang_ast_proj.get_stmt_kind_string instr) "Translation of templated code is unsupported: %a" (Pp.to_string ~f:Clang_ast_j.string_of_stmt) @@ -3618,7 +3618,7 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s | WhileStmt ({Clang_ast_t.si_source_range}, _) | DoStmt ({Clang_ast_t.si_source_range}, _) | ObjCForCollectionStmt ({Clang_ast_t.si_source_range}, _) -> - CFrontend_config.incorrect_assumption __POS__ si_source_range "Unexpected shape for %a: %a" + CFrontend_errors.incorrect_assumption __POS__ si_source_range "Unexpected shape for %a: %a" (Pp.to_string ~f:Clang_ast_proj.get_stmt_kind_string) instr (Pp.to_string ~f:Clang_ast_j.string_of_stmt) diff --git a/infer/src/clang/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index f2035547b..e2b5869a9 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -412,7 +412,7 @@ let dereference_value_from_result ?(strip_pointer = false) source_range sil_loc | Tptr (typ, _) -> typ | _ -> - CFrontend_config.incorrect_assumption __POS__ source_range + CFrontend_errors.incorrect_assumption __POS__ source_range "Expected pointer type but found type %a" (Typ.pp_full Pp.text) class_typ in let cast_typ = if strip_pointer then typ_no_ptr else class_typ in diff --git a/infer/src/clang/cVar_decl.ml b/infer/src/clang/cVar_decl.ml index cd54e5cb7..12c62edda 100644 --- a/infer/src/clang/cVar_decl.ml +++ b/infer/src/clang/cVar_decl.ml @@ -48,7 +48,7 @@ let sil_var_of_decl_ref context source_range decl_ref procname = sil_var_of_decl context var_decl procname | None -> (* FIXME(t21762295) *) - CFrontend_config.incorrect_assumption __POS__ source_range + CFrontend_errors.incorrect_assumption __POS__ source_range "pointer '%d' for var decl not found. The var decl was: %a" pointer (Pp.to_string ~f:Clang_ast_j.string_of_decl_ref) decl_ref )