Package edu.umd.cs.findbugs.detect
Class FindDeadLocalStores
java.lang.Object
edu.umd.cs.findbugs.detect.FindDeadLocalStores
- All Implemented Interfaces:
Detector
,Priorities
Find dead stores to local variables.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final BugReporter
private static final boolean
private static final BitSet
Opcodes of instructions that load constant values that often indicate defensive programming.private static final String
private static final boolean
System property to enable a feature that suppresses warnings if there is at least one live store on the line where the warning would be reported.Fields inherited from interface edu.umd.cs.findbugs.Priorities
EXP_PRIORITY, HIGH_PRIORITY, IGNORE_PRIORITY, LOW_PRIORITY, NORMAL_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
analyzeMethod
(ClassContext classContext, org.apache.bcel.classfile.Method method) private void
countLocalStoresLoadsAndIncrements
(int[] localStoreCount, int[] localLoadCount, int[] localIncrementCount, CFG cfg) Count stores, loads, and increments of local variables in method whose CFG is given.private boolean
Is instruction at given location a load?private boolean
Is instruction at given location a store?private boolean
prescreen
(ClassContext classContext, org.apache.bcel.classfile.Method method) void
report()
This method is called after all classes to be visited.private void
suppressWarningsIfOneLiveStoreOnLine
(BugAccumulator accumulator, BitSet liveStoreSourceLineSet) If feature is enabled, suppress warnings where there is at least one live store on the line where the warning would be reported.void
visitClassContext
(ClassContext classContext) Visit the ClassContext for a class which should be analyzed for instances of bug patterns.
-
Field Details
-
DEBUG
private static final boolean DEBUG -
FINDBUGS_EXCLUDED_LOCALS_PROP_NAME
- See Also:
-
EXCLUDED_LOCALS
-
SUPPRESS_IF_AT_LEAST_ONE_LIVE_STORE_ON_LINE
private static final boolean SUPPRESS_IF_AT_LEAST_ONE_LIVE_STORE_ON_LINESystem property to enable a feature that suppresses warnings if there is at least one live store on the line where the warning would be reported. Eliminates some FPs due to inlining/duplication of finally blocks. But, kills some legitimate warnings where there are truly multiple stores on the same line. -
defensiveConstantValueOpcodes
Opcodes of instructions that load constant values that often indicate defensive programming. -
bugReporter
-
-
Constructor Details
-
FindDeadLocalStores
-
-
Method Details
-
prescreen
-
visitClassContext
Description copied from interface:Detector
Visit the ClassContext for a class which should be analyzed for instances of bug patterns.- Specified by:
visitClassContext
in interfaceDetector
- Parameters:
classContext
- the ClassContext
-
analyzeMethod
private void analyzeMethod(ClassContext classContext, org.apache.bcel.classfile.Method method) throws DataflowAnalysisException, CFGBuilderException -
suppressWarningsIfOneLiveStoreOnLine
private void suppressWarningsIfOneLiveStoreOnLine(BugAccumulator accumulator, BitSet liveStoreSourceLineSet) If feature is enabled, suppress warnings where there is at least one live store on the line where the warning would be reported.- Parameters:
accumulator
- BugAccumulator containing warnings for methodliveStoreSourceLineSet
- bitset of lines where at least one live store was seen
-
countLocalStoresLoadsAndIncrements
private void countLocalStoresLoadsAndIncrements(int[] localStoreCount, int[] localLoadCount, int[] localIncrementCount, CFG cfg) Count stores, loads, and increments of local variables in method whose CFG is given.- Parameters:
localStoreCount
- counts of local stores (indexed by local)localLoadCount
- counts of local loads (indexed by local)localIncrementCount
- counts of local increments (indexed by local)cfg
- control flow graph (CFG) of method
-
isStore
Is instruction at given location a store?- Parameters:
location
- the location- Returns:
- true if instruction at given location is a store, false if not
-
isLoad
Is instruction at given location a load?- Parameters:
location
- the location- Returns:
- true if instruction at given location is a load, false if not
-
report
public void report()Description copied from interface:Detector
This method is called after all classes to be visited. It should be used by any detectors which accumulate information over all visited classes to generate results.
-