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 java.lang.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 java.util.IdentityHashMap<Block,java.lang.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 com.sun.source.tree.Tree |
currentTree
The tree that is currently being looked at.
|
protected java.util.IdentityHashMap<Block,S> |
elseStores
Else stores before every basic block (assumed to be 'no information' if not present).
|
protected javax.annotation.processing.ProcessingEnvironment |
env
The associated processing environment
|
java.util.HashMap<javax.lang.model.element.Element,A> |
finalLocalValues
Map from (effectively final) local variable elements to their abstract value.
|
protected java.util.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 java.util.IdentityHashMap<Node,A> |
nodeValues
Abstract values of nodes.
|
protected java.util.IdentityHashMap<ReturnNode,TransferResult<A,S>> |
storesAtReturnStatements
The stores after every return statement.
|
protected java.util.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 javax.lang.model.util.Types |
types
Instance of the types utility.
|
protected Analysis.Worklist |
worklist
The worklist used for the fix-point iteration.
|
Constructor and Description |
---|
Analysis(javax.annotation.processing.ProcessingEnvironment env)
Construct an object that can perform a org.checkerframework.dataflow analysis over a control
flow graph.
|
Analysis(javax.annotation.processing.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(javax.annotation.processing.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 com.sun.source.tree.ClassTree |
getContainingClass(com.sun.source.tree.Tree t)
Get the
ClassTree of the current CFG if the argument Tree maps to a Node in the CFG or null otherwise. |
@Nullable com.sun.source.tree.MethodTree |
getContainingMethod(com.sun.source.tree.Tree t)
Get the
MethodTree of the current CFG if the argument Tree maps to a Node in the CFG or null otherwise. |
com.sun.source.tree.Tree |
getCurrentTree() |
javax.annotation.processing.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(com.sun.source.tree.Tree t)
Get the
Node for a given Tree . |
S |
getRegularExitStore() |
AnalysisResult<A,S> |
getResult() |
java.util.List<Pair<ReturnNode,TransferResult<A,S>>> |
getReturnStatementStores() |
protected S |
getStoreBefore(Block b,
Store.Kind kind) |
T |
getTransferFunction() |
javax.lang.model.util.Types |
getTypes() |
A |
getValue(Node n) |
A |
getValue(com.sun.source.tree.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(java.util.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(com.sun.source.tree.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 javax.annotation.processing.ProcessingEnvironment env
protected final javax.lang.model.util.Types types
protected java.util.IdentityHashMap<Block,S extends Store<S>> thenStores
protected java.util.IdentityHashMap<Block,S extends Store<S>> elseStores
protected java.util.IdentityHashMap<Block,java.lang.Integer> blockCount
protected final int maxCountBeforeWidening
protected java.util.IdentityHashMap<Block,TransferInput<A extends AbstractValue<A>,S extends Store<S>>> inputs
protected java.util.IdentityHashMap<ReturnNode,TransferResult<A extends AbstractValue<A>,S extends Store<S>>> storesAtReturnStatements
protected Analysis.Worklist worklist
protected java.util.IdentityHashMap<Node,A extends AbstractValue<A>> nodeValues
public java.util.HashMap<javax.lang.model.element.Element,A extends AbstractValue<A>> finalLocalValues
protected Node currentNode
!isRunning ⇒ (currentNode == null)
protected com.sun.source.tree.Tree currentTree
getValue
will not return information for this given tree.protected TransferInput<A extends AbstractValue<A>,S extends Store<S>> currentInput
public Analysis(javax.annotation.processing.ProcessingEnvironment env)
setTransferFunction
.public Analysis(javax.annotation.processing.ProcessingEnvironment env, T transfer)
public Analysis(javax.annotation.processing.ProcessingEnvironment env, T transfer, int maxCountBeforeWidening)
public com.sun.source.tree.Tree getCurrentTree()
public void setCurrentTree(com.sun.source.tree.Tree currentTree)
public void setTransferFunction(T transfer)
public T getTransferFunction()
public javax.lang.model.util.Types getTypes()
public javax.annotation.processing.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(java.util.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(com.sun.source.tree.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 Node getNodeForTree(com.sun.source.tree.Tree t)
Node
for a given Tree
.public @Nullable com.sun.source.tree.MethodTree getContainingMethod(com.sun.source.tree.Tree t)
MethodTree
of the current CFG if the argument Tree
maps to a Node
in the CFG or null otherwise.public @Nullable com.sun.source.tree.ClassTree getContainingClass(com.sun.source.tree.Tree t)
ClassTree
of the current CFG if the argument Tree
maps to a Node
in the CFG or null otherwise.public java.util.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()