diff --git a/infer/lib/python/inferlib/issues.py b/infer/lib/python/inferlib/issues.py index 0bbb95602..cf7277839 100644 --- a/infer/lib/python/inferlib/issues.py +++ b/infer/lib/python/inferlib/issues.py @@ -95,6 +95,11 @@ CSV_INDEX_ADVICE = 15 JSON_INDEX_DOTTY = 'dotty' JSON_INDEX_FILENAME = 'file' JSON_INDEX_HASH = 'hash' +JSON_INDEX_INFER_SOURCE_LOC = 'infer_source_loc' +JSON_INDEX_ISL_FILE = 'file' +JSON_INDEX_ISL_LNUM = 'lnum' +JSON_INDEX_ISL_CNUM = 'cnum' +JSON_INDEX_ISL_ENUM = 'enum' JSON_INDEX_KIND = 'kind' JSON_INDEX_LINE = 'line' JSON_INDEX_PROCEDURE = 'procedure' @@ -111,11 +116,7 @@ JSON_INDEX_TRACE_DESCRIPTION = 'description' JSON_INDEX_TRACE_NODE_TAGS = 'node_tags' JSON_INDEX_TRACE_NODE_TAGS_TAG = 'tags' JSON_INDEX_TRACE_NODE_TAGS_VALUE = 'value' -JSON_INDEX_INFER_SOURCE_LOC = 'infer_source_loc' -JSON_INDEX_ISL_FILE = 'file' -JSON_INDEX_ISL_LNUM = 'lnum' -JSON_INDEX_ISL_CNUM = 'cnum' -JSON_INDEX_ISL_ENUM = 'enum' +JSON_INDEX_VISIBILITY = 'visibility' QUALIFIER_TAGS = 'qualifier_tags' diff --git a/infer/src/backend/InferPrint.re b/infer/src/backend/InferPrint.re index 2aa69aaaf..342697f7a 100644 --- a/infer/src/backend/InferPrint.re +++ b/infer/src/backend/InferPrint.re @@ -344,7 +344,7 @@ let module IssuesCsv = { /** Write bug report in csv format */ let pp_issues_of_error_log fmt error_filter _ proc_loc_opt procname err_log => { let pp x => F.fprintf fmt x; - let pp_row (_, node_key) loc _ ekind in_footprint error_name error_desc severity ltr _ eclass => { + let pp_row (_, node_key) loc _ ekind in_footprint error_name error_desc severity ltr _ eclass _ => { let source_file = switch proc_loc_opt { | Some proc_loc => proc_loc.Location.file @@ -425,7 +425,8 @@ let module IssuesJson = { severity ltr _ - eclass => { + eclass + visibility => { let source_file = switch proc_loc_opt { | Some proc_loc => proc_loc.Location.file @@ -443,12 +444,14 @@ let module IssuesJson = { Some Jsonbug_j.{file, lnum, cnum, enum} | _ => None }; + let visibility = Exceptions.string_of_exception_visibility visibility; let bug = { Jsonbug_j.bug_class: Exceptions.err_class_string eclass, kind, bug_type, qualifier: error_desc_to_plain_string error_desc, severity, + visibility, line: loc.Location.line, column: loc.Location.col, procedure: Procname.to_string procname, @@ -476,7 +479,7 @@ let module IssuesJson = { let module IssuesTests = { /** Write bug report in a format suitable for tests on analysis results. */ let pp_issues_of_error_log fmt error_filter _ proc_loc_opt proc_name err_log => { - let pp_row _ loc _ ekind in_footprint error_name error_desc _ _ _ _ => { + let pp_row _ loc _ ekind in_footprint error_name error_desc _ _ _ _ _ => { let (source_file, line_offset) = switch proc_loc_opt { | Some proc_loc => @@ -521,7 +524,7 @@ let module IssuesTests = { let module IssuesTxt = { /** Write bug report in text format */ let pp_issues_of_error_log fmt error_filter _ proc_loc_opt _ err_log => { - let pp_row (node_id, node_key) loc _ ekind in_footprint error_name error_desc _ _ _ _ => { + let pp_row (node_id, node_key) loc _ ekind in_footprint error_name error_desc _ _ _ _ _ => { let source_file = switch proc_loc_opt { | Some proc_loc => proc_loc.Location.file @@ -586,7 +589,8 @@ let module IssuesXml = { severity ltr pre_opt - eclass => { + eclass + _ => { let source_file = switch proc_loc_opt { | Some proc_loc => proc_loc.Location.file @@ -780,7 +784,7 @@ let module Stats = { }; let process_err_log error_filter linereader err_log stats => { let found_errors = ref false; - let process_row _ loc _ ekind in_footprint error_name error_desc _ ltr _ _ => { + let process_row _ loc _ ekind in_footprint error_name error_desc _ ltr _ _ _ => { let type_str = Localise.to_string error_name; if (in_footprint && error_filter error_desc error_name) { switch ekind { diff --git a/infer/src/backend/errlog.ml b/infer/src/backend/errlog.ml index b8d8a459f..9e29e16e3 100644 --- a/infer/src/backend/errlog.ml +++ b/infer/src/backend/errlog.ml @@ -26,11 +26,11 @@ type loc_trace = loc_trace_elem list (** Data associated to a specific error *) type err_data = (int * int) * int * Location.t * L.ml_loc option * loc_trace * - Prop.normal Prop.t option * Exceptions.err_class + Prop.normal Prop.t option * Exceptions.err_class * Exceptions.exception_visibility let err_data_compare - (_, _, loc1, _, _, _, _) - (_, _, loc2, _, _, _, _) = + (_, _, loc1, _, _, _, _, _) + (_, _, loc2, _, _, _, _, _) = Location.compare loc1 loc2 module ErrDataSet = (* set err_data with no repeated loc *) @@ -74,16 +74,17 @@ type iter_fun = loc_trace -> Prop.normal Prop.t option -> Exceptions.err_class -> + Exceptions.exception_visibility -> unit (** Apply f to nodes and error names *) let iter (f: iter_fun) (err_log: t) = ErrLogHash.iter (fun (ekind, in_footprint, err_name, desc, severity) set -> ErrDataSet.iter - (fun (node_id_key, _, loc, ml_loc_opt, ltr, pre_opt, eclass) -> + (fun (node_id_key, _, loc, ml_loc_opt, ltr, pre_opt, eclass, visibility) -> f node_id_key loc ml_loc_opt ekind in_footprint err_name - desc severity ltr pre_opt eclass) + desc severity ltr pre_opt eclass visibility) set) err_log @@ -112,7 +113,7 @@ let pp_warnings fmt (errlog : t) = let pp_html source path_to_root fmt (errlog: t) = let pp_eds fmt eds = let pp_nodeid_session_loc - fmt ((nodeid, _), session, loc, _, _, _, _) = + fmt ((nodeid, _), session, loc, _, _, _, _, _) = Io_infer.Html.pp_session_link source path_to_root fmt (nodeid, session, loc.Location.line) in ErrDataSet.iter (pp_nodeid_session_loc fmt) eds in let f do_fp ek (ekind, infp, err_name, desc, _) eds = @@ -189,7 +190,8 @@ let log_issue _ekind err_log loc node_id_key session ltr pre_opt exn = let added = add_issue err_log (ekind, !Config.footprint, err_name, desc, severity_to_str severity) - (ErrDataSet.singleton (node_id_key, session, loc, ml_loc_opt, ltr, pre_opt, eclass)) in + (ErrDataSet.singleton + (node_id_key, session, loc, ml_loc_opt, ltr, pre_opt, eclass, visibility)) in let should_print_now = match exn with | Exceptions.Internal_error _ -> true @@ -268,7 +270,7 @@ module Err_table = struct ErrDataSet.iter (fun loc -> add_err loc err_name) eds in ErrLogHash.iter f err_table; - let pp ekind (nodeidkey, _, loc, ml_loc_opt, _, _, _) fmt err_names = + let pp ekind (nodeidkey, _, loc, ml_loc_opt, _, _, _, _) fmt err_names = IList.iter (fun (err_name, desc) -> Exceptions.pp_err nodeidkey loc ekind err_name desc ml_loc_opt fmt ()) err_names in F.fprintf fmt "@.Detailed errors during footprint phase:@."; diff --git a/infer/src/backend/errlog.mli b/infer/src/backend/errlog.mli index 92def2318..41d657b4d 100644 --- a/infer/src/backend/errlog.mli +++ b/infer/src/backend/errlog.mli @@ -39,6 +39,7 @@ type iter_fun = loc_trace -> Prop.normal Prop.t option -> Exceptions.err_class -> + Exceptions.exception_visibility -> unit (** Apply f to nodes and error names *) diff --git a/infer/src/backend/exceptions.ml b/infer/src/backend/exceptions.ml index 120d54060..3b13dc290 100644 --- a/infer/src/backend/exceptions.ml +++ b/infer/src/backend/exceptions.ml @@ -19,6 +19,12 @@ type exception_visibility = | Exn_developer (** only add to error log in developer mode *) | Exn_system (** never add to error log *) +let string_of_exception_visibility vis = + match vis with + | Exn_user -> "user" + | Exn_developer -> "developer" + | Exn_system -> "system" + (** severity of bugs *) type exception_severity = | High (* high severity bug *) @@ -237,7 +243,7 @@ let recognize_exception exn = desc, Some ml_loc, Exn_developer, Low, None, Nocat) | Precondition_not_met (desc, ml_loc) -> (Localise.precondition_not_met, - desc, Some ml_loc, Exn_user, Medium, Some Kwarning, Nocat) (* always a warning *) + desc, Some ml_loc, Exn_developer, Medium, Some Kwarning, Nocat) (* always a warning *) | Retain_cycle (_, _, desc, ml_loc) -> (Localise.retain_cycle, desc, Some ml_loc, Exn_user, High, None, Prover) diff --git a/infer/src/backend/exceptions.mli b/infer/src/backend/exceptions.mli index 6f0231b03..cacbab161 100644 --- a/infer/src/backend/exceptions.mli +++ b/infer/src/backend/exceptions.mli @@ -18,6 +18,8 @@ type exception_visibility = | Exn_developer (** only add to error log in developer mode *) | Exn_system (** never add to error log *) +val string_of_exception_visibility : exception_visibility -> string + (** severity of bugs *) type exception_severity = | High (** high severity bug *) diff --git a/infer/src/backend/jsonbug.atd b/infer/src/backend/jsonbug.atd index 9e727de6c..2e538ef46 100644 --- a/infer/src/backend/jsonbug.atd +++ b/infer/src/backend/jsonbug.atd @@ -24,6 +24,7 @@ type jsonbug = { bug_type : string; qualifier : string; severity : string; + visibility : string; line: int; column: int; procedure : string; diff --git a/infer/src/backend/printer.ml b/infer/src/backend/printer.ml index c47845cc4..3d94871db 100644 --- a/infer/src/backend/printer.ml +++ b/infer/src/backend/printer.ml @@ -435,7 +435,7 @@ let write_proc_html source whole_seconds pdesc = (** Creare a hash table mapping line numbers to the set of errors occurring on that line *) let create_table_err_per_line err_log = let err_per_line = Hashtbl.create 17 in - let add_err _ loc _ _ _ err_name desc _ _ _ _ = + let add_err _ loc _ _ _ err_name desc _ _ _ _ _ = let err_str = Localise.to_string err_name ^ " " ^