[purity] Simplify should_report

Reviewed By: skcho

Differential Revision: D19413263

fbshipit-source-id: 3a3da9231
master
Ezgi Çiçek 5 years ago committed by Facebook Github Bot
parent 8d0f6820ca
commit 61b83c037d

@ -130,7 +130,7 @@ let report_errors summary modified_opt =
Reporting.log_error summary ~loc:pname_loc ~ltr:[impure_fun_ltr] IssueType.impure_function
impure_fun_desc
| Some (ImpurityDomain.{modified_globals; modified_params} as astate) ->
if Purity.should_report pdesc && not (ImpurityDomain.is_pure astate) then
if Purity.should_report proc_name && not (ImpurityDomain.is_pure astate) then
let modified_ltr param_source set acc =
ImpurityDomain.ModifiedVarSet.fold
(ImpurityDomain.add_to_errlog ~nesting:1 param_source)

@ -184,20 +184,18 @@ end
module Analyzer = LowerHil.MakeAbstractInterpreter (TransferFunctions)
let should_report pdesc =
let proc_name = Procdesc.get_proc_name pdesc in
(not (Procname.is_constructor proc_name))
&&
match proc_name with
| Procname.Java java_pname ->
not
(Procname.Java.is_class_initializer java_pname || Procname.Java.is_access_method java_pname)
| Procname.ObjC_Cpp name ->
not
( Procname.ObjC_Cpp.is_destructor name
|| Procname.ObjC_Cpp.is_objc_constructor name.method_name )
| _ ->
true
let should_report proc_name =
not
( Procname.is_constructor proc_name
||
match proc_name with
| Procname.Java java_pname ->
Procname.Java.is_class_initializer java_pname || Procname.Java.is_access_method java_pname
| Procname.ObjC_Cpp name ->
Procname.ObjC_Cpp.is_destructor name
|| Procname.ObjC_Cpp.is_objc_constructor name.method_name
| _ ->
false )
let report_errors astate summary =
@ -205,7 +203,7 @@ let report_errors astate summary =
let proc_name = Procdesc.get_proc_name pdesc in
match astate with
| Some astate ->
if should_report pdesc && PurityDomain.is_pure astate then
if should_report proc_name && PurityDomain.is_pure astate then
let loc = Procdesc.get_loc pdesc in
let exp_desc = F.asprintf "Side-effect free function %a" Procname.pp proc_name in
let ltr = [Errlog.make_trace_element 0 loc exp_desc []] in

@ -9,4 +9,4 @@ open! IStd
val checker : Callbacks.proc_callback_t
val should_report : Procdesc.t -> bool
val should_report : Procname.t -> bool

Loading…
Cancel
Save