diff options
author | Chris Lattner <sabre@nondot.org> | 2002-09-26 05:03:22 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-09-26 05:03:22 +0000 |
commit | 4dfede807021d5ce419d510c02a9cab40a8de953 (patch) | |
tree | d91fa88d7d1bc4b66e4072883443da9b563e7d13 /llvm/lib/VMCore/BasicBlock.cpp | |
parent | 506389a37f7e6d113da178f902b0fe8dada64abe (diff) | |
download | bcm5719-llvm-4dfede807021d5ce419d510c02a9cab40a8de953.tar.gz bcm5719-llvm-4dfede807021d5ce419d510c02a9cab40a8de953.zip |
- Add new ctor to BasicBlock to allow insertion before any BB, not just at
the end of the function.
llvm-svn: 3934
Diffstat (limited to 'llvm/lib/VMCore/BasicBlock.cpp')
-rw-r--r-- | llvm/lib/VMCore/BasicBlock.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/BasicBlock.cpp b/llvm/lib/VMCore/BasicBlock.cpp index bf7191c6593..2f1072dc336 100644 --- a/llvm/lib/VMCore/BasicBlock.cpp +++ b/llvm/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(); |