nus-yam/ex-repair huggingface dataset:
Program: 132484
Project: 132484
Buggy source:
public DiskIndex(String path,ByteRangeComparator comp) throws IOException {
  this.comp=comp;
  dbFile=new RandomAccessFile(path,"String_Node_Str");
  dbFile.seek(dbFile.length() - Integer.SIZE / 8);
  blockIndexOffset=dbFile.readInt();
  blockIndexBuf=ByteBuffer.allocate((int)(dbFile.length() - Integer.SIZE / 8 - blockIndexOffset));
  FileChannel channel=dbFile.getChannel();
  channel.position(blockIndexOffset);
  channel.read(blockIndexBuf);
  blockIndex=new BlockReader(blockIndexBuf,0,blockIndexBuf.limit(),comp);
  mappedFile=channel.map(MapMode.READ_ONLY,0,blockIndexOffset);
  assert(channel.size() <= Integer.MAX_VALUE);
}

Fixed version (ground truth):
public DiskIndex(String path,ByteRangeComparator comp) throws IOException {
  this.comp=comp;
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
  dbFile=new RandomAccessFile(path,"String_Node_Str");
  dbFile.seek(dbFile.length() - Integer.SIZE / 8);
  blockIndexOffset=dbFile.readInt();
  blockIndexBuf=ByteBuffer.allocate((int)(dbFile.length() - Integer.SIZE / 8 - blockIndexOffset));
  FileChannel channel=dbFile.getChannel();
  channel.position(blockIndexOffset);
  channel.read(blockIndexBuf);
  blockIndex=new BlockReader(blockIndexBuf,0,blockIndexBuf.limit(),comp);
  mappedFile=channel.map(MapMode.READ_ONLY,0,blockIndexOffset);
  assert(channel.size() <= Integer.MAX_VALUE);
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + channel.size());
  Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + blockIndexOffset);
}
Program: 132486
Project: 132486
Buggy source:
public MiniPage(int numEntries,ByteBuffer buf,int offset,ByteRangeComparator comp){
  this.numEntries=numEntries;
  this.buf=buf;
  this.offset=offset;
  this.comp=comp;
}

Fixed version (ground truth):
public MiniPage(int numEntries,ByteBuffer buf,int offset,ByteRangeComparator comp){
}
Program: 132487
Project: 132487
Buggy source:
public static int getExclBottomOffset(MiniPage page,byte[] entry,ByteRangeComparator comp){
  int low=0;
  int high=page.getNumEntries() - 1;
  int mid=high;
  int cmp=0;
  while (low <= high) {
    mid=(low + high) >>> 1;
    ByteRange currKey=page.getEntry(mid);
    cmp=comp.compare(currKey,entry);
    if (cmp < 0)     low=mid + 1;
 else     if (cmp > 0)     high=mid - 1;
 else     return mid - 1;
  }
  return cmp > 0 ? mid - 1 : mid;
}

Fixed version (ground truth):
public static int getExclBottomOffset(MiniPage page,byte[] entry,ByteRangeComparator comp){
}
Program: 132488
Project: 132488
Buggy source:
public static int getInclBottomOffset(MiniPage page,byte[] entry,ByteRangeComparator comp){
  int low=0;
  int high=page.getNumEntries() - 1;
  int mid=high;
  int cmp=0;
  while (low <= high) {
    mid=(low + high) >>> 1;
    ByteRange currKey=page.getEntry(mid);
    cmp=comp.compare(currKey,entry);
    if (cmp < 0)     low=mid + 1;
 else     if (cmp > 0)     high=mid - 1;
 else     return mid;
  }
  return cmp > 0 ? mid - 1 : mid;
}

Fixed version (ground truth):
public static int getInclBottomOffset(MiniPage page,byte[] entry,ByteRangeComparator comp){
}
Program: 132489
Project: 132489
Buggy source:
public static int getOffset(MiniPage page,byte[] entry,ByteRangeComparator comp){
  int low=0;
  int high=page.getNumEntries() - 1;
  int mid=high;
  int cmp=0;
  while (low <= high) {
    mid=(low + high) >>> 1;
    ByteRange currKey=page.getEntry(mid);
    cmp=comp.compare(currKey,entry);
    if (cmp < 0)     low=mid + 1;
 else     if (cmp > 0)     high=mid - 1;
 else     return mid;
  }
  return -1;
}

Fixed version (ground truth):
public static int getOffset(MiniPage page,byte[] entry,ByteRangeComparator comp){
}
Program: 132490
Project: 132490
Buggy source:
public static int getInclTopOffset(MiniPage page,byte[] entry,ByteRangeComparator comp){
  int low=0;
  int high=page.getNumEntries() - 1;
  int mid=high;
  int cmp=0;
  while (low <= high) {
    mid=(low + high) >>> 1;
    ByteRange currKey=page.getEntry(mid);
    cmp=comp.compare(currKey,entry);
    if (cmp < 0)     low=mid + 1;
 else     if (cmp > 0)     high=mid - 1;
 else     return mid;
  }
  return cmp > 0 ? mid : mid + 1;
}

Fixed version (ground truth):
public static int getInclTopOffset(MiniPage page,byte[] entry,ByteRangeComparator comp){
}
Program: 132491
Project: 132491
Buggy source:
/** 
 * Links the indices to the latest on-disk snapshot, cleans up any  unnecessary in-memory and on-disk data
 * @param viewId the viewId of the snapshot
 * @param sequenceNo the sequenceNo of the snaphot
 * @throws java.io.IOException if snapshots cannot be cleaned up
 */
public void cleanupSnapshot(final int viewId,final long sequenceNo) throws IOException {
  for (int index=0; index < trees.size(); index++) {
    final LSMTree tree=trees.get(index);
    if (Logging.isDebug())     Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + databaseDir + getSnaphotFilename(index,viewId,sequenceNo));
    tree.linkToSnapshot(databaseDir + getSnaphotFilename(index,viewId,sequenceNo));
    ondiskLSN=new LSN(viewId,sequenceNo);
    File f=new File(databaseDir);
    String[] files=f.list();
    Pattern p=Pattern.compile(SNAPSHOT_FILENAME_REGEXP);
    for (    String fname : files) {
      Matcher m=p.matcher(fname);
      if (m.matches()) {
        int fView=Integer.valueOf(m.group(2));
        int fSeq=Integer.valueOf(m.group(3));
        if ((fView < viewId) || ((fView == viewId) && (fSeq < sequenceNo))) {
          File snap=new File(databaseDir + fname);
          snap.delete();
        }
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Links the indices to the latest on-disk snapshot, cleans up any  unnecessary in-memory and on-disk data
 * @param viewId the viewId of the snapshot
 * @param sequenceNo the sequenceNo of the snaphot
 * @throws java.io.IOException if snapshots cannot be cleaned up
 */
public void cleanupSnapshot(final int viewId,final long sequenceNo) throws IOException {
  for (int index=0; index < trees.size(); index++) {
    final LSMTree tree=trees.get(index);
    Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str" + databaseDir + getSnaphotFilename(index,viewId,sequenceNo)+ "String_Node_Str"+ databaseName+ "String_Node_Str"+ index);
    tree.linkToSnapshot(databaseDir + getSnaphotFilename(index,viewId,sequenceNo));
    Logging.logMessage(Logging.LEVEL_INFO,this,"String_Node_Str");
    ondiskLSN=new LSN(viewId,sequenceNo);
    File f=new File(databaseDir);
    String[] files=f.list();
    Pattern p=Pattern.compile(SNAPSHOT_FILENAME_REGEXP);
    for (    String fname : files) {
      Matcher m=p.matcher(fname);
      if (m.matches()) {
        int fView=Integer.valueOf(m.group(2));
        int fSeq=Integer.valueOf(m.group(3));
        if ((fView < viewId) || ((fView == viewId) && (fSeq < sequenceNo))) {
          File snap=new File(databaseDir + fname);
          snap.delete();
        }
      }
    }
  }
}
Program: 132492
Project: 132492
Buggy source:
public void setUp() throws Exception {
}

Fixed version (ground truth):
public void setUp() throws Exception {
  Logging.start(Logging.LEVEL_ERROR);
}
Program: 132493
Project: 132493
Buggy source:
private void getNextBlockData(){
  if (currentBlockIndex > blockIndexEnd) {
    currentBlock=null;
    currentBlockIterator=null;
    return;
  }
  int startOffset=getBlockOffset(currentBlockIndex,itBlockIndex);
  int endOffset=currentBlockIndex == itBlockIndex.getNumEntries() - 1 ? blockIndexOffset : getBlockOffset(currentBlockIndex + 1,itBlockIndex);
  currentBlock=getBlock(startOffset,endOffset,map);
  currentBlockIterator=currentBlock == null ? null : currentBlock.rangeLookup(from == null ? null : from,to == null ? null : to);
}

Fixed version (ground truth):
private void getNextBlockData(){
  if (blockIndexStart == -1 && blockIndexEnd == -1)   return;
  if (currentBlockIndex > blockIndexEnd) {
    currentBlock=null;
    currentBlockIterator=null;
    return;
  }
  int startOffset=getBlockOffset(currentBlockIndex,itBlockIndex);
  int endOffset=currentBlockIndex == itBlockIndex.getNumEntries() - 1 ? blockIndexOffset : getBlockOffset(currentBlockIndex + 1,itBlockIndex);
  currentBlock=getBlock(startOffset,endOffset,map);
  currentBlockIterator=currentBlock == null ? null : currentBlock.rangeLookup(from == null ? null : from,to == null ? null : to);
}
Program: 132495
Project: 132495
Buggy source:
/** 
 * Performs a prefix lookup in a given snapshot. Key-value paris are returned in an iterator in ascending key order, where only such keys are returned with a matching prefix according to the comparator.
 * @param prefix the prefix
 * @return an iterator with key-value pairs
 */
public Iterator<Entry<byte[],byte[]>> prefixLookup(byte[] prefix,int snapId){
  if (prefix != null && prefix.length == 0)   prefix=null;
  List<Iterator<Entry<byte[],byte[]>>> list=new ArrayList<Iterator<Entry<byte[],byte[]>>>(2);
  list.add(overlay.prefixLookup(prefix,snapId,true));
  if (index != null) {
    byte[][] rng=comp.prefixToRange(prefix);
    list.add(index.rangeLookup(rng[0],rng[1]));
  }
  return new OverlayMergeIterator<byte[],byte[]>(list,comp,null);
}

Fixed version (ground truth):
/** 
 * Performs a prefix lookup in a given snapshot. Key-value paris are returned in an iterator in ascending key order, where only such keys are returned with a matching prefix according to the comparator.
 * @param prefix the prefix
 * @return an iterator with key-value pairs
 */
public Iterator<Entry<byte[],byte[]>> prefixLookup(byte[] prefix,int snapId){
  if (prefix != null && prefix.length == 0)   prefix=null;
  List<Iterator<Entry<byte[],byte[]>>> list=new ArrayList<Iterator<Entry<byte[],byte[]>>>(2);
  list.add(overlay.prefixLookup(prefix,snapId,true));
  if (index != null) {
    byte[][] rng=comp.prefixToRange(prefix);
    list.add(index.rangeLookup(rng[0],rng[1]));
  }
  return new OverlayMergeIterator<byte[],byte[]>(list,comp,NULL_ELEMENT);
}
Program: 132497
Project: 132497
Buggy source:
public void setUp(){
  Logging.start(Logging.LEVEL_ERROR);
  new File(SNAP_FILE).delete();
  new File(SNAP_FILE2).delete();
}

Fixed version (ground truth):
public void setUp(){
  Logging.start(Logging.LEVEL_ERROR);
  new File(SNAP_FILE).delete();
  new File(SNAP_FILE2).delete();
  new File(SNAP_FILE3).delete();
}
Program: 132498
Project: 132498
Buggy source:
public void tearDown() throws Exception {
  new File(SNAP_FILE).delete();
  new File(SNAP_FILE2).delete();
}

Fixed version (ground truth):
public void tearDown() throws Exception {
  new File(SNAP_FILE).delete();
  new File(SNAP_FILE2).delete();
  new File(SNAP_FILE3).delete();
}
Program: 132499
Project: 132499
Buggy source:
public ByteRange getEntry(int n){
  return new ByteRange(buf,offset + n * entrySize,offset + (n + 1) * entrySize);
}

Fixed version (ground truth):
public ByteRange getEntry(int n){
}
Program: 132501
Project: 132501
Buggy source:
public void run(){
  quit=false;
  down.set(false);
  while (!quit) {
    try {
      final LSMDBRequest r=requests.take();
switch (r.getOperation()) {
case INSERT:
        doInsert(r);
      break;
case LOOKUP:
    doLookup(r);
  break;
case PREFIX_LOOKUP:
doPrefixLookup(r);
break;
case USER_DEFINED_LOOKUP:
doUserLookup(r);
break;
default :
{
Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str");
System.exit(1);
}
}
}
 catch (InterruptedException ex) {
}
}
Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
synchronized (down) {
down.set(true);
down.notifyAll();
}
}

Fixed version (ground truth):
@Override public void run(){
  while (!quit) {
    try {
      final LSMDBRequest r=requests.take();
switch (r.getOperation()) {
case INSERT:
        doInsert(r);
      break;
case LOOKUP:
    doLookup(r);
  break;
case PREFIX_LOOKUP:
doPrefixLookup(r);
break;
case USER_DEFINED_LOOKUP:
doUserLookup(r);
break;
default :
{
Logging.logMessage(Logging.LEVEL_ERROR,this,"String_Node_Str");
System.exit(1);
}
}
}
 catch (InterruptedException ex) {
}
}
Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str");
synchronized (down) {
down.set(true);
down.notifyAll();
}
}
Program: 132502
Project: 132502
Buggy source:
public void waitForShutdown() throws InterruptedException {
synchronized (down) {
    if (!down.get())     down.wait();
  }
}

Fixed version (ground truth):
public void waitForShutdown() throws InterruptedException {
synchronized (down) {
    if (!down.get()) {
      down.wait();
    }
  }
}
Program: 132503
Project: 132503
Buggy source:
public LSMDBWorker(DiskLogger logger,int id,ReadWriteLock insertLock,boolean pseudoSync,int maxQ,Replication replication){
  super("String_Node_Str" + id);
  this.replicationFacade=replication;
  if (maxQ > 0)   requests=new LinkedBlockingQueue<LSMDBRequest>(maxQ);
 else   requests=new LinkedBlockingQueue<LSMDBRequest>();
  down=new AtomicBoolean(false);
  this.lookupIfs=new HashMap<LSMDatabase,LSMLookupInterface>();
  this.logger=logger;
  this.insertLock=insertLock;
  this.pseudoSync=pseudoSync;
}

Fixed version (ground truth):
public LSMDBWorker(DiskLogger logger,int id,ReadWriteLock insertLock,boolean pseudoSync,int maxQ,Replication replication){
  super("String_Node_Str" + id);
  down=new AtomicBoolean(false);
  this.replicationFacade=replication;
  if (maxQ > 0)   requests=new LinkedBlockingQueue<LSMDBRequest>(maxQ);
 else   requests=new LinkedBlockingQueue<LSMDBRequest>();
  this.lookupIfs=new HashMap<LSMDatabase,LSMLookupInterface>();
  this.logger=logger;
  this.insertLock=insertLock;
  this.pseudoSync=pseudoSync;
}
Program: 132504
Project: 132504
Buggy source:
@Override public int compare(Status<T> o1,Status<T> o2){
  if (o1.getStatus().equals(o2.getStatus())) {
    if (o1.getValue() instanceof Request) {
      Request rq1=(Request)o1.getValue();
      Request rq2=(Request)o2.getValue();
      if (rq2 == null)       return +1;
      Token rq1t=rq1.getToken();
      Token rq2t=rq2.getToken();
      if (rq1t.compareTo(rq2t) == 0) {
switch (rq1t) {
case ACK:
          return rq2.getLSN().compareTo(rq1.getLSN());
case RQ:
        return rq1.getLSN().compareTo(rq2.getLSN());
case REPLICA_BROADCAST:
      return rq1.getLSN().compareTo(rq2.getLSN());
case CHUNK:
    return rq1.getChunkDetails().compareTo(rq2.getChunkDetails());
case REPLICA:
  return rq1.getLSN().compareTo(rq2.getLSN());
case CHUNK_RP:
return rq1.getChunkDetails().compareTo(rq2.getChunkDetails());
default :
return 0;
}
}
return rq1t.compareTo(rq2t);
}
 else if (o1.getValue() instanceof LSN) {
LSN lsn1=(LSN)o1.getValue();
LSN lsn2=(LSN)o2.getValue();
return lsn1.compareTo(lsn2);
}
 else if (o1.getValue() instanceof Chunk) {
Chunk chunk1=(Chunk)o1.getValue();
Chunk chunk2=(Chunk)o2.getValue();
return chunk1.compareTo(chunk2);
}
 else return +1;
}
 else return o1.getStatus().compareTo(o2.getStatus());
}

Fixed version (ground truth):
@Override public int compare(Status<T> o1,Status<T> o2){
  if ((o1.isPending() && o2.isPending()) || (!o1.isPending() && !o2.isPending())) {
    if (o1.getValue() instanceof Request) {
      Request rq1=(Request)o1.getValue();
      Request rq2=(Request)o2.getValue();
      if (rq2 == null)       return +1;
      Token rq1t=rq1.getToken();
      Token rq2t=rq2.getToken();
      if (rq1t.compareTo(rq2t) == 0) {
switch (rq1t) {
case ACK:
          return rq2.getLSN().compareTo(rq1.getLSN());
case RQ:
        return rq1.getLSN().compareTo(rq2.getLSN());
case REPLICA_BROADCAST:
      return rq1.getLSN().compareTo(rq2.getLSN());
case CHUNK:
    return rq1.getChunkDetails().compareTo(rq2.getChunkDetails());
case REPLICA:
  return rq1.getLSN().compareTo(rq2.getLSN());
case CHUNK_RP:
return rq1.getChunkDetails().compareTo(rq2.getChunkDetails());
default :
return 0;
}
}
return rq1t.compareTo(rq2t);
}
 else if (o1.getValue() instanceof LSN) {
LSN lsn1=(LSN)o1.getValue();
LSN lsn2=(LSN)o2.getValue();
return lsn1.compareTo(lsn2);
}
 else if (o1.getValue() instanceof Chunk) {
Chunk chunk1=(Chunk)o1.getValue();
Chunk chunk2=(Chunk)o2.getValue();
return chunk1.compareTo(chunk2);
}
 else return +1;
}
 else if (o1.isPending()) return +1;
 else return -1;
}
Program: 132505
Project: 132505
Buggy source:
/** 
 * Insert a full record group. Only to be used by log replay.
 * @param ins
 */
private void insert(InsertRecordGroup ins){
  final LSMDatabase db=databases.get(ins.getDatabaseId());
  if (db == null) {
    return;
  }
  for (  InsertRecord ir : ins.getInserts()) {
    LSMTree tree=db.getIndex(ir.getIndexId());
    Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + new String(ir.getKey()) + "String_Node_Str"+ new String(ir.getValue())+ "String_Node_Str"+ db.getDatabaseName()+ "String_Node_Str"+ ir.getIndexId());
    tree.insert(ir.getKey(),ir.getValue());
  }
}

Fixed version (ground truth):
/** 
 * Insert a full record group. Only to be used by log replay.
 * @param ins
 */
private void insert(InsertRecordGroup ins){
  final LSMDatabase db=databases.get(ins.getDatabaseId());
  if (db == null) {
    return;
  }
  for (  InsertRecord ir : ins.getInserts()) {
    LSMTree tree=db.getIndex(ir.getIndexId());
    Logging.logMessage(Logging.LEVEL_DEBUG,this,"String_Node_Str" + new String(ir.getKey()) + "String_Node_Str"+ (ir.getValue() == null ? null : new String(ir.getValue()))+ "String_Node_Str"+ db.getDatabaseName()+ "String_Node_Str"+ ir.getIndexId());
    tree.insert(ir.getKey(),ir.getValue());
  }
}
Program: 132506
Project: 132506
Buggy source:
private void notifyChanged(T winnerCanon,T loserCanon){
  for (  ScopedUnionFind<T> subscriber : subscribed.get(loserCanon)) {
    subscriber.merge(winnerCanon,loserCanon);
  }
}

Fixed version (ground truth):
private void notifyChanged(boolean before,T winnerCanon,T loserCanon){
  Pair<T,Boolean> key=Pair.create(loserCanon,before);
  for (  UnionFindSubscriber<T> subscriber : subscribed.get(key)) {
    subscriber.notifyMerge(winnerCanon,loserCanon);
  }
}
Program: 132507
Project: 132507
Buggy source:
/** 
 * Merge loser into winner. Note: if they are already in same set, no changes, even if loser is canonical
 * @param winner
 * @param loser
 * @return unmodifiable collection of values that changed their canonical member
 */
public Set<T> merge(T winner,T loser){
  T winnerCanon=lookup(winner);
  T loserCanon=lookup(loser);
  Set<T> affectedMembers=members(loserCanon);
  if (affectedMembers.contains(winnerCanon)) {
    return Collections.emptySet();
  }
  notifyChanged(winnerCanon,loserCanon);
  for (  T affectedMember : affectedMembers) {
    canonical.put(affectedMember,winnerCanon);
  }
  subscribeToUpdates(winnerCanon);
  return Collections.unmodifiableSet(affectedMembers);
}

Fixed version (ground truth):
/** 
 * Merge loser into winner. Note: if they are already in same set, no changes, even if loser is canonical
 * @param winner
 * @param loser
 * @return unmodifiable collection of values that changed their canonical member
 */
public Set<T> merge(T winner,T loser){
  T winnerCanon=lookup(winner);
  T loserCanon=lookup(loser);
  Set<T> affectedMembers=members(loserCanon);
  if (affectedMembers.contains(winnerCanon)) {
    return Collections.emptySet();
  }
  notifyChanged(true,winnerCanon,loserCanon);
  for (  T affectedMember : affectedMembers) {
    canonical.put(affectedMember,winnerCanon);
  }
  subscribeToParentUpdates(winnerCanon);
  subscribeToParentUpdates(loserCanon);
  notifyChanged(false,winnerCanon,loserCanon);
  return Collections.unmodifiableSet(affectedMembers);
}
Program: 132508
Project: 132508
Buggy source:
/** 
 * Test merging
 */
@Test @Ignore public void testPropagateChild3(){
  ScopedUnionFind<Integer> uf=buildBasic();
  ScopedUnionFind<Integer> child=buildChild(uf);
  Set<Integer> affected;
  affected=child.merge(100,200);
  assertEquals(new HashSet<Integer>(Arrays.asList(200)),affected);
  affected=uf.merge(50,200);
  assertEquals(new HashSet<Integer>(Arrays.asList(200)),affected);
  assertEquals(50,(int)uf.lookup(50));
  assertEquals(100,(int)uf.lookup(100));
  assertEquals(50,(int)uf.lookup(200));
  assertEquals(50,(int)child.lookup(50));
  assertEquals(50,(int)child.lookup(100));
  assertEquals(50,(int)child.lookup(200));
}

Fixed version (ground truth):
/** 
 * Test merging
 */
@Test public void testPropagateChild3(){
  ScopedUnionFind<Integer> uf=buildBasic();
  ScopedUnionFind<Integer> child=buildChild(uf);
  Set<Integer> affected;
  affected=child.merge(100,200);
  assertEquals(new HashSet<Integer>(Arrays.asList(200)),affected);
  affected=uf.merge(50,200);
  assertEquals(new HashSet<Integer>(Arrays.asList(200)),affected);
  assertEquals(50,(int)uf.lookup(50));
  assertEquals(100,(int)uf.lookup(100));
  assertEquals(50,(int)uf.lookup(200));
  assertEquals(50,(int)child.lookup(50));
  assertEquals(50,(int)child.lookup(100));
  assertEquals(50,(int)child.lookup(200));
}
Program: 132509
Project: 132509
Buggy source:
@Override public void declare(List<VarDecl> decls){
}

Fixed version (ground truth):
@Override public void declare(List<VarDecl> decls){
  List<TclList> batchedArgs=new ArrayList<TclList>();
  List<String> batchedVarNames=new ArrayList<String>();
  List<TclList> batchedFileArgs=new ArrayList<TclList>();
  List<String> batchedFileVarNames=new ArrayList<String>();
  List<Boolean> batchedFileIsMappeds=new ArrayList<Boolean>();
  for (  VarDecl decl : decls) {
    Var var=decl.var;
    Arg initReaders=decl.initReaders;
    Arg initWriters=decl.initWriters;
    assert(!var.mappedDecl() || Types.isMappable(var.type()));
    if (var.storage() == Alloc.ALIAS) {
      assert(initReaders == null && initWriters == null);
      continue;
    }
    pointAdd(new Comment("String_Node_Str" + var.type().typeName() + "String_Node_Str"+ prefixVar(var.name())+ "String_Node_Str"+ var.provenance().logFormat()));
    if (var.storage().isGlobal()) {
      pointAdd(Turbine.makeTCLGlobal(prefixVar(var)));
      continue;
    }
    if (!Settings.getBooleanUnchecked(Settings.ENABLE_REFCOUNTING)) {
      initReaders=Arg.ONE;
    }
    if (Types.isFile(var)) {
      batchedFileArgs.add(createArgs(var,initReaders,initWriters));
      batchedFileVarNames.add(prefixVar(var));
      batchedFileIsMappeds.add(var.mappedDecl());
    }
 else     if (Types.isPrimFuture(var) || Types.isPrimUpdateable(var) || Types.isArray(var)|| Types.isRef(var)|| Types.isBag(var)|| Types.isStruct(var)) {
      batchedArgs.add(createArgs(var,initReaders,initWriters));
      batchedVarNames.add(prefixVar(var));
    }
 else     if (Types.isPrimValue(var) || Types.isContainerLocal(var) || Types.isStructLocal(var)) {
      assert(var.storage() == Alloc.LOCAL);
    }
 else {
      throw new STCRuntimeError("String_Node_Str" + "String_Node_Str" + var.type().typeName());
    }
  }
  if (!batchedArgs.isEmpty()) {
    pointAdd(Turbine.batchDeclare(batchedVarNames,batchedArgs));
    pointAdd(logVariableCreation(batchedVarNames));
  }
  if (!batchedFileArgs.isEmpty()) {
    pointAdd(Turbine.batchDeclareFiles(batchedFileVarNames,batchedFileArgs,batchedFileIsMappeds));
  }
}
Program: 132510
Project: 132510
Buggy source:
/** 
 * A loop over an integer range.  The range can be totally fixed ( the bounds might be literal integers) or can vary at runtime ( ( in which case it is specified by integer value variables ) The loop construct should run immediately, but have the loop iterations run in parallel
 * @param loopName unique name for loop
 * @param loopVar variable (integer value) used to store iteration parameter
 * @param countVar variable (integer value) used to store iteration number startingfrom 0 (optional)
 * @param start start (inclusive) of the loop: should be int or int value var
 * @param end end (inclusive) of the loop: should be int or int value var
 * @param increment increment of the loop: should be int or int value var
 * @param passedVars variables used in loop body
 * @param splitDegree the desired loop split factor (negative if no splitting)
 * @param perIterIncrs per-iteration increments
 * @param constIncrs constant increments
 */
public void startRangeLoop(String loopName,Var loopVar,Var countVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs);

Fixed version (ground truth):
/** 
 * A loop over an integer range.  The range can be totally fixed ( the bounds might be literal integers) or can vary at runtime ( ( in which case it is specified by integer value variables ) The loop construct should run immediately, but have the loop iterations run in parallel
 * @param loopName unique name for loop
 * @param loopVar variable (integer value) used to store iteration parameter
 * @param countVar variable (integer value) used to store iteration number startingfrom 0 (optional)
 * @param start start (inclusive) of the loop: should be int or int value var
 * @param end end (inclusive) of the loop: should be int or int value var
 * @param increment increment of the loop: should be int or int value var
 * @param passedVars variables used in loop body
 * @param splitDegree the desired loop split factor (negative if no splitting)
 * @param perIterIncrs per-iteration increments
 * @param constIncrs constant increments
 */
public void startRangeLoop(String loopName,Var loopVar,Var countVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs,List<RefCount> perIterDecrs);
Program: 132511
Project: 132511
Buggy source:
/** 
 * Start a parallel foreach loop over an array.
 * @param loopName unique name for loop
 * @param container
 * @param memberVar
 * @param loopCountVar counter variable, can be null
 * @param splitDegree
 * @param leafDegree
 * @param arrayClosed if true, assume array is already closed
 * @param passedVars
 * @param perIterIncrs per-iteration increments
 * @param constIncrs constant increments
 */
public void startForeachLoop(String loopName,Var container,Var memberVar,Var loopCountVar,int splitDegree,int leafDegree,boolean arrayClosed,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs);

Fixed version (ground truth):
/** 
 * Start a parallel foreach loop over an array.
 * @param loopName unique name for loop
 * @param container
 * @param memberVar
 * @param loopCountVar counter variable, can be null
 * @param splitDegree
 * @param leafDegree
 * @param arrayClosed if true, assume array is already closed
 * @param passedVars
 * @param perIterIncrs per-iteration increments
 * @param constIncrs constant increments
 */
public void startForeachLoop(String loopName,Var container,Var memberVar,Var loopCountVar,int splitDegree,int leafDegree,boolean arrayClosed,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs,List<RefCount> perIterDecrs);
Program: 132512
Project: 132512
Buggy source:
@Override public void generate(Logger logger,CompilerBackend gen,GenInfo info){
  gen.startRangeLoop(loopName,loopVar,loopCounterVar,start,end,increment,splitDegree,leafDegree,passedVars,startIncrements,constStartIncrements);
  this.loopBody.generate(logger,gen,info);
  gen.endRangeLoop(splitDegree,endDecrements);
}

Fixed version (ground truth):
@Override public void generate(Logger logger,CompilerBackend gen,GenInfo info){
  gen.startRangeLoop(loopName,loopVar,loopCounterVar,start,end,increment,splitDegree,leafDegree,passedVars,startIncrements,constStartIncrements,endDecrements);
  this.loopBody.generate(logger,gen,info);
  gen.endRangeLoop(splitDegree,endDecrements);
}
Program: 132513
Project: 132513
Buggy source:
@Override public void startRangeLoop(String loopName,Var loopVar,Var countVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs){
}

Fixed version (ground truth):
@Override public void startRangeLoop(String loopName,Var loopVar,Var countVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs,List<RefCount> perIterDecrs){
}
Program: 132514
Project: 132514
Buggy source:
private void startIntRangeLoop2(String loopName,String loopVarName,Expression start,Expression end,Expression incr,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs){
  if (!perIterIncrs.isEmpty()) {
    pointAdd(new SetVariable(TCLTMP_ITERSTOTAL,rangeItersLeft(start,end,incr)));
    Value itersTotal=Value.numericValue(TCLTMP_ITERSTOTAL);
    handleRefcounts(constIncrs,perIterIncrs,itersTotal,false);
  }
  if (splitDegree > 0) {
    startRangeSplit(loopName,passedVars,perIterIncrs,splitDegree,leafDegree,start,end,incr);
    startRangeLoopInner(loopName,loopVarName,TCLTMP_RANGE_LO_V,TCLTMP_RANGE_HI_V,TCLTMP_RANGE_INC_V);
  }
 else {
    startRangeLoopInner(loopName,loopVarName,start,end,incr);
  }
}

Fixed version (ground truth):
private void startIntRangeLoop2(String loopName,String loopVarName,Expression start,Expression end,Expression incr,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs,List<RefCount> perIterDecrs){
  if (!perIterIncrs.isEmpty()) {
    pointAdd(new SetVariable(TCLTMP_ITERSTOTAL,rangeItersLeft(start,end,incr)));
    Value itersTotal=Value.numericValue(TCLTMP_ITERSTOTAL);
    handleRefcounts(constIncrs,perIterIncrs,itersTotal,false);
  }
  if (splitDegree > 0) {
    startRangeSplit(loopName,passedVars,perIterIncrs,splitDegree,leafDegree,start,end,incr,perIterDecrs);
    startRangeLoopInner(loopName,loopVarName,TCLTMP_RANGE_LO_V,TCLTMP_RANGE_HI_V,TCLTMP_RANGE_INC_V);
  }
 else {
    startRangeLoopInner(loopName,loopVarName,start,end,incr);
  }
}
Program: 132515
Project: 132515
Buggy source:
private void startIntRangeLoop(String loopName,String loopVarName,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs){
  assert(start.isImmInt());
  assert(end.isImmInt());
  assert(increment.isImmInt());
  startIntRangeLoop2(loopName,loopVarName,argToExpr(start),argToExpr(end),argToExpr(increment),splitDegree,leafDegree,passedVars,perIterIncrs,constIncrs);
}

Fixed version (ground truth):
private void startIntRangeLoop(String loopName,String loopVarName,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs,List<RefCount> perIterDecrs){
  assert(start.isImmInt());
  assert(end.isImmInt());
  assert(increment.isImmInt());
  startIntRangeLoop2(loopName,loopVarName,argToExpr(start),argToExpr(end),argToExpr(increment),splitDegree,leafDegree,passedVars,perIterIncrs,constIncrs,perIterDecrs);
}
Program: 132516
Project: 132516
Buggy source:
private void startFloatRangeLoop(String loopName,Var loopVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs){
  assert(start.isImmFloat());
  assert(end.isImmFloat());
  assert(increment.isImmFloat());
  assert(Types.isFloatVal(loopVar));
  Expression startE=argToExpr(start);
  Expression endE=argToExpr(end);
  Expression incrE=argToExpr(increment);
  Value iterLimitVar=new Value(TCLTMP_FLOAT_RANGE_ITERMAX);
  pointAdd(new SetVariable(iterLimitVar.variable(),new TclExpr(TclExpr.exprFn(TclExpr.INT_CONV,TclExpr.group(TclExpr.exprFn(TclExpr.FLOOR,TclExpr.group(TclExpr.paren(endE,TclExpr.MINUS,startE,TclExpr.PLUS,incrE),TclExpr.DIV,incrE)))),TclExpr.MINUS,LiteralInt.ONE)));
  Value dummyLoopVar=new Value(TCLTMP_FLOAT_RANGE_ITER);
  List<PassedVar> passedVars2=PassedVar.mergeLists(passedVars,PassedVar.fromArgs(false,start,increment));
  startIntRangeLoop2(loopName,dummyLoopVar.variable(),LiteralInt.ZERO,iterLimitVar,LiteralInt.ONE,splitDegree,leafDegree,passedVars2,perIterIncrs,constIncrs);
  pointAdd(new SetVariable(prefixVar(loopVar),new TclExpr(startE,TclExpr.PLUS,incrE,TclExpr.TIMES,dummyLoopVar)));
}

Fixed version (ground truth):
private void startFloatRangeLoop(String loopName,Var loopVar,Arg start,Arg end,Arg increment,int splitDegree,int leafDegree,List<PassedVar> passedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs,List<RefCount> perIterDecrs){
  assert(start.isImmFloat());
  assert(end.isImmFloat());
  assert(increment.isImmFloat());
  assert(Types.isFloatVal(loopVar));
  Expression startE=argToExpr(start);
  Expression endE=argToExpr(end);
  Expression incrE=argToExpr(increment);
  Value iterLimitVar=new Value(TCLTMP_FLOAT_RANGE_ITERMAX);
  pointAdd(new SetVariable(iterLimitVar.variable(),new TclExpr(TclExpr.exprFn(TclExpr.INT_CONV,TclExpr.group(TclExpr.exprFn(TclExpr.FLOOR,TclExpr.group(TclExpr.paren(endE,TclExpr.MINUS,startE,TclExpr.PLUS,incrE),TclExpr.DIV,incrE)))),TclExpr.MINUS,LiteralInt.ONE)));
  Value dummyLoopVar=new Value(TCLTMP_FLOAT_RANGE_ITER);
  List<PassedVar> passedVars2=PassedVar.mergeLists(passedVars,PassedVar.fromArgs(false,start,increment));
  startIntRangeLoop2(loopName,dummyLoopVar.variable(),LiteralInt.ZERO,iterLimitVar,LiteralInt.ONE,splitDegree,leafDegree,passedVars2,perIterIncrs,constIncrs,perIterDecrs);
  pointAdd(new SetVariable(prefixVar(loopVar),new TclExpr(startE,TclExpr.PLUS,incrE,TclExpr.TIMES,dummyLoopVar)));
}
Program: 132519
Project: 132519
Buggy source:
private void startForeachSplit(String procName,Var arrayVar,String contentsVar,int splitDegree,int leafDegree,boolean haveKeys,List<PassedVar> usedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs){
  pointAdd(Turbine.containerSize(TCLTMP_CONTAINER_SIZE,varToExpr(arrayVar)));
  Value containerSize=Value.numericValue(TCLTMP_CONTAINER_SIZE);
  Expression lastIndex=TclExpr.minus(containerSize,LiteralInt.ONE);
  handleForeachContainerRefcounts(perIterIncrs,constIncrs,containerSize);
  ArrayList<PassedVar> splitUsedVars=new ArrayList<PassedVar>(usedVars);
  if (!PassedVar.contains(splitUsedVars,arrayVar)) {
    splitUsedVars.add(new PassedVar(arrayVar,false));
  }
  startRangeSplit(procName,splitUsedVars,perIterIncrs,splitDegree,leafDegree,LiteralInt.ZERO,lastIndex,LiteralInt.ONE);
  pointAdd(new SetVariable(TCLTMP_SPLITLEN,new TclExpr(Value.numericValue(TCLTMP_RANGE_HI),TclExpr.MINUS,Value.numericValue(TCLTMP_RANGE_LO),TclExpr.PLUS,LiteralInt.ONE)));
  pointAdd(Turbine.enumerate(contentsVar,varToExpr(arrayVar),haveKeys,TCLTMP_RANGE_LO_V,Value.numericValue(TCLTMP_SPLITLEN)));
}

Fixed version (ground truth):
private void startForeachSplit(String procName,Var arrayVar,String contentsVar,int splitDegree,int leafDegree,boolean haveKeys,List<PassedVar> usedVars,List<RefCount> perIterIncrs,ListMultimap<Var,RefCount> constIncrs,List<RefCount> perIterDecrs){
  pointAdd(Turbine.containerSize(TCLTMP_CONTAINER_SIZE,varToExpr(arrayVar)));
  Value containerSize=Value.numericValue(TCLTMP_CONTAINER_SIZE);
  Expression lastIndex=TclExpr.minus(containerSize,LiteralInt.ONE);
  handleForeachContainerRefcounts(perIterIncrs,constIncrs,containerSize);
  ArrayList<PassedVar> splitUsedVars=new ArrayList<PassedVar>(usedVars);
  if (!PassedVar.contains(splitUsedVars,arrayVar)) {
    splitUsedVars.add(new PassedVar(arrayVar,false));
  }
  startRangeSplit(procName,splitUsedVars,perIterIncrs,splitDegree,leafDegree,LiteralInt.ZERO,lastIndex,LiteralInt.ONE,perIterDecrs);
  pointAdd(new SetVariable(TCLTMP_SPLITLEN,new TclExpr(Value.numericValue(TCLTMP_RANGE_HI),TclExpr.MINUS,Value.numericValue(TCLTMP_RANGE_LO),TclExpr.PLUS,LiteralInt.ONE)));
  pointAdd(Turbine.enumerate(contentsVar,varToExpr(arrayVar),haveKeys,TCLTMP_RANGE_LO_V,Value.numericValue(TCLTMP_SPLITLEN)));
}
Program: 132520
Project: 132520
Buggy source:
private void compileTopLevel(GlobalContext context,LocatedModule mainModule) throws UserException, UndefinedFunctionException, ModuleLoadException {
  LocalContext topLevelContext=LocalContext.topLevelContext(context);
  Pair<ParsedModule,Boolean> loadedMainModule=modules.loadIfNeeded(context,mainModule);
  assert(!loadedMainModule.val2);
  varAnalyzer.walkTopLevel(context,loadedMainModule.val1.ast,moduleIterator(context));
  backend.startFunction(FnID.ENTRY_FUNCTION,Var.NONE,Var.NONE,ExecTarget.syncControl());
  for (  LocatedModule loadedModule : modules.loadedModules()) {
    loadModule(context,topLevelContext,FrontendPass.COMPILE_TOPLEVEL,loadedModule);
  }
  List<FnOverload> mainOverloads=context.lookupFunction(Constants.MAIN_FUNCTION);
  if (mainOverloads.size() == 1) {
    FnID mainID=mainOverloads.get(0).id;
    backend.functionCall(mainID,Arg.NONE,Var.NONE,ExecTarget.syncControl(),new TaskProps());
  }
 else   if (mainOverloads.size() >= 2) {
    throw new DoubleDefineException(context,"String_Node_Str" + Constants.MAIN_FUNCTION);
  }
  backend.endFunction();
}

Fixed version (ground truth):
private void compileTopLevel(GlobalContext context,LocatedModule mainModule) throws UserException, UndefinedFunctionException, ModuleLoadException {
  LocalContext topLevelContext=LocalContext.topLevelContext(context);
  Pair<ParsedModule,Boolean> loadedMainModule=modules.loadIfNeeded(context,mainModule);
  assert(!loadedMainModule.val2);
  varAnalyzer.walkTopLevel(context,loadedMainModule.val1);
  backend.startFunction(FnID.ENTRY_FUNCTION,Var.NONE,Var.NONE,ExecTarget.syncControl());
  loadModule(context,topLevelContext,FrontendPass.COMPILE_TOPLEVEL,mainModule);
  List<FnOverload> mainOverloads=context.lookupFunction(Constants.MAIN_FUNCTION);
  if (mainOverloads.size() == 1) {
    FnID mainID=mainOverloads.get(0).id;
    backend.functionCall(mainID,Arg.NONE,Var.NONE,ExecTarget.syncControl(),new TaskProps());
  }
 else   if (mainOverloads.size() >= 2) {
    throw new DoubleDefineException(context,"String_Node_Str" + Constants.MAIN_FUNCTION);
  }
  backend.endFunction();
}
Program: 132521
Project: 132521
Buggy source:
/** 
 * Handle an import statement by loading definitions for, or compiling module as needed.
 * @param context
 * @param tree
 * @param pass
 * @throws UserException
 */
private void importModule(GlobalContext context,SwiftAST tree,FrontendPass pass) throws UserException {
  assert(tree.getType() == ExMParser.IMPORT);
  assert(tree.getChildCount() == 1);
  SwiftAST moduleID=tree.child(0);
  if (pass == FrontendPass.DEFINITIONS) {
    LocatedModule module=LocatedModule.fromModuleNameAST(context,moduleID,false);
    loadModule(context,null,pass,module);
  }
}

Fixed version (ground truth):
/** 
 * Handle an import statement by loading definitions for, or compiling module as needed.
 * @param context
 * @param tree
 * @param topLevelCx required if we're compiling top level statements
 * @param pass
 * @throws UserException
 */
private void importModule(GlobalContext context,LocalContext topLevelCx,SwiftAST tree,FrontendPass pass) throws UserException {
  assert(tree.getType() == ExMParser.IMPORT);
  assert(tree.getChildCount() == 1);
  SwiftAST moduleID=tree.child(0);
  if (pass == FrontendPass.DEFINITIONS || pass == FrontendPass.COMPILE_TOPLEVEL) {
    LocatedModule module=LocatedModule.fromModuleNameAST(context,moduleID,false);
    loadModule(context,topLevelCx,pass,module);
  }
}
Program: 132522
Project: 132522
Buggy source:
/** 
 * Second pass: - Compile top-level statements
 * @param globalContext
 * @param fileTree
 * @throws UserException
 */
private void walkTopLevelCompileStatements(LocalContext context,SwiftAST fileTree) throws UserException {
  assert(fileTree.getType() == ExMParser.PROGRAM);
  syncFilePos(context,fileTree);
  List<SwiftAST> stmts=new ArrayList<SwiftAST>();
  for (  SwiftAST stmt : fileTree.children()) {
    syncFilePos(context,stmt);
    int type=stmt.getType();
    if (TopLevel.isStatement(type)) {
      stmts.add(stmt);
    }
 else     if (!TopLevel.isDefinition(type)) {
      throw new STCRuntimeError("String_Node_Str" + LogHelper.tokName(type) + "String_Node_Str");
    }
  }
  for (  SwiftAST stmt : stmts) {
    walkStatement(context,stmt,WalkMode.NORMAL);
  }
}

Fixed version (ground truth):
/** 
 * Second pass: - Compile top-level statements
 * @param globalContext
 * @param fileTree
 * @throws UserException
 */
private void walkTopLevelCompileStatements(LocalContext context,SwiftAST fileTree) throws UserException {
  assert(fileTree.getType() == ExMParser.PROGRAM);
  syncFilePos(context,fileTree);
  List<SwiftAST> stmts=new ArrayList<SwiftAST>();
  for (  SwiftAST stmt : fileTree.children()) {
    syncFilePos(context,stmt);
    int type=stmt.getType();
    if (TopLevel.isStatement(type)) {
      stmts.add(stmt);
    }
 else     if (type == ExMParser.IMPORT) {
      importModule(context.getGlobals(),context,stmt,FrontendPass.COMPILE_TOPLEVEL);
    }
 else     if (!TopLevel.isDefinition(type)) {
      throw new STCRuntimeError("String_Node_Str" + LogHelper.tokName(type) + "String_Node_Str");
    }
  }
  for (  SwiftAST stmt : stmts) {
    walkStatement(context,stmt,WalkMode.NORMAL);
  }
}
Program: 132523
Project: 132523
Buggy source:
/** 
 * First pass: - Register (but don't compile) all functions and other definitions
 * @param context
 * @param fileTree
 * @throws UserException
 * @throws DoubleDefineException
 * @throws UndefinedTypeException
 */
private void walkTopLevelDefs(GlobalContext context,SwiftAST fileTree) throws UserException {
  assert(fileTree.getType() == ExMParser.PROGRAM);
  syncFilePos(context,fileTree);
  for (  SwiftAST stmt : fileTree.children()) {
    int type=stmt.getType();
    syncFilePos(context,stmt);
switch (type) {
case ExMParser.IMPORT:
      importModule(context,stmt,FrontendPass.DEFINITIONS);
    break;
case ExMParser.DEFINE_BUILTIN_FUNCTION:
  defineBuiltinFunction(context,stmt);
break;
case ExMParser.DEFINE_FUNCTION:
defineFunction(context,stmt);
break;
case ExMParser.DEFINE_APP_FUNCTION:
defineAppFunction(context,stmt);
break;
case ExMParser.DEFINE_NEW_STRUCT_TYPE:
defineNewStructType(context,stmt);
break;
case ExMParser.DEFINE_NEW_TYPE:
case ExMParser.TYPEDEF:
defineNewType(context,stmt,type == ExMParser.TYPEDEF);
break;
case ExMParser.GLOBAL_CONST:
globalConst(context,stmt);
break;
case ExMParser.PRAGMA:
pragmaTopLevel(context,stmt);
break;
case ExMParser.EOF:
break;
default :
if (!TopLevel.isStatement(type)) {
throw new STCRuntimeError("String_Node_Str" + LogHelper.tokName(type) + "String_Node_Str");
}
}
}
}

Fixed version (ground truth):
/** 
 * First pass: - Register (but don't compile) all functions and other definitions
 * @param context
 * @param fileTree
 * @throws UserException
 * @throws DoubleDefineException
 * @throws UndefinedTypeException
 */
private void walkTopLevelDefs(GlobalContext context,SwiftAST fileTree) throws UserException {
  assert(fileTree.getType() == ExMParser.PROGRAM);
  syncFilePos(context,fileTree);
  for (  SwiftAST stmt : fileTree.children()) {
    int type=stmt.getType();
    syncFilePos(context,stmt);
switch (type) {
case ExMParser.IMPORT:
      importModule(context,null,stmt,FrontendPass.DEFINITIONS);
    break;
case ExMParser.DEFINE_BUILTIN_FUNCTION:
  defineBuiltinFunction(context,stmt);
break;
case ExMParser.DEFINE_FUNCTION:
defineFunction(context,stmt);
break;
case ExMParser.DEFINE_APP_FUNCTION:
defineAppFunction(context,stmt);
break;
case ExMParser.DEFINE_NEW_STRUCT_TYPE:
defineNewStructType(context,stmt);
break;
case ExMParser.DEFINE_NEW_TYPE:
case ExMParser.TYPEDEF:
defineNewType(context,stmt,type == ExMParser.TYPEDEF);
break;
case ExMParser.GLOBAL_CONST:
globalConst(context,stmt);
break;
case ExMParser.PRAGMA:
pragmaTopLevel(context,stmt);
break;
case ExMParser.EOF:
break;
default :
if (!TopLevel.isStatement(type)) {
throw new STCRuntimeError("String_Node_Str" + LogHelper.tokName(type) + "String_Node_Str");
}
}
}
}
Program: 132525
Project: 132525
Buggy source:
public ASTWalker(STCMiddleEnd backend,ForeignFunctions foreignFuncs){
  this.backend=backend;
  this.foreignFuncs=foreignFuncs;
  this.modules=new LoadedModules();
  this.varCreator=new VarCreator(backend);
  this.wrapper=new WrapperGen(backend);
  this.exprWalker=new ExprWalker(wrapper,varCreator,backend,modules);
  this.lValWalker=new LValWalker(backend,varCreator,exprWalker,modules);
  this.varAnalyzer=new VariableUsageAnalyzer();
}

Fixed version (ground truth):
public ASTWalker(STCMiddleEnd backend,ForeignFunctions foreignFuncs){
  this.backend=backend;
  this.foreignFuncs=foreignFuncs;
  this.modules=new LoadedModules();
  this.varCreator=new VarCreator(backend);
  this.wrapper=new WrapperGen(backend);
  this.exprWalker=new ExprWalker(wrapper,varCreator,backend,modules);
  this.lValWalker=new LValWalker(backend,varCreator,exprWalker,modules);
  this.varAnalyzer=new VariableUsageAnalyzer(modules);
}
Program: 132526
Project: 132526
Buggy source:
public Context(Logger logger,int level){
  super();
  this.level=level;
  this.logger=logger;
}

Fixed version (ground truth):
public Context(Context parent,Logger logger,int level){
  super();
  this.parent=parent;
  this.level=level;
  this.logger=logger;
}
Program: 132527
Project: 132527
Buggy source:
public GlobalContext(String inputFile,Logger logger,ForeignFunctions foreignFuncs){
  super(logger,0);
  this.inputFile=inputFile;
  this.foreignFuncs=foreignFuncs;
  Map<String,Type> builtInTypes=Types.getBuiltInTypes();
  for (  Entry<String,Type> type : builtInTypes.entrySet()) {
    types.put(type.getKey(),type.getValue());
    try {
      addDef(type.getKey(),DefKind.TYPE);
    }
 catch (    DoubleDefineException e) {
      throw new STCRuntimeError(e.getMessage());
    }
  }
  try {
    addExecContexts(ExecContext.builtinExecContexts());
  }
 catch (  DoubleDefineException e) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str",e);
  }
}

Fixed version (ground truth):
public GlobalContext(String inputFile,Logger logger,ForeignFunctions foreignFuncs){
  super(null,logger,0);
  this.inputFile=inputFile;
  this.foreignFuncs=foreignFuncs;
  Map<String,Type> builtInTypes=Types.getBuiltInTypes();
  for (  Entry<String,Type> type : builtInTypes.entrySet()) {
    types.put(type.getKey(),type.getValue());
    try {
      addDef(type.getKey(),DefKind.TYPE);
    }
 catch (    DoubleDefineException e) {
      throw new STCRuntimeError(e.getMessage());
    }
  }
  try {
    addExecContexts(ExecContext.builtinExecContexts());
  }
 catch (  DoubleDefineException e) {
    throw new STCRuntimeError("String_Node_Str" + "String_Node_Str",e);
  }
}
Program: 132528
Project: 132528
Buggy source:
public LocalContext(Context parent,String functionName,boolean isTopLevel){
  super(parent.getLogger(),parent.getLevel() + 1);
  this.functionContext=functionName != null ? new FunctionContext(functionName) : null;
  this.parent=parent;
  this.globals=parent.getGlobals();
  this.isTopLevel=isTopLevel;
  inputFile=parent.inputFile;
  line=parent.line;
  col=parent.col;
}

Fixed version (ground truth):
public LocalContext(Context parent,String functionName,boolean isTopLevel){
  super(parent,parent.getLogger(),parent.getLevel() + 1);
  this.functionContext=functionName != null ? new FunctionContext(functionName) : null;
  this.globals=parent.getGlobals();
  this.isTopLevel=isTopLevel;
  inputFile=parent.inputFile;
  line=parent.line;
  col=parent.col;
}
Program: 132529
Project: 132529
Buggy source:
/** 
 * @param filePath
 * @return
 * @throws IOException 
 */
public static String getCanonicalFilePath(String filePath) throws IOException {
  return new File(filePath).getCanonicalPath();
}

Fixed version (ground truth):
/** 
 * @param filePath
 * @return
 * @throws IOException
 */
public static String getCanonicalFilePath(String filePath) throws IOException {
  return new File(filePath).getCanonicalPath();
}
Program: 132530
Project: 132530
Buggy source:
/** 
 * Use the file and line info from c preprocessor to  update SwiftAST
 * @param lexer
 * @param tree
 */
private static LineMapping parsePreprocOutput(ANTLRInputStream input){
}

Fixed version (ground truth):
/** 
 * Use the file and line info from c preprocessor to update SwiftAST
 * @param lexer
 * @param tree
 */
private static LineMapping parsePreprocOutput(ANTLRInputStream input){
}