[llvm] r306472 - [Analysis] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).

Eugene Zelenko via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 14:52:05 PDT 2017


Author: eugenezelenko
Date: Tue Jun 27 14:52:05 2017
New Revision: 306472

URL: http://llvm.org/viewvc/llvm-project?rev=306472&view=rev
Log:
[Analysis] Fix some Clang-tidy modernize-use-using and Include What You Use warnings; other minor fixes (NFC).

Modified:
    llvm/trunk/include/llvm/Analysis/LoopInfo.h
    llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h
    llvm/trunk/include/llvm/Analysis/LoopIterator.h
    llvm/trunk/include/llvm/Analysis/RegionInfo.h
    llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h
    llvm/trunk/include/llvm/Analysis/RegionIterator.h
    llvm/trunk/lib/Analysis/RegionInfo.cpp

Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=306472&r1=306471&r2=306472&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Tue Jun 27 14:52:05 2017
@@ -39,26 +39,39 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/GraphTraits.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/CFG.h"
+#include "llvm/IR/DebugLoc.h"
 #include "llvm/IR/Instruction.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/IR/Use.h"
+#include "llvm/IR/User.h"
 #include "llvm/Pass.h"
+#include "llvm/Support/Casting.h"
 #include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <string>
+#include <utility>
+#include <vector>
 
 namespace llvm {
 
 class DominatorTree;
-class LoopInfo;
+template<class N> class DominatorTreeBase;
+class Function;
 class Loop;
+class LoopInfo;
+template<class N, class M> class LoopInfoBase;
 class MDNode;
-class PHINode;
 class raw_ostream;
-template<class N> class DominatorTreeBase;
-template<class N, class M> class LoopInfoBase;
-template<class N, class M> class LoopBase;
+class Value;
 
 //===----------------------------------------------------------------------===//
 /// Instances of this class are used to represent loops that are detected in the
@@ -66,7 +79,8 @@ template<class N, class M> class LoopBas
 ///
 template<class BlockT, class LoopT>
 class LoopBase {
-  LoopT *ParentLoop;
+  LoopT *ParentLoop = nullptr;
+
   // Loops contained entirely within this one.
   std::vector<LoopT *> SubLoops;
 
@@ -78,12 +92,12 @@ class LoopBase {
   /// Indicator that this loop is no longer a valid loop.
   bool IsInvalid = false;
 
-  LoopBase(const LoopBase<BlockT, LoopT> &) = delete;
-  const LoopBase<BlockT, LoopT>&
-    operator=(const LoopBase<BlockT, LoopT> &) = delete;
 public:
   /// This creates an empty loop.
-  LoopBase() : ParentLoop(nullptr) {}
+  LoopBase() = default;
+  LoopBase(const LoopBase<BlockT, LoopT> &) = delete;
+  LoopBase<BlockT, LoopT> &operator=(const LoopBase<BlockT, LoopT> &) = delete;
+
   ~LoopBase() {
     for (size_t i = 0, e = SubLoops.size(); i != e; ++i)
       delete SubLoops[i];
@@ -126,9 +140,11 @@ public:
   /// Return the loops contained entirely within this loop.
   const std::vector<LoopT *> &getSubLoops() const { return SubLoops; }
   std::vector<LoopT *> &getSubLoopsVector() { return SubLoops; }
-  typedef typename std::vector<LoopT *>::const_iterator iterator;
-  typedef typename std::vector<LoopT *>::const_reverse_iterator
-    reverse_iterator;
+
+  using iterator = typename std::vector<LoopT *>::const_iterator;
+  using reverse_iterator =
+      typename std::vector<LoopT *>::const_reverse_iterator;
+
   iterator begin() const { return SubLoops.begin(); }
   iterator end() const { return SubLoops.end(); }
   reverse_iterator rbegin() const { return SubLoops.rbegin(); }
@@ -137,7 +153,9 @@ public:
 
   /// Get a list of the basic blocks which make up this loop.
   const std::vector<BlockT*> &getBlocks() const { return Blocks; }
-  typedef typename std::vector<BlockT*>::const_iterator block_iterator;
+
+  using block_iterator = typename std::vector<BlockT*>::const_iterator;
+
   block_iterator block_begin() const { return Blocks.begin(); }
   block_iterator block_end() const { return Blocks.end(); }
   inline iterator_range<block_iterator> blocks() const {
@@ -173,8 +191,8 @@ public:
     assert(contains(BB) && "block does not belong to the loop");
 
     BlockT *Header = getHeader();
-    auto PredBegin = GraphTraits<Inverse<BlockT*> >::child_begin(Header);
-    auto PredEnd = GraphTraits<Inverse<BlockT*> >::child_end(Header);
+    auto PredBegin = GraphTraits<Inverse<BlockT*>>::child_begin(Header);
+    auto PredEnd = GraphTraits<Inverse<BlockT*>>::child_end(Header);
     return std::find(PredBegin, PredEnd, BB) != PredEnd;
   }
 
@@ -183,7 +201,7 @@ public:
     unsigned NumBackEdges = 0;
     BlockT *H = getHeader();
 
-    for (const auto Pred : children<Inverse<BlockT*> >(H))
+    for (const auto Pred : children<Inverse<BlockT *>>(H))
       if (contains(Pred))
         ++NumBackEdges;
 
@@ -216,7 +234,7 @@ public:
   BlockT *getExitBlock() const;
 
   /// Edge type.
-  typedef std::pair<const BlockT*, const BlockT*> Edge;
+  using Edge = std::pair<const BlockT*, const BlockT*>;
 
   /// Return all pairs of (_inside_block_,_outside_block_).
   void getExitEdges(SmallVectorImpl<Edge> &ExitEdges) const;
@@ -320,7 +338,7 @@ public:
   /// Blocks as appropriate. This does not update the mapping in the LoopInfo
   /// class.
   void removeBlockFromLoop(BlockT *BB) {
-    auto I = find(Blocks, BB);
+    auto I = llvm::find(Blocks, BB);
     assert(I != Blocks.end() && "N is not in this list!");
     Blocks.erase(I);
 
@@ -338,6 +356,7 @@ public:
 
 protected:
   friend class LoopInfoBase<BlockT, LoopT>;
+
   explicit LoopBase(BlockT *BB) : ParentLoop(nullptr) {
     Blocks.push_back(BB);
     DenseBlockSet.insert(BB);
@@ -353,7 +372,6 @@ raw_ostream& operator<<(raw_ostream &OS,
 // Implementation in LoopInfoImpl.h
 extern template class LoopBase<BasicBlock, Loop>;
 
-
 /// Represents a single loop in the control flow graph.  Note that not all SCCs
 /// in the CFG are necessarily loops.
 class Loop : public LoopBase<BasicBlock, Loop> {
@@ -364,7 +382,7 @@ public:
     DebugLoc End;
 
   public:
-    LocRange() {}
+    LocRange() = default;
     LocRange(DebugLoc Start) : Start(std::move(Start)), End(std::move(Start)) {}
     LocRange(DebugLoc Start, DebugLoc End) : Start(std::move(Start)),
                                              End(std::move(End)) {}
@@ -379,7 +397,7 @@ public:
     }
   };
 
-  Loop() {}
+  Loop() = default;
 
   /// Return true if the specified value is loop invariant.
   bool isLoopInvariant(const Value *V) const;
@@ -407,7 +425,6 @@ public:
   ///
   /// If InsertPt is specified, it is the point to hoist instructions to.
   /// If null, the terminator of the loop preheader is used.
-  ///
   bool makeLoopInvariant(Instruction *I, bool &Changed,
                          Instruction *InsertPt = nullptr) const;
 
@@ -417,7 +434,6 @@ public:
   ///
   /// The IndVarSimplify pass transforms loops to have a canonical induction
   /// variable.
-  ///
   PHINode *getCanonicalInductionVariable() const;
 
   /// Return true if the Loop is in LCSSA form.
@@ -454,6 +470,7 @@ public:
   /// contain llvm.loop or or if multiple latches contain different nodes then
   /// 0 is returned.
   MDNode *getLoopID() const;
+
   /// Set the llvm.loop loop id metadata for this loop.
   ///
   /// The LoopID metadata node will be added to each terminator instruction in
@@ -499,6 +516,7 @@ public:
 
 private:
   friend class LoopInfoBase<BasicBlock, Loop>;
+
   explicit Loop(BasicBlock *BB) : LoopBase<BasicBlock, Loop>(BB) {}
 };
 
@@ -509,19 +527,17 @@ private:
 
 template<class BlockT, class LoopT>
 class LoopInfoBase {
+  friend class LoopBase<BlockT, LoopT>;
+  friend class LoopInfo;
+
   // BBMap - Mapping of basic blocks to the inner most loop they occur in
   DenseMap<const BlockT *, LoopT *> BBMap;
+
   std::vector<LoopT *> TopLevelLoops;
   std::vector<LoopT *> RemovedLoops;
 
-  friend class LoopBase<BlockT, LoopT>;
-  friend class LoopInfo;
-
-  void operator=(const LoopInfoBase &) = delete;
-  LoopInfoBase(const LoopInfoBase &) = delete;
 public:
-  LoopInfoBase() { }
-  ~LoopInfoBase() { releaseMemory(); }
+  LoopInfoBase() = default;
 
   LoopInfoBase(LoopInfoBase &&Arg)
       : BBMap(std::move(Arg.BBMap)),
@@ -529,6 +545,7 @@ public:
     // We have to clear the arguments top level loops as we've taken ownership.
     Arg.TopLevelLoops.clear();
   }
+
   LoopInfoBase &operator=(LoopInfoBase &&RHS) {
     BBMap = std::move(RHS.BBMap);
 
@@ -539,6 +556,10 @@ public:
     return *this;
   }
 
+  LoopInfoBase(const LoopInfoBase &) = delete;
+  LoopInfoBase &operator=(const LoopInfoBase &) = delete;
+  ~LoopInfoBase() { releaseMemory(); }
+
   void releaseMemory() {
     BBMap.clear();
 
@@ -552,10 +573,10 @@ public:
 
   /// iterator/begin/end - The interface to the top-level loops in the current
   /// function.
-  ///
-  typedef typename std::vector<LoopT *>::const_iterator iterator;
-  typedef typename std::vector<LoopT *>::const_reverse_iterator
-    reverse_iterator;
+  using iterator = typename std::vector<LoopT *>::const_iterator;
+  using reverse_iterator =
+      typename std::vector<LoopT *>::const_reverse_iterator;
+
   iterator begin() const { return TopLevelLoops.begin(); }
   iterator end() const { return TopLevelLoops.end(); }
   reverse_iterator rbegin() const { return TopLevelLoops.rbegin(); }
@@ -627,7 +648,7 @@ public:
   /// loop.
   void changeTopLevelLoop(LoopT *OldLoop,
                           LoopT *NewLoop) {
-    auto I = find(TopLevelLoops, OldLoop);
+    auto I = llvm::find(TopLevelLoops, OldLoop);
     assert(I != TopLevelLoops.end() && "Old loop not at top level!");
     *I = NewLoop;
     assert(!NewLoop->ParentLoop && !OldLoop->ParentLoop &&
@@ -675,22 +696,24 @@ public:
 extern template class LoopInfoBase<BasicBlock, Loop>;
 
 class LoopInfo : public LoopInfoBase<BasicBlock, Loop> {
-  typedef LoopInfoBase<BasicBlock, Loop> BaseT;
-
   friend class LoopBase<BasicBlock, Loop>;
 
-  void operator=(const LoopInfo &) = delete;
-  LoopInfo(const LoopInfo &) = delete;
+  using BaseT = LoopInfoBase<BasicBlock, Loop>;
+
 public:
-  LoopInfo() {}
+  LoopInfo() = default;
   explicit LoopInfo(const DominatorTreeBase<BasicBlock> &DomTree);
 
   LoopInfo(LoopInfo &&Arg) : BaseT(std::move(static_cast<BaseT &>(Arg))) {}
+
   LoopInfo &operator=(LoopInfo &&RHS) {
     BaseT::operator=(std::move(static_cast<BaseT &>(RHS)));
     return *this;
   }
 
+  LoopInfo(const LoopInfo &) = delete;
+  LoopInfo &operator=(const LoopInfo &) = delete;
+
   /// Handle invalidation explicitly.
   bool invalidate(Function &F, const PreservedAnalyses &PA,
                   FunctionAnalysisManager::Invalidator &);
@@ -798,8 +821,8 @@ public:
 
 // Allow clients to walk the list of nested loops...
 template <> struct GraphTraits<const Loop*> {
-  typedef const Loop *NodeRef;
-  typedef LoopInfo::iterator ChildIteratorType;
+  using NodeRef = const Loop *;
+  using ChildIteratorType = LoopInfo::iterator;
 
   static NodeRef getEntryNode(const Loop *L) { return L; }
   static ChildIteratorType child_begin(NodeRef N) { return N->begin(); }
@@ -807,8 +830,8 @@ template <> struct GraphTraits<const Loo
 };
 
 template <> struct GraphTraits<Loop*> {
-  typedef Loop *NodeRef;
-  typedef LoopInfo::iterator ChildIteratorType;
+  using NodeRef = Loop *;
+  using ChildIteratorType = LoopInfo::iterator;
 
   static NodeRef getEntryNode(Loop *L) { return L; }
   static ChildIteratorType child_begin(NodeRef N) { return N->begin(); }
@@ -818,10 +841,11 @@ template <> struct GraphTraits<Loop*> {
 /// \brief Analysis pass that exposes the \c LoopInfo for a function.
 class LoopAnalysis : public AnalysisInfoMixin<LoopAnalysis> {
   friend AnalysisInfoMixin<LoopAnalysis>;
+
   static AnalysisKey Key;
 
 public:
-  typedef LoopInfo Result;
+  using Result = LoopInfo;
 
   LoopInfo run(Function &F, FunctionAnalysisManager &AM);
 };
@@ -832,6 +856,7 @@ class LoopPrinterPass : public PassInfoM
 
 public:
   explicit LoopPrinterPass(raw_ostream &OS) : OS(OS) {}
+
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
@@ -869,6 +894,6 @@ public:
 /// Function to print a loop's contents as LLVM's text IR assembly.
 void printLoop(Loop &L, raw_ostream &OS, const std::string &Banner = "");
 
-} // End llvm namespace
+} // end namespace llvm
 
-#endif
+#endif // LLVM_ANALYSIS_LOOPINFO_H

Modified: llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h?rev=306472&r1=306471&r2=306472&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfoImpl.h Tue Jun 27 14:52:05 2017
@@ -15,12 +15,23 @@
 #ifndef LLVM_ANALYSIS_LOOPINFOIMPL_H
 #define LLVM_ANALYSIS_LOOPINFOIMPL_H
 
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/DepthFirstIterator.h"
+#include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/IR/Dominators.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cassert>
+#include <vector>
 
 namespace llvm {
 
@@ -108,7 +119,8 @@ BlockT *LoopBase<BlockT, LoopT>::getLoop
     return nullptr;
 
   // Make sure there is only one exit out of the preheader.
-  typedef GraphTraits<BlockT*> BlockTraits;
+  using BlockTraits = GraphTraits<BlockT *>;
+
   typename BlockTraits::ChildIteratorType SI = BlockTraits::child_begin(Out);
   ++SI;
   if (SI != BlockTraits::child_end(Out))
@@ -237,14 +249,14 @@ void LoopBase<BlockT, LoopT>::verifyLoop
                        [&](BlockT *B){return contains(B);}) &&
            "Loop block has no in-loop successors!");
 
-    assert(std::any_of(GraphTraits<Inverse<BlockT*> >::child_begin(BB),
-                       GraphTraits<Inverse<BlockT*> >::child_end(BB),
+    assert(std::any_of(GraphTraits<Inverse<BlockT *>>::child_begin(BB),
+                       GraphTraits<Inverse<BlockT *>>::child_end(BB),
                        [&](BlockT *B){return contains(B);}) &&
            "Loop block has no in-loop predecessors!");
 
     SmallVector<BlockT *, 2> OutsideLoopPreds;
-    std::for_each(GraphTraits<Inverse<BlockT*> >::child_begin(BB),
-                  GraphTraits<Inverse<BlockT*> >::child_end(BB),
+    std::for_each(GraphTraits<Inverse<BlockT *>>::child_begin(BB),
+                  GraphTraits<Inverse<BlockT *>>::child_end(BB),
                   [&](BlockT *B){if (!contains(B))
                       OutsideLoopPreds.push_back(B);
                   });
@@ -344,7 +356,7 @@ template<class BlockT, class LoopT>
 static void discoverAndMapSubloop(LoopT *L, ArrayRef<BlockT*> Backedges,
                                   LoopInfoBase<BlockT, LoopT> *LI,
                                   const DominatorTreeBase<BlockT> &DomTree) {
-  typedef GraphTraits<Inverse<BlockT*> > InvBlockTraits;
+  using InvBlockTraits = GraphTraits<Inverse<BlockT *>>;
 
   unsigned NumBlocks = 0;
   unsigned NumSubloops = 0;
@@ -401,13 +413,13 @@ static void discoverAndMapSubloop(LoopT
 /// Populate all loop data in a stable order during a single forward DFS.
 template<class BlockT, class LoopT>
 class PopulateLoopsDFS {
-  typedef GraphTraits<BlockT*> BlockTraits;
-  typedef typename BlockTraits::ChildIteratorType SuccIterTy;
+  using BlockTraits = GraphTraits<BlockT *>;
+  using SuccIterTy = typename BlockTraits::ChildIteratorType;
 
   LoopInfoBase<BlockT, LoopT> *LI;
+
 public:
-  PopulateLoopsDFS(LoopInfoBase<BlockT, LoopT> *li):
-    LI(li) {}
+  PopulateLoopsDFS(LoopInfoBase<BlockT, LoopT> *li) : LI(li) {}
 
   void traverse(BlockT *EntryBlock);
 
@@ -657,6 +669,6 @@ void LoopInfoBase<BlockT, LoopT>::verify
 #endif
 }
 
-} // End llvm namespace
+} // end namespace llvm
 
-#endif
+#endif // LLVM_ANALYSIS_LOOPINFOIMPL_H

Modified: llvm/trunk/include/llvm/Analysis/LoopIterator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopIterator.h?rev=306472&r1=306471&r2=306472&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopIterator.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopIterator.h Tue Jun 27 14:52:05 2017
@@ -1,4 +1,4 @@
-//===--------- LoopIterator.h - Iterate over loop blocks --------*- C++ -*-===//
+//===- LoopIterator.h - Iterate over loop blocks ----------------*- C++ -*-===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -24,11 +24,23 @@
 #ifndef LLVM_ANALYSIS_LOOPITERATOR_H
 #define LLVM_ANALYSIS_LOOPITERATOR_H
 
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/PostOrderIterator.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/Analysis/LoopInfo.h"
+#include "llvm/IR/CFG.h"
+#include "llvm/Support/MathExtras.h"
+#include <cassert>
+#include <cstddef>
+#include <utility>
+#include <vector>
 
 namespace llvm {
 
+class BasicBlock;
 class LoopBlocksTraversal;
 
 // A traits type that is intended to be used in graph algorithms. The graph
@@ -97,12 +109,12 @@ struct LoopBodyTraits {
 /// TODO: This could be generalized for any CFG region, or the entire CFG.
 class LoopBlocksDFS {
 public:
-  /// Postorder list iterators.
-  typedef std::vector<BasicBlock*>::const_iterator POIterator;
-  typedef std::vector<BasicBlock*>::const_reverse_iterator RPOIterator;
-
   friend class LoopBlocksTraversal;
 
+  /// Postorder list iterators.
+  using POIterator = std::vector<BasicBlock *>::const_iterator;
+  using RPOIterator = std::vector<BasicBlock *>::const_reverse_iterator;
+
 private:
   Loop *L;
 
@@ -171,8 +183,10 @@ public:
 /// Specialize po_iterator_storage to record postorder numbers.
 template<> class po_iterator_storage<LoopBlocksTraversal, true> {
   LoopBlocksTraversal &LBT;
+
 public:
   po_iterator_storage(LoopBlocksTraversal &lbs) : LBT(lbs) {}
+
   // These functions are defined below.
   bool insertEdge(Optional<BasicBlock *> From, BasicBlock *To);
   void finishPostorder(BasicBlock *BB);
@@ -182,7 +196,7 @@ public:
 class LoopBlocksTraversal {
 public:
   /// Graph traversal iterator.
-  typedef po_iterator<BasicBlock*, LoopBlocksTraversal, true> POTIterator;
+  using POTIterator = po_iterator<BasicBlock*, LoopBlocksTraversal, true>;
 
 private:
   LoopBlocksDFS &DFS;
@@ -236,6 +250,6 @@ finishPostorder(BasicBlock *BB) {
   LBT.finishPostorder(BB);
 }
 
-} // End namespace llvm
+} // end namespace llvm
 
-#endif
+#endif // LLVM_ANALYSIS_LOOPITERATOR_H

Modified: llvm/trunk/include/llvm/Analysis/RegionInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/RegionInfo.h?rev=306472&r1=306471&r2=306472&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/RegionInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/RegionInfo.h Tue Jun 27 14:52:05 2017
@@ -37,18 +37,38 @@
 #ifndef LLVM_ANALYSIS_REGIONINFO_H
 #define LLVM_ANALYSIS_REGIONINFO_H
 
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DepthFirstIterator.h"
+#include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/iterator_range.h"
-#include "llvm/IR/CFG.h"
+#include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Dominators.h"
 #include "llvm/IR/PassManager.h"
+#include "llvm/Pass.h"
+#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cassert>
 #include <map>
 #include <memory>
 #include <set>
+#include <string>
+#include <type_traits>
+#include <vector>
 
 namespace llvm {
 
+class DominanceFrontier;
+class DominatorTree;
+class Loop;
+class LoopInfo;
+struct PostDominatorTree;
+class Region;
+template <class RegionTr> class RegionBase;
+class RegionInfo;
+template <class RegionTr> class RegionInfoBase;
+class RegionNode;
+
 // Class to be specialized for different users of RegionInfo
 // (i.e. BasicBlocks or MachineBasicBlocks). This is only to avoid needing to
 // pass around an unreasonable number of template parameters.
@@ -59,37 +79,23 @@ struct RegionTraits {
   // RegionT
   // RegionNodeT
   // RegionInfoT
-  typedef typename FuncT_::UnknownRegionTypeError BrokenT;
+  using BrokenT = typename FuncT_::UnknownRegionTypeError;
 };
 
-class DominatorTree;
-class DominanceFrontier;
-class Loop;
-class LoopInfo;
-struct PostDominatorTree;
-class raw_ostream;
-class Region;
-template <class RegionTr>
-class RegionBase;
-class RegionNode;
-class RegionInfo;
-template <class RegionTr>
-class RegionInfoBase;
-
 template <>
 struct RegionTraits<Function> {
-  typedef Function FuncT;
-  typedef BasicBlock BlockT;
-  typedef Region RegionT;
-  typedef RegionNode RegionNodeT;
-  typedef RegionInfo RegionInfoT;
-  typedef DominatorTree DomTreeT;
-  typedef DomTreeNode DomTreeNodeT;
-  typedef DominanceFrontier DomFrontierT;
-  typedef PostDominatorTree PostDomTreeT;
-  typedef Instruction InstT;
-  typedef Loop LoopT;
-  typedef LoopInfo LoopInfoT;
+  using FuncT = Function;
+  using BlockT = BasicBlock;
+  using RegionT = Region;
+  using RegionNodeT = RegionNode;
+  using RegionInfoT = RegionInfo;
+  using DomTreeT = DominatorTree;
+  using DomTreeNodeT = DomTreeNode;
+  using DomFrontierT = DominanceFrontier;
+  using PostDomTreeT = PostDominatorTree;
+  using InstT = Instruction;
+  using LoopT = Loop;
+  using LoopInfoT = LoopInfo;
 
   static unsigned getNumSuccessors(BasicBlock *BB) {
     return BB->getTerminator()->getNumSuccessors();
@@ -113,13 +119,10 @@ class RegionNodeBase {
   friend class RegionBase<Tr>;
 
 public:
-  typedef typename Tr::BlockT BlockT;
-  typedef typename Tr::RegionT RegionT;
+  using BlockT = typename Tr::BlockT;
+  using RegionT = typename Tr::RegionT;
 
 private:
-  RegionNodeBase(const RegionNodeBase &) = delete;
-  const RegionNodeBase &operator=(const RegionNodeBase &) = delete;
-
   /// This is the entry basic block that starts this region node.  If this is a
   /// BasicBlock RegionNode, then entry is just the basic block, that this
   /// RegionNode represents.  Otherwise it is the entry of this (Sub)RegionNode.
@@ -150,6 +153,9 @@ protected:
       : entry(Entry, isSubRegion), parent(Parent) {}
 
 public:
+  RegionNodeBase(const RegionNodeBase &) = delete;
+  RegionNodeBase &operator=(const RegionNodeBase &) = delete;
+
   /// @brief Get the parent Region of this RegionNode.
   ///
   /// The parent Region is the Region this RegionNode belongs to. If for
@@ -247,24 +253,22 @@ public:
 /// tree, the second one creates a graphical representation using graphviz.
 template <class Tr>
 class RegionBase : public RegionNodeBase<Tr> {
-  typedef typename Tr::FuncT FuncT;
-  typedef typename Tr::BlockT BlockT;
-  typedef typename Tr::RegionInfoT RegionInfoT;
-  typedef typename Tr::RegionT RegionT;
-  typedef typename Tr::RegionNodeT RegionNodeT;
-  typedef typename Tr::DomTreeT DomTreeT;
-  typedef typename Tr::LoopT LoopT;
-  typedef typename Tr::LoopInfoT LoopInfoT;
-  typedef typename Tr::InstT InstT;
-
-  typedef GraphTraits<BlockT *> BlockTraits;
-  typedef GraphTraits<Inverse<BlockT *>> InvBlockTraits;
-  typedef typename BlockTraits::ChildIteratorType SuccIterTy;
-  typedef typename InvBlockTraits::ChildIteratorType PredIterTy;
-
   friend class RegionInfoBase<Tr>;
-  RegionBase(const RegionBase &) = delete;
-  const RegionBase &operator=(const RegionBase &) = delete;
+ 
+  using FuncT = typename Tr::FuncT;
+  using BlockT = typename Tr::BlockT;
+  using RegionInfoT = typename Tr::RegionInfoT;
+  using RegionT = typename Tr::RegionT;
+  using RegionNodeT = typename Tr::RegionNodeT;
+  using DomTreeT = typename Tr::DomTreeT;
+  using LoopT = typename Tr::LoopT;
+  using LoopInfoT = typename Tr::LoopInfoT;
+  using InstT = typename Tr::InstT;
+
+  using BlockTraits = GraphTraits<BlockT *>;
+  using InvBlockTraits = GraphTraits<Inverse<BlockT *>>;
+  using SuccIterTy = typename BlockTraits::ChildIteratorType;
+  using PredIterTy = typename InvBlockTraits::ChildIteratorType;
 
   // Information necessary to manage this Region.
   RegionInfoT *RI;
@@ -274,12 +278,12 @@ class RegionBase : public RegionNodeBase
   // (The entry BasicBlock is part of RegionNode)
   BlockT *exit;
 
-  typedef std::vector<std::unique_ptr<RegionT>> RegionSet;
+  using RegionSet = std::vector<std::unique_ptr<RegionT>>;
 
   // The subregions of this region.
   RegionSet children;
 
-  typedef std::map<BlockT *, std::unique_ptr<RegionNodeT>> BBNodeMapT;
+  using BBNodeMapT = std::map<BlockT *, std::unique_ptr<RegionNodeT>>;
 
   // Save the BasicBlock RegionNodes that are element of this Region.
   mutable BBNodeMapT BBNodeMap;
@@ -308,6 +312,9 @@ public:
   RegionBase(BlockT *Entry, BlockT *Exit, RegionInfoT *RI, DomTreeT *DT,
              RegionT *Parent = nullptr);
 
+  RegionBase(const RegionBase &) = delete;
+  RegionBase &operator=(const RegionBase &) = delete;
+
   /// Delete the Region and all its subregions.
   ~RegionBase();
 
@@ -543,8 +550,8 @@ public:
   ///
   /// These iterators iterator over all subregions of this Region.
   //@{
-  typedef typename RegionSet::iterator iterator;
-  typedef typename RegionSet::const_iterator const_iterator;
+  using iterator = typename RegionSet::iterator;
+  using const_iterator = typename RegionSet::const_iterator;
 
   iterator begin() { return children.begin(); }
   iterator end() { return children.end(); }
@@ -563,12 +570,13 @@ public:
   class block_iterator_wrapper
       : public df_iterator<
             typename std::conditional<IsConst, const BlockT, BlockT>::type *> {
-    typedef df_iterator<
-        typename std::conditional<IsConst, const BlockT, BlockT>::type *> super;
+    using super =
+        df_iterator<
+            typename std::conditional<IsConst, const BlockT, BlockT>::type *>;
 
   public:
-    typedef block_iterator_wrapper<IsConst> Self;
-    typedef typename super::value_type value_type;
+    using Self = block_iterator_wrapper<IsConst>;
+    using value_type = typename super::value_type;
 
     // Construct the begin iterator.
     block_iterator_wrapper(value_type Entry, value_type Exit)
@@ -592,8 +600,8 @@ public:
     }
   };
 
-  typedef block_iterator_wrapper<false> block_iterator;
-  typedef block_iterator_wrapper<true> const_block_iterator;
+  using block_iterator = block_iterator_wrapper<false>;
+  using const_block_iterator = block_iterator_wrapper<true>;
 
   block_iterator block_begin() { return block_iterator(getEntry(), getExit()); }
 
@@ -604,8 +612,8 @@ public:
   }
   const_block_iterator block_end() const { return const_block_iterator(); }
 
-  typedef iterator_range<block_iterator> block_range;
-  typedef iterator_range<const_block_iterator> const_block_range;
+  using block_range = iterator_range<block_iterator>;
+  using const_block_range = iterator_range<const_block_iterator>;
 
   /// @brief Returns a range view of the basic blocks in the region.
   inline block_range blocks() {
@@ -626,14 +634,14 @@ public:
   /// are direct children of this Region. It does not iterate over any
   /// RegionNodes that are also element of a subregion of this Region.
   //@{
-  typedef df_iterator<RegionNodeT *, df_iterator_default_set<RegionNodeT *>,
-                      false, GraphTraits<RegionNodeT *>>
-      element_iterator;
-
-  typedef df_iterator<const RegionNodeT *,
-                      df_iterator_default_set<const RegionNodeT *>, false,
-                      GraphTraits<const RegionNodeT *>>
-      const_element_iterator;
+  using element_iterator =
+      df_iterator<RegionNodeT *, df_iterator_default_set<RegionNodeT *>, false,
+                  GraphTraits<RegionNodeT *>>;
+
+  using const_element_iterator =
+      df_iterator<const RegionNodeT *,
+                  df_iterator_default_set<const RegionNodeT *>, false,
+                  GraphTraits<const RegionNodeT *>>;
 
   element_iterator element_begin();
   element_iterator element_end();
@@ -661,29 +669,26 @@ inline raw_ostream &operator<<(raw_ostre
 /// Tree.
 template <class Tr>
 class RegionInfoBase {
-  typedef typename Tr::BlockT BlockT;
-  typedef typename Tr::FuncT FuncT;
-  typedef typename Tr::RegionT RegionT;
-  typedef typename Tr::RegionInfoT RegionInfoT;
-  typedef typename Tr::DomTreeT DomTreeT;
-  typedef typename Tr::DomTreeNodeT DomTreeNodeT;
-  typedef typename Tr::PostDomTreeT PostDomTreeT;
-  typedef typename Tr::DomFrontierT DomFrontierT;
-  typedef GraphTraits<BlockT *> BlockTraits;
-  typedef GraphTraits<Inverse<BlockT *>> InvBlockTraits;
-  typedef typename BlockTraits::ChildIteratorType SuccIterTy;
-  typedef typename InvBlockTraits::ChildIteratorType PredIterTy;
-
   friend class RegionInfo;
   friend class MachineRegionInfo;
-  typedef DenseMap<BlockT *, BlockT *> BBtoBBMap;
-  typedef DenseMap<BlockT *, RegionT *> BBtoRegionMap;
 
-  RegionInfoBase();
-  virtual ~RegionInfoBase();
+  using BlockT = typename Tr::BlockT;
+  using FuncT = typename Tr::FuncT;
+  using RegionT = typename Tr::RegionT;
+  using RegionInfoT = typename Tr::RegionInfoT;
+  using DomTreeT = typename Tr::DomTreeT;
+  using DomTreeNodeT = typename Tr::DomTreeNodeT;
+  using PostDomTreeT = typename Tr::PostDomTreeT;
+  using DomFrontierT = typename Tr::DomFrontierT;
+  using BlockTraits = GraphTraits<BlockT *>;
+  using InvBlockTraits = GraphTraits<Inverse<BlockT *>>;
+  using SuccIterTy = typename BlockTraits::ChildIteratorType;
+  using PredIterTy = typename InvBlockTraits::ChildIteratorType;
 
-  RegionInfoBase(const RegionInfoBase &) = delete;
-  const RegionInfoBase &operator=(const RegionInfoBase &) = delete;
+  using BBtoBBMap = DenseMap<BlockT *, BlockT *>;
+  using BBtoRegionMap = DenseMap<BlockT *, RegionT *>;
+
+  RegionInfoBase();
 
   RegionInfoBase(RegionInfoBase &&Arg)
     : DT(std::move(Arg.DT)), PDT(std::move(Arg.PDT)), DF(std::move(Arg.DF)),
@@ -691,6 +696,7 @@ class RegionInfoBase {
       BBtoRegion(std::move(Arg.BBtoRegion)) {
     Arg.wipe();
   }
+
   RegionInfoBase &operator=(RegionInfoBase &&RHS) {
     DT = std::move(RHS.DT);
     PDT = std::move(RHS.PDT);
@@ -701,12 +707,14 @@ class RegionInfoBase {
     return *this;
   }
 
+  virtual ~RegionInfoBase();
+
   DomTreeT *DT;
   PostDomTreeT *PDT;
   DomFrontierT *DF;
 
   /// The top level region.
-  RegionT *TopLevelRegion;
+  RegionT *TopLevelRegion = nullptr;
 
   /// Map every BB to the smallest region, that contains BB.
   BBtoRegionMap BBtoRegion;
@@ -785,6 +793,9 @@ private:
   void calculate(FuncT &F);
 
 public:
+  RegionInfoBase(const RegionInfoBase &) = delete;
+  RegionInfoBase &operator=(const RegionInfoBase &) = delete;
+
   static bool VerifyRegionInfo;
   static typename RegionT::PrintStyle printStyle;
 
@@ -887,21 +898,22 @@ public:
 
 class RegionInfo : public RegionInfoBase<RegionTraits<Function>> {
 public:
-  typedef RegionInfoBase<RegionTraits<Function>> Base;
+  using Base = RegionInfoBase<RegionTraits<Function>>;
 
   explicit RegionInfo();
 
-  ~RegionInfo() override;
-
   RegionInfo(RegionInfo &&Arg) : Base(std::move(static_cast<Base &>(Arg))) {
     updateRegionTree(*this, TopLevelRegion);
   }
+
   RegionInfo &operator=(RegionInfo &&RHS) {
     Base::operator=(std::move(static_cast<Base &>(RHS)));
     updateRegionTree(*this, TopLevelRegion);
     return *this;
   }
 
+  ~RegionInfo() override;
+
   /// Handle invalidation explicitly.
   bool invalidate(Function &F, const PreservedAnalyses &PA,
                   FunctionAnalysisManager::Invalidator &);
@@ -931,8 +943,8 @@ class RegionInfoPass : public FunctionPa
 
 public:
   static char ID;
-  explicit RegionInfoPass();
 
+  explicit RegionInfoPass();
   ~RegionInfoPass() override;
 
   RegionInfo &getRegionInfo() { return RI; }
@@ -953,10 +965,11 @@ public:
 /// \brief Analysis pass that exposes the \c RegionInfo for a function.
 class RegionInfoAnalysis : public AnalysisInfoMixin<RegionInfoAnalysis> {
   friend AnalysisInfoMixin<RegionInfoAnalysis>;
+
   static AnalysisKey Key;
 
 public:
-  typedef RegionInfo Result;
+  using Result = RegionInfo;
 
   RegionInfo run(Function &F, FunctionAnalysisManager &AM);
 };
@@ -967,6 +980,7 @@ class RegionInfoPrinterPass : public Pas
 
 public:
   explicit RegionInfoPrinterPass(raw_ostream &OS);
+
   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
 };
 
@@ -995,8 +1009,8 @@ RegionNodeBase<RegionTraits<Function>>::
 template <class Tr>
 inline raw_ostream &operator<<(raw_ostream &OS,
                                const RegionNodeBase<Tr> &Node) {
-  typedef typename Tr::BlockT BlockT;
-  typedef typename Tr::RegionT RegionT;
+  using BlockT = typename Tr::BlockT;
+  using RegionT = typename Tr::RegionT;
 
   if (Node.isSubRegion())
     return OS << Node.template getNodeAs<RegionT>()->getNameStr();
@@ -1008,5 +1022,6 @@ extern template class RegionBase<RegionT
 extern template class RegionNodeBase<RegionTraits<Function>>;
 extern template class RegionInfoBase<RegionTraits<Function>>;
 
-} // End llvm namespace
-#endif
+} // end namespace llvm
+
+#endif // LLVM_ANALYSIS_REGIONINFO_H

Modified: llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h?rev=306472&r1=306471&r2=306472&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h Tue Jun 27 14:52:05 2017
@@ -12,7 +12,11 @@
 #ifndef LLVM_ANALYSIS_REGIONINFOIMPL_H
 #define LLVM_ANALYSIS_REGIONINFOIMPL_H
 
+#include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/PostOrderIterator.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/iterator_range.h"
 #include "llvm/Analysis/DominanceFrontier.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/PostDominators.h"
@@ -20,9 +24,15 @@
 #include "llvm/Analysis/RegionIterator.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
 #include <algorithm>
+#include <cassert>
 #include <iterator>
+#include <memory>
 #include <set>
+#include <string>
+#include <type_traits>
+#include <vector>
 
 namespace llvm {
 
@@ -303,7 +313,8 @@ RegionBase<Tr>::element_end() const {
 
 template <class Tr>
 typename Tr::RegionT *RegionBase<Tr>::getSubRegionNode(BlockT *BB) const {
-  typedef typename Tr::RegionT RegionT;
+  using RegionT = typename Tr::RegionT;
+
   RegionT *R = RI->getRegionFor(BB);
 
   if (!R || R == this)
@@ -330,7 +341,8 @@ typename Tr::RegionNodeT *RegionBase<Tr>
   if (at == BBNodeMap.end()) {
     auto Deconst = const_cast<RegionBase<Tr> *>(this);
     typename BBNodeMapT::value_type V = {
-        BB, make_unique<RegionNodeT>(static_cast<RegionT *>(Deconst), BB)};
+        BB,
+        llvm::make_unique<RegionNodeT>(static_cast<RegionT *>(Deconst), BB)};
     at = BBNodeMap.insert(std::move(V)).first;
   }
   return at->second.get();
@@ -357,10 +369,10 @@ void RegionBase<Tr>::transferChildrenTo(
 template <class Tr>
 void RegionBase<Tr>::addSubRegion(RegionT *SubRegion, bool moveChildren) {
   assert(!SubRegion->parent && "SubRegion already has a parent!");
-  assert(find_if(*this,
-                 [&](const std::unique_ptr<RegionT> &R) {
-                   return R.get() == SubRegion;
-                 }) == children.end() &&
+  assert(llvm::find_if(*this,
+                       [&](const std::unique_ptr<RegionT> &R) {
+                         return R.get() == SubRegion;
+                       }) == children.end() &&
          "Subregion already exists!");
 
   SubRegion->parent = static_cast<RegionT *>(this);
@@ -402,7 +414,7 @@ typename Tr::RegionT *RegionBase<Tr>::re
   assert(Child->parent == this && "Child is not a child of this region!");
   Child->parent = nullptr;
   typename RegionSet::iterator I =
-      find_if(children, [&](const std::unique_ptr<RegionT> &R) {
+      llvm::find_if(children, [&](const std::unique_ptr<RegionT> &R) {
         return R.get() == Child;
       });
   assert(I != children.end() && "Region does not exit. Unable to remove.");
@@ -505,8 +517,7 @@ void RegionBase<Tr>::clearNodeCache() {
 //
 
 template <class Tr>
-RegionInfoBase<Tr>::RegionInfoBase()
-    : TopLevelRegion(nullptr) {}
+RegionInfoBase<Tr>::RegionInfoBase() = default;
 
 template <class Tr>
 RegionInfoBase<Tr>::~RegionInfoBase() {
@@ -543,7 +554,8 @@ bool RegionInfoBase<Tr>::isCommonDomFron
 template <class Tr>
 bool RegionInfoBase<Tr>::isRegion(BlockT *entry, BlockT *exit) const {
   assert(entry && exit && "entry and exit must not be null!");
-  typedef typename DomFrontierT::DomSetType DST;
+
+  using DST = typename DomFrontierT::DomSetType;
 
   DST *entrySuccs = &DF->find(entry)->second;
 
@@ -689,7 +701,8 @@ void RegionInfoBase<Tr>::findRegionsWith
 
 template <class Tr>
 void RegionInfoBase<Tr>::scanForRegions(FuncT &F, BBtoBBMap *ShortCut) {
-  typedef typename std::add_pointer<FuncT>::type FuncPtrT;
+  using FuncPtrT = typename std::add_pointer<FuncT>::type;
+
   BlockT *entry = GraphTraits<FuncPtrT>::getEntryNode(&F);
   DomTreeNodeT *N = DT->getNode(entry);
 
@@ -876,7 +889,7 @@ RegionInfoBase<Tr>::getCommonRegion(Smal
 
 template <class Tr>
 void RegionInfoBase<Tr>::calculate(FuncT &F) {
-  typedef typename std::add_pointer<FuncT>::type FuncPtrT;
+  using FuncPtrT = typename std::add_pointer<FuncT>::type;
 
   // ShortCut a function where for every BB the exit of the largest region
   // starting with BB is stored. These regions can be threated as single BBS.
@@ -892,4 +905,4 @@ void RegionInfoBase<Tr>::calculate(FuncT
 
 } // end namespace llvm
 
-#endif
+#endif // LLVM_ANALYSIS_REGIONINFOIMPL_H

Modified: llvm/trunk/include/llvm/Analysis/RegionIterator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/RegionIterator.h?rev=306472&r1=306471&r2=306472&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/RegionIterator.h (original)
+++ llvm/trunk/include/llvm/Analysis/RegionIterator.h Tue Jun 27 14:52:05 2017
@@ -8,17 +8,23 @@
 //===----------------------------------------------------------------------===//
 // This file defines the iterators to iterate over the elements of a Region.
 //===----------------------------------------------------------------------===//
+
 #ifndef LLVM_ANALYSIS_REGIONITERATOR_H
 #define LLVM_ANALYSIS_REGIONITERATOR_H
 
+#include "llvm/ADT/DepthFirstIterator.h"
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/PointerIntPair.h"
-#include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/Analysis/RegionInfo.h"
 #include "llvm/IR/CFG.h"
-#include "llvm/Support/raw_ostream.h"
+#include <cassert>
+#include <iterator>
+#include <type_traits>
 
 namespace llvm {
+
+class BasicBlock;
+
 //===----------------------------------------------------------------------===//
 /// @brief Hierarchical RegionNode successor iterator.
 ///
@@ -33,10 +39,9 @@ namespace llvm {
 template <class NodeRef, class BlockT, class RegionT>
 class RNSuccIterator
     : public std::iterator<std::forward_iterator_tag, NodeRef> {
-  typedef std::iterator<std::forward_iterator_tag, NodeRef> super;
-
-  typedef GraphTraits<BlockT*> BlockTraits;
-  typedef typename BlockTraits::ChildIteratorType SuccIterTy;
+  using super = std::iterator<std::forward_iterator_tag, NodeRef>;
+  using BlockTraits = GraphTraits<BlockT *>;
+  using SuccIterTy = typename BlockTraits::ChildIteratorType;
 
   // The iterator works in two modes, bb mode or region mode.
   enum ItMode {
@@ -92,16 +97,15 @@ class RNSuccIterator
   inline bool isExit(BlockT* BB) const {
     return getNode()->getParent()->getExit() == BB;
   }
-public:
-  typedef RNSuccIterator<NodeRef, BlockT, RegionT> Self;
 
-  typedef typename super::value_type value_type;
+public:
+  using Self = RNSuccIterator<NodeRef, BlockT, RegionT>;
+  using value_type = typename super::value_type;
 
   /// @brief Create begin iterator of a RegionNode.
   inline RNSuccIterator(NodeRef node)
       : Node(node, node->isSubRegion() ? ItRgBegin : ItBB),
         BItor(BlockTraits::child_begin(node->getEntry())) {
-
     // Skip the exit block
     if (!isRegionMode())
       while (BlockTraits::child_end(node->getEntry()) != BItor && isExit(*BItor))
@@ -153,7 +157,6 @@ public:
   }
 };
 
-
 //===----------------------------------------------------------------------===//
 /// @brief Flat RegionNode iterator.
 ///
@@ -163,16 +166,16 @@ public:
 template <class NodeRef, class BlockT, class RegionT>
 class RNSuccIterator<FlatIt<NodeRef>, BlockT, RegionT>
     : public std::iterator<std::forward_iterator_tag, NodeRef> {
-  typedef std::iterator<std::forward_iterator_tag, NodeRef> super;
-  typedef GraphTraits<BlockT*> BlockTraits;
-  typedef typename BlockTraits::ChildIteratorType SuccIterTy;
+  using super = std::iterator<std::forward_iterator_tag, NodeRef>;
+  using BlockTraits = GraphTraits<BlockT *>;
+  using SuccIterTy = typename BlockTraits::ChildIteratorType;
 
   NodeRef Node;
   SuccIterTy Itor;
 
 public:
-  typedef RNSuccIterator<FlatIt<NodeRef>, BlockT, RegionT> Self;
-  typedef typename super::value_type value_type;
+  using Self = RNSuccIterator<FlatIt<NodeRef>, BlockT, RegionT>;
+  using value_type = typename super::value_type;
 
   /// @brief Create the iterator from a RegionNode.
   ///
@@ -255,8 +258,8 @@ inline RNSuccIterator<NodeRef, BlockT, R
 
 #define RegionNodeGraphTraits(NodeT, BlockT, RegionT)                          \
   template <> struct GraphTraits<NodeT *> {                                    \
-    typedef NodeT *NodeRef;                                                    \
-    typedef RNSuccIterator<NodeRef, BlockT, RegionT> ChildIteratorType;        \
+    using NodeRef = NodeT *;                                                   \
+    using ChildIteratorType = RNSuccIterator<NodeRef, BlockT, RegionT>;        \
     static NodeRef getEntryNode(NodeRef N) { return N; }                       \
     static inline ChildIteratorType child_begin(NodeRef N) {                   \
       return RNSuccIterator<NodeRef, BlockT, RegionT>(N);                      \
@@ -266,9 +269,9 @@ inline RNSuccIterator<NodeRef, BlockT, R
     }                                                                          \
   };                                                                           \
   template <> struct GraphTraits<FlatIt<NodeT *>> {                            \
-    typedef NodeT *NodeRef;                                                    \
-    typedef RNSuccIterator<FlatIt<NodeRef>, BlockT, RegionT>                   \
-        ChildIteratorType;                                                     \
+    using NodeRef = NodeT *;                                                   \
+    using ChildIteratorType =                                                  \
+        RNSuccIterator<FlatIt<NodeRef>, BlockT, RegionT>;		       \
     static NodeRef getEntryNode(NodeRef N) { return N; }                       \
     static inline ChildIteratorType child_begin(NodeRef N) {                   \
       return RNSuccIterator<FlatIt<NodeRef>, BlockT, RegionT>(N);              \
@@ -280,7 +283,7 @@ inline RNSuccIterator<NodeRef, BlockT, R
 
 #define RegionGraphTraits(RegionT, NodeT)                                      \
   template <> struct GraphTraits<RegionT *> : public GraphTraits<NodeT *> {    \
-    typedef df_iterator<NodeRef> nodes_iterator;                               \
+    using nodes_iterator = df_iterator<NodeRef>;                               \
     static NodeRef getEntryNode(RegionT *R) {                                  \
       return R->getNode(R->getEntry());                                        \
     }                                                                          \
@@ -294,9 +297,9 @@ inline RNSuccIterator<NodeRef, BlockT, R
   template <>                                                                  \
   struct GraphTraits<FlatIt<RegionT *>>                                        \
       : public GraphTraits<FlatIt<NodeT *>> {                                  \
-    typedef df_iterator<NodeRef, df_iterator_default_set<NodeRef>, false,      \
-                        GraphTraits<FlatIt<NodeRef>>>                          \
-        nodes_iterator;                                                        \
+    using nodes_iterator =                                                     \
+        df_iterator<NodeRef, df_iterator_default_set<NodeRef>, false,          \
+                    GraphTraits<FlatIt<NodeRef>>>;                             \
     static NodeRef getEntryNode(RegionT *R) {                                  \
       return R->getBBNode(R->getEntry());                                      \
     }                                                                          \
@@ -315,17 +318,19 @@ RegionGraphTraits(Region, RegionNode);
 RegionGraphTraits(const Region, const RegionNode);
 
 template <> struct GraphTraits<RegionInfo*>
-  : public GraphTraits<FlatIt<RegionNode*> > {
-  typedef df_iterator<NodeRef, df_iterator_default_set<NodeRef>, false,
-                      GraphTraits<FlatIt<NodeRef>>>
-      nodes_iterator;
+  : public GraphTraits<FlatIt<RegionNode*>> {
+  using nodes_iterator =
+      df_iterator<NodeRef, df_iterator_default_set<NodeRef>, false,
+                  GraphTraits<FlatIt<NodeRef>>>;
 
   static NodeRef getEntryNode(RegionInfo *RI) {
-    return GraphTraits<FlatIt<Region*> >::getEntryNode(RI->getTopLevelRegion());
+    return GraphTraits<FlatIt<Region*>>::getEntryNode(RI->getTopLevelRegion());
   }
+
   static nodes_iterator nodes_begin(RegionInfo* RI) {
     return nodes_iterator::begin(getEntryNode(RI));
   }
+
   static nodes_iterator nodes_end(RegionInfo *RI) {
     return nodes_iterator::end(getEntryNode(RI));
   }
@@ -333,21 +338,23 @@ template <> struct GraphTraits<RegionInf
 
 template <> struct GraphTraits<RegionInfoPass*>
   : public GraphTraits<RegionInfo *> {
-  typedef df_iterator<NodeRef, df_iterator_default_set<NodeRef>, false,
-                      GraphTraits<FlatIt<NodeRef>>>
-      nodes_iterator;
+  using nodes_iterator =
+      df_iterator<NodeRef, df_iterator_default_set<NodeRef>, false,
+                  GraphTraits<FlatIt<NodeRef>>>;
 
   static NodeRef getEntryNode(RegionInfoPass *RI) {
     return GraphTraits<RegionInfo*>::getEntryNode(&RI->getRegionInfo());
   }
+
   static nodes_iterator nodes_begin(RegionInfoPass* RI) {
     return GraphTraits<RegionInfo*>::nodes_begin(&RI->getRegionInfo());
   }
+
   static nodes_iterator nodes_end(RegionInfoPass *RI) {
     return GraphTraits<RegionInfo*>::nodes_end(&RI->getRegionInfo());
   }
 };
 
-} // End namespace llvm
+} // end namespace llvm
 
-#endif
+#endif // LLVM_ANALYSIS_REGIONITERATOR_H

Modified: llvm/trunk/lib/Analysis/RegionInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/RegionInfo.cpp?rev=306472&r1=306471&r2=306472&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/RegionInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/RegionInfo.cpp Tue Jun 27 14:52:05 2017
@@ -10,28 +10,29 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/Analysis/RegionInfo.h"
-#include "llvm/ADT/PostOrderIterator.h"
 #include "llvm/ADT/Statistic.h"
-#include "llvm/Analysis/LoopInfo.h"
-#include "llvm/Analysis/RegionInfoImpl.h"
-#include "llvm/Analysis/RegionIterator.h"
-#include "llvm/IR/PassManager.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/Debug.h"
-#include "llvm/Support/ErrorHandling.h"
 #ifndef NDEBUG
 #include "llvm/Analysis/RegionPrinter.h"
 #endif
+#include "llvm/Analysis/RegionInfoImpl.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/Pass.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
 
 #define DEBUG_TYPE "region"
 
 namespace llvm {
+
 template class RegionBase<RegionTraits<Function>>;
 template class RegionNodeBase<RegionTraits<Function>>;
 template class RegionInfoBase<RegionTraits<Function>>;
-}
+
+} // end namespace llvm
 
 STATISTIC(numRegions,       "The # of regions");
 STATISTIC(numSimpleRegions, "The # of simple regions");
@@ -44,7 +45,6 @@ VerifyRegionInfoX(
   cl::location(RegionInfoBase<RegionTraits<Function>>::VerifyRegionInfo),
   cl::desc("Verify region info (time consuming)"));
 
-
 static cl::opt<Region::PrintStyle, true> printStyleX("print-region-style",
   cl::location(RegionInfo::printStyle),
   cl::Hidden,
@@ -56,7 +56,6 @@ static cl::opt<Region::PrintStyle, true>
     clEnumValN(Region::PrintRN, "rn",
                "print regions in detail with element_iterator")));
 
-
 //===----------------------------------------------------------------------===//
 // Region implementation
 //
@@ -68,20 +67,15 @@ Region::Region(BasicBlock *Entry, BasicB
 
 }
 
-Region::~Region() { }
+Region::~Region() = default;
 
 //===----------------------------------------------------------------------===//
 // RegionInfo implementation
 //
 
-RegionInfo::RegionInfo() :
-  RegionInfoBase<RegionTraits<Function>>() {
-
-}
+RegionInfo::RegionInfo() = default;
 
-RegionInfo::~RegionInfo() {
-
-}
+RegionInfo::~RegionInfo() = default;
 
 bool RegionInfo::invalidate(Function &F, const PreservedAnalyses &PA,
                             FunctionAnalysisManager::Invalidator &) {
@@ -126,9 +120,7 @@ RegionInfoPass::RegionInfoPass() : Funct
   initializeRegionInfoPassPass(*PassRegistry::getPassRegistry());
 }
 
-RegionInfoPass::~RegionInfoPass() {
-
-}
+RegionInfoPass::~RegionInfoPass() = default;
 
 bool RegionInfoPass::runOnFunction(Function &F) {
   releaseMemory();
@@ -181,10 +173,12 @@ INITIALIZE_PASS_END(RegionInfoPass, "reg
 // the link time optimization.
 
 namespace llvm {
+
   FunctionPass *createRegionInfoPass() {
     return new RegionInfoPass();
   }
-}
+
+} // end namespace llvm
 
 //===----------------------------------------------------------------------===//
 // RegionInfoAnalysis implementation




More information about the llvm-commits mailing list