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 voidcopy(ReturnPathType source, ReturnPathType dest)Copy dataflow facts.ReturnPathTypecreateFact()Create empty (uninitialized) dataflow facts for one program point.voidedgeTransfer(Edge edge, ReturnPathType fact)Edge transfer function.voidfinishIteration()Called after finishing an iteration of analysis.BlockOrdergetBlockOrder(CFG cfg)Return the BlockOrder specifying the order in which BasicBlocks should be visited in the main dataflow loop.intgetLastUpdateTimestamp(ReturnPathType fact)voidinitEntryFact(ReturnPathType result)Initialize the "entry" fact for the graph.booleanisForwards()Returns true if the analysis is forwards, false if backwards.booleanisTop(ReturnPathType fact)Is the given fact the top value.voidmakeFactTop(ReturnPathType fact)Make given fact the top value.voidmeetInto(ReturnPathType fact, Edge edge, ReturnPathType result)Meet a dataflow fact associated with an incoming edge into another fact.booleansame(ReturnPathType fact1, ReturnPathType fact2)Are given dataflow facts the same?voidsetLastUpdateTimestamp(ReturnPathType fact, int timestamp)voidstartIteration()Called before beginning an iteration of analysis.voidtransfer(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:DataflowAnalysisCopy dataflow facts.
-
createFact
public ReturnPathType createFact()
Description copied from interface:DataflowAnalysisCreate 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:DataflowAnalysisEdge 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:
edgeTransferin interfaceDataflowAnalysis<ReturnPathType>- Overrides:
edgeTransferin classBasicAbstractDataflowAnalysis<ReturnPathType>- Parameters:
edge- the Edgefact- a dataflow fact
-
finishIteration
public void finishIteration()
Description copied from interface:DataflowAnalysisCalled after finishing an iteration of analysis.- Specified by:
finishIterationin interfaceDataflowAnalysis<ReturnPathType>- Overrides:
finishIterationin classBasicAbstractDataflowAnalysis<ReturnPathType>
-
getBlockOrder
public BlockOrder getBlockOrder(CFG cfg)
Description copied from interface:DataflowAnalysisReturn 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:
getLastUpdateTimestampin interfaceDataflowAnalysis<ReturnPathType>- Overrides:
getLastUpdateTimestampin classBasicAbstractDataflowAnalysis<ReturnPathType>
-
initEntryFact
public void initEntryFact(ReturnPathType result) throws DataflowAnalysisException
Description copied from interface:DataflowAnalysisInitialize the "entry" fact for the graph.- Throws:
DataflowAnalysisException
-
isForwards
public boolean isForwards()
Description copied from interface:DataflowAnalysisReturns true if the analysis is forwards, false if backwards.
-
isTop
public boolean isTop(ReturnPathType fact)
Description copied from interface:DataflowAnalysisIs the given fact the top value.
-
makeFactTop
public void makeFactTop(ReturnPathType fact)
Description copied from interface:DataflowAnalysisMake given fact the top value.
-
meetInto
public void meetInto(ReturnPathType fact, Edge edge, ReturnPathType result) throws DataflowAnalysisException
Description copied from interface:DataflowAnalysisMeet 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:DataflowAnalysisAre given dataflow facts the same?
-
setLastUpdateTimestamp
public void setLastUpdateTimestamp(ReturnPathType fact, int timestamp)
- Specified by:
setLastUpdateTimestampin interfaceDataflowAnalysis<ReturnPathType>- Overrides:
setLastUpdateTimestampin classBasicAbstractDataflowAnalysis<ReturnPathType>
-
startIteration
public void startIteration()
Description copied from interface:DataflowAnalysisCalled before beginning an iteration of analysis. Each iteration visits every basic block in the CFG.- Specified by:
startIterationin interfaceDataflowAnalysis<ReturnPathType>- Overrides:
startIterationin classBasicAbstractDataflowAnalysis<ReturnPathType>
-
transfer
public void transfer(BasicBlock basicBlock, org.apache.bcel.generic.InstructionHandle end, ReturnPathType start, ReturnPathType result) throws DataflowAnalysisException
Description copied from interface:DataflowAnalysisTransfer 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
-
-