r328826 - [AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).

Eugene Zelenko via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 29 13:51:59 PDT 2018


Author: eugenezelenko
Date: Thu Mar 29 13:51:59 2018
New Revision: 328826

URL: http://llvm.org/viewvc/llvm-project?rev=328826&view=rev
Log:
[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).

Modified:
    cfe/trunk/include/clang/AST/DeclTemplate.h
    cfe/trunk/include/clang/AST/Type.h
    cfe/trunk/lib/AST/DeclTemplate.cpp
    cfe/trunk/lib/AST/Type.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=328826&r1=328825&r2=328826&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Thu Mar 29 13:51:59 2018
@@ -299,7 +299,7 @@ class DefaultArgStorage {
 
   static ParmDecl *getParmOwningDefaultArg(ParmDecl *Parm) {
     const DefaultArgStorage &Storage = Parm->getDefaultArgStorage();
-    if (auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl*>())
+    if (auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl *>())
       Parm = Prev;
     assert(!Parm->getDefaultArgStorage()
                 .ValueOrInherited.template is<ParmDecl *>() &&
@@ -321,9 +321,9 @@ public:
   /// default argument is visible.
   ArgType get() const {
     const DefaultArgStorage *Storage = this;
-    if (auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl*>())
+    if (const auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl *>())
       Storage = &Prev->getDefaultArgStorage();
-    if (auto *C = Storage->ValueOrInherited.template dyn_cast<Chain*>())
+    if (const auto *C = Storage->ValueOrInherited.template dyn_cast<Chain *>())
       return C->Value;
     return Storage->ValueOrInherited.template get<ArgType>();
   }
@@ -331,9 +331,9 @@ public:
   /// Get the parameter from which we inherit the default argument, if any.
   /// This is the parameter on which the default argument was actually written.
   const ParmDecl *getInheritedFrom() const {
-    if (auto *D = ValueOrInherited.template dyn_cast<ParmDecl*>())
+    if (const auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>())
       return D;
-    if (auto *C = ValueOrInherited.template dyn_cast<Chain*>())
+    if (const auto *C = ValueOrInherited.template dyn_cast<Chain *>())
       return C->PrevDeclWithDefaultArg;
     return nullptr;
   }
@@ -443,7 +443,7 @@ public:
   }
 
   Expr *getAssociatedConstraints() const {
-    const TemplateDecl *const C = cast<TemplateDecl>(getCanonicalDecl());
+    const auto *const C = cast<TemplateDecl>(getCanonicalDecl());
     const auto *const CTDI =
         C->TemplateParams.dyn_cast<ConstrainedTemplateDeclInfo *>();
     return CTDI ? CTDI->getAssociatedConstraints() : nullptr;
@@ -466,6 +466,7 @@ public:
 
 protected:
   NamedDecl *TemplatedDecl;
+
   /// \brief The template parameter list and optional requires-clause
   /// associated with this declaration; alternatively, a
   /// \c ConstrainedTemplateDeclInfo if the associated constraints of the
@@ -1621,7 +1622,7 @@ public:
   }
 
   SourceRange getSourceRange() const override LLVM_READONLY {
-    return SourceRange();
+    return {};
   }
 
   BuiltinTemplateKind getBuiltinTemplateKind() const { return BTK; }
@@ -1789,8 +1790,8 @@ public:
   llvm::PointerUnion<ClassTemplateDecl *,
                      ClassTemplatePartialSpecializationDecl *>
   getSpecializedTemplateOrPartial() const {
-    if (SpecializedPartialSpecialization *PartialSpec
-          = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
+    if (const auto *PartialSpec =
+            SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
       return PartialSpec->PartialSpecialization;
 
     return SpecializedTemplate.get<ClassTemplateDecl*>();
@@ -1808,8 +1809,8 @@ public:
   /// deduced template arguments for the class template partial specialization
   /// itself.
   const TemplateArgumentList &getTemplateInstantiationArgs() const {
-    if (SpecializedPartialSpecialization *PartialSpec
-        = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
+    if (const auto *PartialSpec =
+            SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
       return *PartialSpec->TemplateArgs;
 
     return getTemplateArgs();
@@ -1822,8 +1823,7 @@ public:
                           const TemplateArgumentList *TemplateArgs) {
     assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
            "Already set to a class template partial specialization!");
-    SpecializedPartialSpecialization *PS
-      = new (getASTContext()) SpecializedPartialSpecialization();
+    auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
     PS->PartialSpecialization = PartialSpec;
     PS->TemplateArgs = TemplateArgs;
     SpecializedTemplate = PS;
@@ -1984,7 +1984,7 @@ public:
   /// \c Outer<float>::Inner<U*>, this function would return
   /// \c Outer<T>::Inner<U*>.
   ClassTemplatePartialSpecializationDecl *getInstantiatedFromMember() const {
-    const ClassTemplatePartialSpecializationDecl *First =
+    const auto *First =
         cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
     return First->InstantiatedFromMember.getPointer();
   }
@@ -1995,8 +1995,7 @@ public:
 
   void setInstantiatedFromMember(
                           ClassTemplatePartialSpecializationDecl *PartialSpec) {
-    ClassTemplatePartialSpecializationDecl *First =
-        cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
+    auto *First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
     First->InstantiatedFromMember.setPointer(PartialSpec);
   }
 
@@ -2017,15 +2016,14 @@ public:
   /// struct X<int>::Inner<T*> { /* ... */ };
   /// \endcode
   bool isMemberSpecialization() {
-    ClassTemplatePartialSpecializationDecl *First =
+    const auto *First =
         cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
     return First->InstantiatedFromMember.getInt();
   }
 
   /// \brief Note that this member template is a specialization.
   void setMemberSpecialization() {
-    ClassTemplatePartialSpecializationDecl *First =
-        cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
+    auto *First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
     assert(First->InstantiatedFromMember.getPointer() &&
            "Only member templates can be member template specializations");
     return First->InstantiatedFromMember.setInt(true);
@@ -2627,7 +2625,7 @@ public:
   /// specialization which was specialized by this.
   llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
   getSpecializedTemplateOrPartial() const {
-    if (SpecializedPartialSpecialization *PartialSpec =
+    if (const auto *PartialSpec =
             SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
       return PartialSpec->PartialSpecialization;
 
@@ -2646,7 +2644,7 @@ public:
   /// return deduced template arguments for the variable template partial
   /// specialization itself.
   const TemplateArgumentList &getTemplateInstantiationArgs() const {
-    if (SpecializedPartialSpecialization *PartialSpec =
+    if (const auto *PartialSpec =
             SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
       return *PartialSpec->TemplateArgs;
 
@@ -2660,8 +2658,7 @@ public:
                           const TemplateArgumentList *TemplateArgs) {
     assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
            "Already set to a variable template partial specialization!");
-    SpecializedPartialSpecialization *PS =
-        new (getASTContext()) SpecializedPartialSpecialization();
+    auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
     PS->PartialSpecialization = PartialSpec;
     PS->TemplateArgs = TemplateArgs;
     SpecializedTemplate = PS;
@@ -2815,15 +2812,14 @@ public:
   /// \c Outer<float>::Inner<U*>, this function would return
   /// \c Outer<T>::Inner<U*>.
   VarTemplatePartialSpecializationDecl *getInstantiatedFromMember() const {
-    const VarTemplatePartialSpecializationDecl *First =
+    const auto *First =
         cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
     return First->InstantiatedFromMember.getPointer();
   }
 
   void
   setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec) {
-    VarTemplatePartialSpecializationDecl *First =
-        cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
+    auto *First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
     First->InstantiatedFromMember.setPointer(PartialSpec);
   }
 
@@ -2844,15 +2840,14 @@ public:
   /// U* X<int>::Inner<T*> = (T*)(0) + 1;
   /// \endcode
   bool isMemberSpecialization() {
-    VarTemplatePartialSpecializationDecl *First =
+    const auto *First =
         cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
     return First->InstantiatedFromMember.getInt();
   }
 
   /// \brief Note that this member template is a specialization.
   void setMemberSpecialization() {
-    VarTemplatePartialSpecializationDecl *First =
-        cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
+    auto *First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
     assert(First->InstantiatedFromMember.getPointer() &&
            "Only member templates can be member template specializations");
     return First->InstantiatedFromMember.setInt(true);
@@ -3021,11 +3016,11 @@ public:
 };
 
 inline NamedDecl *getAsNamedDecl(TemplateParameter P) {
-  if (auto *PD = P.dyn_cast<TemplateTypeParmDecl*>())
+  if (auto *PD = P.dyn_cast<TemplateTypeParmDecl *>())
     return PD;
-  if (auto *PD = P.dyn_cast<NonTypeTemplateParmDecl*>())
+  if (auto *PD = P.dyn_cast<NonTypeTemplateParmDecl *>())
     return PD;
-  return P.get<TemplateTemplateParmDecl*>();
+  return P.get<TemplateTemplateParmDecl *>();
 }
 
 inline TemplateDecl *getAsTypeTemplateDecl(Decl *D) {

Modified: cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=328826&r1=328825&r2=328826&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Mar 29 13:51:59 2018
@@ -667,8 +667,7 @@ class QualType {
 
   const ExtQualsTypeCommonBase *getCommonPtr() const {
     assert(!isNull() && "Cannot retrieve a NULL type pointer");
-    uintptr_t CommonPtrVal
-      = reinterpret_cast<uintptr_t>(Value.getOpaqueValue());
+    auto CommonPtrVal = reinterpret_cast<uintptr_t>(Value.getOpaqueValue());
     CommonPtrVal &= ~(uintptr_t)((1 << TypeAlignmentInBits) - 1);
     return reinterpret_cast<ExtQualsTypeCommonBase*>(CommonPtrVal);
   }
@@ -3544,7 +3543,7 @@ private:
     assert(hasExtParameterInfos());
 
     // Find the end of the exception specification.
-    const char *ptr = reinterpret_cast<const char *>(exception_begin());
+    const auto *ptr = reinterpret_cast<const char *>(exception_begin());
     ptr += getExceptionSpecSize();
 
     return reinterpret_cast<const ExtParameterInfo *>(ptr);
@@ -5499,8 +5498,8 @@ public:
 
 inline ObjCInterfaceDecl *ObjCObjectType::getInterface() const {
   QualType baseType = getBaseType();
-  while (const ObjCObjectType *ObjT = baseType->getAs<ObjCObjectType>()) {
-    if (const ObjCInterfaceType *T = dyn_cast<ObjCInterfaceType>(ObjT))
+  while (const auto *ObjT = baseType->getAs<ObjCObjectType>()) {
+    if (const auto *T = dyn_cast<ObjCInterfaceType>(ObjT))
       return T->getDecl();
 
     baseType = ObjT->getBaseType();
@@ -5922,10 +5921,10 @@ inline Qualifiers::GC QualType::getObjCG
 }
 
 inline FunctionType::ExtInfo getFunctionExtInfo(const Type &t) {
-  if (const PointerType *PT = t.getAs<PointerType>()) {
-    if (const FunctionType *FT = PT->getPointeeType()->getAs<FunctionType>())
+  if (const auto *PT = t.getAs<PointerType>()) {
+    if (const auto *FT = PT->getPointeeType()->getAs<FunctionType>())
       return FT->getExtInfo();
-  } else if (const FunctionType *FT = t.getAs<FunctionType>())
+  } else if (const auto *FT = t.getAs<FunctionType>())
     return FT->getExtInfo();
 
   return FunctionType::ExtInfo();
@@ -5970,7 +5969,7 @@ inline bool QualType::isAtLeastAsQualifi
 ///   analysis, the expression designates the object or function
 ///   denoted by the reference, and the expression is an lvalue.
 inline QualType QualType::getNonReferenceType() const {
-  if (const ReferenceType *RefType = (*this)->getAs<ReferenceType>())
+  if (const auto *RefType = (*this)->getAs<ReferenceType>())
     return RefType->getPointeeType();
   else
     return *this;
@@ -6045,7 +6044,7 @@ inline bool Type::isRValueReferenceType(
 }
 
 inline bool Type::isFunctionPointerType() const {
-  if (const PointerType *T = getAs<PointerType>())
+  if (const auto *T = getAs<PointerType>())
     return T->getPointeeType()->isFunctionType();
   else
     return false;
@@ -6056,14 +6055,14 @@ inline bool Type::isMemberPointerType()
 }
 
 inline bool Type::isMemberFunctionPointerType() const {
-  if (const MemberPointerType* T = getAs<MemberPointerType>())
+  if (const auto *T = getAs<MemberPointerType>())
     return T->isMemberFunctionPointer();
   else
     return false;
 }
 
 inline bool Type::isMemberDataPointerType() const {
-  if (const MemberPointerType* T = getAs<MemberPointerType>())
+  if (const auto *T = getAs<MemberPointerType>())
     return T->isMemberDataPointer();
   else
     return false;
@@ -6135,31 +6134,31 @@ inline bool Type::isAtomicType() const {
 }
 
 inline bool Type::isObjCQualifiedIdType() const {
-  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
+  if (const auto *OPT = getAs<ObjCObjectPointerType>())
     return OPT->isObjCQualifiedIdType();
   return false;
 }
 
 inline bool Type::isObjCQualifiedClassType() const {
-  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
+  if (const auto *OPT = getAs<ObjCObjectPointerType>())
     return OPT->isObjCQualifiedClassType();
   return false;
 }
 
 inline bool Type::isObjCIdType() const {
-  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
+  if (const auto *OPT = getAs<ObjCObjectPointerType>())
     return OPT->isObjCIdType();
   return false;
 }
 
 inline bool Type::isObjCClassType() const {
-  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
+  if (const auto *OPT = getAs<ObjCObjectPointerType>())
     return OPT->isObjCClassType();
   return false;
 }
 
 inline bool Type::isObjCSelType() const {
-  if (const PointerType *OPT = getAs<PointerType>())
+  if (const auto *OPT = getAs<PointerType>())
     return OPT->getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCSel);
   return false;
 }
@@ -6222,13 +6221,13 @@ inline bool Type::isSpecificBuiltinType(
 }
 
 inline bool Type::isPlaceholderType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(this))
+  if (const auto *BT = dyn_cast<BuiltinType>(this))
     return BT->isPlaceholderType();
   return false;
 }
 
 inline const BuiltinType *Type::getAsPlaceholderType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(this))
+  if (const auto *BT = dyn_cast<BuiltinType>(this))
     if (BT->isPlaceholderType())
       return BT;
   return nullptr;
@@ -6236,38 +6235,38 @@ inline const BuiltinType *Type::getAsPla
 
 inline bool Type::isSpecificPlaceholderType(unsigned K) const {
   assert(BuiltinType::isPlaceholderTypeKind((BuiltinType::Kind) K));
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(this))
+  if (const auto *BT = dyn_cast<BuiltinType>(this))
     return (BT->getKind() == (BuiltinType::Kind) K);
   return false;
 }
 
 inline bool Type::isNonOverloadPlaceholderType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(this))
+  if (const auto *BT = dyn_cast<BuiltinType>(this))
     return BT->isNonOverloadPlaceholderType();
   return false;
 }
 
 inline bool Type::isVoidType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() == BuiltinType::Void;
   return false;
 }
 
 inline bool Type::isHalfType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() == BuiltinType::Half;
   // FIXME: Should we allow complex __fp16? Probably not.
   return false;
 }
 
 inline bool Type::isFloat16Type() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() == BuiltinType::Float16;
   return false;
 }
 
 inline bool Type::isNullPtrType() const {
-  if (const BuiltinType *BT = getAs<BuiltinType>())
+  if (const auto *BT = getAs<BuiltinType>())
     return BT->getKind() == BuiltinType::NullPtr;
   return false;
 }
@@ -6276,7 +6275,7 @@ bool IsEnumDeclComplete(EnumDecl *);
 bool IsEnumDeclScoped(EnumDecl *);
 
 inline bool Type::isIntegerType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::Int128;
   if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
@@ -6289,7 +6288,7 @@ inline bool Type::isIntegerType() const
 }
 
 inline bool Type::isScalarType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() > BuiltinType::Void &&
            BT->getKind() <= BuiltinType::NullPtr;
   if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
@@ -6304,20 +6303,20 @@ inline bool Type::isScalarType() const {
 }
 
 inline bool Type::isIntegralOrEnumerationType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::Int128;
 
   // Check for a complete enum type; incomplete enum types are not properly an
   // enumeration type in the sense required here.
-  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
+  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
     return IsEnumDeclComplete(ET->getDecl());
 
   return false;  
 }
 
 inline bool Type::isBooleanType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() == BuiltinType::Bool;
   return false;
 }
@@ -6394,7 +6393,7 @@ template <typename T> const T *Type::get
                 "ArrayType cannot be used with getAs!");
 
   // If this is directly a T type, return it.
-  if (const T *Ty = dyn_cast<T>(this))
+  if (const auto *Ty = dyn_cast<T>(this))
     return Ty;
 
   // If the canonical form of this type isn't the right kind, reject it.
@@ -6410,7 +6409,7 @@ template <typename T> const T *Type::get
   static_assert(!TypeIsArrayType<T>::value, "ArrayType cannot be used with getAsAdjusted!");
 
   // If this is directly a T type, return it.
-  if (const T *Ty = dyn_cast<T>(this))
+  if (const auto *Ty = dyn_cast<T>(this))
     return Ty;
 
   // If the canonical form of this type isn't the right kind, reject it.
@@ -6440,7 +6439,7 @@ template <typename T> const T *Type::get
 
 inline const ArrayType *Type::getAsArrayTypeUnsafe() const {
   // If this is directly an array type, return it.
-  if (const ArrayType *arr = dyn_cast<ArrayType>(this))
+  if (const auto *arr = dyn_cast<ArrayType>(this))
     return arr;
 
   // If the canonical form of this type isn't the right kind, reject it.
@@ -6456,14 +6455,14 @@ template <typename T> const T *Type::cas
   static_assert(!TypeIsArrayType<T>::value,
                 "ArrayType cannot be used with castAs!");
 
-  if (const T *ty = dyn_cast<T>(this)) return ty;
+  if (const auto *ty = dyn_cast<T>(this)) return ty;
   assert(isa<T>(CanonicalType));
   return cast<T>(getUnqualifiedDesugaredType());
 }
 
 inline const ArrayType *Type::castAsArrayTypeUnsafe() const {
   assert(isa<ArrayType>(CanonicalType));
-  if (const ArrayType *arr = dyn_cast<ArrayType>(this)) return arr;
+  if (const auto *arr = dyn_cast<ArrayType>(this)) return arr;
   return cast<ArrayType>(getUnqualifiedDesugaredType());
 }
 

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=328826&r1=328825&r2=328826&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Thu Mar 29 13:51:59 2018
@@ -17,6 +17,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclarationName.h"
 #include "clang/AST/Expr.h"
+#include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -56,11 +57,11 @@ TemplateParameterList::TemplateParameter
     begin()[Idx] = P;
 
     if (!P->isTemplateParameterPack()) {
-      if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P))
+      if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P))
         if (NTTP->getType()->containsUnexpandedParameterPack())
           ContainsUnexpandedParameterPack = true;
 
-      if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(P))
+      if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P))
         if (TTP->getTemplateParameters()->containsUnexpandedParameterPack())
           ContainsUnexpandedParameterPack = true;
 
@@ -118,11 +119,9 @@ unsigned TemplateParameterList::getDepth
     return 0;
   
   const NamedDecl *FirstParm = getParam(0);
-  if (const TemplateTypeParmDecl *TTP
-        = dyn_cast<TemplateTypeParmDecl>(FirstParm))
+  if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(FirstParm))
     return TTP->getDepth();
-  else if (const NonTypeTemplateParmDecl *NTTP 
-             = dyn_cast<NonTypeTemplateParmDecl>(FirstParm))
+  else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(FirstParm))
     return NTTP->getDepth();
   else
     return cast<TemplateTemplateParmDecl>(FirstParm)->getDepth();
@@ -133,7 +132,7 @@ static void AdoptTemplateParameterList(T
   for (NamedDecl *P : *Params) {
     P->setDeclContext(Owner);
 
-    if (auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P))
+    if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P))
       AdoptTemplateParameterList(TTP->getTemplateParameters(), Owner);
   }
 }
@@ -258,7 +257,7 @@ FunctionTemplateDecl *FunctionTemplateDe
 
 RedeclarableTemplateDecl::CommonBase *
 FunctionTemplateDecl::newCommon(ASTContext &C) const {
-  Common *CommonPtr = new (C) Common;
+  auto *CommonPtr = new (C) Common;
   C.addDestruction(CommonPtr);
   return CommonPtr;
 }
@@ -318,8 +317,8 @@ ClassTemplateDecl *ClassTemplateDecl::Cr
     return new (C, DC) ClassTemplateDecl(C, DC, L, Name, Params, Decl);
   }
 
-  ConstrainedTemplateDeclInfo *const CTDI = new (C) ConstrainedTemplateDeclInfo;
-  ClassTemplateDecl *const New =
+  auto *const CTDI = new (C) ConstrainedTemplateDeclInfo;
+  auto *const New =
       new (C, DC) ClassTemplateDecl(CTDI, C, DC, L, Name, Params, Decl);
   New->setAssociatedConstraints(AssociatedConstraints);
   return New;
@@ -349,7 +348,7 @@ ClassTemplateDecl::getPartialSpecializat
 
 RedeclarableTemplateDecl::CommonBase *
 ClassTemplateDecl::newCommon(ASTContext &C) const {
-  Common *CommonPtr = new (C) Common;
+  auto *CommonPtr = new (C) Common;
   C.addDestruction(CommonPtr);
   return CommonPtr;
 }
@@ -453,8 +452,8 @@ TemplateTypeParmDecl::Create(const ASTCo
                              SourceLocation KeyLoc, SourceLocation NameLoc,
                              unsigned D, unsigned P, IdentifierInfo *Id,
                              bool Typename, bool ParameterPack) {
-  TemplateTypeParmDecl *TTPDecl =
-    new (C, DC) TemplateTypeParmDecl(DC, KeyLoc, NameLoc, Id, Typename);
+  auto *TTPDecl =
+      new (C, DC) TemplateTypeParmDecl(DC, KeyLoc, NameLoc, Id, Typename);
   QualType TTPType = C.getTemplateTypeParmType(D, P, ParameterPack, TTPDecl);
   TTPDecl->setTypeForDecl(TTPType.getTypePtr());
   return TTPDecl;
@@ -709,7 +708,7 @@ ClassTemplateSpecializationDecl::Create(
                                         ClassTemplateDecl *SpecializedTemplate,
                                         ArrayRef<TemplateArgument> Args,
                                    ClassTemplateSpecializationDecl *PrevDecl) {
-  ClassTemplateSpecializationDecl *Result =
+  auto *Result =
       new (Context, DC) ClassTemplateSpecializationDecl(
           Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
           SpecializedTemplate, Args, PrevDecl);
@@ -722,7 +721,7 @@ ClassTemplateSpecializationDecl::Create(
 ClassTemplateSpecializationDecl *
 ClassTemplateSpecializationDecl::CreateDeserialized(ASTContext &C,
                                                     unsigned ID) {
-  ClassTemplateSpecializationDecl *Result =
+  auto *Result =
     new (C, ID) ClassTemplateSpecializationDecl(C, ClassTemplateSpecialization);
   Result->MayHaveOutOfDateDef = false;
   return Result;
@@ -732,7 +731,7 @@ void ClassTemplateSpecializationDecl::ge
     raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const {
   NamedDecl::getNameForDiagnostic(OS, Policy, Qualified);
 
-  auto *PS = dyn_cast<ClassTemplatePartialSpecializationDecl>(this);
+  const auto *PS = dyn_cast<ClassTemplatePartialSpecializationDecl>(this);
   if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
           PS ? PS->getTemplateArgsAsWritten() : nullptr) {
     printTemplateArgumentList(OS, ArgsAsWritten->arguments(), Policy);
@@ -744,8 +743,8 @@ void ClassTemplateSpecializationDecl::ge
 
 ClassTemplateDecl *
 ClassTemplateSpecializationDecl::getSpecializedTemplate() const {
-  if (SpecializedPartialSpecialization *PartialSpec
-      = SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
+  if (const auto *PartialSpec =
+          SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
     return PartialSpec->PartialSpecialization->getSpecializedTemplate();
   return SpecializedTemplate.get<ClassTemplateDecl*>();
 }
@@ -770,7 +769,7 @@ ClassTemplateSpecializationDecl::getSour
     // uses ExplicitInfo to record the TypeAsWritten, but the source
     // locations should be retrieved from the instantiation pattern.
     using CTPSDecl = ClassTemplatePartialSpecializationDecl;
-    CTPSDecl *ctpsd = const_cast<CTPSDecl*>(cast<CTPSDecl>(this));
+    auto *ctpsd = const_cast<CTPSDecl *>(cast<CTPSDecl>(this));
     CTPSDecl *inst_from = ctpsd->getInstantiatedFromMember();
     assert(inst_from != nullptr);
     return inst_from->getSourceRange();
@@ -782,9 +781,9 @@ ClassTemplateSpecializationDecl::getSour
       inst_from = getInstantiatedFrom();
     if (inst_from.isNull())
       return getSpecializedTemplate()->getSourceRange();
-    if (ClassTemplateDecl *ctd = inst_from.dyn_cast<ClassTemplateDecl*>())
+    if (const auto *ctd = inst_from.dyn_cast<ClassTemplateDecl *>())
       return ctd->getSourceRange();
-    return inst_from.get<ClassTemplatePartialSpecializationDecl*>()
+    return inst_from.get<ClassTemplatePartialSpecializationDecl *>()
       ->getSourceRange();
   }
 }
@@ -826,7 +825,7 @@ Create(ASTContext &Context, TagKind TK,D
   const ASTTemplateArgumentListInfo *ASTArgInfos =
     ASTTemplateArgumentListInfo::Create(Context, ArgInfos);
 
-  ClassTemplatePartialSpecializationDecl *Result = new (Context, DC)
+  auto *Result = new (Context, DC)
       ClassTemplatePartialSpecializationDecl(Context, TK, DC, StartLoc, IdLoc,
                                              Params, SpecializedTemplate, Args,
                                              ASTArgInfos, PrevDecl);
@@ -840,8 +839,7 @@ Create(ASTContext &Context, TagKind TK,D
 ClassTemplatePartialSpecializationDecl *
 ClassTemplatePartialSpecializationDecl::CreateDeserialized(ASTContext &C,
                                                            unsigned ID) {
-  ClassTemplatePartialSpecializationDecl *Result =
-      new (C, ID) ClassTemplatePartialSpecializationDecl(C);
+  auto *Result = new (C, ID) ClassTemplatePartialSpecializationDecl(C);
   Result->MayHaveOutOfDateDef = false;
   return Result;
 }
@@ -887,7 +885,7 @@ TypeAliasTemplateDecl *TypeAliasTemplate
 
 RedeclarableTemplateDecl::CommonBase *
 TypeAliasTemplateDecl::newCommon(ASTContext &C) const {
-  Common *CommonPtr = new (C) Common;
+  auto *CommonPtr = new (C) Common;
   C.addDestruction(CommonPtr);
   return CommonPtr;
 }
@@ -950,7 +948,7 @@ VarTemplateDecl::getPartialSpecializatio
 
 RedeclarableTemplateDecl::CommonBase *
 VarTemplateDecl::newCommon(ASTContext &C) const {
-  Common *CommonPtr = new (C) Common;
+  auto *CommonPtr = new (C) Common;
   C.addDestruction(CommonPtr);
   return CommonPtr;
 }
@@ -1048,7 +1046,7 @@ void VarTemplateSpecializationDecl::getN
     raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const {
   NamedDecl::getNameForDiagnostic(OS, Policy, Qualified);
 
-  auto *PS = dyn_cast<VarTemplatePartialSpecializationDecl>(this);
+  const auto *PS = dyn_cast<VarTemplatePartialSpecializationDecl>(this);
   if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
           PS ? PS->getTemplateArgsAsWritten() : nullptr) {
     printTemplateArgumentList(OS, ArgsAsWritten->arguments(), Policy);
@@ -1059,7 +1057,7 @@ void VarTemplateSpecializationDecl::getN
 }
 
 VarTemplateDecl *VarTemplateSpecializationDecl::getSpecializedTemplate() const {
-  if (SpecializedPartialSpecialization *PartialSpec =
+  if (const auto *PartialSpec =
           SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
     return PartialSpec->PartialSpecialization->getSpecializedTemplate();
   return SpecializedTemplate.get<VarTemplateDecl *>();
@@ -1104,7 +1102,7 @@ VarTemplatePartialSpecializationDecl::Cr
   const ASTTemplateArgumentListInfo *ASTArgInfos
     = ASTTemplateArgumentListInfo::Create(Context, ArgInfos);
 
-  VarTemplatePartialSpecializationDecl *Result =
+  auto *Result =
       new (Context, DC) VarTemplatePartialSpecializationDecl(
           Context, DC, StartLoc, IdLoc, Params, SpecializedTemplate, T, TInfo,
           S, Args, ASTArgInfos);

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=328826&r1=328825&r2=328826&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Thu Mar 29 13:51:59 2018
@@ -29,6 +29,7 @@
 #include "clang/AST/TypeVisitor.h"
 #include "clang/Basic/AddressSpaces.h"
 #include "clang/Basic/ExceptionSpecificationType.h"
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/Linkage.h"
@@ -228,7 +229,7 @@ VectorType::VectorType(TypeClass tc, Qua
 /// This method should never be used when type qualifiers are meaningful.
 const Type *Type::getArrayElementTypeNoTypeQual() const {
   // If this is directly an array type, return it.
-  if (const ArrayType *ATy = dyn_cast<ArrayType>(this))
+  if (const auto *ATy = dyn_cast<ArrayType>(this))
     return ATy->getElementType().getTypePtr();
 
   // If the canonical form of this type isn't the right kind, reject it.
@@ -264,7 +265,7 @@ QualType Type::getLocallyUnqualifiedSing
 #define ABSTRACT_TYPE(Class, Parent)
 #define TYPE(Class, Parent) \
   case Type::Class: { \
-    const Class##Type *ty = cast<Class##Type>(this); \
+    const auto *ty = cast<Class##Type>(this); \
     if (!ty->isSugared()) return QualType(ty, 0); \
     return ty->desugar(); \
   }
@@ -283,7 +284,7 @@ SplitQualType QualType::getSplitDesugare
 #define ABSTRACT_TYPE(Class, Parent)
 #define TYPE(Class, Parent) \
     case Type::Class: { \
-      const Class##Type *Ty = cast<Class##Type>(CurTy); \
+      const auto *Ty = cast<Class##Type>(CurTy); \
       if (!Ty->isSugared()) \
         return SplitQualType(Ty, Qs); \
       Cur = Ty->desugar(); \
@@ -312,7 +313,7 @@ SplitQualType QualType::getSplitUnqualif
 #define ABSTRACT_TYPE(Class, Parent)
 #define TYPE(Class, Parent) \
     case Type::Class: { \
-      const Class##Type *ty = cast<Class##Type>(split.Ty); \
+      const auto *ty = cast<Class##Type>(split.Ty); \
       if (!ty->isSugared()) goto done; \
       next = ty->desugar(); \
       break; \
@@ -335,7 +336,7 @@ SplitQualType QualType::getSplitUnqualif
 
 QualType QualType::IgnoreParens(QualType T) {
   // FIXME: this seems inherently un-qualifiers-safe.
-  while (const ParenType *PT = T->getAs<ParenType>())
+  while (const auto *PT = T->getAs<ParenType>())
     T = PT->getInnerType();
   return T;
 }
@@ -345,13 +346,13 @@ QualType QualType::IgnoreParens(QualType
 /// reaches a T or a non-sugared type.
 template<typename T> static const T *getAsSugar(const Type *Cur) {
   while (true) {
-    if (const T *Sugar = dyn_cast<T>(Cur))
+    if (const auto *Sugar = dyn_cast<T>(Cur))
       return Sugar;
     switch (Cur->getTypeClass()) {
 #define ABSTRACT_TYPE(Class, Parent)
 #define TYPE(Class, Parent) \
     case Type::Class: { \
-      const Class##Type *Ty = cast<Class##Type>(Cur); \
+      const auto *Ty = cast<Class##Type>(Cur); \
       if (!Ty->isSugared()) return 0; \
       Cur = Ty->desugar().getTypePtr(); \
       break; \
@@ -384,7 +385,7 @@ const Type *Type::getUnqualifiedDesugare
 #define ABSTRACT_TYPE(Class, Parent)
 #define TYPE(Class, Parent) \
     case Class: { \
-      const Class##Type *Ty = cast<Class##Type>(Cur); \
+      const auto *Ty = cast<Class##Type>(Cur); \
       if (!Ty->isSugared()) return Cur; \
       Cur = Ty->desugar().getTypePtr(); \
       break; \
@@ -395,28 +396,31 @@ const Type *Type::getUnqualifiedDesugare
 }
 
 bool Type::isClassType() const {
-  if (const RecordType *RT = getAs<RecordType>())
+  if (const auto *RT = getAs<RecordType>())
     return RT->getDecl()->isClass();
   return false;
 }
 
 bool Type::isStructureType() const {
-  if (const RecordType *RT = getAs<RecordType>())
+  if (const auto *RT = getAs<RecordType>())
     return RT->getDecl()->isStruct();
   return false;
 }
+
 bool Type::isObjCBoxableRecordType() const {
-  if (const RecordType *RT = getAs<RecordType>())
+  if (const auto *RT = getAs<RecordType>())
     return RT->getDecl()->hasAttr<ObjCBoxableAttr>();
   return false;
 }
+
 bool Type::isInterfaceType() const {
-  if (const RecordType *RT = getAs<RecordType>())
+  if (const auto *RT = getAs<RecordType>())
     return RT->getDecl()->isInterface();
   return false;
 }
+
 bool Type::isStructureOrClassType() const {
-  if (const RecordType *RT = getAs<RecordType>()) {
+  if (const auto *RT = getAs<RecordType>()) {
     RecordDecl *RD = RT->getDecl();
     return RD->isStruct() || RD->isClass() || RD->isInterface();
   }
@@ -424,19 +428,19 @@ bool Type::isStructureOrClassType() cons
 }
 
 bool Type::isVoidPointerType() const {
-  if (const PointerType *PT = getAs<PointerType>())
+  if (const auto *PT = getAs<PointerType>())
     return PT->getPointeeType()->isVoidType();
   return false;
 }
 
 bool Type::isUnionType() const {
-  if (const RecordType *RT = getAs<RecordType>())
+  if (const auto *RT = getAs<RecordType>())
     return RT->getDecl()->isUnion();
   return false;
 }
 
 bool Type::isComplexType() const {
-  if (const ComplexType *CT = dyn_cast<ComplexType>(CanonicalType))
+  if (const auto *CT = dyn_cast<ComplexType>(CanonicalType))
     return CT->getElementType()->isFloatingType();
   return false;
 }
@@ -447,37 +451,37 @@ bool Type::isComplexIntegerType() const
 }
 
 const ComplexType *Type::getAsComplexIntegerType() const {
-  if (const ComplexType *Complex = getAs<ComplexType>())
+  if (const auto *Complex = getAs<ComplexType>())
     if (Complex->getElementType()->isIntegerType())
       return Complex;
   return nullptr;
 }
 
 QualType Type::getPointeeType() const {
-  if (const PointerType *PT = getAs<PointerType>())
+  if (const auto *PT = getAs<PointerType>())
     return PT->getPointeeType();
-  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
+  if (const auto *OPT = getAs<ObjCObjectPointerType>())
     return OPT->getPointeeType();
-  if (const BlockPointerType *BPT = getAs<BlockPointerType>())
+  if (const auto *BPT = getAs<BlockPointerType>())
     return BPT->getPointeeType();
-  if (const ReferenceType *RT = getAs<ReferenceType>())
+  if (const auto *RT = getAs<ReferenceType>())
     return RT->getPointeeType();
-  if (const MemberPointerType *MPT = getAs<MemberPointerType>())
+  if (const auto *MPT = getAs<MemberPointerType>())
     return MPT->getPointeeType();
-  if (const DecayedType *DT = getAs<DecayedType>())
+  if (const auto *DT = getAs<DecayedType>())
     return DT->getPointeeType();
-  return QualType();
+  return {};
 }
 
 const RecordType *Type::getAsStructureType() const {
   // If this is directly a structure type, return it.
-  if (const RecordType *RT = dyn_cast<RecordType>(this)) {
+  if (const auto *RT = dyn_cast<RecordType>(this)) {
     if (RT->getDecl()->isStruct())
       return RT;
   }
 
   // If the canonical form of this type isn't the right kind, reject it.
-  if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
+  if (const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
     if (!RT->getDecl()->isStruct())
       return nullptr;
 
@@ -490,13 +494,13 @@ const RecordType *Type::getAsStructureTy
 
 const RecordType *Type::getAsUnionType() const {
   // If this is directly a union type, return it.
-  if (const RecordType *RT = dyn_cast<RecordType>(this)) {
+  if (const auto *RT = dyn_cast<RecordType>(this)) {
     if (RT->getDecl()->isUnion())
       return RT;
   }
 
   // If the canonical form of this type isn't the right kind, reject it.
-  if (const RecordType *RT = dyn_cast<RecordType>(CanonicalType)) {
+  if (const auto *RT = dyn_cast<RecordType>(CanonicalType)) {
     if (!RT->getDecl()->isUnion())
       return nullptr;
 
@@ -512,7 +516,7 @@ bool Type::isObjCIdOrObjectKindOfType(co
                                       const ObjCObjectType *&bound) const {
   bound = nullptr;
 
-  const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>();
+  const auto *OPT = getAs<ObjCObjectPointerType>();
   if (!OPT)
     return false;
 
@@ -535,7 +539,7 @@ bool Type::isObjCIdOrObjectKindOfType(co
 }
 
 bool Type::isObjCClassOrClassKindOfType() const {
-  const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>();
+  const auto *OPT = getAs<ObjCObjectPointerType>();
   if (!OPT)
     return false;
 
@@ -560,7 +564,7 @@ bool Type::isObjCClassOrClassKindOfType(
 bool Type::isObjCInertUnsafeUnretainedType() const {
   const Type *cur = this;
   while (true) {
-    if (auto attributed = dyn_cast<AttributedType>(cur)) {
+    if (const auto attributed = dyn_cast<AttributedType>(cur)) {
       if (attributed->getAttrKind() ==
             AttributedType::attr_objc_inert_unsafe_unretained)
         return true;
@@ -622,7 +626,7 @@ bool ObjCObjectType::isSpecialized() con
     return true;
 
   // Otherwise, check whether the base type is specialized.
-  if (auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
+  if (const auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
     // Terminate when we reach an interface type.
     if (isa<ObjCInterfaceType>(objcObject))
       return false;
@@ -640,7 +644,7 @@ ArrayRef<QualType> ObjCObjectType::getTy
     return getTypeArgsAsWritten();
 
   // Look at the base type, which might have type arguments.
-  if (auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
+  if (const auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
     // Terminate when we reach an interface type.
     if (isa<ObjCInterfaceType>(objcObject))
       return {};
@@ -657,7 +661,7 @@ bool ObjCObjectType::isKindOfType() cons
     return true;
 
   // Look at the base type, which might have type arguments.
-  if (auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
+  if (const auto objcObject = getBaseType()->getAs<ObjCObjectType>()) {
     // Terminate when we reach an interface type.
     if (isa<ObjCInterfaceType>(objcObject))
       return false;
@@ -677,10 +681,8 @@ QualType ObjCObjectType::stripObjCKindOf
   // Recursively strip __kindof.
   SplitQualType splitBaseType = getBaseType().split();
   QualType baseType(splitBaseType.Ty, 0);
-  if (const ObjCObjectType *baseObj
-        = splitBaseType.Ty->getAs<ObjCObjectType>()) {
+  if (const auto *baseObj = splitBaseType.Ty->getAs<ObjCObjectType>())
     baseType = baseObj->stripObjCKindOfTypeAndQuals(ctx);
-  }
 
   return ctx.getObjCObjectType(ctx.getQualifiedType(baseType,
                                                     splitBaseType.Quals),
@@ -733,7 +735,7 @@ public:
   QualType VisitComplexType(const ComplexType *T) { 
     QualType elementType = recurse(T->getElementType());
     if (elementType.isNull())
-      return QualType();
+      return {};
 
     if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
       return QualType(T, 0);
@@ -744,7 +746,7 @@ public:
   QualType VisitPointerType(const PointerType *T) {
     QualType pointeeType = recurse(T->getPointeeType());
     if (pointeeType.isNull())
-      return QualType();
+      return {};
 
     if (pointeeType.getAsOpaquePtr() == T->getPointeeType().getAsOpaquePtr())
       return QualType(T, 0);
@@ -755,7 +757,7 @@ public:
   QualType VisitBlockPointerType(const BlockPointerType *T) {
     QualType pointeeType = recurse(T->getPointeeType());
     if (pointeeType.isNull())
-      return QualType();
+      return {};
 
     if (pointeeType.getAsOpaquePtr() == T->getPointeeType().getAsOpaquePtr())
       return QualType(T, 0);
@@ -766,7 +768,7 @@ public:
   QualType VisitLValueReferenceType(const LValueReferenceType *T) {
     QualType pointeeType = recurse(T->getPointeeTypeAsWritten());
     if (pointeeType.isNull())
-      return QualType();
+      return {};
 
     if (pointeeType.getAsOpaquePtr() 
           == T->getPointeeTypeAsWritten().getAsOpaquePtr())
@@ -778,7 +780,7 @@ public:
   QualType VisitRValueReferenceType(const RValueReferenceType *T) {
     QualType pointeeType = recurse(T->getPointeeTypeAsWritten());
     if (pointeeType.isNull())
-      return QualType();
+      return {};
 
     if (pointeeType.getAsOpaquePtr() 
           == T->getPointeeTypeAsWritten().getAsOpaquePtr())
@@ -790,7 +792,7 @@ public:
   QualType VisitMemberPointerType(const MemberPointerType *T) {
     QualType pointeeType = recurse(T->getPointeeType());
     if (pointeeType.isNull())
-      return QualType();
+      return {};
 
     if (pointeeType.getAsOpaquePtr() == T->getPointeeType().getAsOpaquePtr())
       return QualType(T, 0);
@@ -801,7 +803,7 @@ public:
   QualType VisitConstantArrayType(const ConstantArrayType *T) {
     QualType elementType = recurse(T->getElementType());
     if (elementType.isNull())
-      return QualType();
+      return {};
 
     if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
       return QualType(T, 0);
@@ -814,7 +816,7 @@ public:
   QualType VisitVariableArrayType(const VariableArrayType *T) {
     QualType elementType = recurse(T->getElementType());
     if (elementType.isNull())
-      return QualType();
+      return {};
 
     if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
       return QualType(T, 0);
@@ -828,7 +830,7 @@ public:
   QualType VisitIncompleteArrayType(const IncompleteArrayType *T) {
     QualType elementType = recurse(T->getElementType());
     if (elementType.isNull())
-      return QualType();
+      return {};
 
     if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
       return QualType(T, 0);
@@ -840,7 +842,7 @@ public:
   QualType VisitVectorType(const VectorType *T) { 
     QualType elementType = recurse(T->getElementType());
     if (elementType.isNull())
-      return QualType();
+      return {};
 
     if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
       return QualType(T, 0);
@@ -852,7 +854,7 @@ public:
   QualType VisitExtVectorType(const ExtVectorType *T) { 
     QualType elementType = recurse(T->getElementType());
     if (elementType.isNull())
-      return QualType();
+      return {};
 
     if (elementType.getAsOpaquePtr() == T->getElementType().getAsOpaquePtr())
       return QualType(T, 0);
@@ -863,7 +865,7 @@ public:
   QualType VisitFunctionNoProtoType(const FunctionNoProtoType *T) { 
     QualType returnType = recurse(T->getReturnType());
     if (returnType.isNull())
-      return QualType();
+      return {};
 
     if (returnType.getAsOpaquePtr() == T->getReturnType().getAsOpaquePtr())
       return QualType(T, 0);
@@ -874,7 +876,7 @@ public:
   QualType VisitFunctionProtoType(const FunctionProtoType *T) { 
     QualType returnType = recurse(T->getReturnType());
     if (returnType.isNull())
-      return QualType();
+      return {};
 
     // Transform parameter types.
     SmallVector<QualType, 4> paramTypes;
@@ -882,7 +884,7 @@ public:
     for (auto paramType : T->getParamTypes()) {
       QualType newParamType = recurse(paramType);
       if (newParamType.isNull())
-        return QualType();
+        return {};
 
       if (newParamType.getAsOpaquePtr() != paramType.getAsOpaquePtr())
         paramChanged = true;
@@ -898,10 +900,9 @@ public:
       for (auto exceptionType : info.ExceptionSpec.Exceptions) {
         QualType newExceptionType = recurse(exceptionType);
         if (newExceptionType.isNull())
-          return QualType();
+          return {};
         
-        if (newExceptionType.getAsOpaquePtr() 
-              != exceptionType.getAsOpaquePtr())
+        if (newExceptionType.getAsOpaquePtr() != exceptionType.getAsOpaquePtr())
           exceptionChanged = true;
 
         exceptionTypes.push_back(newExceptionType);
@@ -923,7 +924,7 @@ public:
   QualType VisitParenType(const ParenType *T) { 
     QualType innerType = recurse(T->getInnerType());
     if (innerType.isNull())
-      return QualType();
+      return {};
 
     if (innerType.getAsOpaquePtr() == T->getInnerType().getAsOpaquePtr())
       return QualType(T, 0);
@@ -937,11 +938,11 @@ public:
   QualType VisitAdjustedType(const AdjustedType *T) { 
     QualType originalType = recurse(T->getOriginalType());
     if (originalType.isNull())
-      return QualType();
+      return {};
 
     QualType adjustedType = recurse(T->getAdjustedType());
     if (adjustedType.isNull())
-      return QualType();
+      return {};
 
     if (originalType.getAsOpaquePtr() 
           == T->getOriginalType().getAsOpaquePtr() &&
@@ -954,7 +955,7 @@ public:
   QualType VisitDecayedType(const DecayedType *T) { 
     QualType originalType = recurse(T->getOriginalType());
     if (originalType.isNull())
-      return QualType();
+      return {};
 
     if (originalType.getAsOpaquePtr() 
           == T->getOriginalType().getAsOpaquePtr())
@@ -976,11 +977,11 @@ public:
   QualType VisitAttributedType(const AttributedType *T) { 
     QualType modifiedType = recurse(T->getModifiedType());
     if (modifiedType.isNull())
-      return QualType();
+      return {};
 
     QualType equivalentType = recurse(T->getEquivalentType());
     if (equivalentType.isNull())
-      return QualType();
+      return {};
 
     if (modifiedType.getAsOpaquePtr() 
           == T->getModifiedType().getAsOpaquePtr() &&
@@ -995,7 +996,7 @@ public:
   QualType VisitSubstTemplateTypeParmType(const SubstTemplateTypeParmType *T) {
     QualType replacementType = recurse(T->getReplacementType());
     if (replacementType.isNull())
-      return QualType();
+      return {};
 
     if (replacementType.getAsOpaquePtr() 
           == T->getReplacementType().getAsOpaquePtr())
@@ -1014,7 +1015,7 @@ public:
 
     QualType deducedType = recurse(T->getDeducedType());
     if (deducedType.isNull())
-      return QualType();
+      return {};
 
     if (deducedType.getAsOpaquePtr() 
           == T->getDeducedType().getAsOpaquePtr())
@@ -1030,7 +1031,7 @@ public:
   QualType VisitObjCObjectType(const ObjCObjectType *T) {
     QualType baseType = recurse(T->getBaseType());
     if (baseType.isNull())
-      return QualType();
+      return {};
 
     // Transform type arguments.
     bool typeArgChanged = false;
@@ -1038,7 +1039,7 @@ public:
     for (auto typeArg : T->getTypeArgsAsWritten()) {
       QualType newTypeArg = recurse(typeArg);
       if (newTypeArg.isNull())
-        return QualType();
+        return {};
 
       if (newTypeArg.getAsOpaquePtr() != typeArg.getAsOpaquePtr())
         typeArgChanged = true;
@@ -1061,7 +1062,7 @@ public:
   QualType VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
     QualType pointeeType = recurse(T->getPointeeType());
     if (pointeeType.isNull())
-      return QualType();
+      return {};
 
     if (pointeeType.getAsOpaquePtr() 
           == T->getPointeeType().getAsOpaquePtr())
@@ -1073,7 +1074,7 @@ public:
   QualType VisitAtomicType(const AtomicType *T) {
     QualType valueType = recurse(T->getValueType());
     if (valueType.isNull())
-      return QualType();
+      return {};
 
     if (valueType.getAsOpaquePtr() 
           == T->getValueType().getAsOpaquePtr())
@@ -1184,7 +1185,7 @@ QualType QualType::substObjCTypeArgs(
                               typeArgs,
                               ObjCSubstitutionContext::Result);
       if (returnType.isNull())
-        return QualType();
+        return {};
 
       // Handle non-prototyped functions, which only substitute into the result
       // type.
@@ -1209,7 +1210,7 @@ QualType QualType::substObjCTypeArgs(
                                   typeArgs,
                                   ObjCSubstitutionContext::Parameter);
         if (newParamType.isNull())
-          return QualType();
+          return {};
 
         if (newParamType.getAsOpaquePtr() != paramType.getAsOpaquePtr())
           paramChanged = true;
@@ -1228,7 +1229,7 @@ QualType QualType::substObjCTypeArgs(
                                         typeArgs,
                                         ObjCSubstitutionContext::Ordinary);
           if (newExceptionType.isNull())
-            return QualType();
+            return {};
 
           if (newExceptionType.getAsOpaquePtr()
               != exceptionType.getAsOpaquePtr())
@@ -1262,7 +1263,7 @@ QualType QualType::substObjCTypeArgs(
                                   ctx, typeArgs,
                                   ObjCSubstitutionContext::Ordinary);
           if (newTypeArg.isNull())
-            return QualType();
+            return {};
 
           if (newTypeArg.getAsOpaquePtr() != typeArg.getAsOpaquePtr()) {
             // If we're substituting based on an unspecialized context type,
@@ -1335,7 +1336,7 @@ QualType QualType::stripObjCKindOfType(c
 }
 
 QualType QualType::getAtomicUnqualifiedType() const {
-  if (auto AT = getTypePtr()->getAs<AtomicType>())
+  if (const auto AT = getTypePtr()->getAs<AtomicType>())
     return AT->getValueType().getUnqualifiedType();
   return getUnqualifiedType();
 }
@@ -1343,12 +1344,12 @@ QualType QualType::getAtomicUnqualifiedT
 Optional<ArrayRef<QualType>> Type::getObjCSubstitutions(
                                const DeclContext *dc) const {
   // Look through method scopes.
-  if (auto method = dyn_cast<ObjCMethodDecl>(dc))
+  if (const auto method = dyn_cast<ObjCMethodDecl>(dc))
     dc = method->getDeclContext();
 
   // Find the class or category in which the type we're substituting
   // was declared.
-  const ObjCInterfaceDecl *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
+  const auto *dcClassDecl = dyn_cast<ObjCInterfaceDecl>(dc);
   const ObjCCategoryDecl *dcCategoryDecl = nullptr;
   ObjCTypeParamList *dcTypeParams = nullptr;
   if (dcClassDecl) {
@@ -1525,7 +1526,7 @@ const ObjCObjectType *Type::getAsObjCQua
   // There is no sugar for ObjCObjectType's, just return the canonical
   // type pointer if it is the right class.  There is no typedef information to
   // return and these cannot be Address-space qualified.
-  if (const ObjCObjectType *T = getAs<ObjCObjectType>())
+  if (const auto *T = getAs<ObjCObjectType>())
     if (T->getNumProtocols() && T->getInterface())
       return T;
   return nullptr;
@@ -1538,7 +1539,7 @@ bool Type::isObjCQualifiedInterfaceType(
 const ObjCObjectPointerType *Type::getAsObjCQualifiedIdType() const {
   // There is no sugar for ObjCQualifiedIdType's, just return the canonical
   // type pointer if it is the right class.
-  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>()) {
+  if (const auto *OPT = getAs<ObjCObjectPointerType>()) {
     if (OPT->isObjCQualifiedIdType())
       return OPT;
   }
@@ -1548,7 +1549,7 @@ const ObjCObjectPointerType *Type::getAs
 const ObjCObjectPointerType *Type::getAsObjCQualifiedClassType() const {
   // There is no sugar for ObjCQualifiedClassType's, just return the canonical
   // type pointer if it is the right class.
-  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>()) {
+  if (const auto *OPT = getAs<ObjCObjectPointerType>()) {
     if (OPT->isObjCQualifiedClassType())
       return OPT;
   }
@@ -1556,7 +1557,7 @@ const ObjCObjectPointerType *Type::getAs
 }
 
 const ObjCObjectType *Type::getAsObjCInterfaceType() const {
-  if (const ObjCObjectType *OT = getAs<ObjCObjectType>()) {
+  if (const auto *OT = getAs<ObjCObjectType>()) {
     if (OT->getInterface())
       return OT;
   }
@@ -1564,7 +1565,7 @@ const ObjCObjectType *Type::getAsObjCInt
 }
 
 const ObjCObjectPointerType *Type::getAsObjCInterfacePointerType() const {
-  if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>()) {
+  if (const auto *OPT = getAs<ObjCObjectPointerType>()) {
     if (OPT->getInterfaceType())
       return OPT;
   }
@@ -1573,14 +1574,14 @@ const ObjCObjectPointerType *Type::getAs
 
 const CXXRecordDecl *Type::getPointeeCXXRecordDecl() const {
   QualType PointeeType;
-  if (const PointerType *PT = getAs<PointerType>())
+  if (const auto *PT = getAs<PointerType>())
     PointeeType = PT->getPointeeType();
-  else if (const ReferenceType *RT = getAs<ReferenceType>())
+  else if (const auto *RT = getAs<ReferenceType>())
     PointeeType = RT->getPointeeType();
   else
     return nullptr;
 
-  if (const RecordType *RT = PointeeType->getAs<RecordType>())
+  if (const auto *RT = PointeeType->getAs<RecordType>())
     return dyn_cast<CXXRecordDecl>(RT->getDecl());
 
   return nullptr;
@@ -1693,7 +1694,7 @@ bool Type::hasAutoForTrailingReturnType(
 }
 
 bool Type::hasIntegerRepresentation() const {
-  if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
+  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
     return VT->getElementType()->isIntegerType();
   else
     return isIntegerType();
@@ -1719,20 +1720,20 @@ bool Type::hasIntegerRepresentation() co
 ///
 /// \returns true if the type is considered an integral type, false otherwise.
 bool Type::isIntegralType(const ASTContext &Ctx) const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::Int128;
 
   // Complete enum types are integral in C.
   if (!Ctx.getLangOpts().CPlusPlus)
-    if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
+    if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
       return ET->getDecl()->isComplete();
 
   return false;
 }
 
 bool Type::isIntegralOrUnscopedEnumerationType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::Int128;
 
@@ -1740,14 +1741,14 @@ bool Type::isIntegralOrUnscopedEnumerati
   // enumeration type in the sense required here.
   // C++0x: However, if the underlying type of the enum is fixed, it is
   // considered complete.
-  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
+  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
     return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
 
   return false;
 }
 
 bool Type::isCharType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() == BuiltinType::Char_U ||
            BT->getKind() == BuiltinType::UChar ||
            BT->getKind() == BuiltinType::Char_S ||
@@ -1756,20 +1757,20 @@ bool Type::isCharType() const {
 }
 
 bool Type::isWideCharType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() == BuiltinType::WChar_S ||
            BT->getKind() == BuiltinType::WChar_U;
   return false;
 }
 
 bool Type::isChar16Type() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() == BuiltinType::Char16;
   return false;
 }
 
 bool Type::isChar32Type() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() == BuiltinType::Char32;
   return false;
 }
@@ -1777,7 +1778,7 @@ bool Type::isChar32Type() const {
 /// \brief Determine whether this type is any of the built-in character
 /// types.
 bool Type::isAnyCharacterType() const {
-  const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType);
+  const auto *BT = dyn_cast<BuiltinType>(CanonicalType);
   if (!BT) return false;
   switch (BT->getKind()) {
   default: return false;
@@ -1797,7 +1798,7 @@ bool Type::isAnyCharacterType() const {
 /// signed, according to C99 6.2.5p4 [char, signed char, short, int, long..],
 /// an enum decl which has a signed representation
 bool Type::isSignedIntegerType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
     return BT->getKind() >= BuiltinType::Char_S &&
            BT->getKind() <= BuiltinType::Int128;
   }
@@ -1813,12 +1814,12 @@ bool Type::isSignedIntegerType() const {
 }
 
 bool Type::isSignedIntegerOrEnumerationType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
     return BT->getKind() >= BuiltinType::Char_S &&
            BT->getKind() <= BuiltinType::Int128;
   }
   
-  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
+  if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
     if (ET->getDecl()->isComplete())
       return ET->getDecl()->getIntegerType()->isSignedIntegerType();
   }
@@ -1827,7 +1828,7 @@ bool Type::isSignedIntegerOrEnumerationT
 }
 
 bool Type::hasSignedIntegerRepresentation() const {
-  if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
+  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
     return VT->getElementType()->isSignedIntegerOrEnumerationType();
   else
     return isSignedIntegerOrEnumerationType();
@@ -1837,12 +1838,12 @@ bool Type::hasSignedIntegerRepresentatio
 /// unsigned, according to C99 6.2.5p6 [which returns true for _Bool], an enum
 /// decl which has an unsigned representation
 bool Type::isUnsignedIntegerType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::UInt128;
   }
 
-  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
+  if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
     // Incomplete enum types are not treated as integer types.
     // FIXME: In C++, enum types are never integer types.
     if (ET->getDecl()->isComplete() && !ET->getDecl()->isScoped())
@@ -1853,12 +1854,12 @@ bool Type::isUnsignedIntegerType() const
 }
 
 bool Type::isUnsignedIntegerOrEnumerationType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType)) {
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType)) {
     return BT->getKind() >= BuiltinType::Bool &&
     BT->getKind() <= BuiltinType::UInt128;
   }
   
-  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
+  if (const auto *ET = dyn_cast<EnumType>(CanonicalType)) {
     if (ET->getDecl()->isComplete())
       return ET->getDecl()->getIntegerType()->isUnsignedIntegerType();
   }
@@ -1867,48 +1868,48 @@ bool Type::isUnsignedIntegerOrEnumeratio
 }
 
 bool Type::hasUnsignedIntegerRepresentation() const {
-  if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
+  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
     return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
   else
     return isUnsignedIntegerOrEnumerationType();
 }
 
 bool Type::isFloatingType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() >= BuiltinType::Half &&
            BT->getKind() <= BuiltinType::Float128;
-  if (const ComplexType *CT = dyn_cast<ComplexType>(CanonicalType))
+  if (const auto *CT = dyn_cast<ComplexType>(CanonicalType))
     return CT->getElementType()->isFloatingType();
   return false;
 }
 
 bool Type::hasFloatingRepresentation() const {
-  if (const VectorType *VT = dyn_cast<VectorType>(CanonicalType))
+  if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
     return VT->getElementType()->isFloatingType();
   else
     return isFloatingType();
 }
 
 bool Type::isRealFloatingType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->isFloatingPoint();
   return false;
 }
 
 bool Type::isRealType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::Float128;
-  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
+  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
       return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped();
   return false;
 }
 
 bool Type::isArithmeticType() const {
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
+  if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() >= BuiltinType::Bool &&
            BT->getKind() <= BuiltinType::Float128;
-  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
+  if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
     // GCC allows forward declaration of enum types (forbid by C99 6.7.2.3p2).
     // If a body isn't seen by the time we get here, return false.
     //
@@ -1923,7 +1924,7 @@ Type::ScalarTypeKind Type::getScalarType
   assert(isScalarType());
 
   const Type *T = CanonicalType.getTypePtr();
-  if (const BuiltinType *BT = dyn_cast<BuiltinType>(T)) {
+  if (const auto *BT = dyn_cast<BuiltinType>(T)) {
     if (BT->getKind() == BuiltinType::Bool) return STK_Bool;
     if (BT->getKind() == BuiltinType::NullPtr) return STK_CPointer;
     if (BT->isInteger()) return STK_Integral;
@@ -1940,7 +1941,7 @@ Type::ScalarTypeKind Type::getScalarType
   } else if (isa<EnumType>(T)) {
     assert(cast<EnumType>(T)->getDecl()->isComplete());
     return STK_Integral;
-  } else if (const ComplexType *CT = dyn_cast<ComplexType>(T)) {
+  } else if (const auto *CT = dyn_cast<ComplexType>(T)) {
     if (CT->getElementType()->isRealFloatingType())
       return STK_FloatingComplex;
     return STK_IntegralComplex;
@@ -1959,8 +1960,8 @@ Type::ScalarTypeKind Type::getScalarType
 /// subsumes the notion of C aggregates (C99 6.2.5p21) because it also
 /// includes union types.
 bool Type::isAggregateType() const {
-  if (const RecordType *Record = dyn_cast<RecordType>(CanonicalType)) {
-    if (CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
+  if (const auto *Record = dyn_cast<RecordType>(CanonicalType)) {
+    if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(Record->getDecl()))
       return ClassDecl->isAggregate();
 
     return true;
@@ -2099,8 +2100,8 @@ bool QualType::isCXX98PODType(const ASTC
     return true;
 
   case Type::Record:
-    if (CXXRecordDecl *ClassDecl
-          = dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
+    if (const auto *ClassDecl =
+            dyn_cast<CXXRecordDecl>(cast<RecordType>(CanonicalType)->getDecl()))
       return ClassDecl->isPOD();
 
     // C struct/union is POD.
@@ -2138,9 +2139,8 @@ bool QualType::isTrivialType(const ASTCo
   // As an extension, Clang treats vector types as Scalar types.
   if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
     return true;
-  if (const RecordType *RT = CanonicalType->getAs<RecordType>()) {
-    if (const CXXRecordDecl *ClassDecl =
-        dyn_cast<CXXRecordDecl>(RT->getDecl())) {
+  if (const auto *RT = CanonicalType->getAs<RecordType>()) {
+    if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
       // C++11 [class]p6:
       //   A trivial class is a class that has a default constructor,
       //   has no non-trivial default constructors, and is trivially
@@ -2182,9 +2182,8 @@ bool QualType::isTriviallyCopyableType(c
   if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
     return true;
 
-  if (const RecordType *RT = CanonicalType->getAs<RecordType>()) {
-    if (const CXXRecordDecl *ClassDecl =
-          dyn_cast<CXXRecordDecl>(RT->getDecl())) {
+  if (const auto *RT = CanonicalType->getAs<RecordType>()) {
+    if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
       if (!ClassDecl->isTriviallyCopyable()) return false;
     }
 
@@ -2287,7 +2286,7 @@ bool Type::isLiteralType(const ASTContex
   if (BaseTy->isReferenceType())
     return true;
   //    -- a class type that has all of the following properties:
-  if (const RecordType *RT = BaseTy->getAs<RecordType>()) {
+  if (const auto *RT = BaseTy->getAs<RecordType>()) {
     //    -- a trivial destructor,
     //    -- every constructor call and full-expression in the
     //       brace-or-equal-initializers for non-static data members (if any)
@@ -2298,15 +2297,14 @@ bool Type::isLiteralType(const ASTContex
     //    -- all non-static data members and base classes of literal types
     //
     // We resolve DR1361 by ignoring the second bullet.
-    if (const CXXRecordDecl *ClassDecl =
-        dyn_cast<CXXRecordDecl>(RT->getDecl()))
+    if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
       return ClassDecl->isLiteral();
 
     return true;
   }
 
   // We treat _Atomic T as a literal type if T is a literal type.
-  if (const AtomicType *AT = BaseTy->getAs<AtomicType>())
+  if (const auto *AT = BaseTy->getAs<AtomicType>())
     return AT->getValueType()->isLiteralType(Ctx);
 
   // If this type hasn't been deduced yet, then conservatively assume that
@@ -2335,9 +2333,8 @@ bool Type::isStandardLayoutType() const
 
   // As an extension, Clang treats vector types as Scalar types.
   if (BaseTy->isScalarType() || BaseTy->isVectorType()) return true;
-  if (const RecordType *RT = BaseTy->getAs<RecordType>()) {
-    if (const CXXRecordDecl *ClassDecl =
-        dyn_cast<CXXRecordDecl>(RT->getDecl()))
+  if (const auto *RT = BaseTy->getAs<RecordType>()) {
+    if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl()))
       if (!ClassDecl->isStandardLayout())
         return false;
 
@@ -2375,9 +2372,8 @@ bool QualType::isCXX11PODType(const ASTC
 
   // As an extension, Clang treats vector types as Scalar types.
   if (BaseTy->isScalarType() || BaseTy->isVectorType()) return true;
-  if (const RecordType *RT = BaseTy->getAs<RecordType>()) {
-    if (const CXXRecordDecl *ClassDecl =
-        dyn_cast<CXXRecordDecl>(RT->getDecl())) {
+  if (const auto *RT = BaseTy->getAs<RecordType>()) {
+    if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
       // C++11 [class]p10:
       //   A POD struct is a non-union class that is both a trivial class [...]
       if (!ClassDecl->isTrivial()) return false;
@@ -2405,8 +2401,8 @@ bool QualType::isCXX11PODType(const ASTC
 }
 
 bool Type::isAlignValT() const {
-  if (auto *ET = getAs<EnumType>()) {
-    auto *II = ET->getDecl()->getIdentifier();
+  if (const auto *ET = getAs<EnumType>()) {
+    IdentifierInfo *II = ET->getDecl()->getIdentifier();
     if (II && II->isStr("align_val_t") && ET->getDecl()->isInStdNamespace())
       return true;
   }
@@ -2414,8 +2410,8 @@ bool Type::isAlignValT() const {
 }
 
 bool Type::isStdByteType() const {
-  if (auto *ET = getAs<EnumType>()) {
-    auto *II = ET->getDecl()->getIdentifier();
+  if (const auto *ET = getAs<EnumType>()) {
+    IdentifierInfo *II = ET->getDecl()->getIdentifier();
     if (II && II->isStr("byte") && ET->getDecl()->isInStdNamespace())
       return true;
   }
@@ -2423,7 +2419,7 @@ bool Type::isStdByteType() const {
 }
 
 bool Type::isPromotableIntegerType() const {
-  if (const BuiltinType *BT = getAs<BuiltinType>())
+  if (const auto *BT = getAs<BuiltinType>())
     switch (BT->getKind()) {
     case BuiltinType::Bool:
     case BuiltinType::Char_S:
@@ -2443,7 +2439,7 @@ bool Type::isPromotableIntegerType() con
 
   // Enumerated types are promotable to their compatible integer types
   // (C99 6.3.1.1) a.k.a. its underlying type (C++ [conv.prom]p2).
-  if (const EnumType *ET = getAs<EnumType>()){
+  if (const auto *ET = getAs<EnumType>()){
     if (this->isDependentType() || ET->getDecl()->getPromotionType().isNull()
         || ET->getDecl()->isScoped())
       return false;
@@ -2550,7 +2546,7 @@ TypeWithKeyword::KeywordIsTagTypeKind(El
 
 StringRef TypeWithKeyword::getKeywordName(ElaboratedTypeKeyword Keyword) {
   switch (Keyword) {
-  case ETK_None: return "";
+  case ETK_None: return {};
   case ETK_Typename: return "typename";
   case ETK_Class:  return "class";
   case ETK_Struct: return "struct";
@@ -2598,12 +2594,12 @@ DependentTemplateSpecializationType::Pro
 
 bool Type::isElaboratedTypeSpecifier() const {
   ElaboratedTypeKeyword Keyword;
-  if (const ElaboratedType *Elab = dyn_cast<ElaboratedType>(this))
+  if (const auto *Elab = dyn_cast<ElaboratedType>(this))
     Keyword = Elab->getKeyword();
-  else if (const DependentNameType *DepName = dyn_cast<DependentNameType>(this))
+  else if (const auto *DepName = dyn_cast<DependentNameType>(this))
     Keyword = DepName->getKeyword();
-  else if (const DependentTemplateSpecializationType *DepTST =
-             dyn_cast<DependentTemplateSpecializationType>(this))
+  else if (const auto *DepTST =
+               dyn_cast<DependentTemplateSpecializationType>(this))
     Keyword = DepTST->getKeyword();
   else
     return false;
@@ -2718,7 +2714,7 @@ StringRef BuiltinType::getName(const Pri
 }
 
 QualType QualType::getNonLValueExprType(const ASTContext &Context) const {
-  if (const ReferenceType *RefType = getTypePtr()->getAs<ReferenceType>())
+  if (const auto *RefType = getTypePtr()->getAs<ReferenceType>())
     return RefType->getPointeeType();
   
   // C++0x [basic.lval]:
@@ -2777,7 +2773,7 @@ FunctionProtoType::FunctionProtoType(Qua
   FunctionTypeBits.RefQualifier = epi.RefQualifier;
 
   // Fill in the trailing argument array.
-  QualType *argSlot = reinterpret_cast<QualType*>(this+1);
+  auto *argSlot = reinterpret_cast<QualType *>(this+1);
   for (unsigned i = 0; i != NumParams; ++i) {
     if (params[i]->isDependentType())
       setDependent();
@@ -2808,7 +2804,7 @@ FunctionProtoType::FunctionProtoType(Qua
     }
   } else if (getExceptionSpecType() == EST_ComputedNoexcept) {
     // Store the noexcept expression and context.
-    Expr **noexSlot = reinterpret_cast<Expr **>(argSlot + NumParams);
+    auto **noexSlot = reinterpret_cast<Expr **>(argSlot + NumParams);
     *noexSlot = epi.ExceptionSpec.NoexceptExpr;
 
     if (epi.ExceptionSpec.NoexceptExpr) {
@@ -2822,8 +2818,7 @@ FunctionProtoType::FunctionProtoType(Qua
   } else if (getExceptionSpecType() == EST_Uninstantiated) {
     // Store the function decl from which we will resolve our
     // exception specification.
-    FunctionDecl **slot =
-        reinterpret_cast<FunctionDecl **>(argSlot + NumParams);
+    auto **slot = reinterpret_cast<FunctionDecl **>(argSlot + NumParams);
     slot[0] = epi.ExceptionSpec.SourceDecl;
     slot[1] = epi.ExceptionSpec.SourceTemplate;
     // This exception specification doesn't make the type dependent, because
@@ -2831,8 +2826,7 @@ FunctionProtoType::FunctionProtoType(Qua
   } else if (getExceptionSpecType() == EST_Unevaluated) {
     // Store the function decl from which we will resolve our
     // exception specification.
-    FunctionDecl **slot =
-        reinterpret_cast<FunctionDecl **>(argSlot + NumParams);
+    auto **slot = reinterpret_cast<FunctionDecl **>(argSlot + NumParams);
     slot[0] = epi.ExceptionSpec.SourceDecl;
   }
 
@@ -2850,7 +2844,7 @@ FunctionProtoType::FunctionProtoType(Qua
   }
 
   if (epi.ExtParameterInfos) {
-    ExtParameterInfo *extParamInfos =
+    auto *extParamInfos =
       const_cast<ExtParameterInfo *>(getExtParameterInfosBuffer());
     for (unsigned i = 0; i != NumParams; ++i)
       extParamInfos[i] = epi.ExtParameterInfos[i];
@@ -3093,7 +3087,7 @@ bool RecordType::hasConstFields() const
     if (FieldTy.isConstQualified())
       return true;
     FieldTy = FieldTy.getCanonicalType();
-    if (const RecordType *FieldRecTy = FieldTy->getAs<RecordType>())
+    if (const auto *FieldRecTy = FieldTy->getAs<RecordType>())
       if (FieldRecTy->hasConstFields())
         return true;
   }
@@ -3276,8 +3270,7 @@ TemplateSpecializationType(TemplateName
           T.getKind() == TemplateName::SubstTemplateTemplateParmPack) &&
          "Unexpected template name for TemplateSpecializationType");
 
-  TemplateArgument *TemplateArgs
-    = reinterpret_cast<TemplateArgument *>(this + 1);
+  auto *TemplateArgs = reinterpret_cast<TemplateArgument *>(this + 1);
   for (const TemplateArgument &Arg : Args) {
     // Update instantiation-dependent and variably-modified bits.
     // If the canonical type exists and is non-dependent, the template
@@ -3299,7 +3292,7 @@ TemplateSpecializationType(TemplateName
 
   // Store the aliased type if this is a type alias template specialization.
   if (TypeAlias) {
-    TemplateArgument *Begin = reinterpret_cast<TemplateArgument *>(this + 1);
+    auto *Begin = reinterpret_cast<TemplateArgument *>(this + 1);
     *reinterpret_cast<QualType*>(Begin + getNumArgs()) = AliasedType;
   }
 }
@@ -3497,7 +3490,7 @@ static CachedProperties computeCachedPro
   case Type::RValueReference:
     return Cache::get(cast<ReferenceType>(T)->getPointeeType());
   case Type::MemberPointer: {
-    const MemberPointerType *MPT = cast<MemberPointerType>(T);
+    const auto *MPT = cast<MemberPointerType>(T);
     return merge(Cache::get(MPT->getClass()),
                  Cache::get(MPT->getPointeeType()));
   }
@@ -3511,7 +3504,7 @@ static CachedProperties computeCachedPro
   case Type::FunctionNoProto:
     return Cache::get(cast<FunctionType>(T)->getReturnType());
   case Type::FunctionProto: {
-    const FunctionProtoType *FPT = cast<FunctionProtoType>(T);
+    const auto *FPT = cast<FunctionProtoType>(T);
     CachedProperties result = Cache::get(FPT->getReturnType());
     for (const auto &ai : FPT->param_types())
       result = merge(result, Cache::get(ai));
@@ -3581,7 +3574,7 @@ LinkageInfo LinkageComputer::computeType
   case Type::RValueReference:
     return computeTypeLinkageInfo(cast<ReferenceType>(T)->getPointeeType());
   case Type::MemberPointer: {
-    const MemberPointerType *MPT = cast<MemberPointerType>(T);
+    const auto *MPT = cast<MemberPointerType>(T);
     LinkageInfo LV = computeTypeLinkageInfo(MPT->getClass());
     LV.merge(computeTypeLinkageInfo(MPT->getPointeeType()));
     return LV;
@@ -3596,7 +3589,7 @@ LinkageInfo LinkageComputer::computeType
   case Type::FunctionNoProto:
     return computeTypeLinkageInfo(cast<FunctionType>(T)->getReturnType());
   case Type::FunctionProto: {
-    const FunctionProtoType *FPT = cast<FunctionProtoType>(T);
+    const auto *FPT = cast<FunctionProtoType>(T);
     LinkageInfo LV = computeTypeLinkageInfo(FPT->getReturnType());
     for (const auto &ai : FPT->param_types())
       LV.merge(computeTypeLinkageInfo(ai));
@@ -3791,7 +3784,7 @@ Optional<NullabilityKind> AttributedType
 }
 
 bool Type::isBlockCompatibleObjCPointerType(ASTContext &ctx) const {
-  const ObjCObjectPointerType *objcPtr = getAs<ObjCObjectPointerType>();
+  const auto *objcPtr = getAs<ObjCObjectPointerType>();
   if (!objcPtr)
     return false;
 
@@ -3836,11 +3829,10 @@ bool Type::isObjCARCImplicitlyUnretained
   const Type *canon = getCanonicalTypeInternal().getTypePtr();
 
   // Walk down to the base type.  We don't care about qualifiers for this.
-  while (const ArrayType *array = dyn_cast<ArrayType>(canon))
+  while (const auto *array = dyn_cast<ArrayType>(canon))
     canon = array->getElementType().getTypePtr();
 
-  if (const ObjCObjectPointerType *opt
-        = dyn_cast<ObjCObjectPointerType>(canon)) {
+  if (const auto *opt = dyn_cast<ObjCObjectPointerType>(canon)) {
     // Class and Class<Protocol> don't require retention.
     if (opt->getObjectType()->isObjCClass())
       return true;
@@ -3852,7 +3844,7 @@ bool Type::isObjCARCImplicitlyUnretained
 bool Type::isObjCNSObjectType() const {
   const Type *cur = this;
   while (true) {
-    if (const TypedefType *typedefType = dyn_cast<TypedefType>(cur))
+    if (const auto *typedefType = dyn_cast<TypedefType>(cur))
       return typedefType->getDecl()->hasAttr<ObjCNSObjectAttr>();
 
     // Single-step desugar until we run out of sugar.
@@ -3863,7 +3855,7 @@ bool Type::isObjCNSObjectType() const {
 }
 
 bool Type::isObjCIndependentClassType() const {
-  if (const TypedefType *typedefType = dyn_cast<TypedefType>(this))
+  if (const auto *typedefType = dyn_cast<TypedefType>(this))
     return typedefType->getDecl()->hasAttr<ObjCIndependentClassAttr>();
   return false;
 }
@@ -3877,11 +3869,11 @@ bool Type::isObjCRetainableType() const
 bool Type::isObjCIndirectLifetimeType() const {
   if (isObjCLifetimeType())
     return true;
-  if (const PointerType *OPT = getAs<PointerType>())
+  if (const auto *OPT = getAs<PointerType>())
     return OPT->getPointeeType()->isObjCIndirectLifetimeType();
-  if (const ReferenceType *Ref = getAs<ReferenceType>())
+  if (const auto *Ref = getAs<ReferenceType>())
     return Ref->getPointeeType()->isObjCIndirectLifetimeType();
-  if (const MemberPointerType *MemPtr = getAs<MemberPointerType>())
+  if (const auto *MemPtr = getAs<MemberPointerType>())
     return MemPtr->getPointeeType()->isObjCIndirectLifetimeType();
   return false;
 }
@@ -3903,7 +3895,7 @@ bool Type::isObjCARCBridgableType() cons
 
 /// \brief Determine whether the given type T is a "bridgeable" C type.
 bool Type::isCARCBridgableType() const {
-  const PointerType *Pointer = getAs<PointerType>();
+  const auto *Pointer = getAs<PointerType>();
   if (!Pointer)
     return false;
   
@@ -3914,9 +3906,9 @@ bool Type::isCARCBridgableType() const {
 bool Type::hasSizedVLAType() const {
   if (!isVariablyModifiedType()) return false;
 
-  if (const PointerType *ptr = getAs<PointerType>())
+  if (const auto *ptr = getAs<PointerType>())
     return ptr->getPointeeType()->hasSizedVLAType();
-  if (const ReferenceType *ref = getAs<ReferenceType>())
+  if (const auto *ref = getAs<ReferenceType>())
     return ref->getPointeeType()->hasSizedVLAType();
   if (const ArrayType *arr = getAsArrayTypeUnsafe()) {
     if (isa<VariableArrayType>(arr) && 




More information about the cfe-commits mailing list