Package edu.umd.cs.findbugs.ba.deref
Class UnconditionalValueDerefAnalysis
- java.lang.Object
-
- edu.umd.cs.findbugs.ba.BasicAbstractDataflowAnalysis<Fact>
-
- edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis<Fact>
-
- edu.umd.cs.findbugs.ba.BackwardDataflowAnalysis<UnconditionalValueDerefSet>
-
- edu.umd.cs.findbugs.ba.deref.UnconditionalValueDerefAnalysis
-
- All Implemented Interfaces:
DataflowAnalysis<UnconditionalValueDerefSet>
public class UnconditionalValueDerefAnalysis extends BackwardDataflowAnalysis<UnconditionalValueDerefSet>
Dataflow analysis to find values unconditionally dereferenced in the future.- Author:
- David Hovemeyer
-
-
Field Summary
Fields Modifier and Type Field Description static booleanASSUME_NONZERO_TRIP_LOOPSstatic booleanCHECK_ANNOTATIONSstatic booleanCHECK_CALLSstatic booleanDEBUGstatic booleanDEBUG_CHECK_CALLSstatic booleanIGNORE_DEREF_OF_NCPstatic booleanVERBOSE_NULLARG_DEBUG
-
Constructor Summary
Constructors Constructor Description UnconditionalValueDerefAnalysis(ReverseDepthFirstSearch rdfs, DepthFirstSearch dfs, CFG cfg, org.apache.bcel.classfile.Method method, org.apache.bcel.generic.MethodGen methodGen, ValueNumberDataflow vnaDataflow, AssertionMethods assertionMethods)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.Set<ValueNumber>checkAllNonNullParams(Location location, ValueNumberFrame vnaFrame, org.apache.bcel.generic.ConstantPoolGen constantPool, org.apache.bcel.classfile.Method method, IsNullValueDataflow invDataflow, TypeDataflow typeDataflow)static java.util.Set<ValueNumber>checkNonNullParams(Location location, ValueNumberFrame vnaFrame, org.apache.bcel.generic.ConstantPoolGen constantPool, org.apache.bcel.classfile.Method method, IsNullValueFrame invFrame)static java.util.Set<ValueNumber>checkUnconditionalDerefDatabase(Location location, ValueNumberFrame vnaFrame, org.apache.bcel.generic.ConstantPoolGen constantPool, IsNullValueFrame invFrame, TypeDataflow typeDataflow)voidclearDerefsOnNonNullBranches(IsNullValueDataflow invDataflow)HACK: use the given is-null dataflow to clear deref sets for values that are known to be definitely non-null on a branch.voidcopy(UnconditionalValueDerefSet source, UnconditionalValueDerefSet dest)Copy dataflow facts.UnconditionalValueDerefSetcreateFact()Create empty (uninitialized) dataflow facts for one program point.intgetLastUpdateTimestamp(UnconditionalValueDerefSet fact)voidinitEntryFact(UnconditionalValueDerefSet result)Initialize the "entry" fact for the graph.booleanisFactValid(UnconditionalValueDerefSet fact)Determine whether the given fact is valid (neither top nor bottom).static booleanisNullCheck(org.apache.bcel.generic.InstructionHandle h, org.apache.bcel.generic.ConstantPoolGen cpg)booleanisTop(UnconditionalValueDerefSet fact)Is the given fact the top value.voidmakeFactTop(UnconditionalValueDerefSet fact)Make given fact the top value.voidmeetInto(UnconditionalValueDerefSet fact, Edge edge, UnconditionalValueDerefSet result)Meet a dataflow fact associated with an incoming edge into another fact.voidmeetInto(UnconditionalValueDerefSet fact, Edge edge, UnconditionalValueDerefSet result, boolean onlyEdge)static booleanreportPotentialDereference(Location location, IsNullValueFrame invFrame)booleansame(UnconditionalValueDerefSet fact1, UnconditionalValueDerefSet fact2)Are given dataflow facts the same?voidsetLastUpdateTimestamp(UnconditionalValueDerefSet fact, int lastUpdate)voidsetTypeDataflow(TypeDataflow typeDataflow)voidstartIteration()Called before beginning an iteration of analysis.java.lang.StringtoString()voidtransferInstruction(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock, UnconditionalValueDerefSet fact)Transfer function for a single instruction.-
Methods inherited from class edu.umd.cs.findbugs.ba.BackwardDataflowAnalysis
getBlockOrder, getReverseDepthFirstSearch, isForwards
-
Methods inherited from class edu.umd.cs.findbugs.ba.AbstractDataflowAnalysis
getFactAfterLocation, getFactAtLocation, transfer
-
Methods inherited from class edu.umd.cs.findbugs.ba.BasicAbstractDataflowAnalysis
edgeTransfer, factToString, finishIteration, getFactOnEdge, getResultFact, getStartFact, resultFactIterator
-
-
-
-
Field Detail
-
DEBUG
public static final boolean DEBUG
-
ASSUME_NONZERO_TRIP_LOOPS
public static final boolean ASSUME_NONZERO_TRIP_LOOPS
-
IGNORE_DEREF_OF_NCP
public static final boolean IGNORE_DEREF_OF_NCP
-
CHECK_ANNOTATIONS
public static final boolean CHECK_ANNOTATIONS
-
CHECK_CALLS
public static final boolean CHECK_CALLS
-
DEBUG_CHECK_CALLS
public static final boolean DEBUG_CHECK_CALLS
-
VERBOSE_NULLARG_DEBUG
public static final boolean VERBOSE_NULLARG_DEBUG
-
-
Constructor Detail
-
UnconditionalValueDerefAnalysis
public UnconditionalValueDerefAnalysis(ReverseDepthFirstSearch rdfs, DepthFirstSearch dfs, CFG cfg, org.apache.bcel.classfile.Method method, org.apache.bcel.generic.MethodGen methodGen, ValueNumberDataflow vnaDataflow, AssertionMethods assertionMethods)
Constructor.- Parameters:
rdfs- the reverse depth-first-search (for the block order)cfg- the CFG for the methodmethodGen- the MethodGen for the methodvnaDataflow-assertionMethods- AssertionMethods for the analyzed class
-
-
Method Detail
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clearDerefsOnNonNullBranches
public void clearDerefsOnNonNullBranches(IsNullValueDataflow invDataflow)
HACK: use the given is-null dataflow to clear deref sets for values that are known to be definitely non-null on a branch.- Parameters:
invDataflow- the IsNullValueDataflow to use
-
setTypeDataflow
public void setTypeDataflow(TypeDataflow typeDataflow)
-
isFactValid
public boolean isFactValid(UnconditionalValueDerefSet fact)
Description copied from class:AbstractDataflowAnalysisDetermine whether the given fact is valid (neither top nor bottom).- Specified by:
isFactValidin classAbstractDataflowAnalysis<UnconditionalValueDerefSet>
-
isNullCheck
public static boolean isNullCheck(org.apache.bcel.generic.InstructionHandle h, org.apache.bcel.generic.ConstantPoolGen cpg)
-
reportPotentialDereference
public static boolean reportPotentialDereference(Location location, IsNullValueFrame invFrame) throws DataflowAnalysisException
- Throws:
DataflowAnalysisException
-
transferInstruction
public void transferInstruction(org.apache.bcel.generic.InstructionHandle handle, BasicBlock basicBlock, UnconditionalValueDerefSet fact) throws DataflowAnalysisExceptionDescription copied from class:AbstractDataflowAnalysisTransfer function for a single instruction.- Specified by:
transferInstructionin classAbstractDataflowAnalysis<UnconditionalValueDerefSet>- Parameters:
handle- the instructionbasicBlock- the BasicBlock containing the instruction; needed to disambiguate instructions in inlined JSR subroutinesfact- which should be modified based on the instruction- Throws:
DataflowAnalysisException
-
checkUnconditionalDerefDatabase
public static java.util.Set<ValueNumber> checkUnconditionalDerefDatabase(Location location, ValueNumberFrame vnaFrame, org.apache.bcel.generic.ConstantPoolGen constantPool, @CheckForNull IsNullValueFrame invFrame, TypeDataflow typeDataflow) throws DataflowAnalysisException
- Throws:
DataflowAnalysisException
-
checkAllNonNullParams
public static java.util.Set<ValueNumber> checkAllNonNullParams(Location location, ValueNumberFrame vnaFrame, org.apache.bcel.generic.ConstantPoolGen constantPool, @CheckForNull org.apache.bcel.classfile.Method method, @CheckForNull IsNullValueDataflow invDataflow, TypeDataflow typeDataflow) throws DataflowAnalysisException
- Throws:
DataflowAnalysisException
-
checkNonNullParams
public static java.util.Set<ValueNumber> checkNonNullParams(Location location, ValueNumberFrame vnaFrame, org.apache.bcel.generic.ConstantPoolGen constantPool, @CheckForNull org.apache.bcel.classfile.Method method, @CheckForNull IsNullValueFrame invFrame) throws DataflowAnalysisException
- Throws:
DataflowAnalysisException
-
copy
public void copy(UnconditionalValueDerefSet source, UnconditionalValueDerefSet dest)
Description copied from interface:DataflowAnalysisCopy dataflow facts.
-
createFact
public UnconditionalValueDerefSet 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.
-
initEntryFact
public void initEntryFact(UnconditionalValueDerefSet result) throws DataflowAnalysisException
Description copied from interface:DataflowAnalysisInitialize the "entry" fact for the graph.- Throws:
DataflowAnalysisException
-
makeFactTop
public void makeFactTop(UnconditionalValueDerefSet fact)
Description copied from interface:DataflowAnalysisMake given fact the top value.
-
isTop
public boolean isTop(UnconditionalValueDerefSet fact)
Description copied from interface:DataflowAnalysisIs the given fact the top value.
-
meetInto
public void meetInto(UnconditionalValueDerefSet fact, Edge edge, UnconditionalValueDerefSet 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
-
meetInto
public void meetInto(UnconditionalValueDerefSet fact, Edge edge, UnconditionalValueDerefSet result, boolean onlyEdge)
-
same
public boolean same(UnconditionalValueDerefSet fact1, UnconditionalValueDerefSet fact2)
Description copied from interface:DataflowAnalysisAre given dataflow facts the same?
-
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<UnconditionalValueDerefSet>- Overrides:
startIterationin classBasicAbstractDataflowAnalysis<UnconditionalValueDerefSet>
-
getLastUpdateTimestamp
public int getLastUpdateTimestamp(UnconditionalValueDerefSet fact)
- Specified by:
getLastUpdateTimestampin interfaceDataflowAnalysis<UnconditionalValueDerefSet>- Overrides:
getLastUpdateTimestampin classBasicAbstractDataflowAnalysis<UnconditionalValueDerefSet>
-
setLastUpdateTimestamp
public void setLastUpdateTimestamp(UnconditionalValueDerefSet fact, int lastUpdate)
- Specified by:
setLastUpdateTimestampin interfaceDataflowAnalysis<UnconditionalValueDerefSet>- Overrides:
setLastUpdateTimestampin classBasicAbstractDataflowAnalysis<UnconditionalValueDerefSet>
-
-