diff options
author | Chris Lattner <sabre@nondot.org> | 2001-06-27 23:26:41 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-06-27 23:26:41 +0000 |
commit | 1020b3982c9eae15844c5612b0cf251917931b1d (patch) | |
tree | f5de5c6a2697aac3f36193ed29cfeded73856a4f /include/llvm/BasicBlock.h | |
parent | 0305cfd3cc858313a58d6a969db91edbd59d5861 (diff) |
Add extra forwarding accessor methods so that getMethodList(), getBasicBlocks()
and getInstList() are obsolete... except for when modifying those lists. This
makes code much more succinct and to the point.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/BasicBlock.h')
-rw-r--r-- | include/llvm/BasicBlock.h | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index 3fb33d4b6d..f01f79cecf 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -43,6 +43,12 @@ private : void setParent(Method *parent); public: + // Instruction iterators... + typedef InstListType::iterator iterator; + typedef InstListType::const_iterator const_iterator; + typedef reverse_iterator<const_iterator> const_reverse_iterator; + typedef reverse_iterator<iterator> reverse_iterator; + typedef cfg::succ_iterator succ_iterator; // Include CFG.h to use these typedef cfg::pred_iterator pred_iterator; typedef cfg::succ_const_iterator succ_const_iterator; @@ -57,9 +63,6 @@ public: const Method *getParent() const { return (const Method*)InstList.getParent();} Method *getParent() { return (Method*)InstList.getParent(); } - const InstListType &getInstList() const { return InstList; } - InstListType &getInstList() { return InstList; } - // getTerminator() - If this is a well formed basic block, then this returns // a pointer to the terminator instruction. If it is not, then you get a null // pointer back. @@ -67,6 +70,31 @@ public: TerminatorInst *getTerminator(); const TerminatorInst *const getTerminator() const; + //===--------------------------------------------------------------------===// + // Instruction iterator methods + inline iterator begin() { return InstList.begin(); } + inline const_iterator begin() const { return InstList.begin(); } + inline iterator end () { return InstList.end(); } + inline const_iterator end () const { return InstList.end(); } + + inline reverse_iterator rbegin() { return InstList.rbegin(); } + inline const_reverse_iterator rbegin() const { return InstList.rbegin(); } + inline reverse_iterator rend () { return InstList.rend(); } + inline const_reverse_iterator rend () const { return InstList.rend(); } + + inline unsigned size() const { return InstList.size(); } + inline bool empty() const { return InstList.empty(); } + inline const Instruction *front() const { return InstList.front(); } + inline Instruction *front() { return InstList.front(); } + inline const Instruction *back() const { return InstList.back(); } + inline Instruction *back() { return InstList.back(); } + + // getInstList() - Return the underlying instruction list container. You need + // to access it directly if you want to modify it currently. + // + const InstListType &getInstList() const { return InstList; } + InstListType &getInstList() { return InstList; } + // hasConstantPoolReferences() - This predicate is true if there is a // reference to this basic block in the constant pool for this method. For // example, if a block is reached through a switch table, that table resides @@ -96,7 +124,7 @@ public: // cause a degenerate basic block to be formed, having a terminator inside of // the basic block). // - BasicBlock *splitBasicBlock(InstListType::iterator I); + BasicBlock *splitBasicBlock(iterator I); }; #endif |