Program: 100560
Project: 100560
Buggy source:
/** 
 * Create all data dependence edges in this PDG. Scalar dependences are taken from SSA def-use information. Heap dependences are computed by a reaching defs analysis.
 * @param pa
 * @param mod
 */
private void createScalarDataDependenceEdges(DataDependenceOptions dOptions){
  if (dOptions.equals(DataDependenceOptions.NONE)) {
    return;
  }
  IR ir=node.getIR(new WarningSet());
  if (ir == null) {
    return;
  }
  DefUse DU=node.getCallGraph().getInterpreter(node).getDU(node,new WarningSet());
  SSAInstruction[] instructions=ir.getInstructions();
  for (Iterator<? extends Statement> it=iterateNodes(); it.hasNext(); ) {
    Statement s=it.next();
switch (s.getKind()) {
case NORMAL:
case CATCH:
case PI:
case PHI:
{
        SSAInstruction statement=statement2SSAInstruction(instructions,s);
        if (!(statement instanceof SSAInvokeInstruction)) {
          if (dOptions.isTerminateAtCast() && (statement instanceof SSACheckCastInstruction)) {
            break;
          }
          if (dOptions.isTerminateAtCast() && (statement instanceof SSAInstanceofInstruction)) {
            break;
          }
          for (int i=0; i < statement.getNumberOfDefs(); i++) {
            int def=statement.getDef(i);
            for (Iterator<SSAInstruction> it2=DU.getUses(def); it2.hasNext(); ) {
              SSAInstruction use=it2.next();
              if (dOptions.isIgnoreBasePtrs()) {
                if (use instanceof SSANewInstruction) {
                  continue;
                }
                if (hasBasePointer(use)) {
                  int base=getBasePointer(use);
                  if (def == base) {
                    continue;
                  }
                  if (use instanceof SSAArrayReferenceInstruction) {
                    SSAArrayReferenceInstruction arr=(SSAArrayReferenceInstruction)use;
                    if (def == arr.getIndex()) {
                      continue;
                    }
                  }
                }
              }
              Statement u=ssaInstruction2Statement(use);
              addEdge(s,u);
            }
          }
        }
        break;
      }
case EXC_RET_CALLER:
case NORMAL_RET_CALLER:
case PARAM_CALLEE:
{
      if (Assertions.verifyAssertions && dOptions.isIgnoreExceptions()) {
        Assertions._assert(!s.getKind().equals(Kind.EXC_RET_CALLER));
      }
      ValueNumberCarrier a=(ValueNumberCarrier)s;
      for (Iterator<SSAInstruction> it2=DU.getUses(a.getValueNumber()); it2.hasNext(); ) {
        SSAInstruction use=it2.next();
        if (dOptions.isIgnoreBasePtrs()) {
          if (use instanceof SSANewInstruction) {
            continue;
          }
          if (hasBasePointer(use)) {
            int base=getBasePointer(use);
            if (a.getValueNumber() == base) {
              continue;
            }
            if (use instanceof SSAArrayReferenceInstruction) {
              SSAArrayReferenceInstruction arr=(SSAArrayReferenceInstruction)use;
              if (a.getValueNumber() == arr.getIndex()) {
                continue;
              }
            }
          }
        }
        Statement u=ssaInstruction2Statement(use);
        addEdge(s,u);
      }
      break;
    }
case NORMAL_RET_CALLEE:
  for (  NormalStatement ret : computeReturnStatements(ir)) {
    addEdge(ret,s);
  }
break;
case EXC_RET_CALLEE:
if (Assertions.verifyAssertions && dOptions.isIgnoreExceptions()) {
Assertions.UNREACHABLE();
}
for (NormalStatement pei : getPEIs(ir)) {
if (dOptions.isTerminateAtCast() && (pei.getInstruction() instanceof SSACheckCastInstruction)) {
continue;
}
if (pei.getInstruction() instanceof SSAInvokeInstruction) {
SSAInvokeInstruction call=(SSAInvokeInstruction)pei.getInstruction();
Statement st=new ParamStatement.ExceptionalReturnCaller(node,call);
addEdge(st,s);
}
 else {
addEdge(pei,s);
}
}
break;
case PARAM_CALLER:
{
ParamStatement.ParamCaller pac=(ParamStatement.ParamCaller)s;
int vn=pac.getValueNumber();
if (ir.getSymbolTable().isParameter(vn)) {
Statement a=new ParamStatement.ParamCallee(node,vn);
addEdge(a,pac);
}
 else {
SSAInstruction d=DU.getDef(vn);
if (dOptions.isTerminateAtCast() && (d instanceof SSACheckCastInstruction)) {
break;
}
if (d != null) {
if (d instanceof SSAInvokeInstruction) {
SSAInvokeInstruction call=(SSAInvokeInstruction)d;
if (vn == call.getException()) {
  Statement st=new ParamStatement.ExceptionalReturnCaller(node,call);
  addEdge(st,pac);
}
 else {
  Statement st=new ParamStatement.NormalReturnCaller(node,call);
  addEdge(st,pac);
}
}
 else {
Statement ds=ssaInstruction2Statement(d);
addEdge(ds,pac);
}
}
}
}
break;
case HEAP_RET_CALLEE:
case HEAP_RET_CALLER:
case HEAP_PARAM_CALLER:
case HEAP_PARAM_CALLEE:
case METHOD_ENTRY:
break;
default :
Assertions.UNREACHABLE(s.toString());
break;
}
}
}

Fixed version (ground truth):
/** 
 * Create all data dependence edges in this PDG. Scalar dependences are taken from SSA def-use information. Heap dependences are computed by a reaching defs analysis.
 * @param pa
 * @param mod
 */
private void createScalarDataDependenceEdges(DataDependenceOptions dOptions){
  if (dOptions.equals(DataDependenceOptions.NONE)) {
    return;
  }
  IR ir=node.getIR(new WarningSet());
  if (ir == null) {
    return;
  }
  DefUse DU=node.getCallGraph().getInterpreter(node).getDU(node,new WarningSet());
  SSAInstruction[] instructions=ir.getInstructions();
  for (Iterator<? extends Statement> it=iterateNodes(); it.hasNext(); ) {
    Statement s=it.next();
switch (s.getKind()) {
case NORMAL:
case CATCH:
case PI:
case PHI:
{
        SSAInstruction statement=statement2SSAInstruction(instructions,s);
        if (!(statement instanceof SSAInvokeInstruction)) {
          if (dOptions.isTerminateAtCast() && (statement instanceof SSACheckCastInstruction)) {
            break;
          }
          if (dOptions.isTerminateAtCast() && (statement instanceof SSAInstanceofInstruction)) {
            break;
          }
          for (int i=0; i < statement.getNumberOfDefs(); i++) {
            int def=statement.getDef(i);
            for (Iterator<SSAInstruction> it2=DU.getUses(def); it2.hasNext(); ) {
              SSAInstruction use=it2.next();
              if (dOptions.isIgnoreBasePtrs()) {
                if (use instanceof SSANewInstruction) {
                  continue;
                }
                if (hasBasePointer(use)) {
                  int base=getBasePointer(use);
                  if (def == base) {
                    continue;
                  }
                  if (use instanceof SSAArrayReferenceInstruction) {
                    SSAArrayReferenceInstruction arr=(SSAArrayReferenceInstruction)use;
                    if (def == arr.getIndex()) {
                      continue;
                    }
                  }
                }
              }
              Statement u=ssaInstruction2Statement(use);
              addEdge(s,u);
            }
          }
        }
        break;
      }
case EXC_RET_CALLER:
case NORMAL_RET_CALLER:
case PARAM_CALLEE:
{
      if (Assertions.verifyAssertions && dOptions.isIgnoreExceptions()) {
        Assertions._assert(!s.getKind().equals(Kind.EXC_RET_CALLER));
      }
      ValueNumberCarrier a=(ValueNumberCarrier)s;
      for (Iterator<SSAInstruction> it2=DU.getUses(a.getValueNumber()); it2.hasNext(); ) {
        SSAInstruction use=it2.next();
        if (dOptions.isIgnoreBasePtrs()) {
          if (use instanceof SSANewInstruction) {
            continue;
          }
          if (hasBasePointer(use)) {
            int base=getBasePointer(use);
            if (a.getValueNumber() == base) {
              continue;
            }
            if (use instanceof SSAArrayReferenceInstruction) {
              SSAArrayReferenceInstruction arr=(SSAArrayReferenceInstruction)use;
              if (a.getValueNumber() == arr.getIndex()) {
                continue;
              }
            }
          }
        }
        Statement u=ssaInstruction2Statement(use);
        addEdge(s,u);
      }
      break;
    }
case NORMAL_RET_CALLEE:
  for (  NormalStatement ret : computeReturnStatements(ir)) {
    addEdge(ret,s);
  }
break;
case EXC_RET_CALLEE:
if (Assertions.verifyAssertions && dOptions.isIgnoreExceptions()) {
Assertions.UNREACHABLE();
}
for (NormalStatement pei : getPEIs(ir)) {
if (dOptions.isTerminateAtCast() && (pei.getInstruction() instanceof SSACheckCastInstruction)) {
continue;
}
if (pei.getInstruction() instanceof SSAInvokeInstruction) {
SSAInvokeInstruction call=(SSAInvokeInstruction)pei.getInstruction();
Statement st=new ParamStatement.ExceptionalReturnCaller(node,call);
addEdge(st,s);
}
 else {
addEdge(pei,s);
}
}
break;
case PARAM_CALLER:
{
ParamStatement.ParamCaller pac=(ParamStatement.ParamCaller)s;
int vn=pac.getValueNumber();
if (vn > -1) {
if (ir.getSymbolTable().isParameter(vn)) {
Statement a=new ParamStatement.ParamCallee(node,vn);
addEdge(a,pac);
}
 else {
SSAInstruction d=DU.getDef(vn);
if (dOptions.isTerminateAtCast() && (d instanceof SSACheckCastInstruction)) {
break;
}
if (d != null) {
if (d instanceof SSAInvokeInstruction) {
  SSAInvokeInstruction call=(SSAInvokeInstruction)d;
  if (vn == call.getException()) {
    Statement st=new ParamStatement.ExceptionalReturnCaller(node,call);
    addEdge(st,pac);
  }
 else {
    Statement st=new ParamStatement.NormalReturnCaller(node,call);
    addEdge(st,pac);
  }
}
 else {
  Statement ds=ssaInstruction2Statement(d);
  addEdge(ds,pac);
}
}
}
}
}
break;
case HEAP_RET_CALLEE:
case HEAP_RET_CALLER:
case HEAP_PARAM_CALLER:
case HEAP_PARAM_CALLEE:
case METHOD_ENTRY:
break;
default :
Assertions.UNREACHABLE(s.toString());
break;
}
}
}