aboutsummaryrefslogtreecommitdiff
path: root/lib/VMCore/BasicBlock.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VMCore/BasicBlock.cpp')
-rw-r--r--lib/VMCore/BasicBlock.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp
index bf7191c659..2f1072dc33 100644
--- a/lib/VMCore/BasicBlock.cpp
+++ b/lib/VMCore/BasicBlock.cpp
@@ -67,6 +67,26 @@ BasicBlock::BasicBlock(const std::string &name, Function *Parent)
Parent->getBasicBlockList().push_back(this);
}
+/// BasicBlock ctor - If the InsertBefore parameter is specified, the basic
+/// block is automatically inserted right before the specified block.
+///
+BasicBlock::BasicBlock(const std::string &Name, BasicBlock *InsertBefore)
+ : Value(Type::LabelTy, Value::BasicBlockVal, Name) {
+ // Initialize the instlist...
+ InstList.setItemParent(this);
+
+ // Make sure that we get added to a function
+ LeakDetector::addGarbageObject(this);
+
+ if (InsertBefore) {
+ assert(InsertBefore->getParent() &&
+ "Cannot insert block before another block that is not embedded into"
+ " a function yet!");
+ InsertBefore->getParent()->getBasicBlockList().insert(InsertBefore, this);
+ }
+}
+
+
BasicBlock::~BasicBlock() {
dropAllReferences();
InstList.clear();