Suppress 88 Eclipse warnings about dead code

All of these involve conditionals that check some static, final debug
flag or debug level.  The code will indeed be dead if WALA is built
with those debug facilities turned off.  But we still want the code
present in case someone needs to turn some aspect of debugging on for
a while.
This commit is contained in:
Ben Liblit 2017-03-17 21:47:10 -05:00
parent 6a81cf8df2
commit 296657a394
17 changed files with 49 additions and 1 deletions

View File

@ -1021,6 +1021,7 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
processCallingConstraintsInternal(this, caller, instruction, target, constParams, uniqueCatchKey);
}
@SuppressWarnings("unused")
public static void processCallingConstraintsInternal(AstSSAPropagationCallGraphBuilder builder, CGNode caller, SSAAbstractInvokeInstruction instruction, CGNode target,
InstanceKey[][] constParams, PointerKey uniqueCatchKey) {

View File

@ -86,6 +86,7 @@ public class CorrelationFinder {
this.translatorFactory = translatorFactory;
}
@SuppressWarnings("unused")
public static CorrelationSummary findCorrelatedAccesses(IMethod method, IR ir) {
AstMethod astMethod = (AstMethod)method;
DefUse du = new DefUse(ir);

View File

@ -93,6 +93,7 @@ public class ClassLoaderImpl implements IClassLoader {
* @param parent parent loader for delegation
* @param exclusions set of classes to exclude from loading
*/
@SuppressWarnings("unused")
public ClassLoaderImpl(ClassLoaderReference loader, ArrayClassLoader arrayClassLoader, IClassLoader parent,
SetOfClasses exclusions, IClassHierarchy cha) {
@ -118,6 +119,7 @@ public class ClassLoaderImpl implements IClassLoader {
* @return the Set of source files in the module
* @throws IOException
*/
@SuppressWarnings("unused")
private Set<ModuleEntry> getSourceFiles(Module M) throws IOException {
if (DEBUG_LEVEL > 0) {
System.err.println("Get source files for " + M);
@ -147,6 +149,7 @@ public class ClassLoaderImpl implements IClassLoader {
* @return the Set of class Files in the module
* @throws IOException
*/
@SuppressWarnings("unused")
private Set<ModuleEntry> getClassFiles(Module M) throws IOException {
if (DEBUG_LEVEL > 0) {
System.err.println("Get class files for " + M);
@ -238,6 +241,7 @@ public class ClassLoaderImpl implements IClassLoader {
/**
* Set up the set of classes loaded by this object.
*/
@SuppressWarnings("unused")
private void loadAllClasses(Collection<ModuleEntry> moduleEntries, Map<String, Object> fileContents) {
for (Iterator<ModuleEntry> it = moduleEntries.iterator(); it.hasNext();) {
ModuleEntry entry = it.next();
@ -406,6 +410,7 @@ public class ClassLoaderImpl implements IClassLoader {
/**
* Set up mapping from type name to Module Entry
*/
@SuppressWarnings("unused")
protected void loadAllSources(Set<ModuleEntry> sourceModules) {
for (Iterator<ModuleEntry> it = sourceModules.iterator(); it.hasNext();) {
ModuleEntry entry = it.next();
@ -474,6 +479,7 @@ public class ClassLoaderImpl implements IClassLoader {
*
* @throws IllegalArgumentException if modules is null
*/
@SuppressWarnings("unused")
@Override
public void init(List<Module> modules) throws IOException {
@ -586,6 +592,7 @@ public class ClassLoaderImpl implements IClassLoader {
/*
* @see com.ibm.wala.classLoader.IClassLoader#lookupClass(com.ibm.wala.types.TypeName)
*/
@SuppressWarnings("unused")
@Override
public IClass lookupClass(TypeName className) {
if (className == null) {
@ -691,6 +698,7 @@ public class ClassLoaderImpl implements IClassLoader {
/*
* @see com.ibm.wala.classLoader.IClassLoader#removeAll(java.util.Collection)
*/
@SuppressWarnings("unused")
@Override
public void removeAll(Collection<IClass> toRemove) {
if (toRemove == null) {

View File

@ -92,6 +92,7 @@ public class BackwardsSupergraph<T, P> implements ISupergraph<T, P> {
*
* @see com.ibm.wala.dataflow.IFDS.ISupergraph#getCalledNodes(java.lang.Object)
*/
@SuppressWarnings("unused")
@Override
public Iterator<T> getCalledNodes(T ret) {
if (DEBUG_LEVEL > 1) {

View File

@ -53,6 +53,7 @@ public class CallFlowEdges {
* @param d1 source fact at the call edge
* @param d2 result fact (result of the call flow function)
*/
@SuppressWarnings("unused")
public void addCallEdge(int c, int d1, int d2) {
if (TabulationSolver.DEBUG_LEVEL > 0) {
System.err.println("addCallEdge " + c + " " + d1 + " " + d2);
@ -80,6 +81,7 @@ public class CallFlowEdges {
* @param d2
* @return set of d1 s.t. {@literal <c, d1> -> <s_p, d2>} was recorded as call flow, or null if none found.
*/
@SuppressWarnings("unused")
public IntSet getCallFlowSources(int c, int d2) {
if (c < 0) {
throw new IllegalArgumentException("invalid c : " + c);
@ -121,6 +123,7 @@ public class CallFlowEdges {
* @param d2
* @return set of c s.t. {@literal <c, d1> -> <s_p, d2>} was recorded as call flow (for some d1), or null if none found.
*/
@SuppressWarnings("unused")
public IntSet getCallFlowSourceNodes(int d2) {
IntSet s = identityEdges.get(d2);
IBinaryNaturalRelation R = edges.get(d2);

View File

@ -99,6 +99,7 @@ public class LocalPathEdges {
*
* @param j
*/
@SuppressWarnings("unused")
public void addPathEdge(int i, int n, int j) {
if (i == 0) {
@ -137,6 +138,7 @@ public class LocalPathEdges {
*
* @param n local block number of the basic block n
*/
@SuppressWarnings("unused")
private void addIdentityPathEdge(int i, int n) {
BitVectorIntSet s = (BitVectorIntSet) identityPaths.get(i);
if (s == null) {
@ -167,6 +169,7 @@ public class LocalPathEdges {
*
* @param j
*/
@SuppressWarnings("unused")
private void addZeroPathEdge(int n, int j) {
BitVectorIntSet z = (BitVectorIntSet) zeroPaths.get(j);

View File

@ -241,6 +241,7 @@ public class TabulationSolver<T, P, F> {
*
* @throws CancelException
*/
@SuppressWarnings("unused")
private void forwardTabulateSLRPs() throws CancelException {
assert curPathEdge == null : "curPathEdge should not be non-null here";
if (worklist == null) {
@ -326,6 +327,7 @@ public class TabulationSolver<T, P, F> {
*
* @param edge
*/
@SuppressWarnings("unused")
private void processNormal(final PathEdge<T> edge) {
if (DEBUG_LEVEL > 0) {
System.err.println("process normal: " + edge);
@ -358,6 +360,7 @@ public class TabulationSolver<T, P, F> {
* Note that we've changed the way we record summary edges. Summary edges are now associated with a callee (s_p,exit), where the
* original algorithm used a call, return pair in the caller.
*/
@SuppressWarnings("unused")
protected void processExit(final PathEdge<T> edge) {
if (DEBUG_LEVEL > 0) {
System.err.println("process exit: " + edge);
@ -399,6 +402,7 @@ public class TabulationSolver<T, P, F> {
* @param c a call site of edge.s_p
* @param D4 set of d1 s.t. {@literal <c, d1> -> <edge.s_p, edge.d2>} was recorded as call flow
*/
@SuppressWarnings("unused")
private void propagateToReturnSites(final PathEdge<T> edge, final T c, final IntSet D4) {
P proc = supergraph.getProcOf(c);
final T[] entries = supergraph.getEntriesForProcedure(proc);
@ -483,6 +487,7 @@ public class TabulationSolver<T, P, F> {
private void propToReturnSite(final T c, final T[] entries, final T retSite, final int d4, final IntSet D5, final PathEdge<T> edge) {
if (D5 != null) {
D5.foreach(new IntSetAction() {
@SuppressWarnings("unused")
@Override
public void act(final int d5) {
// [26 - 28]
@ -537,6 +542,7 @@ public class TabulationSolver<T, P, F> {
/**
* Handle lines [14 - 19] of the algorithm, propagating information into and across a call site.
*/
@SuppressWarnings({ "unused", "unused" })
protected void processCall(final PathEdge<T> edge) {
if (DEBUG_LEVEL > 0) {
System.err.println("process call: " + edge);
@ -618,6 +624,7 @@ public class TabulationSolver<T, P, F> {
* @param allReturnSites a set collecting return sites for the call. This set is mutated with the return sites for this callee.
* @param calleeEntry the entry node of the callee in question
*/
@SuppressWarnings("unused")
protected void processParticularCallee(final PathEdge<T> edge, final int callNodeNum, Collection<T> allReturnSites, final T calleeEntry) {
if (DEBUG_LEVEL > 0) {
System.err.println(" process callee: " + calleeEntry);
@ -738,6 +745,7 @@ public class TabulationSolver<T, P, F> {
* @return f(call_d, exit_d);
*
*/
@SuppressWarnings("unused")
protected IntSet computeBinaryFlow(int call_d, int exit_d, IBinaryReturnFlowFunction f) {
if (DEBUG_LEVEL > 0) {
System.err.println("got binary flow function " + f);
@ -750,6 +758,7 @@ public class TabulationSolver<T, P, F> {
* @return f(d1)
*
*/
@SuppressWarnings("unused")
protected IntSet computeFlow(int d1, IUnaryFlowFunction f) {
if (DEBUG_LEVEL > 0) {
System.err.println("got flow function " + f);
@ -792,6 +801,7 @@ public class TabulationSolver<T, P, F> {
* @param n reached block
* @param j dataflow fact reached
*/
@SuppressWarnings("unused")
protected boolean propagate(T s_p, int i, T n, int j) {
int number = supergraph.getLocalBlockNumber(n);
if (number < 0) {
@ -849,6 +859,7 @@ public class TabulationSolver<T, P, F> {
}
}
@SuppressWarnings("unused")
protected void addToWorkList(T s_p, int i, T n, int j) {
if (worklist == null) {
worklist = makeWorklist();

View File

@ -876,6 +876,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
// }));
}
@SuppressWarnings("unused")
protected boolean addAllToP2Set(Map<PointerKeyAndState, MutableIntSet> p2setMap, PointerKeyAndState pkAndState, IntSet vals,
IFlowLabel label) {
final PointerKey pk = pkAndState.getPointerKey();

View File

@ -100,6 +100,7 @@ public class SimpleMemoryAccessMap implements MemoryAccessMap {
}
}
@SuppressWarnings("unused")
private void populate(CGNode n) {
// we analyze bytecodes to avoid the cost of IR construction, except
// for synthetic methods, where we must use the synthetic IR

View File

@ -213,6 +213,7 @@ public class AnalysisScope {
/**
* Add a jar file to the scope for a loader
*/
@SuppressWarnings("unused")
public void addToScope(ClassLoaderReference loader, JarFile file) {
List<Module> s = MapUtil.findOrCreateList(moduleMap, loader);
if (DEBUG_LEVEL > 0) {
@ -224,6 +225,7 @@ public class AnalysisScope {
/**
* Add a module to the scope for a loader
*/
@SuppressWarnings("unused")
public void addToScope(ClassLoaderReference loader, Module m) {
if (m == null) {
throw new IllegalArgumentException("null m");
@ -252,6 +254,7 @@ public class AnalysisScope {
/**
* Add a module file to the scope for a loader. The classes in the added jar file will override classes added to the scope so far.
*/
@SuppressWarnings("unused")
public void addToScopeHead(ClassLoaderReference loader, Module m) {
if (m == null) {
throw new IllegalArgumentException("null m");

View File

@ -1394,6 +1394,7 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder<In
* @param klass a class
* @return an int set which represents the subset of S that correspond to subtypes of klass
*/
@SuppressWarnings("unused")
protected IntSet filterForClass(IntSet S, IClass klass) {
MutableIntSet filter = null;
if (klass.getReference().equals(TypeReference.JavaLangObject)) {

View File

@ -366,6 +366,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
* @param exceptionVar PointerKey representing a pointer to an exception value
* @param catchClasses the types "caught" by the exceptionVar
*/
@SuppressWarnings("unused")
private void addExceptionDefConstraints(IRView ir, DefUse du, CGNode node, List<ProgramCounter> peis, PointerKey exceptionVar,
Set<IClass> catchClasses) {
if (DEBUG) {
@ -1601,6 +1602,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
processCallingConstraints(caller, instruction, target, constParams, uniqueCatchKey);
}
@SuppressWarnings("unused")
protected void processCallingConstraints(CGNode caller, SSAAbstractInvokeInstruction instruction, CGNode target,
InstanceKey[][] constParams, PointerKey uniqueCatchKey) {
// TODO: i'd like to enable this optimization, but it's a little tricky

View File

@ -117,6 +117,7 @@ public class BasicRTABuilder extends AbstractRTABuilder {
*/
final private MutableIntSet previousReceivers = IntSetUtil.getDefaultIntSetFactory().make();
@SuppressWarnings("unused")
@Override
public byte evaluate(PointsToSetVariable lhs, PointsToSetVariable rhs) {
IntSetVariable receivers = rhs;

View File

@ -145,6 +145,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
*
* @param n
*/
@SuppressWarnings("unused")
private void addIntraproceduralNodesAndEdgesForCGNodeIfNeeded(CGNode n) {
if (!cgNodesVisited.contains(cg.getNumber(n)) && relevant.test(n)) {
if (DEBUG_LEVEL > 0) {
@ -175,6 +176,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
* @param instrs the instructions for node n
* @param bb a basic block in the CFG
*/
@SuppressWarnings("unused")
protected void addEdgesToNonEntryBlock(CGNode n, ControlFlowGraph<?, T> cfg, SSAInstruction[] instrs, T bb) {
if (DEBUG_LEVEL > 1) {
System.err.println("addEdgesToNonEntryBlock: " + bb);
@ -233,6 +235,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
* @param returnBlock the return site for a call
* @param targetCFG the called method
*/
@SuppressWarnings("unused")
private void addEdgesFromExitToReturn(CGNode caller, T returnBlock, CGNode target,
ControlFlowGraph<SSAInstruction, ? extends T> targetCFG) {
T texit = targetCFG.exit();
@ -255,6 +258,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
* @param callBlock the return site for a call
* @param targetCFG the called method
*/
@SuppressWarnings("unused")
private void addEdgesFromCallToEntry(CGNode caller, T callBlock, CGNode target,
ControlFlowGraph<SSAInstruction, ? extends T> targetCFG) {
T tentry = targetCFG.entry();
@ -277,6 +281,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
* @param n a node in the call graph
* @param bb the entry() block for n
*/
@SuppressWarnings("unused")
private void addInterproceduralEdgesForEntryAndExitBlocks(CGNode n, ControlFlowGraph<SSAInstruction, ? extends T> cfg) {
T entryBlock = cfg.entry();
@ -296,6 +301,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
}
}
@SuppressWarnings("unused")
private void addEntryAndExitEdgesToCaller(CGNode n, T entryBlock, T exitBlock, CGNode caller) {
if (DEBUG_LEVEL > 0) {
System.err.println("caller " + caller + "is relevant");
@ -344,6 +350,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
*
* @param cfg a control-flow graph
*/
@SuppressWarnings("unused")
private void addNodeForEachBasicBlock(ControlFlowGraph<? extends SSAInstruction, ? extends T> cfg, CGNode N) {
for (Iterator<? extends T> bbs = cfg.iterator(); bbs.hasNext();) {
T bb = bbs.next();
@ -481,6 +488,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
/**
* add edges to callee entry for call block, and edges from callee exit to corresponding return blocks
*/
@SuppressWarnings("unused")
private void addCalleeEdgesForCall(CGNode n, BasicBlockInContext<T> callBlock) {
int num = g.getNumber(callBlock);
if (!handledCalls.contains(num)) {

View File

@ -83,6 +83,7 @@ public class SummarizedMethodWithNames extends SummarizedMethod {
if (DEBUG) { System.err.println("From old MSUM"); }
}
@SuppressWarnings("unused")
public SummarizedMethodWithNames(MethodReference ref, VolatileMethodSummary summary, IClass declaringClass)
throws NullPointerException {
super(ref, summary.getMethodSummary(), declaringClass);

View File

@ -54,6 +54,7 @@ public abstract class UTF8Convert {
* @returns unicode string
* @throws IllegalArgumentException if utf8 is null
*/
@SuppressWarnings("unused")
public static String fromUTF8(byte[] utf8) throws UTFDataFormatException {
if (utf8 == null) {
throw new IllegalArgumentException("utf8 is null");

View File

@ -147,7 +147,8 @@ public class WDexClassLoaderImpl extends ClassLoaderImpl {
}
private void loadAllDexClasses(Collection<ModuleEntry> moduleEntries) {
@SuppressWarnings("unused")
private void loadAllDexClasses(Collection<ModuleEntry> moduleEntries) {
for (Iterator<ModuleEntry> it = moduleEntries.iterator(); it.hasNext();) {
ModuleEntry entry = it.next();