Merge branch 'master' into modernization-java-8-lambdas-and-method-references

This commit is contained in:
Ben Liblit 2017-11-29 10:51:33 -06:00
commit 9c83e87cc1
219 changed files with 1195 additions and 1531 deletions

View File

@ -52,8 +52,8 @@ public class SourceDirCallGraph {
AnalysisScope scope = new JavaSourceAnalysisScope();
// add standard libraries to scope
String[] stdlibs = WalaProperties.getJ2SEJarFiles();
for (int i = 0; i < stdlibs.length; i++) {
scope.addToScope(ClassLoaderReference.Primordial, new JarFile(stdlibs[i]));
for (String stdlib : stdlibs) {
scope.addToScope(ClassLoaderReference.Primordial, new JarFile(stdlib));
}
// add the source directory
scope.addToScope(JavaSourceAnalysisScope.SOURCE, new SourceDirectoryTreeModule(new File(sourceDir)));

View File

@ -1410,8 +1410,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
argNodes[idx++] = fFactory.makeConstant(callSiteRef);
// rest of args
for (Iterator<?> iter = arguments.iterator(); iter.hasNext();) {
Object arg = iter.next();
for (Object arg : arguments) {
argNodes[idx++] = (arg instanceof CAstNode) ? ((CAstNode) arg) : visitNode((Expression) arg, context);
}
callNode = makeNode(context, fFactory, nn, CAstNode.CALL, argNodes);

View File

@ -42,7 +42,6 @@ import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -136,9 +135,7 @@ public class ECJSourceModuleTranslator implements SourceModuleTranslator {
while (cl != null) {
List<Module> modules = scope.getModules(cl);
for (Iterator<Module> iter = modules.iterator(); iter.hasNext();) {
Module m = iter.next();
for (Module m : modules) {
if (m instanceof JarFileModule) {
JarFileModule jarFileModule = (JarFileModule) m;

View File

@ -132,9 +132,8 @@ public class AstJavaTypeInference extends AstTypeInference {
public byte evaluate(TypeVariable lhs, TypeVariable[] rhs) {
TypeAbstraction meet = null;
for (int i = 0; i < rhs.length; i++) {
if (rhs[i] != null) {
TypeVariable r = rhs[i];
for (TypeVariable r : rhs) {
if (r != null) {
TypeAbstraction ta = r.getType();
if (ta instanceof PointType) {
if (ta.getType().equals(getStringClass())) {

View File

@ -172,8 +172,8 @@ public class AstJavaSSAPropagationCallGraphBuilder extends AstSSAPropagationCall
InstanceKey[] objs = getInvariantContents(objVal);
for (int i = 0; i < objs.length; i++) {
PointerKey enclosing = new EnclosingObjectReferenceKey(objs[i], cls);
for (InstanceKey obj : objs) {
PointerKey enclosing = new EnclosingObjectReferenceKey(obj, cls);
system.newConstraint(lvalKey, assignOperator, enclosing);
}

View File

@ -53,8 +53,8 @@ public class AstJavaZeroXCFABuilder extends AstJavaCFABuilder {
AnalysisScope scope, String[] xmlFiles, byte instancePolicy) {
com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
for (int i = 0; i < xmlFiles.length; i++) {
com.ibm.wala.ipa.callgraph.impl.Util.addBypassLogic(options, scope, cl, xmlFiles[i], cha);
for (String xmlFile : xmlFiles) {
com.ibm.wala.ipa.callgraph.impl.Util.addBypassLogic(options, scope, cl, xmlFile, cha);
}
return new AstJavaZeroXCFABuilder(cha, options, cache, null, null, instancePolicy);

View File

@ -44,8 +44,8 @@ public class JavaScopeMappingInstanceKeys extends ScopeMappingInstanceKeys {
if ((m instanceof AstMethod) && !m.isStatic()) {
AstMethod M = (AstMethod) m;
LexicalParent[] parents = M.getParents();
for (int i = 0; i < parents.length; i++) {
result.add(parents[i]);
for (LexicalParent parent : parents) {
result.add(parent);
}
}
}

View File

@ -12,7 +12,6 @@ package com.ibm.wala.cast.java.ipa.slicer;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import java.util.function.Predicate;
@ -59,8 +58,7 @@ public class AstJavaSlicer extends Slicer {
public static Set<Statement> gatherStatements(CallGraph CG, Collection<CGNode> partialRoots, Predicate<SSAInstruction> filter) {
Set<Statement> result = new HashSet<>();
for (Iterator<CGNode> ns = DFS.getReachableNodes(CG, partialRoots).iterator(); ns.hasNext();) {
CGNode n = ns.next();
for (CGNode n : DFS.getReachableNodes(CG, partialRoots)) {
IR nir = n.getIR();
if (nir != null) {
SSAInstruction insts[] = nir.getInstructions();

View File

@ -17,7 +17,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -123,8 +122,7 @@ public abstract class JavaSourceLoaderImpl extends ClassLoaderImpl {
@Override
public IClass getSuperclass() {
boolean excludedSupertype=false;
for (Iterator<TypeName> iter = superTypeNames.iterator(); iter.hasNext();) {
TypeName name = iter.next();
for (TypeName name : superTypeNames) {
IClass domoType = lookupClass(name);
if (domoType != null && !domoType.isInterface()) {
return domoType;

View File

@ -158,8 +158,7 @@ public abstract class FieldBasedCallGraphBuilder {
// set up call edges from fake root to all script nodes
AbstractRootMethod fakeRootMethod = (AbstractRootMethod)cg.getFakeRootNode().getMethod();
CGNode fakeRootNode = cg.findOrCreateNode(fakeRootMethod, Everywhere.EVERYWHERE);
for(Iterator<? extends Entrypoint> iter = eps.iterator(); iter.hasNext();) {
Entrypoint ep = iter.next();
for (Entrypoint ep : eps) {
CGNode nd = cg.findOrCreateNode(ep.getMethod(), Everywhere.EVERYWHERE);
SSAAbstractInvokeInstruction invk = ep.addCall(fakeRootMethod);
fakeRootNode.addTarget(invk.getCallSite(), nd);

View File

@ -13,7 +13,6 @@ package com.ibm.wala.cast.js.html.jericho;
import java.io.IOException;
import java.io.Reader;
import java.net.URL;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -110,8 +109,7 @@ public class JerichoHtmlParser implements IHtmlParser{
src = new Source(reader);
src.setLogger(Config.LoggerProvider.getLogger(fileName));
List<Element> childElements = src.getChildElements();
for (Iterator<Element> nodeIterator = childElements.iterator(); nodeIterator.hasNext();) {
Element e = nodeIterator.next();
for (Element e : childElements) {
parser.parse(e);
}
if (! warnings.isEmpty()) {
@ -139,8 +137,7 @@ public class JerichoHtmlParser implements IHtmlParser{
handler.handleStartTag(tag);
handler.handleText(tag.getElementPosition(), tag.getBodyText().snd);
List<Element> childElements = root.getChildElements();
for (Iterator<Element> nodeIterator = childElements.iterator(); nodeIterator.hasNext();) {
Element child = nodeIterator.next();
for (Element child : childElements) {
parse(child);
}
handler.handleEndTag(tag);

View File

@ -528,8 +528,8 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
if (contentsAreInvariant(symbolTable, du, rval)) {
system.recordImplicitPointsToSet(rvalKey);
InstanceKey[] ik = getInvariantContents(rval);
for (int i = 0; i < ik.length; i++) {
system.newConstraint(p, ik[i]);
for (InstanceKey element : ik) {
system.newConstraint(p, element);
}
} else {
system.newConstraint(p, assignOperator, rvalKey);
@ -665,8 +665,8 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
if (contentsAreInvariant(symbolTable, du, receiverVn)) {
system.recordImplicitPointsToSet(receiverKey);
InstanceKey[] ik = getInvariantContents(receiverVn);
for (int i = 0; i < ik.length; i++) {
handleJavascriptDispatch(instruction, ik[i]);
for (InstanceKey element : ik) {
handleJavascriptDispatch(instruction, element);
}
} else {
class ReceiverForDispatchOp extends UnaryOperator<PointsToSetVariable> {
@ -799,17 +799,17 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
InstanceKey[] iks2 = getInstancesArray(arg2);
if ((instruction.getOperator() == BinaryOpInstruction.Operator.ADD) && (getOptions().getTraceStringConstants())) {
for (int i = 0; i < iks1.length; i++) {
if (isStringConstant(iks1[i])) {
for (int j = 0; j < iks2.length; j++) {
if (isStringConstant(iks2[j])) {
for (InstanceKey element : iks1) {
if (isStringConstant(element)) {
for (InstanceKey element2 : iks2) {
if (isStringConstant(element2)) {
try {
MonitorUtil.throwExceptionIfCanceled(builder.monitor);
} catch (CancelException e) {
throw new CancelRuntimeException(e);
}
String v1 = (String) ((ConstantKey<?>) iks1[i]).getValue();
String v2 = (String) ((ConstantKey<?>) iks2[j]).getValue();
String v1 = (String) ((ConstantKey<?>) element).getValue();
String v2 = (String) ((ConstantKey<?>) element2).getValue();
if (v1.indexOf(v2) == -1 && v2.indexOf(v1) == -1) {
InstanceKey lvalKey = getInstanceKeyForConstant(v1 + v2);
if (addKey(lvalKey)) {
@ -831,14 +831,14 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
}
if (doDefault) {
for (int i = 0; i < iks1.length; i++) {
for (int j = 0; j < iks2.length; j++) {
for (InstanceKey element : iks1) {
for (InstanceKey element2 : iks2) {
try {
MonitorUtil.throwExceptionIfCanceled(builder.monitor);
} catch (CancelException e) {
throw new CancelRuntimeException(e);
}
if (handleBinaryOperatorArgs(iks1[i], iks2[j])) {
if (handleBinaryOperatorArgs(element, element2)) {
changed = CHANGED;
}
}
@ -1086,8 +1086,8 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
InstanceKey[] nullkeys = builder.getInvariantContents(sourceST, sourceDU, caller, nullvn, builder);
for (int i = argCount; i < paramCount; i++) {
PointerKey F = builder.getPointerKeyForLocal(target, targetST.getParameter(i));
for (int k = 0; k < nullkeys.length; k++) {
builder.getSystem().newConstraint(F, nullkeys[k]);
for (InstanceKey nullkey : nullkeys) {
builder.getSystem().newConstraint(F, nullkey);
}
}
}

View File

@ -110,8 +110,8 @@ public class JSZeroOrOneXCFABuilder extends JSCFABuilder {
public static JSCFABuilder make(JSAnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, ClassLoader cl,
AnalysisScope scope, String[] xmlFiles, byte instancePolicy, boolean doOneCFA) {
com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
for (int i = 0; i < xmlFiles.length; i++) {
com.ibm.wala.ipa.callgraph.impl.Util.addBypassLogic(options, scope, cl, xmlFiles[i], cha);
for (String xmlFile : xmlFiles) {
com.ibm.wala.ipa.callgraph.impl.Util.addBypassLogic(options, scope, cl, xmlFile, cha);
}
return new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, instancePolicy, doOneCFA);

View File

@ -464,8 +464,8 @@ public class ClosureExtractor extends CAstRewriterExt {
CAstNode[] before = new CAstNode[tler.getStartInner()];
for(i=0;i<tler.getStartInner();++i)
before[i] = copyNodes(start.getChild(i), cfg, context, nodeMap);
for(int x = 0; x < before.length; x++) {
prologue.add(before[x]);
for (CAstNode element : before) {
prologue.add(element);
}
if(i+1 == start.getChildCount()) {
fun_body_stmts.add(addSpuriousExnFlow(start.getChild(i), cfg));
@ -473,8 +473,8 @@ public class ClosureExtractor extends CAstRewriterExt {
CAstNode[] after = new CAstNode[start.getChildCount()-i];
for(int j=0;j+i<start.getChildCount();++j)
after[j] = addSpuriousExnFlow(start.getChild(j+i), cfg);
for(int x = 0; x < after.length; x++) {
fun_body_stmts.add(after[x]);
for (CAstNode element : after) {
fun_body_stmts.add(element);
}
}
for(i=context.getStart()+1;i<context.getEnd();++i)

View File

@ -14,7 +14,6 @@ import java.io.File;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@ -78,8 +77,7 @@ public abstract class TestCAstTranslator extends WalaTestCase {
}
public TranslatorAssertions(Object[][] data) {
for (int dataIndex = 0; dataIndex < data.length; dataIndex++) {
Object[] entry = data[dataIndex];
for (Object[] entry : data) {
String clsName = (String) entry[0];
this.classes.add(clsName);
@ -88,29 +86,29 @@ public abstract class TestCAstTranslator extends WalaTestCase {
String[] instanceFields = (String[]) entry[2];
if (instanceFields != null) {
for (int i = 0; i < instanceFields.length; i++) {
this.instanceFields.add(Pair.make(clsName, instanceFields[i]));
for (String instanceField : instanceFields) {
this.instanceFields.add(Pair.make(clsName, instanceField));
}
}
String[] staticFields = (String[]) entry[3];
if (staticFields != null) {
for (int i = 0; i < staticFields.length; i++) {
this.staticFields.add(Pair.make(clsName, staticFields[i]));
for (String staticField : staticFields) {
this.staticFields.add(Pair.make(clsName, staticField));
}
}
Pair<?, ?>[] instanceMethods = (Pair[]) entry[4];
if (instanceMethods != null) {
for (int i = 0; i < instanceMethods.length; i++) {
this.instanceMethods.put(Pair.make(clsName, (Object) instanceMethods[i].fst), instanceMethods[i].snd);
for (Pair<?, ?> instanceMethod : instanceMethods) {
this.instanceMethods.put(Pair.make(clsName, (Object) instanceMethod.fst), instanceMethod.snd);
}
}
Pair<?, ?>[] staticMethods = (Pair[]) entry[5];
if (staticMethods != null) {
for (int i = 0; i < staticMethods.length; i++) {
this.staticMethods.put(Pair.make(clsName, (Object) staticMethods[i].fst), staticMethods[i].snd);
for (Pair<?, ?> staticMethod : staticMethods) {
this.staticMethods.put(Pair.make(clsName, (Object) staticMethod.fst), staticMethod.snd);
}
}
}
@ -138,19 +136,19 @@ public abstract class TestCAstTranslator extends WalaTestCase {
}
protected void dump(ClassHierarchy cha) {
for (Iterator<?> clss = cha.iterator(); clss.hasNext();) {
IClass cls = (IClass) clss.next();
for (Object name : cha) {
IClass cls = (IClass) name;
System.err.println(("class " + cls));
for (Iterator<?> flds = cls.getDeclaredInstanceFields().iterator(); flds.hasNext();) {
IField fld = (IField) flds.next();
for (Object name2 : cls.getDeclaredInstanceFields()) {
IField fld = (IField) name2;
System.err.println(("instance field " + fld));
}
for (Iterator<?> flds = cls.getDeclaredStaticFields().iterator(); flds.hasNext();) {
IField fld = (IField) flds.next();
for (Object name2 : cls.getDeclaredStaticFields()) {
IField fld = (IField) name2;
System.err.println(("static field " + fld));
}
for (Iterator<?> mths = cls.getDeclaredMethods().iterator(); mths.hasNext();) {
IMethod mth = (IMethod) mths.next();
for (Object name2 : cls.getDeclaredMethods()) {
IMethod mth = (IMethod) name2;
if (mth.isStatic())
System.err.print("static ");
System.err.println(("method " + mth + " with " + mth.getNumberOfParameters() + " parameters"));
@ -171,8 +169,8 @@ public abstract class TestCAstTranslator extends WalaTestCase {
Map<Pair<String, Object>, Object> staticMethods = assertions.getStaticMethods();
int clsCount = 0;
for (Iterator<?> clss = cha.iterator(); clss.hasNext();) {
IClass cls = (IClass) clss.next();
for (Object name : cha) {
IClass cls = (IClass) name;
clsCount++;
Assert.assertTrue("found class " + cls.getName().toString(), classes.contains(cls.getName().toString()));
@ -183,20 +181,20 @@ public abstract class TestCAstTranslator extends WalaTestCase {
.get(cls.getName().toString()).equals(cls.getSuperclass().getName().toString()));
}
for (Iterator<?> flds = cls.getDeclaredInstanceFields().iterator(); flds.hasNext();) {
IField fld = (IField) flds.next();
for (Object name2 : cls.getDeclaredInstanceFields()) {
IField fld = (IField) name2;
Assert.assertTrue(cls.getName() + " has field " + fld.getName(), instanceFields.contains(Pair.make(
cls.getName().toString(), fld.getName().toString())));
}
for (Iterator<?> flds = cls.getDeclaredStaticFields().iterator(); flds.hasNext();) {
IField fld = (IField) flds.next();
for (Object name2 : cls.getDeclaredStaticFields()) {
IField fld = (IField) name2;
Assert.assertTrue(cls.getName() + " has static field " + fld.getName(), staticFields.contains(Pair.make(cls.getName()
.toString(), fld.getName().toString())));
}
for (Iterator<?> mths = cls.getDeclaredMethods().iterator(); mths.hasNext();) {
IMethod mth = (IMethod) mths.next();
for (Object name2 : cls.getDeclaredMethods()) {
IMethod mth = (IMethod) name2;
Integer np = new Integer(mth.getNumberOfParameters());
Pair<String, String> key = Pair.make(cls.getName().toString(), mth.getName().toString());

View File

@ -100,26 +100,26 @@ public abstract class TestCallGraphShape extends WalaTestCase {
}
protected void verifyNameAssertions(CallGraph CG, Object[][] assertionData) {
for (int i = 0; i < assertionData.length; i++) {
Iterator<CGNode> NS = getNodes(CG, (String) assertionData[i][0]).iterator();
for (Object[] element : assertionData) {
Iterator<CGNode> NS = getNodes(CG, (String) element[0]).iterator();
while (NS.hasNext()) {
CGNode N = NS.next();
IR ir = N.getIR();
Name[] names = (Name[]) assertionData[i][1];
for (int j = 0; j < names.length; j++) {
Name[] names = (Name[]) element[1];
for (Name name : names) {
System.err.println("looking for " + names[j].name + ", " + names[j].vn + " in " + N);
System.err.println("looking for " + name.name + ", " + name.vn + " in " + N);
String[] localNames = ir.getLocalNames(names[j].instructionIndex, names[j].vn);
String[] localNames = ir.getLocalNames(name.instructionIndex, name.vn);
boolean found = false;
for (int k = 0; k < localNames.length; k++) {
if (localNames[k].equals(names[j].name)) {
for (String localName : localNames) {
if (localName.equals(name.name)) {
found = true;
}
}
Assert.assertTrue("no name " + names[j].name + " for " + N + "\n" + ir, found);
Assert.assertTrue("no name " + name.name + " for " + N + "\n" + ir, found);
}
}
}
@ -159,8 +159,8 @@ public abstract class TestCallGraphShape extends WalaTestCase {
while (dsts.hasNext()) {
CGNode dst = dsts.next();
for (Iterator<CGNode> tos = CG.getPossibleTargets(src, sr).iterator(); tos.hasNext();) {
if (tos.next().equals(dst)) {
for (CGNode cgNode : CG.getPossibleTargets(src, sr)) {
if (cgNode.equals(dst)) {
if (checkAbsence) {
System.err.println(("found unexpected " + src + " --> " + dst + " at " + sr));
Assert.assertTrue("found edge " + assertionData[i][0] + " ---> " + targetName, false);

View File

@ -90,8 +90,8 @@ public class AstCallGraph extends ExplicitCallGraph {
boolean done = false;
while (!done) {
try {
for (Iterator<Function<Object, Object>> x = callbacks.iterator(); x.hasNext();) {
x.next().apply(null);
for (Function<Object, Object> function : callbacks) {
function.apply(null);
}
} catch (ConcurrentModificationException e) {
done = false;

View File

@ -383,9 +383,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(lsymtab, ldu, lvn)) {
InstanceKey[] ik = getInvariantContents(lsymtab, ldu, lnode, lvn);
system.recordImplicitPointsToSet(lexicalKey);
for (int i = 0; i < ik.length; i++) {
system.findOrCreateIndexForInstanceKey(ik[i]);
system.newConstraint(lval, ik[i]);
for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(element);
system.newConstraint(lval, element);
}
return;
@ -406,9 +406,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(symbolTable, du, vn)) {
InstanceKey[] ik = getInvariantContents(vn);
system.recordImplicitPointsToSet(rval);
for (int i = 0; i < ik.length; i++) {
system.findOrCreateIndexForInstanceKey(ik[i]);
system.newConstraint(lexicalKey, ik[i]);
for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(element);
system.newConstraint(lexicalKey, element);
}
} else {
system.newConstraint(lexicalKey, assignOperator, rval);
@ -523,8 +523,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(symbolTable, du, rval)) {
InstanceKey objects[] = getInvariantContents(rval);
for (int i = 0; i < objects.length; i++) {
PointerKey catalog = getPointerKeyForObjectCatalog(objects[i]);
for (InstanceKey object : objects) {
PointerKey catalog = getPointerKeyForObjectCatalog(object);
system.newConstraint(lk, assignOperator, catalog);
}
}
@ -612,10 +612,10 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
* .
*/
private void doLexicalPointerKeys() {
for (int i = 0; i < accesses.length; i++) {
final String name = accesses[i].variableName;
final String definer = accesses[i].variableDefiner;
final int vn = accesses[i].valueNumber;
for (Access accesse : accesses) {
final String name = accesse.variableName;
final String definer = accesse.variableDefiner;
final int vn = accesse.valueNumber;
if (AstTranslator.DEBUG_LEXICAL)
System.err.println(("looking up lexical parent " + definer));
@ -700,9 +700,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(symtab, du, 1)) {
system.recordImplicitPointsToSet(F);
final InstanceKey[] functionKeys = getInvariantContents(symtab, du, opNode, 1);
for (int f = 0; f < functionKeys.length; f++) {
system.findOrCreateIndexForInstanceKey(functionKeys[f]);
ScopeMappingInstanceKey K = (ScopeMappingInstanceKey) functionKeys[f];
for (InstanceKey functionKey : functionKeys) {
system.findOrCreateIndexForInstanceKey(functionKey);
ScopeMappingInstanceKey K = (ScopeMappingInstanceKey) functionKey;
Iterator<CGNode> x = K.getFunargNodes(definer);
while (x.hasNext()) {
result.add(x.next());
@ -754,9 +754,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(st, du, vn)) {
system.recordImplicitPointsToSet(rhs);
final InstanceKey[] objs = getInvariantContents(st, du, definingNode, vn);
for (int f = 0; f < objs.length; f++) {
system.findOrCreateIndexForInstanceKey(objs[f]);
system.newConstraint(lhs, objs[f]);
for (InstanceKey obj : objs) {
system.findOrCreateIndexForInstanceKey(obj);
system.newConstraint(lhs, obj);
}
} else {
system.newConstraint(lhs, assignOperator, rhs);
@ -851,8 +851,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(symtab, du, objVn)) {
System.err.print(" constant obj:");
InstanceKey[] x = getInvariantContents(symtab, du, opNode, objVn);
for (int i = 0; i < x.length; i++) {
System.err.print((x[i].toString() + " "));
for (InstanceKey element : x) {
System.err.print((element.toString() + " "));
}
} else {
System.err.print((" obj:" + system.findOrCreatePointsToSet(objKey)));
@ -861,8 +861,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(symtab, du, fieldsVn)) {
System.err.print(" constant prop:");
InstanceKey[] x = getInvariantContents(symtab, du, opNode, fieldsVn);
for (int i = 0; i < x.length; i++) {
System.err.print((x[i].toString() + " "));
for (InstanceKey element : x) {
System.err.print((element.toString() + " "));
}
} else {
System.err.print((" props:" + system.findOrCreatePointsToSet(fieldKey)));
@ -874,14 +874,14 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
// make sure instance keys get mapped for PointerAnalysisImpl
if (contentsAreInvariant(symtab, du, objVn)) {
InstanceKey[] x = getInvariantContents(symtab, du, opNode, objVn);
for (int i = 0; i < x.length; i++) {
system.findOrCreateIndexForInstanceKey(x[i]);
for (InstanceKey element : x) {
system.findOrCreateIndexForInstanceKey(element);
}
}
if (contentsAreInvariant(symtab, du, fieldsVn)) {
InstanceKey[] x = getInvariantContents(symtab, du, opNode, fieldsVn);
for (int i = 0; i < x.length; i++) {
system.findOrCreateIndexForInstanceKey(x[i]);
for (InstanceKey element : x) {
system.findOrCreateIndexForInstanceKey(element);
}
}
@ -1004,23 +1004,23 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
objects.getValue().foreach(optr -> {
InstanceKey object = system.getInstanceKey(optr);
PointerKey objCatalog = getPointerKeyForObjectCatalog(object);
for (int f = 0; f < fieldsKeys.length; f++) {
for (InstanceKey fieldsKey : fieldsKeys) {
if (isLoadOperation) {
for (Iterator<PointerKey> keys1 = getPointerKeysForReflectedFieldRead(object, fieldsKeys[f]); keys1.hasNext();) {
AbstractFieldPointerKey key1 = (AbstractFieldPointerKey) keys1.next();
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldRead(object, fieldsKey); keys.hasNext();) {
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
if (DEBUG_PROPERTIES)
action.dump(key1, true, false);
action.action(key1);
action.dump(key, true, false);
action.action(key);
}
} else {
if (objCatalog != null) {
system.newConstraint(objCatalog, fieldsKeys[f]);
system.newConstraint(objCatalog, fieldsKey);
}
for (Iterator<PointerKey> keys2 = getPointerKeysForReflectedFieldWrite(object, fieldsKeys[f]); keys2.hasNext();) {
AbstractFieldPointerKey key2 = (AbstractFieldPointerKey) keys2.next();
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldWrite(object, fieldsKey); keys.hasNext();) {
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
if (DEBUG_PROPERTIES)
action.dump(key2, true, false);
action.action(key2);
action.dump(key, true, false);
action.action(key);
}
}
}
@ -1049,8 +1049,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
protected void newFieldOperationOnlyObjectConstant(final boolean isLoadOperation, final ReflectedFieldAction action,
final PointerKey fieldKey, final InstanceKey[] objKeys) {
if (!isLoadOperation) {
for (int o = 0; o < objKeys.length; o++) {
PointerKey objCatalog = getPointerKeyForObjectCatalog(objKeys[o]);
for (InstanceKey objKey : objKeys) {
PointerKey objCatalog = getPointerKeyForObjectCatalog(objKey);
if (objCatalog != null) {
system.newConstraint(objCatalog, assignOperator, fieldKey);
}
@ -1064,9 +1064,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (fields.getValue() != null) {
fields.getValue().foreach(fptr -> {
InstanceKey field = system.getInstanceKey(fptr);
for (int o = 0; o < objKeys.length; o++) {
for (Iterator<PointerKey> keys = isLoadOperation ? getPointerKeysForReflectedFieldRead(objKeys[o], field)
: getPointerKeysForReflectedFieldWrite(objKeys[o], field); keys.hasNext();) {
for (InstanceKey objKey : objKeys) {
for (Iterator<PointerKey> keys = isLoadOperation ? getPointerKeysForReflectedFieldRead(objKey, field)
: getPointerKeysForReflectedFieldWrite(objKey, field); keys.hasNext();) {
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
if (DEBUG_PROPERTIES)
action.dump(key, false, true);
@ -1097,11 +1097,11 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
protected void newFieldOperationObjectAndFieldConstant(final boolean isLoadOperation, final ReflectedFieldAction action,
final InstanceKey[] objKeys, InstanceKey[] fieldsKeys) {
for (int o = 0; o < objKeys.length; o++) {
PointerKey objCatalog = getPointerKeyForObjectCatalog(objKeys[o]);
for (int f = 0; f < fieldsKeys.length; f++) {
for (InstanceKey objKey : objKeys) {
PointerKey objCatalog = getPointerKeyForObjectCatalog(objKey);
for (InstanceKey fieldsKey : fieldsKeys) {
if (isLoadOperation) {
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldRead(objKeys[o], fieldsKeys[f]); keys.hasNext();) {
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldRead(objKey, fieldsKey); keys.hasNext();) {
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
if (DEBUG_PROPERTIES)
action.dump(key, true, true);
@ -1109,9 +1109,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
}
} else {
if (objCatalog != null) {
system.newConstraint(objCatalog, fieldsKeys[f]);
system.newConstraint(objCatalog, fieldsKey);
}
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldWrite(objKeys[o], fieldsKeys[f]); keys.hasNext();) {
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldWrite(objKey, fieldsKey); keys.hasNext();) {
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
if (DEBUG_PROPERTIES)
action.dump(key, true, true);
@ -1145,17 +1145,17 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
@Override
public void dump(AbstractFieldPointerKey fieldKey, boolean constObj, boolean constProp) {
System.err.println(("writing fixed rvals to " + fieldKey + " " + constObj + ", " + constProp));
for (int i = 0; i < rhsFixedValues.length; i++) {
System.err.println(("writing " + rhsFixedValues[i]));
for (InstanceKey rhsFixedValue : rhsFixedValues) {
System.err.println(("writing " + rhsFixedValue));
}
}
@Override
public void action(AbstractFieldPointerKey fieldKey) {
if (!representsNullType(fieldKey.getInstanceKey())) {
for (int i = 0; i < rhsFixedValues.length; i++) {
system.findOrCreateIndexForInstanceKey(rhsFixedValues[i]);
system.newConstraint(fieldKey, rhsFixedValues[i]);
for (InstanceKey rhsFixedValue : rhsFixedValues) {
system.findOrCreateIndexForInstanceKey(rhsFixedValue);
system.newConstraint(fieldKey, rhsFixedValue);
}
}
}

View File

@ -32,16 +32,16 @@ public class CAstAnalysisScope extends AnalysisScope {
public CAstAnalysisScope(String[] sourceFileNames, SingleClassLoaderFactory loaders, Collection<Language> languages) {
this(loaders, languages);
for (int i = 0; i < sourceFileNames.length; i++) {
File F = new File(sourceFileNames[i]);
for (String sourceFileName : sourceFileNames) {
File F = new File(sourceFileName);
addSourceFileToScope(theLoader, F, F.getPath());
}
}
public CAstAnalysisScope(Module[] sources, SingleClassLoaderFactory loaders, Collection<Language> languages) {
this(loaders, languages);
for (int i = 0; i < sources.length; i++) {
addToScope(theLoader, sources[i]);
for (Module source : sources) {
addToScope(theLoader, source);
}
}

View File

@ -45,8 +45,7 @@ public class MiscellaneousHacksContextSelector implements ContextSelector {
basePolicy = base;
specialPolicy = special;
methodsToSpecialize = HashSetFactory.make();
for (int i = 0; i < descriptors.length; i++) {
String[] descr = descriptors[i];
for (String[] descr : descriptors) {
switch (descr.length) {
// loader name, loader language, classname, method name, method descr

View File

@ -56,8 +56,8 @@ public class AstEchoInstruction extends SSAInstruction {
@Override
public int hashCode() {
int v = 1;
for(int i = 0;i < rvals.length; i++) {
v *= rvals[i];
for (int rval : rvals) {
v *= rval;
}
return v;
@ -66,8 +66,8 @@ public class AstEchoInstruction extends SSAInstruction {
@Override
public String toString(SymbolTable symbolTable) {
StringBuffer result = new StringBuffer("echo/print ");
for(int i = 0; i < rvals.length; i++) {
result.append(getValueString(symbolTable, rvals[i])).append(" ");
for (int rval : rvals) {
result.append(getValueString(symbolTable, rval)).append(" ");
}
return result.toString();

View File

@ -116,8 +116,8 @@ public abstract class AstLexicalAccess extends SSAInstruction {
@Override
public int hashCode() {
int v = 1;
for(int i = 0; i < accesses.length; i++)
v *= accesses[i].variableName.hashCode();
for (Access accesse : accesses)
v *= accesse.variableName.hashCode();
return v;
}

View File

@ -209,8 +209,7 @@ public class SSAConversion extends AbstractSSAConversion {
if (DEBUG_UNDO)
System.err.println(("recreating assignment at " + instructionIndex + " as " + lhs + " = " + rhs));
for (Iterator<Object> uses = renamedUses.iterator(); uses.hasNext();) {
Object x = uses.next();
for (Object x : renamedUses) {
if (x instanceof UseRecord) {
UseRecord use = (UseRecord) x;
int idx = use.instructionIndex;
@ -235,8 +234,8 @@ public class SSAConversion extends AbstractSSAConversion {
}
}
for (Iterator<CopyPropagationRecord> cs = childRecords.iterator(); cs.hasNext();) {
cs.next().undo(lhs);
for (CopyPropagationRecord copyPropagationRecord : childRecords) {
copyPropagationRecord.undo(lhs);
}
}
@ -545,9 +544,9 @@ public class SSAConversion extends AbstractSSAConversion {
int[] exitLive = lexicalInfo.getExitExposedUses();
BitVector v = new BitVector();
if (exitLive != null) {
for (int i = 0; i < exitLive.length; i++) {
if (exitLive[i] > -1) {
v.set(exitLive[i]);
for (int element : exitLive) {
if (element > -1) {
v.set(element);
}
}
}
@ -624,8 +623,8 @@ public class SSAConversion extends AbstractSSAConversion {
int[] lexicalUses = lexicalInfo.getExposedUses(i);
if (lexicalUses != null) {
System.err.print(("extra uses for " + instructions[i] + ": "));
for (int j = 0; j < lexicalUses.length; j++) {
System.err.print((new Integer(lexicalUses[j]).toString() + " "));
for (int lexicalUse : lexicalUses) {
System.err.print((new Integer(lexicalUse).toString() + " "));
}
System.err.println("");
}
@ -640,8 +639,7 @@ public class SSAConversion extends AbstractSSAConversion {
SSAInstruction[] insts = ir.getInstructions();
MutableIntSet foundOne = new BitVectorIntSet();
MutableIntSet foundTwo = new BitVectorIntSet();
for (int i = 0; i < insts.length; i++) {
SSAInstruction inst = insts[i];
for (SSAInstruction inst : insts) {
if (inst != null) {
for (int j = 0; j < inst.getNumberOfDefs(); j++) {
int def = inst.getDef(j);

View File

@ -944,8 +944,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
*/
private void checkForRealizedEdges(CAstNode n) {
if (delayedEdges.containsKey(n)) {
for (Iterator<Pair<PreBasicBlock, Boolean>> ss = delayedEdges.get(n).iterator(); ss.hasNext();) {
Pair<PreBasicBlock, Boolean> s = ss.next();
for (Pair<PreBasicBlock, Boolean> s : delayedEdges.get(n)) {
PreBasicBlock src = s.fst;
boolean exception = s.snd;
if (unwind == null) {
@ -965,8 +964,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
*/
private void checkForRealizedExitEdges(PreBasicBlock exitBlock) {
if (delayedEdges.containsKey(exitMarker)) {
for (Iterator<Pair<PreBasicBlock, Boolean>> ss = delayedEdges.get(exitMarker).iterator(); ss.hasNext();) {
Pair<PreBasicBlock, Boolean> s = ss.next();
for (Pair<PreBasicBlock, Boolean> s : delayedEdges.get(exitMarker)) {
PreBasicBlock src = s.fst;
boolean exception = s.snd;
addEdge(src, exitBlock);
@ -1346,8 +1344,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
SSAInstruction[] insts = getInstructions();
StringBuffer s = new StringBuffer("CAst CFG of " + functionName);
int params[] = symtab.getParameterValueNumbers();
for (int i = 0; i < params.length; i++)
s.append(" ").append(params[i]);
for (int param : params)
s.append(" ").append(param);
s.append("\n");
for (int i = 0; i < getNumberOfNodes(); i++) {
@ -2605,8 +2603,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
} else {
TypeReference[] data = catchTypes.get(bb);
for (int i = 0; i < data.length; i++) {
if (data[i] == catchType) {
for (TypeReference element : data) {
if (element == catchType) {
return;
}
}
@ -2865,8 +2863,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
if (accesses != null) {
Set<String> parents = new LinkedHashSet<>();
for (Iterator<Access> ACS = accesses.iterator(); ACS.hasNext();) {
Access AC = ACS.next();
for (Access AC : accesses) {
if (AC.variableDefiner != null) {
parents.add(AC.variableDefiner);
}
@ -2912,18 +2909,18 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
if (allExposedUses == null) {
allExposedUses = IntSetUtil.make();
if (exitLexicalUses != null) {
for (int i = 0; i < exitLexicalUses.length; i++) {
if (exitLexicalUses[i] > 0) {
allExposedUses.add(exitLexicalUses[i]);
for (int exitLexicalUse : exitLexicalUses) {
if (exitLexicalUse > 0) {
allExposedUses.add(exitLexicalUse);
}
}
}
if (instructionLexicalUses != null) {
for (int i = 0; i < instructionLexicalUses.length; i++) {
if (instructionLexicalUses[i] != null) {
for (int j = 0; j < instructionLexicalUses[i].length; j++) {
if (instructionLexicalUses[i][j] > 0) {
allExposedUses.add(instructionLexicalUses[i][j]);
for (int[] instructionLexicalUse : instructionLexicalUses) {
if (instructionLexicalUse != null) {
for (int j = 0; j < instructionLexicalUse.length; j++) {
if (instructionLexicalUse[j] > 0) {
allExposedUses.add(instructionLexicalUse[j]);
}
}
}
@ -3104,8 +3101,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
System.err.println(("names array of size " + map.length));
}
for (Iterator<Scope> S = scopes.iterator(); S.hasNext();) {
Scope scope = S.next();
for (Scope scope : scopes) {
for (Iterator<String> I = scope.getAllNames(); I.hasNext();) {
String nm = I.next();

View File

@ -13,7 +13,6 @@ package com.ibm.wala.cast.loader;
import java.io.Reader;
import java.net.URL;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@ -184,8 +183,7 @@ abstract public class AstClass implements IClass, ClassConstants {
@Override
public Collection<IField> getDeclaredInstanceFields() {
Set<IField> result = HashSetFactory.make();
for (Iterator<IField> FS = declaredFields.values().iterator(); FS.hasNext();) {
IField F = FS.next();
for (IField F : declaredFields.values()) {
if (!F.isStatic()) {
result.add(F);
}
@ -197,8 +195,7 @@ abstract public class AstClass implements IClass, ClassConstants {
@Override
public Collection<IField> getDeclaredStaticFields() {
Set<IField> result = HashSetFactory.make();
for (Iterator<IField> FS = declaredFields.values().iterator(); FS.hasNext();) {
IField F = FS.next();
for (IField F : declaredFields.values()) {
if (F.isStatic()) {
result.add(F);
}
@ -240,8 +237,8 @@ abstract public class AstClass implements IClass, ClassConstants {
@Override
public Collection<IMethod> getAllMethods() {
Collection<IMethod> result = HashSetFactory.make();
for (Iterator<IMethod> ms = getDeclaredMethods().iterator(); ms.hasNext();) {
result.add(ms.next());
for (IMethod iMethod : getDeclaredMethods()) {
result.add(iMethod);
}
if (getSuperclass() != null) {
result.addAll(getSuperclass().getAllMethods());

View File

@ -186,8 +186,7 @@ public abstract class CAstAbstractLoader implements IClassLoader {
public void removeAll(Collection<IClass> toRemove) {
Set<TypeName> keys = HashSetFactory.make();
for (Iterator<Map.Entry<TypeName,IClass>> EE = types.entrySet().iterator(); EE.hasNext();) {
Map.Entry<TypeName,IClass> E = EE.next();
for (Map.Entry<TypeName, IClass> E : types.entrySet()) {
if (toRemove.contains(E.getValue())) {
keys.add(E.getKey());
}

View File

@ -96,15 +96,14 @@ public abstract class CAstAbstractModuleLoader extends CAstAbstractLoader {
// convert everything to CAst
final Set<Pair<CAstEntity, ModuleEntry>> topLevelEntities = new LinkedHashSet<>();
for (Iterator<Module> mes = modules.iterator(); mes.hasNext();) {
translateModuleToCAst(mes.next(), ast, topLevelEntities);
for (Module module : modules) {
translateModuleToCAst(module, ast, topLevelEntities);
}
// generate IR as needed
final TranslatorToIR xlatorToIR = initTranslator();
for (Iterator<Pair<CAstEntity, ModuleEntry>> tles = topLevelEntities.iterator(); tles.hasNext();) {
Pair<CAstEntity, ModuleEntry> p = tles.next();
for (Pair<CAstEntity, ModuleEntry> p : topLevelEntities) {
if (shouldTranslate(p.fst)) {
xlatorToIR.translate(p.fst, p.snd);
}

View File

@ -12,7 +12,6 @@ package com.ibm.wala.cast.tree.impl;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
@ -127,8 +126,7 @@ public class CAstControlFlowRecorder implements CAstControlFlowMap {
Collection<CAstNode> nodes = cachedMappedNodes;
if (nodes == null) {
nodes = new LinkedHashSet<>();
for (Iterator<Key> keys = table.keySet().iterator(); keys.hasNext();) {
Key key = keys.next();
for (Key key : table.keySet()) {
nodes.add(nodeToCAst.get(key.from));
nodes.add(nodeToCAst.get(table.get(key)));
}

View File

@ -33,8 +33,8 @@ public class CAstValueImpl extends CAstImpl {
@Override
public int hashCode() {
int value = 1237 * kind;
for(int i = 0; i < cs.length; i++)
value *= cs[i].hashCode();
for (CAstNode element : cs)
value *= element.hashCode();
return value;
}

View File

@ -159,8 +159,7 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
Set<CAstNode> allNewTargetNodes = HashSetFactory.make(1);
Collection<CAstNode> oldSources = orig.getMappedNodes();
for (Iterator<Entry<Pair<CAstNode, K>, CAstNode>> NS = nodeMap.entrySet().iterator(); NS.hasNext();) {
Entry<Pair<CAstNode, K>, CAstNode> entry = NS.next();
for (Entry<Pair<CAstNode, K>, CAstNode> entry : nodeMap.entrySet()) {
Pair<CAstNode, K> N = entry.getKey();
CAstNode oldSource = N.fst;
K key = N.snd;
@ -272,8 +271,7 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
protected CAstSourcePositionMap copySource(Map<Pair<CAstNode, K>, CAstNode> nodeMap, CAstSourcePositionMap orig) {
CAstSourcePositionRecorder newMap = new CAstSourcePositionRecorder();
for (Iterator<Map.Entry<Pair<CAstNode, K>, CAstNode>> NS = nodeMap.entrySet().iterator(); NS.hasNext();) {
Map.Entry<Pair<CAstNode, K>, CAstNode> entry = NS.next();
for (Entry<Pair<CAstNode, K>, CAstNode> entry : nodeMap.entrySet()) {
Pair<CAstNode, K> N = entry.getKey();
CAstNode oldNode = N.fst;
@ -290,8 +288,7 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
protected CAstNodeTypeMap copyTypes(Map<Pair<CAstNode, K>, CAstNode> nodeMap, CAstNodeTypeMap orig) {
if (orig != null) {
CAstNodeTypeMapRecorder newMap = new CAstNodeTypeMapRecorder();
for (Iterator<Entry<Pair<CAstNode, K>, CAstNode>> NS = nodeMap.entrySet().iterator(); NS.hasNext();) {
Entry<Pair<CAstNode, K>, CAstNode> entry = NS.next();
for (Entry<Pair<CAstNode, K>, CAstNode> entry : nodeMap.entrySet()) {
Pair<CAstNode, K> N = entry.getKey();
CAstNode oldNode = N.fst;
@ -312,8 +309,7 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
Map<CAstNode, Collection<CAstEntity>> children) {
final Map<CAstNode, Collection<CAstEntity>> newChildren = new LinkedHashMap<>();
for (Iterator<Entry<Pair<CAstNode, K>, CAstNode>> NS = nodeMap.entrySet().iterator(); NS.hasNext();) {
Entry<Pair<CAstNode, K>, CAstNode> entry = NS.next();
for (Entry<Pair<CAstNode, K>, CAstNode> entry : nodeMap.entrySet()) {
Pair<CAstNode, K> N = entry.getKey();
CAstNode oldNode = N.fst;
@ -322,14 +318,13 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
if (children.containsKey(oldNode)) {
Set<CAstEntity> newEntities = new LinkedHashSet<>();
newChildren.put(newNode, newEntities);
for (Iterator<CAstEntity> oldEntities = children.get(oldNode).iterator(); oldEntities.hasNext();) {
newEntities.add(rewrite(oldEntities.next()));
for (CAstEntity cAstEntity : children.get(oldNode)) {
newEntities.add(rewrite(cAstEntity));
}
}
}
for (Iterator<Map.Entry<CAstNode, Collection<CAstEntity>>> keys = children.entrySet().iterator(); keys.hasNext();) {
Map.Entry<CAstNode, Collection<CAstEntity>> entry = keys.next();
for (Entry<CAstNode, Collection<CAstEntity>> entry : children.entrySet()) {
CAstNode key = entry.getKey();
if (key == null) {
Set<CAstEntity> newEntities = new LinkedHashSet<>();
@ -450,8 +445,7 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
Map<CAstNode, Collection<CAstEntity>> children = root.getAllScopedEntities();
final Map<CAstNode, Collection<CAstEntity>> newChildren = new LinkedHashMap<>();
for (Iterator<Map.Entry<CAstNode, Collection<CAstEntity>>> keys = children.entrySet().iterator(); keys.hasNext();) {
Map.Entry<CAstNode, Collection<CAstEntity>> entry = keys.next();
for (Entry<CAstNode, Collection<CAstEntity>> entry : children.entrySet()) {
CAstNode key = entry.getKey();
Set<CAstEntity> newValues = new LinkedHashSet<>();
newChildren.put(key, newValues);

View File

@ -292,8 +292,8 @@ public class CAstPattern {
return references.get(value).match(tree, s);
} else if (kind == ALTERNATIVE_PATTERN_KIND) {
for (int i = 0; i < children.length; i++) {
if (children[i].tryMatch(tree, s)) {
for (CAstPattern element : children) {
if (element.tryMatch(tree, s)) {
if (s != null && name != null)
s.add(name, tree);

View File

@ -294,8 +294,8 @@ public class CAstPrinter {
if (e.getArgumentNames().length > 0) {
w.write("(");
String[] names = e.getArgumentNames();
for(int i = 0; i < names.length; i++) {
w.write(" " + names[i]);
for (String name : names) {
w.write(" " + name);
}
w.write(" )\n");
}

View File

@ -790,8 +790,8 @@ public class PrimitivesTest extends WalaTestCase {
R.add(3, 11);
R.add(5, 1);
int count = 0;
for (Iterator<IntPair> it = R.iterator(); it.hasNext();) {
System.err.println(it.next());
for (IntPair intPair : R) {
System.err.println(intPair);
count++;
}
Assert.assertTrue(count == 5);

View File

@ -61,14 +61,14 @@ public class WelshPowellTest {
private <T> NumberedGraph<TypedNode<T>> buildGraph(T[][] data) {
DelegatingNumberedGraph<TypedNode<T>> G = new DelegatingNumberedGraph<>();
Map<T,TypedNode<T>> nodes = HashMapFactory.make();
for(int i = 0; i < data.length; i++) {
TypedNode<T> n = new TypedNode<>(data[i][0]);
nodes.put(data[i][0], n);
for (T[] element : data) {
TypedNode<T> n = new TypedNode<>(element[0]);
nodes.put(element[0], n);
G.addNode(n);
}
for(int i = 0; i < data.length; i++) {
for(int j = 1; j < data[i].length; j++) {
G.addEdge(nodes.get(data[i][0]), nodes.get(data[i][j]));
for (T[] element : data) {
for(int j = 1; j < element.length; j++) {
G.addEdge(nodes.get(element[0]), nodes.get(element[j]));
}
}

View File

@ -1,7 +1,6 @@
package com.ibm.wala.core.tests.callGraph;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@ -45,8 +44,7 @@ public class AcyclicCallGraphTest extends WalaTestCase {
Assert.assertTrue("NList should have cycles", backEdges.iterator().hasNext());
Map<CGNode, Set<CGNode>> cgBackEdges = HashMapFactory.make();
for (Iterator<IntPair> ps = backEdges.iterator(); ps.hasNext(); ) {
IntPair p = ps.next();
for (IntPair p : backEdges) {
CGNode src = cg.getNode(p.getX());
if (!cgBackEdges.containsKey(src)) {
cgBackEdges.put(src, HashSetFactory.<CGNode>make());

View File

@ -396,8 +396,7 @@ public class CallGraphTest extends WalaTestCase {
// perform a little icfg exercise
@SuppressWarnings("unused")
int count = 0;
for (Iterator<BasicBlockInContext<ISSABasicBlock>> it = icfg.iterator(); it.hasNext();) {
BasicBlockInContext<ISSABasicBlock> bb = it.next();
for (BasicBlockInContext<ISSABasicBlock> bb : icfg) {
if (icfg.hasCall(bb)) {
count++;
}
@ -458,8 +457,8 @@ public class CallGraphTest extends WalaTestCase {
throw new IllegalArgumentException("cg is null");
}
final Set<MethodReference> nodes = HashSetFactory.make();
for (Iterator<CGNode> nodesI = cg.iterator(); nodesI.hasNext();) {
nodes.add((nodesI.next()).getMethod().getReference());
for (CGNode cgNode : cg) {
nodes.add((cgNode).getMethod().getReference());
}
return new Graph<MethodReference>() {
@ -503,8 +502,8 @@ public class CallGraphTest extends WalaTestCase {
public Iterator<MethodReference> getPredNodes(MethodReference N) {
Set<MethodReference> pred = HashSetFactory.make(10);
MethodReference methodReference = N;
for (Iterator<CGNode> i = cg.getNodes(methodReference).iterator(); i.hasNext();)
for (Iterator<? extends CGNode> ps = cg.getPredNodes(i.next()); ps.hasNext();)
for (CGNode cgNode : cg.getNodes(methodReference))
for (Iterator<? extends CGNode> ps = cg.getPredNodes(cgNode); ps.hasNext();)
pred.add(((CGNode) ps.next()).getMethod().getReference());
return pred.iterator();
@ -528,8 +527,8 @@ public class CallGraphTest extends WalaTestCase {
public Iterator<MethodReference> getSuccNodes(MethodReference N) {
Set<MethodReference> succ = HashSetFactory.make(10);
MethodReference methodReference = N;
for (Iterator<? extends CGNode> i = cg.getNodes(methodReference).iterator(); i.hasNext();)
for (Iterator<? extends CGNode> ps = cg.getSuccNodes(i.next()); ps.hasNext();)
for (CGNode node : cg.getNodes(methodReference))
for (Iterator<? extends CGNode> ps = cg.getSuccNodes(node); ps.hasNext();)
succ.add(((CGNode) ps.next()).getMethod().getReference());
return succ.iterator();

View File

@ -63,8 +63,8 @@ public class CloneTest extends WalaTestCase {
Set<CGNode> targets = cg.getPossibleTargets(node, site);
if (targets.size() != 1) {
System.err.println(targets.size() + " targets found for " + site);
for (Iterator<CGNode> k = targets.iterator(); k.hasNext();) {
System.err.println(" " + k.next());
for (CGNode cgNode : targets) {
System.err.println(" " + cgNode);
}
Assert.fail("found " + targets.size() + " targets for " + site + " in " + node);
}

View File

@ -116,8 +116,7 @@ public abstract class AbstractPtrTest {
}
public static CGNode findStaticMethod(CallGraph cg, Atom name, Descriptor args) {
for (Iterator<? extends CGNode> it = cg.iterator(); it.hasNext();) {
CGNode n = it.next();
for (CGNode n : cg) {
// System.err.println(n.getMethod().getName() + " " +
// n.getMethod().getDescriptor());
if (n.getMethod().getName().equals(name) && n.getMethod().getDescriptor().equals(args)) {
@ -129,8 +128,7 @@ public abstract class AbstractPtrTest {
}
public static CGNode findInstanceMethod(CallGraph cg, IClass declaringClass, Atom name, Descriptor args) {
for (Iterator<? extends CGNode> it = cg.iterator(); it.hasNext();) {
CGNode n = it.next();
for (CGNode n : cg) {
// System.err.println(n.getMethod().getDeclaringClass() + " " +
// n.getMethod().getName() + " " + n.getMethod().getDescriptor());
if (n.getMethod().getDeclaringClass().equals(declaringClass) && n.getMethod().getName().equals(name)

View File

@ -109,8 +109,8 @@ public class DeterministicIRTest extends WalaTestCase {
* @param instructions
*/
private static void checkNotAllNull(SSAInstruction[] instructions) {
for (int i = 0; i < instructions.length; i++) {
if (instructions[i] != null) {
for (SSAInstruction instruction : instructions) {
if (instruction != null) {
return;
}
}

View File

@ -11,8 +11,6 @@
package com.ibm.wala.core.tests.ptrs;
import java.io.IOException;
import java.util.Iterator;
import org.junit.Assert;
import org.junit.Test;
@ -75,8 +73,7 @@ public class MultiDimArrayTest extends WalaTestCase {
}
private final static CGNode findDoNothingNode(CallGraph cg) {
for (Iterator<? extends CGNode> it = cg.iterator(); it.hasNext(); ) {
CGNode n = it.next();
for (CGNode n : cg) {
if (n.getMethod().getName().toString().equals("doNothing")) {
return n;
}

View File

@ -11,8 +11,6 @@
package com.ibm.wala.core.tests.ptrs;
import java.io.IOException;
import java.util.Iterator;
import org.junit.Assert;
import org.junit.Test;
@ -68,8 +66,7 @@ public class TypeBasedArrayAliasTest extends WalaTestCase {
}
private final static CGNode findNode(CallGraph cg, String methodName) {
for (Iterator<? extends CGNode> it = cg.iterator(); it.hasNext(); ) {
CGNode n = it.next();
for (CGNode n : cg) {
if (n.getMethod().getName().toString().equals(methodName)) {
return n;
}

View File

@ -1090,8 +1090,7 @@ public class SlicerTest {
public static CGNode findMethod(CallGraph cg, String name) {
Atom a = Atom.findOrCreateUnicodeAtom(name);
for (Iterator<? extends CGNode> it = cg.iterator(); it.hasNext();) {
CGNode n = it.next();
for (CGNode n : cg) {
if (n.getMethod().getName().equals(a)) {
return n;
}

View File

@ -43,8 +43,6 @@ package com.ibm.wala.demandpa.driver;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import com.ibm.wala.analysis.reflection.InstanceKeyWithNode;
import com.ibm.wala.analysis.typeInference.TypeAbstraction;
import com.ibm.wala.analysis.typeInference.TypeInference;
@ -206,8 +204,7 @@ public class CompareToZeroOneCFADriver {
}
Helper h = new Helper();
for (Iterator<? extends CGNode> nodeIter = cg.iterator(); nodeIter.hasNext();) {
CGNode node = nodeIter.next();
for (CGNode node : cg) {
h.checkPointersInMethod(node);
}
}

View File

@ -42,8 +42,6 @@ package com.ibm.wala.demandpa.driver;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import com.ibm.wala.analysis.typeInference.TypeAbstraction;
import com.ibm.wala.analysis.typeInference.TypeInference;
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
@ -156,8 +154,8 @@ public class TestAgainstSimpleDriver {
if (result.isEmpty()) {
System.err.println(" EMPTY!");
}
for (Iterator<InstanceKey> it = result.iterator(); it.hasNext();) {
System.err.println(" " + it.next());
for (InstanceKey instanceKey : result) {
System.err.println(" " + instanceKey);
}
}
}

View File

@ -42,7 +42,6 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Properties;
import com.ibm.wala.ipa.callgraph.CGNode;
@ -68,8 +67,7 @@ public class WalaUtil {
System.err.print("dumping ir...");
String irFile = p.getProperty(WalaProperties.OUTPUT_DIR) + File.separatorChar + benchName + "-ir.txt";
try (final PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(irFile)))) {
for (Iterator<? extends CGNode> iter = cg.iterator(); iter.hasNext();) {
CGNode node = iter.next();
for (CGNode node : cg) {
IR ir = node.getIR();
if (ir == null)
continue;

View File

@ -13,7 +13,6 @@ package com.ibm.wala.examples.analysis;
import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.Properties;
import java.util.Set;
import java.util.jar.JarFile;
@ -99,8 +98,8 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine<InstanceK
private void collectJars(File f, Set<JarFile> result) throws IOException {
if (f.isDirectory()) {
File[] files = f.listFiles();
for (int i = 0; i < files.length; i++) {
collectJars(files[i], result);
for (File file : files) {
collectJars(file, result);
}
} else if (f.getAbsolutePath().endsWith(".jar")) {
try (final JarFile jar = new JarFile(f, false)) {
@ -148,8 +147,8 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine<InstanceK
*/
private Set<JarFileModule> getModuleFiles() {
Set<JarFileModule> result = HashSetFactory.make();
for (Iterator<JarFile> jars = applicationJarFiles.iterator(); jars.hasNext();) {
result.add(new JarFileModule(jars.next()));
for (JarFile jarFile : applicationJarFiles) {
result.add(new JarFileModule(jarFile));
}
return result;
@ -218,8 +217,7 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine<InstanceK
// 1) static fields
for (IClass cls : cha) {
Collection<IField> staticFields = cls.getDeclaredStaticFields();
for (Iterator<IField> sfs = staticFields.iterator(); sfs.hasNext();) {
IField sf = sfs.next();
for (IField sf : staticFields) {
if (sf.getFieldTypeReference().isReferenceType()) {
escapeAnalysisRoots.add(heapModel.getPointerKeyForStaticField(sf));
}
@ -232,14 +230,11 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine<InstanceK
// reachable from fields of types in these pointer keys, and all
// Thread objects must be constructed somewhere)
Collection<IClass> threads = cha.computeSubClasses(TypeReference.JavaLangThread);
for (Iterator<IClass> clss = threads.iterator(); clss.hasNext();) {
IClass cls = clss.next();
for (Iterator<IMethod> ms = cls.getDeclaredMethods().iterator(); ms.hasNext();) {
IMethod m = ms.next();
for (IClass cls : threads) {
for (IMethod m : cls.getDeclaredMethods()) {
if (m.isInit()) {
Set<CGNode> nodes = cg.getNodes(m.getReference());
for (Iterator<CGNode> ns = nodes.iterator(); ns.hasNext();) {
CGNode n = ns.next();
for (CGNode n : nodes) {
escapeAnalysisRoots.add(heapModel.getPointerKeyForLocal(n, 1));
}
}
@ -255,11 +250,9 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine<InstanceK
//
// pass 1: get abstract objects (instance keys) for escaping locations
//
for (Iterator<PointerKey> rts = escapeAnalysisRoots.iterator(); rts.hasNext();) {
PointerKey root = rts.next();
for (PointerKey root : escapeAnalysisRoots) {
OrdinalSet<InstanceKey> objects = pa.getPointsToSet(root);
for (Iterator<InstanceKey> objs = objects.iterator(); objs.hasNext();) {
InstanceKey obj = objs.next();
for (InstanceKey obj : objects) {
escapingInstanceKeys.add(obj);
}
}
@ -270,16 +263,14 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine<InstanceK
Set<InstanceKey> newKeys = HashSetFactory.make();
do {
newKeys.clear();
for (Iterator<InstanceKey> keys = escapingInstanceKeys.iterator(); keys.hasNext();) {
InstanceKey key = keys.next();
for (InstanceKey key : escapingInstanceKeys) {
IClass type = key.getConcreteType();
if (type.isReferenceType()) {
if (type.isArrayClass()) {
if (((ArrayClass) type).getElementClass() != null) {
PointerKey fk = heapModel.getPointerKeyForArrayContents(key);
OrdinalSet<InstanceKey> fobjects = pa.getPointsToSet(fk);
for (Iterator<InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
InstanceKey fobj = fobjs.next();
for (InstanceKey fobj : fobjects) {
if (!escapingInstanceKeys.contains(fobj)) {
newKeys.add(fobj);
}
@ -287,13 +278,11 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine<InstanceK
}
} else {
Collection<IField> fields = type.getAllInstanceFields();
for (Iterator<IField> fs = fields.iterator(); fs.hasNext();) {
IField f = fs.next();
for (IField f : fields) {
if (f.getFieldTypeReference().isReferenceType()) {
PointerKey fk = heapModel.getPointerKeyForInstanceField(key, f);
OrdinalSet<InstanceKey> fobjects = pa.getPointsToSet(fk);
for (Iterator<InstanceKey> fobjs = fobjects.iterator(); fobjs.hasNext();) {
InstanceKey fobj = fobjs.next();
for (InstanceKey fobj : fobjects) {
if (!escapingInstanceKeys.contains(fobj)) {
newKeys.add(fobj);
}
@ -310,8 +299,7 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine<InstanceK
// get set of types from set of instance keys
//
Set<IClass> escapingTypes = HashSetFactory.make();
for (Iterator<InstanceKey> keys = escapingInstanceKeys.iterator(); keys.hasNext();) {
InstanceKey key = keys.next();
for (InstanceKey key : escapingInstanceKeys) {
escapingTypes.add(key.getConcreteType());
}
@ -336,11 +324,9 @@ public class SimpleThreadEscapeAnalysis extends AbstractAnalysisEngine<InstanceK
Set<IClass> escapingTypes = (new SimpleThreadEscapeAnalysis(jars, mainClassName)).gatherThreadEscapingClasses();
for (Iterator<IClass> types = escapingTypes.iterator(); types.hasNext();) {
IClass cls = types.next();
for (IClass cls : escapingTypes) {
if (!cls.isArrayClass()) {
for (Iterator<IField> fs = cls.getAllFields().iterator(); fs.hasNext();) {
IField f = fs.next();
for (IField f : cls.getAllFields()) {
if (!f.isVolatile() && !f.isFinal()) {
System.err.println(f.getReference());
}

View File

@ -55,9 +55,8 @@ public class PDFCallGraph {
public static String findJarFiles(String[] directories) {
Collection<String> result = HashSetFactory.make();
for (int i = 0; i < directories.length; i++) {
for (Iterator<File> it = FileUtil.listFiles(directories[i], ".*\\.jar", true).iterator(); it.hasNext();) {
File f = it.next();
for (String directorie : directories) {
for (File f : FileUtil.listFiles(directorie, ".*\\.jar", true)) {
result.add(f.getAbsolutePath());
}
}

View File

@ -226,7 +226,7 @@ public class IntraproceduralExceptionAnalysis {
if (pointerAnalysis != null) {
PointerKey pointerKey = pointerAnalysis.getHeapModel().getPointerKeyForLocal(node, exceptionVariable);
Iterator it = pointerAnalysis.getHeapGraph().getSuccNodes(pointerKey);
Iterator<Object> it = pointerAnalysis.getHeapGraph().getSuccNodes(pointerKey);
while (it.hasNext()) {
Object next = it.next();
if (next instanceof InstanceKey) {

View File

@ -240,8 +240,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
private OrdinalSetMapping<PointerKey> getPointerKeys() {
MutableMapping<PointerKey> result = MutableMapping.make();
for (Iterator<PointerKey> it = getPointerAnalysis().getPointerKeys().iterator(); it.hasNext();) {
PointerKey p = it.next();
for (PointerKey p : getPointerAnalysis().getPointerKeys()) {
result.add(p);
}
return result;
@ -254,8 +253,8 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
OrdinalSet<T> S = getPointerAnalysis().getPointsToSet(P);
int[] result = new int[S.size()];
int i = 0;
for (Iterator<T> it = S.iterator(); it.hasNext();) {
result[i] = nodeManager.getNumber(it.next());
for (T t : S) {
result[i] = nodeManager.getNumber(t);
i++;
}
return result;
@ -275,8 +274,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
IClass klass = getHeapModel().getClassHierarchy().lookupClass(T);
assert klass != null : "null klass for type " + T;
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
for (Iterator<IField> it = klass.getAllInstanceFields().iterator(); it.hasNext();) {
IField f = it.next();
for (IField f : klass.getAllInstanceFields()) {
if (!f.getReference().getFieldType().isPrimitiveType()) {
PointerKey p = getHeapModel().getPointerKeyForInstanceField(I, f);
if (p != null && nodeManager.containsNode(p)) {
@ -321,8 +319,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
if (!(n instanceof LocalPointerKey)) {
int[] succ = computeSuccNodeNumbers(n, nodeManager);
if (succ != null) {
for (int z = 0; z < succ.length; z++) {
int j = succ[z];
for (int j : succ) {
R.add(j, i);
}
}
@ -336,8 +333,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
private void computePredecessorsForLocals(NumberedNodeManager<Object> nodeManager, BasicNaturalRelation R) {
ArrayList<LocalPointerKey> list = new ArrayList<LocalPointerKey>();
for (Iterator<Object> it = nodeManager.iterator(); it.hasNext();) {
Object n = it.next();
for (Object n : nodeManager) {
if (n instanceof LocalPointerKey) {
list.add((LocalPointerKey) n);
}
@ -355,8 +351,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
int num = nodeManager.getNumber(n);
int[] succ = computeSuccNodeNumbers(n, nodeManager);
if (succ != null) {
for (int z = 0; z < succ.length; z++) {
int j = succ[z];
for (int j : succ) {
R.add(j, num);
}
}
@ -511,7 +506,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
Object node = getNode(i);
if (node != null) {
result.append(i).append(" -> ");
for (Iterator it = getSuccNodes(node); it.hasNext();) {
for (Iterator<Object> it = getSuccNodes(node); it.hasNext();) {
Object s = it.next();
result.append(getNumber(s)).append(" ");
}

View File

@ -189,8 +189,7 @@ public class CloneInterpreter implements SSAContextInterpreter {
// TODO:
IClass k = klass;
while (k != null) {
for (Iterator<IField> it = klass.getDeclaredInstanceFields().iterator(); it.hasNext();) {
IField f = it.next();
for (IField f : klass.getDeclaredInstanceFields()) {
int tempValue = nextLocal++;
SSAGetInstruction G = insts.GetInstruction(statements.size(), tempValue, 1, f.getReference());
statements.add(G);
@ -258,7 +257,7 @@ public class CloneInterpreter implements SSAContextInterpreter {
return CodeScanner.hasObjectArrayStore(statements);
}
public Iterator iterateCastTypes(CGNode node) {
public Iterator<TypeReference> iterateCastTypes(CGNode node) {
SSAInstruction[] statements = getIR(node).getInstructions();
return CodeScanner.iterateCastTypes(statements);
}

View File

@ -157,8 +157,8 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
}
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
HashSet<NewSiteReference> result = HashSetFactory.make(5);
for (Iterator<SSAInstruction> it = m.getAllocationStatements().iterator(); it.hasNext();) {
SSANewInstruction s = (SSANewInstruction) it.next();
for (SSAInstruction ssaInstruction : m.getAllocationStatements()) {
SSANewInstruction s = (SSANewInstruction) ssaInstruction;
result.add(s.getNewSite());
}
return result.iterator();
@ -263,7 +263,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
private SpecializedFactoryMethod findOrCreateSpecializedFactoryMethod(CGNode node) {
SpecializedFactoryMethod m = syntheticMethodCache.get(node.getContext());
if (m == null) {
Set types = getTypesForContext(node.getContext());
Set<TypeReference> types = getTypesForContext(node.getContext());
m = new SpecializedFactoryMethod((SummarizedMethod) node.getMethod(), node.getContext(), types);
syntheticMethodCache.put(node.getContext(), m);
}
@ -312,7 +312,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
}
}
public Iterator iterateCastTypes(CGNode node) {
public Iterator<TypeReference> iterateCastTypes(CGNode node) {
if (node == null) {
throw new IllegalArgumentException("node is null");
}
@ -378,7 +378,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
}
}
protected SpecializedFactoryMethod(final SummarizedMethod m, Context context, final Set S) {
protected SpecializedFactoryMethod(final SummarizedMethod m, Context context, final Set<TypeReference> S) {
super(m, m.getDeclaringClass(), m.isStatic(), true);
this.context = context;
@ -393,8 +393,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
// add original statements from the method summary
nextLocal = addOriginalStatements(m);
for (Iterator it = S.iterator(); it.hasNext();) {
TypeReference type = (TypeReference) it.next();
for (TypeReference type : S) {
TypeAbstraction T = typeRef2TypeAbstraction(m.getClassHierarchy(), type);
addStatementsForTypeAbstraction(T);
}
@ -506,8 +505,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
SSAInstruction[] original = m.getStatements(options.getSSAOptions());
// local value number 1 is "this", so the next free value number is 2
int nextLocal = 2;
for (int i = 0; i < original.length; i++) {
SSAInstruction s = original[i];
for (SSAInstruction s : original) {
allInstructions.add(s);
if (s instanceof SSAInvokeInstruction) {
calls.add(s);
@ -603,8 +601,8 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
public SSAInstruction[] getStatements() {
SSAInstruction[] result = new SSAInstruction[allInstructions.size()];
int i = 0;
for (Iterator<SSAInstruction> it = allInstructions.iterator(); it.hasNext();) {
result[i++] = it.next();
for (SSAInstruction ssaInstruction : allInstructions) {
result[i++] = ssaInstruction;
}
return result;
}

View File

@ -54,6 +54,7 @@ import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.CancelRuntimeException;
import com.ibm.wala.util.graph.INodeWithNumber;
import com.ibm.wala.util.shrike.ShrikeUtil;
/**
@ -215,7 +216,7 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
/*
* Add only the entry variable to the work list.
*/
for (Iterator it = getFixedPointSystem().getStatementsThatUse(entry); it.hasNext();) {
for (Iterator<? extends INodeWithNumber> it = getFixedPointSystem().getStatementsThatUse(entry); it.hasNext();) {
AbstractStatement s = (AbstractStatement) it.next();
addToWorkList(s);
}
@ -683,8 +684,8 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
return true;
if (locals != null)
for (int i = 0; i < locals.length; i++)
if (locals[i] == val)
for (int local : locals)
if (local == val)
return true;
return false;

View File

@ -106,7 +106,7 @@ public class ConeType extends TypeAbstraction {
/**
* @return an Iterator of IClass that implement this interface
*/
public Iterator iterateImplementors() {
public Iterator<IClass> iterateImplementors() {
return type.getClassHierarchy().getImplementors(getType().getReference()).iterator();
}

View File

@ -217,8 +217,7 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
x = new TypeReference[]{ language.getThrowableType() };
}
if (x != null) {
for (int i = 0; i < x.length; i++) {
TypeReference tx = x[i];
for (TypeReference tx : x) {
IClass tc = cha.lookupClass(tx);
if (tc != null) {
v.setType(v.getType().meet(new ConeType(tc)));
@ -308,9 +307,8 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
TypeAbstraction lhsType = lhs.getType();
TypeAbstraction meet = TypeAbstraction.TOP;
for (int i = 0; i < rhs.length; i++) {
if (rhs[i] != null && rhs[i].getType() != null) {
TypeVariable r = rhs[i];
for (TypeVariable r : rhs) {
if (r != null && r.getType() != null) {
meet = meet.meet(r.getType());
}
}
@ -386,9 +384,8 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
public byte evaluate(TypeVariable lhs, TypeVariable[] rhs) {
TypeAbstraction lhsType = lhs.getType();
TypeAbstraction meet = TypeAbstraction.TOP;
for (int i = 0; i < rhs.length; i++) {
if (rhs[i] != null && rhs[i].getType() != null) {
TypeVariable r = rhs[i];
for (TypeVariable r : rhs) {
if (r != null && r.getType() != null) {
meet = meet.meet(r.getType());
}
}
@ -668,8 +665,8 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
private TypeAbstraction meetDeclaredExceptionTypes(SSAGetCaughtExceptionInstruction s) {
ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) ir.getControlFlowGraph().getNode(s.getBasicBlockNumber());
Iterator it = bb.getCaughtExceptionTypes();
TypeReference t = (TypeReference) it.next();
Iterator<TypeReference> it = bb.getCaughtExceptionTypes();
TypeReference t = it.next();
IClass klass = cha.lookupClass(t);
TypeAbstraction result = null;
if (klass == null) {
@ -680,7 +677,7 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
result = new ConeType(klass);
}
while (it.hasNext()) {
t = (TypeReference) it.next();
t = it.next();
IClass tClass = cha.lookupClass(t);
if (tClass == null) {
result = BOTTOM;

View File

@ -537,8 +537,7 @@ public abstract class AbstractCFG<I, T extends IBasicBlock<I>> implements Contro
@Override
public String toString() {
StringBuffer s = new StringBuffer("");
for (Iterator<T> it = iterator(); it.hasNext();) {
T bb = it.next();
for (T bb : this) {
s.append("BB").append(getNumber(bb)).append("\n");
Iterator<T> succNodes = getSuccNodes(bb);

View File

@ -48,15 +48,14 @@ public class CFGSanitizer {
ControlFlowGraph<SSAInstruction, ISSABasicBlock> cfg = ir.getControlFlowGraph();
Graph<ISSABasicBlock> g = SlowSparseNumberedGraph.make();
// add all nodes to the graph
for (Iterator<? extends ISSABasicBlock> it = cfg.iterator(); it.hasNext();) {
g.addNode(it.next());
for (ISSABasicBlock basicBlock : cfg) {
g.addNode(basicBlock);
}
// add all edges to the graph, except those that go to exit
for (Iterator it = cfg.iterator(); it.hasNext();) {
ISSABasicBlock b = (ISSABasicBlock) it.next();
for (Iterator it2 = cfg.getSuccNodes(b); it2.hasNext();) {
ISSABasicBlock b2 = (ISSABasicBlock) it2.next();
for (ISSABasicBlock b : cfg) {
for (Iterator<ISSABasicBlock> it2 = cfg.getSuccNodes(b); it2.hasNext();) {
ISSABasicBlock b2 = it2.next();
if (!b2.isExitBlock()) {
g.addEdge(b, b2);
@ -67,9 +66,9 @@ public class CFGSanitizer {
// now add edges to exit, ignoring undeclared exceptions
ISSABasicBlock exit = cfg.exit();
for (Iterator it = cfg.getPredNodes(exit); it.hasNext();) {
for (Iterator<ISSABasicBlock> it = cfg.getPredNodes(exit); it.hasNext();) {
// for each predecessor of exit ...
ISSABasicBlock b = (ISSABasicBlock) it.next();
ISSABasicBlock b = it.next();
SSAInstruction s = ir.getInstructions()[b.getLastInstructionIndex()];
if (s == null) {
@ -90,14 +89,14 @@ public class CFGSanitizer {
Assertions.UNREACHABLE();
}
// remove any exceptions that are caught by catch blocks
for (Iterator it2 = cfg.getSuccNodes(b); it2.hasNext();) {
IBasicBlock c = (IBasicBlock) it2.next();
for (Iterator<ISSABasicBlock> it2 = cfg.getSuccNodes(b); it2.hasNext();) {
IBasicBlock c = it2.next();
if (c.isCatchBlock()) {
SSACFG.ExceptionHandlerBasicBlock cb = (ExceptionHandlerBasicBlock) c;
for (Iterator it3 = cb.getCaughtExceptionTypes(); it3.hasNext();) {
TypeReference ex = (TypeReference) it3.next();
for (Iterator<TypeReference> it3 = cb.getCaughtExceptionTypes(); it3.hasNext();) {
TypeReference ex = it3.next();
IClass exClass = cha.lookupClass(ex);
if (exClass == null) {
throw new WalaException("failed to find " + ex);
@ -125,17 +124,17 @@ public class CFGSanitizer {
Assertions.UNREACHABLE();
}
if (declared != null && exceptions != null) {
for (int i = 0; i < exceptions.length; i++) {
for (TypeReference exception : exceptions) {
boolean isDeclared = false;
if (exceptions[i] != null) {
IClass exi = cha.lookupClass(exceptions[i]);
if (exception != null) {
IClass exi = cha.lookupClass(exception);
if (exi == null) {
throw new WalaException("failed to find " + exceptions[i]);
throw new WalaException("failed to find " + exception);
}
for (int j = 0; j < declared.length; j++) {
IClass dc = cha.lookupClass(declared[j]);
for (TypeReference element : declared) {
IClass dc = cha.lookupClass(element);
if (dc == null) {
throw new WalaException("failed to find " + declared[j]);
throw new WalaException("failed to find " + element);
}
if (cha.isSubclassOf(exi, dc)) {
isDeclared = true;
@ -158,7 +157,7 @@ public class CFGSanitizer {
* What are the exception types which s may throw?
*/
private static TypeReference[] computeExceptions(IClassHierarchy cha, IR ir, SSAInstruction s) throws InvalidClassFileException {
Collection c = null;
Collection<TypeReference> c = null;
Language l = ir.getMethod().getDeclaringClass().getClassLoader().getLanguage();
if (s instanceof SSAInvokeInstruction) {
SSAInvokeInstruction call = (SSAInvokeInstruction) s;
@ -170,9 +169,9 @@ public class CFGSanitizer {
return null;
} else {
TypeReference[] exceptions = new TypeReference[c.size()];
Iterator it = c.iterator();
Iterator<TypeReference> it = c.iterator();
for (int i = 0; i < exceptions.length; i++) {
exceptions[i] = (TypeReference) it.next();
exceptions[i] = it.next();
}
return exceptions;
}

View File

@ -120,8 +120,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
* Compute outgoing edges in the control flow graph.
*/
private void computeEdges() {
for (Iterator it = iterator(); it.hasNext();) {
BasicBlock b = (BasicBlock) it.next();
for (BasicBlock b : this) {
if (b.equals(exit()))
continue;
b.computeOutgoingEdges();
@ -471,8 +470,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
int tgtNd = getIndexFromIIndex(tgt); // index in instructions-array
BasicBlock target = null;
for (Iterator it = InducedCFG.this.iterator(); it.hasNext();) {
final BasicBlock candid = (BasicBlock) it.next();
for (BasicBlock candid : InducedCFG.this) {
if (candid.getFirstInstructionIndex() == tgtNd) {
target = candid;
break;
@ -623,8 +621,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
@Override
public String toString() {
StringBuffer s = new StringBuffer("");
for (Iterator it = iterator(); it.hasNext();) {
BasicBlock bb = (BasicBlock) it.next();
for (BasicBlock bb : this) {
s.append("BB").append(getNumber(bb)).append("\n");
for (int j = bb.getFirstInstructionIndex(); j <= bb.getLastInstructionIndex(); j++) {
s.append(" ").append(j).append(" ").append(getInstructions()[j]).append("\n");
@ -697,8 +694,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
public Collection<SSAPhiInstruction> getAllPhiInstructions() {
Collection<SSAPhiInstruction> result = HashSetFactory.make();
for (Iterator<BasicBlock> it = iterator(); it.hasNext();) {
BasicBlock b = it.next();
for (BasicBlock b : this) {
result.addAll(b.getPhis());
}
return result;

View File

@ -111,8 +111,7 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
*/
private void computeI2BMapping() {
instruction2Block = new int[getInstructions().length];
for (Iterator it = iterator(); it.hasNext();) {
final BasicBlock b = (BasicBlock) it.next();
for (BasicBlock b : this) {
for (int j = b.getFirstInstructionIndex(); j <= b.getLastInstructionIndex(); j++) {
instruction2Block[j] = getNumber(b);
}
@ -123,8 +122,7 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
* Compute outgoing edges in the control flow graph.
*/
private void computeEdges() {
for (Iterator it = iterator(); it.hasNext();) {
BasicBlock b = (BasicBlock) it.next();
for (BasicBlock b : this) {
if (b.equals(exit())) {
continue;
} else if (b.equals(entry())) {
@ -238,8 +236,8 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
IInstruction last = getInstructions()[getLastInstructionIndex()];
int[] targets = last.getBranchTargets();
for (int i = 0; i < targets.length; i++) {
BasicBlock b = getBlockForInstruction(targets[i]);
for (int target : targets) {
BasicBlock b = getBlockForInstruction(target);
addNormalEdgeTo(b);
}
addExceptionalEdges(last);
@ -310,11 +308,11 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
// this var gets set to false if goToAllHandlers is true but some enclosing exception handler catches all
// exceptions. in such a case, we need not add an exceptional edge to the method exit
boolean needEdgeToExitForAllHandlers = true;
for (int j = 0; j < hs.length; j++) {
for (ExceptionHandler element : hs) {
if (DEBUG) {
System.err.println(" handler " + hs[j]);
System.err.println(" handler " + element);
}
BasicBlock b = getBlockForInstruction(hs[j].getHandler());
BasicBlock b = getBlockForInstruction(element.getHandler());
if (DEBUG) {
System.err.println(" target " + b);
}
@ -325,15 +323,15 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
}
addExceptionalEdgeTo(b);
// if the handler catches all exceptions, we don't need to add an edge to the exit or any other handlers
if (hs[j].getCatchClass() == null) {
if (element.getCatchClass() == null) {
needEdgeToExitForAllHandlers = false;
break;
}
} else {
TypeReference caughtException = null;
if (hs[j].getCatchClass() != null) {
if (element.getCatchClass() != null) {
ClassLoaderReference loader = ShrikeCFG.this.getMethod().getDeclaringClass().getReference().getClassLoader();
caughtException = ShrikeUtil.makeTypeReference(loader, hs[j].getCatchClass());
caughtException = ShrikeUtil.makeTypeReference(loader, element.getCatchClass());
if (DEBUG) {
System.err.println(" caughtException " + caughtException);
}
@ -502,8 +500,7 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
@Override
public String toString() {
StringBuffer s = new StringBuffer("");
for (Iterator it = iterator(); it.hasNext();) {
BasicBlock bb = (BasicBlock) it.next();
for (BasicBlock bb : this) {
s.append("BB").append(getNumber(bb)).append("\n");
for (int j = bb.getFirstInstructionIndex(); j <= bb.getLastInstructionIndex(); j++) {
s.append(" ").append(j).append(" ").append(getInstructions()[j]).append("\n");

View File

@ -214,7 +214,7 @@ public class Util {
throw new IllegalArgumentException("b is null");
}
int i = 0;
for (Iterator it = cfg.getPredNodes(b); it.hasNext();) {
for (Iterator<T> it = cfg.getPredNodes(b); it.hasNext();) {
if (it.next().equals(a)) {
return i;
}

View File

@ -66,13 +66,12 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
edgeLabels = HashMapFactory.make();
}
for (Iterator<? extends T> ns = cfg.iterator(); ns.hasNext();) {
for (T name : cfg) {
HashSet<T> s = HashSetFactory.make(2);
controlDependence.put(ns.next(), s);
controlDependence.put(name, s);
}
for (Iterator<? extends T> ns = cfg.iterator(); ns.hasNext();) {
T y = ns.next();
for (T y : cfg) {
for (Iterator<T> ns2 = RDF.getDominanceFrontier(y); ns2.hasNext();) {
T x = ns2.next();
controlDependence.get(x).add(y);
@ -104,14 +103,13 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
return new NumberedEdgeManager<T>() {
Map<T, Set<T>> backwardEdges = HashMapFactory.make(forwardEdges.size());
{
for (Iterator<? extends T> x = cfg.iterator(); x.hasNext();) {
for (T name : cfg) {
Set<T> s = HashSetFactory.make();
backwardEdges.put(x.next(), s);
backwardEdges.put(name, s);
}
for (Iterator<T> ps = forwardEdges.keySet().iterator(); ps.hasNext();) {
T p = ps.next();
for (Iterator ns = ((Set) forwardEdges.get(p)).iterator(); ns.hasNext();) {
Object n = ns.next();
for (T p : forwardEdges.keySet()) {
for (T t : forwardEdges.get(p)) {
Object n = t;
backwardEdges.get(n).add(p);
}
}
@ -206,15 +204,14 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
for (Iterator<? extends T> ns = iterator(); ns.hasNext();) {
T n = ns.next();
for (T n : this) {
sb.append(n.toString()).append("\n");
for (Iterator ss = getSuccNodes(n); ss.hasNext();) {
for (Iterator<T> ss = getSuccNodes(n); ss.hasNext();) {
Object s = ss.next();
sb.append(" --> ").append(s);
if (edgeLabels != null)
for (Iterator labels = ((Set) edgeLabels.get(Pair.make(n, s))).iterator(); labels.hasNext();)
sb.append("\n label: ").append(labels.next());
for (Object name : edgeLabels.get(Pair.make(n, s)))
sb.append("\n label: ").append(name);
sb.append("\n");
}
}

View File

@ -221,8 +221,8 @@ public class NullPointerState extends AbstractVariable<NullPointerState> {
@Override
public String toString() {
StringBuffer buf = new StringBuffer("<");
for (int i = 0; i < vars.length; i++) {
switch (vars[i]) {
for (State var : vars) {
switch (var) {
case BOTH:
buf.append('*');
break;

View File

@ -503,8 +503,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
protected Collection<IClass> computeAllInterfacesAsCollection() {
Collection<? extends IClass> c = getDirectInterfaces();
Set<IClass> result = HashSetFactory.make();
for (Iterator<? extends IClass> it = c.iterator(); it.hasNext();) {
IClass klass = it.next();
for (IClass klass : c) {
if (klass.isInterface()) {
result.add(klass);
} else {
@ -538,8 +537,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
*/
private Collection<IClass> array2IClassSet(ImmutableByteArray[] interfaces) {
ArrayList<IClass> result = new ArrayList<IClass>(interfaces.length);
for (int i = 0; i < interfaces.length; i++) {
ImmutableByteArray name = interfaces[i];
for (ImmutableByteArray name : interfaces) {
IClass klass = null;
klass = loader.lookupClass(TypeName.findOrCreate(name));
if (klass == null) {
@ -556,17 +554,17 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
List<IField> result = new ArrayList<IField>(1);
if (instanceFields != null) {
for (int i = 0; i < instanceFields.length; i++) {
if (instanceFields[i].getName() == name) {
result.add(instanceFields[i]);
for (IField instanceField : instanceFields) {
if (instanceField.getName() == name) {
result.add(instanceField);
}
}
}
if (staticFields != null) {
for (int i = 0; i < staticFields.length; i++) {
if (staticFields[i].getName() == name) {
result.add(staticFields[i]);
for (IField staticField : staticFields) {
if (staticField.getName() == name) {
result.add(staticField);
}
}
}
@ -603,8 +601,7 @@ public abstract class BytecodeClass<T extends IClassLoader> implements IClass {
} else {
tmpMethodMap= new SmallMap<Selector, IMethod>();
}
for (int i = 0; i < methods.length; i++) {
IMethod m = methods[i];
for (IMethod m : methods) {
tmpMethodMap.put(m.getReference().getSelector(), m);
}

View File

@ -125,8 +125,8 @@ public class ClassLoaderImpl implements IClassLoader {
System.err.println("Get source files for " + M);
}
HashSet<ModuleEntry> result = HashSetFactory.make();
for (Iterator it = M.getEntries(); it.hasNext();) {
ModuleEntry entry = (ModuleEntry) it.next();
for (Iterator<? extends ModuleEntry> it = M.getEntries(); it.hasNext();) {
ModuleEntry entry = it.next();
if (DEBUG_LEVEL > 0) {
System.err.println("consider entry for source information: " + entry);
}
@ -155,8 +155,8 @@ public class ClassLoaderImpl implements IClassLoader {
System.err.println("Get class files for " + M);
}
HashSet<ModuleEntry> result = HashSetFactory.make();
for (Iterator it = M.getEntries(); it.hasNext();) {
ModuleEntry entry = (ModuleEntry) it.next();
for (Iterator<? extends ModuleEntry> it = M.getEntries(); it.hasNext();) {
ModuleEntry entry = it.next();
if (DEBUG_LEVEL > 0) {
System.err.println("ClassLoaderImpl.getClassFiles:Got entry: " + entry);
}
@ -183,13 +183,11 @@ public class ClassLoaderImpl implements IClassLoader {
*/
private static void removeClassFiles(Set<ModuleEntry> s, Set<ModuleEntry> t) {
Set<String> old = HashSetFactory.make();
for (Iterator<ModuleEntry> it = t.iterator(); it.hasNext();) {
ModuleEntry m = it.next();
for (ModuleEntry m : t) {
old.add(m.getClassName());
}
HashSet<ModuleEntry> toRemove = HashSetFactory.make();
for (Iterator<ModuleEntry> it = s.iterator(); it.hasNext();) {
ModuleEntry m = it.next();
for (ModuleEntry m : s) {
if (old.contains(m.getClassName())) {
toRemove.add(m);
}
@ -243,8 +241,7 @@ public class ClassLoaderImpl implements IClassLoader {
*/
@SuppressWarnings("unused")
private void loadAllClasses(Collection<ModuleEntry> moduleEntries, Map<String, Object> fileContents) {
for (Iterator<ModuleEntry> it = moduleEntries.iterator(); it.hasNext();) {
ModuleEntry entry = it.next();
for (ModuleEntry entry : moduleEntries) {
if (!entry.isClassFile()) {
continue;
}
@ -411,8 +408,7 @@ public class ClassLoaderImpl implements IClassLoader {
*/
@SuppressWarnings("unused")
protected void loadAllSources(Set<ModuleEntry> sourceModules) {
for (Iterator<ModuleEntry> it = sourceModules.iterator(); it.hasNext();) {
ModuleEntry entry = it.next();
for (ModuleEntry entry : sourceModules) {
String className = entry.getClassName().replace('.', '/');
className = className.replace(File.separatorChar, '/');
className = "L" + ((className.startsWith("/")) ? className.substring(1) : className);
@ -489,8 +485,7 @@ public class ClassLoaderImpl implements IClassLoader {
// module are loaded according to the given order (same as in Java VM)
Set<ModuleEntry> classModuleEntries = HashSetFactory.make();
Set<ModuleEntry> sourceModuleEntries = HashSetFactory.make();
for (Iterator<Module> it = modules.iterator(); it.hasNext();) {
Module archive = it.next();
for (Module archive : modules) {
if (DEBUG_LEVEL > 0) {
System.err.println("add archive: " + archive);
}
@ -524,12 +519,10 @@ public class ClassLoaderImpl implements IClassLoader {
}
loadAllClasses(classFiles, allClassAndSourceFileContents);
loadAllSources(sourceFiles);
for (Iterator<ModuleEntry> it2 = classFiles.iterator(); it2.hasNext();) {
ModuleEntry file = it2.next();
for (ModuleEntry file : classFiles) {
classModuleEntries.add(file);
}
for (Iterator<ModuleEntry> it2 = sourceFiles.iterator(); it2.hasNext();) {
ModuleEntry file = it2.next();
for (ModuleEntry file : sourceFiles) {
sourceModuleEntries.add(file);
}
}
@ -703,8 +696,7 @@ public class ClassLoaderImpl implements IClassLoader {
if (toRemove == null) {
throw new IllegalArgumentException("toRemove is null");
}
for (Iterator<IClass> it = toRemove.iterator(); it.hasNext();) {
IClass klass = it.next();
for (IClass klass : toRemove) {
if (DEBUG_LEVEL > 0) {
System.err.println("removing " + klass.getName());
}

View File

@ -161,7 +161,7 @@ public class CodeScanner {
* @throws InvalidClassFileException
* @throws IllegalArgumentException if m is null
*/
public static Iterator iterateCastTypes(IMethod m) throws InvalidClassFileException {
public static Iterator<TypeReference> iterateCastTypes(IMethod m) throws InvalidClassFileException {
if (m == null) {
throw new IllegalArgumentException("m is null");
}
@ -173,7 +173,7 @@ public class CodeScanner {
}
}
private static Iterator iterateShrikeBTCastTypes(ShrikeCTMethod wrapper) throws InvalidClassFileException {
private static Iterator<TypeReference> iterateShrikeBTCastTypes(ShrikeCTMethod wrapper) throws InvalidClassFileException {
return wrapper.getCastTypes();
}
@ -182,8 +182,8 @@ public class CodeScanner {
}
private static boolean hasShrikeBTObjectArrayStore(ShrikeCTMethod M) throws InvalidClassFileException {
for (Iterator it = M.getArraysWritten(); it.hasNext();) {
TypeReference t = (TypeReference) it.next();
for (Iterator<TypeReference> it = M.getArraysWritten(); it.hasNext();) {
TypeReference t = it.next();
if (t.isReferenceType()) {
return true;
}
@ -232,8 +232,8 @@ public class CodeScanner {
}
private static boolean hasShrikeBTObjectArrayLoad(ShrikeCTMethod M) throws InvalidClassFileException {
for (Iterator it = M.getArraysRead(); it.hasNext();) {
TypeReference t = (TypeReference) it.next();
for (Iterator<TypeReference> it = M.getArraysRead(); it.hasNext();) {
TypeReference t = it.next();
if (t.isReferenceType()) {
return true;
}
@ -257,8 +257,7 @@ public class CodeScanner {
result.addAll(t);
}
};
for (int i = 0; i < statements.length; i++) {
SSAInstruction s = statements[i];
for (SSAInstruction s : statements) {
if (s != null) {
s.visit(v);
}
@ -274,10 +273,10 @@ public class CodeScanner {
throw new IllegalArgumentException("statements == null");
}
final HashSet<TypeReference> result = HashSetFactory.make(10);
for (int i = 0; i < statements.length; i++) {
if (statements[i] != null) {
if (statements[i] instanceof SSACheckCastInstruction) {
SSACheckCastInstruction c = (SSACheckCastInstruction) statements[i];
for (SSAInstruction statement : statements) {
if (statement != null) {
if (statement instanceof SSACheckCastInstruction) {
SSACheckCastInstruction c = (SSACheckCastInstruction) statement;
for(TypeReference t : c.getDeclaredResultTypes()) {
result.add(t);
}
@ -299,8 +298,7 @@ public class CodeScanner {
result.add(instruction.getCallSite());
}
};
for (int i = 0; i < statements.length; i++) {
SSAInstruction s = statements[i];
for (SSAInstruction s : statements) {
if (s != null) {
s.visit(v);
}
@ -320,8 +318,7 @@ public class CodeScanner {
result.add(instruction.getNewSite());
}
};
for (int i = 0; i < statements.length; i++) {
SSAInstruction s = statements[i];
for (SSAInstruction s : statements) {
if (s != null) {
s.visit(v);
}
@ -345,8 +342,7 @@ public class CodeScanner {
result.add(instruction.getDeclaredField());
}
};
for (int i = 0; i < statements.length; i++) {
SSAInstruction s = statements[i];
for (SSAInstruction s : statements) {
if (s != null) {
s.visit(v);
}
@ -370,8 +366,7 @@ public class CodeScanner {
result.add(instruction.getDeclaredField());
}
};
for (int i = 0; i < statements.length; i++) {
SSAInstruction s = statements[i];
for (SSAInstruction s : statements) {
if (s != null) {
s.visit(v);
}
@ -397,8 +392,7 @@ public class CodeScanner {
}
};
for (int i = 0; i < statements.length; i++) {
SSAInstruction s = statements[i];
for (SSAInstruction s : statements) {
if (s != null) {
s.visit(v);
}
@ -422,8 +416,7 @@ public class CodeScanner {
}
}
ScanVisitor v = new ScanVisitor();
for (int i = 0; i < statements.length; i++) {
SSAInstruction s = statements[i];
for (SSAInstruction s : statements) {
if (s != null) {
s.visit(v);
}
@ -450,8 +443,7 @@ public class CodeScanner {
}
}
ScanVisitor v = new ScanVisitor();
for (int i = 0; i < statements.length; i++) {
SSAInstruction s = statements[i];
for (SSAInstruction s : statements) {
if (s != null) {
s.visit(v);
}

View File

@ -50,11 +50,11 @@ public abstract class DirectoryTreeModule implements Module {
Set<FileModule> result = HashSetFactory.make();
File[] files = dir.listFiles();
if (files != null) {
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
result.addAll(getEntriesRecursive(files[i]));
} else if (includeFile(files[i])) {
FileModule fileModule = makeFile(files[i]);
for (File file : files) {
if (file.isDirectory()) {
result.addAll(getEntriesRecursive(file));
} else if (includeFile(file)) {
FileModule fileModule = makeFile(file);
if (fileModule != null) {
result.add(fileModule);
}

View File

@ -309,7 +309,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
* @return Iterator of TypeReference
* @throws InvalidClassFileException
*/
public Iterator getArraysRead() throws InvalidClassFileException {
public Iterator<TypeReference> getArraysRead() throws InvalidClassFileException {
if (isNative()) {
return EmptyIterator.instance();
}
@ -336,7 +336,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
* @return Iterator of TypeReference
* @throws InvalidClassFileException
*/
public Iterator getCastTypes() throws InvalidClassFileException {
public Iterator<TypeReference> getCastTypes() throws InvalidClassFileException {
if (isNative()) {
return EmptyIterator.instance();
}
@ -499,56 +499,56 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
private static void copyVisitorSetsToArrays(SimpleVisitor simpleVisitor, BytecodeInfo info) {
info.newSites = new NewSiteReference[simpleVisitor.newSites.size()];
int i = 0;
for (Iterator<NewSiteReference> it = simpleVisitor.newSites.iterator(); it.hasNext();) {
info.newSites[i++] = it.next();
for (NewSiteReference newSiteReference : simpleVisitor.newSites) {
info.newSites[i++] = newSiteReference;
}
info.fieldsRead = new FieldReference[simpleVisitor.fieldsRead.size()];
i = 0;
for (Iterator<FieldReference> it = simpleVisitor.fieldsRead.iterator(); it.hasNext();) {
info.fieldsRead[i++] = it.next();
for (FieldReference fieldReference : simpleVisitor.fieldsRead) {
info.fieldsRead[i++] = fieldReference;
}
info.fieldsRead = new FieldReference[simpleVisitor.fieldsRead.size()];
i = 0;
for (Iterator<FieldReference> it = simpleVisitor.fieldsRead.iterator(); it.hasNext();) {
info.fieldsRead[i++] = it.next();
for (FieldReference fieldReference : simpleVisitor.fieldsRead) {
info.fieldsRead[i++] = fieldReference;
}
info.fieldsWritten = new FieldReference[simpleVisitor.fieldsWritten.size()];
i = 0;
for (Iterator<FieldReference> it = simpleVisitor.fieldsWritten.iterator(); it.hasNext();) {
info.fieldsWritten[i++] = it.next();
for (FieldReference fieldReference : simpleVisitor.fieldsWritten) {
info.fieldsWritten[i++] = fieldReference;
}
info.callSites = new CallSiteReference[simpleVisitor.callSites.size()];
i = 0;
for (Iterator<CallSiteReference> it = simpleVisitor.callSites.iterator(); it.hasNext();) {
info.callSites[i++] = it.next();
for (CallSiteReference callSiteReference : simpleVisitor.callSites) {
info.callSites[i++] = callSiteReference;
}
info.arraysRead = new TypeReference[simpleVisitor.arraysRead.size()];
i = 0;
for (Iterator<TypeReference> it = simpleVisitor.arraysRead.iterator(); it.hasNext();) {
info.arraysRead[i++] = it.next();
for (TypeReference typeReference : simpleVisitor.arraysRead) {
info.arraysRead[i++] = typeReference;
}
info.arraysWritten = new TypeReference[simpleVisitor.arraysWritten.size()];
i = 0;
for (Iterator<TypeReference> it = simpleVisitor.arraysWritten.iterator(); it.hasNext();) {
info.arraysWritten[i++] = it.next();
for (TypeReference typeReference : simpleVisitor.arraysWritten) {
info.arraysWritten[i++] = typeReference;
}
info.implicitExceptions = new TypeReference[simpleVisitor.implicitExceptions.size()];
i = 0;
for (Iterator it = simpleVisitor.implicitExceptions.iterator(); it.hasNext();) {
info.implicitExceptions[i++] = (TypeReference) it.next();
for (TypeReference typeReference : simpleVisitor.implicitExceptions) {
info.implicitExceptions[i++] = typeReference;
}
info.castTypes = new TypeReference[simpleVisitor.castTypes.size()];
i = 0;
for (Iterator<TypeReference> it = simpleVisitor.castTypes.iterator(); it.hasNext();) {
info.castTypes[i++] = it.next();
for (TypeReference typeReference : simpleVisitor.castTypes) {
info.castTypes[i++] = typeReference;
}
info.hasMonitorOp = simpleVisitor.hasMonitorOp;
@ -842,9 +842,9 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
}
HashSet<TypeReference> result = HashSetFactory.make(10);
ClassLoaderReference loader = getReference().getDeclaringClass().getClassLoader();
for (int i = 0; i < handlers.length; i++) {
for (int j = 0; j < handlers[i].length; j++) {
TypeReference t = ShrikeUtil.makeTypeReference(loader, handlers[i][j].getCatchClass());
for (ExceptionHandler[] handler : handlers) {
for (int j = 0; j < handler.length; j++) {
TypeReference t = ShrikeUtil.makeTypeReference(loader, handler[j].getCatchClass());
if (t == null) {
t = TypeReference.JavaLangThrowable;
}

View File

@ -12,7 +12,6 @@ package com.ibm.wala.classLoader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import com.ibm.wala.ipa.cha.IClassHierarchy;
@ -228,8 +227,8 @@ public final class ShrikeClass extends JVMClass<IClassLoader> {
public void clearSoftCaches() {
// toss optional information from each method.
if (methodMap != null) {
for (Iterator it = getDeclaredMethods().iterator(); it.hasNext();) {
ShrikeCTMethod m = (ShrikeCTMethod) it.next();
for (IMethod iMethod : getDeclaredMethods()) {
ShrikeCTMethod m = (ShrikeCTMethod) iMethod;
m.clearCaches();
}
}

View File

@ -12,7 +12,6 @@ package com.ibm.wala.client;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
import java.util.jar.JarFile;
import com.ibm.wala.analysis.pointers.BasicHeapGraph;
@ -161,8 +160,8 @@ public abstract class AbstractAnalysisEngine<I extends InstanceKey> implements A
.getClassLoader());
// add standard libraries
for (int i = 0; i < j2seLibs.length; i++) {
scope.addToScope(scope.getPrimordialLoader(), j2seLibs[i]);
for (Module j2seLib : j2seLibs) {
scope.addToScope(scope.getPrimordialLoader(), j2seLib);
}
// add user stuff
@ -210,8 +209,7 @@ public abstract class AbstractAnalysisEngine<I extends InstanceKey> implements A
*/
protected void addApplicationModulesToScope() {
ClassLoaderReference app = scope.getApplicationLoader();
for (Iterator it = moduleFiles.iterator(); it.hasNext();) {
Object o = it.next();
for (Object o : moduleFiles) {
if (!(o instanceof Module)) {
Assertions.UNREACHABLE("Unexpected type: " + o.getClass());
}

View File

@ -334,10 +334,10 @@ public class LocalPathEdges {
// this is convoluted on purpose for efficiency: to avoid random access to
// the sparse vector, we do parallel iteration with the vector's indices
// and contents. TODO: better data structure?
Iterator contents = paths.iterator();
Iterator<IBinaryNaturalRelation> contents = paths.iterator();
for (IntIterator it = paths.iterateIndices(); it.hasNext();) {
int d2 = it.next();
IBinaryNaturalRelation R = (IBinaryNaturalRelation) contents.next();
IBinaryNaturalRelation R = contents.next();
if (R != null && R.contains(n, d1)) {
result.add(d2);
}
@ -353,10 +353,10 @@ public class LocalPathEdges {
// this is convoluted on purpose for efficiency: to avoid random access to
// the sparse vector, we do parallel iteration with the vector's indices
// and contents. TODO: better data structure?
Iterator contents = zeroPaths.iterator();
Iterator<IntSet> contents = zeroPaths.iterator();
for (IntIterator it = zeroPaths.iterateIndices(); it.hasNext();) {
int d2 = it.next();
BitVectorIntSet s = (BitVectorIntSet) contents.next();
IntSet s = contents.next();
if (s != null && s.contains(n)) {
result.add(d2);
}
@ -389,10 +389,10 @@ public class LocalPathEdges {
// this is convoluted on purpose for efficiency: to avoid random access to
// the sparse vector, we do parallel iteration with the vector's indices
// and contents. TODO: better data structure?
Iterator contents = paths.iterator();
Iterator<IBinaryNaturalRelation> contents = paths.iterator();
for (IntIterator it = paths.iterateIndices(); it.hasNext();) {
int d2 = it.next();
IBinaryNaturalRelation R = (IBinaryNaturalRelation) contents.next();
IBinaryNaturalRelation R = contents.next();
if (R != null && R.anyRelated(n)) {
result.add(d2);
}
@ -402,10 +402,10 @@ public class LocalPathEdges {
// this is convoluted on purpose for efficiency: to avoid random access to
// the sparse vector, we do parallel iteration with the vector's indices
// and contents. TODO: better data structure?
Iterator contents = identityPaths.iterator();
Iterator<IntSet> contents = identityPaths.iterator();
for (IntIterator it = identityPaths.iterateIndices(); it.hasNext();) {
int d1 = it.next();
BitVectorIntSet s = (BitVectorIntSet) contents.next();
IntSet s = contents.next();
if (s != null && s.contains(n)) {
result.add(d1);
}
@ -415,10 +415,10 @@ public class LocalPathEdges {
// this is convoluted on purpose for efficiency: to avoid random access to
// the sparse vector, we do parallel iteration with the vector's indices
// and contents. TODO: better data structure?
Iterator contents = zeroPaths.iterator();
Iterator<IntSet> contents = zeroPaths.iterator();
for (IntIterator it = zeroPaths.iterateIndices(); it.hasNext();) {
int d2 = it.next();
BitVectorIntSet s = (BitVectorIntSet) contents.next();
IntSet s = contents.next();
if (s != null && s.contains(n)) {
result.add(d2);
}

View File

@ -10,8 +10,6 @@
*******************************************************************************/
package com.ibm.wala.dataflow.IFDS;
import java.util.Iterator;
import com.ibm.wala.util.collections.SparseVector;
import com.ibm.wala.util.intset.BasicNaturalRelation;
import com.ibm.wala.util.intset.IBinaryNaturalRelation;
@ -133,8 +131,7 @@ public class LocalSummaryEdges {
return null;
} else {
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
for (Iterator it = R.iterator(); it.hasNext();) {
IntPair p = (IntPair) it.next();
for (IntPair p : R) {
if (p.getY() == d2) {
result.add(p.getX());
}

View File

@ -486,8 +486,7 @@ public class TabulationSolver<T, P, F> {
// with respect to one s_profOf(c), we have to propagate
// for each
// potential entry node s_p /in s_procof(c)
for (int i = 0; i < entries.length; i++) {
final T s_p = entries[i];
for (final T s_p : entries) {
if (DEBUG_LEVEL > 1) {
System.err.println(" do entry " + s_p);
}
@ -651,8 +650,7 @@ public class TabulationSolver<T, P, F> {
// for each exit from the callee
P p = supergraph.getProcOf(calleeEntry);
T[] exits = supergraph.getExitsForProcedure(p);
for (int e = 0; e < exits.length; e++) {
final T exit = exits[e];
for (final T exit : exits) {
if (DEBUG_LEVEL > 0) {
assert supergraph.containsNode(exit);
}
@ -923,8 +921,7 @@ public class TabulationSolver<T, P, F> {
IBasicBlock bb2 = (IBasicBlock) o2;
return bb1.getNumber() - bb2.getNumber();
};
for (Iterator<? extends T> it = supergraph.iterator(); it.hasNext();) {
T n = it.next();
for (T n : supergraph) {
P proc = supergraph.getProcOf(n);
TreeSet<T> s = map.get(proc);
if (s == null) {
@ -934,11 +931,9 @@ public class TabulationSolver<T, P, F> {
s.add(n);
}
for (Iterator<Map.Entry<Object, TreeSet<T>>> it = map.entrySet().iterator(); it.hasNext();) {
Map.Entry<Object, TreeSet<T>> e = it.next();
for (Entry<Object, TreeSet<T>> e : map.entrySet()) {
Set<T> s = e.getValue();
for (Iterator<T> it2 = s.iterator(); it2.hasNext();) {
T o = it2.next();
for (T o : s) {
result.append(o + " : " + getResult(o) + "\n");
}
}

View File

@ -82,20 +82,19 @@ public abstract class SSAInference<T extends IVariable<T>> extends DefaultFixedP
private void createEquations(OperatorFactory<T> opFactory) {
SSAInstruction[] instructions = ir.getInstructions();
for (int i = 0; i < instructions.length; i++) {
SSAInstruction s = instructions[i];
for (SSAInstruction s : instructions) {
makeEquationForInstruction(opFactory, s);
}
for (Iterator it = ir.iteratePhis(); it.hasNext();) {
SSAInstruction s = (SSAInstruction) it.next();
for (Iterator<? extends SSAInstruction> it = ir.iteratePhis(); it.hasNext();) {
SSAInstruction s = it.next();
makeEquationForInstruction(opFactory, s);
}
for (Iterator it = ir.iteratePis(); it.hasNext();) {
SSAInstruction s = (SSAInstruction) it.next();
for (Iterator<? extends SSAInstruction> it = ir.iteratePis(); it.hasNext();) {
SSAInstruction s = it.next();
makeEquationForInstruction(opFactory, s);
}
for (Iterator it = ir.iterateCatchInstructions(); it.hasNext();) {
SSAInstruction s = (SSAInstruction) it.next();
for (Iterator<? extends SSAInstruction> it = ir.iterateCatchInstructions(); it.hasNext();) {
SSAInstruction s = it.next();
makeEquationForInstruction(opFactory, s);
}
}

View File

@ -1287,8 +1287,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
// }
g.addSubgraphForNode(caller);
SSAAbstractInvokeInstruction[] callInstrs = getCallInstrs(caller, call);
for (int i = 0; i < callInstrs.length; i++) {
SSAAbstractInvokeInstruction callInstr = callInstrs[i];
for (SSAAbstractInvokeInstruction callInstr : callInstrs) {
PointerKey actualPk = heapModel.getPointerKeyForLocal(caller, callInstr.getUse(paramPos));
assert g.containsNode(actualPk);
assert g.containsNode(localPk);
@ -1575,8 +1574,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
// }
g.addSubgraphForNode(caller);
SSAAbstractInvokeInstruction[] callInstrs = getCallInstrs(caller, call);
for (int i = 0; i < callInstrs.length; i++) {
SSAAbstractInvokeInstruction callInstr = callInstrs[i];
for (SSAAbstractInvokeInstruction callInstr : callInstrs) {
PointerKey returnAtCallerKey = heapModel.getPointerKeyForLocal(caller, isExceptional ? callInstr.getException()
: callInstr.getDef());
assert g.containsNode(returnAtCallerKey);
@ -2050,8 +2048,7 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
// }
g.addSubgraphForNode(caller);
SSAAbstractInvokeInstruction[] callInstrs = getCallInstrs(caller, call);
for (int i = 0; i < callInstrs.length; i++) {
SSAAbstractInvokeInstruction callInstr = callInstrs[i];
for (SSAAbstractInvokeInstruction callInstr : callInstrs) {
final PointerKey actualPk = heapModel.getPointerKeyForLocal(caller, callInstr.getUse(paramPos));
assert g.containsNode(actualPk);
assert g.containsNode(localPk);

View File

@ -134,8 +134,7 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
CallSiteReference call = iterator.next();
if (cg.getPossibleTargets(caller, call).contains(cgNode)) {
SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call);
for (int i = 0; i < callInstrs.length; i++) {
SSAAbstractInvokeInstruction callInstr = callInstrs[i];
for (SSAAbstractInvokeInstruction callInstr : callInstrs) {
PointerKey actualPk = heapModel.getPointerKeyForLocal(caller, callInstr.getUse(paramPos));
assert containsNode(actualPk);
assert containsNode(pk);
@ -224,8 +223,7 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
CallSiteReference call = iterator.next();
if (cg.getPossibleTargets(caller, call).contains(cgNode)) {
SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call);
for (int i = 0; i < callInstrs.length; i++) {
SSAAbstractInvokeInstruction callInstr = callInstrs[i];
for (SSAAbstractInvokeInstruction callInstr : callInstrs) {
PointerKey returnPk = heapModel.getPointerKeyForLocal(caller, isExceptional ? callInstr.getException() : callInstr
.getDef());
assert containsNode(returnPk);
@ -284,8 +282,7 @@ public abstract class AbstractDemandFlowGraph extends AbstractFlowGraph {
v.setBasicBlock(b);
// visit each instruction in the basic block.
for (Iterator<SSAInstruction> it = b.iterator(); it.hasNext();) {
SSAInstruction s = it.next();
for (SSAInstruction s : b) {
if (s != null) {
s.visit(v);
}

View File

@ -385,13 +385,11 @@ public abstract class AbstractFlowGraph extends SlowSparseNumberedLabeledGraph<O
protected Iterator<PointerKey> getArrayReads(PointerKey arrayRef) {
arrayRef = convertPointerKeyToHeapModel(arrayRef, mam.getHeapModel());
Collection<MemoryAccess> arrayReads = mam.getArrayReads(arrayRef);
for (Iterator<MemoryAccess> it = arrayReads.iterator(); it.hasNext();) {
MemoryAccess a = it.next();
for (MemoryAccess a : arrayReads) {
addSubgraphForNode(a.getNode());
}
ArrayList<PointerKey> read = new ArrayList<PointerKey>();
for (Iterator<MemoryAccess> it = arrayReads.iterator(); it.hasNext();) {
MemoryAccess a = it.next();
for (MemoryAccess a : arrayReads) {
IR ir = a.getNode().getIR();
SSAArrayLoadInstruction s = (SSAArrayLoadInstruction) ir.getInstructions()[a.getInstructionIndex()];
if (s == null) {
@ -430,8 +428,7 @@ public abstract class AbstractFlowGraph extends SlowSparseNumberedLabeledGraph<O
*/
protected void addExceptionDefConstraints(IR ir, CGNode node, List<ProgramCounter> peis, PointerKey exceptionVar,
Set<IClass> catchClasses) {
for (Iterator<ProgramCounter> it = peis.iterator(); it.hasNext();) {
ProgramCounter peiLoc = it.next();
for (ProgramCounter peiLoc : peis) {
SSAInstruction pei = ir.getPEI(peiLoc);
if (pei instanceof SSAAbstractInvokeInstruction) {
@ -454,8 +451,7 @@ public abstract class AbstractFlowGraph extends SlowSparseNumberedLabeledGraph<O
// the pei, but just instance keys
Collection<TypeReference> types = pei.getExceptionTypes();
if (types != null) {
for (Iterator<TypeReference> it2 = types.iterator(); it2.hasNext();) {
TypeReference type = it2.next();
for (TypeReference type : types) {
if (type != null) {
InstanceKey ik = heapModel.getInstanceKeyForPEI(node, peiLoc, type);
if (ik == null) {

View File

@ -409,8 +409,7 @@ public class DemandPointerFlowGraph extends AbstractDemandFlowGraph implements I
*/
protected void addExceptionDefConstraints(IR ir, CGNode node, List<ProgramCounter> peis, PointerKey exceptionVar,
Set<IClass> catchClasses) {
for (Iterator<ProgramCounter> it = peis.iterator(); it.hasNext();) {
ProgramCounter peiLoc = it.next();
for (ProgramCounter peiLoc : peis) {
SSAInstruction pei = ir.getPEI(peiLoc);
if (pei instanceof SSAAbstractInvokeInstruction) {
@ -433,8 +432,7 @@ public class DemandPointerFlowGraph extends AbstractDemandFlowGraph implements I
// the pei, but just instance keys
Collection<TypeReference> types = pei.getExceptionTypes();
if (types != null) {
for (Iterator<TypeReference> it2 = types.iterator(); it2.hasNext();) {
TypeReference type = it2.next();
for (TypeReference type : types) {
if (type != null) {
InstanceKey ik = heapModel.getInstanceKeyForPEI(node, peiLoc, type);
if (ik == null) {

View File

@ -305,8 +305,7 @@ public class SimpleDemandPointerFlowGraph extends SlowSparseNumberedGraph<Object
CallSiteReference call = iterator.next();
if (cg.getPossibleTargets(caller, call).contains(node)) {
SSAAbstractInvokeInstruction[] callInstrs = ir.getCalls(call);
for (int i = 0; i < callInstrs.length; i++) {
SSAAbstractInvokeInstruction callInstr = callInstrs[i];
for (SSAAbstractInvokeInstruction callInstr : callInstrs) {
PointerKey actualPk = heapModel.getPointerKeyForLocal(caller, callInstr.getUse(paramPos));
assert containsNode(actualPk);
assert containsNode(pk);
@ -483,8 +482,7 @@ public class SimpleDemandPointerFlowGraph extends SlowSparseNumberedGraph<Object
v.setBasicBlock(b);
// visit each instruction in the basic block.
for (Iterator<SSAInstruction> it = b.iterator(); it.hasNext();) {
SSAInstruction s = it.next();
for (SSAInstruction s : b) {
if (s != null) {
s.visit(v);
}

View File

@ -12,7 +12,6 @@ package com.ibm.wala.demandpa.util;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@ -94,8 +93,7 @@ public class SimpleMemoryAccessMap implements MemoryAccessMap {
}
private void populate(CallGraph cg) {
for (Iterator<CGNode> it = cg.iterator(); it.hasNext();) {
CGNode n = it.next();
for (CGNode n : cg) {
populate(n);
}
}
@ -387,21 +385,20 @@ public class SimpleMemoryAccessMap implements MemoryAccessMap {
allFields.addAll(readMap.keySet());
allFields.addAll(writeMap.keySet());
for (Iterator<IField> it = allFields.iterator(); it.hasNext();) {
IField f = it.next();
for (IField f : allFields) {
result.append("FIELD ").append(f).append(":\n");
Collection<MemoryAccess> reads = getFieldReads(null, f);
if (!reads.isEmpty()) {
result.append(" reads:\n");
for (Iterator<MemoryAccess> it2 = reads.iterator(); it2.hasNext();) {
result.append(" ").append(it2.next()).append("\n");
for (MemoryAccess memoryAccess : reads) {
result.append(" ").append(memoryAccess).append("\n");
}
}
Collection<MemoryAccess> writes = getFieldWrites(null, f);
if (!writes.isEmpty()) {
result.append(" writes:\n");
for (Iterator<MemoryAccess> it2 = writes.iterator(); it2.hasNext();) {
result.append(" ").append(it2.next()).append("\n");
for (MemoryAccess memoryAccess : writes) {
result.append(" ").append(memoryAccess).append("\n");
}
}
}
@ -410,14 +407,14 @@ public class SimpleMemoryAccessMap implements MemoryAccessMap {
result.append("ARRAY CONTENTS:\n");
if (!arrayReads.isEmpty()) {
result.append(" reads:\n");
for (Iterator<MemoryAccess> it2 = arrayReads.iterator(); it2.hasNext();) {
result.append(" ").append(it2.next()).append("\n");
for (MemoryAccess memoryAccess : arrayReads) {
result.append(" ").append(memoryAccess).append("\n");
}
}
if (!arrayWrites.isEmpty()) {
result.append(" writes:\n");
for (Iterator<MemoryAccess> it2 = arrayWrites.iterator(); it2.hasNext();) {
result.append(" ").append(it2.next()).append("\n");
for (MemoryAccess memoryAccess : arrayWrites) {
result.append(" ").append(memoryAccess).append("\n");
}
}
return result.toString();

View File

@ -125,8 +125,8 @@ public class FILiveObjectAnalysis implements ILiveObjectAnalysis {
}
private boolean mayBeLiveInSomeCaller(InstanceKey ik, CGNode m) {
for (Iterator it = callGraph.getPredNodes(m); it.hasNext();) {
CGNode n = (CGNode) it.next();
for (Iterator<CGNode> it = callGraph.getPredNodes(m); it.hasNext();) {
CGNode n = it.next();
if (mayBeLive(ik, n, -1)) {
return true;
}
@ -144,7 +144,7 @@ public class FILiveObjectAnalysis implements ILiveObjectAnalysis {
IR ir = m.getIR();
DefUse du = m.getDU();
for (Iterator it = DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik); it.hasNext();) {
for (Iterator<Object> it = DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik); it.hasNext();) {
Object p = it.next();
if (p instanceof LocalPointerKey) {
LocalPointerKey lpk = (LocalPointerKey) p;
@ -164,7 +164,7 @@ public class FILiveObjectAnalysis implements ILiveObjectAnalysis {
*/
private Set<CGNode> computeLiveNodes(InstanceKey ik) {
Set<CGNode> localRootNodes = HashSetFactory.make();
for (Iterator it = DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik); it.hasNext();) {
for (Iterator<Object> it = DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik); it.hasNext();) {
Object node = it.next();
if (node instanceof StaticFieldKey) {
liveEverywhere.add(ik);

View File

@ -95,10 +95,9 @@ public class LocalLiveRangeAnalysis {
private static Collection<BasicBlock> findBlocks(IR ir, Iterator<SSAInstruction> statements) {
Collection<SSAInstruction> s = Iterator2Collection.toSet(statements);
Collection<BasicBlock> result = HashSetFactory.make();
outer: for (Iterator it = ir.getControlFlowGraph().iterator(); it.hasNext();) {
SSACFG.BasicBlock b = (SSACFG.BasicBlock) it.next();
for (Iterator it2 = b.iterator(); it2.hasNext();) {
SSAInstruction x = (SSAInstruction) it2.next();
outer: for (ISSABasicBlock issaBasicBlock : ir.getControlFlowGraph()) {
SSACFG.BasicBlock b = (SSACFG.BasicBlock) issaBasicBlock;
for (SSAInstruction x : b) {
if (s.contains(x)) {
result.add(b);
continue outer;
@ -120,10 +119,9 @@ public class LocalLiveRangeAnalysis {
if (s == null) {
Assertions.UNREACHABLE();
}
for (Iterator it = ir.getControlFlowGraph().iterator(); it.hasNext();) {
SSACFG.BasicBlock b = (SSACFG.BasicBlock) it.next();
for (Iterator it2 = b.iterator(); it2.hasNext();) {
SSAInstruction x = (SSAInstruction) it2.next();
for (ISSABasicBlock issaBasicBlock : ir.getControlFlowGraph()) {
SSACFG.BasicBlock b = (SSACFG.BasicBlock) issaBasicBlock;
for (SSAInstruction x : b) {
if (s.equals(x)) {
return b;
}
@ -139,8 +137,8 @@ public class LocalLiveRangeAnalysis {
* @return the basic block which contains the ith instruction
*/
private static ISSABasicBlock findBlock(IR ir, int i) {
for (Iterator it = ir.getControlFlowGraph().iterator(); it.hasNext();) {
SSACFG.BasicBlock b = (SSACFG.BasicBlock) it.next();
for (ISSABasicBlock issaBasicBlock : ir.getControlFlowGraph()) {
SSACFG.BasicBlock b = (SSACFG.BasicBlock) issaBasicBlock;
if (i >= b.getFirstInstructionIndex() && i <= b.getLastInstructionIndex()) {
return b;
}

View File

@ -69,7 +69,7 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
}
// allocN := set of call graph nodes representing method allocMethod
Set allocN = cg.getNodes(allocMethod);
Set<CGNode> allocN = cg.getNodes(allocMethod);
if (allocN.size() == 0) {
throw new WalaException("could not find call graph node for allocation method " + allocMethod);
}
@ -89,11 +89,10 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
* { nodes }
* @throws WalaException
*/
private boolean mayEscape(Set allocN, int allocPC, Set nodes) throws WalaException {
private boolean mayEscape(Set<CGNode> allocN, int allocPC, Set nodes) throws WalaException {
Set<InstanceKey> instances = HashSetFactory.make();
// instances := set of instance key allocated at &lt;allocMethod, allocPC>
for (Iterator it = allocN.iterator(); it.hasNext();) {
CGNode n = (CGNode) it.next();
for (CGNode n : allocN) {
NewSiteReference site = findAlloc(n, allocPC);
InstanceKey ik = hg.getHeapModel().getInstanceKeyForAllocation(n, site);
if (ik == null) {
@ -102,9 +101,8 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
instances.add(ik);
}
for (Iterator<InstanceKey> it = instances.iterator(); it.hasNext();) {
InstanceKey ik = it.next();
for (Iterator it2 = hg.getPredNodes(ik); it2.hasNext();) {
for (InstanceKey ik : instances) {
for (Iterator<Object> it2 = hg.getPredNodes(ik); it2.hasNext();) {
PointerKey p = (PointerKey) it2.next();
if (!(p instanceof AbstractLocalPointerKey)) {
// a pointer from the heap. give up.
@ -136,8 +134,8 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
if (n == null) {
throw new IllegalArgumentException("null n");
}
for (Iterator it = n.iterateNewSites(); it.hasNext();) {
NewSiteReference site = (NewSiteReference) it.next();
for (Iterator<NewSiteReference> it = n.iterateNewSites(); it.hasNext();) {
NewSiteReference site = it.next();
if (site.getProgramCounter() == allocPC) {
return site;
}

View File

@ -12,7 +12,6 @@ package com.ibm.wala.ipa.callgraph;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import com.ibm.wala.classLoader.IMethod;
@ -116,8 +115,7 @@ public class CallGraphStats {
Set<CGNode> reachableNodes = DFS.getReachableNodes(cg, Collections.singleton(cg.getFakeRootNode()));
int nNodes = 0;
int nEdges = 0;
for (Iterator<CGNode> it = reachableNodes.iterator(); it.hasNext();) {
CGNode n = it.next();
for (CGNode n : reachableNodes) {
nNodes++;
nEdges += cg.getSuccNodeCount(n);
}
@ -142,8 +140,7 @@ public class CallGraphStats {
}
int ret = 0;
HashSet<IMethod> counted = HashSetFactory.make();
for (Iterator<? extends CGNode> iter = cg.iterator(); iter.hasNext();) {
CGNode node = iter.next();
for (CGNode node : cg) {
IMethod method = node.getMethod();
if (counted.add(method)) {
if (method instanceof ShrikeCTMethod) {
@ -169,8 +166,7 @@ public class CallGraphStats {
throw new IllegalArgumentException("cg is null");
}
HashSet<MethodReference> result = HashSetFactory.make();
for (Iterator it = cg.iterator(); it.hasNext();) {
CGNode N = (CGNode) it.next();
for (CGNode N : cg) {
result.add(N.getMethod().getReference());
}
return result;

View File

@ -11,7 +11,6 @@
package com.ibm.wala.ipa.callgraph;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.function.Function;
@ -46,8 +45,7 @@ public class CallGraphTransitiveClosure {
BitVectorSolver<CGNode> solver = new BitVectorSolver<CGNode>(gr);
solver.solve(null);
Map<CGNode, OrdinalSet<T>> result = HashMapFactory.make();
for (Iterator<? extends CGNode> it = cg.iterator(); it.hasNext();) {
CGNode n = it.next();
for (CGNode n : cg) {
BitVectorVariable bv = solver.getOut(n);
result.put(n, new OrdinalSet<T>(bv.getValue(), gr.getLatticeValues()));
}
@ -62,8 +60,7 @@ public class CallGraphTransitiveClosure {
*/
public static <T> Map<CGNode, Collection<T>> collectNodeResults(CallGraph cg, Function<CGNode, Collection<T>> nodeResultComputer) {
Map<CGNode, Collection<T>> result = HashMapFactory.make();
for (Iterator<? extends CGNode> it = cg.iterator(); it.hasNext();) {
CGNode n = it.next();
for (CGNode n : cg) {
result.put(n, nodeResultComputer.apply(n));
}
return result;

View File

@ -100,8 +100,8 @@ public abstract class AbstractRootMethod extends SyntheticMethod {
public SSAInstruction[] getStatements(SSAOptions options) {
SSAInstruction[] result = new SSAInstruction[statements.size()];
int i = 0;
for (Iterator<SSAInstruction> it = statements.iterator(); it.hasNext();) {
result[i++] = it.next();
for (SSAInstruction ssaInstruction : statements) {
result[i++] = ssaInstruction;
}
return result;
@ -363,9 +363,9 @@ public abstract class AbstractRootMethod extends SyntheticMethod {
public Iterator<NewSiteReference> iterateNewSites(CGNode node) {
ArrayList<NewSiteReference> result = new ArrayList<NewSiteReference>();
SSAInstruction[] statements = getStatements(options.getSSAOptions());
for (int i = 0; i < statements.length; i++) {
if (statements[i] instanceof SSANewInstruction) {
SSANewInstruction s = (SSANewInstruction) statements[i];
for (SSAInstruction statement : statements) {
if (statement instanceof SSANewInstruction) {
SSANewInstruction s = (SSANewInstruction) statement;
result.add(s.getNewSite());
}
}
@ -375,9 +375,9 @@ public abstract class AbstractRootMethod extends SyntheticMethod {
public Iterator<SSAInstruction> getInvokeStatements() {
ArrayList<SSAInstruction> result = new ArrayList<SSAInstruction>();
SSAInstruction[] statements = getStatements(options.getSSAOptions());
for (int i = 0; i < statements.length; i++) {
if (statements[i] instanceof SSAInvokeInstruction) {
result.add(statements[i]);
for (SSAInstruction statement : statements) {
if (statement instanceof SSAInvokeInstruction) {
result.add(statement);
}
}
return result.iterator();

View File

@ -11,8 +11,6 @@
package com.ibm.wala.ipa.callgraph.impl;
import java.util.HashSet;
import java.util.Iterator;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.ipa.callgraph.AnalysisScope;
@ -40,8 +38,7 @@ public class AllApplicationEntrypoints extends HashSet<Entrypoint> {
for (IClass klass : cha) {
if (!klass.isInterface()) {
if (isApplicationClass(scope, klass)) {
for (Iterator methodIt = klass.getDeclaredMethods().iterator(); methodIt.hasNext();) {
IMethod method = (IMethod) methodIt.next();
for (IMethod method : klass.getDeclaredMethods()) {
if (!method.isAbstract()) {
add(new ArgumentTypeEntrypoint(method, cha));
}

View File

@ -11,7 +11,6 @@
package com.ibm.wala.ipa.callgraph.impl;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
import com.ibm.wala.classLoader.ArrayClass;
@ -81,9 +80,8 @@ public class ArgumentTypeEntrypoint extends Entrypoint {
}
private TypeReference chooseAConcreteSubClass(IClass klass) {
Collection subclasses = cha.computeSubClasses(klass.getReference());
for (Iterator it = subclasses.iterator(); it.hasNext();) {
IClass c = (IClass) it.next();
Collection<IClass> subclasses = cha.computeSubClasses(klass.getReference());
for (IClass c : subclasses) {
if (!c.isAbstract()) {
return c.getReference();
}

View File

@ -231,8 +231,8 @@ public abstract class BasicCallGraph<T> extends AbstractNumberedGraph<CGNode> im
@Override
public String toString() {
StringBuffer result = new StringBuffer("");
for (Iterator i = DFS.iterateDiscoverTime(this, new NonNullSingletonIterator<CGNode>(getFakeRootNode())); i.hasNext();) {
CGNode n = (CGNode) i.next();
for (Iterator<CGNode> i = DFS.iterateDiscoverTime(this, new NonNullSingletonIterator<CGNode>(getFakeRootNode())); i.hasNext();) {
CGNode n = i.next();
result.append(nodeToString(this, n) + "\n");
}
return result.toString();
@ -241,14 +241,14 @@ public abstract class BasicCallGraph<T> extends AbstractNumberedGraph<CGNode> im
public static String nodeToString(CallGraph CG, CGNode n) {
StringBuffer result = new StringBuffer(n.toString() + "\n");
if (n.getMethod() != null) {
for (Iterator sites = n.iterateCallSites(); sites.hasNext();) {
CallSiteReference site = (CallSiteReference) sites.next();
Iterator targets = CG.getPossibleTargets(n, site).iterator();
for (Iterator<CallSiteReference> sites = n.iterateCallSites(); sites.hasNext();) {
CallSiteReference site = sites.next();
Iterator<CGNode> targets = CG.getPossibleTargets(n, site).iterator();
if (targets.hasNext()) {
result.append(" - " + site + "\n");
}
for (; targets.hasNext();) {
CGNode target = (CGNode) targets.next();
CGNode target = targets.next();
result.append(" -> " + target + "\n");
}
}

View File

@ -31,11 +31,11 @@ public class ComposedEntrypoints implements Iterable<Entrypoint> {
if (B == null) {
throw new IllegalArgumentException("B is null");
}
for (Iterator<Entrypoint> it = A.iterator(); it.hasNext(); ) {
entrypoints.add(it.next());
for (Entrypoint entrypoint : A) {
entrypoints.add(entrypoint);
}
for (Iterator<Entrypoint> it = B.iterator(); it.hasNext(); ) {
entrypoints.add(it.next());
for (Entrypoint entrypoint : B) {
entrypoints.add(entrypoint);
}
}

View File

@ -96,8 +96,7 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
@Override
public Set<CGNode> getNodes(MethodReference m) {
Set<CGNode> result = HashSetFactory.make();
for (Iterator xs = cg.getNodes(m).iterator(); xs.hasNext();) {
CGNode x = (CGNode) xs.next();
for (CGNode x : cg.getNodes(m)) {
if (containsNode(x)) {
result.add(x);
}
@ -136,8 +135,8 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
public IntSet getSuccNodeNumbers(CGNode node) {
assert containsNode(node);
MutableIntSet x = IntSetUtil.make();
for (Iterator ns = getSuccNodes(node); ns.hasNext();) {
CGNode succ = (CGNode) ns.next();
for (Iterator<CGNode> ns = getSuccNodes(node); ns.hasNext();) {
CGNode succ = ns.next();
if (containsNode(succ)) {
x.add(getNumber(succ));
}
@ -150,8 +149,8 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
public IntSet getPredNodeNumbers(CGNode node) {
assert containsNode(node);
MutableIntSet x = IntSetUtil.make();
for (Iterator ns = getPredNodes(node); ns.hasNext();) {
CGNode pred = (CGNode) ns.next();
for (Iterator<CGNode> ns = getPredNodes(node); ns.hasNext();) {
CGNode pred = ns.next();
if (containsNode(pred)) {
x.add(getNumber(pred));
}
@ -176,8 +175,7 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
return null;
}
Set<CGNode> result = HashSetFactory.make();
for (Iterator ns = cg.getPossibleTargets(node, site).iterator(); ns.hasNext();) {
CGNode target = (CGNode) ns.next();
for (CGNode target : cg.getPossibleTargets(node, site)) {
if (containsNode(target)) {
result.add(target);
}

View File

@ -204,12 +204,12 @@ public class Util {
throw new IllegalArgumentException("(0 < classNames.length) and (classNames[0] == null)");
}
for (int i = 0; i < classNames.length; i++) {
if (classNames[i].indexOf("L") != 0) {
throw new IllegalArgumentException("Expected class name to start with L " + classNames[i]);
for (String className : classNames) {
if (className.indexOf("L") != 0) {
throw new IllegalArgumentException("Expected class name to start with L " + className);
}
if (classNames[i].indexOf(".") > 0) {
Assertions.productionAssertion(false, "Expected class name formatted with /, not . " + classNames[i]);
if (className.indexOf(".") > 0) {
Assertions.productionAssertion(false, "Expected class name formatted with /, not . " + className);
}
}
@ -274,15 +274,13 @@ public class Util {
System.err.println("subgraph: ");
System.err.println(subG.toString());
System.err.println("nodeDiff: ");
for (Iterator it = nodeDiff.iterator(); it.hasNext();) {
System.err.println(it.next().toString());
for (T t : nodeDiff) {
System.err.println(t.toString());
}
Assertions.productionAssertion(nodeDiff.isEmpty(), "bad superset, see tracefile\n");
}
for (Iterator<? extends T> subNodes = subG.iterator(); subNodes.hasNext();) {
T m = subNodes.next();
for (T m : subG) {
Set<T> succDiff = setify(subG.getSuccNodes(m));
succDiff.removeAll(setify(supG.getSuccNodes(m)));
if (!succDiff.isEmpty()) {
@ -297,8 +295,8 @@ public class Util {
System.err.println("subgraph: ");
System.err.println(subG.toString());
System.err.println("predDiff: ");
for (Iterator it = predDiff.iterator(); it.hasNext();) {
System.err.println(it.next().toString());
for (T t : predDiff) {
System.err.println(t.toString());
}
Assertions.UNREACHABLE("bad superset for predecessors of " + m + ":" + predDiff);
}

View File

@ -84,15 +84,14 @@ public final class ConcreteTypeKey implements InstanceKey {
if (pei == null) {
throw new IllegalArgumentException("pei is null");
}
Collection types = pei.getExceptionTypes();
Collection<TypeReference> types = pei.getExceptionTypes();
// TODO: institute a cache?
if (types == null) {
return null;
}
InstanceKey[] result = new InstanceKey[types.size()];
int i = 0;
for (Iterator it = types.iterator(); it.hasNext();) {
TypeReference type = (TypeReference) it.next();
for (TypeReference type : types) {
assert type != null;
IClass klass = cha.lookupClass(type);
result[i++] = new ConcreteTypeKey(klass);

View File

@ -89,12 +89,12 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
@Override
public String toString() {
StringBuffer result = new StringBuffer("PointerAnalysis:\n");
for (Iterator it = pointsToMap.iterateKeys(); it.hasNext();) {
PointerKey p = (PointerKey) it.next();
OrdinalSet O = getPointsToSet(p);
for (Iterator<PointerKey> it = pointsToMap.iterateKeys(); it.hasNext();) {
PointerKey p = it.next();
OrdinalSet<InstanceKey> O = getPointsToSet(p);
result.append(" ").append(p).append(" ->\n");
for (Iterator it2 = O.iterator(); it2.hasNext();) {
result.append(" ").append(it2.next()).append("\n");
for (InstanceKey instanceKey : O) {
result.append(" ").append(instanceKey).append("\n");
}
}
return result.toString();
@ -283,9 +283,8 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
private OrdinalSet<InstanceKey> computeImplicitPointsToSetAtALoad(CGNode node, SSAArrayLoadInstruction instruction) {
PointerKey arrayRef = pointerKeys.getPointerKeyForLocal(node, instruction.getArrayRef());
MutableSparseIntSet S = MutableSparseIntSet.makeEmpty();
OrdinalSet refs = getPointsToSet(arrayRef);
for (Iterator it = refs.iterator(); it.hasNext();) {
InstanceKey ik = (InstanceKey) it.next();
OrdinalSet<InstanceKey> refs = getPointsToSet(arrayRef);
for (InstanceKey ik : refs) {
PointerKey key = pointerKeys.getPointerKeyForArrayContents(ik);
OrdinalSet pointees = getPointsToSet(key);
IntSet set = pointees.getBackingSet();
@ -311,9 +310,8 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
} else {
PointerKey ref = pointerKeys.getPointerKeyForLocal(node, refVn);
MutableSparseIntSet S = MutableSparseIntSet.makeEmpty();
OrdinalSet refs = getPointsToSet(ref);
for (Iterator it = refs.iterator(); it.hasNext();) {
InstanceKey ik = (InstanceKey) it.next();
OrdinalSet<InstanceKey> refs = getPointsToSet(ref);
for (InstanceKey ik : refs) {
PointerKey fkey = pointerKeys.getPointerKeyForInstanceField(ik, f);
if (fkey != null) {
OrdinalSet pointees = getPointsToSet(fkey);
@ -333,8 +331,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
Set<IClass> caughtTypes = SSAPropagationCallGraphBuilder.getCaughtExceptionTypes(instruction, ir);
MutableSparseIntSet S = MutableSparseIntSet.makeEmpty();
// add the instances from each incoming pei ...
for (Iterator<ProgramCounter> it = peis.iterator(); it.hasNext();) {
ProgramCounter peiLoc = it.next();
for (ProgramCounter peiLoc : peis) {
SSAInstruction pei = ir.getPEI(peiLoc);
PointerKey e = null;
// first deal with exception variables from calls and throws.
@ -346,9 +343,8 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
e = pointerKeys.getPointerKeyForLocal(node, s.getException());
}
if (e != null) {
OrdinalSet ep = getPointsToSet(e);
for (Iterator it2 = ep.iterator(); it2.hasNext();) {
InstanceKey ik = (InstanceKey) it2.next();
OrdinalSet<InstanceKey> ep = getPointsToSet(e);
for (InstanceKey ik : ep) {
if (PropagationCallGraphBuilder.catches(caughtTypes, ik.getConcreteType(), getCallGraph().getClassHierarchy())) {
S.add(instanceKeys.getMappedIndex(ik));
}
@ -358,10 +354,9 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
// Account for those exceptions for which we do not actually have a
// points-to set for
// the pei, but just instance keys
Collection types = pei.getExceptionTypes();
Collection<TypeReference> types = pei.getExceptionTypes();
if (types != null) {
for (Iterator it2 = types.iterator(); it2.hasNext();) {
TypeReference type = (TypeReference) it2.next();
for (TypeReference type : types) {
if (type != null) {
InstanceKey ik = SSAPropagationCallGraphBuilder.getInstanceKeyForPEI(node, peiLoc, type, iKeyFactory);
ConcreteTypeKey ck = (ConcreteTypeKey) ik;
@ -388,15 +383,13 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
return rhsSet;
} else {
if (klass.isInterface()) {
for (Iterator it = rhsSet.iterator(); it.hasNext();) {
InstanceKey ik = (InstanceKey) it.next();
for (InstanceKey ik : rhsSet) {
if (getCallGraph().getClassHierarchy().implementsInterface(ik.getConcreteType(), klass)) {
S.add(getInstanceKeyMapping().getMappedIndex(ik));
}
}
} else {
for (Iterator it = rhsSet.iterator(); it.hasNext();) {
InstanceKey ik = (InstanceKey) it.next();
for (InstanceKey ik : rhsSet) {
if (getCallGraph().getClassHierarchy().isSubclassOf(ik.getConcreteType(), klass)) {
S.add(getInstanceKeyMapping().getMappedIndex(ik));
}
@ -419,12 +412,12 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
private OrdinalSet<InstanceKey> toOrdinalSet(InstanceKey[] ik) {
MutableSparseIntSet s = MutableSparseIntSet.makeEmpty();
for (int i = 0; i < ik.length; i++) {
int index = instanceKeys.getMappedIndex(ik[i]);
for (InstanceKey element : ik) {
int index = instanceKeys.getMappedIndex(element);
if (index != -1) {
s.add(index);
} else {
assert index != -1 : "instance " + ik[i] + " not mapped!";
assert index != -1 : "instance " + element + " not mapped!";
}
}
return new OrdinalSet<InstanceKey>(s, instanceKeys);
@ -435,8 +428,7 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis {
*/
private OrdinalSet<InstanceKey> computeImplicitExceptionsForCall(CGNode node, SSAInvokeInstruction call) {
MutableSparseIntSet S = MutableSparseIntSet.makeEmpty();
for (Iterator it = getCallGraph().getPossibleTargets(node, call.getCallSite()).iterator(); it.hasNext();) {
CGNode target = (CGNode) it.next();
for (CGNode target : getCallGraph().getPossibleTargets(node, call.getCallSite())) {
PointerKey retVal = pointerKeys.getPointerKeyForExceptionalReturnValue(target);
IntSet set = getPointsToSet(retVal).getBackingSet();
if (set != null) {

View File

@ -187,8 +187,8 @@ public class PointsToMap {
* Wipe out the cached transitive closure information
*/
public void revertToPreTransitive() {
for (Iterator it = iterateKeys(); it.hasNext();) {
PointerKey key = (PointerKey) it.next();
for (Iterator<PointerKey> it = iterateKeys(); it.hasNext();) {
PointerKey key = it.next();
if (!isTransitiveRoot(key) && !isImplicit(key) && !isUnified(key)) {
PointsToSetVariable v = getPointsToSet(key);
v.removeAll();

View File

@ -244,8 +244,7 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder<In
discoveredNodes.add(callGraph.getFakeRootNode());
// Set up the initially reachable methods and classes
for (Iterator it = options.getEntrypoints().iterator(); it.hasNext();) {
Entrypoint E = (Entrypoint) it.next();
for (Entrypoint E : options.getEntrypoints()) {
if (DEBUG_ENTRYPOINTS) {
System.err.println("Entrypoint: " + E);
}
@ -924,8 +923,7 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder<In
List<InstanceKey> instances = system.getInstances(rhs.getValue());
boolean sideEffect = false;
for (Iterator<InstanceKey> it = instances.iterator(); it.hasNext();) {
InstanceKey I = it.next();
for (InstanceKey I : instances) {
if (!I.getConcreteType().isArrayClass()) {
continue;
}

View File

@ -362,7 +362,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
private final Iterator<UnaryOperator<PointsToSetVariable>> outerKeyDelegate = implicitUnaryMap.keySet().iterator();
private Iterator innerDelegate;
private Iterator<IntPair> innerDelegate;
private UnaryOperator<PointsToSetVariable> currentOperator;
@ -378,7 +378,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
while (outerKeyDelegate.hasNext()) {
currentOperator = outerKeyDelegate.next();
IBinaryNaturalRelation R = implicitUnaryMap.get(currentOperator);
Iterator it = R.iterator();
Iterator<IntPair> it = R.iterator();
if (it.hasNext()) {
innerDelegate = it;
return;
@ -393,7 +393,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
@Override
public AbstractStatement next() {
IntPair p = (IntPair) innerDelegate.next();
IntPair p = innerDelegate.next();
int lhs = p.getX();
int rhs = p.getY();
UnaryStatement result = currentOperator.makeEquation((PointsToSetVariable) delegateGraph.getNode(lhs),
@ -504,7 +504,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
*/
@Override
public Iterator<PointsToSetVariable> getPredNodes(PointsToSetVariable v) {
final Iterator eqs = getStatementsThatDef(v);
final Iterator<AbstractStatement> eqs = getStatementsThatDef(v);
return new Iterator<PointsToSetVariable>() {
Iterator<INodeWithNumber> inner;
@ -522,7 +522,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
}
return result;
} else {
AbstractStatement eq = (AbstractStatement) eqs.next();
AbstractStatement eq = eqs.next();
if (useImplicitRepresentation(eq)) {
return (PointsToSetVariable) ((UnaryStatement) eq).getRightHandSide();
} else {
@ -547,8 +547,8 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
public int getPredNodeCount(INodeWithNumber N) {
PointsToSetVariable v = (PointsToSetVariable) N;
int result = 0;
for (Iterator eqs = getStatementsThatDef(v); eqs.hasNext();) {
AbstractStatement eq = (AbstractStatement) eqs.next();
for (Iterator<AbstractStatement> eqs = getStatementsThatDef(v); eqs.hasNext();) {
AbstractStatement eq = eqs.next();
if (useImplicitRepresentation(eq)) {
result++;
} else {
@ -563,7 +563,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
*/
@Override
public Iterator<PointsToSetVariable> getSuccNodes(PointsToSetVariable v) {
final Iterator eqs = getStatementsThatUse(v);
final Iterator<AbstractStatement> eqs = getStatementsThatUse(v);
return new Iterator<PointsToSetVariable>() {
PointsToSetVariable nextResult;
{
@ -585,7 +585,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
private void advance() {
nextResult = null;
while (eqs.hasNext() && nextResult == null) {
AbstractStatement eq = (AbstractStatement) eqs.next();
AbstractStatement eq = eqs.next();
nextResult = (PointsToSetVariable) eq.getLHS();
}
}
@ -604,8 +604,8 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
@Override
public int getSuccNodeCount(PointsToSetVariable v) {
int result = 0;
for (Iterator eqs = getStatementsThatUse(v); eqs.hasNext();) {
AbstractStatement eq = (AbstractStatement) eqs.next();
for (Iterator<AbstractStatement> eqs = getStatementsThatUse(v); eqs.hasNext();) {
AbstractStatement eq = eqs.next();
IVariable lhs = eq.getLHS();
if (lhs != null) {
result++;
@ -722,8 +722,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
return 0;
}
int result = delegateGraph.getSuccNodeCount(v);
for (Iterator it = invImplicitUnaryMap.keySet().iterator(); it.hasNext();) {
UnaryOperator op = (UnaryOperator) it.next();
for (UnaryOperator<PointsToSetVariable> op : invImplicitUnaryMap.keySet()) {
IBinaryNaturalRelation R = invImplicitUnaryMap.get(op);
IntSet s = R.getRelated(number);
if (s != null) {
@ -743,8 +742,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
return 0;
}
int result = delegateGraph.getPredNodeCount(v);
for (Iterator it = implicitUnaryMap.keySet().iterator(); it.hasNext();) {
UnaryOperator op = (UnaryOperator) it.next();
for (UnaryOperator<PointsToSetVariable> op : implicitUnaryMap.keySet()) {
IBinaryNaturalRelation R = implicitUnaryMap.get(op);
IntSet s = R.getRelated(number);
if (s != null) {
@ -771,10 +769,10 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
System.err.println("implicit map:");
int count = 0;
int totalBytes = 0;
for (Iterator it = implicitUnaryMap.entrySet().iterator(); it.hasNext();) {
count++;
Map.Entry e = (Map.Entry) it.next();
IBinaryNaturalRelation R = (IBinaryNaturalRelation) e.getValue();
for (Map.Entry<UnaryOperator<PointsToSetVariable>, IBinaryNaturalRelation> entry : implicitUnaryMap.entrySet()) {
count++;
Map.Entry<?, IBinaryNaturalRelation> e = entry;
IBinaryNaturalRelation R = e.getValue();
System.err.println(("entry " + count));
R.performVerboseAction();
HeapTracer.Result result = HeapTracer.traceHeap(Collections.singleton(R), false);
@ -938,7 +936,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
*/
@Override
public Iterator<PointsToSetVariable> getPredNodes(PointsToSetVariable v) {
final Iterator eqs = getStatementsThatDef(v);
final Iterator<AbstractStatement> eqs = getStatementsThatDef(v);
return new Iterator<PointsToSetVariable>() {
PointsToSetVariable nextResult;
{
@ -960,7 +958,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
private void advance() {
nextResult = null;
while (eqs.hasNext() && nextResult == null) {
AbstractStatement eq = (AbstractStatement) eqs.next();
AbstractStatement eq = eqs.next();
if (isInteresting(eq)) {
nextResult = (PointsToSetVariable) ((UnaryStatement) eq).getRightHandSide();
}
@ -980,8 +978,8 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
@Override
public int getPredNodeCount(PointsToSetVariable v) {
int result = 0;
for (Iterator eqs = getStatementsThatDef(v); eqs.hasNext();) {
AbstractStatement eq = (AbstractStatement) eqs.next();
for (Iterator<AbstractStatement> eqs = getStatementsThatDef(v); eqs.hasNext();) {
AbstractStatement eq = eqs.next();
if (isInteresting(eq)) {
result++;
}
@ -994,7 +992,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
*/
@Override
public Iterator<PointsToSetVariable> getSuccNodes(PointsToSetVariable v) {
final Iterator eqs = getStatementsThatUse(v);
final Iterator<AbstractStatement> eqs = getStatementsThatUse(v);
return new Iterator<PointsToSetVariable>() {
PointsToSetVariable nextResult;
{
@ -1016,7 +1014,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
private void advance() {
nextResult = null;
while (eqs.hasNext() && nextResult == null) {
AbstractStatement eq = (AbstractStatement) eqs.next();
AbstractStatement eq = eqs.next();
if (isInteresting(eq)) {
nextResult = (PointsToSetVariable) ((UnaryStatement) eq).getLHS();
}
@ -1037,8 +1035,8 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
@Override
public int getSuccNodeCount(PointsToSetVariable v) {
int result = 0;
for (Iterator eqs = getStatementsThatUse(v); eqs.hasNext();) {
AbstractStatement eq = (AbstractStatement) eqs.next();
for (Iterator<AbstractStatement> eqs = getStatementsThatUse(v); eqs.hasNext();) {
AbstractStatement eq = eqs.next();
if (isInteresting(eq)) {
result++;
}
@ -1093,7 +1091,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
private int countImplicitEdges() {
int result = 0;
for (Iterator it = new GlobalImplicitIterator(); it.hasNext();) {
for (Iterator<AbstractStatement> it = new GlobalImplicitIterator(); it.hasNext();) {
it.next();
result++;
}

View File

@ -146,8 +146,7 @@ public class PropagationSystem extends DefaultFixedPointSolver<PointsToSetVariab
protected void updateSideEffects(PointsToSetVariable p, PointsToSetVariable rep) {
Set<UnarySideEffect> set = fixedSetMap.get(p);
if (set != null) {
for (Iterator it = set.iterator(); it.hasNext();) {
UnarySideEffect s = (UnarySideEffect) it.next();
for (UnarySideEffect s : set) {
s.replaceFixedSet(rep);
}
Set<UnarySideEffect> s2 = MapUtil.findOrCreateSet(fixedSetMap, rep);
@ -483,10 +482,9 @@ public class PropagationSystem extends DefaultFixedPointSolver<PointsToSetVariab
}
private void registerArrayInstanceWithAllInterfacesOfElement(int index, IClass elementClass, int dim) {
Collection ifaces = null;
Collection<IClass> ifaces = null;
ifaces = elementClass.getAllImplementedInterfaces();
for (Iterator it = ifaces.iterator(); it.hasNext();) {
IClass I = (IClass) it.next();
for (IClass I : ifaces) {
TypeReference iArrayRef = makeArray(I.getReference(), dim);
IClass iArrayClass = null;
iArrayClass = I.getClassLoader().lookupClass(iArrayRef.getName());
@ -529,9 +527,8 @@ public class PropagationSystem extends DefaultFixedPointSolver<PointsToSetVariab
* @throws ClassHierarchyException
*/
private void registerInstanceWithAllInterfaces(IClass klass, int index) throws ClassHierarchyException {
Collection ifaces = klass.getAllImplementedInterfaces();
for (Iterator it = ifaces.iterator(); it.hasNext();) {
IClass I = (IClass) it.next();
Collection<IClass> ifaces = klass.getAllImplementedInterfaces();
for (IClass I : ifaces) {
MutableIntSet set = findOrCreateSparseSetForClass(I);
set.add(index);
if (DEBUG) {
@ -720,7 +717,7 @@ public class PropagationSystem extends DefaultFixedPointSolver<PointsToSetVariab
pointsToMap.revertToPreTransitive();
}
public Iterator getTransitiveRoots() {
public Iterator<PointerKey> getTransitiveRoots() {
return pointsToMap.getTransitiveRoots();
}
@ -794,8 +791,7 @@ public class PropagationSystem extends DefaultFixedPointSolver<PointsToSetVariab
*/
private void updateSideEffectsForUnification(HashSet<PointsToSetVariable> s, int rep) {
PointsToSetVariable pRef = pointsToMap.getPointsToSet(rep);
for (Iterator<PointsToSetVariable> it = s.iterator(); it.hasNext();) {
PointsToSetVariable p = it.next();
for (PointsToSetVariable p : s) {
updateSideEffects(p, pRef);
}
}
@ -809,15 +805,11 @@ public class PropagationSystem extends DefaultFixedPointSolver<PointsToSetVariab
@SuppressWarnings("unchecked")
private void updateEquationsForUnification(HashSet<PointsToSetVariable> s, int rep) {
PointsToSetVariable pRef = pointsToMap.getPointsToSet(rep);
for (Iterator<PointsToSetVariable> it = s.iterator(); it.hasNext();) {
PointsToSetVariable p = it.next();
for (PointsToSetVariable p : s) {
if (p != pRef) {
// pRef is the representative for p.
// be careful: cache the defs before mucking with the underlying system
for (Iterator d = Iterator2Collection.toSet(getStatementsThatDef(p)).iterator(); d.hasNext();) {
AbstractStatement as = (AbstractStatement) d.next();
for (AbstractStatement as : Iterator2Collection.toSet(getStatementsThatDef(p))) {
if (as instanceof AssignEquation) {
AssignEquation assign = (AssignEquation) as;
PointsToSetVariable rhs = assign.getRightHandSide();
@ -832,8 +824,7 @@ public class PropagationSystem extends DefaultFixedPointSolver<PointsToSetVariab
}
}
// be careful: cache the defs before mucking with the underlying system
for (Iterator u = Iterator2Collection.toSet(getStatementsThatUse(p)).iterator(); u.hasNext();) {
AbstractStatement as = (AbstractStatement) u.next();
for (AbstractStatement as : Iterator2Collection.toSet(getStatementsThatUse(p))) {
if (as instanceof AssignEquation) {
AssignEquation assign = (AssignEquation) as;
PointsToSetVariable lhs = assign.getLHS();

View File

@ -12,7 +12,6 @@ package com.ibm.wala.ipa.callgraph.propagation;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.function.Predicate;
@ -80,8 +79,8 @@ public class ReflectionHandler {
Collection<Statement> casts = Iterator2Collection.toSet(new FilterIterator<>(slice.iterator(), f));
changedNodes.addAll(modifyFactoryInterpreter(st, casts, builder.getContextInterpreter(), builder.getClassHierarchy()));
}
for (Iterator<CGNode> it = changedNodes.iterator(); it.hasNext();) {
builder.addConstraintsFromChangedNode(it.next(), monitor);
for (CGNode cgNode : changedNodes) {
builder.addConstraintsFromChangedNode(cgNode, monitor);
}
return changedNodes.size() > 0;
@ -90,8 +89,7 @@ public class ReflectionHandler {
private Collection<Statement> computeFactoryReturnStatements() {
// todo: clean up logic with inheritance, delegation.
HashSet<Statement> result = HashSetFactory.make();
for (Iterator it = builder.getCallGraph().iterator(); it.hasNext();) {
CGNode n = (CGNode) it.next();
for (CGNode n : builder.getCallGraph()) {
if (n.getMethod() instanceof SyntheticMethod) {
SyntheticMethod m = (SyntheticMethod) n.getMethod();
if (m.isFactoryMethod()) {

View File

@ -284,9 +284,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
v.setBasicBlock(b);
// visit each instruction in the basic block.
for (Iterator<SSAInstruction> it = b.iterator(); it.hasNext();) {
for (SSAInstruction s : b) {
MonitorUtil.throwExceptionIfCanceled(monitor);
SSAInstruction s = it.next();
if (s != null) {
s.visit(v);
if (wasChanged(node)) {
@ -301,7 +300,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
private void addPhiConstraints(CGNode node, ControlFlowGraph<SSAInstruction, ISSABasicBlock> controlFlowGraph, BasicBlock b,
ConstraintVisitor v) {
// visit each phi instruction in each successor block
for (Iterator sbs = controlFlowGraph.getSuccNodes(b); sbs.hasNext();) {
for (Iterator<ISSABasicBlock> sbs = controlFlowGraph.getSuccNodes(b); sbs.hasNext();) {
BasicBlock sb = (BasicBlock) sbs.next();
if (!sb.hasPhi()) {
continue;
@ -329,8 +328,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(v.symbolTable, v.du, phi.getUse(n))) {
system.recordImplicitPointsToSet(use);
InstanceKey[] ik = getInvariantContents(v.symbolTable, v.du, node, phi.getUse(n), this);
for (int i = 0; i < ik.length; i++) {
system.newConstraint(def, ik[i]);
for (InstanceKey element : ik) {
system.newConstraint(def, element);
}
} else {
system.newConstraint(def, assignOperator, use);
@ -371,8 +370,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (DEBUG) {
System.err.println("Add exception def constraints for node " + node);
}
for (Iterator<ProgramCounter> it = peis.iterator(); it.hasNext();) {
ProgramCounter peiLoc = it.next();
for (ProgramCounter peiLoc : peis) {
if (DEBUG) {
System.err.println("peiLoc: " + peiLoc);
}
@ -398,9 +396,9 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(ir.getSymbolTable(), du, s.getException())) {
InstanceKey[] ik = getInvariantContents(ir.getSymbolTable(), du, node, s.getException(), this);
for (int i = 0; i < ik.length; i++) {
system.findOrCreateIndexForInstanceKey(ik[i]);
assignInstanceToCatch(exceptionVar, catchClasses, ik[i]);
for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(element);
assignInstanceToCatch(exceptionVar, catchClasses, element);
}
} else {
addAssignmentsForCatchPointerKey(exceptionVar, catchClasses, e);
@ -412,8 +410,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
// the pei, but just instance keys
Collection<TypeReference> types = pei.getExceptionTypes();
if (types != null) {
for (Iterator<TypeReference> it2 = types.iterator(); it2.hasNext();) {
TypeReference type = it2.next();
for (TypeReference type : types) {
if (type != null) {
InstanceKey ik = getInstanceKeyForPEI(node, peiLoc, type, instanceKeyFactory);
if (ik == null) {
@ -487,7 +484,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
}
ControlFlowGraph<SSAInstruction, ISSABasicBlock> g = ir.getControlFlowGraph();
List<ProgramCounter> result = new ArrayList<ProgramCounter>(g.getPredNodeCount(bb));
for (Iterator it = g.getPredNodes(bb); it.hasNext();) {
for (Iterator<ISSABasicBlock> it = g.getPredNodes(bb); it.hasNext();) {
BasicBlock pred = (BasicBlock) it.next();
if (DEBUG) {
System.err.println("pred: " + pred);
@ -536,9 +533,9 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
InstanceKey[] ik = invariants != null ? invariants[p] : null;
if (ik != null) {
if (ik.length > 0) {
for (int i = 0; i < ik.length; i++) {
system.findOrCreateIndexForInstanceKey(ik[i]);
keys[pi] = ik[i];
for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(element);
keys[pi] = element;
rec(pi + 1, rhsi);
}
} /* else {
@ -791,11 +788,11 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, value)) {
system.recordImplicitPointsToSet(valuePtrKey);
InstanceKey[] vk = getInvariantContents(value);
for (int j = 0; j < vk.length; j++) {
system.findOrCreateIndexForInstanceKey(vk[j]);
if (vk[j].getConcreteType() != null) {
if (getClassHierarchy().isAssignableFrom(contents, vk[j].getConcreteType())) {
system.newConstraint(p, vk[j]);
for (InstanceKey element : vk) {
system.findOrCreateIndexForInstanceKey(element);
if (element.getConcreteType() != null) {
if (getClassHierarchy().isAssignableFrom(contents, element.getConcreteType())) {
system.newConstraint(p, element);
}
}
}
@ -813,10 +810,10 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, value)) {
system.recordImplicitPointsToSet(valuePtrKey);
InstanceKey[] ik = getInvariantContents(value);
for (int i = 0; i < ik.length; i++) {
system.findOrCreateIndexForInstanceKey(ik[i]);
for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(element);
assert !system.isUnified(arrayRefPtrKey);
system.newSideEffect(getBuilder().new InstanceArrayStoreOperator(ik[i]), arrayRefPtrKey);
system.newSideEffect(getBuilder().new InstanceArrayStoreOperator(element), arrayRefPtrKey);
}
} else {
system.newSideEffect(getBuilder().new ArrayStoreOperator(system.findOrCreatePointsToSet(valuePtrKey)), arrayRefPtrKey);
@ -868,17 +865,17 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
IClass cls = getClassHierarchy().lookupClass(t);
if (cls.isInterface()) {
for (int i = 0; i < ik.length; i++) {
system.findOrCreateIndexForInstanceKey(ik[i]);
if (getClassHierarchy().implementsInterface(ik[i].getConcreteType(), cls)) {
system.newConstraint(result, ik[i]);
for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(element);
if (getClassHierarchy().implementsInterface(element.getConcreteType(), cls)) {
system.newConstraint(result, element);
}
}
} else {
for (int i = 0; i < ik.length; i++) {
system.findOrCreateIndexForInstanceKey(ik[i]);
if (getClassHierarchy().isSubclassOf(ik[i].getConcreteType(), cls)) {
system.newConstraint(result, ik[i]);
for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(element);
if (getClassHierarchy().isSubclassOf(element.getConcreteType(), cls)) {
system.newConstraint(result, element);
}
}
}
@ -912,11 +909,11 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, instruction.getResult())) {
system.recordImplicitPointsToSet(result);
InstanceKey[] ik = getInvariantContents(instruction.getResult());
for (int i = 0; i < ik.length; i++) {
for (InstanceKey element : ik) {
if (DEBUG) {
System.err.println("invariant contents: " + returnValue + " " + ik[i]);
System.err.println("invariant contents: " + returnValue + " " + element);
}
system.newConstraint(returnValue, ik[i]);
system.newConstraint(returnValue, element);
}
} else {
system.newConstraint(returnValue, assignOperator, result);
@ -1044,15 +1041,15 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (!representsNullType(refk[j])) {
system.findOrCreateIndexForInstanceKey(refk[j]);
PointerKey p = getPointerKeyForInstanceField(refk[j], f);
for (int i = 0; i < ik.length; i++) {
system.newConstraint(p, ik[i]);
for (InstanceKey element : ik) {
system.newConstraint(p, element);
}
}
}
} else {
for (int i = 0; i < ik.length; i++) {
system.findOrCreateIndexForInstanceKey(ik[i]);
system.newSideEffect(getBuilder().new InstancePutFieldOperator(f, ik[i]), refKey);
for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(element);
system.newSideEffect(getBuilder().new InstancePutFieldOperator(f, element), refKey);
}
}
} else {
@ -1084,8 +1081,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, rval)) {
system.recordImplicitPointsToSet(rvalKey);
InstanceKey[] ik = getInvariantContents(rval);
for (int i = 0; i < ik.length; i++) {
system.newConstraint(fKey, ik[i]);
for (InstanceKey element : ik) {
system.newConstraint(fKey, element);
}
} else {
system.newConstraint(fKey, assignOperator, rvalKey);
@ -1331,8 +1328,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, instruction.getUse(i))) {
system.recordImplicitPointsToSet(use);
InstanceKey[] ik = getInvariantContents(instruction.getUse(i));
for (int j = 0; j < ik.length; j++) {
system.newConstraint(dst, ik[j]);
for (InstanceKey element : ik) {
system.newConstraint(dst, element);
}
} else {
system.newConstraint(dst, assignOperator, use);
@ -1379,10 +1376,10 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, val)) {
system.recordImplicitPointsToSet(src);
InstanceKey[] ik = getInvariantContents(val);
for (int j = 0; j < ik.length; j++) {
boolean assignable = getClassHierarchy().isAssignableFrom(cls, ik[j].getConcreteType());
for (InstanceKey element : ik) {
boolean assignable = getClassHierarchy().isAssignableFrom(cls, element.getConcreteType());
if ((assignable && useFilter) || (!assignable && !useFilter)) {
system.newConstraint(dst, ik[j]);
system.newConstraint(dst, element);
}
}
} else {
@ -1416,8 +1413,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, src)) {
system.recordImplicitPointsToSet(srcKey);
InstanceKey[] ik = getInvariantContents(src);
for (int j = 0; j < ik.length; j++) {
system.newConstraint(dst, ik[j]);
for (InstanceKey element : ik) {
system.newConstraint(dst, element);
}
} else {
system.newConstraint(dst, assignOperator, srcKey);
@ -1642,8 +1639,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
PointerKey formal = getTargetPointerKey(target, i);
if (constParams != null && constParams[i] != null) {
InstanceKey[] ik = constParams[i];
for (int j = 0; j < ik.length; j++) {
system.newConstraint(formal, ik[j]);
for (InstanceKey element : ik) {
system.newConstraint(formal, element);
}
} else {
if (instruction.getUse(i) < 0) {
@ -2042,8 +2039,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
// todo: enhance this by solving a dead-code elimination
// problem.
InterestingVisitor v = makeInterestingVisitor(node, vn);
for (Iterator it = du.getUses(v.vn); it.hasNext();) {
SSAInstruction s = (SSAInstruction) it.next();
for (Iterator<SSAInstruction> it = du.getUses(v.vn); it.hasNext();) {
SSAInstruction s = it.next();
s.visit(v);
if (v.bingo) {
return false;
@ -2314,8 +2311,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
}
if (ensureIndexes) {
for (int i = 0; i < result.length; i++) {
system.findOrCreateIndexForInstanceKey(result[i]);
for (InstanceKey element : result) {
system.findOrCreateIndexForInstanceKey(element);
}
}

View File

@ -76,8 +76,8 @@ public class ZeroXCFABuilder extends SSAPropagationCallGraphBuilder {
throw new IllegalArgumentException("options is null");
}
Util.addDefaultSelectors(options, cha);
for (int i = 0; i < xmlFiles.length; i++) {
Util.addBypassLogic(options, scope, cl, xmlFiles[i], cha);
for (String xmlFile : xmlFiles) {
Util.addBypassLogic(options, scope, cl, xmlFile, cha);
}
return new ZeroXCFABuilder(cha, options, cache, null, null, instancePolicy);

View File

@ -214,8 +214,7 @@ public class ZeroXInstanceKeys implements InstanceKeyFactory {
if (s == null) {
Map<IClass, Integer> count = countAllocsByType(node);
HashSet<IClass> smushees = HashSetFactory.make(5);
for (Iterator<Map.Entry<IClass, Integer>> it = count.entrySet().iterator(); it.hasNext();) {
Map.Entry<IClass, Integer> e = it.next();
for (Map.Entry<IClass, Integer> e : count.entrySet()) {
Integer i = e.getValue();
if (i.intValue() > SMUSH_LIMIT) {
smushees.add(e.getKey());
@ -232,8 +231,8 @@ public class ZeroXInstanceKeys implements InstanceKeyFactory {
*/
private Map<IClass, Integer> countAllocsByType(CGNode node) {
Map<IClass, Integer> count = HashMapFactory.make();
for (Iterator it = contextInterpreter.iterateNewSites(node); it.hasNext();) {
NewSiteReference n = (NewSiteReference) it.next();
for (Iterator<NewSiteReference> it = contextInterpreter.iterateNewSites(node); it.hasNext();) {
NewSiteReference n = it.next();
IClass alloc = cha.lookupClass(n.getDeclaredType());
if (alloc != null) {
Integer old = count.get(alloc);
@ -336,8 +335,7 @@ public class ZeroXInstanceKeys implements InstanceKeyFactory {
if (c.getReference().equals(TypeReference.JavaLangObject)) {
return true;
} else {
for (Iterator<IField> it = c.getDeclaredInstanceFields().iterator(); it.hasNext();) {
IField f = it.next();
for (IField f : c.getDeclaredInstanceFields()) {
if (f.getReference().getFieldType().isReferenceType()) {
return false;
}

Some files were not shown because too many files have changed in this diff Show More