[infer][ondemand] remove the call to `Specs.get_summary_unsafe` for the Fragement Retains View checker

Reviewed By: jberdine

Differential Revision: D4704641

fbshipit-source-id: bfd5afe
master
Jeremy Dubreil 8 years ago committed by Facebook Github Bot
parent c5b30b4c05
commit 4a62c44a3e

@ -20,8 +20,6 @@ type log_t =
exn -> exn ->
unit unit
type log_issue = Typ.Procname.t -> log_t
type log_issue_from_errlog = Errlog.t -> log_t type log_issue_from_errlog = Errlog.t -> log_t
let log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr ?linters_def_file exn = let log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr ?linters_def_file exn =
@ -45,23 +43,20 @@ let log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr ?linters_
Errlog.log_issue err_kind err_log loc node_id session ltr ?linters_def_file exn Errlog.log_issue err_kind err_log loc node_id session ltr ?linters_def_file exn
let log_issue let log_issue_from_summary err_kind summary ?loc ?node_id ?session ?ltr ?linters_def_file exn =
err_kind let should_suppress_lint =
proc_name
?loc
?node_id
?session
?ltr
?linters_def_file
exn =
let should_suppress_lint (summary : Specs.summary) =
Config.curr_language_is Config.Java && Config.curr_language_is Config.Java &&
Annotations.ia_is_suppress_lint (fst summary.attributes.ProcAttributes.method_annotation) in Annotations.ia_is_suppress_lint
match Specs.get_summary proc_name with (fst summary.Specs.attributes.ProcAttributes.method_annotation) in
| Some summary when should_suppress_lint summary -> () if not should_suppress_lint
| Some summary -> then
let err_log = summary.Specs.attributes.ProcAttributes.err_log in let err_log = summary.Specs.attributes.ProcAttributes.err_log in
log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr ?linters_def_file exn log_issue_from_errlog err_kind err_log ?loc ?node_id ?session ?ltr ?linters_def_file exn
let log_issue err_kind proc_name ?loc ?node_id ?session ?ltr ?linters_def_file exn =
match Specs.get_summary proc_name with
| Some summary ->
log_issue_from_summary err_kind summary ?loc ?node_id ?session ?ltr ?linters_def_file exn
| None -> | None ->
failwithf failwithf
"Trying to report error on procedure %a, but cannot because no summary exists for this \ "Trying to report error on procedure %a, but cannot because no summary exists for this \
@ -69,10 +64,14 @@ let log_issue
Typ.Procname.pp proc_name Typ.Procname.pp proc_name
Typ.Procname.pp proc_name Typ.Procname.pp proc_name
let log_error = log_issue Exceptions.Kerror
let log_warning = log_issue Exceptions.Kwarning
let log_info = log_issue Exceptions.Kinfo
let log_error_from_errlog = log_issue_from_errlog Exceptions.Kerror let log_error_from_errlog = log_issue_from_errlog Exceptions.Kerror
let log_warning_from_errlog = log_issue_from_errlog Exceptions.Kwarning let log_warning_from_errlog = log_issue_from_errlog Exceptions.Kwarning
let log_info_from_errlog = log_issue_from_errlog Exceptions.Kinfo let log_info_from_errlog = log_issue_from_errlog Exceptions.Kinfo
let log_error_from_summary = log_issue_from_summary Exceptions.Kerror
let log_warning_from_summary = log_issue_from_summary Exceptions.Kwarning
let log_info_from_summary = log_issue_from_summary Exceptions.Kwarning
let log_error = log_issue Exceptions.Kerror
let log_warning = log_issue Exceptions.Kwarning
let log_info = log_issue Exceptions.Kinfo

@ -20,18 +20,16 @@ type log_t =
exn -> exn ->
unit unit
type log_issue = Typ.Procname.t -> log_t
type log_issue_from_errlog = Errlog.t -> log_t type log_issue_from_errlog = Errlog.t -> log_t
(** Report an error in the given procedure. *) (** Report an error in the given procedure. *)
val log_error : log_issue val log_error : Typ.Procname.t -> log_t
(** Report a warning in the given procedure. *) (** Report a warning in the given procedure. *)
val log_warning : log_issue val log_warning : Typ.Procname.t -> log_t
(** Report an info in the given procedure. *) (** Report an info in the given procedure. *)
val log_info : log_issue val log_info : Typ.Procname.t -> log_t
(** Report an issue of a given kind in the given error log. *) (** Report an issue of a given kind in the given error log. *)
val log_issue_from_errlog : Exceptions.err_kind -> log_issue_from_errlog val log_issue_from_errlog : Exceptions.err_kind -> log_issue_from_errlog
@ -44,3 +42,12 @@ val log_warning_from_errlog : log_issue_from_errlog
(** Report an info in the given error log. *) (** Report an info in the given error log. *)
val log_info_from_errlog : log_issue_from_errlog val log_info_from_errlog : log_issue_from_errlog
(** Add an error to the given summary. *)
val log_error_from_summary : Specs.summary -> log_t
(** Add an warning to the given summary. *)
val log_warning_from_summary : Specs.summary -> log_t
(** Add an info to the given summary. *)
val log_info_from_summary : Specs.summary -> log_t

@ -13,15 +13,16 @@ open! IStd
module P = Printf module P = Printf
let report_error fragment_typ fld fld_typ pname pdesc = let report_error fragment_typ fld fld_typ summary pdesc =
let pname = Procdesc.get_proc_name pdesc in
let retained_view = "CHECKERS_FRAGMENT_RETAINS_VIEW" in let retained_view = "CHECKERS_FRAGMENT_RETAINS_VIEW" in
let description = Localise.desc_fragment_retains_view fragment_typ fld fld_typ pname in let description = Localise.desc_fragment_retains_view fragment_typ fld fld_typ pname in
let exn = Exceptions.Checkers (retained_view, description) in let exn = Exceptions.Checkers (retained_view, description) in
let loc = Procdesc.get_loc pdesc in let loc = Procdesc.get_loc pdesc in
Reporting.log_error pname ~loc exn Reporting.log_error_from_summary summary ~loc exn
let callback_fragment_retains_view_java let callback_fragment_retains_view_java
pname_java { Callbacks.proc_desc; tenv } = pname_java { Callbacks.proc_desc; summary; tenv } =
(* TODO: complain if onDestroyView is not defined, yet the Fragment has View fields *) (* TODO: complain if onDestroyView is not defined, yet the Fragment has View fields *)
(* TODO: handle fields nullified in callees in the same file *) (* TODO: handle fields nullified in callees in the same file *)
let is_on_destroy_view = String.equal (Typ.Procname.java_get_method pname_java) "onDestroyView" in let is_on_destroy_view = String.equal (Typ.Procname.java_get_method pname_java) "onDestroyView" in
@ -46,7 +47,7 @@ let callback_fragment_retains_view_java
~f:(fun (fname, fld_typ, _) -> ~f:(fun (fname, fld_typ, _) ->
if not (Ident.FieldSet.mem fname fields_nullified) then if not (Ident.FieldSet.mem fname fields_nullified) then
report_error report_error
(Tstruct class_typename) fname fld_typ (Typ.Procname.Java pname_java) proc_desc) (Tstruct class_typename) fname fld_typ summary proc_desc)
declared_view_fields declared_view_fields
| _ -> () | _ -> ()
end end
@ -60,4 +61,4 @@ let callback_fragment_retains_view ({ Callbacks.summary } as args) : Specs.summa
| _ -> | _ ->
() ()
end; end;
Specs.get_summary_unsafe "callback_fragment_retains_view" proc_name summary

Loading…
Cancel
Save