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();
// add standard libraries to scope
String[] stdlibs = WalaProperties.getJ2SEJarFiles();
for (int i = 0; i < stdlibs.length; i++) {
scope.addToScope(ClassLoaderReference.Primordial, new JarFile(stdlibs[i]));
for (String stdlib : stdlibs) {
scope.addToScope(ClassLoaderReference.Primordial, new JarFile(stdlib));
}
// add the source directory
scope.addToScope(JavaSourceAnalysisScope.SOURCE, new SourceDirectoryTreeModule(new File(sourceDir)));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,8 +10,6 @@
*******************************************************************************/
package com.ibm.wala.dataflow.IFDS;
import java.util.Iterator;
import com.ibm.wala.util.collections.SparseVector;
import com.ibm.wala.util.intset.BasicNaturalRelation;
import com.ibm.wala.util.intset.IBinaryNaturalRelation;
@ -133,8 +131,7 @@ public class LocalSummaryEdges {
return null;
} else {
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
for (Iterator<IntPair> it = R.iterator(); it.hasNext();) {
IntPair p = it.next();
for (IntPair p : R) {
if (p.getY() == d2) {
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
// for each
// potential entry node s_p /in s_procof(c)
for (int i = 0; i < entries.length; i++) {
final T s_p = entries[i];
for (final T s_p : entries) {
if (DEBUG_LEVEL > 1) {
System.err.println(" do entry " + s_p);
}
@ -674,8 +673,7 @@ public class TabulationSolver<T, P, F> {
// for each exit from the callee
P p = supergraph.getProcOf(calleeEntry);
T[] exits = supergraph.getExitsForProcedure(p);
for (int e = 0; e < exits.length; e++) {
final T exit = exits[e];
for (final T exit : exits) {
if (DEBUG_LEVEL > 0) {
assert supergraph.containsNode(exit);
}
@ -959,8 +957,7 @@ public class TabulationSolver<T, P, F> {
return bb1.getNumber() - bb2.getNumber();
}
};
for (Iterator<? extends T> it = supergraph.iterator(); it.hasNext();) {
T n = it.next();
for (T n : supergraph) {
P proc = supergraph.getProcOf(n);
TreeSet<T> s = map.get(proc);
if (s == null) {
@ -970,11 +967,9 @@ public class TabulationSolver<T, P, F> {
s.add(n);
}
for (Iterator<Map.Entry<Object, TreeSet<T>>> it = map.entrySet().iterator(); it.hasNext();) {
Map.Entry<Object, TreeSet<T>> e = it.next();
for (Entry<Object, TreeSet<T>> e : map.entrySet()) {
Set<T> s = e.getValue();
for (Iterator<T> it2 = s.iterator(); it2.hasNext();) {
T o = it2.next();
for (T o : s) {
result.append(o + " : " + getResult(o) + "\n");
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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