NodeT *TheBB;
DomTreeNodeBase<NodeT> *IDom;
std::vector<DomTreeNodeBase<NodeT> *> Children;
- int DFSNumIn, DFSNumOut;
+ mutable int DFSNumIn, DFSNumOut;
template<class N> friend class DominatorTreeBase;
friend struct PostDominatorTree;
DomTreeNodeMapType DomTreeNodes;
DomTreeNodeBase<NodeT> *RootNode;
- bool DFSInfoValid;
- unsigned int SlowQueries;
+ mutable bool DFSInfoValid;
+ mutable unsigned int SlowQueries;
// Information record used during immediate dominators computation.
struct InfoRec {
unsigned DFSNum;
/// Note that this is not a constant time operation!
///
bool properlyDominates(const DomTreeNodeBase<NodeT> *A,
- const DomTreeNodeBase<NodeT> *B) {
+ const DomTreeNodeBase<NodeT> *B) const {
if (A == 0 || B == 0)
return false;
if (A == B)
return dominates(A, B);
}
- bool properlyDominates(const NodeT *A, const NodeT *B);
+ bool properlyDominates(const NodeT *A, const NodeT *B) const;
/// isReachableFromEntry - Return true if A is dominated by the entry
/// block of the function containing it.
/// constant time operation!
///
inline bool dominates(const DomTreeNodeBase<NodeT> *A,
- const DomTreeNodeBase<NodeT> *B) {
+ const DomTreeNodeBase<NodeT> *B) const {
// A node trivially dominates itself.
if (B == A)
return true;
return dominatedBySlowTreeWalk(A, B);
}
- bool dominates(const NodeT *A, const NodeT *B);
+ bool dominates(const NodeT *A, const NodeT *B) const;
NodeT *getRoot() const {
assert(this->Roots.size() == 1 && "Should always have entry node!");
/// updateDFSNumbers - Assign In and Out numbers to the nodes while walking
/// dominator tree in dfs order.
- void updateDFSNumbers() {
+ void updateDFSNumbers() const {
unsigned DFSNum = 0;
- SmallVector<std::pair<DomTreeNodeBase<NodeT>*,
- typename DomTreeNodeBase<NodeT>::iterator>, 32> WorkStack;
+ SmallVector<std::pair<const DomTreeNodeBase<NodeT>*,
+ typename DomTreeNodeBase<NodeT>::const_iterator>, 32> WorkStack;
- DomTreeNodeBase<NodeT> *ThisRoot = getRootNode();
+ const DomTreeNodeBase<NodeT> *ThisRoot = getRootNode();
if (!ThisRoot)
return;
ThisRoot->DFSNumIn = DFSNum++;
while (!WorkStack.empty()) {
- DomTreeNodeBase<NodeT> *Node = WorkStack.back().first;
- typename DomTreeNodeBase<NodeT>::iterator ChildIt =
+ const DomTreeNodeBase<NodeT> *Node = WorkStack.back().first;
+ typename DomTreeNodeBase<NodeT>::const_iterator ChildIt =
WorkStack.back().second;
// If we visited all of the children of this node, "recurse" back up the
WorkStack.pop_back();
} else {
// Otherwise, recursively visit this child.
- DomTreeNodeBase<NodeT> *Child = *ChildIt;
+ const DomTreeNodeBase<NodeT> *Child = *ChildIt;
++WorkStack.back().second;
WorkStack.push_back(std::make_pair(Child, Child->begin()));
// These two functions are declared out of line as a workaround for building
// with old (< r147295) versions of clang because of pr11642.
template<class NodeT>
-bool DominatorTreeBase<NodeT>::dominates(const NodeT *A, const NodeT *B) {
+bool DominatorTreeBase<NodeT>::dominates(const NodeT *A, const NodeT *B) const {
if (A == B)
return true;
}
template<class NodeT>
bool
-DominatorTreeBase<NodeT>::properlyDominates(const NodeT *A, const NodeT *B) {
+DominatorTreeBase<NodeT>::properlyDominates(const NodeT *A, const NodeT *B) const {
if (A == B)
return false;