A
- 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 approximated runtime behaviorpublic class Analysis<A extends AbstractValue<A>,S extends Store<S>,T extends TransferFunction<A,S>> extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
Analysis.Worklist
A worklist is a priority queue of blocks in which the order is given by depth-first ordering
to place non-loop predecessors ahead of successors.
|
Modifier and Type | Field and Description |
---|---|
protected IdentityHashMap<Block,Integer> |
blockCount
Number of times every block has been analyzed since the last time widening was applied.
|
protected ControlFlowGraph |
cfg
The control flow graph to perform the analysis on.
|
protected TransferInput<A,S> |
currentInput
The current transfer input when the analysis is running.
|
protected Node |
currentNode
The node that is currently handled in the analysis (if it is running).
|
protected Tree |
currentTree
The tree that is currently being looked at.
|
protected IdentityHashMap<Block,S> |
elseStores
Else stores before every basic block (assumed to be 'no information' if not present).
|
protected ProcessingEnvironment |
env
The associated processing environment
|
HashMap<Element,A> |
finalLocalValues
Map from (effectively final) local variable elements to their abstract value.
|
protected IdentityHashMap<Block,TransferInput<A,S>> |
inputs
The transfer inputs before every basic block (assumed to be 'no information' if not present).
|
protected boolean |
isRunning
Is the analysis currently running?
|
protected int |
maxCountBeforeWidening
Number of times a block can be analyzed before widening.
|
protected IdentityHashMap<Node,A> |
nodeValues
Abstract values of nodes.
|
protected IdentityHashMap<ReturnNode,TransferResult<A,S>> |
storesAtReturnStatements
The stores after every return statement.
|
protected IdentityHashMap<Block,S> |
thenStores
Then stores before every basic block (assumed to be 'no information' if not present).
|
protected T |
transferFunction
The transfer function for regular nodes.
|
protected Types |
types
Instance of the types utility.
|
protected Analysis.Worklist |
worklist
The worklist used for the fix-point iteration.
|
Constructor and Description |
---|
Analysis(ProcessingEnvironment env)
Construct an object that can perform a org.checkerframework.dataflow analysis over a control
flow graph.
|
Analysis(ProcessingEnvironment env,
T transfer)
Construct an object that can perform a org.checkerframework.dataflow analysis over a control
flow graph, given a transfer function.
|
Analysis(ProcessingEnvironment env,
T transfer,
int maxCountBeforeWidening)
Construct an object that can perform a org.checkerframework.dataflow analysis over a control
flow graph, given a transfer function.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addStoreBefore(Block b,
Node node,
S s,
Store.Kind kind,
boolean addBlockToWorklist)
Add a store before the basic block
b by merging with the existing stores for that
location. |
protected void |
addToWorklist(Block b)
Add a basic block to the worklist.
|
protected TransferResult<A,S> |
callTransferFunction(Node node,
TransferInput<A,S> store)
Call the transfer function for node
node , and set that node as current node first. |
@Nullable ClassTree |
getContainingClass(Tree t)
|
@Nullable MethodTree |
getContainingMethod(Tree t)
Get the
MethodTree of the current CFG if the argument Tree maps to a Node in the CFG or null otherwise. |
Tree |
getCurrentTree() |
ProcessingEnvironment |
getEnv() |
S |
getExceptionalExitStore() |
@Nullable TransferInput<A,S> |
getInput(Block b)
Read the
TransferInput for a particular basic block (or null if none exists
yet). |
protected @Nullable TransferInput<A,S> |
getInputBefore(Block b) |
Node |
getNodeForTree(Tree t)
|
S |
getRegularExitStore() |
AnalysisResult<A,S> |
getResult() |
List<Pair<ReturnNode,TransferResult<A,S>>> |
getReturnStatementStores() |
protected S |
getStoreBefore(Block b,
Store.Kind kind) |
T |
getTransferFunction() |
Types |
getTypes() |
A |
getValue(Node n) |
A |
getValue(Tree t) |
protected void |
init(ControlFlowGraph cfg)
Initialize the analysis with a new control flow graph.
|
boolean |
isRunning()
Is the analysis currently running?
|
void |
performAnalysis(ControlFlowGraph cfg)
Perform the actual analysis.
|
protected void |
propagateStoresTo(Block succ,
Node node,
TransferInput<A,S> currentInput,
Store.FlowRule flowRule,
boolean addToWorklistAgain)
Propagate the stores in currentInput to the successor block, succ, according to the flowRule.
|
protected static <S> S |
readFromStore(Map<Block,S> stores,
Block b)
Read the
Store for a particular basic block from a map of stores (or null if
none exists yet). |
void |
setCurrentTree(Tree currentTree) |
void |
setTransferFunction(T transfer) |
protected boolean |
updateNodeValues(Node node,
TransferResult<A,S> transferResult)
Updates the value of node
node to the value of the transferResult . |
protected boolean isRunning
protected T extends TransferFunction<A,S> transferFunction
protected ControlFlowGraph cfg
protected final ProcessingEnvironment env
protected final Types types
protected IdentityHashMap<Block,S extends Store<S>> thenStores
protected IdentityHashMap<Block,S extends Store<S>> elseStores
protected IdentityHashMap<Block,Integer> blockCount
protected final int maxCountBeforeWidening
protected IdentityHashMap<Block,TransferInput<A extends AbstractValue<A>,S extends Store<S>>> inputs
protected IdentityHashMap<ReturnNode,TransferResult<A extends AbstractValue<A>,S extends Store<S>>> storesAtReturnStatements
protected Analysis.Worklist worklist
protected IdentityHashMap<Node,A extends AbstractValue<A>> nodeValues
public HashMap<Element,A extends AbstractValue<A>> finalLocalValues
protected Node currentNode
!isRunning ⇒ (currentNode == null)
protected Tree currentTree
getValue
will not return information for this given tree.protected TransferInput<A extends AbstractValue<A>,S extends Store<S>> currentInput
public Analysis(ProcessingEnvironment env)
setTransferFunction
.public Analysis(ProcessingEnvironment env, T transfer)
public Analysis(ProcessingEnvironment env, T transfer, int maxCountBeforeWidening)
public Tree getCurrentTree()
public void setCurrentTree(Tree currentTree)
public void setTransferFunction(T transfer)
public T getTransferFunction()
public Types getTypes()
public ProcessingEnvironment getEnv()
public void performAnalysis(ControlFlowGraph cfg)
protected void propagateStoresTo(Block succ, Node node, TransferInput<A,S> currentInput, Store.FlowRule flowRule, boolean addToWorklistAgain)
protected boolean updateNodeValues(Node node, TransferResult<A,S> transferResult)
node
to the value of the transferResult
. Returns
true if the node's value changed, or a store was updated.protected TransferResult<A,S> callTransferFunction(Node node, TransferInput<A,S> store)
node
, and set that node as current node first.protected void init(ControlFlowGraph cfg)
protected void addToWorklist(Block b)
b
is already present, the method does nothing.protected void addStoreBefore(Block b, Node node, S s, Store.Kind kind, boolean addBlockToWorklist)
b
by merging with the existing stores for that
location.public @Nullable TransferInput<A,S> getInput(Block b)
TransferInput
for a particular basic block (or null
if none exists
yet).protected @Nullable TransferInput<A,S> getInputBefore(Block b)
b
.protected S getStoreBefore(Block b, Store.Kind kind)
b
.protected static <S> S readFromStore(Map<Block,S> stores, Block b)
Store
for a particular basic block from a map of stores (or null
if
none exists yet).public boolean isRunning()
public A getValue(Node n)
Node
n
, or null
if no information is
available. Note that if the analysis has not finished yet, this value might not represent
the final value for this node.public A getValue(Tree t)
Tree
t
, or null
if no information is
available. Note that if the analysis has not finished yet, this value might not represent
the final value for this node.public @Nullable MethodTree getContainingMethod(Tree t)
MethodTree
of the current CFG if the argument Tree
maps to a Node
in the CFG or null otherwise.public List<Pair<ReturnNode,TransferResult<A,S>>> getReturnStatementStores()
public AnalysisResult<A,S> getResult()
public S getRegularExitStore()
null
, if there is no such store (because the
method cannot exit through the regular exit block).public S getExceptionalExitStore()