Retain some unused methods

Manu requests that we keep these around even though they are currently
unused.  So we'll retain them, but also annotate them to suppress the
warning.
This commit is contained in:
Ben Liblit 2017-03-25 16:58:55 -05:00
parent 64dfd2d908
commit b4e5d078dd
4 changed files with 138 additions and 1 deletions

View File

@ -274,6 +274,14 @@ public abstract class FieldBasedCallGraphBuilder {
return flowGraph.getReachingSet(functionParam, monitor);
}
@SuppressWarnings("unused")
private OrdinalSet<FuncVertex> getConstructorTargets(FlowGraph flowGraph, CallVertex callVertex, IProgressMonitor monitor) throws CancelException {
SSAAbstractInvokeInstruction invoke = callVertex.getInstruction();
assert invoke.getDeclaredTarget().getName().equals(JavaScriptMethods.ctorAtom);
VarVertex objectParam = flowGraph.getVertexFactory().makeVarVertex(callVertex.getCaller(), invoke.getUse(0));
return flowGraph.getReachingSet(objectParam, monitor);
}
/**
* Extract call edges from the flow graph into high-level representation.
*/

View File

@ -19,6 +19,7 @@ import java.util.Iterator;
import java.util.List;
import java.util.Set;
import com.ibm.wala.analysis.reflection.CloneInterpreter;
import com.ibm.wala.cfg.ControlFlowGraph;
import com.ibm.wala.cfg.IBasicBlock;
import com.ibm.wala.classLoader.ArrayClass;
@ -71,6 +72,7 @@ import com.ibm.wala.ssa.SSAThrowInstruction;
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.FieldReference;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.Selector;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.MonitorUtil;
@ -139,6 +141,16 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
*/
protected final static boolean SHORT_CIRCUIT_SINGLE_USES = false;
/**
* Should we change calls to clone() to assignments?
*/
private final boolean clone2Assign = false;
/**
* Cache for efficiency
*/
private final static Selector cloneSelector = CloneInterpreter.CLONE.getSelector();
/**
* set of class whose clinits have already been processed
*/
@ -1880,6 +1892,74 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
*/
}
@SuppressWarnings("unused")
private void handleAllReceivers(MutableIntSet receiverVals, InstanceKey[] keys, MutableBoolean sideEffect) {
assert keys[0] == null;
IntIterator receiverIter = receiverVals.intIterator();
while (receiverIter.hasNext()) {
final int rcvr = receiverIter.next();
keys[0] = system.getInstanceKey(rcvr);
if (clone2Assign) {
// for efficiency: assume that only call sites that reference
// clone() might dispatch to clone methods
if (call.getCallSite().getDeclaredTarget().getSelector().equals(cloneSelector)) {
IClass recv = (keys[0] != null) ? keys[0].getConcreteType() : null;
IMethod targetMethod = getOptions().getMethodTargetSelector().getCalleeTarget(node, call.getCallSite(), recv);
if (targetMethod != null && targetMethod.getReference().equals(CloneInterpreter.CLONE)) {
// treat this call to clone as an assignment
PointerKey result = getPointerKeyForLocal(node, call.getDef());
PointerKey receiver = getPointerKeyForLocal(node, call.getReceiver());
system.newConstraint(result, assignOperator, receiver);
return;
}
}
}
CGNode target = getTargetForCall(node, call.getCallSite(), keys[0].getConcreteType(), keys);
if (target == null) {
// This indicates an error; I sure hope getTargetForCall
// raised a warning about this!
if (DEBUG) {
System.err.println("Warning: null target for call " + call);
}
} else {
IntSet targets = getCallGraph().getPossibleTargetNumbers(node, call.getCallSite());
// even if we've seen this target before, if we have constant
// parameters, we may need to re-process the call, as the constraints
// for the first time we reached this target may not have been fully
// general. TODO a more refined check?
if (targets != null && targets.contains(target.getGraphNodeId()) && noConstParams()) {
// do nothing; we've previously discovered and handled this
// receiver for this call site.
} else {
// process the newly discovered target for this call
sideEffect.b = true;
processResolvedCall(node, call, target, constParams, uniqueCatch);
if (!haveAlreadyVisited(target)) {
markDiscovered(target);
}
}
}
}
keys[0] = null;
}
private boolean noConstParams() {
if (constParams != null) {
for (int i = 0; i < constParams.length; i++) {
if (constParams[i] != null) {
for (int j = 0; j < constParams[i].length; i++) {
if (constParams[i][j] != null) {
return false;
}
}
}
}
}
return true;
}
@Override
public String toString() {
return "Dispatch to " + call + " in node " + node;

View File

@ -533,7 +533,28 @@ public class Instantiator implements IInstantiator {
return ret;
}
/**
* Path back to Object (including T itself).
*/
@SuppressWarnings("unused")
private List<TypeReference> getAllSuper(final TypeReference T) {
if (T.isPrimitiveType()) {
throw new IllegalArgumentException("Not you that call primitive type on :P");
}
final List<TypeReference> ret = new ArrayList<>();
IClass cls = this.cha.lookupClass(T);
if (cls == null) {
throw new IllegalArgumentException("The type " + T + " is not in the ClassHierarchy");
}
while (cls != null) {
ret.add(cls.getReference());
cls = cls.getSuperclass();
}
return ret;
}
/**
* The Constructor starts with 'this()' or 'super()'.

View File

@ -280,6 +280,21 @@ public class AndroidManifestXMLReader {
return Collections.unmodifiableSet(this.relevantAttributes);
}
/**
* The given Attr is in {@link #getRelevantAttributes()}.
*/
public boolean isRelevant(Attr attr) {
return relevantAttributes.contains(attr);
}
/**
* All Tags in this Enum but UNIMPORTANT are relevant.
*/
@SuppressWarnings("unused")
public boolean isRelevant() {
return (this != Tag.UNIMPORTANT);
}
/**
* Match the Tag-Name in the XML-File against the one associated to the Enums Tag.
*
@ -297,6 +312,14 @@ public class AndroidManifestXMLReader {
return Tag.UNIMPORTANT;
}
}
/**
* The Tag appears in the XML File using this name.
*/
@SuppressWarnings("unused")
public String getName() {
return this.tagName;
}
}
/**
@ -324,6 +347,11 @@ public class AndroidManifestXMLReader {
this.attrName = attrName;
}
@SuppressWarnings("unused")
public boolean isRelevantIn(Tag tag) {
return tag.isRelevant(this);
}
public String getName() {
return this.attrName;
}