MC CFG: Add more MCFunction container methods (find, empty).
[oota-llvm.git] / lib / MC / MCFunction.cpp
index cb2504668a328a20674deaa84d52ee5d652eaf4a..5011d5fd6b8ef022edbb01e7dc9451fe8b8567fa 100644 (file)
@@ -30,6 +30,18 @@ MCBasicBlock &MCFunction::createBlock(const MCTextAtom &TA) {
   return *Blocks.back();
 }
 
+const MCBasicBlock *MCFunction::find(uint64_t StartAddr) const {
+  for (const_iterator I = begin(), E = end(); I != E; ++I)
+    if ((*I)->getInsts()->getBeginAddr() == StartAddr)
+      return (*I);
+  return 0;
+}
+
+MCBasicBlock *MCFunction::find(uint64_t StartAddr) {
+  return const_cast<MCBasicBlock *>(
+           const_cast<const MCFunction *>(this)->find(StartAddr));
+}
+
 // MCBasicBlock
 
 MCBasicBlock::MCBasicBlock(const MCTextAtom &Insts, MCFunction *Parent)