diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-07-30 17:36:47 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2012-07-30 17:36:47 +0000 |
commit | fee94ca15bc257e7dcaa5fc137a484bead1e866b (patch) | |
tree | 49a81bef43b891e794a47c2e01c7d1a99f0be277 /llvm/lib/CodeGen/MachineBasicBlock.cpp | |
parent | 088e37c77aafaec5ead8fbe7ebf918265e6b86f2 (diff) | |
download | bcm5719-llvm-fee94ca15bc257e7dcaa5fc137a484bead1e866b.tar.gz bcm5719-llvm-fee94ca15bc257e7dcaa5fc137a484bead1e866b.zip |
Add MachineBasicBlock::isPredecessor().
A->isPredecessor(B) is the same as B->isSuccessor(A), but it can
tolerate a B that is null or dangling. This shouldn't happen normally,
but it it useful for verification code.
llvm-svn: 160968
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineBasicBlock.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineBasicBlock.cpp b/llvm/lib/CodeGen/MachineBasicBlock.cpp index ecc1e951fad..f361d1ac293 100644 --- a/llvm/lib/CodeGen/MachineBasicBlock.cpp +++ b/llvm/lib/CodeGen/MachineBasicBlock.cpp @@ -540,9 +540,12 @@ MachineBasicBlock::transferSuccessorsAndUpdatePHIs(MachineBasicBlock *fromMBB) { } } +bool MachineBasicBlock::isPredecessor(const MachineBasicBlock *MBB) const { + return std::find(pred_begin(), pred_end(), MBB) != pred_end(); +} + bool MachineBasicBlock::isSuccessor(const MachineBasicBlock *MBB) const { - const_succ_iterator I = std::find(Successors.begin(), Successors.end(), MBB); - return I != Successors.end(); + return std::find(succ_begin(), succ_end(), MBB) != succ_end(); } bool MachineBasicBlock::isLayoutSuccessor(const MachineBasicBlock *MBB) const { |