From 7fc9fe34390c66ca58646d09a87f7dbaacb6c1f8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 27 Jun 2001 23:41:11 +0000 Subject: Miscellaneous cleanups: * Convert post to pre-increment for for loops * Use generic programming more * Use new Value::cast* instructions * Use new Module, Method, & BasicBlock forwarding methods * Use new facilities in STLExtras.h * Use new Instruction::isPHINode() method git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CFG.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/CFG.h b/include/llvm/CFG.h index e313e16fa6..5f207b5cfe 100644 --- a/include/llvm/CFG.h +++ b/include/llvm/CFG.h @@ -48,12 +48,15 @@ public: typedef PredIterator<_Ptr,_USE_iterator> _Self; typedef bidirectional_iterator_tag iterator_category; + typedef _Ptr &reference; + typedef unsigned difference_type; + typedef _Ptr value_type; typedef _Ptr pointer; inline void advancePastConstPool() { // Loop to ignore constant pool references while (It != BB->use_end() && - (((*It)->getValueType() != Value::InstructionVal) || + ((!(*It)->isInstruction()) || !(((Instruction*)(*It))->isTerminator()))) ++It; } @@ -67,8 +70,7 @@ public: inline bool operator!=(const _Self& x) const { return !operator==(x); } inline pointer operator*() const { - assert ((*It)->getValueType() == Value::InstructionVal); - return ((Instruction *)(*It))->getParent(); + return (*It)->castInstructionAsserting()->getParent(); } inline pointer *operator->() const { return &(operator*()); } @@ -113,6 +115,9 @@ public: typedef SuccIterator<_Term, _BB> _Self; // TODO: This can be random access iterator, need operator+ and stuff tho typedef bidirectional_iterator_tag iterator_category; + typedef _BB &reference; + typedef unsigned difference_type; + typedef _BB value_type; typedef _BB pointer; inline SuccIterator(_Term T) : Term(T), idx(0) {} // begin iterator @@ -242,11 +247,11 @@ public: }; inline df_iterator df_begin(Method *M, bool Reverse = false) { - return df_iterator(M->getBasicBlocks().front(), Reverse); + return df_iterator(M->front(), Reverse); } inline df_const_iterator df_begin(const Method *M, bool Reverse = false) { - return df_const_iterator(M->getBasicBlocks().front(), Reverse); + return df_const_iterator(M->front(), Reverse); } inline df_iterator df_end(Method*) { return df_iterator(); @@ -334,10 +339,10 @@ public: }; inline po_iterator po_begin( Method *M) { - return po_iterator(M->getBasicBlocks().front()); + return po_iterator(M->front()); } inline po_const_iterator po_begin(const Method *M) { - return po_const_iterator(M->getBasicBlocks().front()); + return po_const_iterator(M->front()); } inline po_iterator po_end ( Method *M) { return po_iterator(); @@ -371,7 +376,7 @@ class ReversePostOrderTraversal { } public: inline ReversePostOrderTraversal(Method *M) { - Initialize(M->getBasicBlocks().front()); + Initialize(M->front()); } inline ReversePostOrderTraversal(BasicBlock *BB) { Initialize(BB); -- cgit v1.2.3