make InefficientKeysetIterator an `intraprocedural`

Summary: Making checkers/ its own dune library.

Reviewed By: ezgicicek

Differential Revision: D21407063

fbshipit-source-id: 8a3ab3c04
master
Jules Villard 5 years ago committed by Facebook GitHub Bot
parent 2a696e6fb4
commit e3300230cc

@ -175,7 +175,7 @@ let all_checkers =
; callbacks= [(Procedure Liveness.checker, Language.Clang)] } ; callbacks= [(Procedure Liveness.checker, Language.Clang)] }
; { name= "inefficient keyset iterator" ; { name= "inefficient keyset iterator"
; active= Config.is_checker_enabled InefficientKeysetIterator ; active= Config.is_checker_enabled InefficientKeysetIterator
; callbacks= [(Procedure InefficientKeysetIterator.checker, Language.Java)] } ; callbacks= [(intraprocedural InefficientKeysetIterator.checker, Language.Java)] }
; { name= "immutable cast" ; { name= "immutable cast"
; active= Config.is_checker_enabled ImmutableCast ; active= Config.is_checker_enabled ImmutableCast
; callbacks= ; callbacks=

@ -52,7 +52,7 @@ let find_first_arg_pvar node ~fun_name ~class_name_f =
else None else None
let report_matching_get tenv summary pvar loop_nodes : unit = let report_matching_get attrs err_log tenv pvar loop_nodes : unit =
LoopNodes.iter LoopNodes.iter
(fun node -> (fun node ->
let instrs = Procdesc.Node.get_instrs node in let instrs = Procdesc.Node.get_instrs node in
@ -75,7 +75,7 @@ let report_matching_get tenv summary pvar loop_nodes : unit =
in in
let loc = Procdesc.Node.get_loc node in let loc = Procdesc.Node.get_loc node in
let ltr = [Errlog.make_trace_element 0 loc exp_desc []] in let ltr = [Errlog.make_trace_element 0 loc exp_desc []] in
SummaryReporting.log_error summary ~loc ~ltr Reporting.log_error attrs err_log ~loc ~ltr
IssueType.inefficient_keyset_iterator exp_desc ) ) ) IssueType.inefficient_keyset_iterator exp_desc ) ) )
loop_nodes loop_nodes
@ -102,12 +102,11 @@ let when_dominating_preds_satisfy idom my_node ~fun_name ~class_name_f ~f =
aux my_node 4 aux my_node 4
let checker Callbacks.{summary; exe_env} : Summary.t = let checker {IntraproceduralAnalysis.proc_desc; tenv; err_log} =
let proc_desc = Summary.get_proc_desc summary in
let tenv = Exe_env.get_tenv exe_env (Summary.get_proc_name summary) in
let cfg = CFG.from_pdesc proc_desc in let cfg = CFG.from_pdesc proc_desc in
let _, loop_head_to_loop_nodes = Loop_control.get_loop_control_maps cfg in let _, loop_head_to_loop_nodes = Loop_control.get_loop_control_maps cfg in
let idom = Dominators.get_idoms proc_desc in let idom = Dominators.get_idoms proc_desc in
let attrs = Procdesc.get_attributes proc_desc in
Procdesc.NodeMap.iter Procdesc.NodeMap.iter
(fun loop_head loop_nodes -> (fun loop_head loop_nodes ->
if if
@ -119,6 +118,5 @@ let checker Callbacks.{summary; exe_env} : Summary.t =
~class_name_f:(PatternMatch.implements_set tenv) ~f:(fun itr_node _ -> ~class_name_f:(PatternMatch.implements_set tenv) ~f:(fun itr_node _ ->
when_dominating_preds_satisfy idom itr_node ~fun_name:"keySet" when_dominating_preds_satisfy idom itr_node ~fun_name:"keySet"
~class_name_f:(implements_map tenv) ~f:(fun _keySet_node get_pvar -> ~class_name_f:(implements_map tenv) ~f:(fun _keySet_node get_pvar ->
report_matching_get tenv summary get_pvar loop_nodes ) ) ) report_matching_get attrs err_log tenv get_pvar loop_nodes ) ) )
loop_head_to_loop_nodes ; loop_head_to_loop_nodes
summary

@ -0,0 +1,10 @@
(*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*)
open! IStd
val checker : IntraproceduralAnalysis.t -> unit
Loading…
Cancel
Save