patch 1850117, fix some unguarded assertions
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2176 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
8b4cb4cb66
commit
ebedfde191
|
@ -97,3 +97,5 @@ junit
|
|||
backedge
|
||||
lhs
|
||||
bytecode
|
||||
alan
|
||||
donovan
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
import com.ibm.wala.util.debug.UnimplementedError;
|
||||
|
||||
/**
|
||||
* Implementation of IClass for array classes.
|
||||
* Implementation of {@link IClass} for array classes.
|
||||
*
|
||||
* @author Alan Donovan
|
||||
* @author sfink
|
||||
|
@ -35,7 +35,7 @@ import com.ibm.wala.util.debug.UnimplementedError;
|
|||
public class ArrayClass implements IClass, Constants {
|
||||
|
||||
private final IClassHierarchy cha;
|
||||
|
||||
|
||||
/**
|
||||
* Package-visible constructor; only for use by ArrayClassLoader class.
|
||||
* 'loader' must be the Primordial IClassLoader.
|
||||
|
@ -54,7 +54,9 @@ public class ArrayClass implements IClass, Constants {
|
|||
Assertions.UNREACHABLE("caller should not attempt to create an array with type " + type);
|
||||
}
|
||||
} else {
|
||||
Assertions._assert(loader.getReference().equals(ClassLoaderReference.Primordial));
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(loader.getReference().equals(ClassLoaderReference.Primordial));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +111,9 @@ public class ArrayClass implements IClass, Constants {
|
|||
try {
|
||||
IClass elt = getElementClass();
|
||||
|
||||
Assertions._assert(getReference().getArrayElementType().isPrimitiveType() || elt != null);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(getReference().getArrayElementType().isPrimitiveType() || elt != null);
|
||||
}
|
||||
|
||||
// super is Ljava/lang/Object in two cases:
|
||||
// 1) [Ljava/lang/Object
|
||||
|
@ -284,8 +288,8 @@ public class ArrayClass implements IClass, Constants {
|
|||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* @see com.ibm.wala.classLoader.IClass#getAllStaticFields()
|
||||
*/
|
||||
public Collection<IField> getAllStaticFields() throws UnimplementedError, ClassHierarchyException {
|
||||
|
@ -293,20 +297,20 @@ public class ArrayClass implements IClass, Constants {
|
|||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
|
||||
*/
|
||||
public Collection<IMethod> getAllMethods() throws UnimplementedError, ClassHierarchyException {
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* @see com.ibm.wala.classLoader.IClass#getAllFields()
|
||||
*/
|
||||
public Collection<IField> getAllFields() throws UnimplementedError, ClassHierarchyException {
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
}
|
||||
|
||||
public IClassHierarchy getClassHierarchy() {
|
||||
|
|
|
@ -157,8 +157,8 @@ public class ClassHierarchy implements IClassHierarchy {
|
|||
this(scope, factory, scope.getLanguages(), progressMonitor);
|
||||
}
|
||||
|
||||
private ClassHierarchy(AnalysisScope scope, ClassLoaderFactory factory, Collection<Language> languages, IProgressMonitor progressMonitor)
|
||||
throws ClassHierarchyException, IllegalArgumentException {
|
||||
private ClassHierarchy(AnalysisScope scope, ClassLoaderFactory factory, Collection<Language> languages,
|
||||
IProgressMonitor progressMonitor) throws ClassHierarchyException, IllegalArgumentException {
|
||||
// now is a good time to clear the warnings globally.
|
||||
// TODO: think of a better way to guard against warning leaks.
|
||||
Warnings.clear();
|
||||
|
@ -171,18 +171,18 @@ public class ClassHierarchy implements IClassHierarchy {
|
|||
}
|
||||
this.scope = scope;
|
||||
this.factory = factory;
|
||||
Set<Atom> langNames= new HashSet<Atom>();
|
||||
for(Language lang: languages) {
|
||||
Set<Atom> langNames = new HashSet<Atom>();
|
||||
for (Language lang : languages) {
|
||||
this.languages.add(lang);
|
||||
this.languages.addAll(lang.getDerivedLanguages());
|
||||
langNames.add(lang.getName());
|
||||
}
|
||||
for(Language lang: this.languages) {
|
||||
for (Language lang : this.languages) {
|
||||
if (lang.getRootType() != null) {
|
||||
if (this.rootTypeRef != null) {
|
||||
throw new IllegalArgumentException("AnalysisScope must have only 1 root type");
|
||||
} else {
|
||||
this.rootTypeRef= lang.getRootType();
|
||||
this.rootTypeRef = lang.getRootType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -290,7 +290,9 @@ public class ClassHierarchy implements IClassHierarchy {
|
|||
|
||||
if (klass.getReference().equals(this.rootTypeRef)) {
|
||||
// there is only one root
|
||||
Assertions._assert(root == null);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(root == null);
|
||||
}
|
||||
root = node;
|
||||
}
|
||||
|
||||
|
@ -956,8 +958,8 @@ public class ClassHierarchy implements IClassHierarchy {
|
|||
/**
|
||||
* Does c implement i?
|
||||
*
|
||||
* @return true iff i is an interface and c is a class that implements i, r
|
||||
* c is an interface that extends i.
|
||||
* @return true iff i is an interface and c is a class that implements i, r c
|
||||
* is an interface that extends i.
|
||||
*
|
||||
*/
|
||||
public boolean implementsInterface(IClass c, IClass i) {
|
||||
|
|
|
@ -15,11 +15,12 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
|
||||
/**
|
||||
* @author sfink
|
||||
*
|
||||
*
|
||||
*/
|
||||
public abstract class SSAAbstractUnaryInstruction extends SSAInstruction {
|
||||
|
||||
protected final int result;
|
||||
|
||||
protected final int val;
|
||||
|
||||
protected SSAAbstractUnaryInstruction(int result, int val) {
|
||||
|
@ -43,7 +44,9 @@ public abstract class SSAAbstractUnaryInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -75,7 +78,7 @@ public abstract class SSAAbstractUnaryInstruction extends SSAInstruction {
|
|||
return val * 1663 ^ result * 4027;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* @see com.ibm.wala.ssa.Instruction#isFallThrough()
|
||||
*/
|
||||
@Override
|
||||
|
|
|
@ -71,7 +71,9 @@ public class SSAArrayLengthInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,9 @@ public class SSAArrayLoadInstruction extends SSAArrayReferenceInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SSABinaryOpInstruction extends SSAInstruction {
|
|||
private final int val2;
|
||||
|
||||
private final BinaryOpInstruction.IOperator operator;
|
||||
|
||||
|
||||
/**
|
||||
* Might this instruction represent integer arithmetic?
|
||||
*/
|
||||
|
@ -44,7 +44,9 @@ public class SSABinaryOpInstruction extends SSAInstruction {
|
|||
this.val2 = val2;
|
||||
this.operator = operator;
|
||||
this.mayBeInteger = mayBeInteger;
|
||||
Assertions._assert(val1 != -1 && val2 != -1);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(val1 != -1 && val2 != -1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -71,7 +73,7 @@ public class SSABinaryOpInstruction extends SSAInstruction {
|
|||
}
|
||||
|
||||
/**
|
||||
* Ugh. clean up shrike operator stuff.
|
||||
* Ugh. clean up shrike operator stuff.
|
||||
*/
|
||||
public BinaryOpInstruction.IOperator getOperator() {
|
||||
return operator;
|
||||
|
@ -89,7 +91,9 @@ public class SSABinaryOpInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
|
||||
/**
|
||||
* @author sfink
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SSACheckCastInstruction extends SSAInstruction {
|
||||
|
||||
|
@ -48,12 +48,14 @@ public class SSACheckCastInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public String toString(SymbolTable symbolTable, ValueDecorator d) {
|
||||
return getValueString(symbolTable, d, result) + " = checkcast " + declaredResultType.getName() + " " + getValueString(symbolTable, d, val);
|
||||
return getValueString(symbolTable, d, result) + " = checkcast " + declaredResultType.getName() + " "
|
||||
+ getValueString(symbolTable, d, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.ibm.wala.ssa.SSAInstruction#visit(IVisitor)
|
||||
* @throws IllegalArgumentException if v is null
|
||||
* @throws IllegalArgumentException
|
||||
* if v is null
|
||||
*/
|
||||
@Override
|
||||
public void visit(IVisitor v) {
|
||||
|
@ -78,7 +80,9 @@ public class SSACheckCastInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,8 @@ public class SSAComparisonInstruction extends SSAInstruction {
|
|||
private final short opcode;
|
||||
|
||||
/**
|
||||
* @param opcode opcode from list in {@link Constants}
|
||||
* @param opcode
|
||||
* opcode from list in {@link Constants}
|
||||
*/
|
||||
SSAComparisonInstruction(short opcode, int result, int val1, int val2) {
|
||||
super();
|
||||
|
@ -45,7 +46,7 @@ public class SSAComparisonInstruction extends SSAInstruction {
|
|||
@Override
|
||||
public SSAInstruction copyForSSA(int[] defs, int[] uses) throws IllegalArgumentException {
|
||||
// TODO: Julian ... is this correct?
|
||||
if (uses!= null && uses.length != 2) {
|
||||
if (uses != null && uses.length != 2) {
|
||||
throw new IllegalArgumentException("expected 2 uses, got " + uses.length);
|
||||
}
|
||||
return new SSAComparisonInstruction(opcode, defs == null || defs.length == 0 ? result : defs[0], uses == null ? val1 : uses[0],
|
||||
|
@ -81,7 +82,9 @@ public class SSAComparisonInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@ public class SSAConversionInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public String toString(SymbolTable symbolTable, ValueDecorator d) {
|
||||
return getValueString(symbolTable, d, result) + " = conversion(" + toType.getName() + ") " + getValueString(symbolTable, d, val);
|
||||
return getValueString(symbolTable, d, result) + " = conversion(" + toType.getName() + ") "
|
||||
+ getValueString(symbolTable, d, val);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +75,9 @@ public class SSAConversionInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,8 @@ public class SSAGetCaughtExceptionInstruction extends SSAInstruction {
|
|||
|
||||
/**
|
||||
* @see com.ibm.wala.ssa.SSAInstruction#visit(IVisitor)
|
||||
* @throws IllegalArgumentException if v is null
|
||||
* @throws IllegalArgumentException
|
||||
* if v is null
|
||||
*/
|
||||
@Override
|
||||
public void visit(IVisitor v) {
|
||||
|
@ -80,7 +81,9 @@ public class SSAGetCaughtExceptionInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return exceptionValueNumber;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
package com.ibm.wala.ssa;
|
||||
|
||||
|
||||
import com.ibm.wala.types.FieldReference;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
|
||||
|
@ -74,7 +73,9 @@ public class SSAGetInstruction extends SSAFieldAccessInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,9 @@ public class SSAInstanceofInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
|
||||
public class SSALoadClassInstruction extends SSAInstruction {
|
||||
|
||||
private static final Collection<TypeReference> loadClassExceptions = Collections.singleton(TypeReference.JavaLangClassNotFoundException);
|
||||
private static final Collection<TypeReference> loadClassExceptions = Collections
|
||||
.singleton(TypeReference.JavaLangClassNotFoundException);
|
||||
|
||||
private final int lval;
|
||||
|
||||
|
@ -72,7 +73,9 @@ public class SSALoadClassInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return lval;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,8 @@ public class SSANewInstruction extends SSAInstruction {
|
|||
throw new IllegalArgumentException("site cannot be null");
|
||||
}
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(!site.getDeclaredType().isArrayType() || site.getDeclaredType().getClassLoader().getLanguage() != ClassLoaderReference.Java);
|
||||
Assertions._assert(!site.getDeclaredType().isArrayType()
|
||||
|| site.getDeclaredType().getClassLoader().getLanguage() != ClassLoaderReference.Java);
|
||||
}
|
||||
this.result = result;
|
||||
this.site = site;
|
||||
|
@ -51,8 +52,11 @@ public class SSANewInstruction extends SSAInstruction {
|
|||
|
||||
/**
|
||||
* Create a new instruction to allocate an array.
|
||||
* @throws IllegalArgumentException if site is null
|
||||
* @throws IllegalArgumentException if params is null
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if site is null
|
||||
* @throws IllegalArgumentException
|
||||
* if params is null
|
||||
*/
|
||||
public SSANewInstruction(int result, NewSiteReference site, int[] params) {
|
||||
|
||||
|
@ -64,7 +68,8 @@ public class SSANewInstruction extends SSAInstruction {
|
|||
throw new IllegalArgumentException("site is null");
|
||||
}
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(site.getDeclaredType().isArrayType() || site.getDeclaredType().getClassLoader().getLanguage() != ClassLoaderReference.Java);
|
||||
Assertions._assert(site.getDeclaredType().isArrayType()
|
||||
|| site.getDeclaredType().getClassLoader().getLanguage() != ClassLoaderReference.Java);
|
||||
}
|
||||
this.result = result;
|
||||
this.site = site;
|
||||
|
@ -77,20 +82,20 @@ public class SSANewInstruction extends SSAInstruction {
|
|||
if (params == null) {
|
||||
return new SSANewInstruction(defs == null ? result : defs[0], site);
|
||||
} else {
|
||||
return new SSANewInstruction(defs == null ? result : defs[0],
|
||||
site,
|
||||
uses == null ? params: uses);
|
||||
return new SSANewInstruction(defs == null ? result : defs[0], site, uses == null ? params : uses);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(SymbolTable symbolTable, ValueDecorator d) {
|
||||
return getValueString(symbolTable, d, result) + " = new " + site.getDeclaredType() + "@" + site.getProgramCounter() + (params==null?"":" dims: "+params.length);
|
||||
return getValueString(symbolTable, d, result) + " = new " + site.getDeclaredType() + "@" + site.getProgramCounter()
|
||||
+ (params == null ? "" : " dims: " + params.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see com.ibm.wala.ssa.SSAInstruction#visit(IVisitor)
|
||||
* @throws IllegalArgumentException if v is null
|
||||
* @throws IllegalArgumentException
|
||||
* if v is null
|
||||
*/
|
||||
@Override
|
||||
public void visit(IVisitor v) {
|
||||
|
@ -115,7 +120,9 @@ public class SSANewInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ import com.ibm.wala.util.debug.Assertions;
|
|||
|
||||
/**
|
||||
* @author sfink
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SSAPhiInstruction extends SSAInstruction {
|
||||
private final int result;
|
||||
|
@ -66,7 +66,8 @@ public class SSAPhiInstruction extends SSAInstruction {
|
|||
|
||||
/**
|
||||
* @see com.ibm.wala.ssa.SSAInstruction#visit(IVisitor)
|
||||
* @throws IllegalArgumentException if v is null
|
||||
* @throws IllegalArgumentException
|
||||
* if v is null
|
||||
*/
|
||||
@Override
|
||||
public void visit(IVisitor v) {
|
||||
|
@ -91,7 +92,9 @@ public class SSAPhiInstruction extends SSAInstruction {
|
|||
|
||||
@Override
|
||||
public int getDef(int i) {
|
||||
Assertions._assert(i == 0);
|
||||
if (Assertions.verifyAssertions) {
|
||||
Assertions._assert(i == 0);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue