more IllegalArgumentExceptions and declared exceptions
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1665 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
a11e72931b
commit
19a0c8a5ad
|
@ -634,7 +634,7 @@ public abstract class AbstractCFG implements ControlFlowGraph, Constants {
|
|||
return Iterator2Collection.toCollection(iterateNormalPredecessors(b));
|
||||
}
|
||||
|
||||
public IntSet getPredNodeNumbers(IBasicBlock node) {
|
||||
public IntSet getPredNodeNumbers(IBasicBlock node) throws UnimplementedError {
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -543,11 +543,11 @@ public class TwoExitCFG implements ControlFlowGraph {
|
|||
return new NumberedNodeIterator<IBasicBlock>(s, this);
|
||||
}
|
||||
|
||||
public void removeIncomingEdges(IBasicBlock node) {
|
||||
public void removeIncomingEdges(IBasicBlock node) throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void removeOutgoingEdges(IBasicBlock node) {
|
||||
public void removeOutgoingEdges(IBasicBlock node) throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -152,7 +152,7 @@ public class SyntheticMethod implements IMethod {
|
|||
return new InducedCFG(getStatements(), this, Everywhere.EVERYWHERE);
|
||||
}
|
||||
|
||||
public BytecodeStream getBytecodeStream() {
|
||||
public BytecodeStream getBytecodeStream() throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -217,7 +217,7 @@ public class ExplodedSupergraph<T> implements Graph<ExplodedSupergraphNode<T>> {
|
|||
return count;
|
||||
}
|
||||
|
||||
public void addEdge(ExplodedSupergraphNode src, ExplodedSupergraphNode dst) {
|
||||
public void addEdge(ExplodedSupergraphNode src, ExplodedSupergraphNode dst) throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -264,8 +264,8 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
throw new IllegalArgumentException(
|
||||
"(n instanceof com.ibm.wala.cfg.IBasicBlock) and (not ( n instanceof com.ibm.wala.ipa.cfg.BasicBlockInContext ) )");
|
||||
}
|
||||
if (n instanceof IBasicBlock) {
|
||||
return partialIPFG.getCGNode((IBasicBlock) n);
|
||||
if (n instanceof BasicBlockInContext) {
|
||||
return partialIPFG.getCGNode((BasicBlockInContext) n);
|
||||
} else {
|
||||
return nodeManager.getProcOfCollapsedNode(n);
|
||||
}
|
||||
|
@ -294,9 +294,8 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
*/
|
||||
private void computeTransverseEdges() {
|
||||
// compute transverse edges that originate from basic blocks
|
||||
for (Iterator it = partialIPFG.iterator(); it.hasNext();) {
|
||||
IBasicBlock bb = (IBasicBlock) it.next();
|
||||
if (partialIPFG.hasCall((BasicBlockInContext) bb)) {
|
||||
for (BasicBlockInContext bb: partialIPFG) {
|
||||
if (partialIPFG.hasCall(bb)) {
|
||||
Set targets = partialIPFG.getCallTargets(bb);
|
||||
for (Iterator it2 = targets.iterator(); it2.hasNext();) {
|
||||
CGNode n = (CGNode) it2.next();
|
||||
|
@ -851,8 +850,8 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
|
|||
* @see com.ibm.wala.dataflow.IFDS.ISupergraph#isReturn(java.lang.Object)
|
||||
*/
|
||||
public boolean isReturn(Object object) {
|
||||
if (object instanceof IBasicBlock) {
|
||||
return partialIPFG.isReturn(object);
|
||||
if (object instanceof BasicBlockInContext) {
|
||||
return partialIPFG.isReturn((BasicBlockInContext)object);
|
||||
} else {
|
||||
if (nodeManager.isCollapsedExit(object)) {
|
||||
CGNode node = getProcOf(object);
|
||||
|
|
|
@ -56,6 +56,7 @@ import com.ibm.wala.util.collections.FilterIterator;
|
|||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.debug.Trace;
|
||||
import com.ibm.wala.util.debug.UnimplementedError;
|
||||
import com.ibm.wala.util.graph.traverse.SlowDFSDiscoverTimeIterator;
|
||||
|
||||
/**
|
||||
|
@ -74,7 +75,7 @@ public class SimpleDemandPointsTo extends AbstractDemandPointsTo {
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<InstanceKey> getPointsTo(PointerKey pk) {
|
||||
public Collection<InstanceKey> getPointsTo(PointerKey pk) throws UnimplementedError {
|
||||
|
||||
Assertions._assert(pk instanceof LocalPointerKey, "we only handle locals");
|
||||
LocalPointerKey lpk = (LocalPointerKey) pk;
|
||||
|
|
|
@ -158,7 +158,7 @@ public abstract class UnaryStatement extends AbstractStatement {
|
|||
return result;
|
||||
}
|
||||
|
||||
public IVariable[] getRHS() {
|
||||
public IVariable[] getRHS() throws UnsupportedOperationException {
|
||||
// This should never be called ...use the more efficient getRightHandSide instead
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,10 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
|
|||
public class OneCFABuilder extends CFABuilder {
|
||||
|
||||
public static OneCFABuilder make(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache,
|
||||
ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter, ReflectionSpecification reflect) {
|
||||
ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter, ReflectionSpecification reflect) throws IllegalArgumentException {
|
||||
if (options == null) {
|
||||
throw new IllegalArgumentException("options == null");
|
||||
}
|
||||
return new OneCFABuilder(cha, options, cache, appContextSelector, appContextInterpreter, reflect);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,10 @@ public class ZeroXCFABuilder extends CFABuilder {
|
|||
|
||||
public static ZeroXCFABuilder make(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache,
|
||||
ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter, ReflectionSpecification reflect,
|
||||
int instancePolicy) {
|
||||
int instancePolicy) throws IllegalArgumentException {
|
||||
if (options == null) {
|
||||
throw new IllegalArgumentException("options == null");
|
||||
}
|
||||
return new ZeroXCFABuilder(cha, options, cache, appContextSelector, appContextInterpreter, reflect, instancePolicy);
|
||||
}
|
||||
|
||||
|
|
|
@ -526,32 +526,32 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
|
|||
}
|
||||
BasicBlockInContext b = new BasicBlockInContext(N, bb);
|
||||
G.addNode(b);
|
||||
if (hasCall(bb, cfg)) {
|
||||
if (hasCall(b, cfg)) {
|
||||
hasCallVector.set(getNumber(b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param B
|
||||
* @return the original CFG from whence B came
|
||||
* @throws IllegalArgumentException if B == null
|
||||
*/
|
||||
public ControlFlowGraph getCFG(IBasicBlock B) {
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(B instanceof BasicBlockInContext);
|
||||
public ControlFlowGraph getCFG(BasicBlockInContext B) throws IllegalArgumentException {
|
||||
if (B == null) {
|
||||
throw new IllegalArgumentException("B == null");
|
||||
}
|
||||
return getCFG(getCGNode(B));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param B
|
||||
* @return the original CGNode from whence B came
|
||||
* @throws IllegalArgumentException if B == null
|
||||
*/
|
||||
public CGNode getCGNode(IBasicBlock B) {
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(B instanceof BasicBlockInContext);
|
||||
public CGNode getCGNode(BasicBlockInContext B) throws IllegalArgumentException {
|
||||
if (B == null) {
|
||||
throw new IllegalArgumentException("B == null");
|
||||
}
|
||||
return ((BasicBlockInContext) B).getNode();
|
||||
return B.getNode();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -662,10 +662,9 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param B
|
||||
* @return true iff basic block B ends in a call instuction
|
||||
*/
|
||||
private boolean hasCall(IBasicBlock B, ControlFlowGraph cfg) {
|
||||
private boolean hasCall(BasicBlockInContext B, ControlFlowGraph cfg) {
|
||||
IInstruction[] statements = cfg.getInstructions();
|
||||
|
||||
int lastIndex = B.getLastInstructionIndex();
|
||||
|
@ -692,13 +691,10 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
|
|||
* @throws IllegalArgumentException
|
||||
* if B is null
|
||||
*/
|
||||
public Set<CGNode> getCallTargets(IBasicBlock B) {
|
||||
public Set<CGNode> getCallTargets(BasicBlockInContext B) {
|
||||
if (B == null) {
|
||||
throw new IllegalArgumentException("B is null");
|
||||
}
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(B instanceof BasicBlockInContext);
|
||||
}
|
||||
ControlFlowGraph cfg = getCFG(B);
|
||||
return getCallTargets(B, cfg, getCGNode(B));
|
||||
}
|
||||
|
@ -814,11 +810,10 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
|
|||
}
|
||||
};
|
||||
|
||||
public boolean isReturn(Object object) {
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(object instanceof BasicBlockInContext);
|
||||
public boolean isReturn(BasicBlockInContext bb) throws IllegalArgumentException {
|
||||
if (bb == null) {
|
||||
throw new IllegalArgumentException("bb == null");
|
||||
}
|
||||
BasicBlockInContext bb = (BasicBlockInContext) object;
|
||||
ControlFlowGraph cfg = getCFG(bb);
|
||||
for (Iterator it = cfg.getPredNodes(bb.getDelegate()); it.hasNext();) {
|
||||
IBasicBlock b = (IBasicBlock) it.next();
|
||||
|
|
|
@ -207,6 +207,7 @@ public class HeapReachingDefs {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
|
|
|
@ -58,7 +58,10 @@ import com.ibm.wala.util.intset.IntPair;
|
|||
public class SSABuilder extends AbstractIntStackMachine {
|
||||
|
||||
public static SSABuilder make(ShrikeCTMethod method, SSACFG cfg, ShrikeCFG scfg, SSAInstruction[] instructions,
|
||||
SymbolTable symbolTable, boolean buildLocalMap, boolean addPiNodes) {
|
||||
SymbolTable symbolTable, boolean buildLocalMap, boolean addPiNodes) throws IllegalArgumentException {
|
||||
if (scfg == null) {
|
||||
throw new IllegalArgumentException("scfg == null");
|
||||
}
|
||||
return new SSABuilder(method, cfg, scfg, instructions, symbolTable, buildLocalMap, addPiNodes);
|
||||
}
|
||||
|
||||
|
@ -78,8 +81,8 @@ public class SSABuilder extends AbstractIntStackMachine {
|
|||
*/
|
||||
private final SSA2LocalMap localMap;
|
||||
|
||||
private SSABuilder(ShrikeCTMethod method, SSACFG cfg, ShrikeCFG scfg, SSAInstruction[] instructions,
|
||||
SymbolTable symbolTable, boolean buildLocalMap, boolean addPiNodes) {
|
||||
private SSABuilder(ShrikeCTMethod method, SSACFG cfg, ShrikeCFG scfg, SSAInstruction[] instructions, SymbolTable symbolTable,
|
||||
boolean buildLocalMap, boolean addPiNodes) {
|
||||
super(scfg);
|
||||
localMap = buildLocalMap ? new SSA2LocalMap(scfg, instructions.length, cfg.getNumberOfNodes(), maxLocals) : null;
|
||||
init(new SymbolTableMeeter(symbolTable, cfg, instructions, scfg), new SymbolicPropagator(scfg, instructions, symbolTable,
|
||||
|
@ -604,10 +607,10 @@ public class SSABuilder extends AbstractIntStackMachine {
|
|||
NewSiteReference ref = NewSiteReference.make(getCurrentProgramCounter(), t);
|
||||
if (t.isArrayType()) {
|
||||
int[] sizes = new int[t.getDimensionality()];
|
||||
for (int i = 0; i<instruction.getArrayBoundsCount(); i++) {
|
||||
for (int i = 0; i < instruction.getArrayBoundsCount(); i++) {
|
||||
sizes[i] = workingState.pop();
|
||||
}
|
||||
for (int i = instruction.getArrayBoundsCount(); i< sizes.length; i++) {
|
||||
for (int i = instruction.getArrayBoundsCount(); i < sizes.length; i++) {
|
||||
sizes[i] = symbolTable.getConstant(0);
|
||||
}
|
||||
emitInstruction(new SSANewInstruction(result, ref, sizes));
|
||||
|
@ -815,9 +818,9 @@ public class SSABuilder extends AbstractIntStackMachine {
|
|||
|
||||
/**
|
||||
* @param nInstructions
|
||||
* number of instructions in the bytecode for this method
|
||||
* number of instructions in the bytecode for this method
|
||||
* @param nBlocks
|
||||
* number of basic blocks in the CFG
|
||||
* number of basic blocks in the CFG
|
||||
*/
|
||||
SSA2LocalMap(ShrikeCFG shrikeCfg, int nInstructions, int nBlocks, int maxLocals) {
|
||||
shrikeCFG = shrikeCfg;
|
||||
|
@ -862,9 +865,9 @@ public class SSABuilder extends AbstractIntStackMachine {
|
|||
|
||||
/**
|
||||
* @param index -
|
||||
* index into IR instruction array
|
||||
* index into IR instruction array
|
||||
* @param vn -
|
||||
* value number
|
||||
* value number
|
||||
*/
|
||||
public String[] getLocalNames(int index, int vn) {
|
||||
try {
|
||||
|
@ -892,9 +895,9 @@ public class SSABuilder extends AbstractIntStackMachine {
|
|||
|
||||
/**
|
||||
* @param pc
|
||||
* a program counter (index into ShrikeBT instruction array)
|
||||
* a program counter (index into ShrikeBT instruction array)
|
||||
* @param vn
|
||||
* a value number
|
||||
* a value number
|
||||
* @return if we know that immediately after the given program counter, v_vn
|
||||
* corresponds to some set of locals, then return an array of the
|
||||
* local numbers. else return null.
|
||||
|
|
|
@ -213,7 +213,7 @@ public class ExplodedControlFlowGraph implements ControlFlowGraph {
|
|||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public void addNode(IBasicBlock n) {
|
||||
public void addNode(IBasicBlock n) throws UnsupportedOperationException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ public class DelegatingNumberedEdgeManager<T extends INodeWithNumberedEdges> imp
|
|||
/*
|
||||
* @see com.ibm.wala.util.graph.EdgeManager#removeEdges(com.ibm.wala.util.graph.Node)
|
||||
*/
|
||||
public void removeAllIncidentEdges(T node) {
|
||||
public void removeAllIncidentEdges(T node) throws UnimplementedError {
|
||||
if (node == null) {
|
||||
throw new IllegalArgumentException("node is null");
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ public class DelegatingNumberedEdgeManager<T extends INodeWithNumberedEdges> imp
|
|||
/*
|
||||
* @see com.ibm.wala.util.graph.EdgeManager#removeEdges(com.ibm.wala.util.graph.Node)
|
||||
*/
|
||||
public void removeIncomingEdges(T node) {
|
||||
public void removeIncomingEdges(T node) throws UnimplementedError {
|
||||
if (node == null) {
|
||||
throw new IllegalArgumentException("node cannot be null");
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ public class DelegatingNumberedEdgeManager<T extends INodeWithNumberedEdges> imp
|
|||
/*
|
||||
* @see com.ibm.wala.util.graph.EdgeManager#removeEdges(com.ibm.wala.util.graph.Node)
|
||||
*/
|
||||
public void removeOutgoingEdges(T node) {
|
||||
public void removeOutgoingEdges(T node) throws UnimplementedError {
|
||||
if (node == null) {
|
||||
throw new IllegalArgumentException("node cannot be null");
|
||||
}
|
||||
|
|
|
@ -52,8 +52,12 @@ public final class SparseNumberedEdgeManager<T> implements NumberedEdgeManager<T
|
|||
* an object to track nodes
|
||||
* @param normalCase
|
||||
* what is the "normal" number of out edges for a node?
|
||||
* @throws IllegalArgumentException if normalCase < 0
|
||||
*/
|
||||
public SparseNumberedEdgeManager(NumberedNodeManager<T> nodeManager, int normalCase, byte delegateImpl) {
|
||||
public SparseNumberedEdgeManager(NumberedNodeManager<T> nodeManager, int normalCase, byte delegateImpl) throws IllegalArgumentException {
|
||||
if (normalCase < 0) {
|
||||
throw new IllegalArgumentException("normalCase < 0");
|
||||
}
|
||||
this.nodeManager = nodeManager;
|
||||
if (normalCase == 0) {
|
||||
successors = new BasicNaturalRelation(defaultImpl, delegateImpl);
|
||||
|
|
|
@ -74,11 +74,16 @@ public final class BasicNaturalRelation implements IBinaryNaturalRelation {
|
|||
* implemented with a SimpleIntVector, and the 2nd and 3rd are implemented
|
||||
* with TwoLevelIntVector
|
||||
* @throws IllegalArgumentException if implementation is null
|
||||
* @throws IllegalArgumentException if implementation.length == 0
|
||||
*/
|
||||
public BasicNaturalRelation(byte[] implementation, byte vectorImpl) {
|
||||
public BasicNaturalRelation(byte[] implementation, byte vectorImpl) throws IllegalArgumentException {
|
||||
|
||||
if (implementation == null) {
|
||||
throw new IllegalArgumentException("implementation is null");
|
||||
}
|
||||
if (implementation.length == 0) {
|
||||
throw new IllegalArgumentException("implementation.length == 0");
|
||||
}
|
||||
smallStore = new IntVector[implementation.length];
|
||||
for (int i = 0; i < implementation.length; i++) {
|
||||
switch (implementation[i]) {
|
||||
|
|
|
@ -220,7 +220,7 @@ public class BimodalMutableIntSet implements MutableIntSet {
|
|||
return impl.max();
|
||||
}
|
||||
|
||||
public static BimodalMutableIntSet makeCopy(IntSet B) throws IllegalArgumentException {
|
||||
public static BimodalMutableIntSet makeCopy(IntSet B) throws UnimplementedError, IllegalArgumentException {
|
||||
if (B == null) {
|
||||
throw new IllegalArgumentException("B == null");
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.util.intset;
|
||||
|
||||
import com.ibm.wala.util.debug.UnimplementedError;
|
||||
|
||||
/**
|
||||
*
|
||||
* An object that creates some bimodal mutable int sets.
|
||||
|
@ -41,7 +43,7 @@ public class BimodalMutableIntSetFactory implements MutableIntSetFactory {
|
|||
/*
|
||||
* @see com.ibm.wala.util.intset.MutableIntSetFactory#make(com.ibm.wala.util.intset.IntSet)
|
||||
*/
|
||||
public MutableIntSet makeCopy(IntSet x) throws IllegalArgumentException {
|
||||
public MutableIntSet makeCopy(IntSet x) throws UnimplementedError, IllegalArgumentException {
|
||||
if (x == null) {
|
||||
throw new IllegalArgumentException("x == null");
|
||||
}
|
||||
|
|
|
@ -37,10 +37,12 @@ public final class MutableSparseLongSet extends SparseLongSet implements Mutable
|
|||
*/
|
||||
private final static int INITIAL_NONEMPTY_SIZE = 2;
|
||||
|
||||
/**
|
||||
* @param set
|
||||
*/
|
||||
public MutableSparseLongSet(LongSet set) {
|
||||
|
||||
public static MutableSparseLongSet make(LongSet set) {
|
||||
return new MutableSparseLongSet(set);
|
||||
}
|
||||
|
||||
private MutableSparseLongSet(LongSet set) {
|
||||
super();
|
||||
copySet(set);
|
||||
}
|
||||
|
|
|
@ -356,7 +356,7 @@ public class SparseLongSet implements LongSet {
|
|||
throw new IllegalArgumentException("that == null");
|
||||
}
|
||||
if (that instanceof SparseLongSet) {
|
||||
MutableSparseLongSet temp = new MutableSparseLongSet(this);
|
||||
MutableSparseLongSet temp = MutableSparseLongSet.make(this);
|
||||
temp.intersectWith((SparseLongSet) that);
|
||||
return temp;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue