fix a bug with object-sensitivity context selection and recursion
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2939 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
711d039714
commit
47857f7041
|
@ -17,6 +17,7 @@ import com.ibm.wala.classLoader.NewSiteReference;
|
|||
import com.ibm.wala.classLoader.ProgramCounter;
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisOptions;
|
||||
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.types.TypeReference;
|
||||
|
@ -67,16 +68,16 @@ public class AllocationSiteInNodeFactory implements InstanceKeyFactory {
|
|||
}
|
||||
|
||||
// disallow recursion in contexts.
|
||||
if (node.getContext() instanceof ReceiverInstanceContext) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
InstanceKey key = new NormalAllocationInNode(node, allocation, type);
|
||||
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
|
|
@ -200,21 +200,29 @@ public class ContainerContextSelector implements ContextSelector {
|
|||
* If C is a ReceiverInstanceContext, Let N be the node that allocated C.instance. If N.method == M, return N. Else
|
||||
* return findRecursiveMatchingContext(M, N.context) Else return null
|
||||
*/
|
||||
public static CGNode findNodeRecursiveMatchingContext(IMethod M, Context C) {
|
||||
public static CGNode findNodeRecursiveMatchingContext(IMethod m, Context c) {
|
||||
if (DEBUG) {
|
||||
System.err.println("findNodeRecursiveMatchingContext " + M + " in context " + C);
|
||||
System.err.println("findNodeRecursiveMatchingContext " + m + " in context " + c);
|
||||
}
|
||||
if (C instanceof ReceiverInstanceContext) {
|
||||
ReceiverInstanceContext ric = (ReceiverInstanceContext) C;
|
||||
if (c instanceof ReceiverInstanceContext) {
|
||||
ReceiverInstanceContext ric = (ReceiverInstanceContext) c;
|
||||
if (!(ric.getReceiver() instanceof AllocationSiteInNode)) {
|
||||
return null;
|
||||
}
|
||||
AllocationSiteInNode I = (AllocationSiteInNode) ric.getReceiver();
|
||||
CGNode N = I.getNode();
|
||||
if (N.getMethod().equals(M)) {
|
||||
return N;
|
||||
AllocationSiteInNode i = (AllocationSiteInNode) ric.getReceiver();
|
||||
CGNode n = i.getNode();
|
||||
if (n.getMethod().equals(m)) {
|
||||
return n;
|
||||
} else {
|
||||
return findNodeRecursiveMatchingContext(M, N.getContext());
|
||||
return findNodeRecursiveMatchingContext(m, n.getContext());
|
||||
}
|
||||
} else if (c instanceof CallerContext) {
|
||||
CallerContext cc = (CallerContext)c;
|
||||
CGNode n = cc.getCaller();
|
||||
if (n.getMethod().equals(m)) {
|
||||
return n;
|
||||
} else {
|
||||
return findNodeRecursiveMatchingContext(m, n.getContext());
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue