Fix some null checks to actually test the part that needs checking.
[oota-llvm.git] / include / llvm / Analysis / Dominators.h
index c8e753c149573a7a4040583d94d4cb99f8f047a3..45eed7fcdaf133ff9790ebb632496e84d21ec5dd 100644 (file)
@@ -322,11 +322,27 @@ public:
   }
   
   /// Return the immediate dominator of A.
-  BasicBlock *getIDom(BasicBlock *A) {
+  BasicBlock *getIDom(BasicBlock *A) const {
     ETNode *NodeA = getNode(A);
+    if (!NodeA) return 0;
     const ETNode *idom = NodeA->getFather();
     return idom ? idom->getData<BasicBlock>() : 0;
   }
+  
+  void getChildren(BasicBlock *A, std::vector<BasicBlock*>& children) const {
+    ETNode *NodeA = getNode(A);
+    if (!NodeA) return;
+    const ETNode* son = NodeA->getSon();
+    
+    if (!son) return;
+    children.push_back(son->getData<BasicBlock>());
+        
+    const ETNode* brother = son->getBrother();
+    while (brother != son) {
+      children.push_back(brother->getData<BasicBlock>());
+      brother = brother->getBrother();
+    }
+  }
 
   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
     AU.setPreservesAll();