<commit_before>//===--- Verifier - Verification of Swift CFGs -----------------------------==//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines the high-level Instruction classes used for Swift CFGs.
//
//===----------------------------------------------------------------------===//

#include "swift/CFG/CFG.h"
#include "swift/CFG/CFGVisitor.h"
using namespace swift;

namespace {
/// CFGVerifier class - This class implements the CFG verifier, which walks over
/// an instance of the CFG, checking and enforcing its invariants.
class CFGVerifier : public CFGVisitor<CFGVerifier> {
public:
  
  void visit(Instruction *I) {
    
    const BasicBlock *BB = I->getParent();
    // Check that non-terminators look ok.
    if (!isa<TermInst>(I)) {
      assert(!BB->empty() &&
             "Can't be in a parent block if it is empty");
      assert(&*BB->getInsts().rbegin() != I &&
             "Non-terminators cannot be the last in a block");
    } else {
      assert(&*BB->getInsts().rbegin() == I &&
             "Terminator must be the last in block");
    }

    
    // Dispatch to our more-specialized instances below.
    ((CFGVisitor<CFGVerifier>*)this)->visit(I);
  }
  
  void visitCallInst(CallInst *CI) {
  }
  
  void visitDeclRefInst(DeclRefInst *DRI) {
  }
  void visitIntegerLiteralInst(IntegerLiteralInst *ILI) {
  }
  void visitLoadInst(LoadInst *LI) {
  }
  void visitThisApplyInst(ThisApplyInst *TAI) {
  }
  void visitTupleInst(TupleInst *TI) {
  }
  void visitTypeOfInst(TypeOfInst *TOI) {
  }
  
  void visitReturnInst(ReturnInst *RI) {
  }
  
  void visitBranchInst(BranchInst *BI) {
    // FIXME: Generalize this to support all terminators in the generic
    // terminator case.  Just diff "successors()" of the TermInst vs the block.
    // why redundantly store block terminators in the first place?
    
    const BasicBlock &targetBlock = *BI->getDestBB();
    assert(std::find(targetBlock.pred_begin(),
                     targetBlock.pred_end(), BI->getParent()) !=
                     targetBlock.pred_end() &&
           "BasicBlock of UncondBranchInst must be a predecessor of target");
    (void)targetBlock;
  }
  
  void visitCondBranchInst(CondBranchInst *CBI) {
  }
};
} // end anonymous namespace<commit_msg>remove verification of predecessor list for BranchInst - this should apply to all terminators, but is implicitly generated now, so it can't wander due to random compiler bugs.<commit_after>//===--- Verifier - Verification of Swift CFGs -----------------------------==//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines the high-level Instruction classes used for Swift CFGs.
//
//===----------------------------------------------------------------------===//

#include "swift/CFG/CFG.h"
#include "swift/CFG/CFGVisitor.h"
using namespace swift;

namespace {
/// CFGVerifier class - This class implements the CFG verifier, which walks over
/// an instance of the CFG, checking and enforcing its invariants.
class CFGVerifier : public CFGVisitor<CFGVerifier> {
public:
  
  void visit(Instruction *I) {
    
    const BasicBlock *BB = I->getParent();
    // Check that non-terminators look ok.
    if (!isa<TermInst>(I)) {
      assert(!BB->empty() &&
             "Can't be in a parent block if it is empty");
      assert(&*BB->getInsts().rbegin() != I &&
             "Non-terminators cannot be the last in a block");
    } else {
      assert(&*BB->getInsts().rbegin() == I &&
             "Terminator must be the last in block");
    }

    
    // Dispatch to our more-specialized instances below.
    ((CFGVisitor<CFGVerifier>*)this)->visit(I);
  }
  
  void visitCallInst(CallInst *CI) {
  }
  
  void visitDeclRefInst(DeclRefInst *DRI) {
  }
  void visitIntegerLiteralInst(IntegerLiteralInst *ILI) {
  }
  void visitLoadInst(LoadInst *LI) {
  }
  void visitThisApplyInst(ThisApplyInst *TAI) {
  }
  void visitTupleInst(TupleInst *TI) {
  }
  void visitTypeOfInst(TypeOfInst *TOI) {
  }
  
  void visitReturnInst(ReturnInst *RI) {
  }
  
  void visitBranchInst(BranchInst *BI) {
  }
  
  void visitCondBranchInst(CondBranchInst *CBI) {
  }
};
} // end anonymous namespace
{'fraction_non_alphanumeric': 0.18383838383838383, 'fraction_numerical': 0.00404040404040404, 'mean_word_length': 2.3139223560910307, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2716845', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1398, 'n_words': 437}