Package edu.umd.cs.findbugs.ba.npe
Class ReturnPathTypeAnalysis
- java.lang.Object
-
- edu.umd.cs.findbugs.ba.BasicAbstractDataflowAnalysis<ReturnPathType>
-
- edu.umd.cs.findbugs.ba.npe.ReturnPathTypeAnalysis
-
- All Implemented Interfaces:
DataflowAnalysis<ReturnPathType>
public class ReturnPathTypeAnalysis extends BasicAbstractDataflowAnalysis<ReturnPathType>
A dataflow analysis to determine, at each location in a method's CFG, whether or not it is possible to return normally at that location.- Author:
- David Hovemeyer
-
-
Constructor Summary
Constructors Constructor Description ReturnPathTypeAnalysis(CFG cfg, ReverseDepthFirstSearch rdfs, DepthFirstSearch dfs)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copy(ReturnPathType source, ReturnPathType dest)
Copy dataflow facts.ReturnPathType
createFact()
Create empty (uninitialized) dataflow facts for one program point.void
edgeTransfer(Edge edge, ReturnPathType fact)
Edge transfer function.void
finishIteration()
Called after finishing an iteration of analysis.BlockOrder
getBlockOrder(CFG cfg)
Return the BlockOrder specifying the order in which BasicBlocks should be visited in the main dataflow loop.int
getLastUpdateTimestamp(ReturnPathType fact)
void
initEntryFact(ReturnPathType result)
Initialize the "entry" fact for the graph.boolean
isForwards()
Returns true if the analysis is forwards, false if backwards.boolean
isTop(ReturnPathType fact)
Is the given fact the top value.void
makeFactTop(ReturnPathType fact)
Make given fact the top value.void
meetInto(ReturnPathType fact, Edge edge, ReturnPathType result)
Meet a dataflow fact associated with an incoming edge into another fact.boolean
same(ReturnPathType fact1, ReturnPathType fact2)
Are given dataflow facts the same?void
setLastUpdateTimestamp(ReturnPathType fact, int timestamp)
void
startIteration()
Called before beginning an iteration of analysis.void
transfer(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle end, ReturnPathType start, ReturnPathType result)
Transfer function for the analysis.-
Methods inherited from class edu.umd.cs.findbugs.ba.BasicAbstractDataflowAnalysis
factToString, getFactAfterLocation, getFactAtLocation, getFactOnEdge, getResultFact, getStartFact, resultFactIterator
-
-
-
-
Constructor Detail
-
ReturnPathTypeAnalysis
public ReturnPathTypeAnalysis(CFG cfg, ReverseDepthFirstSearch rdfs, DepthFirstSearch dfs)
Constructor.- Parameters:
cfg
- the method's CFGrdfs
- a ReverseDepthFirstSearch on the method's CFGdfs
- a DepthFirstSearch on the method's CFG
-
-
Method Detail
-
copy
public void copy(ReturnPathType source, ReturnPathType dest)
Description copied from interface:DataflowAnalysis
Copy dataflow facts.
-
createFact
public ReturnPathType createFact()
Description copied from interface:DataflowAnalysis
Create empty (uninitialized) dataflow facts for one program point. A valid value will be copied into it before it is used.
-
edgeTransfer
public void edgeTransfer(Edge edge, ReturnPathType fact)
Description copied from interface:DataflowAnalysis
Edge transfer function. Modify the given fact that is true on the (logical) edge source to modify it so that it is true at the (logical) edge target.A do-nothing implementation is legal, and appropriate for analyses where branches are not significant.
- Specified by:
edgeTransfer
in interfaceDataflowAnalysis<ReturnPathType>
- Overrides:
edgeTransfer
in classBasicAbstractDataflowAnalysis<ReturnPathType>
- Parameters:
edge
- the Edgefact
- a dataflow fact
-
finishIteration
public void finishIteration()
Description copied from interface:DataflowAnalysis
Called after finishing an iteration of analysis.- Specified by:
finishIteration
in interfaceDataflowAnalysis<ReturnPathType>
- Overrides:
finishIteration
in classBasicAbstractDataflowAnalysis<ReturnPathType>
-
getBlockOrder
public BlockOrder getBlockOrder(CFG cfg)
Description copied from interface:DataflowAnalysis
Return the BlockOrder specifying the order in which BasicBlocks should be visited in the main dataflow loop.- Parameters:
cfg
- the CFG upon which we're performing dataflow analysis
-
getLastUpdateTimestamp
public int getLastUpdateTimestamp(ReturnPathType fact)
- Specified by:
getLastUpdateTimestamp
in interfaceDataflowAnalysis<ReturnPathType>
- Overrides:
getLastUpdateTimestamp
in classBasicAbstractDataflowAnalysis<ReturnPathType>
-
initEntryFact
public void initEntryFact(ReturnPathType result) throws DataflowAnalysisException
Description copied from interface:DataflowAnalysis
Initialize the "entry" fact for the graph.- Throws:
DataflowAnalysisException
-
isForwards
public boolean isForwards()
Description copied from interface:DataflowAnalysis
Returns true if the analysis is forwards, false if backwards.
-
isTop
public boolean isTop(ReturnPathType fact)
Description copied from interface:DataflowAnalysis
Is the given fact the top value.
-
makeFactTop
public void makeFactTop(ReturnPathType fact)
Description copied from interface:DataflowAnalysis
Make given fact the top value.
-
meetInto
public void meetInto(ReturnPathType fact, Edge edge, ReturnPathType result) throws DataflowAnalysisException
Description copied from interface:DataflowAnalysis
Meet a dataflow fact associated with an incoming edge into another fact. This is used to determine the start fact for a basic block.- Parameters:
fact
- the predecessor fact (incoming edge)edge
- the edge from the predecessorresult
- the result fact- Throws:
DataflowAnalysisException
-
same
public boolean same(ReturnPathType fact1, ReturnPathType fact2)
Description copied from interface:DataflowAnalysis
Are given dataflow facts the same?
-
setLastUpdateTimestamp
public void setLastUpdateTimestamp(ReturnPathType fact, int timestamp)
- Specified by:
setLastUpdateTimestamp
in interfaceDataflowAnalysis<ReturnPathType>
- Overrides:
setLastUpdateTimestamp
in classBasicAbstractDataflowAnalysis<ReturnPathType>
-
startIteration
public void startIteration()
Description copied from interface:DataflowAnalysis
Called before beginning an iteration of analysis. Each iteration visits every basic block in the CFG.- Specified by:
startIteration
in interfaceDataflowAnalysis<ReturnPathType>
- Overrides:
startIteration
in classBasicAbstractDataflowAnalysis<ReturnPathType>
-
transfer
public void transfer(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle end, ReturnPathType start, ReturnPathType result) throws DataflowAnalysisException
Description copied from interface:DataflowAnalysis
Transfer function for the analysis. Taking dataflow facts at start (which might be either the entry or exit of the block, depending on whether the analysis is forwards or backwards), modify result to be the facts at the other end of the block.- Parameters:
basicBlock
- the basic blockend
- if nonnull, stop before considering this instruction; otherwise, consider all of the instructions in the basic blockstart
- dataflow facts at beginning of block (if forward analysis) or end of block (if backwards analysis)result
- resulting dataflow facts at other end of block- Throws:
DataflowAnalysisException
-
-