Skip to content

Commit

Permalink
[GenericDomTree][NFC] Remove unnecessary const_casts (llvm#97638)
Browse files Browse the repository at this point in the history
  • Loading branch information
MagentaTreehouse authored Dec 19, 2024
1 parent 01b9638 commit 254ba78
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions llvm/include/llvm/Support/GenericDomTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down Expand Up @@ -1014,23 +1014,15 @@ 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(
const NodeT *A, const NodeT *B) const {
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
Expand Down

0 comments on commit 254ba78

Please sign in to comment.