Use modern for-each loops where possible

Java sources used as test data have been excluded from this mass
clean-up.
This commit is contained in:
Ben Liblit 2017-11-28 14:26:09 -06:00
parent 12ca05ddb7
commit ebfd885d22
205 changed files with 1001 additions and 1340 deletions

View File

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

View File

@ -1411,8 +1411,7 @@ public abstract class JDTJava2CAstTranslator<T extends Position> {
argNodes[idx++] = fFactory.makeConstant(callSiteRef); argNodes[idx++] = fFactory.makeConstant(callSiteRef);
// rest of args // rest of args
for (Iterator<?> iter = arguments.iterator(); iter.hasNext();) { for (Object arg : arguments) {
Object arg = iter.next();
argNodes[idx++] = (arg instanceof CAstNode) ? ((CAstNode) arg) : visitNode((Expression) arg, context); argNodes[idx++] = (arg instanceof CAstNode) ? ((CAstNode) arg) : visitNode((Expression) arg, context);
} }
callNode = makeNode(context, fFactory, nn, CAstNode.CALL, argNodes); 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.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -136,9 +135,7 @@ public class ECJSourceModuleTranslator implements SourceModuleTranslator {
while (cl != null) { while (cl != null) {
List<Module> modules = scope.getModules(cl); List<Module> modules = scope.getModules(cl);
for (Iterator<Module> iter = modules.iterator(); iter.hasNext();) { for (Module m : modules) {
Module m = iter.next();
if (m instanceof JarFileModule) { if (m instanceof JarFileModule) {
JarFileModule jarFileModule = (JarFileModule) m; JarFileModule jarFileModule = (JarFileModule) m;

View File

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

View File

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

View File

@ -53,8 +53,8 @@ public class AstJavaZeroXCFABuilder extends AstJavaCFABuilder {
AnalysisScope scope, String[] xmlFiles, byte instancePolicy) { AnalysisScope scope, String[] xmlFiles, byte instancePolicy) {
com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha); com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
for (int i = 0; i < xmlFiles.length; i++) { for (String xmlFile : xmlFiles) {
com.ibm.wala.ipa.callgraph.impl.Util.addBypassLogic(options, scope, cl, xmlFiles[i], cha); com.ibm.wala.ipa.callgraph.impl.Util.addBypassLogic(options, scope, cl, xmlFile, cha);
} }
return new AstJavaZeroXCFABuilder(cha, options, cache, null, null, instancePolicy); 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()) { if ((m instanceof AstMethod) && !m.isStatic()) {
AstMethod M = (AstMethod) m; AstMethod M = (AstMethod) m;
LexicalParent[] parents = M.getParents(); LexicalParent[] parents = M.getParents();
for (int i = 0; i < parents.length; i++) { for (LexicalParent parent : parents) {
result.add(parents[i]); result.add(parent);
} }
} }
} }

View File

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

View File

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

View File

@ -158,8 +158,7 @@ public abstract class FieldBasedCallGraphBuilder {
// set up call edges from fake root to all script nodes // set up call edges from fake root to all script nodes
AbstractRootMethod fakeRootMethod = (AbstractRootMethod)cg.getFakeRootNode().getMethod(); AbstractRootMethod fakeRootMethod = (AbstractRootMethod)cg.getFakeRootNode().getMethod();
CGNode fakeRootNode = cg.findOrCreateNode(fakeRootMethod, Everywhere.EVERYWHERE); CGNode fakeRootNode = cg.findOrCreateNode(fakeRootMethod, Everywhere.EVERYWHERE);
for(Iterator<? extends Entrypoint> iter = eps.iterator(); iter.hasNext();) { for (Entrypoint ep : eps) {
Entrypoint ep = iter.next();
CGNode nd = cg.findOrCreateNode(ep.getMethod(), Everywhere.EVERYWHERE); CGNode nd = cg.findOrCreateNode(ep.getMethod(), Everywhere.EVERYWHERE);
SSAAbstractInvokeInstruction invk = ep.addCall(fakeRootMethod); SSAAbstractInvokeInstruction invk = ep.addCall(fakeRootMethod);
fakeRootNode.addTarget(invk.getCallSite(), nd); 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.IOException;
import java.io.Reader; import java.io.Reader;
import java.net.URL; import java.net.URL;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
@ -110,8 +109,7 @@ public class JerichoHtmlParser implements IHtmlParser{
src = new Source(reader); src = new Source(reader);
src.setLogger(Config.LoggerProvider.getLogger(fileName)); src.setLogger(Config.LoggerProvider.getLogger(fileName));
List<Element> childElements = src.getChildElements(); List<Element> childElements = src.getChildElements();
for (Iterator<Element> nodeIterator = childElements.iterator(); nodeIterator.hasNext();) { for (Element e : childElements) {
Element e = nodeIterator.next();
parser.parse(e); parser.parse(e);
} }
if (! warnings.isEmpty()) { if (! warnings.isEmpty()) {
@ -139,8 +137,7 @@ public class JerichoHtmlParser implements IHtmlParser{
handler.handleStartTag(tag); handler.handleStartTag(tag);
handler.handleText(tag.getElementPosition(), tag.getBodyText().snd); handler.handleText(tag.getElementPosition(), tag.getBodyText().snd);
List<Element> childElements = root.getChildElements(); List<Element> childElements = root.getChildElements();
for (Iterator<Element> nodeIterator = childElements.iterator(); nodeIterator.hasNext();) { for (Element child : childElements) {
Element child = nodeIterator.next();
parse(child); parse(child);
} }
handler.handleEndTag(tag); handler.handleEndTag(tag);

View File

@ -528,8 +528,8 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
if (contentsAreInvariant(symbolTable, du, rval)) { if (contentsAreInvariant(symbolTable, du, rval)) {
system.recordImplicitPointsToSet(rvalKey); system.recordImplicitPointsToSet(rvalKey);
InstanceKey[] ik = getInvariantContents(rval); InstanceKey[] ik = getInvariantContents(rval);
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.newConstraint(p, ik[i]); system.newConstraint(p, element);
} }
} else { } else {
system.newConstraint(p, assignOperator, rvalKey); system.newConstraint(p, assignOperator, rvalKey);
@ -668,8 +668,8 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
if (contentsAreInvariant(symbolTable, du, receiverVn)) { if (contentsAreInvariant(symbolTable, du, receiverVn)) {
system.recordImplicitPointsToSet(receiverKey); system.recordImplicitPointsToSet(receiverKey);
InstanceKey[] ik = getInvariantContents(receiverVn); InstanceKey[] ik = getInvariantContents(receiverVn);
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
handleJavascriptDispatch(instruction, ik[i]); handleJavascriptDispatch(instruction, element);
} }
} else { } else {
class ReceiverForDispatchOp extends UnaryOperator<PointsToSetVariable> { class ReceiverForDispatchOp extends UnaryOperator<PointsToSetVariable> {
@ -810,17 +810,17 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
InstanceKey[] iks2 = getInstancesArray(arg2); InstanceKey[] iks2 = getInstancesArray(arg2);
if ((instruction.getOperator() == BinaryOpInstruction.Operator.ADD) && (getOptions().getTraceStringConstants())) { if ((instruction.getOperator() == BinaryOpInstruction.Operator.ADD) && (getOptions().getTraceStringConstants())) {
for (int i = 0; i < iks1.length; i++) { for (InstanceKey element : iks1) {
if (isStringConstant(iks1[i])) { if (isStringConstant(element)) {
for (int j = 0; j < iks2.length; j++) { for (InstanceKey element2 : iks2) {
if (isStringConstant(iks2[j])) { if (isStringConstant(element2)) {
try { try {
MonitorUtil.throwExceptionIfCanceled(builder.monitor); MonitorUtil.throwExceptionIfCanceled(builder.monitor);
} catch (CancelException e) { } catch (CancelException e) {
throw new CancelRuntimeException(e); throw new CancelRuntimeException(e);
} }
String v1 = (String) ((ConstantKey<?>) iks1[i]).getValue(); String v1 = (String) ((ConstantKey<?>) element).getValue();
String v2 = (String) ((ConstantKey<?>) iks2[j]).getValue(); String v2 = (String) ((ConstantKey<?>) element2).getValue();
if (v1.indexOf(v2) == -1 && v2.indexOf(v1) == -1) { if (v1.indexOf(v2) == -1 && v2.indexOf(v1) == -1) {
InstanceKey lvalKey = getInstanceKeyForConstant(v1 + v2); InstanceKey lvalKey = getInstanceKeyForConstant(v1 + v2);
if (addKey(lvalKey)) { if (addKey(lvalKey)) {
@ -842,14 +842,14 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
} }
if (doDefault) { if (doDefault) {
for (int i = 0; i < iks1.length; i++) { for (InstanceKey element : iks1) {
for (int j = 0; j < iks2.length; j++) { for (InstanceKey element2 : iks2) {
try { try {
MonitorUtil.throwExceptionIfCanceled(builder.monitor); MonitorUtil.throwExceptionIfCanceled(builder.monitor);
} catch (CancelException e) { } catch (CancelException e) {
throw new CancelRuntimeException(e); throw new CancelRuntimeException(e);
} }
if (handleBinaryOperatorArgs(iks1[i], iks2[j])) { if (handleBinaryOperatorArgs(element, element2)) {
changed = CHANGED; changed = CHANGED;
} }
} }
@ -1097,8 +1097,8 @@ public class JSSSAPropagationCallGraphBuilder extends AstSSAPropagationCallGraph
InstanceKey[] nullkeys = builder.getInvariantContents(sourceST, sourceDU, caller, nullvn, builder); InstanceKey[] nullkeys = builder.getInvariantContents(sourceST, sourceDU, caller, nullvn, builder);
for (int i = argCount; i < paramCount; i++) { for (int i = argCount; i < paramCount; i++) {
PointerKey F = builder.getPointerKeyForLocal(target, targetST.getParameter(i)); PointerKey F = builder.getPointerKeyForLocal(target, targetST.getParameter(i));
for (int k = 0; k < nullkeys.length; k++) { for (InstanceKey nullkey : nullkeys) {
builder.getSystem().newConstraint(F, nullkeys[k]); 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, public static JSCFABuilder make(JSAnalysisOptions options, IAnalysisCacheView cache, IClassHierarchy cha, ClassLoader cl,
AnalysisScope scope, String[] xmlFiles, byte instancePolicy, boolean doOneCFA) { AnalysisScope scope, String[] xmlFiles, byte instancePolicy, boolean doOneCFA) {
com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha); com.ibm.wala.ipa.callgraph.impl.Util.addDefaultSelectors(options, cha);
for (int i = 0; i < xmlFiles.length; i++) { for (String xmlFile : xmlFiles) {
com.ibm.wala.ipa.callgraph.impl.Util.addBypassLogic(options, scope, cl, xmlFiles[i], cha); com.ibm.wala.ipa.callgraph.impl.Util.addBypassLogic(options, scope, cl, xmlFile, cha);
} }
return new JSZeroOrOneXCFABuilder(cha, options, cache, null, null, instancePolicy, doOneCFA); 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()]; CAstNode[] before = new CAstNode[tler.getStartInner()];
for(i=0;i<tler.getStartInner();++i) for(i=0;i<tler.getStartInner();++i)
before[i] = copyNodes(start.getChild(i), cfg, context, nodeMap); before[i] = copyNodes(start.getChild(i), cfg, context, nodeMap);
for(int x = 0; x < before.length; x++) { for (CAstNode element : before) {
prologue.add(before[x]); prologue.add(element);
} }
if(i+1 == start.getChildCount()) { if(i+1 == start.getChildCount()) {
fun_body_stmts.add(addSpuriousExnFlow(start.getChild(i), cfg)); 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]; CAstNode[] after = new CAstNode[start.getChildCount()-i];
for(int j=0;j+i<start.getChildCount();++j) for(int j=0;j+i<start.getChildCount();++j)
after[j] = addSpuriousExnFlow(start.getChild(j+i), cfg); after[j] = addSpuriousExnFlow(start.getChild(j+i), cfg);
for(int x = 0; x < after.length; x++) { for (CAstNode element : after) {
fun_body_stmts.add(after[x]); fun_body_stmts.add(element);
} }
} }
for(i=context.getStart()+1;i<context.getEnd();++i) 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.net.URL;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -78,8 +77,7 @@ public abstract class TestCAstTranslator extends WalaTestCase {
} }
public TranslatorAssertions(Object[][] data) { public TranslatorAssertions(Object[][] data) {
for (int dataIndex = 0; dataIndex < data.length; dataIndex++) { for (Object[] entry : data) {
Object[] entry = data[dataIndex];
String clsName = (String) entry[0]; String clsName = (String) entry[0];
this.classes.add(clsName); this.classes.add(clsName);
@ -88,29 +86,29 @@ public abstract class TestCAstTranslator extends WalaTestCase {
String[] instanceFields = (String[]) entry[2]; String[] instanceFields = (String[]) entry[2];
if (instanceFields != null) { if (instanceFields != null) {
for (int i = 0; i < instanceFields.length; i++) { for (String instanceField : instanceFields) {
this.instanceFields.add(Pair.make(clsName, instanceFields[i])); this.instanceFields.add(Pair.make(clsName, instanceField));
} }
} }
String[] staticFields = (String[]) entry[3]; String[] staticFields = (String[]) entry[3];
if (staticFields != null) { if (staticFields != null) {
for (int i = 0; i < staticFields.length; i++) { for (String staticField : staticFields) {
this.staticFields.add(Pair.make(clsName, staticFields[i])); this.staticFields.add(Pair.make(clsName, staticField));
} }
} }
Pair<?, ?>[] instanceMethods = (Pair[]) entry[4]; Pair<?, ?>[] instanceMethods = (Pair[]) entry[4];
if (instanceMethods != null) { if (instanceMethods != null) {
for (int i = 0; i < instanceMethods.length; i++) { for (Pair<?, ?> instanceMethod : instanceMethods) {
this.instanceMethods.put(Pair.make(clsName, (Object) instanceMethods[i].fst), instanceMethods[i].snd); this.instanceMethods.put(Pair.make(clsName, (Object) instanceMethod.fst), instanceMethod.snd);
} }
} }
Pair<?, ?>[] staticMethods = (Pair[]) entry[5]; Pair<?, ?>[] staticMethods = (Pair[]) entry[5];
if (staticMethods != null) { if (staticMethods != null) {
for (int i = 0; i < staticMethods.length; i++) { for (Pair<?, ?> staticMethod : staticMethods) {
this.staticMethods.put(Pair.make(clsName, (Object) staticMethods[i].fst), staticMethods[i].snd); 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) { protected void dump(ClassHierarchy cha) {
for (Iterator<?> clss = cha.iterator(); clss.hasNext();) { for (Object name : cha) {
IClass cls = (IClass) clss.next(); IClass cls = (IClass) name;
System.err.println(("class " + cls)); System.err.println(("class " + cls));
for (Iterator<?> flds = cls.getDeclaredInstanceFields().iterator(); flds.hasNext();) { for (Object name2 : cls.getDeclaredInstanceFields()) {
IField fld = (IField) flds.next(); IField fld = (IField) name2;
System.err.println(("instance field " + fld)); System.err.println(("instance field " + fld));
} }
for (Iterator<?> flds = cls.getDeclaredStaticFields().iterator(); flds.hasNext();) { for (Object name2 : cls.getDeclaredStaticFields()) {
IField fld = (IField) flds.next(); IField fld = (IField) name2;
System.err.println(("static field " + fld)); System.err.println(("static field " + fld));
} }
for (Iterator<?> mths = cls.getDeclaredMethods().iterator(); mths.hasNext();) { for (Object name2 : cls.getDeclaredMethods()) {
IMethod mth = (IMethod) mths.next(); IMethod mth = (IMethod) name2;
if (mth.isStatic()) if (mth.isStatic())
System.err.print("static "); System.err.print("static ");
System.err.println(("method " + mth + " with " + mth.getNumberOfParameters() + " parameters")); 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(); Map<Pair<String, Object>, Object> staticMethods = assertions.getStaticMethods();
int clsCount = 0; int clsCount = 0;
for (Iterator<?> clss = cha.iterator(); clss.hasNext();) { for (Object name : cha) {
IClass cls = (IClass) clss.next(); IClass cls = (IClass) name;
clsCount++; clsCount++;
Assert.assertTrue("found class " + cls.getName().toString(), classes.contains(cls.getName().toString())); 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())); .get(cls.getName().toString()).equals(cls.getSuperclass().getName().toString()));
} }
for (Iterator<?> flds = cls.getDeclaredInstanceFields().iterator(); flds.hasNext();) { for (Object name2 : cls.getDeclaredInstanceFields()) {
IField fld = (IField) flds.next(); IField fld = (IField) name2;
Assert.assertTrue(cls.getName() + " has field " + fld.getName(), instanceFields.contains(Pair.make( Assert.assertTrue(cls.getName() + " has field " + fld.getName(), instanceFields.contains(Pair.make(
cls.getName().toString(), fld.getName().toString()))); cls.getName().toString(), fld.getName().toString())));
} }
for (Iterator<?> flds = cls.getDeclaredStaticFields().iterator(); flds.hasNext();) { for (Object name2 : cls.getDeclaredStaticFields()) {
IField fld = (IField) flds.next(); IField fld = (IField) name2;
Assert.assertTrue(cls.getName() + " has static field " + fld.getName(), staticFields.contains(Pair.make(cls.getName() Assert.assertTrue(cls.getName() + " has static field " + fld.getName(), staticFields.contains(Pair.make(cls.getName()
.toString(), fld.getName().toString()))); .toString(), fld.getName().toString())));
} }
for (Iterator<?> mths = cls.getDeclaredMethods().iterator(); mths.hasNext();) { for (Object name2 : cls.getDeclaredMethods()) {
IMethod mth = (IMethod) mths.next(); IMethod mth = (IMethod) name2;
Integer np = new Integer(mth.getNumberOfParameters()); Integer np = new Integer(mth.getNumberOfParameters());
Pair<String, String> key = Pair.make(cls.getName().toString(), mth.getName().toString()); 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) { protected void verifyNameAssertions(CallGraph CG, Object[][] assertionData) {
for (int i = 0; i < assertionData.length; i++) { for (Object[] element : assertionData) {
Iterator<CGNode> NS = getNodes(CG, (String) assertionData[i][0]).iterator(); Iterator<CGNode> NS = getNodes(CG, (String) element[0]).iterator();
while (NS.hasNext()) { while (NS.hasNext()) {
CGNode N = NS.next(); CGNode N = NS.next();
IR ir = N.getIR(); IR ir = N.getIR();
Name[] names = (Name[]) assertionData[i][1]; Name[] names = (Name[]) element[1];
for (int j = 0; j < names.length; j++) { 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; boolean found = false;
for (int k = 0; k < localNames.length; k++) { for (String localName : localNames) {
if (localNames[k].equals(names[j].name)) { if (localName.equals(name.name)) {
found = true; 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()) { while (dsts.hasNext()) {
CGNode dst = dsts.next(); CGNode dst = dsts.next();
for (Iterator<CGNode> tos = CG.getPossibleTargets(src, sr).iterator(); tos.hasNext();) { for (CGNode cgNode : CG.getPossibleTargets(src, sr)) {
if (tos.next().equals(dst)) { if (cgNode.equals(dst)) {
if (checkAbsence) { if (checkAbsence) {
System.err.println(("found unexpected " + src + " --> " + dst + " at " + sr)); System.err.println(("found unexpected " + src + " --> " + dst + " at " + sr));
Assert.assertTrue("found edge " + assertionData[i][0] + " ---> " + targetName, false); Assert.assertTrue("found edge " + assertionData[i][0] + " ---> " + targetName, false);

View File

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

View File

@ -384,9 +384,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(lsymtab, ldu, lvn)) { if (contentsAreInvariant(lsymtab, ldu, lvn)) {
InstanceKey[] ik = getInvariantContents(lsymtab, ldu, lnode, lvn); InstanceKey[] ik = getInvariantContents(lsymtab, ldu, lnode, lvn);
system.recordImplicitPointsToSet(lexicalKey); system.recordImplicitPointsToSet(lexicalKey);
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(ik[i]); system.findOrCreateIndexForInstanceKey(element);
system.newConstraint(lval, ik[i]); system.newConstraint(lval, element);
} }
return; return;
@ -407,9 +407,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(symbolTable, du, vn)) { if (contentsAreInvariant(symbolTable, du, vn)) {
InstanceKey[] ik = getInvariantContents(vn); InstanceKey[] ik = getInvariantContents(vn);
system.recordImplicitPointsToSet(rval); system.recordImplicitPointsToSet(rval);
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(ik[i]); system.findOrCreateIndexForInstanceKey(element);
system.newConstraint(lexicalKey, ik[i]); system.newConstraint(lexicalKey, element);
} }
} else { } else {
system.newConstraint(lexicalKey, assignOperator, rval); system.newConstraint(lexicalKey, assignOperator, rval);
@ -527,8 +527,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(symbolTable, du, rval)) { if (contentsAreInvariant(symbolTable, du, rval)) {
InstanceKey objects[] = getInvariantContents(rval); InstanceKey objects[] = getInvariantContents(rval);
for (int i = 0; i < objects.length; i++) { for (InstanceKey object : objects) {
PointerKey catalog = getPointerKeyForObjectCatalog(objects[i]); PointerKey catalog = getPointerKeyForObjectCatalog(object);
system.newConstraint(lk, assignOperator, catalog); system.newConstraint(lk, assignOperator, catalog);
} }
} }
@ -619,10 +619,10 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
* . * .
*/ */
private void doLexicalPointerKeys() { private void doLexicalPointerKeys() {
for (int i = 0; i < accesses.length; i++) { for (Access accesse : accesses) {
final String name = accesses[i].variableName; final String name = accesse.variableName;
final String definer = accesses[i].variableDefiner; final String definer = accesse.variableDefiner;
final int vn = accesses[i].valueNumber; final int vn = accesse.valueNumber;
if (AstTranslator.DEBUG_LEXICAL) if (AstTranslator.DEBUG_LEXICAL)
System.err.println(("looking up lexical parent " + definer)); System.err.println(("looking up lexical parent " + definer));
@ -707,9 +707,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(symtab, du, 1)) { if (contentsAreInvariant(symtab, du, 1)) {
system.recordImplicitPointsToSet(F); system.recordImplicitPointsToSet(F);
final InstanceKey[] functionKeys = getInvariantContents(symtab, du, opNode, 1); final InstanceKey[] functionKeys = getInvariantContents(symtab, du, opNode, 1);
for (int f = 0; f < functionKeys.length; f++) { for (InstanceKey functionKey : functionKeys) {
system.findOrCreateIndexForInstanceKey(functionKeys[f]); system.findOrCreateIndexForInstanceKey(functionKey);
ScopeMappingInstanceKey K = (ScopeMappingInstanceKey) functionKeys[f]; ScopeMappingInstanceKey K = (ScopeMappingInstanceKey) functionKey;
Iterator<CGNode> x = K.getFunargNodes(definer); Iterator<CGNode> x = K.getFunargNodes(definer);
while (x.hasNext()) { while (x.hasNext()) {
result.add(x.next()); result.add(x.next());
@ -764,9 +764,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(st, du, vn)) { if (contentsAreInvariant(st, du, vn)) {
system.recordImplicitPointsToSet(rhs); system.recordImplicitPointsToSet(rhs);
final InstanceKey[] objs = getInvariantContents(st, du, definingNode, vn); final InstanceKey[] objs = getInvariantContents(st, du, definingNode, vn);
for (int f = 0; f < objs.length; f++) { for (InstanceKey obj : objs) {
system.findOrCreateIndexForInstanceKey(objs[f]); system.findOrCreateIndexForInstanceKey(obj);
system.newConstraint(lhs, objs[f]); system.newConstraint(lhs, obj);
} }
} else { } else {
system.newConstraint(lhs, assignOperator, rhs); system.newConstraint(lhs, assignOperator, rhs);
@ -861,8 +861,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(symtab, du, objVn)) { if (contentsAreInvariant(symtab, du, objVn)) {
System.err.print(" constant obj:"); System.err.print(" constant obj:");
InstanceKey[] x = getInvariantContents(symtab, du, opNode, objVn); InstanceKey[] x = getInvariantContents(symtab, du, opNode, objVn);
for (int i = 0; i < x.length; i++) { for (InstanceKey element : x) {
System.err.print((x[i].toString() + " ")); System.err.print((element.toString() + " "));
} }
} else { } else {
System.err.print((" obj:" + system.findOrCreatePointsToSet(objKey))); System.err.print((" obj:" + system.findOrCreatePointsToSet(objKey)));
@ -871,8 +871,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
if (contentsAreInvariant(symtab, du, fieldsVn)) { if (contentsAreInvariant(symtab, du, fieldsVn)) {
System.err.print(" constant prop:"); System.err.print(" constant prop:");
InstanceKey[] x = getInvariantContents(symtab, du, opNode, fieldsVn); InstanceKey[] x = getInvariantContents(symtab, du, opNode, fieldsVn);
for (int i = 0; i < x.length; i++) { for (InstanceKey element : x) {
System.err.print((x[i].toString() + " ")); System.err.print((element.toString() + " "));
} }
} else { } else {
System.err.print((" props:" + system.findOrCreatePointsToSet(fieldKey))); System.err.print((" props:" + system.findOrCreatePointsToSet(fieldKey)));
@ -884,14 +884,14 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
// make sure instance keys get mapped for PointerAnalysisImpl // make sure instance keys get mapped for PointerAnalysisImpl
if (contentsAreInvariant(symtab, du, objVn)) { if (contentsAreInvariant(symtab, du, objVn)) {
InstanceKey[] x = getInvariantContents(symtab, du, opNode, objVn); InstanceKey[] x = getInvariantContents(symtab, du, opNode, objVn);
for (int i = 0; i < x.length; i++) { for (InstanceKey element : x) {
system.findOrCreateIndexForInstanceKey(x[i]); system.findOrCreateIndexForInstanceKey(element);
} }
} }
if (contentsAreInvariant(symtab, du, fieldsVn)) { if (contentsAreInvariant(symtab, du, fieldsVn)) {
InstanceKey[] x = getInvariantContents(symtab, du, opNode, fieldsVn); InstanceKey[] x = getInvariantContents(symtab, du, opNode, fieldsVn);
for (int i = 0; i < x.length; i++) { for (InstanceKey element : x) {
system.findOrCreateIndexForInstanceKey(x[i]); system.findOrCreateIndexForInstanceKey(element);
} }
} }
@ -1022,9 +1022,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
public void act(int optr) { public void act(int optr) {
InstanceKey object = system.getInstanceKey(optr); InstanceKey object = system.getInstanceKey(optr);
PointerKey objCatalog = getPointerKeyForObjectCatalog(object); PointerKey objCatalog = getPointerKeyForObjectCatalog(object);
for (int f = 0; f < fieldsKeys.length; f++) { for (InstanceKey fieldsKey : fieldsKeys) {
if (isLoadOperation) { if (isLoadOperation) {
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldRead(object, fieldsKeys[f]); keys.hasNext();) { for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldRead(object, fieldsKey); keys.hasNext();) {
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next(); AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
if (DEBUG_PROPERTIES) if (DEBUG_PROPERTIES)
action.dump(key, true, false); action.dump(key, true, false);
@ -1032,9 +1032,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
} }
} else { } else {
if (objCatalog != null) { if (objCatalog != null) {
system.newConstraint(objCatalog, fieldsKeys[f]); system.newConstraint(objCatalog, fieldsKey);
} }
for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldWrite(object, fieldsKeys[f]); keys.hasNext();) { for (Iterator<PointerKey> keys = getPointerKeysForReflectedFieldWrite(object, fieldsKey); keys.hasNext();) {
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next(); AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
if (DEBUG_PROPERTIES) if (DEBUG_PROPERTIES)
action.dump(key, true, false); action.dump(key, true, false);
@ -1068,8 +1068,8 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
protected void newFieldOperationOnlyObjectConstant(final boolean isLoadOperation, final ReflectedFieldAction action, protected void newFieldOperationOnlyObjectConstant(final boolean isLoadOperation, final ReflectedFieldAction action,
final PointerKey fieldKey, final InstanceKey[] objKeys) { final PointerKey fieldKey, final InstanceKey[] objKeys) {
if (!isLoadOperation) { if (!isLoadOperation) {
for (int o = 0; o < objKeys.length; o++) { for (InstanceKey objKey : objKeys) {
PointerKey objCatalog = getPointerKeyForObjectCatalog(objKeys[o]); PointerKey objCatalog = getPointerKeyForObjectCatalog(objKey);
if (objCatalog != null) { if (objCatalog != null) {
system.newConstraint(objCatalog, assignOperator, fieldKey); system.newConstraint(objCatalog, assignOperator, fieldKey);
} }
@ -1085,9 +1085,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
@Override @Override
public void act(int fptr) { public void act(int fptr) {
InstanceKey field = system.getInstanceKey(fptr); InstanceKey field = system.getInstanceKey(fptr);
for (int o = 0; o < objKeys.length; o++) { for (InstanceKey objKey : objKeys) {
for (Iterator<PointerKey> keys = isLoadOperation ? getPointerKeysForReflectedFieldRead(objKeys[o], field) for (Iterator<PointerKey> keys = isLoadOperation ? getPointerKeysForReflectedFieldRead(objKey, field)
: getPointerKeysForReflectedFieldWrite(objKeys[o], field); keys.hasNext();) { : getPointerKeysForReflectedFieldWrite(objKey, field); keys.hasNext();) {
AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next(); AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
if (DEBUG_PROPERTIES) if (DEBUG_PROPERTIES)
action.dump(key, false, true); action.dump(key, false, true);
@ -1119,11 +1119,11 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
protected void newFieldOperationObjectAndFieldConstant(final boolean isLoadOperation, final ReflectedFieldAction action, protected void newFieldOperationObjectAndFieldConstant(final boolean isLoadOperation, final ReflectedFieldAction action,
final InstanceKey[] objKeys, InstanceKey[] fieldsKeys) { final InstanceKey[] objKeys, InstanceKey[] fieldsKeys) {
for (int o = 0; o < objKeys.length; o++) { for (InstanceKey objKey : objKeys) {
PointerKey objCatalog = getPointerKeyForObjectCatalog(objKeys[o]); PointerKey objCatalog = getPointerKeyForObjectCatalog(objKey);
for (int f = 0; f < fieldsKeys.length; f++) { for (InstanceKey fieldsKey : fieldsKeys) {
if (isLoadOperation) { 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(); AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
if (DEBUG_PROPERTIES) if (DEBUG_PROPERTIES)
action.dump(key, true, true); action.dump(key, true, true);
@ -1131,9 +1131,9 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
} }
} else { } else {
if (objCatalog != null) { 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(); AbstractFieldPointerKey key = (AbstractFieldPointerKey) keys.next();
if (DEBUG_PROPERTIES) if (DEBUG_PROPERTIES)
action.dump(key, true, true); action.dump(key, true, true);
@ -1167,17 +1167,17 @@ public abstract class AstSSAPropagationCallGraphBuilder extends SSAPropagationCa
@Override @Override
public void dump(AbstractFieldPointerKey fieldKey, boolean constObj, boolean constProp) { public void dump(AbstractFieldPointerKey fieldKey, boolean constObj, boolean constProp) {
System.err.println(("writing fixed rvals to " + fieldKey + " " + constObj + ", " + constProp)); System.err.println(("writing fixed rvals to " + fieldKey + " " + constObj + ", " + constProp));
for (int i = 0; i < rhsFixedValues.length; i++) { for (InstanceKey rhsFixedValue : rhsFixedValues) {
System.err.println(("writing " + rhsFixedValues[i])); System.err.println(("writing " + rhsFixedValue));
} }
} }
@Override @Override
public void action(AbstractFieldPointerKey fieldKey) { public void action(AbstractFieldPointerKey fieldKey) {
if (!representsNullType(fieldKey.getInstanceKey())) { if (!representsNullType(fieldKey.getInstanceKey())) {
for (int i = 0; i < rhsFixedValues.length; i++) { for (InstanceKey rhsFixedValue : rhsFixedValues) {
system.findOrCreateIndexForInstanceKey(rhsFixedValues[i]); system.findOrCreateIndexForInstanceKey(rhsFixedValue);
system.newConstraint(fieldKey, rhsFixedValues[i]); system.newConstraint(fieldKey, rhsFixedValue);
} }
} }
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -209,8 +209,7 @@ public class SSAConversion extends AbstractSSAConversion {
if (DEBUG_UNDO) if (DEBUG_UNDO)
System.err.println(("recreating assignment at " + instructionIndex + " as " + lhs + " = " + rhs)); System.err.println(("recreating assignment at " + instructionIndex + " as " + lhs + " = " + rhs));
for (Iterator<Object> uses = renamedUses.iterator(); uses.hasNext();) { for (Object x : renamedUses) {
Object x = uses.next();
if (x instanceof UseRecord) { if (x instanceof UseRecord) {
UseRecord use = (UseRecord) x; UseRecord use = (UseRecord) x;
int idx = use.instructionIndex; int idx = use.instructionIndex;
@ -235,8 +234,8 @@ public class SSAConversion extends AbstractSSAConversion {
} }
} }
for (Iterator<CopyPropagationRecord> cs = childRecords.iterator(); cs.hasNext();) { for (CopyPropagationRecord copyPropagationRecord : childRecords) {
cs.next().undo(lhs); copyPropagationRecord.undo(lhs);
} }
} }
@ -545,9 +544,9 @@ public class SSAConversion extends AbstractSSAConversion {
int[] exitLive = lexicalInfo.getExitExposedUses(); int[] exitLive = lexicalInfo.getExitExposedUses();
BitVector v = new BitVector(); BitVector v = new BitVector();
if (exitLive != null) { if (exitLive != null) {
for (int i = 0; i < exitLive.length; i++) { for (int element : exitLive) {
if (exitLive[i] > -1) { if (element > -1) {
v.set(exitLive[i]); v.set(element);
} }
} }
} }
@ -624,8 +623,8 @@ public class SSAConversion extends AbstractSSAConversion {
int[] lexicalUses = lexicalInfo.getExposedUses(i); int[] lexicalUses = lexicalInfo.getExposedUses(i);
if (lexicalUses != null) { if (lexicalUses != null) {
System.err.print(("extra uses for " + instructions[i] + ": ")); System.err.print(("extra uses for " + instructions[i] + ": "));
for (int j = 0; j < lexicalUses.length; j++) { for (int lexicalUse : lexicalUses) {
System.err.print((new Integer(lexicalUses[j]).toString() + " ")); System.err.print((new Integer(lexicalUse).toString() + " "));
} }
System.err.println(""); System.err.println("");
} }
@ -640,8 +639,7 @@ public class SSAConversion extends AbstractSSAConversion {
SSAInstruction[] insts = ir.getInstructions(); SSAInstruction[] insts = ir.getInstructions();
MutableIntSet foundOne = new BitVectorIntSet(); MutableIntSet foundOne = new BitVectorIntSet();
MutableIntSet foundTwo = new BitVectorIntSet(); MutableIntSet foundTwo = new BitVectorIntSet();
for (int i = 0; i < insts.length; i++) { for (SSAInstruction inst : insts) {
SSAInstruction inst = insts[i];
if (inst != null) { if (inst != null) {
for (int j = 0; j < inst.getNumberOfDefs(); j++) { for (int j = 0; j < inst.getNumberOfDefs(); j++) {
int def = inst.getDef(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) { private void checkForRealizedEdges(CAstNode n) {
if (delayedEdges.containsKey(n)) { if (delayedEdges.containsKey(n)) {
for (Iterator<Pair<PreBasicBlock, Boolean>> ss = delayedEdges.get(n).iterator(); ss.hasNext();) { for (Pair<PreBasicBlock, Boolean> s : delayedEdges.get(n)) {
Pair<PreBasicBlock, Boolean> s = ss.next();
PreBasicBlock src = s.fst; PreBasicBlock src = s.fst;
boolean exception = s.snd; boolean exception = s.snd;
if (unwind == null) { if (unwind == null) {
@ -965,8 +964,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
*/ */
private void checkForRealizedExitEdges(PreBasicBlock exitBlock) { private void checkForRealizedExitEdges(PreBasicBlock exitBlock) {
if (delayedEdges.containsKey(exitMarker)) { if (delayedEdges.containsKey(exitMarker)) {
for (Iterator<Pair<PreBasicBlock, Boolean>> ss = delayedEdges.get(exitMarker).iterator(); ss.hasNext();) { for (Pair<PreBasicBlock, Boolean> s : delayedEdges.get(exitMarker)) {
Pair<PreBasicBlock, Boolean> s = ss.next();
PreBasicBlock src = s.fst; PreBasicBlock src = s.fst;
boolean exception = s.snd; boolean exception = s.snd;
addEdge(src, exitBlock); addEdge(src, exitBlock);
@ -1362,8 +1360,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
SSAInstruction[] insts = getInstructions(); SSAInstruction[] insts = getInstructions();
StringBuffer s = new StringBuffer("CAst CFG of " + functionName); StringBuffer s = new StringBuffer("CAst CFG of " + functionName);
int params[] = symtab.getParameterValueNumbers(); int params[] = symtab.getParameterValueNumbers();
for (int i = 0; i < params.length; i++) for (int param : params)
s.append(" ").append(params[i]); s.append(" ").append(param);
s.append("\n"); s.append("\n");
for (int i = 0; i < getNumberOfNodes(); i++) { for (int i = 0; i < getNumberOfNodes(); i++) {
@ -2621,8 +2619,8 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
} else { } else {
TypeReference[] data = catchTypes.get(bb); TypeReference[] data = catchTypes.get(bb);
for (int i = 0; i < data.length; i++) { for (TypeReference element : data) {
if (data[i] == catchType) { if (element == catchType) {
return; return;
} }
} }
@ -2881,8 +2879,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
if (accesses != null) { if (accesses != null) {
Set<String> parents = new LinkedHashSet<>(); Set<String> parents = new LinkedHashSet<>();
for (Iterator<Access> ACS = accesses.iterator(); ACS.hasNext();) { for (Access AC : accesses) {
Access AC = ACS.next();
if (AC.variableDefiner != null) { if (AC.variableDefiner != null) {
parents.add(AC.variableDefiner); parents.add(AC.variableDefiner);
} }
@ -2928,18 +2925,18 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
if (allExposedUses == null) { if (allExposedUses == null) {
allExposedUses = IntSetUtil.make(); allExposedUses = IntSetUtil.make();
if (exitLexicalUses != null) { if (exitLexicalUses != null) {
for (int i = 0; i < exitLexicalUses.length; i++) { for (int exitLexicalUse : exitLexicalUses) {
if (exitLexicalUses[i] > 0) { if (exitLexicalUse > 0) {
allExposedUses.add(exitLexicalUses[i]); allExposedUses.add(exitLexicalUse);
} }
} }
} }
if (instructionLexicalUses != null) { if (instructionLexicalUses != null) {
for (int i = 0; i < instructionLexicalUses.length; i++) { for (int[] instructionLexicalUse : instructionLexicalUses) {
if (instructionLexicalUses[i] != null) { if (instructionLexicalUse != null) {
for (int j = 0; j < instructionLexicalUses[i].length; j++) { for (int j = 0; j < instructionLexicalUse.length; j++) {
if (instructionLexicalUses[i][j] > 0) { if (instructionLexicalUse[j] > 0) {
allExposedUses.add(instructionLexicalUses[i][j]); allExposedUses.add(instructionLexicalUse[j]);
} }
} }
} }
@ -3120,8 +3117,7 @@ public abstract class AstTranslator extends CAstVisitor<AstTranslator.WalkContex
System.err.println(("names array of size " + map.length)); System.err.println(("names array of size " + map.length));
} }
for (Iterator<Scope> S = scopes.iterator(); S.hasNext();) { for (Scope scope : scopes) {
Scope scope = S.next();
for (Iterator<String> I = scope.getAllNames(); I.hasNext();) { for (Iterator<String> I = scope.getAllNames(); I.hasNext();) {
String nm = I.next(); String nm = I.next();

View File

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

View File

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

View File

@ -96,15 +96,14 @@ public abstract class CAstAbstractModuleLoader extends CAstAbstractLoader {
// convert everything to CAst // convert everything to CAst
final Set<Pair<CAstEntity, ModuleEntry>> topLevelEntities = new LinkedHashSet<>(); final Set<Pair<CAstEntity, ModuleEntry>> topLevelEntities = new LinkedHashSet<>();
for (Iterator<Module> mes = modules.iterator(); mes.hasNext();) { for (Module module : modules) {
translateModuleToCAst(mes.next(), ast, topLevelEntities); translateModuleToCAst(module, ast, topLevelEntities);
} }
// generate IR as needed // generate IR as needed
final TranslatorToIR xlatorToIR = initTranslator(); final TranslatorToIR xlatorToIR = initTranslator();
for (Iterator<Pair<CAstEntity, ModuleEntry>> tles = topLevelEntities.iterator(); tles.hasNext();) { for (Pair<CAstEntity, ModuleEntry> p : topLevelEntities) {
Pair<CAstEntity, ModuleEntry> p = tles.next();
if (shouldTranslate(p.fst)) { if (shouldTranslate(p.fst)) {
xlatorToIR.translate(p.fst, p.snd); 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.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.Map; import java.util.Map;
@ -127,8 +126,7 @@ public class CAstControlFlowRecorder implements CAstControlFlowMap {
Collection<CAstNode> nodes = cachedMappedNodes; Collection<CAstNode> nodes = cachedMappedNodes;
if (nodes == null) { if (nodes == null) {
nodes = new LinkedHashSet<>(); nodes = new LinkedHashSet<>();
for (Iterator<Key> keys = table.keySet().iterator(); keys.hasNext();) { for (Key key : table.keySet()) {
Key key = keys.next();
nodes.add(nodeToCAst.get(key.from)); nodes.add(nodeToCAst.get(key.from));
nodes.add(nodeToCAst.get(table.get(key))); nodes.add(nodeToCAst.get(table.get(key)));
} }

View File

@ -33,8 +33,8 @@ public class CAstValueImpl extends CAstImpl {
@Override @Override
public int hashCode() { public int hashCode() {
int value = 1237 * kind; int value = 1237 * kind;
for(int i = 0; i < cs.length; i++) for (CAstNode element : cs)
value *= cs[i].hashCode(); value *= element.hashCode();
return value; 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); Set<CAstNode> allNewTargetNodes = HashSetFactory.make(1);
Collection<CAstNode> oldSources = orig.getMappedNodes(); Collection<CAstNode> oldSources = orig.getMappedNodes();
for (Iterator<Entry<Pair<CAstNode, K>, CAstNode>> NS = nodeMap.entrySet().iterator(); NS.hasNext();) { for (Entry<Pair<CAstNode, K>, CAstNode> entry : nodeMap.entrySet()) {
Entry<Pair<CAstNode, K>, CAstNode> entry = NS.next();
Pair<CAstNode, K> N = entry.getKey(); Pair<CAstNode, K> N = entry.getKey();
CAstNode oldSource = N.fst; CAstNode oldSource = N.fst;
K key = N.snd; 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) { protected CAstSourcePositionMap copySource(Map<Pair<CAstNode, K>, CAstNode> nodeMap, CAstSourcePositionMap orig) {
CAstSourcePositionRecorder newMap = new CAstSourcePositionRecorder(); CAstSourcePositionRecorder newMap = new CAstSourcePositionRecorder();
for (Iterator<Map.Entry<Pair<CAstNode, K>, CAstNode>> NS = nodeMap.entrySet().iterator(); NS.hasNext();) { for (Entry<Pair<CAstNode, K>, CAstNode> entry : nodeMap.entrySet()) {
Map.Entry<Pair<CAstNode, K>, CAstNode> entry = NS.next();
Pair<CAstNode, K> N = entry.getKey(); Pair<CAstNode, K> N = entry.getKey();
CAstNode oldNode = N.fst; 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) { protected CAstNodeTypeMap copyTypes(Map<Pair<CAstNode, K>, CAstNode> nodeMap, CAstNodeTypeMap orig) {
if (orig != null) { if (orig != null) {
CAstNodeTypeMapRecorder newMap = new CAstNodeTypeMapRecorder(); CAstNodeTypeMapRecorder newMap = new CAstNodeTypeMapRecorder();
for (Iterator<Entry<Pair<CAstNode, K>, CAstNode>> NS = nodeMap.entrySet().iterator(); NS.hasNext();) { for (Entry<Pair<CAstNode, K>, CAstNode> entry : nodeMap.entrySet()) {
Entry<Pair<CAstNode, K>, CAstNode> entry = NS.next();
Pair<CAstNode, K> N = entry.getKey(); Pair<CAstNode, K> N = entry.getKey();
CAstNode oldNode = N.fst; CAstNode oldNode = N.fst;
@ -312,8 +309,7 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
Map<CAstNode, Collection<CAstEntity>> children) { Map<CAstNode, Collection<CAstEntity>> children) {
final Map<CAstNode, Collection<CAstEntity>> newChildren = new LinkedHashMap<>(); final Map<CAstNode, Collection<CAstEntity>> newChildren = new LinkedHashMap<>();
for (Iterator<Entry<Pair<CAstNode, K>, CAstNode>> NS = nodeMap.entrySet().iterator(); NS.hasNext();) { for (Entry<Pair<CAstNode, K>, CAstNode> entry : nodeMap.entrySet()) {
Entry<Pair<CAstNode, K>, CAstNode> entry = NS.next();
Pair<CAstNode, K> N = entry.getKey(); Pair<CAstNode, K> N = entry.getKey();
CAstNode oldNode = N.fst; CAstNode oldNode = N.fst;
@ -322,14 +318,13 @@ public abstract class CAstRewriter<C extends CAstRewriter.RewriteContext<K>, K e
if (children.containsKey(oldNode)) { if (children.containsKey(oldNode)) {
Set<CAstEntity> newEntities = new LinkedHashSet<>(); Set<CAstEntity> newEntities = new LinkedHashSet<>();
newChildren.put(newNode, newEntities); newChildren.put(newNode, newEntities);
for (Iterator<CAstEntity> oldEntities = children.get(oldNode).iterator(); oldEntities.hasNext();) { for (CAstEntity cAstEntity : children.get(oldNode)) {
newEntities.add(rewrite(oldEntities.next())); newEntities.add(rewrite(cAstEntity));
} }
} }
} }
for (Iterator<Map.Entry<CAstNode, Collection<CAstEntity>>> keys = children.entrySet().iterator(); keys.hasNext();) { for (Entry<CAstNode, Collection<CAstEntity>> entry : children.entrySet()) {
Map.Entry<CAstNode, Collection<CAstEntity>> entry = keys.next();
CAstNode key = entry.getKey(); CAstNode key = entry.getKey();
if (key == null) { if (key == null) {
Set<CAstEntity> newEntities = new LinkedHashSet<>(); 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(); Map<CAstNode, Collection<CAstEntity>> children = root.getAllScopedEntities();
final Map<CAstNode, Collection<CAstEntity>> newChildren = new LinkedHashMap<>(); final Map<CAstNode, Collection<CAstEntity>> newChildren = new LinkedHashMap<>();
for (Iterator<Map.Entry<CAstNode, Collection<CAstEntity>>> keys = children.entrySet().iterator(); keys.hasNext();) { for (Entry<CAstNode, Collection<CAstEntity>> entry : children.entrySet()) {
Map.Entry<CAstNode, Collection<CAstEntity>> entry = keys.next();
CAstNode key = entry.getKey(); CAstNode key = entry.getKey();
Set<CAstEntity> newValues = new LinkedHashSet<>(); Set<CAstEntity> newValues = new LinkedHashSet<>();
newChildren.put(key, newValues); newChildren.put(key, newValues);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -63,8 +63,8 @@ public class CloneTest extends WalaTestCase {
Set<CGNode> targets = cg.getPossibleTargets(node, site); Set<CGNode> targets = cg.getPossibleTargets(node, site);
if (targets.size() != 1) { if (targets.size() != 1) {
System.err.println(targets.size() + " targets found for " + site); System.err.println(targets.size() + " targets found for " + site);
for (Iterator<CGNode> k = targets.iterator(); k.hasNext();) { for (CGNode cgNode : targets) {
System.err.println(" " + k.next()); System.err.println(" " + cgNode);
} }
Assert.fail("found " + targets.size() + " targets for " + site + " in " + node); 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) { public static CGNode findStaticMethod(CallGraph cg, Atom name, Descriptor args) {
for (Iterator<? extends CGNode> it = cg.iterator(); it.hasNext();) { for (CGNode n : cg) {
CGNode n = it.next();
// System.err.println(n.getMethod().getName() + " " + // System.err.println(n.getMethod().getName() + " " +
// n.getMethod().getDescriptor()); // n.getMethod().getDescriptor());
if (n.getMethod().getName().equals(name) && n.getMethod().getDescriptor().equals(args)) { 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) { public static CGNode findInstanceMethod(CallGraph cg, IClass declaringClass, Atom name, Descriptor args) {
for (Iterator<? extends CGNode> it = cg.iterator(); it.hasNext();) { for (CGNode n : cg) {
CGNode n = it.next();
// System.err.println(n.getMethod().getDeclaringClass() + " " + // System.err.println(n.getMethod().getDeclaringClass() + " " +
// n.getMethod().getName() + " " + n.getMethod().getDescriptor()); // n.getMethod().getName() + " " + n.getMethod().getDescriptor());
if (n.getMethod().getDeclaringClass().equals(declaringClass) && n.getMethod().getName().equals(name) if (n.getMethod().getDeclaringClass().equals(declaringClass) && n.getMethod().getName().equals(name)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -245,8 +245,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
private OrdinalSetMapping<PointerKey> getPointerKeys() { private OrdinalSetMapping<PointerKey> getPointerKeys() {
MutableMapping<PointerKey> result = MutableMapping.make(); MutableMapping<PointerKey> result = MutableMapping.make();
for (Iterator<PointerKey> it = getPointerAnalysis().getPointerKeys().iterator(); it.hasNext();) { for (PointerKey p : getPointerAnalysis().getPointerKeys()) {
PointerKey p = it.next();
result.add(p); result.add(p);
} }
return result; return result;
@ -259,8 +258,8 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
OrdinalSet<T> S = getPointerAnalysis().getPointsToSet(P); OrdinalSet<T> S = getPointerAnalysis().getPointsToSet(P);
int[] result = new int[S.size()]; int[] result = new int[S.size()];
int i = 0; int i = 0;
for (Iterator<T> it = S.iterator(); it.hasNext();) { for (T t : S) {
result[i] = nodeManager.getNumber(it.next()); result[i] = nodeManager.getNumber(t);
i++; i++;
} }
return result; return result;
@ -280,8 +279,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
IClass klass = getHeapModel().getClassHierarchy().lookupClass(T); IClass klass = getHeapModel().getClassHierarchy().lookupClass(T);
assert klass != null : "null klass for type " + T; assert klass != null : "null klass for type " + T;
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty(); MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
for (Iterator<IField> it = klass.getAllInstanceFields().iterator(); it.hasNext();) { for (IField f : klass.getAllInstanceFields()) {
IField f = it.next();
if (!f.getReference().getFieldType().isPrimitiveType()) { if (!f.getReference().getFieldType().isPrimitiveType()) {
PointerKey p = getHeapModel().getPointerKeyForInstanceField(I, f); PointerKey p = getHeapModel().getPointerKeyForInstanceField(I, f);
if (p != null && nodeManager.containsNode(p)) { if (p != null && nodeManager.containsNode(p)) {
@ -326,8 +324,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
if (!(n instanceof LocalPointerKey)) { if (!(n instanceof LocalPointerKey)) {
int[] succ = computeSuccNodeNumbers(n, nodeManager); int[] succ = computeSuccNodeNumbers(n, nodeManager);
if (succ != null) { if (succ != null) {
for (int z = 0; z < succ.length; z++) { for (int j : succ) {
int j = succ[z];
R.add(j, i); R.add(j, i);
} }
} }
@ -341,8 +338,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
private void computePredecessorsForLocals(NumberedNodeManager<Object> nodeManager, BasicNaturalRelation R) { private void computePredecessorsForLocals(NumberedNodeManager<Object> nodeManager, BasicNaturalRelation R) {
ArrayList<LocalPointerKey> list = new ArrayList<LocalPointerKey>(); ArrayList<LocalPointerKey> list = new ArrayList<LocalPointerKey>();
for (Iterator<Object> it = nodeManager.iterator(); it.hasNext();) { for (Object n : nodeManager) {
Object n = it.next();
if (n instanceof LocalPointerKey) { if (n instanceof LocalPointerKey) {
list.add((LocalPointerKey) n); list.add((LocalPointerKey) n);
} }
@ -360,8 +356,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
int num = nodeManager.getNumber(n); int num = nodeManager.getNumber(n);
int[] succ = computeSuccNodeNumbers(n, nodeManager); int[] succ = computeSuccNodeNumbers(n, nodeManager);
if (succ != null) { if (succ != null) {
for (int z = 0; z < succ.length; z++) { for (int j : succ) {
int j = succ[z];
R.add(j, num); R.add(j, num);
} }
} }

View File

@ -189,8 +189,7 @@ public class CloneInterpreter implements SSAContextInterpreter {
// TODO: // TODO:
IClass k = klass; IClass k = klass;
while (k != null) { while (k != null) {
for (Iterator<IField> it = klass.getDeclaredInstanceFields().iterator(); it.hasNext();) { for (IField f : klass.getDeclaredInstanceFields()) {
IField f = it.next();
int tempValue = nextLocal++; int tempValue = nextLocal++;
SSAGetInstruction G = insts.GetInstruction(statements.size(), tempValue, 1, f.getReference()); SSAGetInstruction G = insts.GetInstruction(statements.size(), tempValue, 1, f.getReference());
statements.add(G); statements.add(G);

View File

@ -157,8 +157,8 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
} }
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node); SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
HashSet<NewSiteReference> result = HashSetFactory.make(5); HashSet<NewSiteReference> result = HashSetFactory.make(5);
for (Iterator<SSAInstruction> it = m.getAllocationStatements().iterator(); it.hasNext();) { for (SSAInstruction ssaInstruction : m.getAllocationStatements()) {
SSANewInstruction s = (SSANewInstruction) it.next(); SSANewInstruction s = (SSANewInstruction) ssaInstruction;
result.add(s.getNewSite()); result.add(s.getNewSite());
} }
return result.iterator(); return result.iterator();
@ -393,8 +393,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
// add original statements from the method summary // add original statements from the method summary
nextLocal = addOriginalStatements(m); nextLocal = addOriginalStatements(m);
for (Iterator<TypeReference> it = S.iterator(); it.hasNext();) { for (TypeReference type : S) {
TypeReference type = it.next();
TypeAbstraction T = typeRef2TypeAbstraction(m.getClassHierarchy(), type); TypeAbstraction T = typeRef2TypeAbstraction(m.getClassHierarchy(), type);
addStatementsForTypeAbstraction(T); addStatementsForTypeAbstraction(T);
} }
@ -506,8 +505,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
SSAInstruction[] original = m.getStatements(options.getSSAOptions()); SSAInstruction[] original = m.getStatements(options.getSSAOptions());
// local value number 1 is "this", so the next free value number is 2 // local value number 1 is "this", so the next free value number is 2
int nextLocal = 2; int nextLocal = 2;
for (int i = 0; i < original.length; i++) { for (SSAInstruction s : original) {
SSAInstruction s = original[i];
allInstructions.add(s); allInstructions.add(s);
if (s instanceof SSAInvokeInstruction) { if (s instanceof SSAInvokeInstruction) {
calls.add(s); calls.add(s);
@ -603,8 +601,8 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
public SSAInstruction[] getStatements() { public SSAInstruction[] getStatements() {
SSAInstruction[] result = new SSAInstruction[allInstructions.size()]; SSAInstruction[] result = new SSAInstruction[allInstructions.size()];
int i = 0; int i = 0;
for (Iterator<SSAInstruction> it = allInstructions.iterator(); it.hasNext();) { for (SSAInstruction ssaInstruction : allInstructions) {
result[i++] = it.next(); result[i++] = ssaInstruction;
} }
return result; return result;
} }

View File

@ -684,8 +684,8 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
return true; return true;
if (locals != null) if (locals != null)
for (int i = 0; i < locals.length; i++) for (int local : locals)
if (locals[i] == val) if (local == val)
return true; return true;
return false; return false;

View File

@ -217,8 +217,7 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
x = new TypeReference[]{ language.getThrowableType() }; x = new TypeReference[]{ language.getThrowableType() };
} }
if (x != null) { if (x != null) {
for (int i = 0; i < x.length; i++) { for (TypeReference tx : x) {
TypeReference tx = x[i];
IClass tc = cha.lookupClass(tx); IClass tc = cha.lookupClass(tx);
if (tc != null) { if (tc != null) {
v.setType(v.getType().meet(new ConeType(tc))); 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 lhsType = lhs.getType();
TypeAbstraction meet = TypeAbstraction.TOP; TypeAbstraction meet = TypeAbstraction.TOP;
for (int i = 0; i < rhs.length; i++) { for (TypeVariable r : rhs) {
if (rhs[i] != null && rhs[i].getType() != null) { if (r != null && r.getType() != null) {
TypeVariable r = rhs[i];
meet = meet.meet(r.getType()); meet = meet.meet(r.getType());
} }
} }
@ -386,9 +384,8 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
public byte evaluate(TypeVariable lhs, TypeVariable[] rhs) { public byte evaluate(TypeVariable lhs, TypeVariable[] rhs) {
TypeAbstraction lhsType = lhs.getType(); TypeAbstraction lhsType = lhs.getType();
TypeAbstraction meet = TypeAbstraction.TOP; TypeAbstraction meet = TypeAbstraction.TOP;
for (int i = 0; i < rhs.length; i++) { for (TypeVariable r : rhs) {
if (rhs[i] != null && rhs[i].getType() != null) { if (r != null && r.getType() != null) {
TypeVariable r = rhs[i];
meet = meet.meet(r.getType()); meet = meet.meet(r.getType());
} }
} }

View File

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

View File

@ -48,13 +48,12 @@ public class CFGSanitizer {
ControlFlowGraph<SSAInstruction, ISSABasicBlock> cfg = ir.getControlFlowGraph(); ControlFlowGraph<SSAInstruction, ISSABasicBlock> cfg = ir.getControlFlowGraph();
Graph<ISSABasicBlock> g = SlowSparseNumberedGraph.make(); Graph<ISSABasicBlock> g = SlowSparseNumberedGraph.make();
// add all nodes to the graph // add all nodes to the graph
for (Iterator<? extends ISSABasicBlock> it = cfg.iterator(); it.hasNext();) { for (ISSABasicBlock basicBlock : cfg) {
g.addNode(it.next()); g.addNode(basicBlock);
} }
// add all edges to the graph, except those that go to exit // add all edges to the graph, except those that go to exit
for (Iterator<ISSABasicBlock> it = cfg.iterator(); it.hasNext();) { for (ISSABasicBlock b : cfg) {
ISSABasicBlock b = it.next();
for (Iterator<ISSABasicBlock> it2 = cfg.getSuccNodes(b); it2.hasNext();) { for (Iterator<ISSABasicBlock> it2 = cfg.getSuccNodes(b); it2.hasNext();) {
ISSABasicBlock b2 = it2.next(); ISSABasicBlock b2 = it2.next();
@ -125,17 +124,17 @@ public class CFGSanitizer {
Assertions.UNREACHABLE(); Assertions.UNREACHABLE();
} }
if (declared != null && exceptions != null) { if (declared != null && exceptions != null) {
for (int i = 0; i < exceptions.length; i++) { for (TypeReference exception : exceptions) {
boolean isDeclared = false; boolean isDeclared = false;
if (exceptions[i] != null) { if (exception != null) {
IClass exi = cha.lookupClass(exceptions[i]); IClass exi = cha.lookupClass(exception);
if (exi == null) { 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++) { for (TypeReference element : declared) {
IClass dc = cha.lookupClass(declared[j]); IClass dc = cha.lookupClass(element);
if (dc == null) { if (dc == null) {
throw new WalaException("failed to find " + declared[j]); throw new WalaException("failed to find " + element);
} }
if (cha.isSubclassOf(exi, dc)) { if (cha.isSubclassOf(exi, dc)) {
isDeclared = true; isDeclared = true;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -257,8 +257,7 @@ public class CodeScanner {
result.addAll(t); result.addAll(t);
} }
}; };
for (int i = 0; i < statements.length; i++) { for (SSAInstruction s : statements) {
SSAInstruction s = statements[i];
if (s != null) { if (s != null) {
s.visit(v); s.visit(v);
} }
@ -274,10 +273,10 @@ public class CodeScanner {
throw new IllegalArgumentException("statements == null"); throw new IllegalArgumentException("statements == null");
} }
final HashSet<TypeReference> result = HashSetFactory.make(10); final HashSet<TypeReference> result = HashSetFactory.make(10);
for (int i = 0; i < statements.length; i++) { for (SSAInstruction statement : statements) {
if (statements[i] != null) { if (statement != null) {
if (statements[i] instanceof SSACheckCastInstruction) { if (statement instanceof SSACheckCastInstruction) {
SSACheckCastInstruction c = (SSACheckCastInstruction) statements[i]; SSACheckCastInstruction c = (SSACheckCastInstruction) statement;
for(TypeReference t : c.getDeclaredResultTypes()) { for(TypeReference t : c.getDeclaredResultTypes()) {
result.add(t); result.add(t);
} }
@ -299,8 +298,7 @@ public class CodeScanner {
result.add(instruction.getCallSite()); result.add(instruction.getCallSite());
} }
}; };
for (int i = 0; i < statements.length; i++) { for (SSAInstruction s : statements) {
SSAInstruction s = statements[i];
if (s != null) { if (s != null) {
s.visit(v); s.visit(v);
} }
@ -320,8 +318,7 @@ public class CodeScanner {
result.add(instruction.getNewSite()); result.add(instruction.getNewSite());
} }
}; };
for (int i = 0; i < statements.length; i++) { for (SSAInstruction s : statements) {
SSAInstruction s = statements[i];
if (s != null) { if (s != null) {
s.visit(v); s.visit(v);
} }
@ -345,8 +342,7 @@ public class CodeScanner {
result.add(instruction.getDeclaredField()); result.add(instruction.getDeclaredField());
} }
}; };
for (int i = 0; i < statements.length; i++) { for (SSAInstruction s : statements) {
SSAInstruction s = statements[i];
if (s != null) { if (s != null) {
s.visit(v); s.visit(v);
} }
@ -370,8 +366,7 @@ public class CodeScanner {
result.add(instruction.getDeclaredField()); result.add(instruction.getDeclaredField());
} }
}; };
for (int i = 0; i < statements.length; i++) { for (SSAInstruction s : statements) {
SSAInstruction s = statements[i];
if (s != null) { if (s != null) {
s.visit(v); s.visit(v);
} }
@ -397,8 +392,7 @@ public class CodeScanner {
} }
}; };
for (int i = 0; i < statements.length; i++) { for (SSAInstruction s : statements) {
SSAInstruction s = statements[i];
if (s != null) { if (s != null) {
s.visit(v); s.visit(v);
} }
@ -422,8 +416,7 @@ public class CodeScanner {
} }
} }
ScanVisitor v = new ScanVisitor(); ScanVisitor v = new ScanVisitor();
for (int i = 0; i < statements.length; i++) { for (SSAInstruction s : statements) {
SSAInstruction s = statements[i];
if (s != null) { if (s != null) {
s.visit(v); s.visit(v);
} }
@ -450,8 +443,7 @@ public class CodeScanner {
} }
} }
ScanVisitor v = new ScanVisitor(); ScanVisitor v = new ScanVisitor();
for (int i = 0; i < statements.length; i++) { for (SSAInstruction s : statements) {
SSAInstruction s = statements[i];
if (s != null) { if (s != null) {
s.visit(v); s.visit(v);
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -92,8 +92,7 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
private boolean mayEscape(Set<CGNode> allocN, int allocPC, Set nodes) throws WalaException { private boolean mayEscape(Set<CGNode> allocN, int allocPC, Set nodes) throws WalaException {
Set<InstanceKey> instances = HashSetFactory.make(); Set<InstanceKey> instances = HashSetFactory.make();
// instances := set of instance key allocated at &lt;allocMethod, allocPC> // instances := set of instance key allocated at &lt;allocMethod, allocPC>
for (Iterator<CGNode> it = allocN.iterator(); it.hasNext();) { for (CGNode n : allocN) {
CGNode n = it.next();
NewSiteReference site = findAlloc(n, allocPC); NewSiteReference site = findAlloc(n, allocPC);
InstanceKey ik = hg.getHeapModel().getInstanceKeyForAllocation(n, site); InstanceKey ik = hg.getHeapModel().getInstanceKeyForAllocation(n, site);
if (ik == null) { if (ik == null) {
@ -102,8 +101,7 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
instances.add(ik); instances.add(ik);
} }
for (Iterator<InstanceKey> it = instances.iterator(); it.hasNext();) { for (InstanceKey ik : instances) {
InstanceKey ik = it.next();
for (Iterator<Object> it2 = hg.getPredNodes(ik); it2.hasNext();) { for (Iterator<Object> it2 = hg.getPredNodes(ik); it2.hasNext();) {
PointerKey p = (PointerKey) it2.next(); PointerKey p = (PointerKey) it2.next();
if (!(p instanceof AbstractLocalPointerKey)) { if (!(p instanceof AbstractLocalPointerKey)) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -105,8 +105,7 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
@Override @Override
public Set<CGNode> getNodes(MethodReference m) { public Set<CGNode> getNodes(MethodReference m) {
Set<CGNode> result = HashSetFactory.make(); Set<CGNode> result = HashSetFactory.make();
for (Iterator<CGNode> xs = cg.getNodes(m).iterator(); xs.hasNext();) { for (CGNode x : cg.getNodes(m)) {
CGNode x = xs.next();
if (containsNode(x)) { if (containsNode(x)) {
result.add(x); result.add(x);
} }
@ -189,8 +188,7 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
return null; return null;
} }
Set<CGNode> result = HashSetFactory.make(); Set<CGNode> result = HashSetFactory.make();
for (Iterator<CGNode> ns = cg.getPossibleTargets(node, site).iterator(); ns.hasNext();) { for (CGNode target : cg.getPossibleTargets(node, site)) {
CGNode target = ns.next();
if (containsNode(target)) { if (containsNode(target)) {
result.add(target); result.add(target);
} }

View File

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

View File

@ -93,8 +93,7 @@ public final class ConcreteTypeKey implements InstanceKey {
} }
InstanceKey[] result = new InstanceKey[types.size()]; InstanceKey[] result = new InstanceKey[types.size()];
int i = 0; int i = 0;
for (Iterator<TypeReference> it = types.iterator(); it.hasNext();) { for (TypeReference type : types) {
TypeReference type = it.next();
assert type != null; assert type != null;
IClass klass = cha.lookupClass(type); IClass klass = cha.lookupClass(type);
result[i++] = new ConcreteTypeKey(klass); result[i++] = new ConcreteTypeKey(klass);

View File

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

View File

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

View File

@ -733,8 +733,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
return 0; return 0;
} }
int result = delegateGraph.getSuccNodeCount(v); int result = delegateGraph.getSuccNodeCount(v);
for (Iterator<UnaryOperator<PointsToSetVariable>> it = invImplicitUnaryMap.keySet().iterator(); it.hasNext();) { for (UnaryOperator<PointsToSetVariable> op : invImplicitUnaryMap.keySet()) {
UnaryOperator<PointsToSetVariable> op = it.next();
IBinaryNaturalRelation R = invImplicitUnaryMap.get(op); IBinaryNaturalRelation R = invImplicitUnaryMap.get(op);
IntSet s = R.getRelated(number); IntSet s = R.getRelated(number);
if (s != null) { if (s != null) {
@ -754,8 +753,7 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
return 0; return 0;
} }
int result = delegateGraph.getPredNodeCount(v); int result = delegateGraph.getPredNodeCount(v);
for (Iterator<UnaryOperator<PointsToSetVariable>> it = implicitUnaryMap.keySet().iterator(); it.hasNext();) { for (UnaryOperator<PointsToSetVariable> op : implicitUnaryMap.keySet()) {
UnaryOperator<PointsToSetVariable> op = it.next();
IBinaryNaturalRelation R = implicitUnaryMap.get(op); IBinaryNaturalRelation R = implicitUnaryMap.get(op);
IntSet s = R.getRelated(number); IntSet s = R.getRelated(number);
if (s != null) { if (s != null) {
@ -788,9 +786,9 @@ public class PropagationGraph implements IFixedPointSystem<PointsToSetVariable>
System.err.println("implicit map:"); System.err.println("implicit map:");
int count = 0; int count = 0;
int totalBytes = 0; int totalBytes = 0;
for (Iterator<Entry<UnaryOperator<PointsToSetVariable>, IBinaryNaturalRelation>> it = implicitUnaryMap.entrySet().iterator(); it.hasNext();) { for (Entry<UnaryOperator<PointsToSetVariable>, IBinaryNaturalRelation> entry : implicitUnaryMap.entrySet()) {
count++; count++;
Map.Entry<?, IBinaryNaturalRelation> e = it.next(); Map.Entry<?, IBinaryNaturalRelation> e = entry;
IBinaryNaturalRelation R = e.getValue(); IBinaryNaturalRelation R = e.getValue();
System.err.println(("entry " + count)); System.err.println(("entry " + count));
R.performVerboseAction(); R.performVerboseAction();

View File

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

View File

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

View File

@ -284,9 +284,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
v.setBasicBlock(b); v.setBasicBlock(b);
// visit each instruction in the basic block. // visit each instruction in the basic block.
for (Iterator<SSAInstruction> it = b.iterator(); it.hasNext();) { for (SSAInstruction s : b) {
MonitorUtil.throwExceptionIfCanceled(monitor); MonitorUtil.throwExceptionIfCanceled(monitor);
SSAInstruction s = it.next();
if (s != null) { if (s != null) {
s.visit(v); s.visit(v);
if (wasChanged(node)) { if (wasChanged(node)) {
@ -329,8 +328,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(v.symbolTable, v.du, phi.getUse(n))) { if (contentsAreInvariant(v.symbolTable, v.du, phi.getUse(n))) {
system.recordImplicitPointsToSet(use); system.recordImplicitPointsToSet(use);
InstanceKey[] ik = getInvariantContents(v.symbolTable, v.du, node, phi.getUse(n), this); InstanceKey[] ik = getInvariantContents(v.symbolTable, v.du, node, phi.getUse(n), this);
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.newConstraint(def, ik[i]); system.newConstraint(def, element);
} }
} else { } else {
system.newConstraint(def, assignOperator, use); system.newConstraint(def, assignOperator, use);
@ -371,8 +370,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (DEBUG) { if (DEBUG) {
System.err.println("Add exception def constraints for node " + node); System.err.println("Add exception def constraints for node " + node);
} }
for (Iterator<ProgramCounter> it = peis.iterator(); it.hasNext();) { for (ProgramCounter peiLoc : peis) {
ProgramCounter peiLoc = it.next();
if (DEBUG) { if (DEBUG) {
System.err.println("peiLoc: " + peiLoc); System.err.println("peiLoc: " + peiLoc);
} }
@ -398,9 +396,9 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(ir.getSymbolTable(), du, s.getException())) { if (contentsAreInvariant(ir.getSymbolTable(), du, s.getException())) {
InstanceKey[] ik = getInvariantContents(ir.getSymbolTable(), du, node, s.getException(), this); InstanceKey[] ik = getInvariantContents(ir.getSymbolTable(), du, node, s.getException(), this);
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(ik[i]); system.findOrCreateIndexForInstanceKey(element);
assignInstanceToCatch(exceptionVar, catchClasses, ik[i]); assignInstanceToCatch(exceptionVar, catchClasses, element);
} }
} else { } else {
addAssignmentsForCatchPointerKey(exceptionVar, catchClasses, e); addAssignmentsForCatchPointerKey(exceptionVar, catchClasses, e);
@ -412,8 +410,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
// the pei, but just instance keys // the pei, but just instance keys
Collection<TypeReference> types = pei.getExceptionTypes(); Collection<TypeReference> types = pei.getExceptionTypes();
if (types != null) { if (types != null) {
for (Iterator<TypeReference> it2 = types.iterator(); it2.hasNext();) { for (TypeReference type : types) {
TypeReference type = it2.next();
if (type != null) { if (type != null) {
InstanceKey ik = getInstanceKeyForPEI(node, peiLoc, type, instanceKeyFactory); InstanceKey ik = getInstanceKeyForPEI(node, peiLoc, type, instanceKeyFactory);
if (ik == null) { if (ik == null) {
@ -536,9 +533,9 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
InstanceKey[] ik = invariants != null ? invariants[p] : null; InstanceKey[] ik = invariants != null ? invariants[p] : null;
if (ik != null) { if (ik != null) {
if (ik.length > 0) { if (ik.length > 0) {
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(ik[i]); system.findOrCreateIndexForInstanceKey(element);
keys[pi] = ik[i]; keys[pi] = element;
rec(pi + 1, rhsi); rec(pi + 1, rhsi);
} }
} /* else { } /* else {
@ -794,11 +791,11 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, value)) { if (contentsAreInvariant(symbolTable, du, value)) {
system.recordImplicitPointsToSet(valuePtrKey); system.recordImplicitPointsToSet(valuePtrKey);
InstanceKey[] vk = getInvariantContents(value); InstanceKey[] vk = getInvariantContents(value);
for (int j = 0; j < vk.length; j++) { for (InstanceKey element : vk) {
system.findOrCreateIndexForInstanceKey(vk[j]); system.findOrCreateIndexForInstanceKey(element);
if (vk[j].getConcreteType() != null) { if (element.getConcreteType() != null) {
if (getClassHierarchy().isAssignableFrom(contents, vk[j].getConcreteType())) { if (getClassHierarchy().isAssignableFrom(contents, element.getConcreteType())) {
system.newConstraint(p, vk[j]); system.newConstraint(p, element);
} }
} }
} }
@ -816,10 +813,10 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, value)) { if (contentsAreInvariant(symbolTable, du, value)) {
system.recordImplicitPointsToSet(valuePtrKey); system.recordImplicitPointsToSet(valuePtrKey);
InstanceKey[] ik = getInvariantContents(value); InstanceKey[] ik = getInvariantContents(value);
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(ik[i]); system.findOrCreateIndexForInstanceKey(element);
assert !system.isUnified(arrayRefPtrKey); assert !system.isUnified(arrayRefPtrKey);
system.newSideEffect(getBuilder().new InstanceArrayStoreOperator(ik[i]), arrayRefPtrKey); system.newSideEffect(getBuilder().new InstanceArrayStoreOperator(element), arrayRefPtrKey);
} }
} else { } else {
system.newSideEffect(getBuilder().new ArrayStoreOperator(system.findOrCreatePointsToSet(valuePtrKey)), arrayRefPtrKey); system.newSideEffect(getBuilder().new ArrayStoreOperator(system.findOrCreatePointsToSet(valuePtrKey)), arrayRefPtrKey);
@ -871,17 +868,17 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
IClass cls = getClassHierarchy().lookupClass(t); IClass cls = getClassHierarchy().lookupClass(t);
if (cls.isInterface()) { if (cls.isInterface()) {
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(ik[i]); system.findOrCreateIndexForInstanceKey(element);
if (getClassHierarchy().implementsInterface(ik[i].getConcreteType(), cls)) { if (getClassHierarchy().implementsInterface(element.getConcreteType(), cls)) {
system.newConstraint(result, ik[i]); system.newConstraint(result, element);
} }
} }
} else { } else {
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(ik[i]); system.findOrCreateIndexForInstanceKey(element);
if (getClassHierarchy().isSubclassOf(ik[i].getConcreteType(), cls)) { if (getClassHierarchy().isSubclassOf(element.getConcreteType(), cls)) {
system.newConstraint(result, ik[i]); system.newConstraint(result, element);
} }
} }
} }
@ -915,11 +912,11 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, instruction.getResult())) { if (contentsAreInvariant(symbolTable, du, instruction.getResult())) {
system.recordImplicitPointsToSet(result); system.recordImplicitPointsToSet(result);
InstanceKey[] ik = getInvariantContents(instruction.getResult()); InstanceKey[] ik = getInvariantContents(instruction.getResult());
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
if (DEBUG) { 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 { } else {
system.newConstraint(returnValue, assignOperator, result); system.newConstraint(returnValue, assignOperator, result);
@ -1047,15 +1044,15 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (!representsNullType(refk[j])) { if (!representsNullType(refk[j])) {
system.findOrCreateIndexForInstanceKey(refk[j]); system.findOrCreateIndexForInstanceKey(refk[j]);
PointerKey p = getPointerKeyForInstanceField(refk[j], f); PointerKey p = getPointerKeyForInstanceField(refk[j], f);
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.newConstraint(p, ik[i]); system.newConstraint(p, element);
} }
} }
} }
} else { } else {
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.findOrCreateIndexForInstanceKey(ik[i]); system.findOrCreateIndexForInstanceKey(element);
system.newSideEffect(getBuilder().new InstancePutFieldOperator(f, ik[i]), refKey); system.newSideEffect(getBuilder().new InstancePutFieldOperator(f, element), refKey);
} }
} }
} else { } else {
@ -1087,8 +1084,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, rval)) { if (contentsAreInvariant(symbolTable, du, rval)) {
system.recordImplicitPointsToSet(rvalKey); system.recordImplicitPointsToSet(rvalKey);
InstanceKey[] ik = getInvariantContents(rval); InstanceKey[] ik = getInvariantContents(rval);
for (int i = 0; i < ik.length; i++) { for (InstanceKey element : ik) {
system.newConstraint(fKey, ik[i]); system.newConstraint(fKey, element);
} }
} else { } else {
system.newConstraint(fKey, assignOperator, rvalKey); system.newConstraint(fKey, assignOperator, rvalKey);
@ -1337,8 +1334,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, instruction.getUse(i))) { if (contentsAreInvariant(symbolTable, du, instruction.getUse(i))) {
system.recordImplicitPointsToSet(use); system.recordImplicitPointsToSet(use);
InstanceKey[] ik = getInvariantContents(instruction.getUse(i)); InstanceKey[] ik = getInvariantContents(instruction.getUse(i));
for (int j = 0; j < ik.length; j++) { for (InstanceKey element : ik) {
system.newConstraint(dst, ik[j]); system.newConstraint(dst, element);
} }
} else { } else {
system.newConstraint(dst, assignOperator, use); system.newConstraint(dst, assignOperator, use);
@ -1385,10 +1382,10 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, val)) { if (contentsAreInvariant(symbolTable, du, val)) {
system.recordImplicitPointsToSet(src); system.recordImplicitPointsToSet(src);
InstanceKey[] ik = getInvariantContents(val); InstanceKey[] ik = getInvariantContents(val);
for (int j = 0; j < ik.length; j++) { for (InstanceKey element : ik) {
boolean assignable = getClassHierarchy().isAssignableFrom(cls, ik[j].getConcreteType()); boolean assignable = getClassHierarchy().isAssignableFrom(cls, element.getConcreteType());
if ((assignable && useFilter) || (!assignable && !useFilter)) { if ((assignable && useFilter) || (!assignable && !useFilter)) {
system.newConstraint(dst, ik[j]); system.newConstraint(dst, element);
} }
} }
} else { } else {
@ -1422,8 +1419,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
if (contentsAreInvariant(symbolTable, du, src)) { if (contentsAreInvariant(symbolTable, du, src)) {
system.recordImplicitPointsToSet(srcKey); system.recordImplicitPointsToSet(srcKey);
InstanceKey[] ik = getInvariantContents(src); InstanceKey[] ik = getInvariantContents(src);
for (int j = 0; j < ik.length; j++) { for (InstanceKey element : ik) {
system.newConstraint(dst, ik[j]); system.newConstraint(dst, element);
} }
} else { } else {
system.newConstraint(dst, assignOperator, srcKey); system.newConstraint(dst, assignOperator, srcKey);
@ -1648,8 +1645,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
PointerKey formal = getTargetPointerKey(target, i); PointerKey formal = getTargetPointerKey(target, i);
if (constParams != null && constParams[i] != null) { if (constParams != null && constParams[i] != null) {
InstanceKey[] ik = constParams[i]; InstanceKey[] ik = constParams[i];
for (int j = 0; j < ik.length; j++) { for (InstanceKey element : ik) {
system.newConstraint(formal, ik[j]); system.newConstraint(formal, element);
} }
} else { } else {
if (instruction.getUse(i) < 0) { if (instruction.getUse(i) < 0) {
@ -2331,8 +2328,8 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
} }
if (ensureIndexes) { if (ensureIndexes) {
for (int i = 0; i < result.length; i++) { for (InstanceKey element : result) {
system.findOrCreateIndexForInstanceKey(result[i]); system.findOrCreateIndexForInstanceKey(element);
} }
} }

View File

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

View File

@ -214,8 +214,7 @@ public class ZeroXInstanceKeys implements InstanceKeyFactory {
if (s == null) { if (s == null) {
Map<IClass, Integer> count = countAllocsByType(node); Map<IClass, Integer> count = countAllocsByType(node);
HashSet<IClass> smushees = HashSetFactory.make(5); HashSet<IClass> smushees = HashSetFactory.make(5);
for (Iterator<Map.Entry<IClass, Integer>> it = count.entrySet().iterator(); it.hasNext();) { for (Map.Entry<IClass, Integer> e : count.entrySet()) {
Map.Entry<IClass, Integer> e = it.next();
Integer i = e.getValue(); Integer i = e.getValue();
if (i.intValue() > SMUSH_LIMIT) { if (i.intValue() > SMUSH_LIMIT) {
smushees.add(e.getKey()); smushees.add(e.getKey());
@ -336,8 +335,7 @@ public class ZeroXInstanceKeys implements InstanceKeyFactory {
if (c.getReference().equals(TypeReference.JavaLangObject)) { if (c.getReference().equals(TypeReference.JavaLangObject)) {
return true; return true;
} else { } else {
for (Iterator<IField> it = c.getDeclaredInstanceFields().iterator(); it.hasNext();) { for (IField f : c.getDeclaredInstanceFields()) {
IField f = it.next();
if (f.getReference().getFieldType().isReferenceType()) { if (f.getReference().getFieldType().isReferenceType()) {
return false; return false;
} }

View File

@ -349,8 +349,8 @@ public abstract class AbstractRTABuilder extends PropagationCallGraphBuilder {
FakeRootMethod m = (FakeRootMethod) getCallGraph().getFakeRootNode().getMethod(); FakeRootMethod m = (FakeRootMethod) getCallGraph().getFakeRootNode().getMethod();
for (int i = 0; i < PRE_ALLOC.length; i++) { for (TypeReference element : PRE_ALLOC) {
SSANewInstruction n = m.addAllocation(PRE_ALLOC[i]); SSANewInstruction n = m.addAllocation(element);
// visit now to ensure java.lang.Object is visited first // visit now to ensure java.lang.Object is visited first
visitNew(getCallGraph().getFakeRootNode(), n.getNewSite()); visitNew(getCallGraph().getFakeRootNode(), n.getNewSite());
} }

View File

@ -10,8 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package com.ibm.wala.ipa.callgraph.propagation.rta; package com.ibm.wala.ipa.callgraph.propagation.rta;
import java.util.Iterator;
import com.ibm.wala.analysis.reflection.CloneInterpreter; import com.ibm.wala.analysis.reflection.CloneInterpreter;
import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.CallSiteReference;
import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IClass;
@ -55,8 +53,7 @@ public class BasicRTABuilder extends AbstractRTABuilder {
// set up the selector map to record each method that class implements // set up the selector map to record each method that class implements
registerImplementedMethods(klass, iKey); registerImplementedMethods(klass, iKey);
for (Iterator<IClass> ifaces = klass.getAllImplementedInterfaces().iterator(); ifaces.hasNext();) { for (IClass c : klass.getAllImplementedInterfaces()) {
IClass c = ifaces.next();
registerImplementedMethods(c, iKey); registerImplementedMethods(c, iKey);
} }
klass = klass.getSuperclass(); klass = klass.getSuperclass();
@ -73,8 +70,7 @@ public class BasicRTABuilder extends AbstractRTABuilder {
if (DEBUG) { if (DEBUG) {
System.err.println(("registerImplementedMethods: " + declarer + " " + iKey)); System.err.println(("registerImplementedMethods: " + declarer + " " + iKey));
} }
for (Iterator<IMethod> it = declarer.getDeclaredMethods().iterator(); it.hasNext();) { for (IMethod M : declarer.getDeclaredMethods()) {
IMethod M = it.next();
Selector selector = M.getReference().getSelector(); Selector selector = M.getReference().getSelector();
PointerKey sKey = getKeyForSelector(selector); PointerKey sKey = getKeyForSelector(selector);
if (DEBUG) { if (DEBUG) {

View File

@ -10,7 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package com.ibm.wala.ipa.callgraph.propagation.rta; package com.ibm.wala.ipa.callgraph.propagation.rta;
import java.util.Iterator;
import java.util.Set; import java.util.Set;
import com.ibm.wala.classLoader.CallSiteReference; import com.ibm.wala.classLoader.CallSiteReference;
@ -73,8 +72,7 @@ public class DelegatingExplicitCallGraph extends ExplicitCallGraph {
@Override @Override
public MutableSharedBitVectorIntSet getAllTargetNumbers() { public MutableSharedBitVectorIntSet getAllTargetNumbers() {
MutableSharedBitVectorIntSet result = new MutableSharedBitVectorIntSet(super.getAllTargetNumbers()); MutableSharedBitVectorIntSet result = new MutableSharedBitVectorIntSet(super.getAllTargetNumbers());
for (Iterator<Object> it = targets.iterator(); it.hasNext();) { for (Object n : targets) {
Object n = it.next();
if (n instanceof CallSite) { if (n instanceof CallSite) {
ExplicitNode delegate = (ExplicitNode) ((CallSite) n).getNode(); ExplicitNode delegate = (ExplicitNode) ((CallSite) n).getNode();
IntSet s = DelegatingExplicitCallGraph.this.getPossibleTargetNumbers(delegate, ((CallSite) n).getSite()); IntSet s = DelegatingExplicitCallGraph.this.getPossibleTargetNumbers(delegate, ((CallSite) n).getSite());
@ -119,8 +117,7 @@ public class DelegatingExplicitCallGraph extends ExplicitCallGraph {
if (super.getAllTargetNumbers().contains(y)) { if (super.getAllTargetNumbers().contains(y)) {
return true; return true;
} else { } else {
for (Iterator<Object> it = targets.iterator(); it.hasNext();) { for (Object n : targets) {
Object n = it.next();
if (n instanceof CallSite) { if (n instanceof CallSite) {
ExplicitNode delegate = (ExplicitNode) ((CallSite) n).getNode(); ExplicitNode delegate = (ExplicitNode) ((CallSite) n).getNode();
IntSet s = DelegatingExplicitCallGraph.this.getPossibleTargetNumbers(delegate,((CallSite) n).getSite()); IntSet s = DelegatingExplicitCallGraph.this.getPossibleTargetNumbers(delegate,((CallSite) n).getSite());

View File

@ -89,12 +89,10 @@ public class TypeBasedHeapModel implements HeapModel {
if (pKeys == null) { if (pKeys == null) {
pKeys = HashMapFactory.make(); pKeys = HashMapFactory.make();
} }
for (Iterator<IClass> it = klasses.iterator(); it.hasNext();) { for (IClass klass : klasses) {
IClass klass = it.next();
pKeys.putAll(computePointerKeys(klass)); pKeys.putAll(computePointerKeys(klass));
} }
for (Iterator<CGNode> it = cg.iterator(); it.hasNext();) { for (CGNode node : cg) {
CGNode node = it.next();
initPKeysForNode(node); initPKeysForNode(node);
} }
} }
@ -159,8 +157,7 @@ public class TypeBasedHeapModel implements HeapModel {
result.put(p, p); result.put(p, p);
} }
} else { } else {
for (Iterator<IField> it = klass.getAllFields().iterator(); it.hasNext();) { for (IField f : klass.getAllFields()) {
IField f = it.next();
if (!f.getFieldTypeReference().isPrimitiveType()) { if (!f.getFieldTypeReference().isPrimitiveType()) {
if (f.isStatic()) { if (f.isStatic()) {
PointerKey p = pointerKeys.getPointerKeyForStaticField(f); PointerKey p = pointerKeys.getPointerKeyForStaticField(f);

View File

@ -11,7 +11,6 @@
package com.ibm.wala.ipa.callgraph.propagation.rta; package com.ibm.wala.ipa.callgraph.propagation.rta;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import com.ibm.wala.classLoader.IClass; import com.ibm.wala.classLoader.IClass;
@ -71,8 +70,7 @@ public class TypeBasedPointerAnalysis extends AbstractPointerAnalysis {
throw new IllegalArgumentException("null c"); throw new IllegalArgumentException("null c");
} }
MutableMapping<InstanceKey> result = MutableMapping.make(); MutableMapping<InstanceKey> result = MutableMapping.make();
for (Iterator<IClass> it = c.iterator(); it.hasNext();) { for (IClass klass : c) {
IClass klass = it.next();
if (!klass.isAbstract() && !klass.isInterface()) { if (!klass.isAbstract() && !klass.isInterface()) {
result.add(new ConcreteTypeKey(klass)); result.add(new ConcreteTypeKey(klass));
} }
@ -141,8 +139,7 @@ public class TypeBasedPointerAnalysis extends AbstractPointerAnalysis {
private OrdinalSet<InstanceKey> toOrdinalInstanceKeySet(Collection<IClass> c) { private OrdinalSet<InstanceKey> toOrdinalInstanceKeySet(Collection<IClass> c) {
BimodalMutableIntSet s = new BimodalMutableIntSet(); BimodalMutableIntSet s = new BimodalMutableIntSet();
for (Iterator<IClass> it = c.iterator(); it.hasNext();) { for (IClass klass : c) {
IClass klass = it.next();
int index = getInstanceKeyMapping().add(new ConcreteTypeKey(klass)); int index = getInstanceKeyMapping().add(new ConcreteTypeKey(klass));
s.add(index); s.add(index);
} }

View File

@ -159,8 +159,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
addNodeForEachBasicBlock(cfg, n); addNodeForEachBasicBlock(cfg, n);
SSAInstruction[] instrs = cfg.getInstructions(); SSAInstruction[] instrs = cfg.getInstructions();
// create edges for node n. // create edges for node n.
for (Iterator<T> bbs = cfg.iterator(); bbs.hasNext();) { for (T bb : cfg) {
T bb = bbs.next();
if (bb != cfg.entry()) if (bb != cfg.entry())
addEdgesToNonEntryBlock(n, cfg, instrs, bb); addEdgesToNonEntryBlock(n, cfg, instrs, bb);
} }
@ -352,8 +351,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
*/ */
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void addNodeForEachBasicBlock(ControlFlowGraph<? extends SSAInstruction, ? extends T> cfg, CGNode N) { private void addNodeForEachBasicBlock(ControlFlowGraph<? extends SSAInstruction, ? extends T> cfg, CGNode N) {
for (Iterator<? extends T> bbs = cfg.iterator(); bbs.hasNext();) { for (T bb : cfg) {
T bb = bbs.next();
if (DEBUG_LEVEL > 1) { if (DEBUG_LEVEL > 1) {
System.err.println("IPCFG Add basic block " + bb); System.err.println("IPCFG Add basic block " + bb);
} }
@ -456,8 +454,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
private void addEdgesToCallees(CGNode n) { private void addEdgesToCallees(CGNode n) {
ControlFlowGraph<SSAInstruction, T> cfg = getCFG(n); ControlFlowGraph<SSAInstruction, T> cfg = getCFG(n);
if (cfg != null) { if (cfg != null) {
for (Iterator<T> bbs = cfg.iterator(); bbs.hasNext();) { for (T bb : cfg) {
T bb = bbs.next();
BasicBlockInContext<T> block = new BasicBlockInContext<T>(n, bb); BasicBlockInContext<T> block = new BasicBlockInContext<T>(n, bb);
if (hasCall(block)) { if (hasCall(block)) {
addCalleeEdgesForCall(n, block); addCalleeEdgesForCall(n, block);
@ -499,8 +496,7 @@ public abstract class AbstractInterproceduralCFG<T extends ISSABasicBlock> imple
System.err.println("got Site: " + site); System.err.println("got Site: " + site);
} }
boolean irrelevantTargets = false; boolean irrelevantTargets = false;
for (Iterator<CGNode> ts = cg.getPossibleTargets(n, site).iterator(); ts.hasNext();) { for (CGNode tn : cg.getPossibleTargets(n, site)) {
CGNode tn = ts.next();
if (!relevant.test(tn)) { if (!relevant.test(tn)) {
if (DEBUG_LEVEL > 1) { if (DEBUG_LEVEL > 1) {
System.err.println("Irrelevant target: " + tn); System.err.println("Irrelevant target: " + tn);

View File

@ -215,8 +215,7 @@ public class PrunedCFG<I, T extends IBasicBlock<I>> extends AbstractNumberedGrap
@Override @Override
public int getMaxNumber() { public int getMaxNumber() {
int max = -1; int max = -1;
for (Iterator<? extends T> NS = nodes.iterator(); NS.hasNext();) { for (T N : nodes) {
T N = NS.next();
if (subset.contains(N) && getNumber(N) > max) { if (subset.contains(N) && getNumber(N) > max) {
max = getNumber(N); max = getNumber(N);
} }

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