[llvm] 254ba78 - [GenericDomTree][NFC] Remove unnecessary `const_cast`s (#97638)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 09:46:08 PST 2024


Author: MagentaTreehouse
Date: 2024-12-19T09:46:03-08:00
New Revision: 254ba78495100d9f20c4fa9802395f11c6d3cef1

URL: https://github.com/llvm/llvm-project/commit/254ba78495100d9f20c4fa9802395f11c6d3cef1
DIFF: https://github.com/llvm/llvm-project/commit/254ba78495100d9f20c4fa9802395f11c6d3cef1.diff

LOG: [GenericDomTree][NFC] Remove unnecessary `const_cast`s (#97638)

Added: 
    

Modified: 
    llvm/include/llvm/Support/GenericDomTree.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Support/GenericDomTree.h b/llvm/include/llvm/Support/GenericDomTree.h
index d0eec2070b4d7e..a4a680c97a0794 100644
--- a/llvm/include/llvm/Support/GenericDomTree.h
+++ b/llvm/include/llvm/Support/GenericDomTree.h
@@ -456,7 +456,7 @@ class DominatorTreeBase {
   bool isReachableFromEntry(const NodeT *A) const {
     assert(!this->isPostDominator() &&
            "This is not implemented for post dominators");
-    return isReachableFromEntry(getNode(const_cast<NodeT *>(A)));
+    return isReachableFromEntry(getNode(A));
   }
 
   bool isReachableFromEntry(const DomTreeNodeBase<NodeT> *A) const { return A; }
@@ -1014,11 +1014,7 @@ bool DominatorTreeBase<NodeT, IsPostDom>::dominates(const NodeT *A,
   if (A == B)
     return true;
 
-  // Cast away the const qualifiers here. This is ok since
-  // this function doesn't actually return the values returned
-  // from getNode.
-  return dominates(getNode(const_cast<NodeT *>(A)),
-                   getNode(const_cast<NodeT *>(B)));
+  return dominates(getNode(A), getNode(B));
 }
 template <typename NodeT, bool IsPostDom>
 bool DominatorTreeBase<NodeT, IsPostDom>::properlyDominates(
@@ -1026,11 +1022,7 @@ bool DominatorTreeBase<NodeT, IsPostDom>::properlyDominates(
   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 dominates(getNode(const_cast<NodeT *>(A)),
-                   getNode(const_cast<NodeT *>(B)));
+  return dominates(getNode(A), getNode(B));
 }
 
 } // end namespace llvm


        


More information about the llvm-commits mailing list