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)] }
; { name= "inefficient keyset iterator"
; active= Config.is_checker_enabled InefficientKeysetIterator
; callbacks= [(Procedure InefficientKeysetIterator.checker, Language.Java)] }
; callbacks= [(intraprocedural InefficientKeysetIterator.checker, Language.Java)] }
; { name= "immutable cast"
; active= Config.is_checker_enabled ImmutableCast
; callbacks=

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

@ -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