diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/AllocationSiteInNodeFactory.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/AllocationSiteInNodeFactory.java index ef500218e..08e7b112e 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/AllocationSiteInNodeFactory.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/AllocationSiteInNodeFactory.java @@ -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; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ContainerContextSelector.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ContainerContextSelector.java index c67bbcc78..4b6c929b5 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ContainerContextSelector.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ContainerContextSelector.java @@ -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;