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

llvm-svn: 310766
diff --git a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp
index 1a39988..076a2b2 100644
--- a/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/CFLAndersAliasAnalysis.cpp
@@ -1,4 +1,4 @@
-//- CFLAndersAliasAnalysis.cpp - Unification-based Alias Analysis ---*- C++-*-//
+//===- CFLAndersAliasAnalysis.cpp - Unification-based Alias Analysis ------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -54,9 +54,35 @@
 // FunctionPasses to run concurrently.
 
 #include "llvm/Analysis/CFLAndersAliasAnalysis.h"
+#include "AliasAnalysisSummary.h"
 #include "CFLGraph.h"
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseMapInfo.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Analysis/AliasAnalysis.h"
+#include "llvm/Analysis/MemoryLocation.h"
+#include "llvm/IR/Argument.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/PassManager.h"
+#include "llvm/IR/Type.h"
 #include "llvm/Pass.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <bitset>
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <functional>
+#include <utility>
+#include <vector>
 
 using namespace llvm;
 using namespace llvm::cflaa;
@@ -66,7 +92,7 @@
 CFLAndersAAResult::CFLAndersAAResult(const TargetLibraryInfo &TLI) : TLI(TLI) {}
 CFLAndersAAResult::CFLAndersAAResult(CFLAndersAAResult &&RHS)
     : AAResultBase(std::move(RHS)), TLI(RHS.TLI) {}
-CFLAndersAAResult::~CFLAndersAAResult() {}
+CFLAndersAAResult::~CFLAndersAAResult() = default;
 
 namespace {
 
@@ -95,7 +121,8 @@
   FlowToMemAliasReadWrite,
 };
 
-typedef std::bitset<7> StateSet;
+using StateSet = std::bitset<7>;
+
 const unsigned ReadOnlyStateMask =
     (1U << static_cast<uint8_t>(MatchState::FlowFromReadOnly)) |
     (1U << static_cast<uint8_t>(MatchState::FlowFromMemAliasReadOnly));
@@ -130,13 +157,14 @@
 // We use ReachabilitySet to keep track of value aliases (The nonterminal "V" in
 // the paper) during the analysis.
 class ReachabilitySet {
-  typedef DenseMap<InstantiatedValue, StateSet> ValueStateMap;
-  typedef DenseMap<InstantiatedValue, ValueStateMap> ValueReachMap;
+  using ValueStateMap = DenseMap<InstantiatedValue, StateSet>;
+  using ValueReachMap = DenseMap<InstantiatedValue, ValueStateMap>;
+
   ValueReachMap ReachMap;
 
 public:
-  typedef ValueStateMap::const_iterator const_valuestate_iterator;
-  typedef ValueReachMap::const_iterator const_value_iterator;
+  using const_valuestate_iterator = ValueStateMap::const_iterator;
+  using const_value_iterator = ValueReachMap::const_iterator;
 
   // Insert edge 'From->To' at state 'State'
   bool insert(InstantiatedValue From, InstantiatedValue To, MatchState State) {
@@ -169,12 +197,13 @@
 // We use AliasMemSet to keep track of all memory aliases (the nonterminal "M"
 // in the paper) during the analysis.
 class AliasMemSet {
-  typedef DenseSet<InstantiatedValue> MemSet;
-  typedef DenseMap<InstantiatedValue, MemSet> MemMapType;
+  using MemSet = DenseSet<InstantiatedValue>;
+  using MemMapType = DenseMap<InstantiatedValue, MemSet>;
+
   MemMapType MemMap;
 
 public:
-  typedef MemSet::const_iterator const_mem_iterator;
+  using const_mem_iterator = MemSet::const_iterator;
 
   bool insert(InstantiatedValue LHS, InstantiatedValue RHS) {
     // Top-level values can never be memory aliases because one cannot take the
@@ -193,11 +222,12 @@
 
 // We use AliasAttrMap to keep track of the AliasAttr of each node.
 class AliasAttrMap {
-  typedef DenseMap<InstantiatedValue, AliasAttrs> MapType;
+  using MapType = DenseMap<InstantiatedValue, AliasAttrs>;
+
   MapType AttrMap;
 
 public:
-  typedef MapType::const_iterator const_iterator;
+  using const_iterator = MapType::const_iterator;
 
   bool add(InstantiatedValue V, AliasAttrs Attr) {
     auto &OldAttr = AttrMap[V];
@@ -234,23 +264,28 @@
   };
   SmallVector<Record, 4> FromRecords, ToRecords;
 };
-}
+
+} // end anonymous namespace
 
 namespace llvm {
+
 // Specialize DenseMapInfo for OffsetValue.
 template <> struct DenseMapInfo<OffsetValue> {
   static OffsetValue getEmptyKey() {
     return OffsetValue{DenseMapInfo<const Value *>::getEmptyKey(),
                        DenseMapInfo<int64_t>::getEmptyKey()};
   }
+
   static OffsetValue getTombstoneKey() {
     return OffsetValue{DenseMapInfo<const Value *>::getTombstoneKey(),
                        DenseMapInfo<int64_t>::getEmptyKey()};
   }
+
   static unsigned getHashValue(const OffsetValue &OVal) {
     return DenseMapInfo<std::pair<const Value *, int64_t>>::getHashValue(
         std::make_pair(OVal.Val, OVal.Offset));
   }
+
   static bool isEqual(const OffsetValue &LHS, const OffsetValue &RHS) {
     return LHS == RHS;
   }
@@ -263,21 +298,25 @@
         DenseMapInfo<InstantiatedValue>::getEmptyKey(),
         DenseMapInfo<int64_t>::getEmptyKey()};
   }
+
   static OffsetInstantiatedValue getTombstoneKey() {
     return OffsetInstantiatedValue{
         DenseMapInfo<InstantiatedValue>::getTombstoneKey(),
         DenseMapInfo<int64_t>::getEmptyKey()};
   }
+
   static unsigned getHashValue(const OffsetInstantiatedValue &OVal) {
     return DenseMapInfo<std::pair<InstantiatedValue, int64_t>>::getHashValue(
         std::make_pair(OVal.IVal, OVal.Offset));
   }
+
   static bool isEqual(const OffsetInstantiatedValue &LHS,
                       const OffsetInstantiatedValue &RHS) {
     return LHS == RHS;
   }
 };
-}
+
+} // end namespace llvm
 
 class CFLAndersAAResult::FunctionInfo {
   /// Map a value to other values that may alias it
@@ -654,41 +693,40 @@
   };
 
   switch (Item.State) {
-  case MatchState::FlowFromReadOnly: {
+  case MatchState::FlowFromReadOnly:
     NextRevAssignState(MatchState::FlowFromReadOnly);
     NextAssignState(MatchState::FlowToReadWrite);
     NextMemState(MatchState::FlowFromMemAliasReadOnly);
     break;
-  }
-  case MatchState::FlowFromMemAliasNoReadWrite: {
+
+  case MatchState::FlowFromMemAliasNoReadWrite:
     NextRevAssignState(MatchState::FlowFromReadOnly);
     NextAssignState(MatchState::FlowToWriteOnly);
     break;
-  }
-  case MatchState::FlowFromMemAliasReadOnly: {
+
+  case MatchState::FlowFromMemAliasReadOnly:
     NextRevAssignState(MatchState::FlowFromReadOnly);
     NextAssignState(MatchState::FlowToReadWrite);
     break;
-  }
-  case MatchState::FlowToWriteOnly: {
+
+  case MatchState::FlowToWriteOnly:
     NextAssignState(MatchState::FlowToWriteOnly);
     NextMemState(MatchState::FlowToMemAliasWriteOnly);
     break;
-  }
-  case MatchState::FlowToReadWrite: {
+
+  case MatchState::FlowToReadWrite:
     NextAssignState(MatchState::FlowToReadWrite);
     NextMemState(MatchState::FlowToMemAliasReadWrite);
     break;
-  }
-  case MatchState::FlowToMemAliasWriteOnly: {
+
+  case MatchState::FlowToMemAliasWriteOnly:
     NextAssignState(MatchState::FlowToWriteOnly);
     break;
-  }
-  case MatchState::FlowToMemAliasReadWrite: {
+
+  case MatchState::FlowToMemAliasReadWrite:
     NextAssignState(MatchState::FlowToReadWrite);
     break;
   }
-  }
 }
 
 static AliasAttrMap buildAttrMap(const CFLGraph &Graph,