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 @Nullable IdentityHashMap<Block,Integer> |
blockCount
Number of times every block has been analyzed since the last time widening was applied.
|
protected @Nullable ControlFlowGraph |
cfg
The current control flow graph to perform the analysis on.
|
protected @Nullable TransferInput<A,S> |
currentInput
The current transfer input when the analysis is running.
|
protected @Nullable Node |
currentNode
The node that is currently handled in the analysis (if it is running).
|
protected @Nullable 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 @Nullable ProcessingEnvironment |
env
Deprecated.
as
env is moved to CFAbstractAnalysis , this field will be removed in
next major update |
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 @Nullable Types |
types
Deprecated.
as
types is moved to CFAbstractAnalysis , this field will be removed in
next major update |
protected Analysis.Worklist |
worklist
The worklist used for the fix-point iteration.
|
Constructor and Description |
---|
Analysis()
Construct an object that can perform a org.checkerframework.dataflow analysis over a control
flow graph.
|
Analysis(int maxCountBeforeWidening)
Construct an object that can perform a org.checkerframework.dataflow analysis over a control
flow graph.
|
Analysis(ProcessingEnvironment env)
Deprecated.
as
env is moved to CFAbstractAnalysis , this helper constructor will be
removed in next major update. Use Analysis() , Analysis(TransferFunction,
int) , Analysis(TransferFunction) or Analysis(int) instead |
Analysis(T transfer)
Construct an object that can perform a org.checkerframework.dataflow analysis over a control
flow graph, given a transfer function.
|
Analysis(T transfer,
int maxCountBeforeWidening)
Construct an object that can perform a org.checkerframework.dataflow analysis over a control
flow graph, given a transfer function.
|
Analysis(T transfer,
int maxCountBeforeWidening,
ProcessingEnvironment env)
Deprecated.
as
env is moved to CFAbstractAnalysis , this constructor will be removed
in next major update. Use Analysis(TransferFunction, int) instead. |
Analysis(T transfer,
ProcessingEnvironment env)
Deprecated.
as
env is moved to CFAbstractAnalysis , this constructor will be removed
in next major update. Use Analysis(TransferFunction, int) instead. |
Modifier and Type | Method and Description |
---|---|
protected void |
addStoreBefore(Block b,
@Nullable 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. |
@Nullable Tree |
getCurrentTree()
The tree that is currently being looked at.
|
@Nullable ProcessingEnvironment |
getEnv()
Deprecated.
as
getEnv() is moved to CFAbstractAnalysis , this method will be removed in
next major update |
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) |
@Nullable Set<Node> |
getNodesForTree(Tree t)
|
IdentityHashMap<Node,A> |
getNodeValues()
Return all current node values.
|
S |
getRegularExitStore() |
AnalysisResult<A,S> |
getResult()
The result of running the analysis.
|
List<Pair<ReturnNode,TransferResult<A,S>>> |
getReturnStatementStores()
The transfer results for each return node in the CFG.
|
protected S |
getStoreBefore(Block b,
Store.Kind kind) |
T |
getTransferFunction()
The current transfer function.
|
@Nullable Types |
getTypes()
Deprecated.
as
getTypes() is moved to CFAbstractAnalysis , this method will be removed in
next major update |
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 |
performAnalysisBlock(Block b)
Perform the actual analysis on one block.
|
protected void |
propagateStoresTo(Block succ,
@Nullable 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) |
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 @Nullable ControlFlowGraph cfg
@Deprecated protected final @Nullable ProcessingEnvironment env
env
is moved to CFAbstractAnalysis
, this field will be removed in
next major update@Deprecated protected final @Nullable Types types
types
is moved to CFAbstractAnalysis
, this field will be removed in
next major updateprotected final IdentityHashMap<Block,S extends Store<S>> thenStores
protected final IdentityHashMap<Block,S extends Store<S>> elseStores
protected final @Nullable IdentityHashMap<Block,Integer> blockCount
protected final int maxCountBeforeWidening
protected final IdentityHashMap<Block,TransferInput<A extends AbstractValue<A>,S extends Store<S>>> inputs
protected final IdentityHashMap<ReturnNode,TransferResult<A extends AbstractValue<A>,S extends Store<S>>> storesAtReturnStatements
protected final Analysis.Worklist worklist
protected final IdentityHashMap<Node,A extends AbstractValue<A>> nodeValues
public final HashMap<Element,A extends AbstractValue<A>> finalLocalValues
protected @Nullable Node currentNode
!isRunning ⇒ (currentNode == null)
protected @Nullable Tree currentTree
getValue
will not return information for this given tree.protected @Nullable TransferInput<A extends AbstractValue<A>,S extends Store<S>> currentInput
@Deprecated public Analysis(ProcessingEnvironment env)
env
is moved to CFAbstractAnalysis
, this helper constructor will be
removed in next major update. Use Analysis()
, Analysis(TransferFunction,
int)
, Analysis(TransferFunction)
or Analysis(int)
insteadCFAbstractAnalysis
, later.env
- associated processing environmentpublic Analysis()
CFAbstractAnalysis
, later.public Analysis(int maxCountBeforeWidening)
CFAbstractAnalysis
, later.maxCountBeforeWidening
- number of times a block can be analyzed before widening@Deprecated public Analysis(T transfer, ProcessingEnvironment env)
env
is moved to CFAbstractAnalysis
, this constructor will be removed
in next major update. Use Analysis(TransferFunction, int)
instead.transfer
- transfer functionenv
- associated processing environmentpublic Analysis(T transfer)
transfer
- transfer function@Deprecated public Analysis(T transfer, int maxCountBeforeWidening, ProcessingEnvironment env)
env
is moved to CFAbstractAnalysis
, this constructor will be removed
in next major update. Use Analysis(TransferFunction, int)
instead.transfer
- transfer functionmaxCountBeforeWidening
- number of times a block can be analyzed before wideningenv
- associated processing environmentpublic Analysis(T transfer, int maxCountBeforeWidening)
transfer
- transfer functionmaxCountBeforeWidening
- number of times a block can be analyzed before wideningpublic void setCurrentTree(Tree currentTree)
public T getTransferFunction()
transferFunction
@Deprecated public @Nullable Types getTypes()
getTypes()
is moved to CFAbstractAnalysis
, this method will be removed in
next major updatetypes
@Deprecated public @Nullable ProcessingEnvironment getEnv()
getEnv()
is moved to CFAbstractAnalysis
, this method will be removed in
next major updateenv
public void performAnalysis(ControlFlowGraph cfg)
cfg
- the control flow graph used to perform analysisprotected void performAnalysisBlock(Block b)
protected void propagateStoresTo(Block succ, @Nullable 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, @Nullable 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 IdentityHashMap<Node,A> getNodeValues()
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()