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

llvm-svn: 318582
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 182a8b4..262a1e3 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -1,4 +1,4 @@
-//===--- ExprCXX.cpp - (C++) Expression AST Node Implementation -----------===//
+//===- ExprCXX.cpp - (C++) Expression AST Node Implementation -------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -11,15 +11,33 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclAccessPair.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclCXX.h"
-#include "clang/AST/DeclTemplate.h"
-#include "clang/AST/ExprCXX.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/LambdaCapture.h"
+#include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/TemplateBase.h"
+#include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
-#include "clang/Basic/IdentifierTable.h"
-using namespace clang;
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Specifiers.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
+#include <cassert>
+#include <cstddef>
+#include <cstring>
+#include <memory>
 
+using namespace clang;
 
 //===----------------------------------------------------------------------===//
 //  Child Iterators for iterating over subexpressions/substatements
@@ -85,15 +103,14 @@
                        Expr *initializer, QualType ty,
                        TypeSourceInfo *allocatedTypeInfo,
                        SourceRange Range, SourceRange directInitRange)
-  : Expr(CXXNewExprClass, ty, VK_RValue, OK_Ordinary,
-         ty->isDependentType(), ty->isDependentType(),
-         ty->isInstantiationDependentType(),
-         ty->containsUnexpandedParameterPack()),
-    SubExprs(nullptr), OperatorNew(operatorNew), OperatorDelete(operatorDelete),
-    AllocatedTypeInfo(allocatedTypeInfo), TypeIdParens(typeIdParens),
-    Range(Range), DirectInitRange(directInitRange),
-    GlobalNew(globalNew), PassAlignment(PassAlignment),
-    UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) {
+    : Expr(CXXNewExprClass, ty, VK_RValue, OK_Ordinary, ty->isDependentType(),
+           ty->isDependentType(), ty->isInstantiationDependentType(),
+           ty->containsUnexpandedParameterPack()),
+      OperatorNew(operatorNew), OperatorDelete(operatorDelete),
+      AllocatedTypeInfo(allocatedTypeInfo), TypeIdParens(typeIdParens),
+      Range(Range), DirectInitRange(directInitRange), GlobalNew(globalNew),
+      PassAlignment(PassAlignment),
+      UsualArrayDeleteWantsSize(usualArrayDeleteWantsSize) {
   assert((initializer != nullptr || initializationStyle == NoInit) &&
          "Only NoInit can have no initializer.");
   StoredInitializationStyle = initializer ? initializationStyle + 1 : 0;
@@ -187,8 +204,7 @@
 
 // CXXPseudoDestructorExpr
 PseudoDestructorTypeStorage::PseudoDestructorTypeStorage(TypeSourceInfo *Info)
- : Type(Info) 
-{
+    : Type(Info) {
   Location = Info->getTypeLoc().getLocalSourceRange().getBegin();
 }
 
@@ -225,7 +241,7 @@
     Base(static_cast<Stmt *>(Base)), IsArrow(isArrow),
     OperatorLoc(OperatorLoc), QualifierLoc(QualifierLoc),
     ScopeType(ScopeType), ColonColonLoc(ColonColonLoc), TildeLoc(TildeLoc),
-    DestroyedType(DestroyedType) { }
+    DestroyedType(DestroyedType) {}
 
 QualType CXXPseudoDestructorExpr::getDestroyedType() const {
   if (TypeSourceInfo *TInfo = DestroyedType.getTypeSourceInfo())
@@ -251,8 +267,7 @@
                              bool ADL,
                              const TemplateArgumentListInfo *Args,
                              UnresolvedSetIterator Begin,
-                             UnresolvedSetIterator End)
-{
+                             UnresolvedSetIterator End) {
   assert(Args || TemplateKWLoc.isValid());
   unsigned num_args = Args ? Args->size() : 0;
 
@@ -290,21 +305,20 @@
                            bool KnownDependent,
                            bool KnownInstantiationDependent,
                            bool KnownContainsUnexpandedParameterPack)
-  : Expr(K, C.OverloadTy, VK_LValue, OK_Ordinary, KnownDependent, 
-         KnownDependent,
-         (KnownInstantiationDependent ||
-          NameInfo.isInstantiationDependent() ||
-          (QualifierLoc &&
-           QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())),
-         (KnownContainsUnexpandedParameterPack ||
-          NameInfo.containsUnexpandedParameterPack() ||
-          (QualifierLoc && 
-           QualifierLoc.getNestedNameSpecifier()
-                                      ->containsUnexpandedParameterPack()))),
-    NameInfo(NameInfo), QualifierLoc(QualifierLoc),
-    Results(nullptr), NumResults(End - Begin),
-    HasTemplateKWAndArgsInfo(TemplateArgs != nullptr ||
-                             TemplateKWLoc.isValid()) {
+    : Expr(K, C.OverloadTy, VK_LValue, OK_Ordinary, KnownDependent,
+           KnownDependent,
+           (KnownInstantiationDependent ||
+            NameInfo.isInstantiationDependent() ||
+            (QualifierLoc &&
+            QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent())),
+           (KnownContainsUnexpandedParameterPack ||
+            NameInfo.containsUnexpandedParameterPack() ||
+            (QualifierLoc &&
+             QualifierLoc.getNestedNameSpecifier()
+                                        ->containsUnexpandedParameterPack()))),
+      NameInfo(NameInfo), QualifierLoc(QualifierLoc), NumResults(End - Begin),
+      HasTemplateKWAndArgsInfo(TemplateArgs != nullptr ||
+                               TemplateKWLoc.isValid()) {
   NumResults = End - Begin;
   if (NumResults) {
     // Determine whether this expression is type-dependent.
@@ -509,7 +523,6 @@
   return nullptr;
 }
 
-
 CXXRecordDecl *CXXMemberCallExpr::getRecordDecl() const {
   Expr* ThisArg = getImplicitObjectArgument();
   if (!ThisArg)
@@ -521,7 +534,6 @@
   return ThisArg->getType()->getAsCXXRecordDecl();
 }
 
-
 //===----------------------------------------------------------------------===//
 //  Named casts
 //===----------------------------------------------------------------------===//
@@ -758,16 +770,12 @@
                                                bool ListInitialization,
                                                bool StdInitListInitialization,
                                                bool ZeroInitialization)
-  : CXXConstructExpr(C, CXXTemporaryObjectExprClass, Type,
-                     TSI->getTypeLoc().getBeginLoc(),
-                     Cons, false, Args,
-                     HadMultipleCandidates,
-                     ListInitialization,
-                     StdInitListInitialization,
-                     ZeroInitialization,
-                     CXXConstructExpr::CK_Complete, ParenOrBraceRange),
-    Type(TSI) {
-}
+    : CXXConstructExpr(C, CXXTemporaryObjectExprClass, Type,
+                       TSI->getTypeLoc().getBeginLoc(), Cons, false, Args,
+                       HadMultipleCandidates, ListInitialization,
+                       StdInitListInitialization,  ZeroInitialization,
+                       CXXConstructExpr::CK_Complete, ParenOrBraceRange),
+      Type(TSI) {}
 
 SourceLocation CXXTemporaryObjectExpr::getLocStart() const {
   return Type->getTypeLoc().getBeginLoc();
@@ -810,18 +818,16 @@
                                    bool ZeroInitialization,
                                    ConstructionKind ConstructKind,
                                    SourceRange ParenOrBraceRange)
-  : Expr(SC, T, VK_RValue, OK_Ordinary,
-         T->isDependentType(), T->isDependentType(),
-         T->isInstantiationDependentType(),
-         T->containsUnexpandedParameterPack()),
-    Constructor(Ctor), Loc(Loc), ParenOrBraceRange(ParenOrBraceRange),
-    NumArgs(Args.size()),
-    Elidable(Elidable), HadMultipleCandidates(HadMultipleCandidates),
-    ListInitialization(ListInitialization),
-    StdInitListInitialization(StdInitListInitialization),
-    ZeroInitialization(ZeroInitialization),
-    ConstructKind(ConstructKind), Args(nullptr)
-{
+    : Expr(SC, T, VK_RValue, OK_Ordinary,
+           T->isDependentType(), T->isDependentType(),
+           T->isInstantiationDependentType(),
+           T->containsUnexpandedParameterPack()),
+      Constructor(Ctor), Loc(Loc), ParenOrBraceRange(ParenOrBraceRange),
+      NumArgs(Args.size()), Elidable(Elidable),
+      HadMultipleCandidates(HadMultipleCandidates),
+      ListInitialization(ListInitialization),
+      StdInitListInitialization(StdInitListInitialization),
+      ZeroInitialization(ZeroInitialization), ConstructKind(ConstructKind) {
   if (NumArgs) {
     this->Args = new (C) Stmt*[Args.size()];
     
@@ -843,8 +849,7 @@
 LambdaCapture::LambdaCapture(SourceLocation Loc, bool Implicit,
                              LambdaCaptureKind Kind, VarDecl *Var,
                              SourceLocation EllipsisLoc)
-  : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc)
-{
+    : DeclAndBits(Var, 0), Loc(Loc), EllipsisLoc(EllipsisLoc) {
   unsigned Bits = 0;
   if (Implicit)
     Bits |= Capture_Implicit;
@@ -1011,7 +1016,7 @@
   // initialized in ASTStmtReader::VisitLambdaExpr, but for reasons I
   // don't understand, that doesn't work.
   if (!getStoredStmts()[NumCaptures])
-    *const_cast<clang::Stmt **>(&getStoredStmts()[NumCaptures]) =
+    *const_cast<Stmt **>(&getStoredStmts()[NumCaptures]) =
         getCallOperator()->getBody();
 
   return static_cast<CompoundStmt *>(getStoredStmts()[NumCaptures]);
@@ -1024,12 +1029,12 @@
 ExprWithCleanups::ExprWithCleanups(Expr *subexpr,
                                    bool CleanupsHaveSideEffects,
                                    ArrayRef<CleanupObject> objects)
-  : Expr(ExprWithCleanupsClass, subexpr->getType(),
-         subexpr->getValueKind(), subexpr->getObjectKind(),
-         subexpr->isTypeDependent(), subexpr->isValueDependent(),
-         subexpr->isInstantiationDependent(),
-         subexpr->containsUnexpandedParameterPack()),
-    SubExpr(subexpr) {
+    : Expr(ExprWithCleanupsClass, subexpr->getType(),
+           subexpr->getValueKind(), subexpr->getObjectKind(),
+           subexpr->isTypeDependent(), subexpr->isValueDependent(),
+           subexpr->isInstantiationDependent(),
+           subexpr->containsUnexpandedParameterPack()),
+      SubExpr(subexpr) {
   ExprWithCleanupsBits.CleanupsHaveSideEffects = CleanupsHaveSideEffects;
   ExprWithCleanupsBits.NumObjects = objects.size();
   for (unsigned i = 0, e = objects.size(); i != e; ++i)
@@ -1046,7 +1051,7 @@
 }
 
 ExprWithCleanups::ExprWithCleanups(EmptyShell empty, unsigned numObjects)
-  : Expr(ExprWithCleanupsClass, empty) {
+    : Expr(ExprWithCleanupsClass, empty) {
   ExprWithCleanupsBits.NumObjects = numObjects;
 }
 
@@ -1062,20 +1067,18 @@
                                                  SourceLocation LParenLoc,
                                                  ArrayRef<Expr*> Args,
                                                  SourceLocation RParenLoc)
-  : Expr(CXXUnresolvedConstructExprClass, 
-         Type->getType().getNonReferenceType(),
-         (Type->getType()->isLValueReferenceType() ? VK_LValue
-          :Type->getType()->isRValueReferenceType()? VK_XValue
-          :VK_RValue),
-         OK_Ordinary,
-         Type->getType()->isDependentType() ||
-             Type->getType()->getContainedDeducedType(),
-         true, true,
-         Type->getType()->containsUnexpandedParameterPack()),
-    Type(Type),
-    LParenLoc(LParenLoc),
-    RParenLoc(RParenLoc),
-    NumArgs(Args.size()) {
+    : Expr(CXXUnresolvedConstructExprClass,
+           Type->getType().getNonReferenceType(),
+           (Type->getType()->isLValueReferenceType()
+                ? VK_LValue
+                : Type->getType()->isRValueReferenceType() ? VK_XValue
+                                                           : VK_RValue),
+           OK_Ordinary,
+           Type->getType()->isDependentType() ||
+               Type->getType()->getContainedDeducedType(),
+           true, true, Type->getType()->containsUnexpandedParameterPack()),
+      Type(Type), LParenLoc(LParenLoc), RParenLoc(RParenLoc),
+      NumArgs(Args.size()) {
   Expr **StoredArgs = getTrailingObjects<Expr *>();
   for (unsigned I = 0; I != Args.size(); ++I) {
     if (Args[I]->containsUnexpandedParameterPack())
@@ -1175,7 +1178,7 @@
   void *Mem = C.Allocate(Size, alignof(CXXDependentScopeMemberExpr));
   CXXDependentScopeMemberExpr *E
     =  new (Mem) CXXDependentScopeMemberExpr(C, nullptr, QualType(),
-                                             0, SourceLocation(),
+                                             false, SourceLocation(),
                                              NestedNameSpecifierLoc(),
                                              SourceLocation(), nullptr,
                                              DeclarationNameInfo(), nullptr);
@@ -1218,19 +1221,18 @@
                                    const TemplateArgumentListInfo *TemplateArgs,
                                            UnresolvedSetIterator Begin, 
                                            UnresolvedSetIterator End)
-  : OverloadExpr(UnresolvedMemberExprClass, C, QualifierLoc, TemplateKWLoc,
-                 MemberNameInfo, TemplateArgs, Begin, End,
-                 // Dependent
-                 ((Base && Base->isTypeDependent()) ||
-                  BaseType->isDependentType()),
-                 ((Base && Base->isInstantiationDependent()) ||
-                   BaseType->isInstantiationDependentType()),
-                 // Contains unexpanded parameter pack
-                 ((Base && Base->containsUnexpandedParameterPack()) ||
-                  BaseType->containsUnexpandedParameterPack())),
-    IsArrow(IsArrow), HasUnresolvedUsing(HasUnresolvedUsing),
-    Base(Base), BaseType(BaseType), OperatorLoc(OperatorLoc) {
-
+    : OverloadExpr(
+          UnresolvedMemberExprClass, C, QualifierLoc, TemplateKWLoc,
+          MemberNameInfo, TemplateArgs, Begin, End,
+          // Dependent
+          ((Base && Base->isTypeDependent()) || BaseType->isDependentType()),
+          ((Base && Base->isInstantiationDependent()) ||
+           BaseType->isInstantiationDependentType()),
+          // Contains unexpanded parameter pack
+          ((Base && Base->containsUnexpandedParameterPack()) ||
+           BaseType->containsUnexpandedParameterPack())),
+      IsArrow(IsArrow), HasUnresolvedUsing(HasUnresolvedUsing), Base(Base),
+      BaseType(BaseType), OperatorLoc(OperatorLoc) {
   // Check whether all of the members are non-static member functions,
   // and if so, mark give this bound-member type instead of overload type.
   if (hasOnlyNonStaticMemberFunctions(Begin, End))
@@ -1331,10 +1333,10 @@
                                  NonTypeTemplateParmDecl *Param,
                                  SourceLocation NameLoc,
                                  const TemplateArgument &ArgPack)
-  : Expr(SubstNonTypeTemplateParmPackExprClass, T, VK_RValue, OK_Ordinary, 
-         true, true, true, true),
-    Param(Param), Arguments(ArgPack.pack_begin()), 
-    NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) { }
+    : Expr(SubstNonTypeTemplateParmPackExprClass, T, VK_RValue, OK_Ordinary,
+           true, true, true, true),
+      Param(Param), Arguments(ArgPack.pack_begin()),
+      NumArguments(ArgPack.pack_size()), NameLoc(NameLoc) {}
 
 TemplateArgument SubstNonTypeTemplateParmPackExpr::getArgumentPack() const {
   return TemplateArgument(llvm::makeArrayRef(Arguments, NumArguments));
@@ -1390,13 +1392,12 @@
                              ArrayRef<TypeSourceInfo *> Args,
                              SourceLocation RParenLoc,
                              bool Value)
-  : Expr(TypeTraitExprClass, T, VK_RValue, OK_Ordinary,
-         /*TypeDependent=*/false,
-         /*ValueDependent=*/false,
-         /*InstantiationDependent=*/false,
-         /*ContainsUnexpandedParameterPack=*/false),
-    Loc(Loc), RParenLoc(RParenLoc)
-{
+    : Expr(TypeTraitExprClass, T, VK_RValue, OK_Ordinary,
+           /*TypeDependent=*/false,
+           /*ValueDependent=*/false,
+           /*InstantiationDependent=*/false,
+           /*ContainsUnexpandedParameterPack=*/false),
+      Loc(Loc), RParenLoc(RParenLoc) {
   TypeTraitExprBits.Kind = Kind;
   TypeTraitExprBits.Value = Value;
   TypeTraitExprBits.NumArgs = Args.size();
@@ -1431,4 +1432,4 @@
   return new (Mem) TypeTraitExpr(EmptyShell());
 }
 
-void ArrayTypeTraitExpr::anchor() { }
+void ArrayTypeTraitExpr::anchor() {}