changes from upstream
This commit is contained in:
parent
59fc11b5f3
commit
4b3cba710d
|
@ -17,6 +17,6 @@ Require-Bundle: com.ibm.wala.cast;bundle-version="1.0.0",
|
|||
org.eclipse.core.resources;bundle-version="3.4.1",
|
||||
com.ibm.wala.ide.tests;bundle-version="1.1.3",
|
||||
org.eclipse.jdt.core;bundle-version="3.4.2",
|
||||
org.junit4;bundle-version="4.3.1"
|
||||
org.junit4;bundle-version="4.8.1"
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,3 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2002 - 2006 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.cast.js.rhino.test;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
@ -40,12 +40,6 @@ public abstract class TestSimplePageCallGraphShape extends TestJSCallGraphShape
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Before
|
||||
public void config() {
|
||||
JSSourceExtractor.USE_TEMP_NAME = false;
|
||||
JSSourceExtractor.DELETE_UPON_EXIT = true;
|
||||
}
|
||||
|
||||
private static final Object[][] assertionsForPage1 = new Object[][] {
|
||||
new Object[] { ROOT, new String[] { "page1.html" } },
|
||||
|
|
|
@ -23,9 +23,9 @@ import java.util.Set;
|
|||
*/
|
||||
public abstract class JSSourceExtractor {
|
||||
|
||||
public static boolean DELETE_UPON_EXIT = true;
|
||||
public static boolean DELETE_UPON_EXIT = false;
|
||||
|
||||
public static boolean USE_TEMP_NAME = true;
|
||||
public static boolean USE_TEMP_NAME = false;
|
||||
|
||||
public abstract Set<MappedSourceModule> extractSources(URL entrypointUrl, IHtmlParser htmlParser, IUrlResolver urlResolver) throws IOException;
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ import com.ibm.wala.classLoader.IClass;
|
|||
import com.ibm.wala.classLoader.IField;
|
||||
import com.ibm.wala.classLoader.IMethod;
|
||||
import com.ibm.wala.classLoader.Language;
|
||||
import com.ibm.wala.classLoader.NewSiteReference;
|
||||
import com.ibm.wala.fixpoint.AbstractOperator;
|
||||
import com.ibm.wala.fixpoint.UnaryOperator;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
|
@ -64,7 +63,6 @@ import com.ibm.wala.ipa.callgraph.propagation.PropagationCallGraphBuilder;
|
|||
import com.ibm.wala.ipa.callgraph.propagation.PropagationSystem;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.shrikeBT.BinaryOpInstruction;
|
||||
import com.ibm.wala.shrikeBT.IBinaryOpInstruction.IOperator;
|
||||
import com.ibm.wala.shrikeBT.IUnaryOpInstruction;
|
||||
import com.ibm.wala.ssa.DefUse;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package arrayAlias;
|
||||
|
||||
public class TestZeroLengthArray {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Object[] arr = new Object[0];
|
||||
// this will throw an exception; use it to test pointer analysis precision
|
||||
arr[0] = new Object();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
|
||||
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
|
||||
<listEntry value="/com.ibm.wala.core.tests"/>
|
||||
|
@ -7,6 +7,7 @@
|
|||
<listEntry value="4"/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
|
||||
<stringAttribute key="org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE" value="/tmp/wala.out"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.ibm.wala.core.tests"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
|
||||
|
@ -20,6 +21,7 @@
|
|||
<listEntry value="<?xml version="1.0" encoding="UTF-8"?> <runtimeClasspathEntry path="3" projectName="com.ibm.wala.core.testdata" type="1"/> "/>
|
||||
</listAttribute>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/JDK 1.6"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.ibm.wala.core.tests"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx800M -verbose:gc -Dcom.ibm.wala.util.fixedpoint.impl.verbose=true"/>
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2008 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.core.tests.ptrs;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.ibm.wala.core.tests.callGraph.CallGraphTestUtil;
|
||||
import com.ibm.wala.core.tests.util.TestConstants;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisCache;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
|
||||
import com.ibm.wala.ipa.callgraph.Entrypoint;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Everywhere;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Util;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.HeapModel;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.PointerAnalysis;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchy;
|
||||
import com.ibm.wala.ipa.cha.ClassHierarchyException;
|
||||
import com.ibm.wala.types.ClassLoaderReference;
|
||||
import com.ibm.wala.types.MethodReference;
|
||||
import com.ibm.wala.types.Selector;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
import com.ibm.wala.util.CancelException;
|
||||
import com.ibm.wala.util.intset.OrdinalSet;
|
||||
|
||||
public class ZeroLengthArrayTest {
|
||||
|
||||
@Test
|
||||
public void testZeroLengthArray() throws ClassHierarchyException, IllegalArgumentException, CancelException, IOException {
|
||||
AnalysisScope scope = CallGraphTestUtil.makeJ2SEAnalysisScope(TestConstants.WALA_TESTDATA,
|
||||
CallGraphTestUtil.REGRESSION_EXCLUSIONS);
|
||||
ClassHierarchy cha = ClassHierarchy.make(scope);
|
||||
Iterable<Entrypoint> entrypoints = com.ibm.wala.ipa.callgraph.impl.Util.makeMainEntrypoints(scope, cha,
|
||||
TestConstants.ZERO_LENGTH_ARRAY_MAIN);
|
||||
AnalysisOptions options = CallGraphTestUtil.makeAnalysisOptions(scope, entrypoints);
|
||||
|
||||
CallGraphBuilder builder = Util.makeVanillaZeroOneCFABuilder(options, new AnalysisCache(), cha, scope);
|
||||
CallGraph cg = builder.makeCallGraph(options, null);
|
||||
PointerAnalysis pa = builder.getPointerAnalysis();
|
||||
// System.err.println(pa);
|
||||
|
||||
HeapModel heapModel = pa.getHeapModel();
|
||||
CGNode mainNode = cg.getNode(
|
||||
cha.resolveMethod(MethodReference.findOrCreate(
|
||||
TypeReference.findOrCreate(ClassLoaderReference.Application, TestConstants.ZERO_LENGTH_ARRAY_MAIN),
|
||||
Selector.make("main([Ljava/lang/String;)V"))), Everywhere.EVERYWHERE);
|
||||
OrdinalSet<InstanceKey> pointsToSet = pa.getPointsToSet(heapModel.getPointerKeyForLocal(mainNode, 4));
|
||||
Assert.assertEquals(1, pointsToSet.size());
|
||||
InstanceKey arrayKey = pointsToSet.iterator().next();
|
||||
OrdinalSet<InstanceKey> arrayContents = pa.getPointsToSet(heapModel.getPointerKeyForArrayContents(arrayKey));
|
||||
System.err.println(arrayContents);
|
||||
Assert.assertEquals(0, arrayContents.size());
|
||||
|
||||
}
|
||||
}
|
|
@ -40,6 +40,8 @@ public interface TestConstants {
|
|||
|
||||
public final static String ARRAY_ALIAS_MAIN = "LarrayAlias/TestArrayAlias";
|
||||
|
||||
public final static String ZERO_LENGTH_ARRAY_MAIN = "LarrayAlias/TestZeroLengthArray";
|
||||
|
||||
public final static String REFLECT1_MAIN = "Lreflection/Reflect1";
|
||||
|
||||
public final static String REFLECT2_MAIN = "Lreflection/Reflect2";
|
||||
|
|
|
@ -20,6 +20,8 @@ import com.ibm.wala.ipa.callgraph.CGNode;
|
|||
import com.ibm.wala.ipa.callgraph.propagation.cfa.CallerContext;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.cfa.ContainerContextSelector;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.ssa.IR;
|
||||
import com.ibm.wala.ssa.SSANewInstruction;
|
||||
import com.ibm.wala.types.TypeReference;
|
||||
|
||||
/**
|
||||
|
@ -63,16 +65,31 @@ public class AllocationSiteInNodeFactory implements InstanceKeyFactory {
|
|||
return null;
|
||||
}
|
||||
|
||||
CGNode nodeToUse = node;
|
||||
|
||||
// disallow recursion in contexts.
|
||||
if (node.getContext() instanceof ReceiverInstanceContext || node.getContext() instanceof CallerContext) {
|
||||
IMethod m = node.getMethod();
|
||||
CGNode n = ContainerContextSelector.findNodeRecursiveMatchingContext(m, node.getContext());
|
||||
if (n != null) {
|
||||
return new NormalAllocationInNode(n, allocation, type);
|
||||
nodeToUse = n;
|
||||
}
|
||||
}
|
||||
|
||||
InstanceKey key = new NormalAllocationInNode(node, allocation, type);
|
||||
if (type.isArrayClass()) {
|
||||
// special case for arrays with zero length in their first dimension
|
||||
IR ir = node.getIR();
|
||||
SSANewInstruction newInstruction = ir.getNew(allocation);
|
||||
int lengthVN = newInstruction.getUse(0);
|
||||
if (ir.getSymbolTable().isIntegerConstant(lengthVN)) {
|
||||
Integer c = (Integer) ir.getSymbolTable().getConstantValue(lengthVN);
|
||||
if (c.intValue() == 0) {
|
||||
return new ZeroLengthArrayInNode(nodeToUse, allocation, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InstanceKey key = new NormalAllocationInNode(nodeToUse, allocation, type);
|
||||
|
||||
return key;
|
||||
}
|
||||
|
|
|
@ -912,6 +912,9 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder {
|
|||
if (!I.getConcreteType().isArrayClass()) {
|
||||
continue;
|
||||
}
|
||||
if (I instanceof ZeroLengthArrayInNode) {
|
||||
continue;
|
||||
}
|
||||
TypeReference C = I.getConcreteType().getReference().getArrayElementType();
|
||||
if (C.isPrimitiveType()) {
|
||||
continue;
|
||||
|
@ -1292,6 +1295,9 @@ public abstract class PropagationCallGraphBuilder implements CallGraphBuilder {
|
|||
if (!I.getConcreteType().isArrayClass()) {
|
||||
return;
|
||||
}
|
||||
if (I instanceof ZeroLengthArrayInNode) {
|
||||
return;
|
||||
}
|
||||
TypeReference C = I.getConcreteType().getReference().getArrayElementType();
|
||||
if (C.isPrimitiveType()) {
|
||||
return;
|
||||
|
|
|
@ -38,7 +38,6 @@ import com.ibm.wala.ipa.callgraph.ContextSelector;
|
|||
import com.ibm.wala.ipa.callgraph.impl.AbstractRootMethod;
|
||||
import com.ibm.wala.ipa.callgraph.impl.ExplicitCallGraph;
|
||||
import com.ibm.wala.ipa.callgraph.impl.FakeRootMethod;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.SSAPropagationCallGraphBuilder.ConstraintVisitor.InvariantComputer;
|
||||
import com.ibm.wala.ipa.cha.IClassHierarchy;
|
||||
import com.ibm.wala.shrikeBT.ConditionalBranchInstruction;
|
||||
import com.ibm.wala.shrikeBT.IInvokeInstruction;
|
||||
|
@ -703,7 +702,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
InstanceKey[] ik = getInvariantContents(arrayRef);
|
||||
|
||||
for (int i = 0; i < ik.length; i++) {
|
||||
if (!representsNullType(ik[i])) {
|
||||
if (!representsNullType(ik[i]) && !(ik[i] instanceof ZeroLengthArrayInNode)) {
|
||||
system.findOrCreateIndexForInstanceKey(ik[i]);
|
||||
PointerKey p = getPointerKeyForArrayContents(ik[i]);
|
||||
IClass contents = ((ArrayClass) ik[i].getConcreteType()).getElementClass();
|
||||
|
@ -1037,7 +1036,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
|
||||
InstanceKey[][] invariantParameters = invs.computeInvariantParameters(instruction);
|
||||
if (instruction.getCallSite().isStatic()) {
|
||||
for (CGNode n : getBuilder().getTargetsForCall(node, instruction.getCallSite(), invariantParameters)) {
|
||||
for (CGNode n : getBuilder().getTargetsForCall(node, instruction, invariantParameters)) {
|
||||
getBuilder().processResolvedCall(node, instruction, n, invariantParameters, uniqueCatch);
|
||||
if (DEBUG) {
|
||||
System.err.println("visitInvoke class init " + n);
|
||||
|
@ -1064,7 +1063,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
});
|
||||
|
||||
if (contentsAreInvariant(symbolTable, du, vns)) {
|
||||
for(CGNode n : getBuilder().getTargetsForCall(node, instruction.getCallSite(), invariantParameters)) {
|
||||
for(CGNode n : getBuilder().getTargetsForCall(node, instruction, invariantParameters)) {
|
||||
getBuilder().processResolvedCall(node, instruction, n, invariantParameters, uniqueCatch);
|
||||
// side effect of invoke: may call class initializer
|
||||
processClassInitializer(n.getMethod().getDeclaringClass());
|
||||
|
@ -1770,56 +1769,62 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
}
|
||||
}
|
||||
|
||||
protected void iterateCrossProduct(final CGNode caller, final CallSiteReference site, IntSet parameters, final InstanceKey[][] invariants, final VoidFunction<InstanceKey[]> f) {
|
||||
final IR ir = caller.getIR();
|
||||
protected void iterateCrossProduct(final CGNode caller, final SSAAbstractInvokeInstruction call, IntSet parameters,
|
||||
final InstanceKey[][] invariants, final VoidFunction<InstanceKey[]> f) {
|
||||
final int params[] = IntSetUtil.toArray(parameters);
|
||||
for (final SSAAbstractInvokeInstruction call : ir.getCalls(site)) {
|
||||
final InstanceKey[] keys = new InstanceKey[call.getNumberOfParameters()];
|
||||
new Object() {
|
||||
private void rec(final int pi) {
|
||||
if (pi == params.length) {
|
||||
f.apply(keys);
|
||||
} else {
|
||||
final int p = params[pi];
|
||||
int vn = call.getUse(p);
|
||||
PointerKey var = getPointerKeyForLocal(caller, vn);
|
||||
InstanceKey[] ik = invariants!=null? invariants[p]: null;
|
||||
if (ik != null) {
|
||||
if (ik.length > 0) {
|
||||
for (int i = 0; i < ik.length; i++) {
|
||||
system.findOrCreateIndexForInstanceKey(ik[i]);
|
||||
keys[p] = ik[i];
|
||||
rec(pi+1);
|
||||
}
|
||||
} else {
|
||||
if (!site.isDispatch() || p != 0) {
|
||||
keys[p] = null;
|
||||
rec(pi+1);
|
||||
}
|
||||
}
|
||||
final InstanceKey[] keys = new InstanceKey[call.getNumberOfParameters()];
|
||||
final CallSiteReference site = call.getCallSite();
|
||||
new Object() {
|
||||
private void rec(final int pi) {
|
||||
if (pi == params.length) {
|
||||
f.apply(keys);
|
||||
} else {
|
||||
final int p = params[pi];
|
||||
int vn = call.getUse(p);
|
||||
PointerKey var = getPointerKeyForLocal(caller, vn);
|
||||
InstanceKey[] ik = invariants != null ? invariants[p] : null;
|
||||
if (ik != null) {
|
||||
if (ik.length > 0) {
|
||||
for (int i = 0; i < ik.length; i++) {
|
||||
system.findOrCreateIndexForInstanceKey(ik[i]);
|
||||
keys[p] = ik[i];
|
||||
rec(pi + 1);
|
||||
}
|
||||
} else {
|
||||
IntSet s = system.findOrCreatePointsToSet(var).getValue();
|
||||
if (s != null && !s.isEmpty()) {
|
||||
s.foreach(new IntSetAction() {
|
||||
public void act(int x) {
|
||||
keys[p] = system.getInstanceKey(x);
|
||||
rec(pi+1);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (!site.isDispatch() || p != 0) {
|
||||
keys[p] = null;
|
||||
rec(pi+1);
|
||||
if (!site.isDispatch() || p != 0) {
|
||||
keys[p] = null;
|
||||
rec(pi + 1);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IntSet s = system.findOrCreatePointsToSet(var).getValue();
|
||||
if (s != null && !s.isEmpty()) {
|
||||
s.foreach(new IntSetAction() {
|
||||
public void act(int x) {
|
||||
keys[p] = system.getInstanceKey(x);
|
||||
rec(pi + 1);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (!site.isDispatch() || p != 0) {
|
||||
keys[p] = null;
|
||||
rec(pi + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.rec(0);
|
||||
}
|
||||
}
|
||||
}.rec(0);
|
||||
}
|
||||
|
||||
protected Set<CGNode> getTargetsForCall(final CGNode caller, final CallSiteReference site, InstanceKey[][] invs) {
|
||||
protected Set<CGNode> getTargetsForCall(final CGNode caller, final SSAAbstractInvokeInstruction instruction, InstanceKey[][] invs) {
|
||||
// This method used to take a CallSiteReference as a parameter, rather than
|
||||
// an SSAAbstractInvokeInstruction. This was bad, since it's
|
||||
// possible for multiple invoke instructions with different actual
|
||||
// parameters to be associated with a single CallSiteReference. Changed
|
||||
// to take the invoke instruction as a parameter instead, since invs is
|
||||
// associated with the instruction
|
||||
final CallSiteReference site = instruction.getCallSite();
|
||||
IntSet params = contextSelector.getRelevantParameters(caller, site);
|
||||
if (!site.isStatic() && !params.contains(0)) {
|
||||
params = IntSetUtil.makeMutableCopy(params);
|
||||
|
@ -1838,7 +1843,7 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
|||
}
|
||||
}
|
||||
};
|
||||
iterateCrossProduct(caller, site, params, invs, f);
|
||||
iterateCrossProduct(caller, instruction, params, invs, f);
|
||||
return targets;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.ipa.callgraph.propagation;
|
||||
|
||||
import com.ibm.wala.classLoader.IClass;
|
||||
import com.ibm.wala.classLoader.NewSiteReference;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
|
||||
/**
|
||||
* Represents an array with length zero. Useful for precision since such arrays
|
||||
* cannot have contents.
|
||||
*/
|
||||
public final class ZeroLengthArrayInNode extends AllocationSiteInNode {
|
||||
|
||||
public ZeroLengthArrayInNode(CGNode node, NewSiteReference allocation, IClass type) {
|
||||
super(node, allocation, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
// instanceof is OK because this class is final
|
||||
if (obj instanceof ZeroLengthArrayInNode) {
|
||||
AllocationSiteInNode other = (AllocationSiteInNode) obj;
|
||||
return getNode().equals(other.getNode()) && getSite().equals(other.getSite());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getNode().hashCode() * 8647 + getSite().hashCode();
|
||||
}
|
||||
|
||||
}
|
|
@ -42,7 +42,7 @@ public class CallString implements ContextItem {
|
|||
public String toString() {
|
||||
StringBuffer str = new StringBuffer("[");
|
||||
for (int i = 0; i < sites.length; i++) {
|
||||
str.append(" ").append(methods[i].getName()).append("@").append(sites[i].getProgramCounter());
|
||||
str.append(" ").append(methods[i].getSignature()).append("@").append(sites[i].getProgramCounter());
|
||||
}
|
||||
str.append(" ]");
|
||||
return str.toString();
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.ibm.wala.ipa.callgraph.ContextKey;
|
|||
import com.ibm.wala.ipa.callgraph.ContextSelector;
|
||||
import com.ibm.wala.ipa.callgraph.impl.Everywhere;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
|
||||
import com.ibm.wala.ipa.callgraph.propagation.ReceiverInstanceContext;
|
||||
import com.ibm.wala.util.intset.EmptyIntSet;
|
||||
import com.ibm.wala.util.intset.IntSet;
|
||||
|
||||
|
@ -31,7 +32,7 @@ public abstract class CallStringContextSelector implements ContextSelector {
|
|||
}
|
||||
};
|
||||
|
||||
private static class CallStringContextPair implements Context {
|
||||
public static class CallStringContextPair implements Context {
|
||||
private final CallString cs;
|
||||
|
||||
private final Context base;
|
||||
|
@ -64,6 +65,14 @@ public abstract class CallStringContextSelector implements ContextSelector {
|
|||
return base.get(name);
|
||||
}
|
||||
}
|
||||
|
||||
public Context getBaseContext() {
|
||||
return base;
|
||||
}
|
||||
|
||||
public CallString getCallString() {
|
||||
return cs;
|
||||
}
|
||||
};
|
||||
|
||||
private final ContextSelector base;
|
||||
|
@ -103,7 +112,7 @@ public abstract class CallStringContextSelector implements ContextSelector {
|
|||
}
|
||||
|
||||
public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) {
|
||||
return EmptyIntSet.instance;
|
||||
return base.getRelevantParameters(caller, site);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
#Thu Feb 03 10:35:13 EST 2011
|
||||
#Tue Jun 05 11:13:30 EDT 2012
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.6
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||
|
@ -17,7 +9,6 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
|||
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||
|
@ -74,7 +65,6 @@ org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disa
|
|||
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.6
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
|
||||
|
|
|
@ -8,6 +8,14 @@ import com.ibm.wala.util.collections.FilterIterator;
|
|||
import com.ibm.wala.util.collections.Pair;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
|
||||
/**
|
||||
* Extends {@link DFSPathFinder} to discover all paths from a set of root nodes
|
||||
* to nodes passing some {@link Filter}.
|
||||
*
|
||||
* Note that this code performs work that is potentially exponential in the size
|
||||
* of the underlying graph, using exponential space. It most likely won't work
|
||||
* even for graphs of moderate size.
|
||||
*/
|
||||
public class DFSAllPathsFinder<T> extends DFSPathFinder<T> {
|
||||
|
||||
public DFSAllPathsFinder(Graph<T> G, Iterator<T> nodes, Filter<T> f) {
|
||||
|
@ -18,6 +26,7 @@ public class DFSAllPathsFinder<T> extends DFSPathFinder<T> {
|
|||
super(G, N, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterator<? extends T> getConnected(T n) {
|
||||
final List<T> cp = currentPath();
|
||||
return new FilterIterator<T>(G.getSuccNodes(n), new Filter<T>() {
|
||||
|
|
Loading…
Reference in New Issue