Simplify.
[oota-llvm.git] / lib / VMCore / BasicBlock.cpp
index 3065766362e4a1394091ee919ccbd6f32b0041c6..d0fa02ce1cd94fa7fc59a22fa89a9bd203627f2b 100644 (file)
@@ -14,6 +14,7 @@
 #include "llvm/BasicBlock.h"
 #include "llvm/Constants.h"
 #include "llvm/Instructions.h"
+#include "llvm/LLVMContext.h"
 #include "llvm/Type.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/CFG.h"
@@ -29,12 +30,16 @@ ValueSymbolTable *BasicBlock::getValueSymbolTable() {
   return 0;
 }
 
+LLVMContext &BasicBlock::getContext() const {
+  return getType()->getContext();
+}
+
 // Explicit instantiation of SymbolTableListTraits since some of the methods
 // are not in the public header file...
 template class SymbolTableListTraits<Instruction, BasicBlock>;
 
 
-BasicBlock::BasicBlock(const std::string &Name, Function *NewParent,
+BasicBlock::BasicBlock(const Twine &Name, Function *NewParent,
                        BasicBlock *InsertBefore)
   : Value(Type::LabelTy, Value::BasicBlockVal), Parent(0) {
 
@@ -198,7 +203,7 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
           PN->replaceAllUsesWith(PN->getOperand(0));
         else
           // We are left with an infinite loop with no entries: kill the PHI.
-          PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
+          PN->replaceAllUsesWith(getContext().getUndef(PN->getType()));
         getInstList().pop_front();    // Remove the PHI node
       }
 
@@ -235,7 +240,7 @@ void BasicBlock::removePredecessor(BasicBlock *Pred,
 /// cause a degenerate basic block to be formed, having a terminator inside of
 /// the basic block).
 ///
-BasicBlock *BasicBlock::splitBasicBlock(iterator I, const std::string &BBName) {
+BasicBlock *BasicBlock::splitBasicBlock(iterator I, const Twine &BBName) {
   assert(getTerminator() && "Can't use splitBasicBlock on degenerate BB!");
   assert(I != InstList.end() &&
          "Trying to get me to create degenerate basic block!");