[purity][refactor] Open AbstractDomain.Types

Summary: This diff opens AbstractDomain.Types for simplicity.

Reviewed By: ezgicicek

Differential Revision: D23161968

fbshipit-source-id: 37712443b
master
Sungkeun Cho 4 years ago committed by Facebook GitHub Bot
parent a7ff42069c
commit 55ecfd8811

@ -6,6 +6,7 @@
*) *)
open! IStd open! IStd
open AbstractDomain.Types
module F = Format module F = Format
module L = Logging module L = Logging
module ModifiedVarSet = PrettyPrintable.MakePPSet (Var) module ModifiedVarSet = PrettyPrintable.MakePPSet (Var)
@ -130,9 +131,9 @@ module TransferFunctions = struct
(* if the callee is impure, find the parameters that have been modified by the callee *) (* if the callee is impure, find the parameters that have been modified by the callee *)
let find_modified_if_impure inferbo_mem formals args callee_summary = let find_modified_if_impure inferbo_mem formals args callee_summary =
match callee_summary with match callee_summary with
| AbstractDomain.Types.Top -> | Top ->
Domain.impure_global Domain.impure_global
| AbstractDomain.Types.NonTop callee_modified_params -> | NonTop callee_modified_params ->
Domain.( Domain.(
debug "Callee modified params %a \n" ModifiedParamIndices.pp callee_modified_params ; debug "Callee modified params %a \n" ModifiedParamIndices.pp callee_modified_params ;
if ModifiedParamIndices.is_empty callee_modified_params then pure if ModifiedParamIndices.is_empty callee_modified_params then pure
@ -169,7 +170,7 @@ module TransferFunctions = struct
| Call (_, Indirect _, _, _, _) -> | Call (_, Indirect _, _, _, _) ->
(* This should never happen in Java *) (* This should never happen in Java *)
debug "Unexpected indirect call %a" HilInstr.pp instr ; debug "Unexpected indirect call %a" HilInstr.pp instr ;
AbstractDomain.Types.Top Top
| _ -> | _ ->
astate astate

@ -5,6 +5,7 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*) *)
open! IStd open! IStd
open AbstractDomain.Types
module L = Logging module L = Logging
module InvariantVars = AbstractDomain.FiniteSet (Var) module InvariantVars = AbstractDomain.FiniteSet (Var)
module VarsInLoop = AbstractDomain.FiniteSet (Var) module VarsInLoop = AbstractDomain.FiniteSet (Var)
@ -199,7 +200,7 @@ let get_invalidated_vars_in_loop tenv loop_head ~is_pure_by_default ~get_callee_
let purity = get_purity tenv ~is_pure_by_default ~get_callee_purity callee_pname in let purity = get_purity tenv ~is_pure_by_default ~get_callee_purity callee_pname in
PurityDomain.( PurityDomain.(
match purity with match purity with
| AbstractDomain.Types.Top -> | Top ->
(* modified global *) (* modified global *)
(* if one of the callees modifies a global static (* if one of the callees modifies a global static
variable, invalidate all unmodeled function calls + args *) variable, invalidate all unmodeled function calls + args *)
@ -209,7 +210,7 @@ let get_invalidated_vars_in_loop tenv loop_head ~is_pure_by_default ~get_callee_
(InvalidatedVars.add (Var.of_id id) acc) (InvalidatedVars.add (Var.of_id id) acc)
in in
InvalidatedVars.union invalidated_args (force all_unmodeled_modified) InvalidatedVars.union invalidated_args (force all_unmodeled_modified)
| AbstractDomain.Types.NonTop modified_params -> | NonTop modified_params ->
if ModifiedParamIndices.is_empty modified_params then (*pure*) if ModifiedParamIndices.is_empty modified_params then (*pure*)
acc acc
else else

@ -5,24 +5,25 @@
* LICENSE file in the root directory of this source tree. * LICENSE file in the root directory of this source tree.
*) *)
open! IStd open! IStd
open AbstractDomain.Types
module F = Format module F = Format
module ModifiedParamIndices = AbstractDomain.FiniteSet (Int) module ModifiedParamIndices = AbstractDomain.FiniteSet (Int)
module Domain = AbstractDomain.TopLifted (ModifiedParamIndices) module Domain = AbstractDomain.TopLifted (ModifiedParamIndices)
include Domain include Domain
let pure = AbstractDomain.Types.NonTop ModifiedParamIndices.empty let pure = NonTop ModifiedParamIndices.empty
let impure_global = AbstractDomain.Types.Top let impure_global = Top
let is_pure astate = let is_pure astate =
match astate with match astate with
| AbstractDomain.Types.Top -> | Top ->
false false
| AbstractDomain.Types.NonTop modified_params -> | NonTop modified_params ->
ModifiedParamIndices.is_empty modified_params ModifiedParamIndices.is_empty modified_params
let impure_params modified_params = AbstractDomain.Types.NonTop modified_params let impure_params modified_params = NonTop modified_params
let all_params_modified args = let all_params_modified args =
List.foldi ~init:ModifiedParamIndices.empty List.foldi ~init:ModifiedParamIndices.empty

Loading…
Cancel
Save