[llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Feb 23 18:37:40 PST 2005



Changes in directory llvm/lib/VMCore:

BasicBlock.cpp updated: 1.56 -> 1.57
---
Log message:

add a new method.


---
Diffs of the changes:  (+10 -0)

 BasicBlock.cpp |   10 ++++++++++
 1 files changed, 10 insertions(+)


Index: llvm/lib/VMCore/BasicBlock.cpp
diff -u llvm/lib/VMCore/BasicBlock.cpp:1.56 llvm/lib/VMCore/BasicBlock.cpp:1.57
--- llvm/lib/VMCore/BasicBlock.cpp:1.56	Wed Feb 23 10:53:04 2005
+++ llvm/lib/VMCore/BasicBlock.cpp	Wed Feb 23 20:37:26 2005
@@ -129,6 +129,16 @@
     I->dropAllReferences();
 }
 
+/// getSinglePredecessor - If this basic block has a single predecessor block,
+/// return the block, otherwise return a null pointer.
+BasicBlock *BasicBlock::getSinglePredecessor() {
+  pred_iterator PI = pred_begin(this), E = pred_end(this);
+  if (PI == E) return 0;         // No preds.
+  BasicBlock *ThePred = *PI;
+  ++PI;
+  return (PI == E) ? ThePred : 0 /*multiple preds*/;
+}
+
 // removePredecessor - This method is used to notify a BasicBlock that the
 // specified Predecessor of the block is no longer able to reach it.  This is
 // actually not used to update the Predecessor list, but is actually used to 






More information about the llvm-commits mailing list