[cost] Add method name to report

Summary: This diff adds method name to cost reports.

Reviewed By: ezgicicek

Differential Revision: D20737699

fbshipit-source-id: 080dc27de
master
Sungkeun Cho 5 years ago committed by Facebook GitHub Bot
parent d84fea52ae
commit 88e9079357

@ -178,7 +178,9 @@ module Java = struct
false
let is_autogen_method {method_name} = String.contains method_name '$'
let is_autogen_method_name method_name = String.contains method_name '$'
let is_autogen_method {method_name} = is_autogen_method_name method_name
(** Check if the proc name has the type of a java vararg. Note: currently only checks that the
last argument has type Object[]. *)

@ -65,6 +65,9 @@ module Java : sig
val is_autogen_method : t -> bool
(** Check if the procedure name is of an auto-generated method containing '$'. *)
val is_autogen_method_name : string -> bool
(** Check if the string of procedure name is of an auto-generated method containing '$'. *)
val is_anonymous_inner_class_constructor_exn : t -> bool
(** Check if the procedure name is an anonymous inner class constructor. Throws if it is not a
Java type *)

@ -260,14 +260,21 @@ let issue_of_cost kind CostIssues.{complexity_increase_issue; unreachable_issue;
Format.asprintf "%a %t %s" MarkupFormatter.pp_bold
"This function is called during cold start!" pp_avg_inclusive_time common_msg )
in
let msg =
let msg f =
(* Java Only *)
if String.equal method_name Procname.Java.constructor_method_name then "constructor"
if String.equal method_name Procname.Java.constructor_method_name then
Format.pp_print_string f "constructor"
else if String.equal method_name Procname.Java.class_initializer_method_name then
"class initializer"
else "this function"
Format.pp_print_string f "class initializer"
else
Format.fprintf f "%t%a"
(fun f ->
if Procname.Java.is_autogen_method_name method_name then
Format.pp_print_string f "auto-generated method " )
(MarkupFormatter.wrap_monospaced Format.pp_print_string)
method_name
in
Format.asprintf "%s of %s has %a from %a to %a. %s %a"
Format.asprintf "%s of %t has %a from %a to %a. %s %a"
(CostKind.to_complexity_string kind)
msg
(MarkupFormatter.wrap_bold pp_delta)

Loading…
Cancel
Save