Merge branch 'master' of https://github.com/wala/WALA
This commit is contained in:
commit
803243ea53
|
@ -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)));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -13,8 +13,8 @@
|
|||
<property name="javacVerbose" value="false"/>
|
||||
<property name="logExtension" value=".log"/>
|
||||
<property name="compilerArg" value=""/>
|
||||
<property name="javacSource" value="1.7"/>
|
||||
<property name="javacTarget" value="1.7"/>
|
||||
<property name="javacSource" value="1.8"/>
|
||||
<property name="javacTarget" value="1.8"/>
|
||||
<!-- This property has been updated to correspond to the paths used by the latest Java update
|
||||
on Mac OS X 10.6 (Java version 1.6.0_22). If you are not using this version of Mac OS X or Java,
|
||||
try changing the value of the property to "${java.home}/../../../Classes" -->
|
||||
|
|
|
@ -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())) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE project>
|
||||
<project name="com.ibm.wala.cast.js.html.nu_validator" default="getJars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<property name="javacVerbose" value="false"/>
|
||||
<property name="logExtension" value=".log"/>
|
||||
<property name="compilerArg" value=""/>
|
||||
<property name="javacSource" value="1.5"/>
|
||||
<property name="javacTarget" value="1.5"/>
|
||||
<!-- This property has been updated to correspond to the paths used by the latest Java update
|
||||
on Mac OS X 10.6 (Java version 1.6.0_22). If you are not using this version of Mac OS X or Java,
|
||||
try changing the value of the property to "${java.home}/../../../Classes" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="NuPresent" depends="init">
|
||||
<available file="${plugin.destination}/lib/htmlparser-1.4.jar" property="nu.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchNu" depends="NuPresent" unless="nu.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<get src="http://about.validator.nu/htmlparser/htmlparser-1.4.zip" dest="${temp.folder}/htmlparser-1.4.zip"/>
|
||||
<unzip src="${temp.folder}/htmlparser-1.4.zip" dest="${temp.folder}"/>
|
||||
<copy file="${temp.folder}/htmlparser-1.4/htmlparser-1.4.jar" tofile="${plugin.destination}/lib/htmlparser-1.4.jar" />
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchNu" />
|
||||
|
||||
<target name="init" depends="properties">
|
||||
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
|
||||
<isset property="buildTempFolder"/>
|
||||
</condition>
|
||||
<property name="pluginTemp" value="${basedir}"/>
|
||||
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
|
||||
<isset property="buildTempFolder"/>
|
||||
</condition>
|
||||
<property name="build.result.folder" value="${basedir}"/>
|
||||
<property name="temp.folder" value="${basedir}/temp.folder"/>
|
||||
<property name="plugin.destination" value="${basedir}"/>
|
||||
</target>
|
||||
|
||||
<target name="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -1,48 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE project>
|
||||
<project name="com.ibm.wala.cast.js.rhino" default="getJars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<property name="javacVerbose" value="false"/>
|
||||
<property name="logExtension" value=".log"/>
|
||||
<property name="compilerArg" value=""/>
|
||||
<property name="javacSource" value="1.5"/>
|
||||
<property name="javacTarget" value="1.5"/>
|
||||
|
||||
<target name="RhinoPresent" depends="init">
|
||||
<available file="${plugin.destination}/lib/rhino-1.7.6.jar" property="rhino.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchRhino" depends="RhinoPresent" unless="rhino.present">
|
||||
<get src="http://central.maven.org/maven2/org/mozilla/rhino/1.7.6/rhino-1.7.6.jar" dest="${plugin.destination}/lib/rhino-1.7.6.jar" />
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchRhino" />
|
||||
|
||||
|
||||
<target name="init" depends="properties">
|
||||
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
|
||||
<isset property="buildTempFolder"/>
|
||||
</condition>
|
||||
<property name="pluginTemp" value="${basedir}"/>
|
||||
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
|
||||
<isset property="buildTempFolder"/>
|
||||
</condition>
|
||||
<property name="build.result.folder" value="${basedir}"/>
|
||||
<property name="temp.folder" value="${basedir}/temp.folder"/>
|
||||
<property name="plugin.destination" value="${basedir}"/>
|
||||
</target>
|
||||
|
||||
<target name="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -13,8 +13,8 @@
|
|||
<property name="javacVerbose" value="false"/>
|
||||
<property name="logExtension" value=".log"/>
|
||||
<property name="compilerArg" value=""/>
|
||||
<property name="javacSource" value="1.5"/>
|
||||
<property name="javacTarget" value="1.5"/>
|
||||
<property name="javacSource" value="1.8"/>
|
||||
<property name="javacTarget" value="1.8"/>
|
||||
<!-- This property has been updated to correspond to the paths used by the latest Java update
|
||||
on Mac OS X 10.6 (Java version 1.6.0_22). If you are not using this version of Mac OS X or Java,
|
||||
try changing the value of the property to "${java.home}/../../../Classes" -->
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE project>
|
||||
<project name="com.ibm.wala.cast.js" default="getJars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<property name="javacVerbose" value="false"/>
|
||||
<property name="logExtension" value=".log"/>
|
||||
<property name="compilerArg" value=""/>
|
||||
<property name="javacSource" value="1.5"/>
|
||||
<property name="javacTarget" value="1.5"/>
|
||||
<!-- This property has been updated to correspond to the paths used by the latest Java update
|
||||
on Mac OS X 10.6 (Java version 1.6.0_22). If you are not using this version of Mac OS X or Java,
|
||||
try changing the value of the property to "${java.home}/../../../Classes" -->
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="JerichoPresent" depends="init">
|
||||
<available file="${plugin.destination}/lib/jericho-html-3.2.jar" property="jericho.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchJericho" depends="JerichoPresent" unless="jericho.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<get src="http://sourceforge.net/projects/jerichohtml/files/jericho-html/3.2/jericho-html-3.2.zip/download" dest="${temp.folder}/jericho-html-3.2.zip"/>
|
||||
<unzip src="${temp.folder}/jericho-html-3.2.zip" dest="${temp.folder}"/>
|
||||
<copy file="${temp.folder}/jericho-html-3.2/dist/jericho-html-3.2.jar" tofile="${plugin.destination}/lib/jericho-html-3.2.jar" />
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchJericho" />
|
||||
|
||||
<target name="init" depends="properties">
|
||||
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
|
||||
<isset property="buildTempFolder"/>
|
||||
</condition>
|
||||
<property name="pluginTemp" value="${basedir}"/>
|
||||
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
|
||||
<isset property="buildTempFolder"/>
|
||||
</condition>
|
||||
<property name="build.result.folder" value="${basedir}"/>
|
||||
<property name="temp.folder" value="${basedir}/temp.folder"/>
|
||||
<property name="plugin.destination" value="${basedir}"/>
|
||||
</target>
|
||||
|
||||
<target name="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE project>
|
||||
<!--
|
||||
=======================================================================
|
||||
WALA CAst core tests build file
|
||||
=======================================================================
|
||||
-->
|
||||
<project name="com.ibm.wala.cast.test" default="jar" basedir=".">
|
||||
<!-- Software version details -->
|
||||
<property name="name" value="walacasttest" />
|
||||
<property name="module_name" value="com.ibm.wala.cast.test" />
|
||||
<property name="Name" value="WALA CAst core tests" />
|
||||
<property name="version" value="1-alpha" />
|
||||
|
||||
<!-- Compilation switches -->
|
||||
<property name="debug" value="true" />
|
||||
<property name="deprecation" value="false" />
|
||||
<property name="optimize" value="true" />
|
||||
<property name="javacFailOnError" value="true" />
|
||||
<property name="javacDebugInfo" value="on" />
|
||||
<property name="javacVerbose" value="false" />
|
||||
|
||||
|
||||
<!-- Set global properties for this build -->
|
||||
<property name="src" value="harness-src" />
|
||||
<property name="build" value="build" />
|
||||
<property name="build.result" value="${basedir}" />
|
||||
<property name="build.tests" value="${basedir}" />
|
||||
<property name="build.javadocs" value="${build}/javadocs" />
|
||||
<property name="publish.javadocs" value="javadocs/com.ibm.wala.cast.test" />
|
||||
<property name="dist" value="dist" />
|
||||
<property name="etc" value="etc" />
|
||||
<property name="docs" value="docs" />
|
||||
<property name="lib" value="lib" />
|
||||
<property name="mainlib" value="../mainlib" />
|
||||
<property name="sharedlib" value="../sharedlib" />
|
||||
|
||||
<property name="templates" value="../com.ibm.safe/templates"/>
|
||||
<property name="specifications" value="../com.ibm.safe/specifications"/>
|
||||
|
||||
<property name="cvsroot" value="/gsa/watgsa/home/d/o/dolby/cvs/JTD"/>
|
||||
|
||||
<property name="excluded-tests-file" value="excluded-tests.txt" />
|
||||
|
||||
<import file="${sharedlib}/scripts/common-tests-targets.xml"/>
|
||||
|
||||
</project>
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE project>
|
||||
<!--
|
||||
=======================================================================
|
||||
WALA CAst build file
|
||||
=======================================================================
|
||||
-->
|
||||
<project name="com.ibm.wala.cast" default="getJars" basedir=".">
|
||||
<!-- Software version details -->
|
||||
<property name="name" value="walacast" />
|
||||
<property name="module_name" value="com.ibm.wala.cast" />
|
||||
<property name="Name" value="walacast" />
|
||||
<property name="version" value="1-alpha" />
|
||||
|
||||
<!-- Compilation switches -->
|
||||
<property name="debug" value="true" />
|
||||
<property name="deprecation" value="false" />
|
||||
<property name="optimize" value="true" />
|
||||
<property name="javacFailOnError" value="true" />
|
||||
<property name="javacDebugInfo" value="on" />
|
||||
<property name="javacVerbose" value="false" />
|
||||
|
||||
<!-- Set global properties for this build -->
|
||||
<property name="src" value="source/java" />
|
||||
<property name="nativesourcedir" value="source/c" />
|
||||
<property name="src.tests" value="tests" />
|
||||
<property name="build" value="build" />
|
||||
<property name="build.result" value="${basedir}" />
|
||||
<property name="build.tests" value="build/tests" />
|
||||
<property name="build.javadocs" value="${build}/javadocs" />
|
||||
<property name="publish.javadocs" value="javadocs/com.ibm.wala.cast" />
|
||||
<property name="dist" value="dist" />
|
||||
<property name="etc" value="etc" />
|
||||
<property name="docs" value="docs" />
|
||||
<property name="lib" value="lib" />
|
||||
<property name="mainlib" value="../mainlib" />
|
||||
<property name="sharedlib" value="../sharedlib" />
|
||||
|
||||
<target name="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
</target>
|
||||
|
||||
<target name="init" depends="properties">
|
||||
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
|
||||
<isset property="buildTempFolder"/>
|
||||
</condition>
|
||||
<property name="pluginTemp" value="${basedir}"/>
|
||||
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.testdata">
|
||||
<isset property="buildTempFolder"/>
|
||||
</condition>
|
||||
<property name="build.result.folder" value="${basedir}"/>
|
||||
<property name="temp.folder" value="${basedir}/temp.folder"/>
|
||||
<property name="plugin.destination" value="${basedir}"/>
|
||||
</target>
|
||||
|
||||
<target name="CommonsIoPresent" depends="init">
|
||||
<available file="${plugin.destination}/lib/commons-io-2.4.jar" property="commons.io.present"/>
|
||||
</target>
|
||||
|
||||
<target name="fetchCommonsIo" depends="CommonsIoPresent" unless="commons.io.present">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<get src="http://archive.apache.org/dist/commons/io/binaries/commons-io-2.4-bin.zip" dest="${temp.folder}/commons-io-2.4.zip"/>
|
||||
<unzip src="${temp.folder}/commons-io-2.4.zip" dest="${temp.folder}"/>
|
||||
<copy file="${temp.folder}/commons-io-2.4/commons-io-2.4.jar" tofile="${plugin.destination}/lib/commons-io-2.4.jar" />
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="getJars" depends="fetchCommonsIo" />
|
||||
|
||||
</project>
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -1,277 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE project>
|
||||
<project name="com.ibm.wala.core.tests" default="build.jars" basedir=".">
|
||||
|
||||
<property name="basews" value="${ws}" />
|
||||
<property name="baseos" value="${os}" />
|
||||
<property name="basearch" value="${arch}" />
|
||||
<property name="basenl" value="${nl}" />
|
||||
<property name="bundleId" value="com.ibm.wala.core.tests" />
|
||||
<property name="bundleVersion" value="1.1.3.200805291132" />
|
||||
|
||||
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true" />
|
||||
<property name="javacDebugInfo" value="on" />
|
||||
<property name="javacVerbose" value="false" />
|
||||
<property name="logExtension" value=".log" />
|
||||
<property name="compilerArg" value="" />
|
||||
<property name="javacSource" value="1.5" />
|
||||
<property name="javacTarget" value="1.5" />
|
||||
<!-- <condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac" />
|
||||
</condition> -->
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib" />
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
<include name="*.jar" />
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath" />
|
||||
<property name="bundleJavacSource" value="${javacSource}" />
|
||||
<property name="bundleJavacTarget" value="${javacTarget}" />
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}" />
|
||||
|
||||
<!-- SJF modifications to support junit -->
|
||||
<path id="@dot.classpath">
|
||||
<pathelement path="../com.ibm.wala.core/bin/" />
|
||||
<pathelement path="../com.ibm.wala.core/@dot" />
|
||||
<pathelement path="../com.ibm.wala.shrike/bin/" />
|
||||
<pathelement path="../com.ibm.wala.shrike/@dot" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.resources_3.3.1.R33x_v20080205.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.resources.compatibility_3.2.100.v20070502.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.ant.core_3.1.200.v20070522.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.variables_3.2.0.v20070426.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.runtime_3.3.100.v20070530.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.osgi_3.3.2.R33x_v20080105.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.equinox.common_3.3.0.v20070426.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.jobs_3.3.1.R33x_v20070709.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.100.v20070316/runtime_registry_compatibility.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.100.v20070316" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.equinox.registry_3.3.1.R33x_v20070802.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.equinox.preferences_3.2.101.R33x_v20080117.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.100.v20070316/@dot" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.contenttype_3.2.100.v20070319.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.runtime.compatibility.auth_3.2.100.v20070502.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.equinox.app_1.0.1.R33x_v20070828.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.osgi.services_3.1.200.v20070605.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/javax.servlet_2.4.0.v200706111738.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.expressions_3.3.0.v20070606-0010.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.filesystem_1.1.0.v20070606.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.filesystem.linux.x86_1.1.0.v20070416.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.jface_3.3.2.M20080207-0800.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.swt_3.3.2.v3349d.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.swt.gtk.linux.x86_3.3.2.v3349.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.commands_3.3.0.I20070605-0010.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.jdt.core_3.3.3.v_793_R33x.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.jdt.compiler.tool_1.0.1.v_793_R33x.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.jdt.compiler.apt_1.0.1.R33x_v20071002-2100.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.text_3.3.0.v20070606-0010.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/com.ibm.icu_3.6.1.v20070906.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.team.core_3.3.1.r33x_20080128.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.ui_3.3.1.M20071128-0800.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.ui.workbench_3.3.2.M20080207-0800.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.ui.workbench.compatibility_3.2.0.I20070319-0010/@dot" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.ui.workbench.compatibility_3.2.0.I20070319-0010/compatibility.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.help_3.3.2.v20071126_33x.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.jface.databinding_1.1.1.M20080207-0800.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.databinding_1.0.1.M20070822-0800.jar" />
|
||||
<pathelement path="../com.ibm.wala.core.testdata/bin/" />
|
||||
<pathelement path="../com.ibm.wala.core.testdata/@dot" />
|
||||
<pathelement path="../../../eclipse/plugins/org.junit_3.8.2.v200706111738/junit.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.ui.ide_3.3.2.M20080207-0800.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.ui.views_3.2.101.M20080207-0800.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.update.configurator_3.2.101.R33x_v20070810.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.update.core_3.2.101.R33x_v20070911.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.update.core.linux_3.2.0.v20070615.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.core.net_1.0.1.r33x_20070709.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.update.ui_3.2.100.v20070615.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.ui.forms_3.3.0.v20070511.jar" />
|
||||
<pathelement path="../../../eclipse/plugins/org.eclipse.jface.text_3.3.2.r332_20071017-0800.jar" />
|
||||
</path>
|
||||
|
||||
<property name="junit.dir" value="junit-results" />
|
||||
|
||||
<target name="runtests" depends="clean,build.update.jar" description="run junit tests for com.ibm.wala.core.tests">
|
||||
<delete dir="${junit.dir}" />
|
||||
<mkdir dir="${junit.dir}" />
|
||||
<junit fork="yes" errorProperty="test.failed" failureProperty="test.failed">
|
||||
<jvmarg value="-Xmx800M" />
|
||||
<jvmarg value="-ea" />
|
||||
<jvmarg value="-Dcom.ibm.wala.junit.profile=short" />
|
||||
<classpath>
|
||||
<path refid="@dot.classpath" />
|
||||
<pathelement path="@dot" />
|
||||
<pathelement path="../com.ibm.wala.core/dat" />
|
||||
<pathelement path="../com.ibm.wala.core.testdata/bin" />
|
||||
<pathelement path="../com.ibm.wala.core.testdata/src" />
|
||||
<pathelement path="../com.ibm.wala.core.testdata/@dot" />
|
||||
</classpath>
|
||||
|
||||
<batchtest todir="${junit.dir}">
|
||||
<!-- zipfileset src="com.ibm.wala.core.tests_1.1.3.200805291132.jar" -->
|
||||
<fileset dir="@dot">
|
||||
<include name="**/*Test*.class" />
|
||||
<exclude name="**/*$*.class" />
|
||||
<exclude name="**/*TestUtil.class" />
|
||||
<exclude name="**/*TestInfo.class" />
|
||||
<exclude name="**/*TestConstants.class" />
|
||||
<exclude name="**/*WalaTestCase.class" />
|
||||
<exclude name="**/*AbstractPtrTest.class" />
|
||||
<exclude name="**/*TestAgainstSimpleDriver.class" />
|
||||
</fileset>
|
||||
</batchtest>
|
||||
|
||||
<formatter type="plain" />
|
||||
<formatter type="xml" />
|
||||
</junit>
|
||||
<fail message="Tests failed: check test reports." if="test.failed" />
|
||||
</target>
|
||||
|
||||
|
||||
<target name="init" depends="properties">
|
||||
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
|
||||
<isset property="buildTempFolder" />
|
||||
</condition>
|
||||
<property name="pluginTemp" value="${basedir}" />
|
||||
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core.tests_1.1.3.200805291132">
|
||||
<isset property="buildTempFolder" />
|
||||
</condition>
|
||||
<property name="build.result.folder" value="${basedir}" />
|
||||
<property name="temp.folder" value="${basedir}/temp.folder" />
|
||||
<property name="plugin.destination" value="${basedir}" />
|
||||
</target>
|
||||
|
||||
<target name="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" />
|
||||
|
||||
</target>
|
||||
|
||||
<target name="build.update.jar" depends="init" description="Build the plug-in: com.ibm.wala.core.tests for an update site.">
|
||||
<delete dir="${temp.folder}" />
|
||||
<mkdir dir="${temp.folder}" />
|
||||
<antcall target="build.jars" />
|
||||
<antcall target="gather.bin.parts">
|
||||
<param name="destination.temp.folder" value="${temp.folder}/" />
|
||||
</antcall>
|
||||
<jar destfile="${plugin.destination}/com.ibm.wala.core.tests_1.1.3.200805291132.jar" basedir="${temp.folder}/com.ibm.wala.core.tests_1.1.3.200805291132" filesetmanifest="merge" />
|
||||
<delete dir="${temp.folder}" />
|
||||
</target>
|
||||
|
||||
<target name="@dot" depends="init" unless="@dot" description="Create jar: com.ibm.wala.core.tests @dot.">
|
||||
<delete dir="${temp.folder}/@dot.bin" />
|
||||
<mkdir dir="${temp.folder}/@dot.bin" />
|
||||
<!-- compile the source code -->
|
||||
<javac destdir="${temp.folder}/@dot.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}">
|
||||
<compilerarg line="${compilerArg}" compiler="${build.compiler}" />
|
||||
<classpath refid="@dot.classpath" />
|
||||
<src path="src/" />
|
||||
<src path="dat/" />
|
||||
<compilerarg value="@${basedir}/javaCompiler...args" compiler="org.eclipse.jdt.core.JDTCompilerAdapter" />
|
||||
<compilerarg line="-log '${temp.folder}/@dot.bin${logExtension}'" compiler="org.eclipse.jdt.core.JDTCompilerAdapter" />
|
||||
</javac>
|
||||
<!-- Copy necessary resources -->
|
||||
<copy todir="${temp.folder}/@dot.bin" failonerror="true" overwrite="false">
|
||||
<fileset dir="src/">
|
||||
<exclude name="**/*.java" />
|
||||
<exclude name="**/package.htm*" />
|
||||
</fileset>
|
||||
<fileset dir="dat/">
|
||||
<exclude name="**/*.java" />
|
||||
<exclude name="**/package.htm*" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<mkdir dir="${build.result.folder}" />
|
||||
<copy todir="${build.result.folder}/@dot" failonerror="true" overwrite="false">
|
||||
<fileset dir="${temp.folder}/@dot.bin">
|
||||
</fileset>
|
||||
</copy>
|
||||
<delete dir="${temp.folder}/@dot.bin" />
|
||||
</target>
|
||||
|
||||
<target name="src.zip" depends="init" unless="src.zip">
|
||||
<mkdir dir="${build.result.folder}" />
|
||||
<zip destfile="${build.result.folder}/src.zip" filesonly="false" whenempty="skip" update="false">
|
||||
<fileset dir="src/">
|
||||
<include name="**/*.java" />
|
||||
</fileset>
|
||||
<fileset dir="dat/">
|
||||
<include name="**/*.java" />
|
||||
</fileset>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="build.jars" depends="init" description="Compile classes and build nested jars for the plug-in: com.ibm.wala.core.tests.">
|
||||
<available property="@dot" file="${build.result.folder}/@dot" />
|
||||
<antcall target="@dot" />
|
||||
</target>
|
||||
|
||||
<target name="build.sources" depends="init">
|
||||
<available property="src.zip" file="${build.result.folder}/src.zip" />
|
||||
<antcall target="src.zip" />
|
||||
</target>
|
||||
|
||||
<target name="gather.bin.parts" depends="init" if="destination.temp.folder">
|
||||
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.tests_1.1.3.200805291132" />
|
||||
<copy todir="${destination.temp.folder}/com.ibm.wala.core.tests_1.1.3.200805291132" failonerror="true" overwrite="false">
|
||||
<fileset dir="${basedir}">
|
||||
<include name="META-INF/" />
|
||||
<include name="plugin.xml" />
|
||||
<include name="plugin.properties" />
|
||||
</fileset>
|
||||
</copy>
|
||||
<!-- eclipse.versionReplacer path="${destination.temp.folder}/com.ibm.wala.core.tests_1.1.3.200805291132" version="1.1.3.200805291132" -->
|
||||
</target>
|
||||
|
||||
<target name="build.zips" depends="init">
|
||||
</target>
|
||||
|
||||
<target name="gather.sources" depends="init" if="destination.temp.folder">
|
||||
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.tests_1.1.3.200805291132" />
|
||||
<copy file="${build.result.folder}/src.zip" todir="${destination.temp.folder}/com.ibm.wala.core.tests_1.1.3.200805291132" failonerror="false" overwrite="false" />
|
||||
</target>
|
||||
|
||||
<target name="gather.logs" depends="init" if="destination.temp.folder">
|
||||
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core.tests_1.1.3.200805291132" />
|
||||
<copy todir="${destination.temp.folder}/com.ibm.wala.core.tests_1.1.3.200805291132" failonerror="false" overwrite="false">
|
||||
<fileset dir="${temp.folder}">
|
||||
<include name="@dot.bin${logExtension}" />
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="clean" depends="init" description="Clean the plug-in: com.ibm.wala.core.tests of all the zips, jars and logs created.">
|
||||
<delete dir="${build.result.folder}/@dot" />
|
||||
<delete file="${build.result.folder}/src.zip" />
|
||||
<delete file="${plugin.destination}/com.ibm.wala.core.tests_1.1.3.200805291132.jar" />
|
||||
<delete file="${plugin.destination}/com.ibm.wala.core.tests_1.1.3.200805291132.zip" />
|
||||
<delete dir="${temp.folder}" />
|
||||
<delete dir="${junit.dir}" />
|
||||
</target>
|
||||
|
||||
<target name="refresh" depends="init" if="eclipse.running" description="Refresh this folder.">
|
||||
<eclipse.convertPath fileSystemPath="/home/snugglebug/sjf/workspace/com.ibm.wala.core.tests" property="resourcePath" />
|
||||
<eclipse.refreshLocal resource="${resourcePath}" depth="infinite" />
|
||||
</target>
|
||||
|
||||
<target name="zip.plugin" depends="init" description="Create a zip containing all the elements for the plug-in: com.ibm.wala.core.tests.">
|
||||
<delete dir="${temp.folder}" />
|
||||
<mkdir dir="${temp.folder}" />
|
||||
<antcall target="build.jars" />
|
||||
<antcall target="build.sources" />
|
||||
<antcall target="gather.bin.parts">
|
||||
<param name="destination.temp.folder" value="${temp.folder}/" />
|
||||
</antcall>
|
||||
<antcall target="gather.sources">
|
||||
<param name="destination.temp.folder" value="${temp.folder}/" />
|
||||
</antcall>
|
||||
<delete>
|
||||
<fileset dir="${temp.folder}">
|
||||
<include name="**/*.bin${logExtension}" />
|
||||
</fileset>
|
||||
</delete>
|
||||
<zip destfile="${plugin.destination}/com.ibm.wala.core.tests_1.1.3.200805291132.zip" basedir="${temp.folder}" filesonly="true" whenempty="skip" update="false" />
|
||||
<delete dir="${temp.folder}" />
|
||||
</target>
|
||||
</project>
|
|
@ -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);
|
||||
|
|
|
@ -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]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,202 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE project>
|
||||
<project name="com.ibm.wala.core" default="build.jars" basedir=".">
|
||||
|
||||
<property file="antbuild.properties"/>
|
||||
<property name="basews" value="${ws}"/>
|
||||
<property name="baseos" value="${os}"/>
|
||||
<property name="basearch" value="${arch}"/>
|
||||
<property name="basenl" value="${nl}"/>
|
||||
<property name="bundleId" value="com.ibm.wala.core"/>
|
||||
<property name="bundleVersion" value="1.1.3.200805291128"/>
|
||||
|
||||
<!-- Compiler settings. -->
|
||||
<property name="javacFailOnError" value="true"/>
|
||||
<property name="javacDebugInfo" value="on"/>
|
||||
<property name="javacVerbose" value="false"/>
|
||||
<property name="logExtension" value=".log"/>
|
||||
<property name="compilerArg" value=""/>
|
||||
<property name="javacSource" value="1.5"/>
|
||||
<property name="javacTarget" value="1.5"/>
|
||||
<condition property="dir_bootclasspath" value="${java.home}/../Classes">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
<property name="dir_bootclasspath" value="${java.home}/lib"/>
|
||||
<path id="path_bootclasspath">
|
||||
<fileset dir="${dir_bootclasspath}">
|
||||
<include name="*.jar"/>
|
||||
</fileset>
|
||||
</path>
|
||||
<property name="bootclasspath" refid="path_bootclasspath"/>
|
||||
<property name="bundleJavacSource" value="${javacSource}"/>
|
||||
<property name="bundleJavacTarget" value="${javacTarget}"/>
|
||||
<property name="bundleBootClasspath" value="${bootclasspath}"/>
|
||||
|
||||
<target name="init" depends="properties">
|
||||
<condition property="pluginTemp" value="${buildTempFolder}/plugins">
|
||||
<isset property="buildTempFolder"/>
|
||||
</condition>
|
||||
<property name="pluginTemp" value="${basedir}"/>
|
||||
<condition property="build.result.folder" value="${pluginTemp}/com.ibm.wala.core_1.1.3.200805291128">
|
||||
<isset property="buildTempFolder"/>
|
||||
</condition>
|
||||
<property name="build.result.folder" value="${basedir}"/>
|
||||
<property name="temp.folder" value="${basedir}/temp.folder"/>
|
||||
<property name="plugin.destination" value="${basedir}"/>
|
||||
</target>
|
||||
|
||||
<target name="properties" if="eclipse.running">
|
||||
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="build.update.jar" depends="clean" description="Build the plug-in: com.ibm.wala.core for an update site.">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<antcall target="build.jars"/>
|
||||
<antcall target="gather.bin.parts">
|
||||
<param name="destination.temp.folder" value="${temp.folder}/"/>
|
||||
</antcall>
|
||||
<jar destfile="${plugin.destination}/com.ibm.wala.core_1.1.3.200805291128.jar" basedir="${temp.folder}/com.ibm.wala.core_1.1.3.200805291128" filesetmanifest="merge"/>
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="@dot" depends="init" unless="@dot" description="Create jar: com.ibm.wala.core @dot.">
|
||||
<delete dir="${temp.folder}/@dot.bin"/>
|
||||
<mkdir dir="${temp.folder}/@dot.bin"/>
|
||||
<path id="@dot.classpath">
|
||||
<pathelement path="${shrike.root}/bin/"/>
|
||||
<pathelement path="${shrike.root}/@dot"/>
|
||||
<pathelement path="${eclipse35.root}/plugins/org.eclipse.core.runtime_3.5.0.v20090525.jar"/>
|
||||
<pathelement path="${eclipse35.root}/plugins/org.eclipse.equinox.common_3.5.1.R35x_v20090807-1100.jar"/>
|
||||
<pathelement path="${eclipse35.root}/plugins/org.eclipse.core.resources_3.5.2.R35x_v20091203-1235.jar"/>
|
||||
<pathelement path="${eclipse35.root}/plugins/org.eclipse.osgi_3.5.2.R35x_v20100126.jar"/>
|
||||
<pathelement path="${eclipse35.root}/plugins/org.eclipse.core.jobs_3.4.100.v20090429-1800.jar"/>
|
||||
</path>
|
||||
<!-- compile the source code -->
|
||||
<javac destdir="${temp.folder}/@dot.bin" failonerror="${javacFailOnError}" verbose="${javacVerbose}" debug="${javacDebugInfo}" includeAntRuntime="no" bootclasspath="${bundleBootClasspath}" source="${bundleJavacSource}" target="${bundleJavacTarget}" >
|
||||
<compilerarg line="${compilerArg}" compiler="${build.compiler}"/>
|
||||
<classpath refid="@dot.classpath" />
|
||||
<src path="dat/" />
|
||||
<src path="src/" />
|
||||
<src path="lib/" />
|
||||
<compilerarg value="@${basedir}/javaCompiler...args" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
<compilerarg line="-log '${temp.folder}/@dot.bin${logExtension}'" compiler="org.eclipse.jdt.core.JDTCompilerAdapter"/>
|
||||
</javac>
|
||||
<!-- Copy necessary resources -->
|
||||
<copy todir="${temp.folder}/@dot.bin" failonerror="true" overwrite="false">
|
||||
<fileset dir="dat/">
|
||||
<exclude name="**/*.java"/>
|
||||
<exclude name="**/package.htm*"/>
|
||||
</fileset>
|
||||
<fileset dir="src/">
|
||||
<exclude name="**/*.java"/>
|
||||
<exclude name="**/package.htm*"/>
|
||||
</fileset>
|
||||
<fileset dir="lib/">
|
||||
<exclude name="**/*.java"/>
|
||||
<exclude name="**/package.htm*"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<mkdir dir="${build.result.folder}"/>
|
||||
<copy todir="${build.result.folder}/@dot" failonerror="true" overwrite="false">
|
||||
<fileset dir="${temp.folder}/@dot.bin">
|
||||
</fileset>
|
||||
</copy>
|
||||
<delete dir="${temp.folder}/@dot.bin"/>
|
||||
</target>
|
||||
|
||||
<target name="src.zip" depends="init" unless="src.zip">
|
||||
<mkdir dir="${build.result.folder}"/>
|
||||
<zip destfile="${build.result.folder}/src.zip" filesonly="false" whenempty="skip" update="false">
|
||||
<fileset dir="dat/">
|
||||
<include name="**/*.java"/>
|
||||
</fileset>
|
||||
<fileset dir="src/">
|
||||
<include name="**/*.java"/>
|
||||
</fileset>
|
||||
<fileset dir="lib/">
|
||||
<include name="**/*.java"/>
|
||||
</fileset>
|
||||
</zip>
|
||||
</target>
|
||||
|
||||
<target name="build.jars" depends="init" description="Compile classes and build nested jars for the plug-in: com.ibm.wala.core.">
|
||||
<available property="@dot" file="${build.result.folder}/@dot"/>
|
||||
<antcall target="@dot"/>
|
||||
</target>
|
||||
|
||||
<target name="build.sources" depends="init">
|
||||
<available property="src.zip" file="${build.result.folder}/src.zip"/>
|
||||
<antcall target="src.zip"/>
|
||||
</target>
|
||||
|
||||
<target name="gather.bin.parts" depends="init" if="destination.temp.folder">
|
||||
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core_1.1.3.200805291128"/>
|
||||
<copy todir="${destination.temp.folder}/com.ibm.wala.core_1.1.3.200805291128" failonerror="true" overwrite="false">
|
||||
<fileset dir="${build.result.folder}/@dot">
|
||||
<include name="**"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<copy todir="${destination.temp.folder}/com.ibm.wala.core_1.1.3.200805291128" failonerror="true" overwrite="false">
|
||||
<fileset dir="${basedir}">
|
||||
<include name="lib/primordial.jar.model"/>
|
||||
<include name="plugin.properties"/>
|
||||
<include name="dat/natives.xml"/>
|
||||
<include name="META-INF/"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
<!-- eclipse.versionReplacer path="${destination.temp.folder}/com.ibm.wala.core_1.1.3.200805291128" version="1.1.3.200805291128" -->
|
||||
</target>
|
||||
|
||||
<target name="build.zips" depends="init">
|
||||
</target>
|
||||
|
||||
<target name="gather.sources" depends="init" if="destination.temp.folder">
|
||||
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core_1.1.3.200805291128"/>
|
||||
<copy file="${build.result.folder}/src.zip" todir="${destination.temp.folder}/com.ibm.wala.core_1.1.3.200805291128" failonerror="false" overwrite="false"/>
|
||||
</target>
|
||||
|
||||
<target name="gather.logs" depends="init" if="destination.temp.folder">
|
||||
<mkdir dir="${destination.temp.folder}/com.ibm.wala.core_1.1.3.200805291128"/>
|
||||
<copy todir="${destination.temp.folder}/com.ibm.wala.core_1.1.3.200805291128" failonerror="false" overwrite="false">
|
||||
<fileset dir="${temp.folder}">
|
||||
<include name="@dot.bin${logExtension}"/>
|
||||
</fileset>
|
||||
</copy>
|
||||
</target>
|
||||
|
||||
<target name="clean" depends="init" description="Clean the plug-in: com.ibm.wala.core of all the zips, jars and logs created.">
|
||||
<delete dir="${build.result.folder}/@dot"/>
|
||||
<delete file="${build.result.folder}/src.zip"/>
|
||||
<delete file="${plugin.destination}/com.ibm.wala.core_1.1.3.200805291128.jar"/>
|
||||
<delete file="${plugin.destination}/com.ibm.wala.core_1.1.3.200805291128.zip"/>
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
<target name="refresh" depends="init" if="eclipse.running" description="Refresh this folder.">
|
||||
<eclipse.convertPath fileSystemPath="/home/snugglebug/sjf/workspace/com.ibm.wala.core" property="resourcePath"/>
|
||||
<eclipse.refreshLocal resource="${resourcePath}" depth="infinite"/>
|
||||
</target>
|
||||
|
||||
<target name="zip.plugin" depends="init" description="Create a zip containing all the elements for the plug-in: com.ibm.wala.core.">
|
||||
<delete dir="${temp.folder}"/>
|
||||
<mkdir dir="${temp.folder}"/>
|
||||
<antcall target="build.jars"/>
|
||||
<antcall target="build.sources"/>
|
||||
<antcall target="gather.bin.parts">
|
||||
<param name="destination.temp.folder" value="${temp.folder}/"/>
|
||||
</antcall>
|
||||
<antcall target="gather.sources">
|
||||
<param name="destination.temp.folder" value="${temp.folder}/"/>
|
||||
</antcall>
|
||||
<delete>
|
||||
<fileset dir="${temp.folder}">
|
||||
<include name="**/*.bin${logExtension}"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
<zip destfile="${plugin.destination}/com.ibm.wala.core_1.1.3.200805291128.zip" basedir="${temp.folder}" filesonly="true" whenempty="skip" update="false"/>
|
||||
<delete dir="${temp.folder}"/>
|
||||
</target>
|
||||
|
||||
</project>
|
|
@ -226,7 +226,7 @@ public class IntraproceduralExceptionAnalysis {
|
|||
|
||||
if (pointerAnalysis != null) {
|
||||
PointerKey pointerKey = pointerAnalysis.getHeapModel().getPointerKeyForLocal(node, exceptionVariable);
|
||||
Iterator it = pointerAnalysis.getHeapGraph().getSuccNodes(pointerKey);
|
||||
Iterator<Object> it = pointerAnalysis.getHeapGraph().getSuccNodes(pointerKey);
|
||||
while (it.hasNext()) {
|
||||
Object next = it.next();
|
||||
if (next instanceof InstanceKey) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -516,7 +511,7 @@ public class BasicHeapGraph<T extends InstanceKey> extends HeapGraphImpl<T> {
|
|||
Object node = getNode(i);
|
||||
if (node != null) {
|
||||
result.append(i).append(" -> ");
|
||||
for (Iterator it = getSuccNodes(node); it.hasNext();) {
|
||||
for (Iterator<Object> it = getSuccNodes(node); it.hasNext();) {
|
||||
Object s = it.next();
|
||||
result.append(getNumber(s)).append(" ");
|
||||
}
|
||||
|
|
|
@ -189,8 +189,7 @@ public class CloneInterpreter implements SSAContextInterpreter {
|
|||
// TODO:
|
||||
IClass k = klass;
|
||||
while (k != null) {
|
||||
for (Iterator<IField> it = klass.getDeclaredInstanceFields().iterator(); it.hasNext();) {
|
||||
IField f = it.next();
|
||||
for (IField f : klass.getDeclaredInstanceFields()) {
|
||||
int tempValue = nextLocal++;
|
||||
SSAGetInstruction G = insts.GetInstruction(statements.size(), tempValue, 1, f.getReference());
|
||||
statements.add(G);
|
||||
|
@ -258,7 +257,7 @@ public class CloneInterpreter implements SSAContextInterpreter {
|
|||
return CodeScanner.hasObjectArrayStore(statements);
|
||||
}
|
||||
|
||||
public Iterator iterateCastTypes(CGNode node) {
|
||||
public Iterator<TypeReference> iterateCastTypes(CGNode node) {
|
||||
SSAInstruction[] statements = getIR(node).getInstructions();
|
||||
return CodeScanner.iterateCastTypes(statements);
|
||||
}
|
||||
|
|
|
@ -157,8 +157,8 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
}
|
||||
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
||||
HashSet<NewSiteReference> result = HashSetFactory.make(5);
|
||||
for (Iterator<SSAInstruction> it = m.getAllocationStatements().iterator(); it.hasNext();) {
|
||||
SSANewInstruction s = (SSANewInstruction) it.next();
|
||||
for (SSAInstruction ssaInstruction : m.getAllocationStatements()) {
|
||||
SSANewInstruction s = (SSANewInstruction) ssaInstruction;
|
||||
result.add(s.getNewSite());
|
||||
}
|
||||
return result.iterator();
|
||||
|
@ -263,7 +263,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
private SpecializedFactoryMethod findOrCreateSpecializedFactoryMethod(CGNode node) {
|
||||
SpecializedFactoryMethod m = syntheticMethodCache.get(node.getContext());
|
||||
if (m == null) {
|
||||
Set types = getTypesForContext(node.getContext());
|
||||
Set<TypeReference> types = getTypesForContext(node.getContext());
|
||||
m = new SpecializedFactoryMethod((SummarizedMethod) node.getMethod(), node.getContext(), types);
|
||||
syntheticMethodCache.put(node.getContext(), m);
|
||||
}
|
||||
|
@ -312,7 +312,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
}
|
||||
}
|
||||
|
||||
public Iterator iterateCastTypes(CGNode node) {
|
||||
public Iterator<TypeReference> iterateCastTypes(CGNode node) {
|
||||
if (node == null) {
|
||||
throw new IllegalArgumentException("node is null");
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
}
|
||||
}
|
||||
|
||||
protected SpecializedFactoryMethod(final SummarizedMethod m, Context context, final Set S) {
|
||||
protected SpecializedFactoryMethod(final SummarizedMethod m, Context context, final Set<TypeReference> S) {
|
||||
super(m, m.getDeclaringClass(), m.isStatic(), true);
|
||||
|
||||
this.context = context;
|
||||
|
@ -393,8 +393,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
// add original statements from the method summary
|
||||
nextLocal = addOriginalStatements(m);
|
||||
|
||||
for (Iterator it = S.iterator(); it.hasNext();) {
|
||||
TypeReference type = (TypeReference) it.next();
|
||||
for (TypeReference type : S) {
|
||||
TypeAbstraction T = typeRef2TypeAbstraction(m.getClassHierarchy(), type);
|
||||
addStatementsForTypeAbstraction(T);
|
||||
}
|
||||
|
@ -506,8 +505,7 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
SSAInstruction[] original = m.getStatements(options.getSSAOptions());
|
||||
// local value number 1 is "this", so the next free value number is 2
|
||||
int nextLocal = 2;
|
||||
for (int i = 0; i < original.length; i++) {
|
||||
SSAInstruction s = original[i];
|
||||
for (SSAInstruction s : original) {
|
||||
allInstructions.add(s);
|
||||
if (s instanceof SSAInvokeInstruction) {
|
||||
calls.add(s);
|
||||
|
@ -603,8 +601,8 @@ public class FactoryBypassInterpreter extends AbstractReflectionInterpreter {
|
|||
public SSAInstruction[] getStatements() {
|
||||
SSAInstruction[] result = new SSAInstruction[allInstructions.size()];
|
||||
int i = 0;
|
||||
for (Iterator<SSAInstruction> it = allInstructions.iterator(); it.hasNext();) {
|
||||
result[i++] = it.next();
|
||||
for (SSAInstruction ssaInstruction : allInstructions) {
|
||||
result[i++] = ssaInstruction;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ import com.ibm.wala.types.ClassLoaderReference;
|
|||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.CancelRuntimeException;
|
||||
import com.ibm.wala.util.graph.INodeWithNumber;
|
||||
import com.ibm.wala.util.shrike.ShrikeUtil;
|
||||
|
||||
/**
|
||||
|
@ -215,7 +216,7 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
|
|||
/*
|
||||
* Add only the entry variable to the work list.
|
||||
*/
|
||||
for (Iterator it = getFixedPointSystem().getStatementsThatUse(entry); it.hasNext();) {
|
||||
for (Iterator<? extends INodeWithNumber> it = getFixedPointSystem().getStatementsThatUse(entry); it.hasNext();) {
|
||||
AbstractStatement s = (AbstractStatement) it.next();
|
||||
addToWorkList(s);
|
||||
}
|
||||
|
@ -683,8 +684,8 @@ public abstract class AbstractIntStackMachine implements FixedPointConstants {
|
|||
return true;
|
||||
|
||||
if (locals != null)
|
||||
for (int i = 0; i < locals.length; i++)
|
||||
if (locals[i] == val)
|
||||
for (int local : locals)
|
||||
if (local == val)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
|
@ -106,7 +106,7 @@ public class ConeType extends TypeAbstraction {
|
|||
/**
|
||||
* @return an Iterator of IClass that implement this interface
|
||||
*/
|
||||
public Iterator iterateImplementors() {
|
||||
public Iterator<IClass> iterateImplementors() {
|
||||
return type.getClassHierarchy().getImplementors(getType().getReference()).iterator();
|
||||
}
|
||||
|
||||
|
|
|
@ -217,8 +217,7 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
|
|||
x = new TypeReference[]{ language.getThrowableType() };
|
||||
}
|
||||
if (x != null) {
|
||||
for (int i = 0; i < x.length; i++) {
|
||||
TypeReference tx = x[i];
|
||||
for (TypeReference tx : x) {
|
||||
IClass tc = cha.lookupClass(tx);
|
||||
if (tc != null) {
|
||||
v.setType(v.getType().meet(new ConeType(tc)));
|
||||
|
@ -308,9 +307,8 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
|
|||
|
||||
TypeAbstraction lhsType = lhs.getType();
|
||||
TypeAbstraction meet = TypeAbstraction.TOP;
|
||||
for (int i = 0; i < rhs.length; i++) {
|
||||
if (rhs[i] != null && rhs[i].getType() != null) {
|
||||
TypeVariable r = rhs[i];
|
||||
for (TypeVariable r : rhs) {
|
||||
if (r != null && r.getType() != null) {
|
||||
meet = meet.meet(r.getType());
|
||||
}
|
||||
}
|
||||
|
@ -386,9 +384,8 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
|
|||
public byte evaluate(TypeVariable lhs, TypeVariable[] rhs) {
|
||||
TypeAbstraction lhsType = lhs.getType();
|
||||
TypeAbstraction meet = TypeAbstraction.TOP;
|
||||
for (int i = 0; i < rhs.length; i++) {
|
||||
if (rhs[i] != null && rhs[i].getType() != null) {
|
||||
TypeVariable r = rhs[i];
|
||||
for (TypeVariable r : rhs) {
|
||||
if (r != null && r.getType() != null) {
|
||||
meet = meet.meet(r.getType());
|
||||
}
|
||||
}
|
||||
|
@ -668,8 +665,8 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
|
|||
|
||||
private TypeAbstraction meetDeclaredExceptionTypes(SSAGetCaughtExceptionInstruction s) {
|
||||
ExceptionHandlerBasicBlock bb = (ExceptionHandlerBasicBlock) ir.getControlFlowGraph().getNode(s.getBasicBlockNumber());
|
||||
Iterator it = bb.getCaughtExceptionTypes();
|
||||
TypeReference t = (TypeReference) it.next();
|
||||
Iterator<TypeReference> it = bb.getCaughtExceptionTypes();
|
||||
TypeReference t = it.next();
|
||||
IClass klass = cha.lookupClass(t);
|
||||
TypeAbstraction result = null;
|
||||
if (klass == null) {
|
||||
|
@ -680,7 +677,7 @@ public class TypeInference extends SSAInference<TypeVariable> implements FixedPo
|
|||
result = new ConeType(klass);
|
||||
}
|
||||
while (it.hasNext()) {
|
||||
t = (TypeReference) it.next();
|
||||
t = it.next();
|
||||
IClass tClass = cha.lookupClass(t);
|
||||
if (tClass == null) {
|
||||
result = BOTTOM;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -48,15 +48,14 @@ public class CFGSanitizer {
|
|||
ControlFlowGraph<SSAInstruction, ISSABasicBlock> cfg = ir.getControlFlowGraph();
|
||||
Graph<ISSABasicBlock> g = SlowSparseNumberedGraph.make();
|
||||
// add all nodes to the graph
|
||||
for (Iterator<? extends ISSABasicBlock> it = cfg.iterator(); it.hasNext();) {
|
||||
g.addNode(it.next());
|
||||
for (ISSABasicBlock basicBlock : cfg) {
|
||||
g.addNode(basicBlock);
|
||||
}
|
||||
|
||||
// add all edges to the graph, except those that go to exit
|
||||
for (Iterator it = cfg.iterator(); it.hasNext();) {
|
||||
ISSABasicBlock b = (ISSABasicBlock) it.next();
|
||||
for (Iterator it2 = cfg.getSuccNodes(b); it2.hasNext();) {
|
||||
ISSABasicBlock b2 = (ISSABasicBlock) it2.next();
|
||||
for (ISSABasicBlock b : cfg) {
|
||||
for (Iterator<ISSABasicBlock> it2 = cfg.getSuccNodes(b); it2.hasNext();) {
|
||||
ISSABasicBlock b2 = it2.next();
|
||||
|
||||
if (!b2.isExitBlock()) {
|
||||
g.addEdge(b, b2);
|
||||
|
@ -67,9 +66,9 @@ public class CFGSanitizer {
|
|||
// now add edges to exit, ignoring undeclared exceptions
|
||||
ISSABasicBlock exit = cfg.exit();
|
||||
|
||||
for (Iterator it = cfg.getPredNodes(exit); it.hasNext();) {
|
||||
for (Iterator<ISSABasicBlock> it = cfg.getPredNodes(exit); it.hasNext();) {
|
||||
// for each predecessor of exit ...
|
||||
ISSABasicBlock b = (ISSABasicBlock) it.next();
|
||||
ISSABasicBlock b = it.next();
|
||||
|
||||
SSAInstruction s = ir.getInstructions()[b.getLastInstructionIndex()];
|
||||
if (s == null) {
|
||||
|
@ -90,14 +89,14 @@ public class CFGSanitizer {
|
|||
Assertions.UNREACHABLE();
|
||||
}
|
||||
// remove any exceptions that are caught by catch blocks
|
||||
for (Iterator it2 = cfg.getSuccNodes(b); it2.hasNext();) {
|
||||
IBasicBlock c = (IBasicBlock) it2.next();
|
||||
for (Iterator<ISSABasicBlock> it2 = cfg.getSuccNodes(b); it2.hasNext();) {
|
||||
IBasicBlock c = it2.next();
|
||||
|
||||
if (c.isCatchBlock()) {
|
||||
SSACFG.ExceptionHandlerBasicBlock cb = (ExceptionHandlerBasicBlock) c;
|
||||
|
||||
for (Iterator it3 = cb.getCaughtExceptionTypes(); it3.hasNext();) {
|
||||
TypeReference ex = (TypeReference) it3.next();
|
||||
for (Iterator<TypeReference> it3 = cb.getCaughtExceptionTypes(); it3.hasNext();) {
|
||||
TypeReference ex = it3.next();
|
||||
IClass exClass = cha.lookupClass(ex);
|
||||
if (exClass == null) {
|
||||
throw new WalaException("failed to find " + ex);
|
||||
|
@ -125,17 +124,17 @@ public class CFGSanitizer {
|
|||
Assertions.UNREACHABLE();
|
||||
}
|
||||
if (declared != null && exceptions != null) {
|
||||
for (int i = 0; i < exceptions.length; i++) {
|
||||
for (TypeReference exception : exceptions) {
|
||||
boolean isDeclared = false;
|
||||
if (exceptions[i] != null) {
|
||||
IClass exi = cha.lookupClass(exceptions[i]);
|
||||
if (exception != null) {
|
||||
IClass exi = cha.lookupClass(exception);
|
||||
if (exi == null) {
|
||||
throw new WalaException("failed to find " + exceptions[i]);
|
||||
throw new WalaException("failed to find " + exception);
|
||||
}
|
||||
for (int j = 0; j < declared.length; j++) {
|
||||
IClass dc = cha.lookupClass(declared[j]);
|
||||
for (TypeReference element : declared) {
|
||||
IClass dc = cha.lookupClass(element);
|
||||
if (dc == null) {
|
||||
throw new WalaException("failed to find " + declared[j]);
|
||||
throw new WalaException("failed to find " + element);
|
||||
}
|
||||
if (cha.isSubclassOf(exi, dc)) {
|
||||
isDeclared = true;
|
||||
|
@ -158,7 +157,7 @@ public class CFGSanitizer {
|
|||
* What are the exception types which s may throw?
|
||||
*/
|
||||
private static TypeReference[] computeExceptions(IClassHierarchy cha, IR ir, SSAInstruction s) throws InvalidClassFileException {
|
||||
Collection c = null;
|
||||
Collection<TypeReference> c = null;
|
||||
Language l = ir.getMethod().getDeclaringClass().getClassLoader().getLanguage();
|
||||
if (s instanceof SSAInvokeInstruction) {
|
||||
SSAInvokeInstruction call = (SSAInvokeInstruction) s;
|
||||
|
@ -170,9 +169,9 @@ public class CFGSanitizer {
|
|||
return null;
|
||||
} else {
|
||||
TypeReference[] exceptions = new TypeReference[c.size()];
|
||||
Iterator it = c.iterator();
|
||||
Iterator<TypeReference> it = c.iterator();
|
||||
for (int i = 0; i < exceptions.length; i++) {
|
||||
exceptions[i] = (TypeReference) it.next();
|
||||
exceptions[i] = it.next();
|
||||
}
|
||||
return exceptions;
|
||||
}
|
||||
|
|
|
@ -120,8 +120,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
|
|||
* Compute outgoing edges in the control flow graph.
|
||||
*/
|
||||
private void computeEdges() {
|
||||
for (Iterator it = iterator(); it.hasNext();) {
|
||||
BasicBlock b = (BasicBlock) it.next();
|
||||
for (BasicBlock b : this) {
|
||||
if (b.equals(exit()))
|
||||
continue;
|
||||
b.computeOutgoingEdges();
|
||||
|
@ -471,8 +470,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
|
|||
int tgtNd = getIndexFromIIndex(tgt); // index in instructions-array
|
||||
BasicBlock target = null;
|
||||
|
||||
for (Iterator it = InducedCFG.this.iterator(); it.hasNext();) {
|
||||
final BasicBlock candid = (BasicBlock) it.next();
|
||||
for (BasicBlock candid : InducedCFG.this) {
|
||||
if (candid.getFirstInstructionIndex() == tgtNd) {
|
||||
target = candid;
|
||||
break;
|
||||
|
@ -623,8 +621,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuffer s = new StringBuffer("");
|
||||
for (Iterator it = iterator(); it.hasNext();) {
|
||||
BasicBlock bb = (BasicBlock) it.next();
|
||||
for (BasicBlock bb : this) {
|
||||
s.append("BB").append(getNumber(bb)).append("\n");
|
||||
for (int j = bb.getFirstInstructionIndex(); j <= bb.getLastInstructionIndex(); j++) {
|
||||
s.append(" ").append(j).append(" ").append(getInstructions()[j]).append("\n");
|
||||
|
@ -697,8 +694,7 @@ public class InducedCFG extends AbstractCFG<SSAInstruction, InducedCFG.BasicBloc
|
|||
|
||||
public Collection<SSAPhiInstruction> getAllPhiInstructions() {
|
||||
Collection<SSAPhiInstruction> result = HashSetFactory.make();
|
||||
for (Iterator<BasicBlock> it = iterator(); it.hasNext();) {
|
||||
BasicBlock b = it.next();
|
||||
for (BasicBlock b : this) {
|
||||
result.addAll(b.getPhis());
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -111,8 +111,7 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
|
|||
*/
|
||||
private void computeI2BMapping() {
|
||||
instruction2Block = new int[getInstructions().length];
|
||||
for (Iterator it = iterator(); it.hasNext();) {
|
||||
final BasicBlock b = (BasicBlock) it.next();
|
||||
for (BasicBlock b : this) {
|
||||
for (int j = b.getFirstInstructionIndex(); j <= b.getLastInstructionIndex(); j++) {
|
||||
instruction2Block[j] = getNumber(b);
|
||||
}
|
||||
|
@ -123,8 +122,7 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
|
|||
* Compute outgoing edges in the control flow graph.
|
||||
*/
|
||||
private void computeEdges() {
|
||||
for (Iterator it = iterator(); it.hasNext();) {
|
||||
BasicBlock b = (BasicBlock) it.next();
|
||||
for (BasicBlock b : this) {
|
||||
if (b.equals(exit())) {
|
||||
continue;
|
||||
} else if (b.equals(entry())) {
|
||||
|
@ -238,8 +236,8 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
|
|||
|
||||
IInstruction last = getInstructions()[getLastInstructionIndex()];
|
||||
int[] targets = last.getBranchTargets();
|
||||
for (int i = 0; i < targets.length; i++) {
|
||||
BasicBlock b = getBlockForInstruction(targets[i]);
|
||||
for (int target : targets) {
|
||||
BasicBlock b = getBlockForInstruction(target);
|
||||
addNormalEdgeTo(b);
|
||||
}
|
||||
addExceptionalEdges(last);
|
||||
|
@ -310,11 +308,11 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
|
|||
// this var gets set to false if goToAllHandlers is true but some enclosing exception handler catches all
|
||||
// exceptions. in such a case, we need not add an exceptional edge to the method exit
|
||||
boolean needEdgeToExitForAllHandlers = true;
|
||||
for (int j = 0; j < hs.length; j++) {
|
||||
for (ExceptionHandler element : hs) {
|
||||
if (DEBUG) {
|
||||
System.err.println(" handler " + hs[j]);
|
||||
System.err.println(" handler " + element);
|
||||
}
|
||||
BasicBlock b = getBlockForInstruction(hs[j].getHandler());
|
||||
BasicBlock b = getBlockForInstruction(element.getHandler());
|
||||
if (DEBUG) {
|
||||
System.err.println(" target " + b);
|
||||
}
|
||||
|
@ -325,15 +323,15 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
|
|||
}
|
||||
addExceptionalEdgeTo(b);
|
||||
// if the handler catches all exceptions, we don't need to add an edge to the exit or any other handlers
|
||||
if (hs[j].getCatchClass() == null) {
|
||||
if (element.getCatchClass() == null) {
|
||||
needEdgeToExitForAllHandlers = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
TypeReference caughtException = null;
|
||||
if (hs[j].getCatchClass() != null) {
|
||||
if (element.getCatchClass() != null) {
|
||||
ClassLoaderReference loader = ShrikeCFG.this.getMethod().getDeclaringClass().getReference().getClassLoader();
|
||||
caughtException = ShrikeUtil.makeTypeReference(loader, hs[j].getCatchClass());
|
||||
caughtException = ShrikeUtil.makeTypeReference(loader, element.getCatchClass());
|
||||
if (DEBUG) {
|
||||
System.err.println(" caughtException " + caughtException);
|
||||
}
|
||||
|
@ -502,8 +500,7 @@ public class ShrikeCFG extends AbstractCFG<IInstruction, ShrikeCFG.BasicBlock> i
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuffer s = new StringBuffer("");
|
||||
for (Iterator it = iterator(); it.hasNext();) {
|
||||
BasicBlock bb = (BasicBlock) it.next();
|
||||
for (BasicBlock bb : this) {
|
||||
s.append("BB").append(getNumber(bb)).append("\n");
|
||||
for (int j = bb.getFirstInstructionIndex(); j <= bb.getLastInstructionIndex(); j++) {
|
||||
s.append(" ").append(j).append(" ").append(getInstructions()[j]).append("\n");
|
||||
|
|
|
@ -214,7 +214,7 @@ public class Util {
|
|||
throw new IllegalArgumentException("b is null");
|
||||
}
|
||||
int i = 0;
|
||||
for (Iterator it = cfg.getPredNodes(b); it.hasNext();) {
|
||||
for (Iterator<T> it = cfg.getPredNodes(b); it.hasNext();) {
|
||||
if (it.next().equals(a)) {
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -66,13 +66,12 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
|
|||
edgeLabels = HashMapFactory.make();
|
||||
}
|
||||
|
||||
for (Iterator<? extends T> ns = cfg.iterator(); ns.hasNext();) {
|
||||
for (T name : cfg) {
|
||||
HashSet<T> s = HashSetFactory.make(2);
|
||||
controlDependence.put(ns.next(), s);
|
||||
controlDependence.put(name, s);
|
||||
}
|
||||
|
||||
for (Iterator<? extends T> ns = cfg.iterator(); ns.hasNext();) {
|
||||
T y = ns.next();
|
||||
for (T y : cfg) {
|
||||
for (Iterator<T> ns2 = RDF.getDominanceFrontier(y); ns2.hasNext();) {
|
||||
T x = ns2.next();
|
||||
controlDependence.get(x).add(y);
|
||||
|
@ -104,14 +103,13 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
|
|||
return new NumberedEdgeManager<T>() {
|
||||
Map<T, Set<T>> backwardEdges = HashMapFactory.make(forwardEdges.size());
|
||||
{
|
||||
for (Iterator<? extends T> x = cfg.iterator(); x.hasNext();) {
|
||||
for (T name : cfg) {
|
||||
Set<T> s = HashSetFactory.make();
|
||||
backwardEdges.put(x.next(), s);
|
||||
backwardEdges.put(name, s);
|
||||
}
|
||||
for (Iterator<T> ps = forwardEdges.keySet().iterator(); ps.hasNext();) {
|
||||
T p = ps.next();
|
||||
for (Iterator ns = ((Set) forwardEdges.get(p)).iterator(); ns.hasNext();) {
|
||||
Object n = ns.next();
|
||||
for (T p : forwardEdges.keySet()) {
|
||||
for (T t : forwardEdges.get(p)) {
|
||||
Object n = t;
|
||||
backwardEdges.get(n).add(p);
|
||||
}
|
||||
}
|
||||
|
@ -206,15 +204,14 @@ public class ControlDependenceGraph<T> extends AbstractNumberedGraph<T> {
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (Iterator<? extends T> ns = iterator(); ns.hasNext();) {
|
||||
T n = ns.next();
|
||||
for (T n : this) {
|
||||
sb.append(n.toString()).append("\n");
|
||||
for (Iterator ss = getSuccNodes(n); ss.hasNext();) {
|
||||
for (Iterator<T> ss = getSuccNodes(n); ss.hasNext();) {
|
||||
Object s = ss.next();
|
||||
sb.append(" --> ").append(s);
|
||||
if (edgeLabels != null)
|
||||
for (Iterator labels = ((Set) edgeLabels.get(Pair.make(n, s))).iterator(); labels.hasNext();)
|
||||
sb.append("\n label: ").append(labels.next());
|
||||
for (Object name : edgeLabels.get(Pair.make(n, s)))
|
||||
sb.append("\n label: ").append(name);
|
||||
sb.append("\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -125,8 +125,8 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
System.err.println("Get source files for " + M);
|
||||
}
|
||||
HashSet<ModuleEntry> result = HashSetFactory.make();
|
||||
for (Iterator it = M.getEntries(); it.hasNext();) {
|
||||
ModuleEntry entry = (ModuleEntry) it.next();
|
||||
for (Iterator<? extends ModuleEntry> it = M.getEntries(); it.hasNext();) {
|
||||
ModuleEntry entry = it.next();
|
||||
if (DEBUG_LEVEL > 0) {
|
||||
System.err.println("consider entry for source information: " + entry);
|
||||
}
|
||||
|
@ -155,8 +155,8 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
System.err.println("Get class files for " + M);
|
||||
}
|
||||
HashSet<ModuleEntry> result = HashSetFactory.make();
|
||||
for (Iterator it = M.getEntries(); it.hasNext();) {
|
||||
ModuleEntry entry = (ModuleEntry) it.next();
|
||||
for (Iterator<? extends ModuleEntry> it = M.getEntries(); it.hasNext();) {
|
||||
ModuleEntry entry = it.next();
|
||||
if (DEBUG_LEVEL > 0) {
|
||||
System.err.println("ClassLoaderImpl.getClassFiles:Got entry: " + entry);
|
||||
}
|
||||
|
@ -183,13 +183,11 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
*/
|
||||
private static void removeClassFiles(Set<ModuleEntry> s, Set<ModuleEntry> t) {
|
||||
Set<String> old = HashSetFactory.make();
|
||||
for (Iterator<ModuleEntry> it = t.iterator(); it.hasNext();) {
|
||||
ModuleEntry m = it.next();
|
||||
for (ModuleEntry m : t) {
|
||||
old.add(m.getClassName());
|
||||
}
|
||||
HashSet<ModuleEntry> toRemove = HashSetFactory.make();
|
||||
for (Iterator<ModuleEntry> it = s.iterator(); it.hasNext();) {
|
||||
ModuleEntry m = it.next();
|
||||
for (ModuleEntry m : s) {
|
||||
if (old.contains(m.getClassName())) {
|
||||
toRemove.add(m);
|
||||
}
|
||||
|
@ -243,8 +241,7 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
*/
|
||||
@SuppressWarnings("unused")
|
||||
private void loadAllClasses(Collection<ModuleEntry> moduleEntries, Map<String, Object> fileContents) {
|
||||
for (Iterator<ModuleEntry> it = moduleEntries.iterator(); it.hasNext();) {
|
||||
ModuleEntry entry = it.next();
|
||||
for (ModuleEntry entry : moduleEntries) {
|
||||
if (!entry.isClassFile()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -411,8 +408,7 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
*/
|
||||
@SuppressWarnings("unused")
|
||||
protected void loadAllSources(Set<ModuleEntry> sourceModules) {
|
||||
for (Iterator<ModuleEntry> it = sourceModules.iterator(); it.hasNext();) {
|
||||
ModuleEntry entry = it.next();
|
||||
for (ModuleEntry entry : sourceModules) {
|
||||
String className = entry.getClassName().replace('.', '/');
|
||||
className = className.replace(File.separatorChar, '/');
|
||||
className = "L" + ((className.startsWith("/")) ? className.substring(1) : className);
|
||||
|
@ -489,8 +485,7 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
// module are loaded according to the given order (same as in Java VM)
|
||||
Set<ModuleEntry> classModuleEntries = HashSetFactory.make();
|
||||
Set<ModuleEntry> sourceModuleEntries = HashSetFactory.make();
|
||||
for (Iterator<Module> it = modules.iterator(); it.hasNext();) {
|
||||
Module archive = it.next();
|
||||
for (Module archive : modules) {
|
||||
if (DEBUG_LEVEL > 0) {
|
||||
System.err.println("add archive: " + archive);
|
||||
}
|
||||
|
@ -524,12 +519,10 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
}
|
||||
loadAllClasses(classFiles, allClassAndSourceFileContents);
|
||||
loadAllSources(sourceFiles);
|
||||
for (Iterator<ModuleEntry> it2 = classFiles.iterator(); it2.hasNext();) {
|
||||
ModuleEntry file = it2.next();
|
||||
for (ModuleEntry file : classFiles) {
|
||||
classModuleEntries.add(file);
|
||||
}
|
||||
for (Iterator<ModuleEntry> it2 = sourceFiles.iterator(); it2.hasNext();) {
|
||||
ModuleEntry file = it2.next();
|
||||
for (ModuleEntry file : sourceFiles) {
|
||||
sourceModuleEntries.add(file);
|
||||
}
|
||||
}
|
||||
|
@ -703,8 +696,7 @@ public class ClassLoaderImpl implements IClassLoader {
|
|||
if (toRemove == null) {
|
||||
throw new IllegalArgumentException("toRemove is null");
|
||||
}
|
||||
for (Iterator<IClass> it = toRemove.iterator(); it.hasNext();) {
|
||||
IClass klass = it.next();
|
||||
for (IClass klass : toRemove) {
|
||||
if (DEBUG_LEVEL > 0) {
|
||||
System.err.println("removing " + klass.getName());
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class CodeScanner {
|
|||
* @throws InvalidClassFileException
|
||||
* @throws IllegalArgumentException if m is null
|
||||
*/
|
||||
public static Iterator iterateCastTypes(IMethod m) throws InvalidClassFileException {
|
||||
public static Iterator<TypeReference> iterateCastTypes(IMethod m) throws InvalidClassFileException {
|
||||
if (m == null) {
|
||||
throw new IllegalArgumentException("m is null");
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ public class CodeScanner {
|
|||
}
|
||||
}
|
||||
|
||||
private static Iterator iterateShrikeBTCastTypes(ShrikeCTMethod wrapper) throws InvalidClassFileException {
|
||||
private static Iterator<TypeReference> iterateShrikeBTCastTypes(ShrikeCTMethod wrapper) throws InvalidClassFileException {
|
||||
return wrapper.getCastTypes();
|
||||
}
|
||||
|
||||
|
@ -182,8 +182,8 @@ public class CodeScanner {
|
|||
}
|
||||
|
||||
private static boolean hasShrikeBTObjectArrayStore(ShrikeCTMethod M) throws InvalidClassFileException {
|
||||
for (Iterator it = M.getArraysWritten(); it.hasNext();) {
|
||||
TypeReference t = (TypeReference) it.next();
|
||||
for (Iterator<TypeReference> it = M.getArraysWritten(); it.hasNext();) {
|
||||
TypeReference t = it.next();
|
||||
if (t.isReferenceType()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -232,8 +232,8 @@ public class CodeScanner {
|
|||
}
|
||||
|
||||
private static boolean hasShrikeBTObjectArrayLoad(ShrikeCTMethod M) throws InvalidClassFileException {
|
||||
for (Iterator it = M.getArraysRead(); it.hasNext();) {
|
||||
TypeReference t = (TypeReference) it.next();
|
||||
for (Iterator<TypeReference> it = M.getArraysRead(); it.hasNext();) {
|
||||
TypeReference t = it.next();
|
||||
if (t.isReferenceType()) {
|
||||
return true;
|
||||
}
|
||||
|
@ -257,8 +257,7 @@ public class CodeScanner {
|
|||
result.addAll(t);
|
||||
}
|
||||
};
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
SSAInstruction s = statements[i];
|
||||
for (SSAInstruction s : statements) {
|
||||
if (s != null) {
|
||||
s.visit(v);
|
||||
}
|
||||
|
@ -274,10 +273,10 @@ public class CodeScanner {
|
|||
throw new IllegalArgumentException("statements == null");
|
||||
}
|
||||
final HashSet<TypeReference> result = HashSetFactory.make(10);
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
if (statements[i] != null) {
|
||||
if (statements[i] instanceof SSACheckCastInstruction) {
|
||||
SSACheckCastInstruction c = (SSACheckCastInstruction) statements[i];
|
||||
for (SSAInstruction statement : statements) {
|
||||
if (statement != null) {
|
||||
if (statement instanceof SSACheckCastInstruction) {
|
||||
SSACheckCastInstruction c = (SSACheckCastInstruction) statement;
|
||||
for(TypeReference t : c.getDeclaredResultTypes()) {
|
||||
result.add(t);
|
||||
}
|
||||
|
@ -299,8 +298,7 @@ public class CodeScanner {
|
|||
result.add(instruction.getCallSite());
|
||||
}
|
||||
};
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
SSAInstruction s = statements[i];
|
||||
for (SSAInstruction s : statements) {
|
||||
if (s != null) {
|
||||
s.visit(v);
|
||||
}
|
||||
|
@ -320,8 +318,7 @@ public class CodeScanner {
|
|||
result.add(instruction.getNewSite());
|
||||
}
|
||||
};
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
SSAInstruction s = statements[i];
|
||||
for (SSAInstruction s : statements) {
|
||||
if (s != null) {
|
||||
s.visit(v);
|
||||
}
|
||||
|
@ -345,8 +342,7 @@ public class CodeScanner {
|
|||
result.add(instruction.getDeclaredField());
|
||||
}
|
||||
};
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
SSAInstruction s = statements[i];
|
||||
for (SSAInstruction s : statements) {
|
||||
if (s != null) {
|
||||
s.visit(v);
|
||||
}
|
||||
|
@ -370,8 +366,7 @@ public class CodeScanner {
|
|||
result.add(instruction.getDeclaredField());
|
||||
}
|
||||
};
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
SSAInstruction s = statements[i];
|
||||
for (SSAInstruction s : statements) {
|
||||
if (s != null) {
|
||||
s.visit(v);
|
||||
}
|
||||
|
@ -397,8 +392,7 @@ public class CodeScanner {
|
|||
}
|
||||
|
||||
};
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
SSAInstruction s = statements[i];
|
||||
for (SSAInstruction s : statements) {
|
||||
if (s != null) {
|
||||
s.visit(v);
|
||||
}
|
||||
|
@ -422,8 +416,7 @@ public class CodeScanner {
|
|||
}
|
||||
}
|
||||
ScanVisitor v = new ScanVisitor();
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
SSAInstruction s = statements[i];
|
||||
for (SSAInstruction s : statements) {
|
||||
if (s != null) {
|
||||
s.visit(v);
|
||||
}
|
||||
|
@ -450,8 +443,7 @@ public class CodeScanner {
|
|||
}
|
||||
}
|
||||
ScanVisitor v = new ScanVisitor();
|
||||
for (int i = 0; i < statements.length; i++) {
|
||||
SSAInstruction s = statements[i];
|
||||
for (SSAInstruction s : statements) {
|
||||
if (s != null) {
|
||||
s.visit(v);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
|
|||
* @return Iterator of TypeReference
|
||||
* @throws InvalidClassFileException
|
||||
*/
|
||||
public Iterator getArraysRead() throws InvalidClassFileException {
|
||||
public Iterator<TypeReference> getArraysRead() throws InvalidClassFileException {
|
||||
if (isNative()) {
|
||||
return EmptyIterator.instance();
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
|
|||
* @return Iterator of TypeReference
|
||||
* @throws InvalidClassFileException
|
||||
*/
|
||||
public Iterator getCastTypes() throws InvalidClassFileException {
|
||||
public Iterator<TypeReference> getCastTypes() throws InvalidClassFileException {
|
||||
if (isNative()) {
|
||||
return EmptyIterator.instance();
|
||||
}
|
||||
|
@ -499,56 +499,56 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
|
|||
private static void copyVisitorSetsToArrays(SimpleVisitor simpleVisitor, BytecodeInfo info) {
|
||||
info.newSites = new NewSiteReference[simpleVisitor.newSites.size()];
|
||||
int i = 0;
|
||||
for (Iterator<NewSiteReference> it = simpleVisitor.newSites.iterator(); it.hasNext();) {
|
||||
info.newSites[i++] = it.next();
|
||||
for (NewSiteReference newSiteReference : simpleVisitor.newSites) {
|
||||
info.newSites[i++] = newSiteReference;
|
||||
}
|
||||
|
||||
info.fieldsRead = new FieldReference[simpleVisitor.fieldsRead.size()];
|
||||
i = 0;
|
||||
for (Iterator<FieldReference> it = simpleVisitor.fieldsRead.iterator(); it.hasNext();) {
|
||||
info.fieldsRead[i++] = it.next();
|
||||
for (FieldReference fieldReference : simpleVisitor.fieldsRead) {
|
||||
info.fieldsRead[i++] = fieldReference;
|
||||
}
|
||||
|
||||
info.fieldsRead = new FieldReference[simpleVisitor.fieldsRead.size()];
|
||||
i = 0;
|
||||
for (Iterator<FieldReference> it = simpleVisitor.fieldsRead.iterator(); it.hasNext();) {
|
||||
info.fieldsRead[i++] = it.next();
|
||||
for (FieldReference fieldReference : simpleVisitor.fieldsRead) {
|
||||
info.fieldsRead[i++] = fieldReference;
|
||||
}
|
||||
|
||||
info.fieldsWritten = new FieldReference[simpleVisitor.fieldsWritten.size()];
|
||||
i = 0;
|
||||
for (Iterator<FieldReference> it = simpleVisitor.fieldsWritten.iterator(); it.hasNext();) {
|
||||
info.fieldsWritten[i++] = it.next();
|
||||
for (FieldReference fieldReference : simpleVisitor.fieldsWritten) {
|
||||
info.fieldsWritten[i++] = fieldReference;
|
||||
}
|
||||
|
||||
info.callSites = new CallSiteReference[simpleVisitor.callSites.size()];
|
||||
i = 0;
|
||||
for (Iterator<CallSiteReference> it = simpleVisitor.callSites.iterator(); it.hasNext();) {
|
||||
info.callSites[i++] = it.next();
|
||||
for (CallSiteReference callSiteReference : simpleVisitor.callSites) {
|
||||
info.callSites[i++] = callSiteReference;
|
||||
}
|
||||
|
||||
info.arraysRead = new TypeReference[simpleVisitor.arraysRead.size()];
|
||||
i = 0;
|
||||
for (Iterator<TypeReference> it = simpleVisitor.arraysRead.iterator(); it.hasNext();) {
|
||||
info.arraysRead[i++] = it.next();
|
||||
for (TypeReference typeReference : simpleVisitor.arraysRead) {
|
||||
info.arraysRead[i++] = typeReference;
|
||||
}
|
||||
|
||||
info.arraysWritten = new TypeReference[simpleVisitor.arraysWritten.size()];
|
||||
i = 0;
|
||||
for (Iterator<TypeReference> it = simpleVisitor.arraysWritten.iterator(); it.hasNext();) {
|
||||
info.arraysWritten[i++] = it.next();
|
||||
for (TypeReference typeReference : simpleVisitor.arraysWritten) {
|
||||
info.arraysWritten[i++] = typeReference;
|
||||
}
|
||||
|
||||
info.implicitExceptions = new TypeReference[simpleVisitor.implicitExceptions.size()];
|
||||
i = 0;
|
||||
for (Iterator it = simpleVisitor.implicitExceptions.iterator(); it.hasNext();) {
|
||||
info.implicitExceptions[i++] = (TypeReference) it.next();
|
||||
for (TypeReference typeReference : simpleVisitor.implicitExceptions) {
|
||||
info.implicitExceptions[i++] = typeReference;
|
||||
}
|
||||
|
||||
info.castTypes = new TypeReference[simpleVisitor.castTypes.size()];
|
||||
i = 0;
|
||||
for (Iterator<TypeReference> it = simpleVisitor.castTypes.iterator(); it.hasNext();) {
|
||||
info.castTypes[i++] = it.next();
|
||||
for (TypeReference typeReference : simpleVisitor.castTypes) {
|
||||
info.castTypes[i++] = typeReference;
|
||||
}
|
||||
|
||||
info.hasMonitorOp = simpleVisitor.hasMonitorOp;
|
||||
|
@ -842,9 +842,9 @@ public abstract class ShrikeBTMethod implements IMethod, BytecodeConstants {
|
|||
}
|
||||
HashSet<TypeReference> result = HashSetFactory.make(10);
|
||||
ClassLoaderReference loader = getReference().getDeclaringClass().getClassLoader();
|
||||
for (int i = 0; i < handlers.length; i++) {
|
||||
for (int j = 0; j < handlers[i].length; j++) {
|
||||
TypeReference t = ShrikeUtil.makeTypeReference(loader, handlers[i][j].getCatchClass());
|
||||
for (ExceptionHandler[] handler : handlers) {
|
||||
for (int j = 0; j < handler.length; j++) {
|
||||
TypeReference t = ShrikeUtil.makeTypeReference(loader, handler[j].getCatchClass());
|
||||
if (t == null) {
|
||||
t = TypeReference.JavaLangThrowable;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ package com.ibm.wala.classLoader;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
|
@ -228,8 +227,8 @@ public final class ShrikeClass extends JVMClass<IClassLoader> {
|
|||
public void clearSoftCaches() {
|
||||
// toss optional information from each method.
|
||||
if (methodMap != null) {
|
||||
for (Iterator it = getDeclaredMethods().iterator(); it.hasNext();) {
|
||||
ShrikeCTMethod m = (ShrikeCTMethod) it.next();
|
||||
for (IMethod iMethod : getDeclaredMethods()) {
|
||||
ShrikeCTMethod m = (ShrikeCTMethod) iMethod;
|
||||
m.clearCaches();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -334,10 +334,10 @@ public class LocalPathEdges {
|
|||
// this is convoluted on purpose for efficiency: to avoid random access to
|
||||
// the sparse vector, we do parallel iteration with the vector's indices
|
||||
// and contents. TODO: better data structure?
|
||||
Iterator contents = paths.iterator();
|
||||
Iterator<IBinaryNaturalRelation> contents = paths.iterator();
|
||||
for (IntIterator it = paths.iterateIndices(); it.hasNext();) {
|
||||
int d2 = it.next();
|
||||
IBinaryNaturalRelation R = (IBinaryNaturalRelation) contents.next();
|
||||
IBinaryNaturalRelation R = contents.next();
|
||||
if (R != null && R.contains(n, d1)) {
|
||||
result.add(d2);
|
||||
}
|
||||
|
@ -353,10 +353,10 @@ public class LocalPathEdges {
|
|||
// this is convoluted on purpose for efficiency: to avoid random access to
|
||||
// the sparse vector, we do parallel iteration with the vector's indices
|
||||
// and contents. TODO: better data structure?
|
||||
Iterator contents = zeroPaths.iterator();
|
||||
Iterator<IntSet> contents = zeroPaths.iterator();
|
||||
for (IntIterator it = zeroPaths.iterateIndices(); it.hasNext();) {
|
||||
int d2 = it.next();
|
||||
BitVectorIntSet s = (BitVectorIntSet) contents.next();
|
||||
IntSet s = contents.next();
|
||||
if (s != null && s.contains(n)) {
|
||||
result.add(d2);
|
||||
}
|
||||
|
@ -389,10 +389,10 @@ public class LocalPathEdges {
|
|||
// this is convoluted on purpose for efficiency: to avoid random access to
|
||||
// the sparse vector, we do parallel iteration with the vector's indices
|
||||
// and contents. TODO: better data structure?
|
||||
Iterator contents = paths.iterator();
|
||||
Iterator<IBinaryNaturalRelation> contents = paths.iterator();
|
||||
for (IntIterator it = paths.iterateIndices(); it.hasNext();) {
|
||||
int d2 = it.next();
|
||||
IBinaryNaturalRelation R = (IBinaryNaturalRelation) contents.next();
|
||||
IBinaryNaturalRelation R = contents.next();
|
||||
if (R != null && R.anyRelated(n)) {
|
||||
result.add(d2);
|
||||
}
|
||||
|
@ -402,10 +402,10 @@ public class LocalPathEdges {
|
|||
// this is convoluted on purpose for efficiency: to avoid random access to
|
||||
// the sparse vector, we do parallel iteration with the vector's indices
|
||||
// and contents. TODO: better data structure?
|
||||
Iterator contents = identityPaths.iterator();
|
||||
Iterator<IntSet> contents = identityPaths.iterator();
|
||||
for (IntIterator it = identityPaths.iterateIndices(); it.hasNext();) {
|
||||
int d1 = it.next();
|
||||
BitVectorIntSet s = (BitVectorIntSet) contents.next();
|
||||
IntSet s = contents.next();
|
||||
if (s != null && s.contains(n)) {
|
||||
result.add(d1);
|
||||
}
|
||||
|
@ -415,10 +415,10 @@ public class LocalPathEdges {
|
|||
// this is convoluted on purpose for efficiency: to avoid random access to
|
||||
// the sparse vector, we do parallel iteration with the vector's indices
|
||||
// and contents. TODO: better data structure?
|
||||
Iterator contents = zeroPaths.iterator();
|
||||
Iterator<IntSet> contents = zeroPaths.iterator();
|
||||
for (IntIterator it = zeroPaths.iterateIndices(); it.hasNext();) {
|
||||
int d2 = it.next();
|
||||
BitVectorIntSet s = (BitVectorIntSet) contents.next();
|
||||
IntSet s = contents.next();
|
||||
if (s != null && s.contains(n)) {
|
||||
result.add(d2);
|
||||
}
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
*******************************************************************************/
|
||||
package com.ibm.wala.dataflow.IFDS;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.util.collections.SparseVector;
|
||||
import com.ibm.wala.util.intset.BasicNaturalRelation;
|
||||
import com.ibm.wala.util.intset.IBinaryNaturalRelation;
|
||||
|
@ -133,8 +131,7 @@ public class LocalSummaryEdges {
|
|||
return null;
|
||||
} else {
|
||||
MutableSparseIntSet result = MutableSparseIntSet.makeEmpty();
|
||||
for (Iterator it = R.iterator(); it.hasNext();) {
|
||||
IntPair p = (IntPair) it.next();
|
||||
for (IntPair p : R) {
|
||||
if (p.getY() == d2) {
|
||||
result.add(p.getX());
|
||||
}
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,20 +82,19 @@ public abstract class SSAInference<T extends IVariable<T>> extends DefaultFixedP
|
|||
|
||||
private void createEquations(OperatorFactory<T> opFactory) {
|
||||
SSAInstruction[] instructions = ir.getInstructions();
|
||||
for (int i = 0; i < instructions.length; i++) {
|
||||
SSAInstruction s = instructions[i];
|
||||
for (SSAInstruction s : instructions) {
|
||||
makeEquationForInstruction(opFactory, s);
|
||||
}
|
||||
for (Iterator it = ir.iteratePhis(); it.hasNext();) {
|
||||
SSAInstruction s = (SSAInstruction) it.next();
|
||||
for (Iterator<? extends SSAInstruction> it = ir.iteratePhis(); it.hasNext();) {
|
||||
SSAInstruction s = it.next();
|
||||
makeEquationForInstruction(opFactory, s);
|
||||
}
|
||||
for (Iterator it = ir.iteratePis(); it.hasNext();) {
|
||||
SSAInstruction s = (SSAInstruction) it.next();
|
||||
for (Iterator<? extends SSAInstruction> it = ir.iteratePis(); it.hasNext();) {
|
||||
SSAInstruction s = it.next();
|
||||
makeEquationForInstruction(opFactory, s);
|
||||
}
|
||||
for (Iterator it = ir.iterateCatchInstructions(); it.hasNext();) {
|
||||
SSAInstruction s = (SSAInstruction) it.next();
|
||||
for (Iterator<? extends SSAInstruction> it = ir.iterateCatchInstructions(); it.hasNext();) {
|
||||
SSAInstruction s = it.next();
|
||||
makeEquationForInstruction(opFactory, s);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -125,8 +125,8 @@ public class FILiveObjectAnalysis implements ILiveObjectAnalysis {
|
|||
}
|
||||
|
||||
private boolean mayBeLiveInSomeCaller(InstanceKey ik, CGNode m) {
|
||||
for (Iterator it = callGraph.getPredNodes(m); it.hasNext();) {
|
||||
CGNode n = (CGNode) it.next();
|
||||
for (Iterator<CGNode> it = callGraph.getPredNodes(m); it.hasNext();) {
|
||||
CGNode n = it.next();
|
||||
if (mayBeLive(ik, n, -1)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ public class FILiveObjectAnalysis implements ILiveObjectAnalysis {
|
|||
IR ir = m.getIR();
|
||||
DefUse du = m.getDU();
|
||||
|
||||
for (Iterator it = DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik); it.hasNext();) {
|
||||
for (Iterator<Object> it = DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik); it.hasNext();) {
|
||||
Object p = it.next();
|
||||
if (p instanceof LocalPointerKey) {
|
||||
LocalPointerKey lpk = (LocalPointerKey) p;
|
||||
|
@ -164,7 +164,7 @@ public class FILiveObjectAnalysis implements ILiveObjectAnalysis {
|
|||
*/
|
||||
private Set<CGNode> computeLiveNodes(InstanceKey ik) {
|
||||
Set<CGNode> localRootNodes = HashSetFactory.make();
|
||||
for (Iterator it = DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik); it.hasNext();) {
|
||||
for (Iterator<Object> it = DFS.iterateDiscoverTime(GraphInverter.invert(heapGraph), ik); it.hasNext();) {
|
||||
Object node = it.next();
|
||||
if (node instanceof StaticFieldKey) {
|
||||
liveEverywhere.add(ik);
|
||||
|
|
|
@ -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 it = ir.getControlFlowGraph().iterator(); it.hasNext();) {
|
||||
SSACFG.BasicBlock b = (SSACFG.BasicBlock) it.next();
|
||||
for (Iterator it2 = b.iterator(); it2.hasNext();) {
|
||||
SSAInstruction x = (SSAInstruction) it2.next();
|
||||
outer: for (ISSABasicBlock issaBasicBlock : ir.getControlFlowGraph()) {
|
||||
SSACFG.BasicBlock b = (SSACFG.BasicBlock) issaBasicBlock;
|
||||
for (SSAInstruction x : b) {
|
||||
if (s.contains(x)) {
|
||||
result.add(b);
|
||||
continue outer;
|
||||
|
@ -124,10 +123,9 @@ public class LocalLiveRangeAnalysis {
|
|||
if (s == null) {
|
||||
Assertions.UNREACHABLE();
|
||||
}
|
||||
for (Iterator it = ir.getControlFlowGraph().iterator(); it.hasNext();) {
|
||||
SSACFG.BasicBlock b = (SSACFG.BasicBlock) it.next();
|
||||
for (Iterator it2 = b.iterator(); it2.hasNext();) {
|
||||
SSAInstruction x = (SSAInstruction) it2.next();
|
||||
for (ISSABasicBlock issaBasicBlock : ir.getControlFlowGraph()) {
|
||||
SSACFG.BasicBlock b = (SSACFG.BasicBlock) issaBasicBlock;
|
||||
for (SSAInstruction x : b) {
|
||||
if (s.equals(x)) {
|
||||
return b;
|
||||
}
|
||||
|
@ -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 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;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
|
|||
}
|
||||
|
||||
// allocN := set of call graph nodes representing method allocMethod
|
||||
Set allocN = cg.getNodes(allocMethod);
|
||||
Set<CGNode> allocN = cg.getNodes(allocMethod);
|
||||
if (allocN.size() == 0) {
|
||||
throw new WalaException("could not find call graph node for allocation method " + allocMethod);
|
||||
}
|
||||
|
@ -89,11 +89,10 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
|
|||
* { nodes }
|
||||
* @throws WalaException
|
||||
*/
|
||||
private boolean mayEscape(Set allocN, int allocPC, Set nodes) throws WalaException {
|
||||
private boolean mayEscape(Set<CGNode> allocN, int allocPC, Set nodes) throws WalaException {
|
||||
Set<InstanceKey> instances = HashSetFactory.make();
|
||||
// instances := set of instance key allocated at <allocMethod, allocPC>
|
||||
for (Iterator it = allocN.iterator(); it.hasNext();) {
|
||||
CGNode n = (CGNode) it.next();
|
||||
for (CGNode n : allocN) {
|
||||
NewSiteReference site = findAlloc(n, allocPC);
|
||||
InstanceKey ik = hg.getHeapModel().getInstanceKeyForAllocation(n, site);
|
||||
if (ik == null) {
|
||||
|
@ -102,9 +101,8 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
|
|||
instances.add(ik);
|
||||
}
|
||||
|
||||
for (Iterator<InstanceKey> it = instances.iterator(); it.hasNext();) {
|
||||
InstanceKey ik = it.next();
|
||||
for (Iterator it2 = hg.getPredNodes(ik); it2.hasNext();) {
|
||||
for (InstanceKey ik : instances) {
|
||||
for (Iterator<Object> it2 = hg.getPredNodes(ik); it2.hasNext();) {
|
||||
PointerKey p = (PointerKey) it2.next();
|
||||
if (!(p instanceof AbstractLocalPointerKey)) {
|
||||
// a pointer from the heap. give up.
|
||||
|
@ -136,8 +134,8 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn
|
|||
if (n == null) {
|
||||
throw new IllegalArgumentException("null n");
|
||||
}
|
||||
for (Iterator it = n.iterateNewSites(); it.hasNext();) {
|
||||
NewSiteReference site = (NewSiteReference) it.next();
|
||||
for (Iterator<NewSiteReference> it = n.iterateNewSites(); it.hasNext();) {
|
||||
NewSiteReference site = it.next();
|
||||
if (site.getProgramCounter() == allocPC) {
|
||||
return site;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ package com.ibm.wala.ipa.callgraph;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
|
@ -116,8 +115,7 @@ public class CallGraphStats {
|
|||
Set<CGNode> reachableNodes = DFS.getReachableNodes(cg, Collections.singleton(cg.getFakeRootNode()));
|
||||
int nNodes = 0;
|
||||
int nEdges = 0;
|
||||
for (Iterator<CGNode> it = reachableNodes.iterator(); it.hasNext();) {
|
||||
CGNode n = it.next();
|
||||
for (CGNode n : reachableNodes) {
|
||||
nNodes++;
|
||||
nEdges += cg.getSuccNodeCount(n);
|
||||
}
|
||||
|
@ -142,8 +140,7 @@ public class CallGraphStats {
|
|||
}
|
||||
int ret = 0;
|
||||
HashSet<IMethod> counted = HashSetFactory.make();
|
||||
for (Iterator<? extends CGNode> iter = cg.iterator(); iter.hasNext();) {
|
||||
CGNode node = iter.next();
|
||||
for (CGNode node : cg) {
|
||||
IMethod method = node.getMethod();
|
||||
if (counted.add(method)) {
|
||||
if (method instanceof ShrikeCTMethod) {
|
||||
|
@ -169,8 +166,7 @@ public class CallGraphStats {
|
|||
throw new IllegalArgumentException("cg is null");
|
||||
}
|
||||
HashSet<MethodReference> result = HashSetFactory.make();
|
||||
for (Iterator it = cg.iterator(); it.hasNext();) {
|
||||
CGNode N = (CGNode) it.next();
|
||||
for (CGNode N : cg) {
|
||||
result.add(N.getMethod().getReference());
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -11,8 +11,6 @@
|
|||
package com.ibm.wala.ipa.callgraph.impl;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
|
@ -40,8 +38,7 @@ public class AllApplicationEntrypoints extends HashSet<Entrypoint> {
|
|||
for (IClass klass : cha) {
|
||||
if (!klass.isInterface()) {
|
||||
if (isApplicationClass(scope, klass)) {
|
||||
for (Iterator methodIt = klass.getDeclaredMethods().iterator(); methodIt.hasNext();) {
|
||||
IMethod method = (IMethod) methodIt.next();
|
||||
for (IMethod method : klass.getDeclaredMethods()) {
|
||||
if (!method.isAbstract()) {
|
||||
add(new ArgumentTypeEntrypoint(method, cha));
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
package com.ibm.wala.ipa.callgraph.impl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.classLoader.ArrayClass;
|
||||
|
@ -81,9 +80,8 @@ public class ArgumentTypeEntrypoint extends Entrypoint {
|
|||
}
|
||||
|
||||
private TypeReference chooseAConcreteSubClass(IClass klass) {
|
||||
Collection subclasses = cha.computeSubClasses(klass.getReference());
|
||||
for (Iterator it = subclasses.iterator(); it.hasNext();) {
|
||||
IClass c = (IClass) it.next();
|
||||
Collection<IClass> subclasses = cha.computeSubClasses(klass.getReference());
|
||||
for (IClass c : subclasses) {
|
||||
if (!c.isAbstract()) {
|
||||
return c.getReference();
|
||||
}
|
||||
|
|
|
@ -231,8 +231,8 @@ public abstract class BasicCallGraph<T> extends AbstractNumberedGraph<CGNode> im
|
|||
@Override
|
||||
public String toString() {
|
||||
StringBuffer result = new StringBuffer("");
|
||||
for (Iterator i = DFS.iterateDiscoverTime(this, new NonNullSingletonIterator<CGNode>(getFakeRootNode())); i.hasNext();) {
|
||||
CGNode n = (CGNode) i.next();
|
||||
for (Iterator<CGNode> i = DFS.iterateDiscoverTime(this, new NonNullSingletonIterator<CGNode>(getFakeRootNode())); i.hasNext();) {
|
||||
CGNode n = i.next();
|
||||
result.append(nodeToString(this, n) + "\n");
|
||||
}
|
||||
return result.toString();
|
||||
|
@ -241,14 +241,14 @@ public abstract class BasicCallGraph<T> extends AbstractNumberedGraph<CGNode> im
|
|||
public static String nodeToString(CallGraph CG, CGNode n) {
|
||||
StringBuffer result = new StringBuffer(n.toString() + "\n");
|
||||
if (n.getMethod() != null) {
|
||||
for (Iterator sites = n.iterateCallSites(); sites.hasNext();) {
|
||||
CallSiteReference site = (CallSiteReference) sites.next();
|
||||
Iterator targets = CG.getPossibleTargets(n, site).iterator();
|
||||
for (Iterator<CallSiteReference> sites = n.iterateCallSites(); sites.hasNext();) {
|
||||
CallSiteReference site = sites.next();
|
||||
Iterator<CGNode> targets = CG.getPossibleTargets(n, site).iterator();
|
||||
if (targets.hasNext()) {
|
||||
result.append(" - " + site + "\n");
|
||||
}
|
||||
for (; targets.hasNext();) {
|
||||
CGNode target = (CGNode) targets.next();
|
||||
CGNode target = targets.next();
|
||||
result.append(" -> " + target + "\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 xs = cg.getNodes(m).iterator(); xs.hasNext();) {
|
||||
CGNode x = (CGNode) xs.next();
|
||||
for (CGNode x : cg.getNodes(m)) {
|
||||
if (containsNode(x)) {
|
||||
result.add(x);
|
||||
}
|
||||
|
@ -149,8 +148,8 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
|
|||
public IntSet getSuccNodeNumbers(CGNode node) {
|
||||
assert containsNode(node);
|
||||
MutableIntSet x = IntSetUtil.make();
|
||||
for (Iterator ns = getSuccNodes(node); ns.hasNext();) {
|
||||
CGNode succ = (CGNode) ns.next();
|
||||
for (Iterator<CGNode> ns = getSuccNodes(node); ns.hasNext();) {
|
||||
CGNode succ = ns.next();
|
||||
if (containsNode(succ)) {
|
||||
x.add(getNumber(succ));
|
||||
}
|
||||
|
@ -163,8 +162,8 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
|
|||
public IntSet getPredNodeNumbers(CGNode node) {
|
||||
assert containsNode(node);
|
||||
MutableIntSet x = IntSetUtil.make();
|
||||
for (Iterator ns = getPredNodes(node); ns.hasNext();) {
|
||||
CGNode pred = (CGNode) ns.next();
|
||||
for (Iterator<CGNode> ns = getPredNodes(node); ns.hasNext();) {
|
||||
CGNode pred = ns.next();
|
||||
if (containsNode(pred)) {
|
||||
x.add(getNumber(pred));
|
||||
}
|
||||
|
@ -189,8 +188,7 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
|
|||
return null;
|
||||
}
|
||||
Set<CGNode> result = HashSetFactory.make();
|
||||
for (Iterator ns = cg.getPossibleTargets(node, site).iterator(); ns.hasNext();) {
|
||||
CGNode target = (CGNode) ns.next();
|
||||
for (CGNode target : cg.getPossibleTargets(node, site)) {
|
||||
if (containsNode(target)) {
|
||||
result.add(target);
|
||||
}
|
||||
|
|
|
@ -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 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 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);
|
||||
}
|
||||
|
|
|
@ -86,15 +86,14 @@ public final class ConcreteTypeKey implements InstanceKey {
|
|||
if (pei == null) {
|
||||
throw new IllegalArgumentException("pei is null");
|
||||
}
|
||||
Collection types = pei.getExceptionTypes();
|
||||
Collection<TypeReference> types = pei.getExceptionTypes();
|
||||
// TODO: institute a cache?
|
||||
if (types == null) {
|
||||
return null;
|
||||
}
|
||||
InstanceKey[] result = new InstanceKey[types.size()];
|
||||
int i = 0;
|
||||
for (Iterator it = types.iterator(); it.hasNext();) {
|
||||
TypeReference type = (TypeReference) it.next();
|
||||
for (TypeReference type : types) {
|
||||
assert type != null;
|
||||
IClass klass = cha.lookupClass(type);
|
||||
result[i++] = new ConcreteTypeKey(klass);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue