Program: 12166
Project: 12166
Buggy source:
public PDGSlice(PDG pdg,BasicBlock boundaryBlock,PDGNode nodeCriterion,VariableDeclaration localVariableCriterion){
  super();
  this.method=pdg.getMethod();
  this.boundaryBlock=boundaryBlock;
  this.nodeCriterion=nodeCriterion;
  this.localVariableCriterion=localVariableCriterion;
  Set<PDGNode> regionNodes=pdg.blockBasedRegion(boundaryBlock);
  for (  PDGNode node : regionNodes) {
    nodes.add(node);
  }
  for (  GraphEdge edge : pdg.edges) {
    PDGDependence dependence=(PDGDependence)edge;
    if (nodes.contains(dependence.src) && nodes.contains(dependence.dst))     edges.add(dependence);
  }
  this.sliceNodes=new TreeSet<PDGNode>();
  sliceNodes.addAll(computeSlice(nodeCriterion,localVariableCriterion));
  this.remainingNodes=new TreeSet<PDGNode>();
  remainingNodes.add(pdg.getEntryNode());
  for (  GraphNode node : pdg.nodes) {
    PDGNode pdgNode=(PDGNode)node;
    if (!sliceNodes.contains(pdgNode))     remainingNodes.add(pdgNode);
  }
  this.passedParameters=new LinkedHashSet<VariableDeclaration>();
  Set<PDGNode> nCD=new LinkedHashSet<PDGNode>();
  Set<PDGNode> nDD=new LinkedHashSet<PDGNode>();
  for (  GraphEdge edge : pdg.edges) {
    PDGDependence dependence=(PDGDependence)edge;
    PDGNode srcPDGNode=(PDGNode)dependence.src;
    PDGNode dstPDGNode=(PDGNode)dependence.dst;
    if (dependence instanceof PDGDataDependence) {
      PDGDataDependence dataDependence=(PDGDataDependence)dependence;
      if (remainingNodes.contains(srcPDGNode) && sliceNodes.contains(dstPDGNode))       passedParameters.add(dataDependence.getData());
      if (sliceNodes.contains(srcPDGNode) && remainingNodes.contains(dstPDGNode) && !dataDependence.getData().equals(localVariableCriterion))       nDD.add(dstPDGNode);
    }
 else     if (dependence instanceof PDGControlDependence) {
      if (sliceNodes.contains(srcPDGNode) && remainingNodes.contains(dstPDGNode))       nCD.add(dstPDGNode);
    }
  }
  Set<PDGNode> controlIndispensableNodes=new LinkedHashSet<PDGNode>();
  for (  PDGNode p : nCD) {
    for (    VariableDeclaration usedVariable : p.usedVariables) {
      Set<PDGNode> pSliceNodes=computeSlice(p,usedVariable);
      for (      PDGNode q : pSliceNodes) {
        if (q.equals(p))         controlIndispensableNodes.add(q);
      }
    }
  }
  Set<PDGNode> dataIndispensableNodes=new LinkedHashSet<PDGNode>();
  for (  PDGNode p : nDD) {
    for (    VariableDeclaration definedVariable : p.definedVariables) {
      Set<PDGNode> pSliceNodes=computeSlice(p,definedVariable);
      for (      PDGNode q : pSliceNodes) {
        dataIndispensableNodes.add(q);
      }
    }
  }
  this.indispensableNodes=new LinkedHashSet<PDGNode>();
  indispensableNodes.addAll(controlIndispensableNodes);
  indispensableNodes.addAll(dataIndispensableNodes);
  this.removableNodes=new LinkedHashSet<PDGNode>();
  for (  GraphNode node : pdg.nodes) {
    PDGNode pdgNode=(PDGNode)node;
    if (!remainingNodes.contains(pdgNode) && !indispensableNodes.contains(pdgNode))     removableNodes.add(pdgNode);
  }
}

Fixed version (ground truth):
public PDGSlice(PDG pdg,BasicBlock boundaryBlock,PDGNode nodeCriterion,VariableDeclaration localVariableCriterion){
  super();
  this.method=pdg.getMethod();
  this.boundaryBlock=boundaryBlock;
  this.nodeCriterion=nodeCriterion;
  this.localVariableCriterion=localVariableCriterion;
  Set<PDGNode> regionNodes=pdg.blockBasedRegion(boundaryBlock);
  for (  PDGNode node : regionNodes) {
    nodes.add(node);
  }
  for (  GraphEdge edge : pdg.edges) {
    PDGDependence dependence=(PDGDependence)edge;
    if (nodes.contains(dependence.src) && nodes.contains(dependence.dst))     edges.add(dependence);
  }
  this.sliceNodes=new TreeSet<PDGNode>();
  sliceNodes.addAll(computeSlice(nodeCriterion,localVariableCriterion));
  this.remainingNodes=new TreeSet<PDGNode>();
  remainingNodes.add(pdg.getEntryNode());
  for (  GraphNode node : pdg.nodes) {
    PDGNode pdgNode=(PDGNode)node;
    if (!sliceNodes.contains(pdgNode))     remainingNodes.add(pdgNode);
  }
  this.passedParameters=new LinkedHashSet<VariableDeclaration>();
  Set<PDGNode> nCD=new LinkedHashSet<PDGNode>();
  Set<PDGNode> nDD=new LinkedHashSet<PDGNode>();
  for (  GraphEdge edge : pdg.edges) {
    PDGDependence dependence=(PDGDependence)edge;
    PDGNode srcPDGNode=(PDGNode)dependence.src;
    PDGNode dstPDGNode=(PDGNode)dependence.dst;
    if (dependence instanceof PDGDataDependence) {
      PDGDataDependence dataDependence=(PDGDataDependence)dependence;
      if (remainingNodes.contains(srcPDGNode) && sliceNodes.contains(dstPDGNode))       passedParameters.add(dataDependence.getData());
      if (sliceNodes.contains(srcPDGNode) && remainingNodes.contains(dstPDGNode) && !dataDependence.getData().equals(localVariableCriterion))       nDD.add(dstPDGNode);
    }
 else     if (dependence instanceof PDGControlDependence) {
      if (sliceNodes.contains(srcPDGNode) && remainingNodes.contains(dstPDGNode))       nCD.add(dstPDGNode);
    }
  }
  Set<PDGNode> controlIndispensableNodes=new LinkedHashSet<PDGNode>();
  for (  PDGNode p : nCD) {
    for (    VariableDeclaration usedVariable : p.usedVariables) {
      Set<PDGNode> pSliceNodes=computeSlice(p,usedVariable);
      for (      GraphNode node : pdg.nodes) {
        PDGNode q=(PDGNode)node;
        if (pSliceNodes.contains(q) || q.equals(p))         controlIndispensableNodes.add(q);
      }
    }
  }
  Set<PDGNode> dataIndispensableNodes=new LinkedHashSet<PDGNode>();
  for (  PDGNode p : nDD) {
    for (    VariableDeclaration definedVariable : p.definedVariables) {
      Set<PDGNode> pSliceNodes=computeSlice(p,definedVariable);
      for (      GraphNode node : pdg.nodes) {
        PDGNode q=(PDGNode)node;
        if (pSliceNodes.contains(q))         dataIndispensableNodes.add(q);
      }
    }
  }
  this.indispensableNodes=new TreeSet<PDGNode>();
  indispensableNodes.addAll(controlIndispensableNodes);
  indispensableNodes.addAll(dataIndispensableNodes);
  this.removableNodes=new LinkedHashSet<PDGNode>();
  for (  GraphNode node : pdg.nodes) {
    PDGNode pdgNode=(PDGNode)node;
    if (!remainingNodes.contains(pdgNode) && !indispensableNodes.contains(pdgNode))     removableNodes.add(pdgNode);
  }
}