From 77e643ee1e467d291250d570ce35b269d4ecab41 Mon Sep 17 00:00:00 2001 From: Varun Arora Date: Thu, 8 Mar 2018 07:12:01 -0800 Subject: [PATCH] combine ocaml_pos and ml_loc Summary: - Noticed that there were two different type aliases for the same type, representing the return value of `__POS__` - Combined them under `ocaml_pos` name which more closely matches the pervasive - Moved to Logging module Reviewed By: dulmarod Differential Revision: D7194034 fbshipit-source-id: 22cb949 --- infer/src/IR/Errlog.ml | 8 +- infer/src/IR/Errlog.mli | 2 +- infer/src/IR/Exceptions.ml | 292 ++++++++++++++------------- infer/src/IR/Exceptions.mli | 89 ++++---- infer/src/backend/interproc.ml | 2 +- infer/src/backend/state.ml | 2 +- infer/src/backend/symExec.ml | 6 +- infer/src/backend/tabulation.mli | 2 +- infer/src/base/EventLogger.ml | 10 +- infer/src/base/EventLogger.mli | 5 +- infer/src/base/Logging.ml | 16 +- infer/src/base/Logging.mli | 10 +- infer/src/clang/ClangLogging.ml | 5 +- infer/src/clang/ClangLogging.mli | 2 +- infer/src/clang/cFrontend_config.ml | 4 +- infer/src/clang/cFrontend_config.mli | 8 +- infer/src/clang/cTrans_utils.ml | 2 +- infer/src/clang/cTrans_utils.mli | 2 +- 18 files changed, 241 insertions(+), 226 deletions(-) diff --git a/infer/src/IR/Errlog.ml b/infer/src/IR/Errlog.ml index 4779ccf72..a83394e84 100644 --- a/infer/src/IR/Errlog.ml +++ b/infer/src/IR/Errlog.ml @@ -80,7 +80,7 @@ type err_data = { node_id_key: node_id_key ; session: int ; loc: Location.t - ; loc_in_ml_source: L.ml_loc option + ; loc_in_ml_source: L.ocaml_pos option ; loc_trace: loc_trace ; err_class: Exceptions.err_class ; visibility: Exceptions.visibility @@ -260,7 +260,7 @@ let log_issue procname err_kind err_log loc (node_id, node_key) session ltr ?lin (* TODO: Add clang_method_kind field (T26423401) *) { bug_type= error.name.IssueType.unique_id ; bug_kind= Exceptions.err_kind_string err_kind - ; exception_triggered_location= Option.map ~f:Logging.ml_loc_to_string error.ml_loc + ; exception_triggered_location= error.ocaml_pos ; lang= Typ.Procname.get_language procname |> Language.to_explicit_string ; procedure_name= Typ.Procname.to_string procname ; source_location= loc } @@ -273,7 +273,7 @@ let log_issue procname err_kind err_log loc (node_id, node_key) session ltr ?lin { node_id_key ; session ; loc - ; loc_in_ml_source= error.ml_loc + ; loc_in_ml_source= error.ocaml_pos ; loc_trace= ltr ; err_class= error.category ; visibility= error.visibility @@ -294,7 +294,7 @@ let log_issue procname err_kind err_log loc (node_id, node_key) session ltr ?lin let print_now () = L.(debug Analysis Medium) "@\n%a@\n@?" - (Exceptions.pp_err ~node_key loc err_kind error.name error.description error.ml_loc) + (Exceptions.pp_err ~node_key loc err_kind error.name error.description error.ocaml_pos) () ; if err_kind <> Exceptions.Kerror then ( let warn_str = diff --git a/infer/src/IR/Errlog.mli b/infer/src/IR/Errlog.mli index 7559820d1..da269a69f 100644 --- a/infer/src/IR/Errlog.mli +++ b/infer/src/IR/Errlog.mli @@ -51,7 +51,7 @@ type err_data = private { node_id_key: node_id_key ; session: int ; loc: Location.t - ; loc_in_ml_source: Logging.ml_loc option + ; loc_in_ml_source: Logging.ocaml_pos option ; loc_trace: loc_trace ; err_class: Exceptions.err_class ; visibility: Exceptions.visibility diff --git a/infer/src/IR/Exceptions.ml b/infer/src/IR/Exceptions.ml index ce60b4620..51c4a66d6 100644 --- a/infer/src/IR/Exceptions.ml +++ b/infer/src/IR/Exceptions.ml @@ -41,52 +41,52 @@ type err_kind = Kwarning | Kerror | Kinfo | Kadvice | Klike [@@deriving compare] let equal_err_kind = [%compare.equal : err_kind] -exception Abduction_case_not_implemented of L.ml_loc +exception Abduction_case_not_implemented of L.ocaml_pos -exception Analysis_stops of Localise.error_desc * L.ml_loc option +exception Analysis_stops of Localise.error_desc * L.ocaml_pos option -exception Array_out_of_bounds_l1 of Localise.error_desc * L.ml_loc +exception Array_out_of_bounds_l1 of Localise.error_desc * L.ocaml_pos -exception Array_out_of_bounds_l2 of Localise.error_desc * L.ml_loc +exception Array_out_of_bounds_l2 of Localise.error_desc * L.ocaml_pos -exception Array_out_of_bounds_l3 of Localise.error_desc * L.ml_loc +exception Array_out_of_bounds_l3 of Localise.error_desc * L.ocaml_pos -exception Array_of_pointsto of L.ml_loc +exception Array_of_pointsto of L.ocaml_pos -exception Bad_footprint of L.ml_loc +exception Bad_footprint of L.ocaml_pos -exception Cannot_star of L.ml_loc +exception Cannot_star of L.ocaml_pos -exception Class_cast_exception of Localise.error_desc * L.ml_loc +exception Class_cast_exception of Localise.error_desc * L.ocaml_pos exception Codequery of Localise.error_desc -exception Comparing_floats_for_equality of Localise.error_desc * L.ml_loc +exception Comparing_floats_for_equality of Localise.error_desc * L.ocaml_pos -exception Condition_always_true_false of Localise.error_desc * bool * L.ml_loc +exception Condition_always_true_false of Localise.error_desc * bool * L.ocaml_pos exception Custom_error of string * Localise.error_desc exception Dangling_pointer_dereference of - PredSymb.dangling_kind option * Localise.error_desc * L.ml_loc + PredSymb.dangling_kind option * Localise.error_desc * L.ocaml_pos exception Deallocate_stack_variable of Localise.error_desc exception Deallocate_static_memory of Localise.error_desc -exception Deallocation_mismatch of Localise.error_desc * L.ml_loc +exception Deallocation_mismatch of Localise.error_desc * L.ocaml_pos -exception Divide_by_zero of Localise.error_desc * L.ml_loc +exception Divide_by_zero of Localise.error_desc * L.ocaml_pos -exception Double_lock of Localise.error_desc * L.ml_loc +exception Double_lock of Localise.error_desc * L.ocaml_pos -exception Empty_vector_access of Localise.error_desc * L.ml_loc +exception Empty_vector_access of Localise.error_desc * L.ocaml_pos exception Eradicate of IssueType.t * Localise.error_desc -exception Field_not_null_checked of Localise.error_desc * L.ml_loc +exception Field_not_null_checked of Localise.error_desc * L.ocaml_pos -exception Frontend_warning of (string * string option) * Localise.error_desc * L.ml_loc +exception Frontend_warning of (string * string option) * Localise.error_desc * L.ocaml_pos exception Checkers of IssueType.t * Localise.error_desc @@ -97,58 +97,58 @@ exception Internal_error of Localise.error_desc exception Java_runtime_exception of Typ.Name.t * string * Localise.error_desc exception Leak of - bool * Sil.hpred * (visibility * Localise.error_desc) * bool * PredSymb.resource * L.ml_loc + bool * Sil.hpred * (visibility * Localise.error_desc) * bool * PredSymb.resource * L.ocaml_pos -exception Missing_fld of Typ.Fieldname.t * L.ml_loc +exception Missing_fld of Typ.Fieldname.t * L.ocaml_pos -exception Premature_nil_termination of Localise.error_desc * L.ml_loc +exception Premature_nil_termination of Localise.error_desc * L.ocaml_pos -exception Null_dereference of Localise.error_desc * L.ml_loc +exception Null_dereference of Localise.error_desc * L.ocaml_pos -exception Null_test_after_dereference of Localise.error_desc * L.ml_loc +exception Null_test_after_dereference of Localise.error_desc * L.ocaml_pos -exception Parameter_not_null_checked of Localise.error_desc * L.ml_loc +exception Parameter_not_null_checked of Localise.error_desc * L.ocaml_pos -exception Pointer_size_mismatch of Localise.error_desc * L.ml_loc +exception Pointer_size_mismatch of Localise.error_desc * L.ocaml_pos -exception Precondition_not_found of Localise.error_desc * L.ml_loc +exception Precondition_not_found of Localise.error_desc * L.ocaml_pos -exception Precondition_not_met of Localise.error_desc * L.ml_loc +exception Precondition_not_met of Localise.error_desc * L.ocaml_pos -exception Retain_cycle of Sil.hpred * Localise.error_desc * L.ml_loc +exception Retain_cycle of Sil.hpred * Localise.error_desc * L.ocaml_pos -exception Registered_observer_being_deallocated of Localise.error_desc * L.ml_loc +exception Registered_observer_being_deallocated of Localise.error_desc * L.ocaml_pos -exception Return_expression_required of Localise.error_desc * L.ml_loc +exception Return_expression_required of Localise.error_desc * L.ocaml_pos -exception Return_statement_missing of Localise.error_desc * L.ml_loc +exception Return_statement_missing of Localise.error_desc * L.ocaml_pos -exception Return_value_ignored of Localise.error_desc * L.ml_loc +exception Return_value_ignored of Localise.error_desc * L.ocaml_pos exception Skip_function of Localise.error_desc -exception Skip_pointer_dereference of Localise.error_desc * L.ml_loc +exception Skip_pointer_dereference of Localise.error_desc * L.ocaml_pos -exception Stack_variable_address_escape of Localise.error_desc * L.ml_loc +exception Stack_variable_address_escape of Localise.error_desc * L.ocaml_pos -exception Symexec_memory_error of L.ml_loc +exception Symexec_memory_error of L.ocaml_pos -exception Unary_minus_applied_to_unsigned_expression of Localise.error_desc * L.ml_loc +exception Unary_minus_applied_to_unsigned_expression of Localise.error_desc * L.ocaml_pos exception Unknown_proc -exception Unreachable_code_after of Localise.error_desc * L.ml_loc +exception Unreachable_code_after of Localise.error_desc * L.ocaml_pos -exception Unsafe_guarded_by_access of Localise.error_desc * L.ml_loc +exception Unsafe_guarded_by_access of Localise.error_desc * L.ocaml_pos -exception Use_after_free of Localise.error_desc * L.ml_loc +exception Use_after_free of Localise.error_desc * L.ocaml_pos -exception Wrong_argument_number of L.ml_loc +exception Wrong_argument_number of L.ocaml_pos type t = { name: IssueType.t ; description: Localise.error_desc - ; ml_loc: Logging.ml_loc option (** location in the infer source code *) + ; ocaml_pos: L.ocaml_pos option (** location in the infer source code *) ; visibility: visibility ; severity: severity ; kind: err_kind option @@ -157,84 +157,84 @@ type t = let recognize_exception exn = match exn with (* all the static names of errors must be defined in Config.IssueType *) - | Abduction_case_not_implemented ml_loc -> + | Abduction_case_not_implemented ocaml_pos -> { name= IssueType.abduction_case_not_implemented ; description= Localise.no_desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= Low ; kind= None ; category= Nocat } - | Analysis_stops (desc, ml_loc_opt) -> + | Analysis_stops (desc, ocaml_pos_opt) -> let visibility = if Config.analysis_stops then Exn_user else Exn_developer in { name= IssueType.analysis_stops ; description= desc - ; ml_loc= ml_loc_opt + ; ocaml_pos= ocaml_pos_opt ; visibility ; severity= Medium ; kind= None ; category= Nocat } - | Array_of_pointsto ml_loc -> + | Array_of_pointsto ocaml_pos -> { name= IssueType.array_of_pointsto ; description= Localise.no_desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= Low ; kind= None ; category= Nocat } - | Array_out_of_bounds_l1 (desc, ml_loc) -> + | Array_out_of_bounds_l1 (desc, ocaml_pos) -> { name= IssueType.array_out_of_bounds_l1 ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= High ; kind= Some Kerror ; category= Checker } - | Array_out_of_bounds_l2 (desc, ml_loc) -> + | Array_out_of_bounds_l2 (desc, ocaml_pos) -> { name= IssueType.array_out_of_bounds_l2 ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= Medium ; kind= None ; category= Nocat } - | Array_out_of_bounds_l3 (desc, ml_loc) -> + | Array_out_of_bounds_l3 (desc, ocaml_pos) -> { name= IssueType.array_out_of_bounds_l3 ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= Medium ; kind= None ; category= Nocat } | Assert_failure (f, l, c) -> - let ml_loc = (f, l, c, c) in + let ocaml_pos = (f, l, c, c) in { name= IssueType.assert_failure ; description= Localise.no_desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= High ; kind= None ; category= Nocat } - | Bad_footprint ml_loc -> + | Bad_footprint ocaml_pos -> { name= IssueType.bad_footprint ; description= Localise.no_desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= Low ; kind= None ; category= Nocat } - | Cannot_star ml_loc -> + | Cannot_star ocaml_pos -> { name= IssueType.cannot_star ; description= Localise.no_desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= Low ; kind= None ; category= Nocat } - | Class_cast_exception (desc, ml_loc) -> + | Class_cast_exception (desc, ocaml_pos) -> { name= IssueType.class_cast_exception ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= High ; kind= None @@ -242,24 +242,24 @@ let recognize_exception exn = | Codequery desc -> { name= IssueType.codequery ; description= desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_user ; severity= High ; kind= None ; category= Prover } - | Comparing_floats_for_equality (desc, ml_loc) -> + | Comparing_floats_for_equality (desc, ocaml_pos) -> { name= IssueType.comparing_floats_for_equality ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Medium ; kind= None ; category= Nocat } - | Condition_always_true_false (desc, b, ml_loc) -> + | Condition_always_true_false (desc, b, ocaml_pos) -> let name = if b then IssueType.condition_always_true else IssueType.condition_always_false in { name ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Medium ; kind= None @@ -267,12 +267,12 @@ let recognize_exception exn = | Custom_error (error_msg, desc) -> { name= IssueType.from_string error_msg ; description= desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_user ; severity= High ; kind= None ; category= Checker } - | Dangling_pointer_dereference (dko, desc, ml_loc) -> + | Dangling_pointer_dereference (dko, desc, ocaml_pos) -> let visibility = match dko with | Some _ -> @@ -282,7 +282,7 @@ let recognize_exception exn = in { name= IssueType.dangling_pointer_dereference ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility ; severity= High ; kind= None @@ -290,7 +290,7 @@ let recognize_exception exn = | Deallocate_stack_variable desc -> { name= IssueType.deallocate_stack_variable ; description= desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_user ; severity= High ; kind= None @@ -298,31 +298,31 @@ let recognize_exception exn = | Deallocate_static_memory desc -> { name= IssueType.deallocate_static_memory ; description= desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_user ; severity= High ; kind= None ; category= Prover } - | Deallocation_mismatch (desc, ml_loc) -> + | Deallocation_mismatch (desc, ocaml_pos) -> { name= IssueType.deallocation_mismatch ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= None ; category= Prover } - | Divide_by_zero (desc, ml_loc) -> + | Divide_by_zero (desc, ocaml_pos) -> { name= IssueType.divide_by_zero ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= Some Kerror ; category= Checker } - | Double_lock (desc, ml_loc) -> + | Double_lock (desc, ocaml_pos) -> { name= IssueType.double_lock ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= Some Kerror @@ -330,31 +330,31 @@ let recognize_exception exn = | Eradicate (kind, desc) -> { name= kind ; description= desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_user ; severity= High ; kind= None ; category= Prover } - | Empty_vector_access (desc, ml_loc) -> + | Empty_vector_access (desc, ocaml_pos) -> { name= IssueType.empty_vector_access ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= Some Kerror ; category= Prover } - | Field_not_null_checked (desc, ml_loc) -> + | Field_not_null_checked (desc, ocaml_pos) -> { name= IssueType.field_not_null_checked ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Medium ; kind= Some Kwarning ; category= Nocat } - | Frontend_warning ((name, hum), desc, ml_loc) -> + | Frontend_warning ((name, hum), desc, ocaml_pos) -> { name= IssueType.from_string name ?hum ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Medium ; kind= None @@ -362,31 +362,31 @@ let recognize_exception exn = | Checkers (kind, desc) -> { name= kind ; description= desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_user ; severity= High ; kind= None ; category= Prover } - | Null_dereference (desc, ml_loc) -> + | Null_dereference (desc, ocaml_pos) -> { name= IssueType.null_dereference ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= None ; category= Prover } - | Null_test_after_dereference (desc, ml_loc) -> + | Null_test_after_dereference (desc, ocaml_pos) -> { name= IssueType.null_test_after_dereference ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= None ; category= Nocat } - | Pointer_size_mismatch (desc, ml_loc) -> + | Pointer_size_mismatch (desc, ocaml_pos) -> { name= IssueType.pointer_size_mismatch ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= Some Kerror @@ -394,7 +394,7 @@ let recognize_exception exn = | Inherently_dangerous_function desc -> { name= IssueType.inherently_dangerous_function ; description= desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_developer ; severity= Medium ; kind= None @@ -402,7 +402,7 @@ let recognize_exception exn = | Internal_error desc -> { name= IssueType.internal_error ; description= desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_developer ; severity= High ; kind= None @@ -411,16 +411,16 @@ let recognize_exception exn = let exn_str = Typ.Name.name exn_name in { name= IssueType.from_string exn_str ; description= desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_user ; severity= High ; kind= None ; category= Prover } - | Leak (fp_part, _, (exn_vis, error_desc), done_array_abstraction, resource, ml_loc) -> + | Leak (fp_part, _, (exn_vis, error_desc), done_array_abstraction, resource, ocaml_pos) -> if done_array_abstraction then { name= IssueType.leak_after_array_abstraction ; description= error_desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= High ; kind= None @@ -428,7 +428,7 @@ let recognize_exception exn = else if fp_part then { name= IssueType.leak_in_footprint ; description= error_desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= High ; kind= None @@ -447,97 +447,97 @@ let recognize_exception exn = in { name ; description= error_desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= exn_vis ; severity= High ; kind= None ; category= Prover } - | Missing_fld (fld, ml_loc) -> + | Missing_fld (fld, ocaml_pos) -> let desc = Localise.verbatim_desc (Typ.Fieldname.to_full_string fld) in { name= IssueType.missing_fld ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= Medium ; kind= None ; category= Nocat } - | Premature_nil_termination (desc, ml_loc) -> + | Premature_nil_termination (desc, ocaml_pos) -> { name= IssueType.premature_nil_termination ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= None ; category= Prover } - | Parameter_not_null_checked (desc, ml_loc) -> + | Parameter_not_null_checked (desc, ocaml_pos) -> { name= IssueType.parameter_not_null_checked ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Medium ; kind= Some Kwarning ; category= Nocat } - | Precondition_not_found (desc, ml_loc) -> + | Precondition_not_found (desc, ocaml_pos) -> { name= IssueType.precondition_not_found ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= Low ; kind= None ; category= Nocat } - | Precondition_not_met (desc, ml_loc) -> + | Precondition_not_met (desc, ocaml_pos) -> { name= IssueType.precondition_not_met ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= Medium ; kind= Some Kwarning ; category= Nocat } (* always a warning *) - | Retain_cycle (_, desc, ml_loc) -> + | Retain_cycle (_, desc, ocaml_pos) -> { name= IssueType.retain_cycle ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= None ; category= Prover } - | Registered_observer_being_deallocated (desc, ml_loc) -> + | Registered_observer_being_deallocated (desc, ocaml_pos) -> { name= IssueType.registered_observer_being_deallocated ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= Some Kerror ; category= Nocat } - | Return_expression_required (desc, ml_loc) -> + | Return_expression_required (desc, ocaml_pos) -> { name= IssueType.return_expression_required ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Medium ; kind= None ; category= Nocat } - | Stack_variable_address_escape (desc, ml_loc) -> + | Stack_variable_address_escape (desc, ocaml_pos) -> { name= IssueType.stack_variable_address_escape ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= Some Kerror ; category= Nocat } - | Return_statement_missing (desc, ml_loc) -> + | Return_statement_missing (desc, ocaml_pos) -> { name= IssueType.return_statement_missing ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Medium ; kind= None ; category= Nocat } - | Return_value_ignored (desc, ml_loc) -> + | Return_value_ignored (desc, ocaml_pos) -> { name= IssueType.return_value_ignored ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Medium ; kind= None @@ -545,7 +545,7 @@ let recognize_exception exn = | SymOp.Analysis_failure_exe _ -> { name= IssueType.failure_exe ; description= Localise.no_desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_system ; severity= Low ; kind= None @@ -553,32 +553,32 @@ let recognize_exception exn = | Skip_function desc -> { name= IssueType.skip_function ; description= desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_developer ; severity= Low ; kind= None ; category= Nocat } - | Skip_pointer_dereference (desc, ml_loc) -> + | Skip_pointer_dereference (desc, ocaml_pos) -> { name= IssueType.skip_pointer_dereference ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Medium ; kind= Some Kinfo ; category= Nocat } (* always an info *) - | Symexec_memory_error ml_loc -> + | Symexec_memory_error ocaml_pos -> { name= IssueType.symexec_memory_error ; description= Localise.no_desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= Low ; kind= None ; category= Nocat } - | Unary_minus_applied_to_unsigned_expression (desc, ml_loc) -> + | Unary_minus_applied_to_unsigned_expression (desc, ocaml_pos) -> { name= IssueType.unary_minus_applied_to_unsigned_expression ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Medium ; kind= None @@ -586,39 +586,39 @@ let recognize_exception exn = | Unknown_proc -> { name= IssueType.unknown_proc ; description= Localise.no_desc - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_developer ; severity= Low ; kind= None ; category= Nocat } - | Unreachable_code_after (desc, ml_loc) -> + | Unreachable_code_after (desc, ocaml_pos) -> { name= IssueType.unreachable_code_after ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= Medium ; kind= None ; category= Nocat } - | Unsafe_guarded_by_access (desc, ml_loc) -> + | Unsafe_guarded_by_access (desc, ocaml_pos) -> { name= IssueType.unsafe_guarded_by_access ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= None ; category= Prover } - | Use_after_free (desc, ml_loc) -> + | Use_after_free (desc, ocaml_pos) -> { name= IssueType.use_after_free ; description= desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_user ; severity= High ; kind= None ; category= Prover } - | Wrong_argument_number ml_loc -> + | Wrong_argument_number ocaml_pos -> { name= IssueType.wrong_argument_number ; description= Localise.no_desc - ; ml_loc= Some ml_loc + ; ocaml_pos= Some ocaml_pos ; visibility= Exn_developer ; severity= Low ; kind= None @@ -627,7 +627,7 @@ let recognize_exception exn = { name= IssueType.failure_exe ; description= Localise.verbatim_desc (F.asprintf "%a: %s" Exn.pp exn (Caml.Printexc.get_backtrace ())) - ; ml_loc= None + ; ocaml_pos= None ; visibility= Exn_system ; severity= Low ; kind= None @@ -637,11 +637,16 @@ let recognize_exception exn = (** print a description of the exception to the html output *) let print_exception_html s exn = let error = recognize_exception exn in - let ml_loc_string = - match error.ml_loc with None -> "" | Some ml_loc -> " " ^ L.ml_loc_to_string ml_loc + let ocaml_pos_string = + match error.ocaml_pos with + | None -> + "" + | Some ocaml_pos -> + " " ^ L.ocaml_pos_to_string ocaml_pos in let desc_str = F.asprintf "%a" Localise.pp_error_desc error.description in - L.d_strln_color Red (s ^ error.name.IssueType.unique_id ^ " " ^ desc_str ^ ml_loc_string) + L.d_strln_color Red + (F.sprintf "%s%s %s%s" s error.name.IssueType.unique_id desc_str ocaml_pos_string) (** string describing an error kind *) @@ -674,11 +679,12 @@ let err_class_string = function let print_key = false (** pretty print an error *) -let pp_err ~node_key loc ekind ex_name desc ml_loc_opt fmt () = +let pp_err ~node_key loc ekind ex_name desc ocaml_pos_opt fmt () = let kind = err_kind_string (if equal_err_kind ekind Kinfo then Kwarning else ekind) in let pp_key fmt k = if print_key then F.fprintf fmt " key: %s " (Caml.Digest.to_hex k) else () in F.fprintf fmt "%a:%d: %s: %a %a%a%a@\n" SourceFile.pp loc.Location.file loc.Location.line kind - IssueType.pp ex_name Localise.pp_error_desc desc pp_key node_key L.pp_ml_loc_opt ml_loc_opt + IssueType.pp ex_name Localise.pp_error_desc desc pp_key node_key L.pp_ocaml_pos_opt + ocaml_pos_opt (** Return true if the exception is not serious and should be handled in timeout mode *) diff --git a/infer/src/IR/Exceptions.mli b/infer/src/IR/Exceptions.mli index 752c3d57b..6fae2ee0c 100644 --- a/infer/src/IR/Exceptions.mli +++ b/infer/src/IR/Exceptions.mli @@ -39,54 +39,54 @@ type err_class = Checker | Prover | Nocat | Linters val equal_err_class : err_class -> err_class -> bool -exception Abduction_case_not_implemented of Logging.ml_loc +exception Abduction_case_not_implemented of Logging.ocaml_pos -exception Analysis_stops of Localise.error_desc * Logging.ml_loc option +exception Analysis_stops of Localise.error_desc * Logging.ocaml_pos option -exception Array_of_pointsto of Logging.ml_loc +exception Array_of_pointsto of Logging.ocaml_pos -exception Array_out_of_bounds_l1 of Localise.error_desc * Logging.ml_loc +exception Array_out_of_bounds_l1 of Localise.error_desc * Logging.ocaml_pos -exception Array_out_of_bounds_l2 of Localise.error_desc * Logging.ml_loc +exception Array_out_of_bounds_l2 of Localise.error_desc * Logging.ocaml_pos -exception Array_out_of_bounds_l3 of Localise.error_desc * Logging.ml_loc +exception Array_out_of_bounds_l3 of Localise.error_desc * Logging.ocaml_pos -exception Bad_footprint of Logging.ml_loc +exception Bad_footprint of Logging.ocaml_pos -exception Cannot_star of Logging.ml_loc +exception Cannot_star of Logging.ocaml_pos -exception Class_cast_exception of Localise.error_desc * Logging.ml_loc +exception Class_cast_exception of Localise.error_desc * Logging.ocaml_pos exception Codequery of Localise.error_desc -exception Comparing_floats_for_equality of Localise.error_desc * Logging.ml_loc +exception Comparing_floats_for_equality of Localise.error_desc * Logging.ocaml_pos -exception Condition_always_true_false of Localise.error_desc * bool * Logging.ml_loc +exception Condition_always_true_false of Localise.error_desc * bool * Logging.ocaml_pos exception Custom_error of string * Localise.error_desc exception Dangling_pointer_dereference of - PredSymb.dangling_kind option * Localise.error_desc * Logging.ml_loc + PredSymb.dangling_kind option * Localise.error_desc * Logging.ocaml_pos exception Deallocate_stack_variable of Localise.error_desc exception Deallocate_static_memory of Localise.error_desc -exception Deallocation_mismatch of Localise.error_desc * Logging.ml_loc +exception Deallocation_mismatch of Localise.error_desc * Logging.ocaml_pos -exception Double_lock of Localise.error_desc * Logging.ml_loc +exception Double_lock of Localise.error_desc * Logging.ocaml_pos -exception Divide_by_zero of Localise.error_desc * Logging.ml_loc +exception Divide_by_zero of Localise.error_desc * Logging.ocaml_pos -exception Field_not_null_checked of Localise.error_desc * Logging.ml_loc +exception Field_not_null_checked of Localise.error_desc * Logging.ocaml_pos -exception Empty_vector_access of Localise.error_desc * Logging.ml_loc +exception Empty_vector_access of Localise.error_desc * Logging.ocaml_pos exception Eradicate of IssueType.t * Localise.error_desc exception Checkers of IssueType.t * Localise.error_desc -exception Frontend_warning of (string * string option) * Localise.error_desc * Logging.ml_loc +exception Frontend_warning of (string * string option) * Localise.error_desc * Logging.ocaml_pos exception Inherently_dangerous_function of Localise.error_desc @@ -95,53 +95,58 @@ exception Internal_error of Localise.error_desc exception Java_runtime_exception of Typ.Name.t * string * Localise.error_desc exception Leak of - bool * Sil.hpred * (visibility * Localise.error_desc) * bool * PredSymb.resource * Logging.ml_loc + bool + * Sil.hpred + * (visibility * Localise.error_desc) + * bool + * PredSymb.resource + * Logging.ocaml_pos -exception Missing_fld of Typ.Fieldname.t * Logging.ml_loc +exception Missing_fld of Typ.Fieldname.t * Logging.ocaml_pos -exception Premature_nil_termination of Localise.error_desc * Logging.ml_loc +exception Premature_nil_termination of Localise.error_desc * Logging.ocaml_pos -exception Null_dereference of Localise.error_desc * Logging.ml_loc +exception Null_dereference of Localise.error_desc * Logging.ocaml_pos -exception Null_test_after_dereference of Localise.error_desc * Logging.ml_loc +exception Null_test_after_dereference of Localise.error_desc * Logging.ocaml_pos -exception Parameter_not_null_checked of Localise.error_desc * Logging.ml_loc +exception Parameter_not_null_checked of Localise.error_desc * Logging.ocaml_pos -exception Pointer_size_mismatch of Localise.error_desc * Logging.ml_loc +exception Pointer_size_mismatch of Localise.error_desc * Logging.ocaml_pos -exception Precondition_not_found of Localise.error_desc * Logging.ml_loc +exception Precondition_not_found of Localise.error_desc * Logging.ocaml_pos -exception Precondition_not_met of Localise.error_desc * Logging.ml_loc +exception Precondition_not_met of Localise.error_desc * Logging.ocaml_pos -exception Retain_cycle of Sil.hpred * Localise.error_desc * Logging.ml_loc +exception Retain_cycle of Sil.hpred * Localise.error_desc * Logging.ocaml_pos -exception Registered_observer_being_deallocated of Localise.error_desc * Logging.ml_loc +exception Registered_observer_being_deallocated of Localise.error_desc * Logging.ocaml_pos -exception Return_expression_required of Localise.error_desc * Logging.ml_loc +exception Return_expression_required of Localise.error_desc * Logging.ocaml_pos -exception Return_statement_missing of Localise.error_desc * Logging.ml_loc +exception Return_statement_missing of Localise.error_desc * Logging.ocaml_pos -exception Return_value_ignored of Localise.error_desc * Logging.ml_loc +exception Return_value_ignored of Localise.error_desc * Logging.ocaml_pos exception Skip_function of Localise.error_desc -exception Skip_pointer_dereference of Localise.error_desc * Logging.ml_loc +exception Skip_pointer_dereference of Localise.error_desc * Logging.ocaml_pos -exception Stack_variable_address_escape of Localise.error_desc * Logging.ml_loc +exception Stack_variable_address_escape of Localise.error_desc * Logging.ocaml_pos -exception Symexec_memory_error of Logging.ml_loc +exception Symexec_memory_error of Logging.ocaml_pos -exception Unary_minus_applied_to_unsigned_expression of Localise.error_desc * Logging.ml_loc +exception Unary_minus_applied_to_unsigned_expression of Localise.error_desc * Logging.ocaml_pos exception Unknown_proc -exception Unreachable_code_after of Localise.error_desc * Logging.ml_loc +exception Unreachable_code_after of Localise.error_desc * Logging.ocaml_pos -exception Unsafe_guarded_by_access of Localise.error_desc * Logging.ml_loc +exception Unsafe_guarded_by_access of Localise.error_desc * Logging.ocaml_pos -exception Use_after_free of Localise.error_desc * Logging.ml_loc +exception Use_after_free of Localise.error_desc * Logging.ocaml_pos -exception Wrong_argument_number of Logging.ml_loc +exception Wrong_argument_number of Logging.ocaml_pos val err_class_string : err_class -> string (** string describing an error class *) @@ -157,13 +162,13 @@ val print_exception_html : string -> exn -> unit val pp_err : node_key:Caml.Digest.t -> Location.t -> err_kind -> IssueType.t -> Localise.error_desc - -> Logging.ml_loc option -> Format.formatter -> unit -> unit + -> Logging.ocaml_pos option -> Format.formatter -> unit -> unit (** pretty print an error *) type t = { name: IssueType.t ; description: Localise.error_desc - ; ml_loc: Logging.ml_loc option (** location in the infer source code *) + ; ocaml_pos: Logging.ocaml_pos option (** location in the infer source code *) ; visibility: visibility ; severity: severity ; kind: err_kind option diff --git a/infer/src/backend/interproc.ml b/infer/src/backend/interproc.ml index 696a96ed2..ebb4b0db5 100644 --- a/infer/src/backend/interproc.ml +++ b/infer/src/backend/interproc.ml @@ -1173,7 +1173,7 @@ let perform_transition proc_cfg tenv proc_name = "Error in collect_preconditions for %a@." Typ.Procname.pp proc_name ; let error = Exceptions.recognize_exception exn in let err_str = "exception raised " ^ error.name.IssueType.unique_id in - L.(debug Analysis Medium) "Error: %s %a@." err_str L.pp_ml_loc_opt error.ml_loc ; + L.(debug Analysis Medium) "Error: %s %a@." err_str L.pp_ocaml_pos_opt error.ocaml_pos ; [] in transition_footprint_re_exe tenv proc_name joined_pres diff --git a/infer/src/backend/state.ml b/infer/src/backend/state.ml index 4115c8f4a..c08ad91b6 100644 --- a/infer/src/backend/state.ml +++ b/infer/src/backend/state.ml @@ -330,7 +330,7 @@ let process_execution_failures (log_issue: log_issue) pname = | 0, Some (loc, key, _, loc_trace, exn) when not Config.debug_exceptions -> let error = Exceptions.recognize_exception exn in let desc' = Localise.verbatim_desc ("exception: " ^ error.name.IssueType.unique_id) in - let exn' = Exceptions.Analysis_stops (desc', error.ml_loc) in + let exn' = Exceptions.Analysis_stops (desc', error.ocaml_pos) in log_issue pname ~loc ~node_id:key ~ltr:loc_trace exn' | _ -> () diff --git a/infer/src/backend/symExec.ml b/infer/src/backend/symExec.ml index ee9dc2e24..1a5cb5e34 100644 --- a/infer/src/backend/symExec.ml +++ b/infer/src/backend/symExec.ml @@ -1382,7 +1382,11 @@ and instrs ?(mask_errors= false) tenv pdesc instrs ppl = reraise_if exn ~f:(fun () -> not mask_errors || not (SymOp.exn_not_failure exn)) ; let error = Exceptions.recognize_exception exn in let loc = - match error.ml_loc with Some ml_loc -> "at " ^ L.ml_loc_to_string ml_loc | None -> "" + match error.ocaml_pos with + | Some ocaml_pos -> + "at " ^ L.ocaml_pos_to_string ocaml_pos + | None -> + "" in L.d_warning (F.sprintf "Generated Instruction Failed with: %s%s" error.name.IssueType.unique_id loc) ; diff --git a/infer/src/backend/tabulation.mli b/infer/src/backend/tabulation.mli index f43636bf1..b01aa35c7 100644 --- a/infer/src/backend/tabulation.mli +++ b/infer/src/backend/tabulation.mli @@ -34,7 +34,7 @@ val find_dereference_without_null_check_in_sexp : Sil.strexp -> (int * PredSymb. and return the line number and path position *) val create_cast_exception : - Tenv.t -> Logging.ml_loc -> Typ.Procname.t option -> Exp.t -> Exp.t -> Exp.t -> exn + Tenv.t -> Logging.ocaml_pos -> Typ.Procname.t option -> Exp.t -> Exp.t -> Exp.t -> exn (** raise a cast exception *) val prop_is_exn : Typ.Procname.t -> 'a Prop.t -> bool diff --git a/infer/src/base/EventLogger.ml b/infer/src/base/EventLogger.ml index 3ec29ac0a..518abf8e4 100644 --- a/infer/src/base/EventLogger.ml +++ b/infer/src/base/EventLogger.ml @@ -74,7 +74,7 @@ end type analysis_issue = { bug_kind: string ; bug_type: string - ; exception_triggered_location: string option + ; exception_triggered_location: Logging.ocaml_pos option ; lang: string ; procedure_name: string ; source_location: Location.t } @@ -83,7 +83,8 @@ let create_analysis_issue_row base record = let open JsonBuilder in base |> add_string ~key:"bug_kind" ~data:record.bug_kind |> add_string ~key:"bug_type" ~data:record.bug_type - |> add_string_opt ~key:"exception_triggered_location" ~data:record.exception_triggered_location + |> add_string_opt ~key:"exception_triggered_location" + ~data:(Option.map ~f:Logging.ocaml_pos_to_string record.exception_triggered_location) |> add_string ~key:"lang" ~data:record.lang |> add_string ~key:"procedure_name" ~data:record.procedure_name |> add_string ~key:"source_location" @@ -152,8 +153,7 @@ let create_call_trace_row base record = type frontend_exception = { ast_node: string option - ; exception_file: string - ; exception_line: int + ; exception_triggered_location: Logging.ocaml_pos ; exception_type: string ; lang: string ; source_location_start: Location.t @@ -163,7 +163,7 @@ let create_frontend_exception_row base record = let open JsonBuilder in base |> add_string_opt ~key:"ast_node" ~data:record.ast_node |> add_string ~key:"exception_triggered_location" - ~data:(String.concat [record.exception_file; ":"; string_of_int record.exception_line]) + ~data:(Logging.ocaml_pos_to_string record.exception_triggered_location) |> add_string ~key:"exception_type" ~data:record.exception_type |> add_string ~key:"lang" ~data:record.lang |> add_string ~key:"source_location_start_file" diff --git a/infer/src/base/EventLogger.mli b/infer/src/base/EventLogger.mli index a2300d548..f58c15827 100644 --- a/infer/src/base/EventLogger.mli +++ b/infer/src/base/EventLogger.mli @@ -10,7 +10,7 @@ type analysis_issue = { bug_kind: string ; bug_type: string - ; exception_triggered_location: string option + ; exception_triggered_location: Logging.ocaml_pos option ; lang: string ; procedure_name: string ; source_location: Location.t } @@ -36,8 +36,7 @@ type call_trace = type frontend_exception = { ast_node: string option - ; exception_file: string - ; exception_line: int + ; exception_triggered_location: Logging.ocaml_pos ; exception_type: string ; lang: string ; source_location_start: Location.t diff --git a/infer/src/base/Logging.ml b/infer/src/base/Logging.ml index d206b11d9..030e12b50 100644 --- a/infer/src/base/Logging.ml +++ b/infer/src/base/Logging.ml @@ -257,17 +257,23 @@ let external_error fmt = log ~to_console:true external_error_file_fmts fmt let internal_error fmt = log ~to_console:true internal_error_file_fmts fmt (** Type of location in ml source: __POS__ *) -type ml_loc = string * int * int * int +type ocaml_pos = string * int * int * int (** Convert a ml location to a string *) -let ml_loc_to_string (file, lnum, cnum, enum) = Printf.sprintf "%s:%d:%d-%d:" file lnum cnum enum +let ocaml_pos_to_string (file, lnum, cnum, enum) = + Printf.sprintf "%s:%d:%d-%d:" file lnum cnum enum + (** Pretty print a location of ml source *) -let pp_ml_loc fmt ml_loc = F.fprintf fmt "%s" (ml_loc_to_string ml_loc) +let pp_ocaml_pos fmt ocaml_pos = F.fprintf fmt "%s" (ocaml_pos_to_string ocaml_pos) -let pp_ml_loc_opt fmt ml_loc_opt = +let pp_ocaml_pos_opt fmt ocaml_pos_opt = if Config.developer_mode then - match ml_loc_opt with None -> () | Some ml_loc -> F.fprintf fmt "(%a)" pp_ml_loc ml_loc + match ocaml_pos_opt with + | None -> + () + | Some ocaml_pos -> + F.fprintf fmt "(%a)" pp_ocaml_pos ocaml_pos let log_of_kind error fmt = diff --git a/infer/src/base/Logging.mli b/infer/src/base/Logging.mli index 6d2a65441..ffbbb660c 100644 --- a/infer/src/base/Logging.mli +++ b/infer/src/base/Logging.mli @@ -64,13 +64,13 @@ val debug : debug_kind -> debug_level -> ('a, F.formatter, unit) format -> 'a (** log debug info *) (** Type of location in ml source: __POS__ *) -type ml_loc = string * int * int * int +type ocaml_pos = string * int * int * int -val ml_loc_to_string : ml_loc -> string -(** Convert a ml location to a string *) +val ocaml_pos_to_string : ocaml_pos -> string +(** Convert an ocaml position to a string *) -val pp_ml_loc_opt : F.formatter -> ml_loc option -> unit -(** Pretty print a location of ml source *) +val pp_ocaml_pos_opt : F.formatter -> ocaml_pos option -> unit +(** Pretty print a position in ocaml source *) (** log management *) diff --git a/infer/src/clang/ClangLogging.ml b/infer/src/clang/ClangLogging.ml index 98d02bb75..e1391da79 100644 --- a/infer/src/clang/ClangLogging.ml +++ b/infer/src/clang/ClangLogging.ml @@ -10,14 +10,13 @@ open! IStd module F = Format let log_caught_exception (trans_unit_ctx: CFrontend_config.translation_unit_context) exception_type - (exception_file, exception_line, _, _) (source_location_start, source_location_end) ast_node = + exception_triggered_location (source_location_start, source_location_end) ast_node = let caught_exception = EventLogger.FrontendException { exception_type ; source_location_start= CLocation.clang_to_sil_location trans_unit_ctx source_location_start ; source_location_end= CLocation.clang_to_sil_location trans_unit_ctx source_location_end - ; exception_file - ; exception_line + ; exception_triggered_location ; ast_node ; lang= CFrontend_config.string_of_clang_lang trans_unit_ctx.lang } in diff --git a/infer/src/clang/ClangLogging.mli b/infer/src/clang/ClangLogging.mli index 67505a2ff..4d29c95fc 100644 --- a/infer/src/clang/ClangLogging.mli +++ b/infer/src/clang/ClangLogging.mli @@ -10,5 +10,5 @@ open! IStd val log_caught_exception : - CFrontend_config.translation_unit_context -> string -> CFrontend_config.ocaml_pos + CFrontend_config.translation_unit_context -> string -> Logging.ocaml_pos -> Clang_ast_t.source_location * Clang_ast_t.source_location -> string option -> unit diff --git a/infer/src/clang/cFrontend_config.ml b/infer/src/clang/cFrontend_config.ml index a5306cf6e..14aafb6a9 100644 --- a/infer/src/clang/cFrontend_config.ml +++ b/infer/src/clang/cFrontend_config.ml @@ -20,11 +20,9 @@ let string_of_clang_lang (lang: clang_lang) : string = let equal_clang_lang = [%compare.equal : clang_lang] -type ocaml_pos = string * int * int * int - type exception_details = { msg: string - ; position: ocaml_pos + ; position: Logging.ocaml_pos ; source_range: Clang_ast_t.source_range ; ast_node: string option } diff --git a/infer/src/clang/cFrontend_config.mli b/infer/src/clang/cFrontend_config.mli index 9e88c9419..d5626dd78 100644 --- a/infer/src/clang/cFrontend_config.mli +++ b/infer/src/clang/cFrontend_config.mli @@ -17,18 +17,16 @@ val string_of_clang_lang : clang_lang -> string val equal_clang_lang : clang_lang -> clang_lang -> bool -type ocaml_pos = string * int * int * int - type exception_details = { msg: string - ; position: ocaml_pos + ; position: Logging.ocaml_pos ; source_range: Clang_ast_t.source_range ; ast_node: string option } exception Unimplemented of exception_details val unimplemented : - ocaml_pos -> Clang_ast_t.source_range -> ?ast_node:string + 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. *) @@ -36,7 +34,7 @@ val unimplemented : exception IncorrectAssumption of exception_details val incorrect_assumption : - ocaml_pos -> Clang_ast_t.source_range -> ?ast_node:string + 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/cTrans_utils.ml b/infer/src/clang/cTrans_utils.ml index 2c7eef2a6..f020a3e2f 100644 --- a/infer/src/clang/cTrans_utils.ml +++ b/infer/src/clang/cTrans_utils.ml @@ -585,7 +585,7 @@ let extract_stmt_from_singleton stmt_list warning_string = module Self = struct exception SelfClassException of { class_name: Typ.Name.t - ; position: CFrontend_config.ocaml_pos + ; position: Logging.ocaml_pos ; source_range: Clang_ast_t.source_range } let add_self_parameter_for_super_instance stmt_info context procname loc mei = diff --git a/infer/src/clang/cTrans_utils.mli b/infer/src/clang/cTrans_utils.mli index a28847d56..fb9349f70 100644 --- a/infer/src/clang/cTrans_utils.mli +++ b/infer/src/clang/cTrans_utils.mli @@ -157,7 +157,7 @@ end module Self : sig exception SelfClassException of { class_name: Typ.Name.t - ; position: CFrontend_config.ocaml_pos + ; position: Logging.ocaml_pos ; source_range: Clang_ast_t.source_range } val add_self_parameter_for_super_instance :