Index: include/llvm/Support/GenericDomTree.h =================================================================== --- include/llvm/Support/GenericDomTree.h +++ include/llvm/Support/GenericDomTree.h @@ -69,14 +69,13 @@ : Roots(), IsPostDominators(isPostDom) {} DominatorBase(DominatorBase &&Arg) - : Roots(std::move(Arg.Roots)), - IsPostDominators(std::move(Arg.IsPostDominators)) { + : Roots(std::move(Arg.Roots)), IsPostDominators(Arg.IsPostDominators) { Arg.Roots.clear(); } DominatorBase &operator=(DominatorBase &&RHS) { Roots = std::move(RHS.Roots); - IsPostDominators = std::move(RHS.IsPostDominators); + IsPostDominators = RHS.IsPostDominators; RHS.Roots.clear(); return *this; } @@ -99,18 +98,17 @@ template friend class DominatorTreeBase; NodeT *TheBB; - DomTreeNodeBase *IDom; - std::vector *> Children; - mutable int DFSNumIn = -1; - mutable int DFSNumOut = -1; + DomTreeNodeBase *IDom; + std::vector Children; + mutable unsigned DFSNumIn = static_cast(-1); + mutable unsigned DFSNumOut = static_cast(-1); -public: - DomTreeNodeBase(NodeT *BB, DomTreeNodeBase *iDom) - : TheBB(BB), IDom(iDom) {} + public: + DomTreeNodeBase(NodeT *BB, DomTreeNodeBase *iDom) : TheBB(BB), IDom(iDom) {} - typedef typename std::vector *>::iterator iterator; - typedef typename std::vector *>::const_iterator - const_iterator; + using iterator = typename std::vector::iterator; + using const_iterator = + typename std::vector::const_iterator; iterator begin() { return Children.begin(); } iterator end() { return Children.end(); } @@ -118,14 +116,12 @@ const_iterator end() const { return Children.end(); } NodeT *getBlock() const { return TheBB; } - DomTreeNodeBase *getIDom() const { return IDom; } + DomTreeNodeBase *getIDom() const { return IDom; } - const std::vector *> &getChildren() const { - return Children; - } + const std::vector &getChildren() const { return Children; } - std::unique_ptr> - addChild(std::unique_ptr> C) { + std::unique_ptr addChild( + std::unique_ptr C) { Children.push_back(C.get()); return C; } @@ -134,7 +130,7 @@ void clearAllChildren() { Children.clear(); } - bool compare(const DomTreeNodeBase *Other) const { + bool compare(const DomTreeNodeBase *Other) const { if (getNumChildren() != Other->getNumChildren()) return true; @@ -152,10 +148,10 @@ return false; } - void setIDom(DomTreeNodeBase *NewIDom) { + void setIDom(DomTreeNodeBase *NewIDom) { assert(IDom && "No immediate dominator?"); if (IDom != NewIDom) { - typename std::vector *>::iterator I = + typename std::vector::iterator I = find(IDom->Children, this); assert(I != IDom->Children.end() && "Not in immediate dominator children set!"); @@ -177,32 +173,32 @@ private: // Return true if this node is dominated by other. Use this only if DFS info // is valid. - bool DominatedBy(const DomTreeNodeBase *other) const { + bool DominatedBy(const DomTreeNodeBase *other) const { return this->DFSNumIn >= other->DFSNumIn && this->DFSNumOut <= other->DFSNumOut; } }; template -raw_ostream &operator<<(raw_ostream &o, const DomTreeNodeBase *Node) { +raw_ostream &operator<<(raw_ostream &O, const DomTreeNodeBase *Node) { if (Node->getBlock()) - Node->getBlock()->printAsOperand(o, false); + Node->getBlock()->printAsOperand(O, false); else - o << " <>"; + O << " <>"; - o << " {" << Node->getDFSNumIn() << "," << Node->getDFSNumOut() << "}"; + O << " {" << Node->getDFSNumIn() << "," << Node->getDFSNumOut() << "}"; - return o << "\n"; + return O << "\n"; } template -void PrintDomTree(const DomTreeNodeBase *N, raw_ostream &o, +void PrintDomTree(const DomTreeNodeBase *N, raw_ostream &O, unsigned Lev) { - o.indent(2 * Lev) << "[" << Lev << "] " << N; + O.indent(2 * Lev) << "[" << Lev << "] " << N; for (typename DomTreeNodeBase::const_iterator I = N->begin(), E = N->end(); I != E; ++I) - PrintDomTree(*I, o, Lev + 1); + PrintDomTree(*I, O, Lev + 1); } // The calculate routine is provided in a separate header but referenced here. @@ -239,8 +235,8 @@ } protected: - typedef DenseMap>> - DomTreeNodeMapType; + using DomTreeNodeMapType = + DenseMap>>; DomTreeNodeMapType DomTreeNodes; DomTreeNodeBase *RootNode; @@ -663,19 +659,18 @@ /// print - Convert to human readable form /// - void print(raw_ostream &o) const { - o << "=============================--------------------------------\n"; + void print(raw_ostream &O) const { + O << "=============================--------------------------------\n"; if (this->isPostDominator()) - o << "Inorder PostDominator Tree: "; + O << "Inorder PostDominator Tree: "; else - o << "Inorder Dominator Tree: "; + O << "Inorder Dominator Tree: "; if (!DFSInfoValid) - o << "DFSNumbers invalid: " << SlowQueries << " slow queries."; - o << "\n"; + O << "DFSNumbers invalid: " << SlowQueries << " slow queries."; + O << "\n"; // The postdom tree can have a null root if there are no returns. - if (getRootNode()) - PrintDomTree(getRootNode(), o, 1); + if (getRootNode()) PrintDomTree(getRootNode(), O, 1); } protected: @@ -770,7 +765,7 @@ /// recalculate - compute a dominator tree for the given function template void recalculate(FT &F) { - typedef GraphTraits TraitsTy; + using TraitsTy = GraphTraits; reset(); Vertex.push_back(nullptr);