[backend] make use of clang_method_kind more consistent and prevent logging it for non-clang procedures

Summary:
- change a use of clang_method_kind to match directly on the type rather than a brittle check for equality
- make the clang_method_kind field in AnalysisStats an option
- if procedure lang is not clang, then clang_method_kind field gets skipped while logging

Reviewed By: dulmarod

Differential Revision: D7010060

fbshipit-source-id: 077094d
master
Varun Arora 7 years ago committed by Facebook Github Bot
parent a2861229bb
commit d6e546950a

@ -521,15 +521,17 @@ module Stats = struct
let num_preposts = let num_preposts =
match summary.payload.preposts with Some preposts -> List.length preposts | None -> 0 match summary.payload.preposts with Some preposts -> List.length preposts | None -> 0
in in
let lang = Specs.get_proc_name summary |> Typ.Procname.get_language in
stats.events_to_log stats.events_to_log
<- EventLogger.AnalysisStats <- EventLogger.AnalysisStats
{ analysis_nodes_visited= IntSet.cardinal summary.stats.nodes_visited_re { analysis_nodes_visited= IntSet.cardinal summary.stats.nodes_visited_re
; analysis_status= summary.stats.stats_failure ; analysis_status= summary.stats.stats_failure
; analysis_total_nodes= Specs.get_proc_desc summary |> Procdesc.get_nodes_num ; analysis_total_nodes= Specs.get_proc_desc summary |> Procdesc.get_nodes_num
; clang_method_kind= (Specs.get_attributes summary).clang_method_kind ; clang_method_kind=
; lang= ( if Language.equal lang Language.Clang then
Specs.get_proc_name summary |> Typ.Procname.get_language Some (Specs.get_attributes summary).clang_method_kind
|> Language.to_explicit_string else None )
; lang= Language.to_explicit_string lang
; method_location= Specs.get_loc summary ; method_location= Specs.get_loc summary
; method_name= Specs.get_proc_name summary |> Typ.Procname.to_string ; method_name= Specs.get_proc_name summary |> Typ.Procname.to_string
; num_preposts ; num_preposts

@ -1307,9 +1307,8 @@ let rec sym_exec tenv current_pdesc instr_ (prop_: Prop.normal Prop.t) path
prop path resolved_pname ret_annots loc ret_id ret_typ_opt prop path resolved_pname ret_annots loc ret_id ret_typ_opt
n_actual_params ) n_actual_params )
| None -> | None ->
skip_call ~is_objc_instance_method:false skip_call ~reason:"function or method not found" prop path resolved_pname
~reason:"function or method not found" prop path resolved_pname ret_annots ret_annots loc ret_id ret_typ_opt n_actual_params
loc ret_id ret_typ_opt n_actual_params
else else
proc_call proc_call
(Option.value_exn resolved_summary_opt) (Option.value_exn resolved_summary_opt)
@ -1716,6 +1715,7 @@ and sym_exec_alloc_model pname ret_typ tenv ret_id pdesc loc prop path : Builtin
and proc_call callee_summary and proc_call callee_summary
{Builtin.pdesc; tenv; prop_= pre; path; ret_id; args= actual_pars; loc} = {Builtin.pdesc; tenv; prop_= pre; path; ret_id; args= actual_pars; loc} =
let caller_pname = Procdesc.get_proc_name pdesc in let caller_pname = Procdesc.get_proc_name pdesc in
let callee_attrs = Specs.get_attributes callee_summary in
let callee_pname = Specs.get_proc_name callee_summary in let callee_pname = Specs.get_proc_name callee_summary in
check_inherently_dangerous_function caller_pname callee_pname ; check_inherently_dangerous_function caller_pname callee_pname ;
let formal_types = List.map ~f:snd (Specs.get_formals callee_summary) in let formal_types = List.map ~f:snd (Specs.get_formals callee_summary) in
@ -1753,18 +1753,14 @@ and proc_call callee_summary
to their actual type otherwise. The latter case happens to their actual type otherwise. The latter case happens
with variable - arguments functions *) with variable - arguments functions *)
let actual_params = comb actual_pars formal_types in let actual_params = comb actual_pars formal_types in
(* In case we call an objc instance method we add and extra spec *) (* In case we call an objc instance method we add an extra spec
(* were the receiver is null and the semantics of the call is nop*) where the receiver is null and the semantics of the call is nop *)
(* let callee_attrs = Specs.get_attributes callee_summary in *) match (!Language.curr_language, callee_attrs.ProcAttributes.clang_method_kind) with
if !Language.curr_language <> Language.Java | Language.Clang, ProcAttributes.OBJC_INSTANCE ->
&& ProcAttributes.clang_method_kind_equal
(Specs.get_attributes callee_summary).ProcAttributes.clang_method_kind
ProcAttributes.OBJC_INSTANCE
then
handle_objc_instance_method_call actual_pars actual_params pre tenv ret_id pdesc callee_pname handle_objc_instance_method_call actual_pars actual_params pre tenv ret_id pdesc callee_pname
loc path loc path
(Tabulation.exe_function_call callee_summary) (Tabulation.exe_function_call callee_summary)
else | _ ->
(* non-objective-c method call. Standard tabulation *) (* non-objective-c method call. Standard tabulation *)
Tabulation.exe_function_call callee_summary tenv ret_id pdesc callee_pname loc actual_params Tabulation.exe_function_call callee_summary tenv ret_id pdesc callee_pname loc actual_params
pre path pre path

@ -75,7 +75,7 @@ type analysis_stats =
{ analysis_nodes_visited: int { analysis_nodes_visited: int
; analysis_status: SymOp.failure_kind option ; analysis_status: SymOp.failure_kind option
; analysis_total_nodes: int ; analysis_total_nodes: int
; clang_method_kind: ProcAttributes.clang_method_kind ; clang_method_kind: ProcAttributes.clang_method_kind option
; lang: string ; lang: string
; method_location: Location.t ; method_location: Location.t
; method_name: string ; method_name: string
@ -90,8 +90,8 @@ let create_analysis_stats_row base record =
(Option.value_map record.analysis_status ~default:"OK" ~f:(fun stats_failure -> (Option.value_map record.analysis_status ~default:"OK" ~f:(fun stats_failure ->
SymOp.failure_kind_to_string stats_failure )) SymOp.failure_kind_to_string stats_failure ))
|> add_int ~key:"analysis_total_nodes" ~data:record.analysis_total_nodes |> add_int ~key:"analysis_total_nodes" ~data:record.analysis_total_nodes
|> add_string ~key:"clang_method_kind" |> add_string_opt ~key:"clang_method_kind"
~data:(ProcAttributes.string_of_clang_method_kind record.clang_method_kind) ~data:(Option.map record.clang_method_kind ~f:ProcAttributes.string_of_clang_method_kind)
|> add_string ~key:"lang" ~data:record.lang |> add_string ~key:"lang" ~data:record.lang
|> add_string ~key:"method_location" |> add_string ~key:"method_location"
~data: ~data:

@ -11,7 +11,7 @@ type analysis_stats =
{ analysis_nodes_visited: int { analysis_nodes_visited: int
; analysis_status: SymOp.failure_kind option ; analysis_status: SymOp.failure_kind option
; analysis_total_nodes: int ; analysis_total_nodes: int
; clang_method_kind: ProcAttributes.clang_method_kind ; clang_method_kind: ProcAttributes.clang_method_kind option
; lang: string ; lang: string
; method_location: Location.t ; method_location: Location.t
; method_name: string ; method_name: string

Loading…
Cancel
Save