more IllegalArgumentExceptions and related cleanups
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1717 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
83b6561c03
commit
b9b20a28b5
|
@ -98,9 +98,9 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
|
||||
/**
|
||||
* @param cg
|
||||
* Governing call graph
|
||||
* Governing call graph
|
||||
* @param noCollapse
|
||||
* set of nodes in the call graph which cannot be collapsed
|
||||
* set of nodes in the call graph which cannot be collapsed
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public PartiallyCollapsedSupergraph(CallGraph cg, Collection<CGNode> noCollapse) {
|
||||
|
@ -109,12 +109,12 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
|
||||
/**
|
||||
* @param cg
|
||||
* Governing call graph
|
||||
* Governing call graph
|
||||
* @param noCollapse
|
||||
* set of nodes in the call graph which cannot be collapsed
|
||||
* set of nodes in the call graph which cannot be collapsed
|
||||
* @param relevant
|
||||
* set of nodes which are relevant and should be included in the
|
||||
* supergraph
|
||||
* set of nodes which are relevant and should be included in the
|
||||
* supergraph
|
||||
*/
|
||||
public PartiallyCollapsedSupergraph(CallGraph cg, Collection<CGNode> noCollapse, Filter<CGNode> relevant) {
|
||||
|
||||
|
@ -131,7 +131,8 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
}
|
||||
}
|
||||
this.noCollapse = noCollapse;
|
||||
this.partialIPFG = new InterproceduralCFG(cg, new Filtersection<CGNode>(relevant, new CollectionFilter<CGNode>(noCollapse)), true);
|
||||
this.partialIPFG = new InterproceduralCFG(cg, new Filtersection<CGNode>(relevant, new CollectionFilter<CGNode>(noCollapse)),
|
||||
true);
|
||||
if (DEBUG_LEVEL > 0) {
|
||||
Trace.println("IPFG \n" + partialIPFG.toString());
|
||||
}
|
||||
|
@ -164,11 +165,10 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
return cg.getFakeRootNode();
|
||||
}
|
||||
|
||||
public Object getEntryForProcedure(Object p) {
|
||||
public Object getEntryForProcedure(CGNode n) {
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(p != null);
|
||||
Assertions._assert(n != null);
|
||||
}
|
||||
CGNode n = (CGNode) p;
|
||||
if (noCollapse.contains(n)) {
|
||||
// p is cg node which is expanded in the IPFG
|
||||
return partialIPFG.getEntry(n);
|
||||
|
@ -179,7 +179,7 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
}
|
||||
|
||||
public Object[] getEntries(Object n) {
|
||||
Object p = getProcOf(n);
|
||||
CGNode p = getProcOf(n);
|
||||
return new Object[] { getEntryForProcedure(p) };
|
||||
}
|
||||
|
||||
|
@ -202,9 +202,8 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
if (object == null) {
|
||||
throw new IllegalArgumentException("object == null");
|
||||
}
|
||||
if (object instanceof IBasicBlock) {
|
||||
IBasicBlock b = (IBasicBlock) object;
|
||||
return partialIPFG.hasCall((BasicBlockInContext) b);
|
||||
if (object instanceof BasicBlockInContext) {
|
||||
return partialIPFG.hasCall((BasicBlockInContext) object);
|
||||
} else {
|
||||
if (Assertions.verifyAssertions) {
|
||||
if (!(object instanceof CollapsedNode)) {
|
||||
|
@ -244,7 +243,7 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
}
|
||||
|
||||
public Iterator<? extends Object> getReturnSites(Object object) {
|
||||
if (object instanceof IBasicBlock) {
|
||||
if (object instanceof BasicBlockInContext) {
|
||||
return partialIPFG.getReturnSites((BasicBlockInContext) object);
|
||||
} else {
|
||||
CGNode n = nodeManager.getProcOfCollapsedNode(object);
|
||||
|
@ -253,7 +252,7 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
}
|
||||
|
||||
public Iterator<? extends Object> getCallSites(Object object) {
|
||||
if (object instanceof IBasicBlock) {
|
||||
if (object instanceof BasicBlockInContext) {
|
||||
return partialIPFG.getCallSites((BasicBlockInContext) object);
|
||||
} else {
|
||||
CGNode n = nodeManager.getProcOfCollapsedNode(object);
|
||||
|
@ -296,7 +295,7 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
*/
|
||||
private void computeTransverseEdges() {
|
||||
// compute transverse edges that originate from basic blocks
|
||||
for (BasicBlockInContext bb: partialIPFG) {
|
||||
for (BasicBlockInContext bb : partialIPFG) {
|
||||
if (partialIPFG.hasCall(bb)) {
|
||||
Set targets = partialIPFG.getCallTargets(bb);
|
||||
for (Iterator it2 = targets.iterator(); it2.hasNext();) {
|
||||
|
@ -698,7 +697,7 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
* TODO: refactor to avoid allocation?
|
||||
*
|
||||
* @param n
|
||||
* a collapsible node
|
||||
* a collapsible node
|
||||
* @return an object that represents entry to this node
|
||||
*/
|
||||
public CollapsedNode getCollapsedEntry(CGNode n) {
|
||||
|
@ -713,7 +712,7 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
* TODO: refactor to avoid allocation?
|
||||
*
|
||||
* @param n
|
||||
* a collapsible node
|
||||
* a collapsible node
|
||||
* @return an object that represents entry to this node
|
||||
*/
|
||||
public CollapsedNode getCollapsedExit(CGNode n) {
|
||||
|
@ -787,7 +786,11 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
return partialIPFG.iterator();
|
||||
}
|
||||
|
||||
public int getNumber(Object N) {
|
||||
public int getNumber(Object N) throws IllegalArgumentException {
|
||||
if (!(N instanceof BasicBlockInContext) && !(N instanceof CollapsedNode)) {
|
||||
throw new IllegalArgumentException(
|
||||
"(not ( N instanceof com.ibm.wala.ipa.cfg.BasicBlockInContext ) ) and (not ( N instanceof com.ibm.wala.dataflow.IFDS.PartiallyCollapsedSupergraph$CollapsedNode ) )");
|
||||
}
|
||||
if (N instanceof CollapsedNode) {
|
||||
return ((CollapsedNode) N).number;
|
||||
} else {
|
||||
|
@ -853,7 +856,7 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
*/
|
||||
public boolean isReturn(Object object) {
|
||||
if (object instanceof BasicBlockInContext) {
|
||||
return partialIPFG.isReturn((BasicBlockInContext)object);
|
||||
return partialIPFG.isReturn((BasicBlockInContext) object);
|
||||
} else {
|
||||
if (nodeManager.isCollapsedExit(object)) {
|
||||
CGNode node = getProcOf(object);
|
||||
|
|
|
@ -28,8 +28,11 @@ public class BitVectorMinusVector extends UnaryOperator<BitVectorVariable> {
|
|||
|
||||
|
||||
@Override
|
||||
public byte evaluate(BitVectorVariable lhs, BitVectorVariable rhs) throws IllegalArgumentException {
|
||||
public byte evaluate(BitVectorVariable lhs, BitVectorVariable rhs) throws IllegalArgumentException, IllegalArgumentException {
|
||||
|
||||
if (lhs == null) {
|
||||
throw new IllegalArgumentException("lhs == null");
|
||||
}
|
||||
if (rhs == null) {
|
||||
throw new IllegalArgumentException("rhs == null");
|
||||
}
|
||||
|
|
|
@ -27,8 +27,10 @@ public class BitVectorOr extends UnaryOperator<BitVectorVariable> {
|
|||
|
||||
|
||||
@Override
|
||||
public byte evaluate(BitVectorVariable lhs, BitVectorVariable rhs) {
|
||||
|
||||
public byte evaluate(BitVectorVariable lhs, BitVectorVariable rhs) throws IllegalArgumentException {
|
||||
if (lhs == null) {
|
||||
throw new IllegalArgumentException("lhs == null");
|
||||
}
|
||||
BitVectorVariable U = new BitVectorVariable();
|
||||
U.copyState(lhs);
|
||||
U.addAll(rhs);
|
||||
|
|
|
@ -207,10 +207,13 @@ public class ContextSensitiveStateMachine implements StateMachine<IFlowLabel> {
|
|||
/*
|
||||
* @see com.ibm.wala.demandpa.alg.statemachine.StateMachine#transition(com.ibm.wala.demandpa.alg.statemachine.StateMachine.State, java.lang.Object)
|
||||
*/
|
||||
public State transition(State prevState, IFlowLabel label) throws IllegalArgumentException {
|
||||
public State transition(State prevState, IFlowLabel label) throws IllegalArgumentException, IllegalArgumentException {
|
||||
if (prevState == null) {
|
||||
throw new IllegalArgumentException("prevState == null");
|
||||
}
|
||||
if (!(prevState instanceof CallStack)) {
|
||||
throw new IllegalArgumentException("not ( prevState instanceof com.ibm.wala.demandpa.alg.CallStack ) ");
|
||||
}
|
||||
CallStack prevStack = (CallStack) prevState;
|
||||
if (!prevStack.isEmpty() && recursiveCallSites.contains(prevStack.peek())) {
|
||||
// just pop off the call site
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.ipa.callgraph.propagation;
|
||||
|
||||
import com.ibm.wala.classLoader.ArrayClass;
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.NewSiteReference;
|
||||
|
@ -74,7 +75,7 @@ public class AllocationSiteInstanceKeys implements InstanceKeyFactory {
|
|||
}
|
||||
|
||||
public InstanceKey getInstanceKeyForMultiNewArray(CGNode node, NewSiteReference allocation, int dim) {
|
||||
IClass type = options.getClassTargetSelector().getAllocatedTarget(node, allocation);
|
||||
ArrayClass type = (ArrayClass) options.getClassTargetSelector().getAllocatedTarget(node, allocation);
|
||||
if (type == null) {
|
||||
Warnings.add(ResolutionFailure.create(node, allocation));
|
||||
return null;
|
||||
|
|
|
@ -27,14 +27,14 @@ public final class MultiNewArrayAllocationSiteKey extends AllocationSiteKey {
|
|||
* @return null if the element type is a primitive
|
||||
* @throws IllegalArgumentException if T == null
|
||||
*/
|
||||
private static IClass myElementType(IClass T, int d) throws IllegalArgumentException {
|
||||
private static IClass myElementType(ArrayClass T, int d) throws IllegalArgumentException, IllegalArgumentException {
|
||||
if (T == null) {
|
||||
throw new IllegalArgumentException("T == null");
|
||||
}
|
||||
if (d == 0) {
|
||||
return ((ArrayClass) T).getElementClass();
|
||||
return T.getElementClass();
|
||||
} else {
|
||||
IClass element = ((ArrayClass)T).getElementClass();
|
||||
ArrayClass element = (ArrayClass) T.getElementClass();
|
||||
if (element == null) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -43,7 +43,7 @@ public final class MultiNewArrayAllocationSiteKey extends AllocationSiteKey {
|
|||
}
|
||||
}
|
||||
|
||||
public MultiNewArrayAllocationSiteKey(CGNode node, NewSiteReference allocation, IClass type, int dim) {
|
||||
public MultiNewArrayAllocationSiteKey(CGNode node, NewSiteReference allocation, ArrayClass type, int dim) {
|
||||
super(node, allocation, myElementType(type, dim));
|
||||
this.dim = dim;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.ipa.callgraph.propagation;
|
||||
|
||||
import com.ibm.wala.classLoader.ArrayClass;
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.NewSiteReference;
|
||||
|
@ -75,7 +76,7 @@ public class SmushedAllocationSiteInstanceKeys implements InstanceKeyFactory {
|
|||
}
|
||||
|
||||
public InstanceKey getInstanceKeyForMultiNewArray(CGNode node, NewSiteReference allocation, int dim) {
|
||||
IClass type = options.getClassTargetSelector().getAllocatedTarget(node, allocation);
|
||||
ArrayClass type = (ArrayClass) options.getClassTargetSelector().getAllocatedTarget(node, allocation);
|
||||
if (type == null) {
|
||||
Warnings.add(ResolutionFailure.create(node, allocation));
|
||||
return null;
|
||||
|
|
|
@ -11,31 +11,25 @@
|
|||
package com.ibm.wala.ipa.summaries;
|
||||
|
||||
import com.ibm.wala.cfg.ControlFlowGraph;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.SyntheticMethod;
|
||||
import com.ibm.wala.ipa.callgraph.Context;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.IRFactory;
|
||||
import com.ibm.wala.ssa.SSAOptions;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
public class SyntheticIRFactory implements IRFactory {
|
||||
public class SyntheticIRFactory implements IRFactory<SyntheticMethod> {
|
||||
|
||||
public ControlFlowGraph makeCFG(IMethod method, Context C) {
|
||||
public ControlFlowGraph makeCFG(SyntheticMethod method, Context C) {
|
||||
if (method == null) {
|
||||
throw new IllegalArgumentException("method is null");
|
||||
}
|
||||
Assertions._assert(method.isSynthetic());
|
||||
SyntheticMethod sm = (SyntheticMethod) method;
|
||||
return sm.makeControlFlowGraph();
|
||||
return method.makeControlFlowGraph();
|
||||
}
|
||||
|
||||
public IR makeIR(IMethod method, Context C, SSAOptions options) {
|
||||
public IR makeIR(SyntheticMethod method, Context C, SSAOptions options) {
|
||||
if (method == null) {
|
||||
throw new IllegalArgumentException("method is null");
|
||||
}
|
||||
Assertions._assert(method.isSynthetic());
|
||||
SyntheticMethod sm = (SyntheticMethod) method;
|
||||
return sm.makeIR(options);
|
||||
return method.makeIR(options);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.ibm.wala.cfg.ControlFlowGraph;
|
|||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.ShrikeCTMethod;
|
||||
import com.ibm.wala.classLoader.ShrikeIRFactory;
|
||||
import com.ibm.wala.classLoader.SyntheticMethod;
|
||||
import com.ibm.wala.ipa.callgraph.Context;
|
||||
import com.ibm.wala.ipa.summaries.SyntheticIRFactory;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
@ -35,7 +36,7 @@ public class DefaultIRFactory implements IRFactory<IMethod> {
|
|||
throw new IllegalArgumentException("method cannot be null");
|
||||
}
|
||||
if (method.isSynthetic()) {
|
||||
return syntheticFactory.makeCFG(method, C);
|
||||
return syntheticFactory.makeCFG((SyntheticMethod)method, C);
|
||||
} else if (method instanceof ShrikeCTMethod) {
|
||||
return shrikeFactory.makeCFG((ShrikeCTMethod) method, C);
|
||||
} else {
|
||||
|
@ -52,7 +53,7 @@ public class DefaultIRFactory implements IRFactory<IMethod> {
|
|||
throw new IllegalArgumentException("method cannot be null");
|
||||
}
|
||||
if (method.isSynthetic()) {
|
||||
return syntheticFactory.makeIR(method, C, options);
|
||||
return syntheticFactory.makeIR((SyntheticMethod)method, C, options);
|
||||
} else if (method instanceof ShrikeCTMethod) {
|
||||
return shrikeFactory.makeIR((ShrikeCTMethod) method, C, options);
|
||||
} else {
|
||||
|
|
|
@ -729,11 +729,10 @@ public class SSACFG implements ControlFlowGraph<ISSABasicBlock> {
|
|||
/*
|
||||
* @see com.ibm.wala.util.graph.NumberedGraph#getNumber(com.ibm.wala.util.graph.Node)
|
||||
*/
|
||||
public int getNumber(ISSABasicBlock N) throws IllegalArgumentException {
|
||||
if (N == null) {
|
||||
public int getNumber(ISSABasicBlock b) throws IllegalArgumentException {
|
||||
if (b == null) {
|
||||
throw new IllegalArgumentException("N == null");
|
||||
}
|
||||
BasicBlock b = (BasicBlock) N;
|
||||
return b.getNumber();
|
||||
}
|
||||
|
||||
|
@ -1028,11 +1027,10 @@ public class SSACFG implements ControlFlowGraph<ISSABasicBlock> {
|
|||
return getSuccNodeNumbers(src).contains(getNumber(dst));
|
||||
}
|
||||
|
||||
public IntSet getSuccNodeNumbers(ISSABasicBlock node) throws IllegalArgumentException {
|
||||
if (node == null) {
|
||||
throw new IllegalArgumentException("node == null");
|
||||
public IntSet getSuccNodeNumbers(ISSABasicBlock b) throws IllegalArgumentException {
|
||||
if (b == null) {
|
||||
throw new IllegalArgumentException("b == null");
|
||||
}
|
||||
BasicBlock b = (BasicBlock) node;
|
||||
IBasicBlock n = cfg.getNode(b.getNumber());
|
||||
return cfg.getSuccNodeNumbers(n);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue