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 behaviorpublic 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>
AbstractAnalysis.Worklist
Analysis.Direction
Modifier and Type | Field and Description |
---|---|
protected IdentityHashMap<ExceptionBlock,S> |
exceptionStores
Exception store of an exception block, propagated by exceptional successors of its exception
block, and merged with the normal
TransferResult . |
protected IdentityHashMap<Block,S> |
outStores
Out stores after every basic block (assumed to be 'no information' if not present).
|
protected S |
storeAtEntry
The store right before the entry block.
|
cfg, currentInput, currentNode, currentTree, direction, finalLocalValues, inputs, isRunning, nodeValues, transferFunction, worklist
Constructor and Description |
---|
BackwardAnalysisImpl()
Construct an object that can perform a org.checkerframework.dataflow backward analysis over a
control flow graph.
|
BackwardAnalysisImpl(T transfer)
Construct an object that can perform a org.checkerframework.dataflow backward analysis over a
control flow graph given a transfer function.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addStoreAfter(Block pred,
@Nullable Node node,
S s,
boolean addBlockToWorklist)
Add a store after the basic block
pred by merging with the existing stores for that
location. |
S |
getEntryStore()
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 given
Block b. |
protected S |
getStoreAfter(Block b)
Returns the store corresponding to the location right after the basic block
b . |
protected void |
initFields(ControlFlowGraph cfg)
Initialize class fields based on a given control flow graph.
|
protected void |
initInitialInputs()
Initialize the transfer inputs of every basic block before performing the analysis.
|
void |
performAnalysis(ControlFlowGraph cfg)
Perform the actual analysis.
|
void |
performAnalysisBlock(Block b)
Perform the actual analysis on one block.
|
protected void |
propagateStoresTo(Block pred,
@Nullable Node node,
TransferInput<V,S> currentInput,
Store.FlowRule flowRule,
boolean addToWorklistAgain)
Propagate the stores in
currentInput to the next block in the direction of analysis,
according to the flowRule . |
S |
runAnalysisFor(Node node,
boolean before,
TransferInput<V,S> transferInput,
IdentityHashMap<Node,V> nodeValues,
Map<TransferInput<V,S>,IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
Runs the analysis again within the block of
node and returns the store at the
location of node . |
addToWorklist, callTransferFunction, getContainingClass, getContainingMethod, getCurrentTree, getDirection, getExceptionalExitStore, getNodesForTree, getNodeValues, getRegularExitStore, getResult, getTransferFunction, getValue, getValue, init, isRunning, readFromStore, setCurrentNode, setCurrentTree, updateNodeValues
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDirection, getExceptionalExitStore, getRegularExitStore, getResult, getTransferFunction, getValue, getValue, isRunning
protected final IdentityHashMap<Block,S extends Store<S>> outStores
protected final IdentityHashMap<ExceptionBlock,S extends Store<S>> exceptionStores
TransferResult
.public BackwardAnalysisImpl()
org.checkerframework.framework.flow.CFAbstractAnalysis
, later.public BackwardAnalysisImpl(T transfer)
transfer
- the transfer functionpublic void performAnalysis(ControlFlowGraph cfg)
Analysis
performAnalysis
in interface Analysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>
cfg
- the control flow graphpublic void performAnalysisBlock(Block b)
Analysis
performAnalysisBlock
in interface Analysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>
b
- the block to analyzepublic @Nullable TransferInput<V,S> getInput(Block b)
Analysis
Block
b.public S getEntryStore()
BackwardAnalysis
getEntryStore
in interface BackwardAnalysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>
protected void initFields(ControlFlowGraph cfg)
AbstractAnalysis
initFields
in class AbstractAnalysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>
cfg
- a given control flow graph@RequiresNonNull(value="cfg") protected void initInitialInputs()
AbstractAnalysis
initInitialInputs
in class AbstractAnalysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>
protected void propagateStoresTo(Block pred, @Nullable Node node, TransferInput<V,S> currentInput, Store.FlowRule flowRule, boolean addToWorklistAgain)
AbstractAnalysis
currentInput
to the next block in the direction of analysis,
according to the flowRule
.propagateStoresTo
in class AbstractAnalysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>
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 to AbstractAnalysis.worklist
againprotected void addStoreAfter(Block pred, @Nullable Node node, S s, boolean addBlockToWorklist)
pred
by merging with the existing stores for that
location.pred
- the basic blocknode
- the node of the basic block b
s
- the store being addedaddBlockToWorklist
- whether the basic block b
should be added back to Worklist
protected S getStoreAfter(Block b)
b
.b
- the given blockpublic S runAnalysisFor(@FindDistinct Node node, boolean before, TransferInput<V,S> transferInput, IdentityHashMap<Node,V> nodeValues, Map<TransferInput<V,S>,IdentityHashMap<Node,TransferResult<V,S>>> analysisCaches)
Analysis
node
and returns the store at the
location of node
. If before
is true, then the store immediately before the
Node
node
is returned. Otherwise, the store immediately after node
is
returned. If analysisCaches
is not null, this method uses a cache. analysisCaches
is a map of a block of node to the cached analysis result. If the cache for
transferInput
is not in analysisCaches
, this method creates new cache and
stores it in analysisCaches
. The cache is a map of nodes to the analysis results of
the nodes.runAnalysisFor
in interface Analysis<V extends AbstractValue<V>,S extends Store<S>,T extends BackwardTransferFunction<V,S>>
node
- the node to analyzebefore
- the boolean value to indicate which store to return (if it is true, return the
store immediately before node
; otherwise, the store after node
is
returned)transferInput
- the transfer input of the block of this nodenodeValues
- abstract values of nodesanalysisCaches
- caches of analysis resultsnode
(depends on the value of before
) after
running the analysis