Program: 100374
Project: 100374
Buggy source:
/** 
 * For a statement s, compute the set of statements that may def the heap value read by s.
 */
private OrdinalSet<Statement> computeResult(Statement s,Map<PointerKey,MutableIntSet> pointerKeyMod,BitVectorSolver<IBasicBlock> solver,OrdinalSetMapping<Statement> domain,CGNode node,ExtendedHeapModel h,PointerAnalysis pa,Map<CGNode,OrdinalSet<PointerKey>> mod,ExpandedControlFlowGraph cfg,Map<SSAInstruction,NormalStatement> ssaInstruction2Statement){
switch (s.getKind()) {
case NORMAL:
    NormalStatement n=(NormalStatement)s;
  Collection<PointerKey> ref=ModRef.getRef(node,h,pa,n.getInstruction(),exclusions);
if (!ref.isEmpty()) {
  IBasicBlock bb=cfg.getBlockForInstruction(n.getInstructionIndex());
  BitVectorVariable v=(BitVectorVariable)solver.getIn(bb);
  MutableSparseIntSet defs=new MutableSparseIntSet();
  for (  PointerKey p : ref) {
    if (pointerKeyMod.get(p) != null) {
      defs.addAll(pointerKeyMod.get(p).intersection(v.getValue()));
    }
  }
  return new OrdinalSet<Statement>(defs,domain);
}
 else {
  return OrdinalSet.empty();
}
case HEAP_RET_CALLEE:
{
HeapStatement.ReturnCallee r=(HeapStatement.ReturnCallee)s;
PointerKey p=r.getLocation();
BitVectorVariable v=(BitVectorVariable)solver.getIn(cfg.exit());
if (pointerKeyMod.get(p) == null) {
  return OrdinalSet.empty();
}
return new OrdinalSet<Statement>(pointerKeyMod.get(p).intersection(v.getValue()),domain);
}
case HEAP_RET_CALLER:
{
HeapStatement.ReturnCaller r=(HeapStatement.ReturnCaller)s;
IBasicBlock bb=cfg.getBlockForInstruction(r.getCall());
BitVectorVariable v=(BitVectorVariable)solver.getIn(bb);
if (allCalleesMod(r,mod) || pointerKeyMod.get(r.getLocation()) == null || v.getValue() == null) {
return OrdinalSet.empty();
}
 else {
return new OrdinalSet<Statement>(pointerKeyMod.get(r.getLocation()).intersection(v.getValue()),domain);
}
}
case HEAP_PARAM_CALLER:
{
HeapStatement.ParamCaller r=(HeapStatement.ParamCaller)s;
NormalStatement call=ssaInstruction2Statement.get(r.getCall());
IBasicBlock callBlock=cfg.getBlockForInstruction(call.getInstructionIndex());
BitVectorVariable v=(BitVectorVariable)solver.getIn(callBlock);
if (pointerKeyMod.get(r.getLocation()) == null || v.getValue() == null) {
return OrdinalSet.empty();
}
 else {
return new OrdinalSet<Statement>(pointerKeyMod.get(r.getLocation()).intersection(v.getValue()),domain);
}
}
case NORMAL_RET_CALLEE:
case NORMAL_RET_CALLER:
case PARAM_CALLEE:
case PARAM_CALLER:
case EXC_RET_CALLEE:
case EXC_RET_CALLER:
case PHI:
case PI:
case CATCH:
case METHOD_ENTRY:
return OrdinalSet.empty();
case HEAP_PARAM_CALLEE:
return OrdinalSet.empty();
default :
Assertions.UNREACHABLE(s.getKind().toString());
return null;
}
}

Fixed version (ground truth):
/** 
 * For a statement s, compute the set of statements that may def the heap value read by s.
 */
private OrdinalSet<Statement> computeResult(Statement s,Map<PointerKey,MutableIntSet> pointerKeyMod,BitVectorSolver<IBasicBlock> solver,OrdinalSetMapping<Statement> domain,CGNode node,ExtendedHeapModel h,PointerAnalysis pa,Map<CGNode,OrdinalSet<PointerKey>> mod,ExpandedControlFlowGraph cfg,Map<Integer,NormalStatement> ssaInstructionIndex2Statement){
switch (s.getKind()) {
case NORMAL:
    NormalStatement n=(NormalStatement)s;
  Collection<PointerKey> ref=ModRef.getRef(node,h,pa,n.getInstruction(),exclusions);
if (!ref.isEmpty()) {
  IBasicBlock bb=cfg.getBlockForInstruction(n.getInstructionIndex());
  BitVectorVariable v=(BitVectorVariable)solver.getIn(bb);
  MutableSparseIntSet defs=new MutableSparseIntSet();
  for (  PointerKey p : ref) {
    if (pointerKeyMod.get(p) != null) {
      defs.addAll(pointerKeyMod.get(p).intersection(v.getValue()));
    }
  }
  return new OrdinalSet<Statement>(defs,domain);
}
 else {
  return OrdinalSet.empty();
}
case HEAP_RET_CALLEE:
{
HeapStatement.ReturnCallee r=(HeapStatement.ReturnCallee)s;
PointerKey p=r.getLocation();
BitVectorVariable v=(BitVectorVariable)solver.getIn(cfg.exit());
if (pointerKeyMod.get(p) == null) {
  return OrdinalSet.empty();
}
return new OrdinalSet<Statement>(pointerKeyMod.get(p).intersection(v.getValue()),domain);
}
case HEAP_RET_CALLER:
{
HeapStatement.ReturnCaller r=(HeapStatement.ReturnCaller)s;
IBasicBlock bb=cfg.getBlockForInstruction(r.getCall());
BitVectorVariable v=(BitVectorVariable)solver.getIn(bb);
if (allCalleesMod(r,mod) || pointerKeyMod.get(r.getLocation()) == null || v.getValue() == null) {
return OrdinalSet.empty();
}
 else {
return new OrdinalSet<Statement>(pointerKeyMod.get(r.getLocation()).intersection(v.getValue()),domain);
}
}
case HEAP_PARAM_CALLER:
{
HeapStatement.ParamCaller r=(HeapStatement.ParamCaller)s;
NormalStatement call=ssaInstructionIndex2Statement.get(r.getCallIndex());
IBasicBlock callBlock=cfg.getBlockForInstruction(call.getInstructionIndex());
BitVectorVariable v=(BitVectorVariable)solver.getIn(callBlock);
if (pointerKeyMod.get(r.getLocation()) == null || v.getValue() == null) {
return OrdinalSet.empty();
}
 else {
return new OrdinalSet<Statement>(pointerKeyMod.get(r.getLocation()).intersection(v.getValue()),domain);
}
}
case NORMAL_RET_CALLEE:
case NORMAL_RET_CALLER:
case PARAM_CALLEE:
case PARAM_CALLER:
case EXC_RET_CALLEE:
case EXC_RET_CALLER:
case PHI:
case PI:
case CATCH:
case METHOD_ENTRY:
return OrdinalSet.empty();
case HEAP_PARAM_CALLEE:
return OrdinalSet.empty();
default :
Assertions.UNREACHABLE(s.getKind().toString());
return null;
}
}