Class BackwardAnalysisImpl<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>
- java.lang.Object
-
- org.checkerframework.dataflow.analysis.AbstractAnalysis<V,S,T>
-
- org.checkerframework.dataflow.analysis.BackwardAnalysisImpl<V,S,T>
-
- Type Parameters:
V- the abstract value type to be tracked by the analysisS- the store type used in the analysisT- the transfer function type that is used to approximate runtime behavior
- All Implemented Interfaces:
Analysis<V,S,T>,BackwardAnalysis<V,S,T>
public class BackwardAnalysisImpl<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>> extends AbstractAnalysis<V,S,T> implements BackwardAnalysis<V,S,T>
An implementation of a backward analysis to solve a org.checkerframework.dataflow problem given a control flow graph and a backward transfer function.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.checkerframework.dataflow.analysis.AbstractAnalysis
AbstractAnalysis.Worklist
-
Nested classes/interfaces inherited from interface org.checkerframework.dataflow.analysis.Analysis
Analysis.BeforeOrAfter, Analysis.Direction
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.IdentityHashMap<ExceptionBlock,S>exceptionStoresException store of an exception block, propagated by exceptional successors of its exception block, and merged with the normalTransferResult.protected java.util.IdentityHashMap<Block,S>outStoresOut stores after every basic block (assumed to be 'no information' if not present).protected @Nullable SstoreAtEntryThe store right before the entry block.-
Fields inherited from class org.checkerframework.dataflow.analysis.AbstractAnalysis
cfg, currentInput, currentNode, currentTree, direction, finalLocalValues, inputs, isRunning, nodeValues, transferFunction, worklist
-
-
Constructor Summary
Constructors Constructor Description BackwardAnalysisImpl()Construct an object that can perform a org.checkerframework.dataflow backward analysis over a control flow graph.BackwardAnalysisImpl(T transferFunction)Construct an object that can perform a org.checkerframework.dataflow backward analysis over a control flow graph given a transfer function.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddStoreAfter(Block pred, @Nullable Node node, S s, boolean addBlockToWorklist)Add a store after the basic blockpredby merging with the existing stores for that location.@Nullable SgetEntryStore()Get the output store at the entry block of a given control flow graph.@Nullable TransferInput<V,S>getInput(Block b)Get the transfer input of a givenBlockb.protected @Nullable SgetStoreAfter(Block b)Returns the store corresponding to the location right after the basic blockb.protected voidinitFields(ControlFlowGraph cfg)Initialize fields of this object based on a given control flow graph.protected voidinitInitialInputs()Initialize the transfer inputs of every basic block before performing the analysis.voidperformAnalysis(ControlFlowGraph cfg)Perform the actual analysis.voidperformAnalysisBlock(Block b)Perform the actual analysis on one block.protected voidpropagateStoresTo(Block pred, @Nullable Node node, TransferInput<V,S> currentInput, Store.FlowRule flowRule, boolean addToWorklistAgain)Propagate the stores incurrentInputto the next block in the direction of analysis, according to theflowRule.SrunAnalysisFor(Node node, Analysis.BeforeOrAfter preOrPost, TransferInput<V,S> blockTransferInput, java.util.IdentityHashMap<Node,V> nodeValues, @Nullable java.util.Map<TransferInput<V,S>,java.util.IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)Runs the analysis again within the block ofnodeand returns the store at the location ofnode.-
Methods inherited from class org.checkerframework.dataflow.analysis.AbstractAnalysis
addToWorklist, callTransferFunction, getContainingClass, getContainingMethod, getCurrentTree, getDirection, getExceptionalExitStore, getNodesForTree, getNodeValues, getRegularExitStore, getResult, getTransferFunction, getValue, getValue, init, isIgnoredExceptionType, isRunning, readFromStore, setCurrentNode, setCurrentTree, updateNodeValues
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.checkerframework.dataflow.analysis.Analysis
getDirection, getExceptionalExitStore, getRegularExitStore, getResult, getTransferFunction, getValue, getValue, isRunning
-
-
-
-
Field Detail
-
outStores
protected final java.util.IdentityHashMap<Block,S extends Store<S>> outStores
Out stores after every basic block (assumed to be 'no information' if not present).
-
exceptionStores
protected final java.util.IdentityHashMap<ExceptionBlock,S extends Store<S>> exceptionStores
Exception store of an exception block, propagated by exceptional successors of its exception block, and merged with the normalTransferResult.
-
-
Constructor Detail
-
BackwardAnalysisImpl
public BackwardAnalysisImpl()
Construct an object that can perform a org.checkerframework.dataflow backward analysis over a control flow graph. When using this constructor, the transfer function is set later by the subclass, e.g.,org.checkerframework.framework.flow.CFAbstractAnalysis.
-
BackwardAnalysisImpl
public BackwardAnalysisImpl(T transferFunction)
Construct an object that can perform a org.checkerframework.dataflow backward analysis over a control flow graph given a transfer function.- Parameters:
transferFunction- the transfer function
-
-
Method Detail
-
performAnalysis
public void performAnalysis(ControlFlowGraph cfg)
Description copied from interface:AnalysisPerform the actual analysis.- Specified by:
performAnalysisin interfaceAnalysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>- Parameters:
cfg- the control flow graph
-
performAnalysisBlock
public void performAnalysisBlock(Block b)
Description copied from interface:AnalysisPerform the actual analysis on one block.- Specified by:
performAnalysisBlockin interfaceAnalysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>- Parameters:
b- the block to analyze
-
getInput
public @Nullable TransferInput<V,S> getInput(Block b)
Description copied from interface:AnalysisGet the transfer input of a givenBlockb.
-
getEntryStore
public @Nullable S getEntryStore()
Description copied from interface:BackwardAnalysisGet the output store at the entry block of a given control flow graph. For a backward analysis, the output store contains the analyzed flow information from the exit block to the entry block.- Specified by:
getEntryStorein interfaceBackwardAnalysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>- Returns:
- the output store at the entry block of a given control flow graph
-
initFields
protected void initFields(ControlFlowGraph cfg)
Description copied from class:AbstractAnalysisInitialize fields of this object based on a given control flow graph. Sub-class may override this method to initialize customized fields.- Overrides:
initFieldsin classAbstractAnalysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>- Parameters:
cfg- a given control flow graph
-
initInitialInputs
@RequiresNonNull("cfg") protected void initInitialInputs()
Description copied from class:AbstractAnalysisInitialize the transfer inputs of every basic block before performing the analysis.- Specified by:
initInitialInputsin classAbstractAnalysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>
-
propagateStoresTo
protected void propagateStoresTo(Block pred, @Nullable Node node, TransferInput<V,S> currentInput, Store.FlowRule flowRule, boolean addToWorklistAgain)
Description copied from class:AbstractAnalysisPropagate the stores incurrentInputto the next block in the direction of analysis, according to theflowRule.- Specified by:
propagateStoresToin classAbstractAnalysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>- Parameters:
pred- the target block to propagate the stores tonode- the node of the target blockcurrentInput- the current transfer inputflowRule- the flow rule being usedaddToWorklistAgain- whether the block should be added toAbstractAnalysis.worklistagain
-
addStoreAfter
protected void addStoreAfter(Block pred, @Nullable Node node, S s, boolean addBlockToWorklist)
Add a store after the basic blockpredby merging with the existing stores for that location.- Parameters:
pred- the basic blocknode- the node of the basic blockbs- the store being addedaddBlockToWorklist- whether the basic blockbshould be added back toWorklist
-
getStoreAfter
protected @Nullable S getStoreAfter(Block b)
Returns the store corresponding to the location right after the basic blockb.- Parameters:
b- the given block- Returns:
- the store right after the given block
-
runAnalysisFor
public S runAnalysisFor(@FindDistinct Node node, Analysis.BeforeOrAfter preOrPost, TransferInput<V,S> blockTransferInput, java.util.IdentityHashMap<Node,V> nodeValues, @Nullable java.util.Map<TransferInput<V,S>,java.util.IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
Description copied from interface:AnalysisRuns the analysis again within the block ofnodeand returns the store at the location ofnode. Ifbeforeis true, then the store immediately before theNodenodeis returned. Otherwise, the store immediately afternodeis returned. IfanalysisCachesis not null, this method uses a cache.analysisCachesis a map of a block of node to the cached analysis result. If the cache fortransferInputis not inanalysisCaches, this method creates new cache and stores it inanalysisCaches. The cache is a map of nodes to the analysis results of the nodes.- Specified by:
runAnalysisForin interfaceAnalysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>- Parameters:
node- the node to analyzepreOrPost- which store to return: the store immediately beforenodeor the store afternodeblockTransferInput- the transfer input of the block of this nodenodeValues- abstract values of nodesanalysisCaches- caches of analysis results- Returns:
- the store before or after
node(depends on the value ofbefore) after running the analysis
-
-