From 4627bb6f48adb244e6f41a92b8e66c8174fef069 Mon Sep 17 00:00:00 2001 From: Sam Blackshear Date: Mon, 6 Feb 2017 08:48:14 -0800 Subject: [PATCH] [absint] simplify `AbstractInterpreter.Make` functor by hiding `Scheduler` parameter Summary: At one point I thought we'd want to have lots of different schedulers for things like exploring loops in different orders, but that hasn't materialized. Let's make the common use-case simpler by hiding the `Scheduler` parameter inside the `AbstractInterpreter` module. We can always expose `MakeWithScheduler` later if we want to. Reviewed By: jberdine Differential Revision: D4508095 fbshipit-source-id: 726e051 --- infer/src/backend/preanal.ml | 11 ++--------- infer/src/bufferoverrun/bufferOverrunChecker.ml | 6 +----- infer/src/checkers/AbstractInterpreter.ml | 6 ++++-- infer/src/checkers/AbstractInterpreter.mli | 1 - infer/src/checkers/BoundedCallTree.ml | 6 +----- infer/src/checkers/SimpleChecker.ml | 6 +----- infer/src/checkers/Siof.ml | 6 +----- infer/src/checkers/ThreadSafety.ml | 6 +----- infer/src/checkers/addressTaken.ml | 4 +--- infer/src/checkers/annotationReachability.ml | 6 +----- infer/src/checkers/liveness.ml | 5 +---- infer/src/quandary/TaintAnalysis.ml | 5 +---- infer/src/unit/BoundedCallTreeTests.ml | 4 ++-- infer/src/unit/TaintTests.ml | 5 +---- infer/src/unit/abstractInterpreterTests.ml | 2 -- infer/src/unit/addressTakenTests.ml | 5 +---- infer/src/unit/analyzerTester.ml | 7 ++----- infer/src/unit/copyPropagationTests.ml | 6 ++---- infer/src/unit/livenessTests.ml | 6 ++---- 19 files changed, 25 insertions(+), 78 deletions(-) diff --git a/infer/src/backend/preanal.ml b/infer/src/backend/preanal.ml index 379868e77..69b2c5b13 100644 --- a/infer/src/backend/preanal.ml +++ b/infer/src/backend/preanal.ml @@ -93,11 +93,7 @@ let add_abstraction_instructions pdesc = module BackwardCfg = ProcCfg.OneInstrPerNode(ProcCfg.Backward(ProcCfg.Exceptional)) -module LivenessAnalysis = - AbstractInterpreter.Make - (BackwardCfg) - (Scheduler.ReversePostorder) - (Liveness.TransferFunctions) +module LivenessAnalysis = AbstractInterpreter.Make (BackwardCfg) (Liveness.TransferFunctions) module VarDomain = AbstractDomain.FiniteSet(Var.Set) @@ -254,10 +250,7 @@ let add_nullify_instrs pdesc tenv liveness_inv_map = module ExceptionalOneInstrPerNodeCfg = ProcCfg.OneInstrPerNode(ProcCfg.Exceptional) module CopyProp = - AbstractInterpreter.Make - (ExceptionalOneInstrPerNodeCfg) - (Scheduler.ReversePostorder) - (CopyPropagation.TransferFunctions) + AbstractInterpreter.Make (ExceptionalOneInstrPerNodeCfg) (CopyPropagation.TransferFunctions) let do_copy_propagation pdesc tenv = let proc_cfg = ExceptionalOneInstrPerNodeCfg.from_pdesc pdesc in diff --git a/infer/src/bufferoverrun/bufferOverrunChecker.ml b/infer/src/bufferoverrun/bufferOverrunChecker.ml index 1fcae5741..345691635 100644 --- a/infer/src/bufferoverrun/bufferOverrunChecker.ml +++ b/infer/src/bufferoverrun/bufferOverrunChecker.ml @@ -271,11 +271,7 @@ struct output_mem end -module Analyzer = - AbstractInterpreter.Make - (ProcCfg.Normal) - (Scheduler.ReversePostorder) - (TransferFunctions) +module Analyzer = AbstractInterpreter.Make (ProcCfg.Normal) (TransferFunctions) module Interprocedural = AbstractInterpreter.Interprocedural (Summary) module CFG = Analyzer.TransferFunctions.CFG diff --git a/infer/src/checkers/AbstractInterpreter.ml b/infer/src/checkers/AbstractInterpreter.ml index 1aa6994e0..4166ae613 100644 --- a/infer/src/checkers/AbstractInterpreter.ml +++ b/infer/src/checkers/AbstractInterpreter.ml @@ -184,6 +184,8 @@ module Interprocedural (Summ : Summary.S) = struct Summ.read_summary proc_desc proc_name end - -module Make (C : ProcCfg.S) (S : Scheduler.Make) (T : TransferFunctions.Make) = +module MakeWithScheduler (C : ProcCfg.S) (S : Scheduler.Make) (T : TransferFunctions.Make) = MakeNoCFG (S (C)) (T (C)) + +module Make (C : ProcCfg.S) (T : TransferFunctions.Make) = + MakeWithScheduler (C) (Scheduler.ReversePostorder) (T) diff --git a/infer/src/checkers/AbstractInterpreter.mli b/infer/src/checkers/AbstractInterpreter.mli index 9196529ac..227fc97a4 100644 --- a/infer/src/checkers/AbstractInterpreter.mli +++ b/infer/src/checkers/AbstractInterpreter.mli @@ -57,7 +57,6 @@ module MakeNoCFG transfer functions from a CFG *) module Make (CFG : ProcCfg.S) - (MakeScheduler : Scheduler.Make) (MakeTransferFunctions : TransferFunctions.Make) : S with module TransferFunctions = MakeTransferFunctions(CFG) diff --git a/infer/src/checkers/BoundedCallTree.ml b/infer/src/checkers/BoundedCallTree.ml index b5776afa1..38fff5a19 100644 --- a/infer/src/checkers/BoundedCallTree.ml +++ b/infer/src/checkers/BoundedCallTree.ml @@ -149,11 +149,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct astate end -module Analyzer = - AbstractInterpreter.Make - (ProcCfg.Exceptional) - (Scheduler.ReversePostorder) - (TransferFunctions) +module Analyzer = AbstractInterpreter.Make (ProcCfg.Exceptional) (TransferFunctions) let loaded_stacktraces = (* Load all stacktraces defined in either Config.stacktrace or diff --git a/infer/src/checkers/SimpleChecker.ml b/infer/src/checkers/SimpleChecker.ml index 715ac4c5d..d8dc8c797 100644 --- a/infer/src/checkers/SimpleChecker.ml +++ b/infer/src/checkers/SimpleChecker.ml @@ -80,11 +80,7 @@ module Make (Spec : Spec) : S = struct Domain.empty end - module Analyzer = - AbstractInterpreter.Make - (ProcCfg.Exceptional) - (Scheduler.ReversePostorder) - (TransferFunctions) + module Analyzer = AbstractInterpreter.Make (ProcCfg.Exceptional) (TransferFunctions) let checker { Callbacks.proc_desc; proc_name; tenv; } = let nodes = Procdesc.get_nodes proc_desc in diff --git a/infer/src/checkers/Siof.ml b/infer/src/checkers/Siof.ml index 65c28b7b3..5fd75b848 100644 --- a/infer/src/checkers/Siof.ml +++ b/infer/src/checkers/Siof.ml @@ -103,11 +103,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct astate end -module Analyzer = - AbstractInterpreter.Make - (ProcCfg.Normal) - (Scheduler.ReversePostorder) - (TransferFunctions) +module Analyzer = AbstractInterpreter.Make (ProcCfg.Normal) (TransferFunctions) module Interprocedural = AbstractInterpreter.Interprocedural (Summary) diff --git a/infer/src/checkers/ThreadSafety.ml b/infer/src/checkers/ThreadSafety.ml index 0495b9f0b..a309f46a0 100644 --- a/infer/src/checkers/ThreadSafety.ml +++ b/infer/src/checkers/ThreadSafety.ml @@ -440,11 +440,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct astate end -module Analyzer = - AbstractInterpreter.Make - (ProcCfg.Normal) - (Scheduler.ReversePostorder) - (TransferFunctions) +module Analyzer = AbstractInterpreter.Make (ProcCfg.Normal) (TransferFunctions) module Interprocedural = AbstractInterpreter.Interprocedural (Summary) diff --git a/infer/src/checkers/addressTaken.ml b/infer/src/checkers/addressTaken.ml index d8b7f34d7..93966dd93 100644 --- a/infer/src/checkers/addressTaken.ml +++ b/infer/src/checkers/addressTaken.ml @@ -43,6 +43,4 @@ module TransferFunctions (CFG : ProcCfg.S) = struct astate end -module Analyzer = - AbstractInterpreter.Make - (ProcCfg.Exceptional) (Scheduler.ReversePostorder) (TransferFunctions) +module Analyzer = AbstractInterpreter.Make (ProcCfg.Exceptional) (TransferFunctions) diff --git a/infer/src/checkers/annotationReachability.ml b/infer/src/checkers/annotationReachability.ml index da2647ec4..5f855fec6 100644 --- a/infer/src/checkers/annotationReachability.ml +++ b/infer/src/checkers/annotationReachability.ml @@ -327,11 +327,7 @@ module TransferFunctions (CFG : ProcCfg.S) = struct astate end -module Analyzer = - AbstractInterpreter.Make - (ProcCfg.Exceptional) - (Scheduler.ReversePostorder) - (TransferFunctions) +module Analyzer = AbstractInterpreter.Make (ProcCfg.Exceptional) (TransferFunctions) module Interprocedural = struct include AbstractInterpreter.Interprocedural(Summary) diff --git a/infer/src/checkers/liveness.ml b/infer/src/checkers/liveness.ml index 7d37f9ac7..fe49c6887 100644 --- a/infer/src/checkers/liveness.ml +++ b/infer/src/checkers/liveness.ml @@ -55,7 +55,4 @@ module TransferFunctions (CFG : ProcCfg.S) = struct end module Analyzer = - AbstractInterpreter.Make - (ProcCfg.Backward(ProcCfg.Exceptional)) - (Scheduler.ReversePostorder) - (TransferFunctions) + AbstractInterpreter.Make (ProcCfg.Backward(ProcCfg.Exceptional)) (TransferFunctions) diff --git a/infer/src/quandary/TaintAnalysis.ml b/infer/src/quandary/TaintAnalysis.ml index dfc514f52..32a7ef5ca 100644 --- a/infer/src/quandary/TaintAnalysis.ml +++ b/infer/src/quandary/TaintAnalysis.ml @@ -483,10 +483,7 @@ module Make (TaintSpecification : TaintSpec.S) = struct astate end - module Analyzer = AbstractInterpreter.Make - (ProcCfg.Exceptional) - (Scheduler.ReversePostorder) - (TransferFunctions) + module Analyzer = AbstractInterpreter.Make (ProcCfg.Exceptional) (TransferFunctions) let make_summary formal_map access_tree = let access_tree' = diff --git a/infer/src/unit/BoundedCallTreeTests.ml b/infer/src/unit/BoundedCallTreeTests.ml index 0f3e5aeac..5f550c215 100644 --- a/infer/src/unit/BoundedCallTreeTests.ml +++ b/infer/src/unit/BoundedCallTreeTests.ml @@ -11,9 +11,9 @@ open! IStd module F = Format -module TestInterpreter = AnalyzerTester.Make +module TestInterpreter = + AnalyzerTester.Make (ProcCfg.Exceptional) - (Scheduler.ReversePostorder) (BoundedCallTree.TransferFunctions) let mock_get_proc_desc _ = None diff --git a/infer/src/unit/TaintTests.ml b/infer/src/unit/TaintTests.ml index d13d52336..49e8557e8 100644 --- a/infer/src/unit/TaintTests.ml +++ b/infer/src/unit/TaintTests.ml @@ -48,10 +48,7 @@ module MockTaintAnalysis = TaintAnalysis.Make(struct let handle_unknown_call _ _ _ = [] end) -module TestInterpreter = AnalyzerTester.Make - (ProcCfg.Normal) - (Scheduler.ReversePostorder) - (MockTaintAnalysis.TransferFunctions) +module TestInterpreter = AnalyzerTester.Make (ProcCfg.Normal) (MockTaintAnalysis.TransferFunctions) let tests = let open OUnit2 in diff --git a/infer/src/unit/abstractInterpreterTests.ml b/infer/src/unit/abstractInterpreterTests.ml index a14e0c922..b03db33e4 100644 --- a/infer/src/unit/abstractInterpreterTests.ml +++ b/infer/src/unit/abstractInterpreterTests.ml @@ -58,12 +58,10 @@ end module NormalTestInterpreter = AnalyzerTester.Make (ProcCfg.Normal) - (Scheduler.ReversePostorder) (PathCountTransferFunctions) module ExceptionalTestInterpreter = AnalyzerTester.Make (ProcCfg.Exceptional) - (Scheduler.ReversePostorder) (PathCountTransferFunctions) let tests = diff --git a/infer/src/unit/addressTakenTests.ml b/infer/src/unit/addressTakenTests.ml index 37bbf6e83..9dc388813 100644 --- a/infer/src/unit/addressTakenTests.ml +++ b/infer/src/unit/addressTakenTests.ml @@ -11,10 +11,7 @@ open! IStd module F = Format -module TestInterpreter = AnalyzerTester.Make - (ProcCfg.Exceptional) - (Scheduler.ReversePostorder) - (AddressTaken.TransferFunctions) +module TestInterpreter = AnalyzerTester.Make (ProcCfg.Exceptional) (AddressTaken.TransferFunctions) let tests = let open OUnit2 in diff --git a/infer/src/unit/analyzerTester.ml b/infer/src/unit/analyzerTester.ml index 942ba6840..65d12c6af 100644 --- a/infer/src/unit/analyzerTester.ml +++ b/infer/src/unit/analyzerTester.ml @@ -155,14 +155,11 @@ module StructuredSil = struct call_unknown None arg_strs end -module Make - (CFG : ProcCfg.S with type node = Procdesc.Node.t) - (S : Scheduler.Make) - (T : TransferFunctions.Make) = struct +module Make (CFG : ProcCfg.S with type node = Procdesc.Node.t) (T : TransferFunctions.Make) = struct open StructuredSil - module I = AbstractInterpreter.Make (CFG) (S) (T) + module I = AbstractInterpreter.Make (CFG) (T) module M = I.InvariantMap type assert_map = string M.t diff --git a/infer/src/unit/copyPropagationTests.ml b/infer/src/unit/copyPropagationTests.ml index 1b3b6e1ce..18b8a4bc7 100644 --- a/infer/src/unit/copyPropagationTests.ml +++ b/infer/src/unit/copyPropagationTests.ml @@ -11,10 +11,8 @@ open! IStd module F = Format -module TestInterpreter = AnalyzerTester.Make - (ProcCfg.Exceptional) - (Scheduler.ReversePostorder) - (CopyPropagation.TransferFunctions) +module TestInterpreter = + AnalyzerTester.Make (ProcCfg.Exceptional) (CopyPropagation.TransferFunctions) let tests = let open OUnit2 in diff --git a/infer/src/unit/livenessTests.ml b/infer/src/unit/livenessTests.ml index cb7b8db49..f1e740940 100644 --- a/infer/src/unit/livenessTests.ml +++ b/infer/src/unit/livenessTests.ml @@ -11,10 +11,8 @@ open! IStd module F = Format -module TestInterpreter = AnalyzerTester.Make - (ProcCfg.Backward(ProcCfg.Normal)) - (Scheduler.ReversePostorder) - (Liveness.TransferFunctions) +module TestInterpreter = + AnalyzerTester.Make (ProcCfg.Backward(ProcCfg.Normal)) (Liveness.TransferFunctions) let tests = let open OUnit2 in