Package edu.umd.cs.findbugs.ba
Class Dataflow<Fact,AnalysisType extends DataflowAnalysis<Fact>>
- java.lang.Object
-
- edu.umd.cs.findbugs.ba.Dataflow<Fact,AnalysisType>
-
- Direct Known Subclasses:
AbstractDataflow
,BlockTypeDataflow
,CallListDataflow
,ConstantDataflow
,LiveLocalStoreDataflow
,LockDataflow
,ObligationDataflow
,ReturnPathDataflow
,ReturnPathTypeDataflow
,TypeDataflow
,TypeQualifierDataflow
public class Dataflow<Fact,AnalysisType extends DataflowAnalysis<Fact>> extends java.lang.Object
Perform dataflow analysis on a method using a control flow graph. Both forward and backward analyses can be performed.- The "start" point of each block is the entry (forward analyses) or the exit (backward analyses).
- The "result" point of each block is the exit (forward analyses) or the entry (backward analyses).
- See Also:
CFG
,DataflowAnalysis
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
Dataflow.BackwardProgramOrder
(package private) static class
Dataflow.ForwardProgramOrder
-
Field Summary
Fields Modifier and Type Field Description private AnalysisType
analysis
private BlockOrder
blockOrder
private CFG
cfg
static boolean
DEBUG
private boolean
isForwards
private static int
MAX_ITERS
private int
numIterations
-
Constructor Summary
Constructors Constructor Description Dataflow(CFG cfg, AnalysisType analysis)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
blockId(BasicBlock bb)
private static void
debug(BasicBlock bb, BasicBlock pred, Edge edge, java.lang.String msg)
private static void
debug(BasicBlock bb, java.lang.String msg)
void
dumpDataflow(AnalysisType analysis)
void
execute()
Run the algorithm.AnalysisType
getAnalysis()
Get the analysis object.CFG
getCFG()
Get the CFG object.Fact
getFactAfterLocation(Location location)
Get the dataflow fact representing the point just after given Location.Fact
getFactAtLocation(Location location)
Get dataflow fact at (just before) given Location.Fact
getFactOnEdge(Edge edge)
Get the fact that is true on the given control edge.private java.lang.String
getFullyQualifiedMethodName()
int
getNumIterations()
Return the number of iterations of the main execution loop.Fact
getResultFact(BasicBlock block)
Get dataflow facts for end of given block.Fact
getStartFact(BasicBlock block)
Get dataflow facts for start of given block.private BasicBlock
logicalEntryBlock()
Get the "logical" entry block of the CFG.private java.util.Iterator<Edge>
logicalPredecessorEdgeIterator(BasicBlock block)
Return an Iterator over edges that connect given block to its logical predecessors.private void
reportAnalysis(java.lang.String msg)
-
-
-
Field Detail
-
cfg
private final CFG cfg
-
analysis
private final AnalysisType extends DataflowAnalysis<Fact> analysis
-
blockOrder
private final BlockOrder blockOrder
-
isForwards
private final boolean isForwards
-
numIterations
private int numIterations
-
DEBUG
public static boolean DEBUG
-
MAX_ITERS
private static final int MAX_ITERS
-
-
Constructor Detail
-
Dataflow
public Dataflow(CFG cfg, AnalysisType analysis)
Constructor.- Parameters:
cfg
- the control flow graphanalysis
- the DataflowAnalysis to be run
-
-
Method Detail
-
getFullyQualifiedMethodName
private java.lang.String getFullyQualifiedMethodName()
-
execute
public void execute() throws DataflowAnalysisException
Run the algorithm. Afterwards, caller can use the getStartFact() and getResultFact() methods to to get dataflow facts at start and result points of each block.- Throws:
DataflowAnalysisException
-
reportAnalysis
private void reportAnalysis(java.lang.String msg)
-
blockId
private static java.lang.String blockId(BasicBlock bb)
-
debug
private static void debug(BasicBlock bb, java.lang.String msg)
-
debug
private static void debug(BasicBlock bb, BasicBlock pred, Edge edge, java.lang.String msg)
-
getNumIterations
public int getNumIterations()
Return the number of iterations of the main execution loop.
-
getStartFact
public Fact getStartFact(BasicBlock block)
Get dataflow facts for start of given block.
-
getResultFact
public Fact getResultFact(BasicBlock block)
Get dataflow facts for end of given block.
-
getFactAtLocation
public Fact getFactAtLocation(Location location) throws DataflowAnalysisException
Get dataflow fact at (just before) given Location. Note "before" is meant in the logical sense, so for backward analyses, before means after the location in the control flow sense.- Parameters:
location
- the Location- Returns:
- the dataflow value at given Location
- Throws:
DataflowAnalysisException
-
getFactAfterLocation
public Fact getFactAfterLocation(Location location) throws DataflowAnalysisException
Get the dataflow fact representing the point just after given Location. Note "after" is meant in the logical sense, so for backward analyses, after means before the location in the control flow sense.- Parameters:
location
- the Location- Returns:
- the dataflow value after given Location
- Throws:
DataflowAnalysisException
-
getFactOnEdge
public Fact getFactOnEdge(Edge edge) throws DataflowAnalysisException
Get the fact that is true on the given control edge.- Parameters:
edge
- the edge- Returns:
- the fact that is true on the edge
- Throws:
DataflowAnalysisException
-
getAnalysis
public AnalysisType getAnalysis()
Get the analysis object.
-
getCFG
public CFG getCFG()
Get the CFG object.
-
logicalPredecessorEdgeIterator
private java.util.Iterator<Edge> logicalPredecessorEdgeIterator(BasicBlock block)
Return an Iterator over edges that connect given block to its logical predecessors. For forward analyses, this is the incoming edges. For backward analyses, this is the outgoing edges.
-
logicalEntryBlock
private BasicBlock logicalEntryBlock()
Get the "logical" entry block of the CFG. For forward analyses, this is the entry block. For backward analyses, this is the exit block.
-
dumpDataflow
public void dumpDataflow(AnalysisType analysis)
-
-