Eugene.Zelenko created this revision.
Eugene.Zelenko added reviewers: hans, aaron.ballman.
Eugene.Zelenko added a subscriber: cfe-commits.
Eugene.Zelenko set the repository for this revision to rL LLVM.

I fixed Clang-tidy modernize-use-auto warnings. Autos are also used for pointer 
variables assigned via casts. Patch includes other minor cleanups.

Build and regressions were fine on RHEL 6.

Repository:
  rL LLVM

http://reviews.llvm.org/D15338

Files:
  lib/AST/ASTContext.cpp

Index: lib/AST/ASTContext.cpp
===================================================================
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -80,35 +80,34 @@
     return nullptr;
 
   // User can not attach documentation to implicit instantiations.
-  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+  if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
     if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
       return nullptr;
   }
 
-  if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+  if (const auto *VD = dyn_cast<VarDecl>(D)) {
     if (VD->isStaticDataMember() &&
         VD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
       return nullptr;
   }
 
-  if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(D)) {
+  if (const auto *CRD = dyn_cast<CXXRecordDecl>(D)) {
     if (CRD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
       return nullptr;
   }
 
-  if (const ClassTemplateSpecializationDecl *CTSD =
-          dyn_cast<ClassTemplateSpecializationDecl>(D)) {
+  if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D)) {
     TemplateSpecializationKind TSK = CTSD->getSpecializationKind();
     if (TSK == TSK_ImplicitInstantiation ||
         TSK == TSK_Undeclared)
       return nullptr;
   }
 
-  if (const EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
+  if (const auto *ED = dyn_cast<EnumDecl>(D)) {
     if (ED->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
       return nullptr;
   }
-  if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
+  if (const auto *TD = dyn_cast<TagDecl>(D)) {
     // When tag declaration (but not definition!) is part of the
     // decl-specifier-seq of some other declaration, it doesn't get comment
     if (TD->isEmbeddedInDeclarator() && !TD->isCompleteDefinition())
@@ -151,7 +150,7 @@
         // declared via a macro. Try using declaration's starting location as
         // the "declaration location".
         DeclLoc = D->getLocStart();
-      } else if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
+      } else if (const auto *TD = dyn_cast<TagDecl>(D)) {
         // If location of the tag decl is inside a macro, but the spelling of
         // the tag name comes from a macro argument, it looks like a special
         // macro like NS_ENUM is being used to define the tag decl.  In that
@@ -261,7 +260,7 @@
 /// refer to the actual template.
 /// If we have an implicit instantiation, adjust 'D' to refer to template.
 const Decl *adjustDeclToTemplate(const Decl *D) {
-  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+  if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
     // Is this function declaration part of a function template?
     if (const FunctionTemplateDecl *FTD = FD->getDescribedFunctionTemplate())
       return FTD;
@@ -281,7 +280,7 @@
 
     return D;
   }
-  if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+  if (const auto *VD = dyn_cast<VarDecl>(D)) {
     // Static data member is instantiated from a member definition of a class
     // template?
     if (VD->isStaticDataMember())
@@ -290,14 +289,14 @@
 
     return D;
   }
-  if (const CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(D)) {
+  if (const auto *CRD = dyn_cast<CXXRecordDecl>(D)) {
     // Is this class declaration part of a class template?
     if (const ClassTemplateDecl *CTD = CRD->getDescribedClassTemplate())
       return CTD;
 
     // Class is an implicit instantiation of a class template or partial
     // specialization?
-    if (const ClassTemplateSpecializationDecl *CTSD =
+    if (const auto *CTSD =
             dyn_cast<ClassTemplateSpecializationDecl>(CRD)) {
       if (CTSD->getSpecializationKind() != TSK_ImplicitInstantiation)
         return D;
@@ -317,7 +316,7 @@
 
     return D;
   }
-  if (const EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
+  if (const auto *ED = dyn_cast<EnumDecl>(D)) {
     // Enum is instantiated from a member definition of a class template?
     if (const EnumDecl *MemberDecl = ED->getInstantiatedFromMemberEnum())
       return MemberDecl;
@@ -403,7 +402,7 @@
 static void addRedeclaredMethods(const ObjCMethodDecl *ObjCMethod,
                    SmallVectorImpl<const NamedDecl *> &Redeclared) {
   const DeclContext *DC = ObjCMethod->getDeclContext();
-  if (const ObjCImplDecl *IMD = dyn_cast<ObjCImplDecl>(DC)) {
+  if (const auto *IMD = dyn_cast<ObjCImplDecl>(DC)) {
     const ObjCInterfaceDecl *ID = IMD->getClassInterface();
     if (!ID)
       return;
@@ -419,16 +418,14 @@
 
 comments::FullComment *ASTContext::cloneFullComment(comments::FullComment *FC,
                                                     const Decl *D) const {
-  comments::DeclInfo *ThisDeclInfo = new (*this) comments::DeclInfo;
+  auto *ThisDeclInfo = new (*this) comments::DeclInfo;
   ThisDeclInfo->CommentDecl = D;
   ThisDeclInfo->IsFilled = false;
   ThisDeclInfo->fill();
   ThisDeclInfo->CommentDecl = FC->getDecl();
   if (!ThisDeclInfo->TemplateParameters)
     ThisDeclInfo->TemplateParameters = FC->getDeclInfo()->TemplateParameters;
-  comments::FullComment *CFC =
-    new (*this) comments::FullComment(FC->getBlocks(),
-                                      ThisDeclInfo);
+  auto *CFC = new (*this) comments::FullComment(FC->getBlocks(), ThisDeclInfo);
   return CFC;
 }
 
@@ -463,7 +460,7 @@
   if (!RC) {
     if (isa<ObjCMethodDecl>(D) || isa<FunctionDecl>(D)) {
       SmallVector<const NamedDecl*, 8> Overridden;
-      const ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(D);
+      const auto *OMD = dyn_cast<ObjCMethodDecl>(D);
       if (OMD && OMD->isPropertyAccessor())
         if (const ObjCPropertyDecl *PDecl = OMD->findPropertyDecl())
           if (comments::FullComment *FC = getCommentForDecl(PDecl, PP))
@@ -475,7 +472,7 @@
         if (comments::FullComment *FC = getCommentForDecl(Overridden[i], PP))
           return cloneFullComment(FC, D);
     }
-    else if (const TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) {
+    else if (const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
       // Attach any tag type's documentation to its typedef if latter
       // does not have one of its own.
       QualType QT = TD->getUnderlyingType();
@@ -484,19 +481,19 @@
           if (comments::FullComment *FC = getCommentForDecl(TD, PP))
             return cloneFullComment(FC, D);
     }
-    else if (const ObjCInterfaceDecl *IC = dyn_cast<ObjCInterfaceDecl>(D)) {
+    else if (const auto *IC = dyn_cast<ObjCInterfaceDecl>(D)) {
       while (IC->getSuperClass()) {
         IC = IC->getSuperClass();
         if (comments::FullComment *FC = getCommentForDecl(IC, PP))
           return cloneFullComment(FC, D);
       }
     }
-    else if (const ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(D)) {
+    else if (const auto *CD = dyn_cast<ObjCCategoryDecl>(D)) {
       if (const ObjCInterfaceDecl *IC = CD->getClassInterface())
         if (comments::FullComment *FC = getCommentForDecl(IC, PP))
           return cloneFullComment(FC, D);
     }
-    else if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(D)) {
+    else if (const auto *RD = dyn_cast<CXXRecordDecl>(D)) {
       if (!(RD = RD->getDefinition()))
         return nullptr;
       // Check non-virtual bases.
@@ -556,13 +553,13 @@
   for (TemplateParameterList::const_iterator P = Params->begin(), 
                                           PEnd = Params->end();
        P != PEnd; ++P) {
-    if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
+    if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P)) {
       ID.AddInteger(0);
       ID.AddBoolean(TTP->isParameterPack());
       continue;
     }
     
-    if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
+    if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
       ID.AddInteger(1);
       ID.AddBoolean(NTTP->isParameterPack());
       ID.AddPointer(NTTP->getType().getCanonicalType().getAsOpaquePtr());
@@ -578,7 +575,7 @@
       continue;
     }
     
-    TemplateTemplateParmDecl *TTP = cast<TemplateTemplateParmDecl>(*P);
+    auto *TTP = cast<TemplateTemplateParmDecl>(*P);
     ID.AddInteger(2);
     Profile(ID, TTP);
   }
@@ -603,7 +600,7 @@
   for (TemplateParameterList::const_iterator P = Params->begin(), 
                                           PEnd = Params->end();
        P != PEnd; ++P) {
-    if (TemplateTypeParmDecl *TTP = dyn_cast<TemplateTypeParmDecl>(*P))
+    if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(*P))
       CanonParams.push_back(
                   TemplateTypeParmDecl::Create(*this, getTranslationUnitDecl(), 
                                                SourceLocation(),
@@ -611,8 +608,7 @@
                                                TTP->getDepth(),
                                                TTP->getIndex(), nullptr, false,
                                                TTP->isParameterPack()));
-    else if (NonTypeTemplateParmDecl *NTTP
-             = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
+    else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(*P)) {
       QualType T = getCanonicalType(NTTP->getType());
       TypeSourceInfo *TInfo = getTrivialTypeSourceInfo(T);
       NonTypeTemplateParmDecl *Param;
@@ -772,13 +768,13 @@
        const ASTRecordLayout*>::iterator
        I = ObjCLayouts.begin(), E = ObjCLayouts.end(); I != E; )
     // Increment in loop to prevent using deallocated memory.
-    if (ASTRecordLayout *R = const_cast<ASTRecordLayout*>((I++)->second))
+    if (auto *R = const_cast<ASTRecordLayout*>((I++)->second))
       R->Destroy(*this);
 
   for (llvm::DenseMap<const RecordDecl*, const ASTRecordLayout*>::iterator
        I = ASTRecordLayouts.begin(), E = ASTRecordLayouts.end(); I != E; ) {
     // Increment in loop to prevent using deallocated memory.
-    if (ASTRecordLayout *R = const_cast<ASTRecordLayout*>((I++)->second))
+    if (auto *R = const_cast<ASTRecordLayout*>((I++)->second))
       R->Destroy(*this);
   }
   
@@ -977,7 +973,7 @@
 }
 
 void ASTContext::InitBuiltinType(CanQualType &R, BuiltinType::Kind K) {
-  BuiltinType *Ty = new (*this, TypeAlignment) BuiltinType(K);
+  auto *Ty = new (*this, TypeAlignment) BuiltinType(K);
   R = CanQualType::CreateUnsafe(QualType(Ty, 0));
   Types.push_back(Ty);
 }
@@ -1309,13 +1305,13 @@
                       SmallVectorImpl<const NamedDecl *> &Overridden) const {
   assert(D);
 
-  if (const CXXMethodDecl *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
+  if (const auto *CXXMethod = dyn_cast<CXXMethodDecl>(D)) {
     Overridden.append(overridden_methods_begin(CXXMethod),
                       overridden_methods_end(CXXMethod));
     return;
   }
 
-  const ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(D);
+  const auto *Method = dyn_cast<ObjCMethodDecl>(D);
   if (!Method)
     return;
 
@@ -1385,7 +1381,7 @@
   if (UseAlignAttrOnly) {
     // do nothing
 
-  } else if (const ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
+  } else if (const auto *VD = dyn_cast<ValueDecl>(D)) {
     QualType T = VD->getType();
     if (const ReferenceType *RT = T->getAs<ReferenceType>()) {
       if (ForAlignof)
@@ -1408,7 +1404,7 @@
         }
       }
       Align = std::max(Align, getPreferredTypeAlign(T.getTypePtr()));
-      if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+      if (const auto *VD = dyn_cast<VarDecl>(D)) {
         if (VD->hasGlobalStorage() && !ForAlignof)
           Align = std::max(Align, getTargetInfo().getMinGlobalAlign());
       }
@@ -1419,7 +1415,7 @@
     // a max-field-alignment constraint (#pragma pack).  So calculate
     // the actual alignment of the field within the struct, and then
     // (as we're expected to) constrain that by the alignment of the type.
-    if (const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
+    if (const auto *Field = dyn_cast<FieldDecl>(VD)) {
       const RecordDecl *Parent = Field->getParent();
       // We can only produce a sensible answer if the record is valid.
       if (!Parent->isInvalidDecl()) {
@@ -1489,7 +1485,7 @@
 
 std::pair<CharUnits, CharUnits>
 ASTContext::getTypeInfoInChars(const Type *T) const {
-  if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(T))
+  if (const auto *CAT = dyn_cast<ConstantArrayType>(T))
     return getConstantArrayInfoInChars(*this, CAT);
   TypeInfo Info = getTypeInfo(T);
   return std::make_pair(toCharUnitsFromBits(Info.Width),
@@ -1556,7 +1552,7 @@
     break;
 
   case Type::ConstantArray: {
-    const ConstantArrayType *CAT = cast<ConstantArrayType>(T);
+    const auto *CAT = cast<ConstantArrayType>(T);
 
     TypeInfo EltInfo = getTypeInfo(CAT->getElementType());
     uint64_t Size = CAT->getSize().getZExtValue();
@@ -1571,7 +1567,7 @@
   }
   case Type::ExtVector:
   case Type::Vector: {
-    const VectorType *VT = cast<VectorType>(T);
+    const auto *VT = cast<VectorType>(T);
     TypeInfo EltInfo = getTypeInfo(VT->getElementType());
     Width = EltInfo.Width * VT->getNumElements();
     Align = Width;
@@ -1728,7 +1724,7 @@
     break;
   }
   case Type::MemberPointer: {
-    const MemberPointerType *MPT = cast<MemberPointerType>(T);
+    const auto *MPT = cast<MemberPointerType>(T);
     std::tie(Width, Align) = ABI->getMemberPointerWidthAndAlign(MPT);
     break;
   }
@@ -1746,7 +1742,7 @@
   case Type::Decayed:
     return getTypeInfo(cast<AdjustedType>(T)->getAdjustedType().getTypePtr());
   case Type::ObjCInterface: {
-    const ObjCInterfaceType *ObjCI = cast<ObjCInterfaceType>(T);
+    const auto *ObjCI = cast<ObjCInterfaceType>(T);
     const ASTRecordLayout &Layout = getASTObjCInterfaceLayout(ObjCI->getDecl());
     Width = toBits(Layout.getSize());
     Align = toBits(Layout.getAlignment());
@@ -1754,7 +1750,7 @@
   }
   case Type::Record:
   case Type::Enum: {
-    const TagType *TT = cast<TagType>(T);
+    const auto *TT = cast<TagType>(T);
 
     if (TT->getDecl()->isInvalidDecl()) {
       Width = 8;
@@ -1762,7 +1758,7 @@
       break;
     }
 
-    if (const EnumType *ET = dyn_cast<EnumType>(TT)) {
+    if (const auto *ET = dyn_cast<EnumType>(TT)) {
       const EnumDecl *ED = ET->getDecl();
       TypeInfo Info =
           getTypeInfo(ED->getIntegerType()->getUnqualifiedDesugaredType());
@@ -1773,7 +1769,7 @@
       return Info;
     }
 
-    const RecordType *RT = cast<RecordType>(TT);
+    const auto *RT = cast<RecordType>(TT);
     const RecordDecl *RD = RT->getDecl();
     const ASTRecordLayout &Layout = getASTRecordLayout(RD);
     Width = toBits(Layout.getSize());
@@ -1787,7 +1783,7 @@
                        getReplacementType().getTypePtr());
 
   case Type::Auto: {
-    const AutoType *A = cast<AutoType>(T);
+    const auto *A = cast<AutoType>(T);
     assert(!A->getDeducedType().isNull() &&
            "cannot request the size of an undeduced or dependent auto type");
     return getTypeInfo(A->getDeducedType().getTypePtr());
@@ -1797,7 +1793,7 @@
     return getTypeInfo(cast<ParenType>(T)->getInnerType().getTypePtr());
 
   case Type::Typedef: {
-    const TypedefNameDecl *Typedef = cast<TypedefType>(T)->getDecl();
+    const auto *Typedef = cast<TypedefType>(T)->getDecl();
     TypeInfo Info = getTypeInfo(Typedef->getUnderlyingType().getTypePtr());
     // If the typedef has an aligned attribute on it, it overrides any computed
     // alignment we have.  This violates the GCC documentation (which says that
@@ -1961,9 +1957,9 @@
     for (const auto *I : OI->ivars())
       Ivars.push_back(I);
   } else {
-    ObjCInterfaceDecl *IDecl = const_cast<ObjCInterfaceDecl *>(OI);
+    const auto *IDecl = const_cast<ObjCInterfaceDecl *>(OI);
     for (const ObjCIvarDecl *Iv = IDecl->all_declared_ivar_begin(); Iv; 
-         Iv= Iv->getNextIvar())
+         Iv = Iv->getNextIvar())
       Ivars.push_back(Iv);
   }
 }
@@ -1972,7 +1968,7 @@
 /// those inherited by it.
 void ASTContext::CollectInheritedProtocols(const Decl *CDecl,
                           llvm::SmallPtrSet<ObjCProtocolDecl*, 8> &Protocols) {
-  if (const ObjCInterfaceDecl *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
+  if (const auto *OI = dyn_cast<ObjCInterfaceDecl>(CDecl)) {
     // We can use protocol_iterator here instead of
     // all_referenced_protocol_iterator since we are walking all categories.    
     for (auto *Proto : OI->all_referenced_protocols()) {
@@ -1988,11 +1984,11 @@
         CollectInheritedProtocols(SD, Protocols);
         SD = SD->getSuperClass();
       }
-  } else if (const ObjCCategoryDecl *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
+  } else if (const auto *OC = dyn_cast<ObjCCategoryDecl>(CDecl)) {
     for (auto *Proto : OC->protocols()) {
       CollectInheritedProtocols(Proto, Protocols);
     }
-  } else if (const ObjCProtocolDecl *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
+  } else if (const auto *OP = dyn_cast<ObjCProtocolDecl>(CDecl)) {
     // Insert the protocol.
     if (!Protocols.insert(
           const_cast<ObjCProtocolDecl *>(OP->getCanonicalDecl())).second)
@@ -2067,14 +2063,11 @@
 
 const ObjCInterfaceDecl *ASTContext::getObjContainingInterface(
                                               const NamedDecl *ND) const {
-  if (const ObjCInterfaceDecl *ID =
-          dyn_cast<ObjCInterfaceDecl>(ND->getDeclContext()))
+  if (const auto *ID = dyn_cast<ObjCInterfaceDecl>(ND->getDeclContext()))
     return ID;
-  if (const ObjCCategoryDecl *CD =
-          dyn_cast<ObjCCategoryDecl>(ND->getDeclContext()))
+  if (const auto *CD = dyn_cast<ObjCCategoryDecl>(ND->getDeclContext()))
     return CD->getClassInterface();
-  if (const ObjCImplDecl *IMD =
-          dyn_cast<ObjCImplDecl>(ND->getDeclContext()))
+  if (const auto *IMD = dyn_cast<ObjCImplDecl>(ND->getDeclContext()))
     return IMD->getClassInterface();
 
   return nullptr;
@@ -2160,7 +2153,7 @@
     (void) ExtQualNodes.FindNodeOrInsertPos(ID, insertPos);
   }
 
-  ExtQuals *eq = new (*this, TypeAlignment) ExtQuals(baseType, canon, quals);
+  auto *eq = new (*this, TypeAlignment) ExtQuals(baseType, canon, quals);
   ExtQualNodes.InsertNode(eq, insertPos);
   return QualType(eq, fastQuals);
 }
@@ -2219,10 +2212,10 @@
     return T;
 
   QualType Result;
-  if (const FunctionNoProtoType *FNPT = dyn_cast<FunctionNoProtoType>(T)) {
+  if (const auto *FNPT = dyn_cast<FunctionNoProtoType>(T)) {
     Result = getFunctionNoProtoType(FNPT->getReturnType(), Info);
   } else {
-    const FunctionProtoType *FPT = cast<FunctionProtoType>(T);
+    const auto *FPT = cast<FunctionProtoType>(T);
     FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
     EPI.ExtInfo = Info;
     Result = getFunctionType(FPT->getReturnType(), FPT->getParamTypes(), EPI);
@@ -2235,7 +2228,7 @@
                                                  QualType ResultType) {
   FD = FD->getMostRecentDecl();
   while (true) {
-    const FunctionProtoType *FPT = FD->getType()->castAs<FunctionProtoType>();
+    const auto *FPT = FD->getType()->castAs<FunctionProtoType>();
     FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
     FD->setType(getFunctionType(ResultType, FPT->getParamTypes(), EPI));
     if (FunctionDecl *Next = FD->getPreviousDecl())
@@ -2255,12 +2248,12 @@
     ASTContext &Context, QualType Orig,
     const FunctionProtoType::ExceptionSpecInfo &ESI) {
   // Might have some parens.
-  if (auto *PT = dyn_cast<ParenType>(Orig))
+  if (const auto *PT = dyn_cast<ParenType>(Orig))
     return Context.getParenType(
         getFunctionTypeWithExceptionSpec(Context, PT->getInnerType(), ESI));
 
   // Might have a calling-convention attribute.
-  if (auto *AT = dyn_cast<AttributedType>(Orig))
+  if (const auto *AT = dyn_cast<AttributedType>(Orig))
     return Context.getAttributedType(
         AT->getAttrKind(),
         getFunctionTypeWithExceptionSpec(Context, AT->getModifiedType(), ESI),
@@ -2269,7 +2262,7 @@
 
   // Anything else must be a function type. Rebuild it with the new exception
   // specification.
-  const FunctionProtoType *Proto = cast<FunctionProtoType>(Orig);
+  const auto *Proto = cast<FunctionProtoType>(Orig);
   return Context.getFunctionType(
       Proto->getReturnType(), Proto->getParamTypes(),
       Proto->getExtProtoInfo().withExceptionSpec(ESI));
@@ -2325,7 +2318,7 @@
     ComplexType *NewIP = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos);
     assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
   }
-  ComplexType *New = new (*this, TypeAlignment) ComplexType(T, Canonical);
+  auto *New = new (*this, TypeAlignment) ComplexType(T, Canonical);
   Types.push_back(New);
   ComplexTypes.InsertNode(New, InsertPos);
   return QualType(New, 0);
@@ -2353,7 +2346,7 @@
     PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos);
     assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
   }
-  PointerType *New = new (*this, TypeAlignment) PointerType(T, Canonical);
+  auto *New = new (*this, TypeAlignment) PointerType(T, Canonical);
   Types.push_back(New);
   PointerTypes.InsertNode(New, InsertPos);
   return QualType(New, 0);
@@ -2444,8 +2437,7 @@
       BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
     assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
   }
-  BlockPointerType *New
-    = new (*this, TypeAlignment) BlockPointerType(T, Canonical);
+  auto *New = new (*this, TypeAlignment) BlockPointerType(T, Canonical);
   Types.push_back(New);
   BlockPointerTypes.InsertNode(New, InsertPos);
   return QualType(New, 0);
@@ -2483,9 +2475,8 @@
     assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
   }
 
-  LValueReferenceType *New
-    = new (*this, TypeAlignment) LValueReferenceType(T, Canonical,
-                                                     SpelledAsLValue);
+  auto *New = new (*this, TypeAlignment)
+    LValueReferenceType(T, Canonical, SpelledAsLValue);
   Types.push_back(New);
   LValueReferenceTypes.InsertNode(New, InsertPos);
 
@@ -2520,8 +2511,7 @@
     assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
   }
 
-  RValueReferenceType *New
-    = new (*this, TypeAlignment) RValueReferenceType(T, Canonical);
+  auto *New = new (*this, TypeAlignment) RValueReferenceType(T, Canonical);
   Types.push_back(New);
   RValueReferenceTypes.InsertNode(New, InsertPos);
   return QualType(New, 0);
@@ -2551,8 +2541,7 @@
       MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
     assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
   }
-  MemberPointerType *New
-    = new (*this, TypeAlignment) MemberPointerType(T, Cls, Canonical);
+  auto *New = new (*this, TypeAlignment) MemberPointerType(T, Cls, Canonical);
   Types.push_back(New);
   MemberPointerTypes.InsertNode(New, InsertPos);
   return QualType(New, 0);
@@ -2597,7 +2586,7 @@
     assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
   }
 
-  ConstantArrayType *New = new(*this,TypeAlignment)
+  auto *New = new(*this, TypeAlignment)
     ConstantArrayType(EltTy, Canon, ArySize, ASM, IndexTypeQuals);
   ConstantArrayTypes.InsertNode(New, InsertPos);
   Types.push_back(New);
@@ -2666,7 +2655,7 @@
     break;
 
   case Type::LValueReference: {
-    const LValueReferenceType *lv = cast<LValueReferenceType>(ty);
+    const auto *lv = cast<LValueReferenceType>(ty);
     result = getLValueReferenceType(
                  getVariableArrayDecayedType(lv->getPointeeType()),
                                     lv->isSpelledAsLValue());
@@ -2674,20 +2663,20 @@
   }
 
   case Type::RValueReference: {
-    const RValueReferenceType *lv = cast<RValueReferenceType>(ty);
+    const auto *lv = cast<RValueReferenceType>(ty);
     result = getRValueReferenceType(
                  getVariableArrayDecayedType(lv->getPointeeType()));
     break;
   }
 
   case Type::Atomic: {
-    const AtomicType *at = cast<AtomicType>(ty);
+    const auto *at = cast<AtomicType>(ty);
     result = getAtomicType(getVariableArrayDecayedType(at->getValueType()));
     break;
   }
 
   case Type::ConstantArray: {
-    const ConstantArrayType *cat = cast<ConstantArrayType>(ty);
+    const auto *cat = cast<ConstantArrayType>(ty);
     result = getConstantArrayType(
                  getVariableArrayDecayedType(cat->getElementType()),
                                   cat->getSize(),
@@ -2697,7 +2686,7 @@
   }
 
   case Type::DependentSizedArray: {
-    const DependentSizedArrayType *dat = cast<DependentSizedArrayType>(ty);
+    const auto *dat = cast<DependentSizedArrayType>(ty);
     result = getDependentSizedArrayType(
                  getVariableArrayDecayedType(dat->getElementType()),
                                         dat->getSizeExpr(),
@@ -2709,7 +2698,7 @@
 
   // Turn incomplete types into [*] types.
   case Type::IncompleteArray: {
-    const IncompleteArrayType *iat = cast<IncompleteArrayType>(ty);
+    const auto *iat = cast<IncompleteArrayType>(ty);
     result = getVariableArrayType(
                  getVariableArrayDecayedType(iat->getElementType()),
                                   /*size*/ nullptr,
@@ -2721,7 +2710,7 @@
 
   // Turn VLA types into [*] types.
   case Type::VariableArray: {
-    const VariableArrayType *vat = cast<VariableArrayType>(ty);
+    const auto *vat = cast<VariableArrayType>(ty);
     result = getVariableArrayType(
                  getVariableArrayDecayedType(vat->getElementType()),
                                   /*size*/ nullptr,
@@ -2755,7 +2744,7 @@
     Canon = getQualifiedType(Canon, canonSplit.Quals);
   }
   
-  VariableArrayType *New = new(*this, TypeAlignment)
+  auto *New = new(*this, TypeAlignment)
     VariableArrayType(EltTy, Canon, NumElts, ASM, IndexTypeQuals, Brackets);
 
   VariableArrayTypes.push_back(New);
@@ -2780,11 +2769,9 @@
   // initializer.  We do no canonicalization here at all, which is okay
   // because they can't be used in most locations.
   if (!numElements) {
-    DependentSizedArrayType *newType
-      = new (*this, TypeAlignment)
-          DependentSizedArrayType(*this, elementType, QualType(),
-                                  numElements, ASM, elementTypeQuals,
-                                  brackets);
+    auto *newType = new (*this, TypeAlignment)
+      DependentSizedArrayType(*this, elementType, QualType(), numElements, ASM,
+                              elementTypeQuals, brackets);
     Types.push_back(newType);
     return QualType(newType, 0);
   }
@@ -2826,10 +2813,9 @@
 
   // Otherwise, we need to build a type which follows the spelling
   // of the element type.
-  DependentSizedArrayType *sugaredType
-    = new (*this, TypeAlignment)
-        DependentSizedArrayType(*this, elementType, canon, numElements,
-                                ASM, elementTypeQuals, brackets);
+  auto *sugaredType = new (*this, TypeAlignment)
+    DependentSizedArrayType(*this, elementType, canon, numElements, ASM,
+                            elementTypeQuals, brackets);
   Types.push_back(sugaredType);
   return QualType(sugaredType, 0);
 }
@@ -2862,7 +2848,7 @@
     assert(!existing && "Shouldn't be in the map!"); (void) existing;
   }
 
-  IncompleteArrayType *newType = new (*this, TypeAlignment)
+  auto *newType = new (*this, TypeAlignment)
     IncompleteArrayType(elementType, canon, ASM, elementTypeQuals);
 
   IncompleteArrayTypes.InsertNode(newType, insertPos);
@@ -2894,7 +2880,7 @@
     VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
     assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
   }
-  VectorType *New = new (*this, TypeAlignment)
+  auto *New = new (*this, TypeAlignment)
     VectorType(vecType, NumElts, Canonical, VecKind);
   VectorTypes.InsertNode(New, InsertPos);
   Types.push_back(New);
@@ -2925,7 +2911,7 @@
     VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
     assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
   }
-  ExtVectorType *New = new (*this, TypeAlignment)
+  auto *New = new (*this, TypeAlignment)
     ExtVectorType(vecType, NumElts, Canonical);
   VectorTypes.InsertNode(New, InsertPos);
   Types.push_back(New);
@@ -3002,7 +2988,7 @@
   }
 
   FunctionProtoType::ExtInfo newInfo = Info.withCallingConv(CallConv);
-  FunctionNoProtoType *New = new (*this, TypeAlignment)
+  auto *New = new (*this, TypeAlignment)
     FunctionNoProtoType(ResultTy, Canonical, newInfo);
   Types.push_back(New);
   FunctionNoProtoTypes.InsertNode(New, InsertPos);
@@ -3111,7 +3097,7 @@
 #ifndef NDEBUG
 static bool NeedsInjectedClassNameType(const RecordDecl *D) {
   if (!isa<CXXRecordDecl>(D)) return false;
-  const CXXRecordDecl *RD = cast<CXXRecordDecl>(D);
+  const auto *RD = cast<CXXRecordDecl>(D);
   if (isa<ClassTemplatePartialSpecializationDecl>(RD))
     return true;
   if (RD->getDescribedClassTemplate() &&
@@ -3147,21 +3133,20 @@
   assert(Decl && "Passed null for Decl param");
   assert(!Decl->TypeForDecl && "TypeForDecl present in slow case");
 
-  if (const TypedefNameDecl *Typedef = dyn_cast<TypedefNameDecl>(Decl))
+  if (const auto *Typedef = dyn_cast<TypedefNameDecl>(Decl))
     return getTypedefType(Typedef);
 
   assert(!isa<TemplateTypeParmDecl>(Decl) &&
          "Template type parameter types are always available.");
 
-  if (const RecordDecl *Record = dyn_cast<RecordDecl>(Decl)) {
+  if (const auto *Record = dyn_cast<RecordDecl>(Decl)) {
     assert(Record->isFirstDecl() && "struct/union has previous declaration");
     assert(!NeedsInjectedClassNameType(Record));
     return getRecordType(Record);
-  } else if (const EnumDecl *Enum = dyn_cast<EnumDecl>(Decl)) {
+  } else if (const auto *Enum = dyn_cast<EnumDecl>(Decl)) {
     assert(Enum->isFirstDecl() && "enum has previous declaration");
     return getEnumType(Enum);
-  } else if (const UnresolvedUsingTypenameDecl *Using =
-               dyn_cast<UnresolvedUsingTypenameDecl>(Decl)) {
+  } else if (const auto *Using = dyn_cast<UnresolvedUsingTypenameDecl>(Decl)) {
     Type *newType = new (*this, TypeAlignment) UnresolvedUsingType(Using);
     Decl->TypeForDecl = newType;
     Types.push_back(newType);
@@ -3180,7 +3165,7 @@
 
   if (Canonical.isNull())
     Canonical = getCanonicalType(Decl->getUnderlyingType());
-  TypedefType *newType = new(*this, TypeAlignment)
+  auto *newType = new(*this, TypeAlignment)
     TypedefType(Type::Typedef, Decl, Canonical);
   Decl->TypeForDecl = newType;
   Types.push_back(newType);
@@ -3194,7 +3179,7 @@
     if (PrevDecl->TypeForDecl)
       return QualType(Decl->TypeForDecl = PrevDecl->TypeForDecl, 0); 
 
-  RecordType *newType = new (*this, TypeAlignment) RecordType(Decl);
+  auto *newType = new (*this, TypeAlignment) RecordType(Decl);
   Decl->TypeForDecl = newType;
   Types.push_back(newType);
   return QualType(newType, 0);
@@ -3207,7 +3192,7 @@
     if (PrevDecl->TypeForDecl)
       return QualType(Decl->TypeForDecl = PrevDecl->TypeForDecl, 0); 
 
-  EnumType *newType = new (*this, TypeAlignment) EnumType(Decl);
+  auto *newType = new (*this, TypeAlignment) EnumType(Decl);
   Decl->TypeForDecl = newType;
   Types.push_back(newType);
   return QualType(newType, 0);
@@ -3282,7 +3267,7 @@
     SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos);
   }
 
-  SubstTemplateTypeParmPackType *SubstParm
+  auto *SubstParm
     = new (*this, TypeAlignment) SubstTemplateTypeParmPackType(Parm, Canon,
                                                                ArgPack);
   Types.push_back(SubstParm);
@@ -3407,7 +3392,7 @@
                        sizeof(TemplateArgument) * NumArgs +
                        (IsTypeAlias? sizeof(QualType) : 0),
                        TypeAlignment);
-  TemplateSpecializationType *Spec
+  auto *Spec
     = new (Mem) TemplateSpecializationType(Template, Args, NumArgs, CanonType,
                                          IsTypeAlias ? Underlying : QualType());
 
@@ -3757,9 +3742,8 @@
   size += typeArgs.size() * sizeof(QualType);
   size += protocols.size() * sizeof(ObjCProtocolDecl *);
   void *mem = Allocate(size, TypeAlignment);
-  ObjCObjectTypeImpl *T =
-    new (mem) ObjCObjectTypeImpl(canonical, baseType, typeArgs, protocols,
-                                 isKindOf);
+  auto *T = new (mem) ObjCObjectTypeImpl(canonical, baseType, typeArgs,
+                                         protocols, isKindOf);
 
   Types.push_back(T);
   ObjCObjectTypes.InsertNode(T, InsertPos);
@@ -3854,8 +3838,7 @@
 
   // No match.
   void *Mem = Allocate(sizeof(ObjCObjectPointerType), TypeAlignment);
-  ObjCObjectPointerType *QType =
-    new (Mem) ObjCObjectPointerType(Canonical, ObjectT);
+  auto *QType = new (Mem) ObjCObjectPointerType(Canonical, ObjectT);
 
   Types.push_back(QType);
   ObjCObjectPointerTypes.InsertNode(QType, InsertPos);
@@ -3880,7 +3863,7 @@
     Decl = Def;
   
   void *Mem = Allocate(sizeof(ObjCInterfaceType), TypeAlignment);
-  ObjCInterfaceType *T = new (Mem) ObjCInterfaceType(Decl);
+  auto *T = new (Mem) ObjCInterfaceType(Decl);
   Decl->TypeForDecl = T;
   Types.push_back(T);
   return QualType(T, 0);
@@ -3927,7 +3910,7 @@
 /// on canonical types (which are always unique).
 QualType ASTContext::getTypeOfType(QualType tofType) const {
   QualType Canonical = getCanonicalType(tofType);
-  TypeOfType *tot = new (*this, TypeAlignment) TypeOfType(tofType, Canonical);
+  auto *tot = new (*this, TypeAlignment) TypeOfType(tofType, Canonical);
   Types.push_back(tot);
   return QualType(tot, 0);
 }
@@ -3971,7 +3954,7 @@
                                            QualType UnderlyingType,
                                            UnaryTransformType::UTTKind Kind)
     const {
-  UnaryTransformType *Ty =
+  auto *Ty =
     new (*this, TypeAlignment) UnaryTransformType (BaseType, UnderlyingType, 
                                                    Kind,
                                  UnderlyingType->isDependentType() ?
@@ -3995,9 +3978,8 @@
   if (AutoType *AT = AutoTypes.FindNodeOrInsertPos(ID, InsertPos))
     return QualType(AT, 0);
 
-  AutoType *AT = new (*this, TypeAlignment) AutoType(DeducedType,
-                                                     Keyword,
-                                                     IsDependent);
+  auto *AT = new (*this, TypeAlignment) AutoType(DeducedType, Keyword,
+                                                 IsDependent);
   Types.push_back(AT);
   if (InsertPos)
     AutoTypes.InsertNode(AT, InsertPos);
@@ -4026,7 +4008,7 @@
     AtomicType *NewIP = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos);
     assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
   }
-  AtomicType *New = new (*this, TypeAlignment) AtomicType(T, Canonical);
+  auto *New = new (*this, TypeAlignment) AtomicType(T, Canonical);
   Types.push_back(New);
   AtomicTypes.InsertNode(New, InsertPos);
   return QualType(New, 0);
@@ -4140,7 +4122,7 @@
   // the unqualified desugared type and then drops it on the floor.
   // We then have to strip that sugar back off with
   // getUnqualifiedDesugaredType(), which is silly.
-  const ArrayType *AT =
+  const auto *AT =
     dyn_cast<ArrayType>(splitType.Ty->getUnqualifiedDesugaredType());
 
   // If we don't have an array, just use the results in splitType.
@@ -4165,16 +4147,16 @@
   // build the type back up.
   quals.addConsistentQualifiers(splitType.Quals);
 
-  if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT)) {
+  if (const auto *CAT = dyn_cast<ConstantArrayType>(AT)) {
     return getConstantArrayType(unqualElementType, CAT->getSize(),
                                 CAT->getSizeModifier(), 0);
   }
 
-  if (const IncompleteArrayType *IAT = dyn_cast<IncompleteArrayType>(AT)) {
+  if (const auto *IAT = dyn_cast<IncompleteArrayType>(AT)) {
     return getIncompleteArrayType(unqualElementType, IAT->getSizeModifier(), 0);
   }
 
-  if (const VariableArrayType *VAT = dyn_cast<VariableArrayType>(AT)) {
+  if (const auto *VAT = dyn_cast<VariableArrayType>(AT)) {
     return getVariableArrayType(unqualElementType,
                                 VAT->getSizeExpr(),
                                 VAT->getSizeModifier(),
@@ -4182,7 +4164,7 @@
                                 VAT->getBracketsRange());
   }
 
-  const DependentSizedArrayType *DSAT = cast<DependentSizedArrayType>(AT);
+  const auto *DSAT = cast<DependentSizedArrayType>(AT);
   return getDependentSizedArrayType(unqualElementType, DSAT->getSizeExpr(),
                                     DSAT->getSizeModifier(), 0,
                                     SourceRange());
@@ -4285,8 +4267,7 @@
   case TemplateName::QualifiedTemplate:
   case TemplateName::Template: {
     TemplateDecl *Template = Name.getAsTemplateDecl();
-    if (TemplateTemplateParmDecl *TTP 
-          = dyn_cast<TemplateTemplateParmDecl>(Template))
+    if (auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Template))
       Template = getCanonicalTemplateTemplateParmDecl(TTP);
   
     // The canonical template name is the canonical template declaration.
@@ -4338,7 +4319,7 @@
       return Arg;
 
     case TemplateArgument::Declaration: {
-      ValueDecl *D = cast<ValueDecl>(Arg.getAsDecl()->getCanonicalDecl());
+      auto *D = cast<ValueDecl>(Arg.getAsDecl()->getCanonicalDecl());
       return TemplateArgument(D, Arg.getParamTypeForDecl());
     }
 
@@ -4364,8 +4345,7 @@
       if (Arg.pack_size() == 0)
         return Arg;
       
-      TemplateArgument *CanonArgs
-        = new (*this) TemplateArgument[Arg.pack_size()];
+      auto *CanonArgs = new (*this) TemplateArgument[Arg.pack_size()];
       unsigned Idx = 0;
       for (TemplateArgument::pack_iterator A = Arg.pack_begin(),
                                         AEnd = Arg.pack_end();
@@ -4440,7 +4420,7 @@
   // Handle the non-qualified case efficiently.
   if (!T.hasLocalQualifiers()) {
     // Handle the common positive case fast.
-    if (const ArrayType *AT = dyn_cast<ArrayType>(T))
+    if (const auto *AT = dyn_cast<ArrayType>(T))
       return AT;
   }
 
@@ -4460,7 +4440,7 @@
   Qualifiers qs = split.Quals;
 
   // If we have a simple case, just return now.
-  const ArrayType *ATy = dyn_cast<ArrayType>(split.Ty);
+  const auto *ATy = dyn_cast<ArrayType>(split.Ty);
   if (!ATy || qs.empty())
     return ATy;
 
@@ -4468,17 +4448,16 @@
   // qualifiers into the array element type and return a new array type.
   QualType NewEltTy = getQualifiedType(ATy->getElementType(), qs);
 
-  if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(ATy))
+  if (const auto *CAT = dyn_cast<ConstantArrayType>(ATy))
     return cast<ArrayType>(getConstantArrayType(NewEltTy, CAT->getSize(),
                                                 CAT->getSizeModifier(),
                                            CAT->getIndexTypeCVRQualifiers()));
-  if (const IncompleteArrayType *IAT = dyn_cast<IncompleteArrayType>(ATy))
+  if (const auto *IAT = dyn_cast<IncompleteArrayType>(ATy))
     return cast<ArrayType>(getIncompleteArrayType(NewEltTy,
                                                   IAT->getSizeModifier(),
                                            IAT->getIndexTypeCVRQualifiers()));
 
-  if (const DependentSizedArrayType *DSAT
-        = dyn_cast<DependentSizedArrayType>(ATy))
+  if (const auto *DSAT = dyn_cast<DependentSizedArrayType>(ATy))
     return cast<ArrayType>(
                      getDependentSizedArrayType(NewEltTy,
                                                 DSAT->getSizeExpr(),
@@ -4486,7 +4465,7 @@
                                               DSAT->getIndexTypeCVRQualifiers(),
                                                 DSAT->getBracketsRange()));
 
-  const VariableArrayType *VAT = cast<VariableArrayType>(ATy);
+  const auto *VAT = cast<VariableArrayType>(ATy);
   return cast<ArrayType>(getVariableArrayType(NewEltTy,
                                               VAT->getSizeExpr(),
                                               VAT->getSizeModifier(),
@@ -4787,9 +4766,9 @@
   const Type *RHSC = getCanonicalType(RHS).getTypePtr();
 
   // Unwrap enums to their underlying type.
-  if (const EnumType *ET = dyn_cast<EnumType>(LHSC))
+  if (const auto *ET = dyn_cast<EnumType>(LHSC))
     LHSC = getIntegerTypeForEnum(ET);
-  if (const EnumType *ET = dyn_cast<EnumType>(RHSC))
+  if (const auto *ET = dyn_cast<EnumType>(RHSC))
     RHSC = getIntegerTypeForEnum(ET);
 
   if (LHSC == RHSC) return 0;
@@ -5024,7 +5003,7 @@
 // This returns true if a type has been typedefed to BOOL:
 // typedef <type> BOOL;
 static bool isTypeTypedefedAsBOOL(QualType T) {
-  if (const TypedefType *TT = dyn_cast<TypedefType>(T))
+  if (const auto *TT = dyn_cast<TypedefType>(T))
     if (IdentifierInfo *II = TT->getDecl()->getIdentifier())
       return II->isStr("BOOL");
 
@@ -5098,7 +5077,7 @@
   ParmOffset = PtrSize;
   for (auto PVDecl : Decl->params()) {
     QualType PType = PVDecl->getOriginalType(); 
-    if (const ArrayType *AT =
+    if (const auto *AT =
           dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) {
       // Use array's original type only if it has known number of
       // elements.
@@ -5140,7 +5119,7 @@
   // Argument types.
   for (auto PVDecl : Decl->params()) {
     QualType PType = PVDecl->getOriginalType();
-    if (const ArrayType *AT =
+    if (const auto *AT =
           dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) {
       // Use array's original type only if it has known number of
       // elements.
@@ -5211,7 +5190,7 @@
        E = Decl->sel_param_end(); PI != E; ++PI) {
     const ParmVarDecl *PVDecl = *PI;
     QualType PType = PVDecl->getOriginalType();
-    if (const ArrayType *AT =
+    if (const auto *AT =
           dyn_cast<ArrayType>(PType->getCanonicalTypeInternal())) {
       // Use array's original type only if it has known number of
       // elements.
@@ -5234,13 +5213,12 @@
                                       const Decl *Container) const {
   if (!Container)
     return nullptr;
-  if (const ObjCCategoryImplDecl *CID =
-      dyn_cast<ObjCCategoryImplDecl>(Container)) {
+  if (const auto *CID = dyn_cast<ObjCCategoryImplDecl>(Container)) {
     for (auto *PID : CID->property_impls())
       if (PID->getPropertyDecl() == PD)
         return PID;
   } else {
-    const ObjCImplementationDecl *OID=cast<ObjCImplementationDecl>(Container);
+    const auto *OID = cast<ObjCImplementationDecl>(Container);
     for (auto *PID : OID->property_impls())
       if (PID->getPropertyDecl() == PD)
         return PID;
@@ -5455,7 +5433,7 @@
     return 'i';
   
   // The encoding of a fixed enum type matches its fixed underlying type.
-  const BuiltinType *BT = Enum->getIntegerType()->castAs<BuiltinType>();
+  const auto *BT = Enum->getIntegerType()->castAs<BuiltinType>();
   return getObjCEncodingForPrimitiveKind(C, BT->getKind());
 }
 
@@ -5485,7 +5463,7 @@
     if (const EnumType *ET = T->getAs<EnumType>())
       S += ObjCEncodingForEnumType(Ctx, ET);
     else {
-      const BuiltinType *BT = T->castAs<BuiltinType>();
+      const auto *BT = T->castAs<BuiltinType>();
       S += getObjCEncodingForPrimitiveKind(Ctx, BT->getKind());
     }
   }
@@ -5510,21 +5488,21 @@
   case Type::Enum:
     if (FD && FD->isBitField())
       return EncodeBitField(this, S, T, FD);
-    if (const BuiltinType *BT = dyn_cast<BuiltinType>(CT))
+    if (const auto *BT = dyn_cast<BuiltinType>(CT))
       S += getObjCEncodingForPrimitiveKind(this, BT->getKind());
     else
       S += ObjCEncodingForEnumType(this, cast<EnumType>(CT));
     return;
 
   case Type::Complex: {
-    const ComplexType *CT = T->castAs<ComplexType>();
+    const auto *CT = T->castAs<ComplexType>();
     S += 'j';
     getObjCEncodingForTypeImpl(CT->getElementType(), S, false, false, nullptr);
     return;
   }
 
   case Type::Atomic: {
-    const AtomicType *AT = T->castAs<AtomicType>();
+    const auto *AT = T->castAs<AtomicType>();
     S += 'A';
     getObjCEncodingForTypeImpl(AT->getValueType(), S, false, false, nullptr);
     return;
@@ -5536,7 +5514,7 @@
   case Type::RValueReference: {
     QualType PointeeTy;
     if (isa<PointerType>(CT)) {
-      const PointerType *PT = T->castAs<PointerType>();
+      const auto *PT = T->castAs<PointerType>();
       if (PT->isObjCSelType()) {
         S += ':';
         return;
@@ -5605,7 +5583,7 @@
   case Type::ConstantArray:
   case Type::IncompleteArray:
   case Type::VariableArray: {
-    const ArrayType *AT = cast<ArrayType>(CT);
+    const auto *AT = cast<ArrayType>(CT);
 
     if (isa<IncompleteArrayType>(AT) && !StructField) {
       // Incomplete arrays are encoded as a pointer to the array element.
@@ -5616,7 +5594,7 @@
     } else {
       S += '[';
 
-      if (const ConstantArrayType *CAT = dyn_cast<ConstantArrayType>(AT))
+      if (const auto *CAT = dyn_cast<ConstantArrayType>(AT))
         S += llvm::utostr(CAT->getSize().getZExtValue());
       else {
         //Variable length arrays are encoded as a regular array with 0 elements.
@@ -5640,12 +5618,12 @@
     return;
 
   case Type::Record: {
-    RecordDecl *RDecl = cast<RecordType>(CT)->getDecl();
+    auto *RDecl = cast<RecordType>(CT)->getDecl();
     S += RDecl->isUnion() ? '(' : '{';
     // Anonymous structures print as '?'
     if (const IdentifierInfo *II = RDecl->getIdentifier()) {
       S += II->getName();
-      if (ClassTemplateSpecializationDecl *Spec
+      if (const auto *Spec
           = dyn_cast<ClassTemplateSpecializationDecl>(RDecl)) {
         const TemplateArgumentList &TemplateArgs = Spec->getTemplateArgs();
         llvm::raw_string_ostream OS(S);
@@ -5690,10 +5668,10 @@
   }
 
   case Type::BlockPointer: {
-    const BlockPointerType *BT = T->castAs<BlockPointerType>();
+    const auto *BT = T->castAs<BlockPointerType>();
     S += "@?"; // Unlike a pointer-to-function, which is "^?".
     if (EncodeBlockParameters) {
-      const FunctionType *FT = BT->getPointeeType()->castAs<FunctionType>();
+      const auto *FT = BT->getPointeeType()->castAs<FunctionType>();
       
       S += '<';
       // Block return type
@@ -5705,7 +5683,7 @@
       // Block self
       S += "@?";
       // Block parameters
-      if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(FT)) {
+      if (const auto *FPT = dyn_cast<FunctionProtoType>(FT)) {
         for (const auto &I : FPT->param_types())
           getObjCEncodingForTypeImpl(
               I, S, ExpandPointedToStructures, ExpandStructures, FD,
@@ -5741,7 +5719,7 @@
     SmallVector<const ObjCIvarDecl*, 32> Ivars;
     DeepCollectObjCIvars(OI, true, Ivars);
     for (unsigned i = 0, e = Ivars.size(); i != e; ++i) {
-      const FieldDecl *Field = cast<FieldDecl>(Ivars[i]);
+      const auto *Field = cast<FieldDecl>(Ivars[i]);
       if (Field->isBitField())
         getObjCEncodingForTypeImpl(Field->getType(), S, false, true, Field);
       else
@@ -5755,7 +5733,7 @@
   }
 
   case Type::ObjCObjectPointer: {
-    const ObjCObjectPointerType *OPT = T->castAs<ObjCObjectPointerType>();
+    const auto *OPT = T->castAs<ObjCObjectPointerType>();
     if (OPT->isObjCIdType()) {
       S += '@';
       return;
@@ -5874,7 +5852,7 @@
   if (!RDecl->getDefinition())
     return;
 
-  CXXRecordDecl *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
+  const auto *CXXRec = dyn_cast<CXXRecordDecl>(RDecl);
   std::multimap<uint64_t, NamedDecl *> FieldOrBaseOffsets;
   const ASTRecordLayout &layout = getASTRecordLayout(RDecl);
 
@@ -5967,7 +5945,7 @@
     if (!dcl)
       break; // reached end of structure.
 
-    if (CXXRecordDecl *base = dyn_cast<CXXRecordDecl>(dcl)) {
+    if (auto *base = dyn_cast<CXXRecordDecl>(dcl)) {
       // We expand the bases without their virtual bases since those are going
       // in the initial structure. Note that this differs from gcc which
       // expands virtual bases each time one is encountered in the hierarchy,
@@ -5979,7 +5957,7 @@
       CurOffs += toBits(getASTRecordLayout(base).getNonVirtualSize());
 #endif
     } else {
-      FieldDecl *field = cast<FieldDecl>(dcl);
+      const auto *field = cast<FieldDecl>(dcl);
       if (FD) {
         S += '"';
         S += field->getNameAsString();
@@ -6439,7 +6417,7 @@
 
   void *memory = Allocate(sizeof(OverloadedTemplateStorage) +
                           size * sizeof(FunctionTemplateDecl*));
-  OverloadedTemplateStorage *OT = new(memory) OverloadedTemplateStorage(size);
+  auto *OT = new(memory) OverloadedTemplateStorage(size);
 
   NamedDecl **Storage = OT->getStorage();
   for (UnresolvedSetIterator I = Begin; I != End; ++I) {
@@ -6571,7 +6549,7 @@
 TemplateName 
 ASTContext::getSubstTemplateTemplateParmPack(TemplateTemplateParmDecl *Param,
                                        const TemplateArgument &ArgPack) const {
-  ASTContext &Self = const_cast<ASTContext &>(*this);
+  auto &Self = const_cast<ASTContext &>(*this);
   llvm::FoldingSetNodeID ID;
   SubstTemplateTemplateParmPackStorage::Profile(ID, Self, Param, ArgPack);
 
@@ -6637,7 +6615,7 @@
     // pointer.
 #ifndef NDEBUG
     QualType CT = Ty->getCanonicalTypeInternal();
-    while (const ArrayType *AT = dyn_cast<ArrayType>(CT))
+    while (const auto *AT = dyn_cast<ArrayType>(CT))
       CT = AT->getElementType();
     assert(CT->isAnyPointerType() || CT->isBlockPointerType());
 #endif
@@ -7340,8 +7318,8 @@
                                         bool Unqualified) {
   const FunctionType *lbase = lhs->getAs<FunctionType>();
   const FunctionType *rbase = rhs->getAs<FunctionType>();
-  const FunctionProtoType *lproto = dyn_cast<FunctionProtoType>(lbase);
-  const FunctionProtoType *rproto = dyn_cast<FunctionProtoType>(rbase);
+  const auto *lproto = dyn_cast<FunctionProtoType>(lbase);
+  const auto *rproto = dyn_cast<FunctionProtoType>(rbase);
   bool allLTypes = true;
   bool allRTypes = true;
 
@@ -7832,7 +7810,7 @@
       // id foo(); ... __strong id foo(); or: __strong id foo(); ... id foo();
       // In either case, use OldReturnType to build the new function type.
       const FunctionType *F = LHS->getAs<FunctionType>();
-      if (const FunctionProtoType *FPT = cast<FunctionProtoType>(F)) {
+      if (const auto *FPT = cast<FunctionProtoType>(F)) {
         FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo();
         EPI.ExtInfo = getFunctionExtInfo(LHS);
         QualType ResultType =
@@ -8387,7 +8365,7 @@
 }
 
 bool ASTContext::DeclMustBeEmitted(const Decl *D) {
-  if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+  if (const auto *VD = dyn_cast<VarDecl>(D)) {
     if (!VD->isFileVarDecl())
       return false;
     // Global named register variables (GNU extension) are never emitted.
@@ -8396,7 +8374,7 @@
     if (VD->getDescribedVarTemplate() ||
         isa<VarTemplatePartialSpecializationDecl>(VD))
       return false;
-  } else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+  } else if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
     // We never need to emit an uninstantiated function template.
     if (FD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplate)
       return false;
@@ -8417,7 +8395,7 @@
   if (D->hasAttr<AliasAttr>() || D->hasAttr<UsedAttr>())
     return true;
 
-  if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+  if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
     // Forward declarations aren't required.
     if (!FD->doesThisDeclarationHaveABody())
       return FD->doesDeclarationForceExternallyVisibleDefinition();
@@ -8429,7 +8407,7 @@
     // The key function for a class is required.  This rule only comes
     // into play when inline functions can be key functions, though.
     if (getTargetInfo().getCXXABI().canKeyFunctionBeInline()) {
-      if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
+      if (const auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
         const CXXRecordDecl *RD = MD->getParent();
         if (MD->isOutOfLine() && RD->isDynamicClass()) {
           const CXXMethodDecl *KeyFunc = getCurrentKeyFunction(RD);
@@ -8450,7 +8428,7 @@
     return true;
   }
   
-  const VarDecl *VD = cast<VarDecl>(D);
+  const auto *VD = cast<VarDecl>(D);
   assert(VD->isFileVarDecl() && "Expected file scoped var");
 
   if (VD->isThisDeclarationADefinition() == VarDecl::DeclarationOnly &&
@@ -8904,7 +8882,6 @@
       return false;
   }
   return (MethodDecl->isVariadic() == MethodImpl->isVariadic());
-  
 }
 
 // Explicitly instantiate this in case a Redeclarable<T> is used from a TU that
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to