namespace llvm {
class TerminatorInst;
-template <class Term, class BB> class SuccIterator; // Successor Iterator
-template <class Ptr, class USE_iterator> class PredIterator;
template<> struct ilist_traits<Instruction>
: public SymbolTableListTraits<Instruction, BasicBlock> {
typedef InstListType::iterator iterator;
typedef InstListType::const_iterator const_iterator;
- // allocate space for exactly zero operands
+ /// Create - Creates a new BasicBlock. If the Parent parameter is specified,
+ /// the basic block is automatically inserted at either the end of the
+ /// function (if InsertBefore is 0), or before the specified basic block.
static BasicBlock *Create(const std::string &Name = "", Function *Parent = 0,
BasicBlock *InsertBefore = 0) {
return new BasicBlock(Name, Parent, InsertBefore);
return const_cast<BasicBlock*>(this)->getSinglePredecessor();
}
+ /// getUniquePredecessor - If this basic block has a unique predecessor block,
+ /// return the block, otherwise return a null pointer.
+ /// Note that unique predecessor doesn't mean single edge, there can be
+ /// multiple edges from the unique predecessor to this block (for example
+ /// a switch statement with multiple cases having the same destination).
+ BasicBlock *getUniquePredecessor();
+ const BasicBlock *getUniquePredecessor() const {
+ return const_cast<BasicBlock*>(this)->getUniquePredecessor();
+ }
+
//===--------------------------------------------------------------------===//
/// Instruction iterator methods
///
const InstListType &getInstList() const { return InstList; }
InstListType &getInstList() { return InstList; }
- virtual void print(std::ostream &OS) const { print(OS, 0); }
- void print(std::ostream *OS) const { if (OS) print(*OS); }
- void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const;
-
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const BasicBlock *) { return true; }
static inline bool classof(const Value *V) {