Constify properlyDominates in the same manner as dominates.
authorDan Gohman <gohman@apple.com>
Mon, 27 Sep 2010 16:33:31 +0000 (16:33 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 27 Sep 2010 16:33:31 +0000 (16:33 +0000)
Add constified overloads for findNearestCommonDominator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@114834 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/Dominators.h

index 57a5b2a6f4103a6aaf63286e95d3cda60137d921..1de8e15ff3faf89a5c496dd3e1f4661e02a61642 100644 (file)
@@ -361,8 +361,15 @@ public:
     return dominatedBySlowTreeWalk(A, B);
   }
 
-  inline bool properlyDominates(NodeT *A, NodeT *B) {
-    return properlyDominates(getNode(A), getNode(B));
+  inline bool properlyDominates(const NodeT *A, const NodeT *B) {
+    if (A == B)
+      return false;
+
+    // Cast away the const qualifiers here. This is ok since
+    // this function doesn't actually return the values returned
+    // from getNode.
+    return properlyDominates(getNode(const_cast<NodeT *>(A)),
+                             getNode(const_cast<NodeT *>(B)));
   }
 
   bool dominatedBySlowTreeWalk(const DomTreeNodeBase<NodeT> *A,
@@ -478,6 +485,13 @@ public:
     return NULL;
   }
 
+  const NodeT *findNearestCommonDominator(const NodeT *A, const NodeT *B) {
+    // Cast away the const qualifiers here. This is ok since
+    // const is re-introduced on the return type.
+    return findNearestCommonDominator(const_cast<NodeT *>(A),
+                                      const_cast<NodeT *>(B));
+  }
+
   //===--------------------------------------------------------------------===//
   // API to update (Post)DominatorTree information based on modifications to
   // the CFG...
@@ -767,7 +781,7 @@ public:
     return DT->properlyDominates(A, B);
   }
 
-  bool properlyDominates(BasicBlock *A, BasicBlock *B) const {
+  bool properlyDominates(const BasicBlock *A, const BasicBlock *B) const {
     return DT->properlyDominates(A, B);
   }
 
@@ -777,6 +791,11 @@ public:
     return DT->findNearestCommonDominator(A, B);
   }
 
+  inline const BasicBlock *findNearestCommonDominator(const BasicBlock *A,
+                                                      const BasicBlock *B) {
+    return DT->findNearestCommonDominator(A, B);
+  }
+
   inline DomTreeNode *operator[](BasicBlock *BB) const {
     return DT->getNode(BB);
   }