r325256 - NFC; clean up this file based on our coding standards. The impetus was considerable use of a type name as an identifier for an object.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 15 08:20:21 PST 2018


Author: aaronballman
Date: Thu Feb 15 08:20:20 2018
New Revision: 325256

URL: http://llvm.org/viewvc/llvm-project?rev=325256&view=rev
Log:
NFC; clean up this file based on our coding standards. The impetus was considerable use of a type name as an identifier for an object.

Changed identifier names (especially function parameters) to not clash with type names and to follow the proper naming conventions. Use of explicit type names changed to use auto where appropriate. Removed unused parameters that should have never been added in the first place. Minor formatting cleanups.

The changes were mostly mechanical and should have no functional impact.

Modified:
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=325256&r1=325255&r2=325256&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Feb 15 08:20:20 2018
@@ -87,7 +87,7 @@ static bool hasFunctionProto(const Decl
 static unsigned getFunctionOrMethodNumParams(const Decl *D) {
   if (const FunctionType *FnTy = D->getFunctionType())
     return cast<FunctionProtoType>(FnTy)->getNumParams();
-  if (const BlockDecl *BD = dyn_cast<BlockDecl>(D))
+  if (const auto *BD = dyn_cast<BlockDecl>(D))
     return BD->getNumParams();
   return cast<ObjCMethodDecl>(D)->param_size();
 }
@@ -95,7 +95,7 @@ static unsigned getFunctionOrMethodNumPa
 static QualType getFunctionOrMethodParamType(const Decl *D, unsigned Idx) {
   if (const FunctionType *FnTy = D->getFunctionType())
     return cast<FunctionProtoType>(FnTy)->getParamType(Idx);
-  if (const BlockDecl *BD = dyn_cast<BlockDecl>(D))
+  if (const auto *BD = dyn_cast<BlockDecl>(D))
     return BD->getParamDecl(Idx)->getType();
 
   return cast<ObjCMethodDecl>(D)->parameters()[Idx]->getType();
@@ -126,24 +126,21 @@ static SourceRange getFunctionOrMethodRe
 }
 
 static bool isFunctionOrMethodVariadic(const Decl *D) {
-  if (const FunctionType *FnTy = D->getFunctionType()) {
-    const FunctionProtoType *proto = cast<FunctionProtoType>(FnTy);
-    return proto->isVariadic();
-  }
-  if (const BlockDecl *BD = dyn_cast<BlockDecl>(D))
+  if (const FunctionType *FnTy = D->getFunctionType())
+    return cast<FunctionProtoType>(FnTy)->isVariadic();
+  if (const auto *BD = dyn_cast<BlockDecl>(D))
     return BD->isVariadic();
-
   return cast<ObjCMethodDecl>(D)->isVariadic();
 }
 
 static bool isInstanceMethod(const Decl *D) {
-  if (const CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(D))
+  if (const auto *MethodDecl = dyn_cast<CXXMethodDecl>(D))
     return MethodDecl->isInstance();
   return false;
 }
 
 static inline bool isNSStringType(QualType T, ASTContext &Ctx) {
-  const ObjCObjectPointerType *PT = T->getAs<ObjCObjectPointerType>();
+  const auto *PT = T->getAs<ObjCObjectPointerType>();
   if (!PT)
     return false;
 
@@ -159,11 +156,11 @@ static inline bool isNSStringType(QualTy
 }
 
 static inline bool isCFStringType(QualType T, ASTContext &Ctx) {
-  const PointerType *PT = T->getAs<PointerType>();
+  const auto *PT = T->getAs<PointerType>();
   if (!PT)
     return false;
 
-  const RecordType *RT = PT->getPointeeType()->getAs<RecordType>();
+  const auto *RT = PT->getPointeeType()->getAs<RecordType>();
   if (!RT)
     return false;
 
@@ -174,17 +171,17 @@ static inline bool isCFStringType(QualTy
   return RD->getIdentifier() == &Ctx.Idents.get("__CFString");
 }
 
-static unsigned getNumAttributeArgs(const AttributeList &Attr) {
+static unsigned getNumAttributeArgs(const AttributeList &AL) {
   // FIXME: Include the type in the argument list.
-  return Attr.getNumArgs() + Attr.hasParsedType();
+  return AL.getNumArgs() + AL.hasParsedType();
 }
 
 template <typename Compare>
-static bool checkAttributeNumArgsImpl(Sema &S, const AttributeList &Attr,
+static bool checkAttributeNumArgsImpl(Sema &S, const AttributeList &AL,
                                       unsigned Num, unsigned Diag,
                                       Compare Comp) {
-  if (Comp(getNumAttributeArgs(Attr), Num)) {
-    S.Diag(Attr.getLoc(), Diag) << Attr.getName() << Num;
+  if (Comp(getNumAttributeArgs(AL), Num)) {
+    S.Diag(AL.getLoc(), Diag) << AL.getName() << Num;
     return false;
   }
 
@@ -193,27 +190,27 @@ static bool checkAttributeNumArgsImpl(Se
 
 /// \brief Check if the attribute has exactly as many args as Num. May
 /// output an error.
-static bool checkAttributeNumArgs(Sema &S, const AttributeList &Attr,
+static bool checkAttributeNumArgs(Sema &S, const AttributeList &AL,
                                   unsigned Num) {
-  return checkAttributeNumArgsImpl(S, Attr, Num,
+  return checkAttributeNumArgsImpl(S, AL, Num,
                                    diag::err_attribute_wrong_number_arguments,
                                    std::not_equal_to<unsigned>());
 }
 
 /// \brief Check if the attribute has at least as many args as Num. May
 /// output an error.
-static bool checkAttributeAtLeastNumArgs(Sema &S, const AttributeList &Attr,
+static bool checkAttributeAtLeastNumArgs(Sema &S, const AttributeList &AL,
                                          unsigned Num) {
-  return checkAttributeNumArgsImpl(S, Attr, Num,
+  return checkAttributeNumArgsImpl(S, AL, Num,
                                    diag::err_attribute_too_few_arguments,
                                    std::less<unsigned>());
 }
 
 /// \brief Check if the attribute has at most as many args as Num. May
 /// output an error.
-static bool checkAttributeAtMostNumArgs(Sema &S, const AttributeList &Attr,
+static bool checkAttributeAtMostNumArgs(Sema &S, const AttributeList &AL,
                                          unsigned Num) {
-  return checkAttributeNumArgsImpl(S, Attr, Num,
+  return checkAttributeNumArgsImpl(S, AL, Num,
                                    diag::err_attribute_too_many_arguments,
                                    std::greater<unsigned>());
 }
@@ -221,42 +218,42 @@ static bool checkAttributeAtMostNumArgs(
 /// \brief A helper function to provide Attribute Location for the Attr types
 /// AND the AttributeList.
 template <typename AttrInfo>
-static typename std::enable_if<std::is_base_of<clang::Attr, AttrInfo>::value,
+static typename std::enable_if<std::is_base_of<Attr, AttrInfo>::value,
                                SourceLocation>::type
-getAttrLoc(const AttrInfo &Attr) {
-  return Attr.getLocation();
+getAttrLoc(const AttrInfo &AL) {
+  return AL.getLocation();
 }
-static SourceLocation getAttrLoc(const clang::AttributeList &Attr) {
-  return Attr.getLoc();
+static SourceLocation getAttrLoc(const AttributeList &AL) {
+  return AL.getLoc();
 }
 
 /// \brief A helper function to provide Attribute Name for the Attr types
 /// AND the AttributeList.
 template <typename AttrInfo>
-static typename std::enable_if<std::is_base_of<clang::Attr, AttrInfo>::value,
+static typename std::enable_if<std::is_base_of<Attr, AttrInfo>::value,
                                const AttrInfo *>::type
-getAttrName(const AttrInfo &Attr) {
-  return &Attr;
+getAttrName(const AttrInfo &AL) {
+  return &AL;
 }
-static const IdentifierInfo *getAttrName(const clang::AttributeList &Attr) {
-  return Attr.getName();
+static const IdentifierInfo *getAttrName(const AttributeList &AL) {
+  return AL.getName();
 }
 
 /// \brief If Expr is a valid integer constant, get the value of the integer
 /// expression and return success or failure. May output an error.
-template<typename AttrInfo>
-static bool checkUInt32Argument(Sema &S, const AttrInfo& Attr, const Expr *Expr,
+template <typename AttrInfo>
+static bool checkUInt32Argument(Sema &S, const AttrInfo &AI, const Expr *Expr,
                                 uint32_t &Val, unsigned Idx = UINT_MAX) {
   llvm::APSInt I(32);
   if (Expr->isTypeDependent() || Expr->isValueDependent() ||
       !Expr->isIntegerConstantExpr(I, S.Context)) {
     if (Idx != UINT_MAX)
-      S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
-        << getAttrName(Attr) << Idx << AANT_ArgumentIntegerConstant
+      S.Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
+        << getAttrName(AI) << Idx << AANT_ArgumentIntegerConstant
         << Expr->getSourceRange();
     else
-      S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_type)
-        << getAttrName(Attr) << AANT_ArgumentIntegerConstant
+      S.Diag(getAttrLoc(AI), diag::err_attribute_argument_type)
+        << getAttrName(AI) << AANT_ArgumentIntegerConstant
         << Expr->getSourceRange();
     return false;
   }
@@ -274,11 +271,11 @@ static bool checkUInt32Argument(Sema &S,
 /// \brief Wrapper around checkUInt32Argument, with an extra check to be sure
 /// that the result will fit into a regular (signed) int. All args have the same
 /// purpose as they do in checkUInt32Argument.
-template<typename AttrInfo>
-static bool checkPositiveIntArgument(Sema &S, const AttrInfo& Attr, const Expr *Expr,
+template <typename AttrInfo>
+static bool checkPositiveIntArgument(Sema &S, const AttrInfo &AI, const Expr *Expr,
                                      int &Val, unsigned Idx = UINT_MAX) {
   uint32_t UVal;
-  if (!checkUInt32Argument(S, Attr, Expr, UVal, Idx))
+  if (!checkUInt32Argument(S, AI, Expr, UVal, Idx))
     return false;
 
   if (UVal > (uint32_t)std::numeric_limits<int>::max()) {
@@ -298,7 +295,7 @@ static bool checkPositiveIntArgument(Sem
 template <typename AttrTy>
 static bool checkAttrMutualExclusion(Sema &S, Decl *D, SourceRange Range,
                                      IdentifierInfo *Ident) {
-  if (AttrTy *A = D->getAttr<AttrTy>()) {
+  if (const auto *A = D->getAttr<AttrTy>()) {
     S.Diag(Range.getBegin(), diag::err_attributes_are_not_compatible) << Ident
                                                                       << A;
     S.Diag(A->getLocation(), diag::note_conflicting_attribute);
@@ -313,7 +310,7 @@ static bool checkAttrMutualExclusion(Sem
 /// \returns true if IdxExpr is a valid index.
 template <typename AttrInfo>
 static bool checkFunctionOrMethodParameterIndex(
-    Sema &S, const Decl *D, const AttrInfo &Attr, unsigned AttrArgNum,
+    Sema &S, const Decl *D, const AttrInfo &AI, unsigned AttrArgNum,
     const Expr *IdxExpr, uint64_t &Idx, bool AllowImplicitThis = false) {
   assert(isFunctionOrMethodOrBlock(D));
 
@@ -328,24 +325,24 @@ static bool checkFunctionOrMethodParamet
   llvm::APSInt IdxInt;
   if (IdxExpr->isTypeDependent() || IdxExpr->isValueDependent() ||
       !IdxExpr->isIntegerConstantExpr(IdxInt, S.Context)) {
-    S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_n_type)
-      << getAttrName(Attr) << AttrArgNum << AANT_ArgumentIntegerConstant
+    S.Diag(getAttrLoc(AI), diag::err_attribute_argument_n_type)
+      << getAttrName(AI) << AttrArgNum << AANT_ArgumentIntegerConstant
       << IdxExpr->getSourceRange();
     return false;
   }
 
   Idx = IdxInt.getLimitedValue();
   if (Idx < 1 || (!IV && Idx > NumParams)) {
-    S.Diag(getAttrLoc(Attr), diag::err_attribute_argument_out_of_bounds)
-      << getAttrName(Attr) << AttrArgNum << IdxExpr->getSourceRange();
+    S.Diag(getAttrLoc(AI), diag::err_attribute_argument_out_of_bounds)
+      << getAttrName(AI) << AttrArgNum << IdxExpr->getSourceRange();
     return false;
   }
   Idx--; // Convert to zero-based.
   if (HasImplicitThisParam && !AllowImplicitThis) {
     if (Idx == 0) {
-      S.Diag(getAttrLoc(Attr),
+      S.Diag(getAttrLoc(AI),
              diag::err_attribute_invalid_implicit_this_argument)
-        << getAttrName(Attr) << IdxExpr->getSourceRange();
+        << getAttrName(AI) << IdxExpr->getSourceRange();
       return false;
     }
     --Idx;
@@ -358,14 +355,14 @@ static bool checkFunctionOrMethodParamet
 /// If not emit an error and return false. If the argument is an identifier it
 /// will emit an error with a fixit hint and treat it as if it was a string
 /// literal.
-bool Sema::checkStringLiteralArgumentAttr(const AttributeList &Attr,
+bool Sema::checkStringLiteralArgumentAttr(const AttributeList &AL,
                                           unsigned ArgNum, StringRef &Str,
                                           SourceLocation *ArgLocation) {
   // Look for identifiers. If we have one emit a hint to fix it to a literal.
-  if (Attr.isArgIdent(ArgNum)) {
-    IdentifierLoc *Loc = Attr.getArgAsIdent(ArgNum);
+  if (AL.isArgIdent(ArgNum)) {
+    IdentifierLoc *Loc = AL.getArgAsIdent(ArgNum);
     Diag(Loc->Loc, diag::err_attribute_argument_type)
-        << Attr.getName() << AANT_ArgumentString
+        << AL.getName() << AANT_ArgumentString
         << FixItHint::CreateInsertion(Loc->Loc, "\"")
         << FixItHint::CreateInsertion(getLocForEndOfToken(Loc->Loc), "\"");
     Str = Loc->Ident->getName();
@@ -375,14 +372,14 @@ bool Sema::checkStringLiteralArgumentAtt
   }
 
   // Now check for an actual string literal.
-  Expr *ArgExpr = Attr.getArgAsExpr(ArgNum);
-  StringLiteral *Literal = dyn_cast<StringLiteral>(ArgExpr->IgnoreParenCasts());
+  Expr *ArgExpr = AL.getArgAsExpr(ArgNum);
+  const auto *Literal = dyn_cast<StringLiteral>(ArgExpr->IgnoreParenCasts());
   if (ArgLocation)
     *ArgLocation = ArgExpr->getLocStart();
 
   if (!Literal || !Literal->isAscii()) {
     Diag(ArgExpr->getLocStart(), diag::err_attribute_argument_type)
-        << Attr.getName() << AANT_ArgumentString;
+        << AL.getName() << AANT_ArgumentString;
     return false;
   }
 
@@ -393,16 +390,15 @@ bool Sema::checkStringLiteralArgumentAtt
 /// \brief Applies the given attribute to the Decl without performing any
 /// additional semantic checking.
 template <typename AttrType>
-static void handleSimpleAttribute(Sema &S, Decl *D,
-                                  const AttributeList &Attr) {
-  D->addAttr(::new (S.Context) AttrType(Attr.getRange(), S.Context,
-                                        Attr.getAttributeSpellingListIndex()));
+static void handleSimpleAttribute(Sema &S, Decl *D, const AttributeList &AL) {
+  D->addAttr(::new (S.Context) AttrType(AL.getRange(), S.Context,
+                                        AL.getAttributeSpellingListIndex()));
 }
 
 template <typename AttrType>
 static void handleSimpleAttributeWithExclusions(Sema &S, Decl *D,
-                                                const AttributeList &Attr) {
-  handleSimpleAttribute<AttrType>(S, D, Attr);
+                                                const AttributeList &AL) {
+  handleSimpleAttribute<AttrType>(S, D, AL);
 }
 
 /// \brief Applies the given attribute to the Decl so long as the Decl doesn't
@@ -410,12 +406,12 @@ static void handleSimpleAttributeWithExc
 template <typename AttrType, typename IncompatibleAttrType,
           typename... IncompatibleAttrTypes>
 static void handleSimpleAttributeWithExclusions(Sema &S, Decl *D,
-                                                const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<IncompatibleAttrType>(S, D, Attr.getRange(),
-                                                     Attr.getName()))
+                                                const AttributeList &AL) {
+  if (checkAttrMutualExclusion<IncompatibleAttrType>(S, D, AL.getRange(),
+                                                     AL.getName()))
     return;
   handleSimpleAttributeWithExclusions<AttrType, IncompatibleAttrTypes...>(S, D,
-                                                                          Attr);
+                                                                          AL);
 }
 
 /// \brief Check if the passed-in expression is of type int or bool.
@@ -445,13 +441,13 @@ static bool threadSafetyCheckIsSmartPoin
 /// Note that this function may produce an error message.
 /// \return true if the Decl is a pointer type; false otherwise
 static bool threadSafetyCheckIsPointer(Sema &S, const Decl *D,
-                                       const AttributeList &Attr) {
-  const ValueDecl *vd = cast<ValueDecl>(D);
-  QualType QT = vd->getType();
+                                       const AttributeList &AL) {
+  const auto *VD = cast<ValueDecl>(D);
+  QualType QT = VD->getType();
   if (QT->isAnyPointerType())
     return true;
 
-  if (const RecordType *RT = QT->getAs<RecordType>()) {
+  if (const auto *RT = QT->getAs<RecordType>()) {
     // If it's an incomplete type, it could be a smart pointer; skip it.
     // (We don't want to force template instantiation if we can avoid it,
     // since that would alter the order in which templates are instantiated.)
@@ -462,19 +458,19 @@ static bool threadSafetyCheckIsPointer(S
       return true;
   }
 
-  S.Diag(Attr.getLoc(), diag::warn_thread_attribute_decl_not_pointer)
-    << Attr.getName() << QT;
+  S.Diag(AL.getLoc(), diag::warn_thread_attribute_decl_not_pointer)
+      << AL.getName() << QT;
   return false;
 }
 
 /// \brief Checks that the passed in QualType either is of RecordType or points
 /// to RecordType. Returns the relevant RecordType, null if it does not exit.
 static const RecordType *getRecordType(QualType QT) {
-  if (const RecordType *RT = QT->getAs<RecordType>())
+  if (const auto *RT = QT->getAs<RecordType>())
     return RT;
 
   // Now check if we point to record type.
-  if (const PointerType *PT = QT->getAs<PointerType>())
+  if (const auto *PT = QT->getAs<PointerType>())
     return PT->getPointeeType()->getAs<RecordType>();
 
   return nullptr;
@@ -501,7 +497,7 @@ static bool checkRecordTypeForCapability
     return true;
 
   // Else check if any base classes have a capability.
-  if (CXXRecordDecl *CRD = dyn_cast<CXXRecordDecl>(RD)) {
+  if (const auto *CRD = dyn_cast<CXXRecordDecl>(RD)) {
     CXXBasePaths BPaths(false, false);
     if (CRD->lookupInBases([](const CXXBaseSpecifier *BS, CXXBasePath &) {
           const auto *Type = BS->getType()->getAs<RecordType>();
@@ -565,12 +561,12 @@ static bool isCapabilityExpr(Sema &S, co
 /// \param ParamIdxOk Whether an argument can be indexing into a function
 /// parameter list.
 static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D,
-                                           const AttributeList &Attr,
+                                           const AttributeList &AL,
                                            SmallVectorImpl<Expr *> &Args,
                                            int Sidx = 0,
                                            bool ParamIdxOk = false) {
-  for (unsigned Idx = Sidx; Idx < Attr.getNumArgs(); ++Idx) {
-    Expr *ArgExp = Attr.getArgAsExpr(Idx);
+  for (unsigned Idx = Sidx; Idx < AL.getNumArgs(); ++Idx) {
+    Expr *ArgExp = AL.getArgAsExpr(Idx);
 
     if (ArgExp->isTypeDependent()) {
       // FIXME -- need to check this again on template instantiation
@@ -578,7 +574,7 @@ static void checkAttrArgsAreCapabilityOb
       continue;
     }
 
-    if (StringLiteral *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
+    if (const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
       if (StrLit->getLength() == 0 ||
           (StrLit->isAscii() && StrLit->getString() == StringRef("*"))) {
         // Pass empty strings to the analyzer without warnings.
@@ -589,8 +585,7 @@ static void checkAttrArgsAreCapabilityOb
 
       // We allow constant strings to be used as a placeholder for expressions
       // that are not valid C++ syntax, but warn that they are ignored.
-      S.Diag(Attr.getLoc(), diag::warn_thread_attribute_ignored) <<
-        Attr.getName();
+      S.Diag(AL.getLoc(), diag::warn_thread_attribute_ignored) << AL.getName();
       Args.push_back(ArgExp);
       continue;
     }
@@ -599,9 +594,9 @@ static void checkAttrArgsAreCapabilityOb
 
     // A pointer to member expression of the form  &MyClass::mu is treated
     // specially -- we need to look at the type of the member.
-    if (UnaryOperator *UOp = dyn_cast<UnaryOperator>(ArgExp))
+    if (const auto *UOp = dyn_cast<UnaryOperator>(ArgExp))
       if (UOp->getOpcode() == UO_AddrOf)
-        if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
+        if (const auto *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr()))
           if (DRE->getDecl()->isCXXInstanceMember())
             ArgTy = DRE->getDecl()->getType();
 
@@ -610,16 +605,16 @@ static void checkAttrArgsAreCapabilityOb
 
     // Now check if we index into a record type function param.
     if(!RT && ParamIdxOk) {
-      FunctionDecl *FD = dyn_cast<FunctionDecl>(D);
-      IntegerLiteral *IL = dyn_cast<IntegerLiteral>(ArgExp);
+      const auto *FD = dyn_cast<FunctionDecl>(D);
+      const auto *IL = dyn_cast<IntegerLiteral>(ArgExp);
       if(FD && IL) {
         unsigned int NumParams = FD->getNumParams();
         llvm::APInt ArgValue = IL->getValue();
         uint64_t ParamIdxFromOne = ArgValue.getZExtValue();
         uint64_t ParamIdxFromZero = ParamIdxFromOne - 1;
-        if(!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
-          S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_range)
-            << Attr.getName() << Idx + 1 << NumParams;
+        if (!ArgValue.isStrictlyPositive() || ParamIdxFromOne > NumParams) {
+          S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_range)
+              << AL.getName() << Idx + 1 << NumParams;
           continue;
         }
         ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType();
@@ -631,8 +626,8 @@ static void checkAttrArgsAreCapabilityOb
     // capability may be on the type, and the expression is a capability
     // boolean logic expression. Eg) requires_capability(A || B && !C)
     if (!typeHasCapability(S, ArgTy) && !isCapabilityExpr(S, ArgExp))
-      S.Diag(Attr.getLoc(), diag::warn_thread_attribute_argument_not_lockable)
-          << Attr.getName() << ArgTy;
+      S.Diag(AL.getLoc(), diag::warn_thread_attribute_argument_not_lockable)
+          << AL.getName() << ArgTy;
 
     Args.push_back(ArgExp);
   }
@@ -643,21 +638,20 @@ static void checkAttrArgsAreCapabilityOb
 //===----------------------------------------------------------------------===//
 
 static void handlePtGuardedVarAttr(Sema &S, Decl *D,
-                                   const AttributeList &Attr) {
-  if (!threadSafetyCheckIsPointer(S, D, Attr))
+                                   const AttributeList &AL) {
+  if (!threadSafetyCheckIsPointer(S, D, AL))
     return;
 
   D->addAttr(::new (S.Context)
-             PtGuardedVarAttr(Attr.getRange(), S.Context,
-                              Attr.getAttributeSpellingListIndex()));
+             PtGuardedVarAttr(AL.getRange(), S.Context,
+                              AL.getAttributeSpellingListIndex()));
 }
 
-static bool checkGuardedByAttrCommon(Sema &S, Decl *D,
-                                     const AttributeList &Attr,
-                                     Expr* &Arg) {
-  SmallVector<Expr*, 1> Args;
+static bool checkGuardedByAttrCommon(Sema &S, Decl *D, const AttributeList &AL,
+                                     Expr *&Arg) {
+  SmallVector<Expr *, 1> Args;
   // check that all arguments are lockable objects
-  checkAttrArgsAreCapabilityObjs(S, D, Attr, Args);
+  checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
   unsigned Size = Args.size();
   if (Size != 1)
     return false;
@@ -667,45 +661,44 @@ static bool checkGuardedByAttrCommon(Sem
   return true;
 }
 
-static void handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &AL) {
   Expr *Arg = nullptr;
-  if (!checkGuardedByAttrCommon(S, D, Attr, Arg))
+  if (!checkGuardedByAttrCommon(S, D, AL, Arg))
     return;
 
-  D->addAttr(::new (S.Context) GuardedByAttr(Attr.getRange(), S.Context, Arg,
-                                        Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) GuardedByAttr(
+      AL.getRange(), S.Context, Arg, AL.getAttributeSpellingListIndex()));
 }
 
 static void handlePtGuardedByAttr(Sema &S, Decl *D,
-                                  const AttributeList &Attr) {
+                                  const AttributeList &AL) {
   Expr *Arg = nullptr;
-  if (!checkGuardedByAttrCommon(S, D, Attr, Arg))
+  if (!checkGuardedByAttrCommon(S, D, AL, Arg))
     return;
 
-  if (!threadSafetyCheckIsPointer(S, D, Attr))
+  if (!threadSafetyCheckIsPointer(S, D, AL))
     return;
 
-  D->addAttr(::new (S.Context) PtGuardedByAttr(Attr.getRange(),
-                                               S.Context, Arg,
-                                        Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) PtGuardedByAttr(
+      AL.getRange(), S.Context, Arg, AL.getAttributeSpellingListIndex()));
 }
 
 static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D,
-                                        const AttributeList &Attr,
+                                        const AttributeList &AL,
                                         SmallVectorImpl<Expr *> &Args) {
-  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+  if (!checkAttributeAtLeastNumArgs(S, AL, 1))
     return false;
 
   // Check that this attribute only applies to lockable types.
   QualType QT = cast<ValueDecl>(D)->getType();
   if (!QT->isDependentType() && !typeHasCapability(S, QT)) {
-    S.Diag(Attr.getLoc(), diag::warn_thread_attribute_decl_not_lockable)
-      << Attr.getName();
+    S.Diag(AL.getLoc(), diag::warn_thread_attribute_decl_not_lockable)
+        << AL.getName();
     return false;
   }
 
   // Check that all arguments are lockable objects.
-  checkAttrArgsAreCapabilityObjs(S, D, Attr, Args);
+  checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
   if (Args.empty())
     return false;
 
@@ -713,66 +706,63 @@ static bool checkAcquireOrderAttrCommon(
 }
 
 static void handleAcquiredAfterAttr(Sema &S, Decl *D,
-                                    const AttributeList &Attr) {
-  SmallVector<Expr*, 1> Args;
-  if (!checkAcquireOrderAttrCommon(S, D, Attr, Args))
+                                    const AttributeList &AL) {
+  SmallVector<Expr *, 1> Args;
+  if (!checkAcquireOrderAttrCommon(S, D, AL, Args))
     return;
 
   Expr **StartArg = &Args[0];
-  D->addAttr(::new (S.Context)
-             AcquiredAfterAttr(Attr.getRange(), S.Context,
-                               StartArg, Args.size(),
-                               Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) AcquiredAfterAttr(
+      AL.getRange(), S.Context, StartArg, Args.size(),
+      AL.getAttributeSpellingListIndex()));
 }
 
 static void handleAcquiredBeforeAttr(Sema &S, Decl *D,
-                                     const AttributeList &Attr) {
-  SmallVector<Expr*, 1> Args;
-  if (!checkAcquireOrderAttrCommon(S, D, Attr, Args))
+                                     const AttributeList &AL) {
+  SmallVector<Expr *, 1> Args;
+  if (!checkAcquireOrderAttrCommon(S, D, AL, Args))
     return;
 
   Expr **StartArg = &Args[0];
-  D->addAttr(::new (S.Context)
-             AcquiredBeforeAttr(Attr.getRange(), S.Context,
-                                StartArg, Args.size(),
-                                Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) AcquiredBeforeAttr(
+      AL.getRange(), S.Context, StartArg, Args.size(),
+      AL.getAttributeSpellingListIndex()));
 }
 
 static bool checkLockFunAttrCommon(Sema &S, Decl *D,
-                                   const AttributeList &Attr,
+                                   const AttributeList &AL,
                                    SmallVectorImpl<Expr *> &Args) {
   // zero or more arguments ok
   // check that all arguments are lockable objects
-  checkAttrArgsAreCapabilityObjs(S, D, Attr, Args, 0, /*ParamIdxOk=*/true);
+  checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0, /*ParamIdxOk=*/true);
 
   return true;
 }
 
 static void handleAssertSharedLockAttr(Sema &S, Decl *D,
-                                       const AttributeList &Attr) {
-  SmallVector<Expr*, 1> Args;
-  if (!checkLockFunAttrCommon(S, D, Attr, Args))
+                                       const AttributeList &AL) {
+  SmallVector<Expr *, 1> Args;
+  if (!checkLockFunAttrCommon(S, D, AL, Args))
     return;
 
   unsigned Size = Args.size();
   Expr **StartArg = Size == 0 ? nullptr : &Args[0];
   D->addAttr(::new (S.Context)
-             AssertSharedLockAttr(Attr.getRange(), S.Context, StartArg, Size,
-                                  Attr.getAttributeSpellingListIndex()));
+                 AssertSharedLockAttr(AL.getRange(), S.Context, StartArg, Size,
+                                      AL.getAttributeSpellingListIndex()));
 }
 
 static void handleAssertExclusiveLockAttr(Sema &S, Decl *D,
-                                          const AttributeList &Attr) {
-  SmallVector<Expr*, 1> Args;
-  if (!checkLockFunAttrCommon(S, D, Attr, Args))
+                                          const AttributeList &AL) {
+  SmallVector<Expr *, 1> Args;
+  if (!checkLockFunAttrCommon(S, D, AL, Args))
     return;
 
   unsigned Size = Args.size();
   Expr **StartArg = Size == 0 ? nullptr : &Args[0];
-  D->addAttr(::new (S.Context)
-             AssertExclusiveLockAttr(Attr.getRange(), S.Context,
-                                     StartArg, Size,
-                                     Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) AssertExclusiveLockAttr(
+      AL.getRange(), S.Context, StartArg, Size,
+      AL.getAttributeSpellingListIndex()));
 }
 
 /// \brief Checks to be sure that the given parameter number is in bounds, and is
@@ -783,11 +773,11 @@ static void handleAssertExclusiveLockAtt
 /// to actually retrieve the argument, so it's base-0.
 template <typename AttrInfo>
 static bool checkParamIsIntegerType(Sema &S, const FunctionDecl *FD,
-                                    const AttrInfo &Attr, Expr *AttrArg,
+                                    const AttrInfo &AI, Expr *AttrArg,
                                     unsigned FuncParamNo, unsigned AttrArgNo,
                                     bool AllowDependentType = false) {
   uint64_t Idx;
-  if (!checkFunctionOrMethodParameterIndex(S, FD, Attr, FuncParamNo, AttrArg,
+  if (!checkFunctionOrMethodParameterIndex(S, FD, AI, FuncParamNo, AttrArg,
                                            Idx))
     return false;
 
@@ -797,7 +787,7 @@ static bool checkParamIsIntegerType(Sema
   if (!Param->getType()->isIntegerType() && !Param->getType()->isCharType()) {
     SourceLocation SrcLoc = AttrArg->getLocStart();
     S.Diag(SrcLoc, diag::err_attribute_integers_only)
-        << getAttrName(Attr) << Param->getSourceRange();
+        << getAttrName(AI) << Param->getSourceRange();
     return false;
   }
   return true;
@@ -809,131 +799,129 @@ static bool checkParamIsIntegerType(Sema
 /// FuncParamNo is expected to be from the user, so is base-1. AttrArgNo is used
 /// to actually retrieve the argument, so it's base-0.
 static bool checkParamIsIntegerType(Sema &S, const FunctionDecl *FD,
-                                    const AttributeList &Attr,
+                                    const AttributeList &AL,
                                     unsigned FuncParamNo, unsigned AttrArgNo,
                                     bool AllowDependentType = false) {
-  assert(Attr.isArgExpr(AttrArgNo) && "Expected expression argument");
-  return checkParamIsIntegerType(S, FD, Attr, Attr.getArgAsExpr(AttrArgNo),
+  assert(AL.isArgExpr(AttrArgNo) && "Expected expression argument");
+  return checkParamIsIntegerType(S, FD, AL, AL.getArgAsExpr(AttrArgNo),
                                  FuncParamNo, AttrArgNo, AllowDependentType);
 }
 
-static void handleAllocSizeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (!checkAttributeAtLeastNumArgs(S, Attr, 1) ||
-      !checkAttributeAtMostNumArgs(S, Attr, 2))
+static void handleAllocSizeAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (!checkAttributeAtLeastNumArgs(S, AL, 1) ||
+      !checkAttributeAtMostNumArgs(S, AL, 2))
     return;
 
   const auto *FD = cast<FunctionDecl>(D);
   if (!FD->getReturnType()->isPointerType()) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_return_pointers_only)
-        << Attr.getName();
+    S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only)
+        << AL.getName();
     return;
   }
 
-  const Expr *SizeExpr = Attr.getArgAsExpr(0);
+  const Expr *SizeExpr = AL.getArgAsExpr(0);
   int SizeArgNo;
   // Parameter indices are 1-indexed, hence Index=1
-  if (!checkPositiveIntArgument(S, Attr, SizeExpr, SizeArgNo, /*Index=*/1))
+  if (!checkPositiveIntArgument(S, AL, SizeExpr, SizeArgNo, /*Index=*/1))
     return;
 
-  if (!checkParamIsIntegerType(S, FD, Attr, SizeArgNo, /*AttrArgNo=*/0))
+  if (!checkParamIsIntegerType(S, FD, AL, SizeArgNo, /*AttrArgNo=*/0))
     return;
 
   // Args are 1-indexed, so 0 implies that the arg was not present
   int NumberArgNo = 0;
-  if (Attr.getNumArgs() == 2) {
-    const Expr *NumberExpr = Attr.getArgAsExpr(1);
+  if (AL.getNumArgs() == 2) {
+    const Expr *NumberExpr = AL.getArgAsExpr(1);
     // Parameter indices are 1-based, hence Index=2
-    if (!checkPositiveIntArgument(S, Attr, NumberExpr, NumberArgNo,
+    if (!checkPositiveIntArgument(S, AL, NumberExpr, NumberArgNo,
                                   /*Index=*/2))
       return;
 
-    if (!checkParamIsIntegerType(S, FD, Attr, NumberArgNo, /*AttrArgNo=*/1))
+    if (!checkParamIsIntegerType(S, FD, AL, NumberArgNo, /*AttrArgNo=*/1))
       return;
   }
 
-  D->addAttr(::new (S.Context) AllocSizeAttr(
-      Attr.getRange(), S.Context, SizeArgNo, NumberArgNo,
-      Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context)
+                 AllocSizeAttr(AL.getRange(), S.Context, SizeArgNo, NumberArgNo,
+                               AL.getAttributeSpellingListIndex()));
 }
 
 static bool checkTryLockFunAttrCommon(Sema &S, Decl *D,
-                                      const AttributeList &Attr,
+                                      const AttributeList &AL,
                                       SmallVectorImpl<Expr *> &Args) {
-  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+  if (!checkAttributeAtLeastNumArgs(S, AL, 1))
     return false;
 
-  if (!isIntOrBool(Attr.getArgAsExpr(0))) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-      << Attr.getName() << 1 << AANT_ArgumentIntOrBool;
+  if (!isIntOrBool(AL.getArgAsExpr(0))) {
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
+      << AL.getName() << 1 << AANT_ArgumentIntOrBool;
     return false;
   }
 
   // check that all arguments are lockable objects
-  checkAttrArgsAreCapabilityObjs(S, D, Attr, Args, 1);
+  checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 1);
 
   return true;
 }
 
 static void handleSharedTrylockFunctionAttr(Sema &S, Decl *D,
-                                            const AttributeList &Attr) {
+                                            const AttributeList &AL) {
   SmallVector<Expr*, 2> Args;
-  if (!checkTryLockFunAttrCommon(S, D, Attr, Args))
+  if (!checkTryLockFunAttrCommon(S, D, AL, Args))
     return;
 
-  D->addAttr(::new (S.Context)
-             SharedTrylockFunctionAttr(Attr.getRange(), S.Context,
-                                       Attr.getArgAsExpr(0),
-                                       Args.data(), Args.size(),
-                                       Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) SharedTrylockFunctionAttr(
+      AL.getRange(), S.Context, AL.getArgAsExpr(0), Args.data(), Args.size(),
+      AL.getAttributeSpellingListIndex()));
 }
 
 static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D,
-                                               const AttributeList &Attr) {
+                                               const AttributeList &AL) {
   SmallVector<Expr*, 2> Args;
-  if (!checkTryLockFunAttrCommon(S, D, Attr, Args))
+  if (!checkTryLockFunAttrCommon(S, D, AL, Args))
     return;
 
   D->addAttr(::new (S.Context) ExclusiveTrylockFunctionAttr(
-      Attr.getRange(), S.Context, Attr.getArgAsExpr(0), Args.data(),
-      Args.size(), Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, AL.getArgAsExpr(0), Args.data(),
+      Args.size(), AL.getAttributeSpellingListIndex()));
 }
 
 static void handleLockReturnedAttr(Sema &S, Decl *D,
-                                   const AttributeList &Attr) {
+                                   const AttributeList &AL) {
   // check that the argument is lockable object
   SmallVector<Expr*, 1> Args;
-  checkAttrArgsAreCapabilityObjs(S, D, Attr, Args);
+  checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
   unsigned Size = Args.size();
   if (Size == 0)
     return;
 
   D->addAttr(::new (S.Context)
-             LockReturnedAttr(Attr.getRange(), S.Context, Args[0],
-                              Attr.getAttributeSpellingListIndex()));
+             LockReturnedAttr(AL.getRange(), S.Context, Args[0],
+                              AL.getAttributeSpellingListIndex()));
 }
 
 static void handleLocksExcludedAttr(Sema &S, Decl *D,
-                                    const AttributeList &Attr) {
-  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+                                    const AttributeList &AL) {
+  if (!checkAttributeAtLeastNumArgs(S, AL, 1))
     return;
 
   // check that all arguments are lockable objects
   SmallVector<Expr*, 1> Args;
-  checkAttrArgsAreCapabilityObjs(S, D, Attr, Args);
+  checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
   unsigned Size = Args.size();
   if (Size == 0)
     return;
   Expr **StartArg = &Args[0];
 
   D->addAttr(::new (S.Context)
-             LocksExcludedAttr(Attr.getRange(), S.Context, StartArg, Size,
-                               Attr.getAttributeSpellingListIndex()));
+             LocksExcludedAttr(AL.getRange(), S.Context, StartArg, Size,
+                               AL.getAttributeSpellingListIndex()));
 }
 
 static bool checkFunctionConditionAttr(Sema &S, Decl *D,
-                                       const AttributeList &Attr,
+                                       const AttributeList &AL,
                                        Expr *&Cond, StringRef &Msg) {
-  Cond = Attr.getArgAsExpr(0);
+  Cond = AL.getArgAsExpr(0);
   if (!Cond->isTypeDependent()) {
     ExprResult Converted = S.PerformContextuallyConvertToBool(Cond);
     if (Converted.isInvalid())
@@ -941,7 +929,7 @@ static bool checkFunctionConditionAttr(S
     Cond = Converted.get();
   }
 
-  if (!S.checkStringLiteralArgumentAttr(Attr, 1, Msg))
+  if (!S.checkStringLiteralArgumentAttr(AL, 1, Msg))
     return false;
 
   if (Msg.empty())
@@ -951,8 +939,8 @@ static bool checkFunctionConditionAttr(S
   if (isa<FunctionDecl>(D) && !Cond->isValueDependent() &&
       !Expr::isPotentialConstantExprUnevaluated(Cond, cast<FunctionDecl>(D),
                                                 Diags)) {
-    S.Diag(Attr.getLoc(), diag::err_attr_cond_never_constant_expr)
-        << Attr.getName();
+    S.Diag(AL.getLoc(), diag::err_attr_cond_never_constant_expr)
+        << AL.getName();
     for (const PartialDiagnosticAt &PDiag : Diags)
       S.Diag(PDiag.first, PDiag.second);
     return false;
@@ -960,15 +948,15 @@ static bool checkFunctionConditionAttr(S
   return true;
 }
 
-static void handleEnableIfAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  S.Diag(Attr.getLoc(), diag::ext_clang_enable_if);
+static void handleEnableIfAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  S.Diag(AL.getLoc(), diag::ext_clang_enable_if);
 
   Expr *Cond;
   StringRef Msg;
-  if (checkFunctionConditionAttr(S, D, Attr, Cond, Msg))
+  if (checkFunctionConditionAttr(S, D, AL, Cond, Msg))
     D->addAttr(::new (S.Context)
-                   EnableIfAttr(Attr.getRange(), S.Context, Cond, Msg,
-                                Attr.getAttributeSpellingListIndex()));
+                   EnableIfAttr(AL.getRange(), S.Context, Cond, Msg,
+                                AL.getAttributeSpellingListIndex()));
 }
 
 namespace {
@@ -1017,21 +1005,21 @@ public:
 };
 }
 
-static void handleDiagnoseIfAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  S.Diag(Attr.getLoc(), diag::ext_clang_diagnose_if);
+static void handleDiagnoseIfAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  S.Diag(AL.getLoc(), diag::ext_clang_diagnose_if);
 
   Expr *Cond;
   StringRef Msg;
-  if (!checkFunctionConditionAttr(S, D, Attr, Cond, Msg))
+  if (!checkFunctionConditionAttr(S, D, AL, Cond, Msg))
     return;
 
   StringRef DiagTypeStr;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 2, DiagTypeStr))
+  if (!S.checkStringLiteralArgumentAttr(AL, 2, DiagTypeStr))
     return;
 
   DiagnoseIfAttr::DiagnosticType DiagType;
   if (!DiagnoseIfAttr::ConvertStrToDiagnosticType(DiagTypeStr, DiagType)) {
-    S.Diag(Attr.getArgAsExpr(2)->getLocStart(),
+    S.Diag(AL.getArgAsExpr(2)->getLocStart(),
            diag::err_diagnose_if_invalid_diagnostic_type);
     return;
   }
@@ -1040,21 +1028,21 @@ static void handleDiagnoseIfAttr(Sema &S
   if (const auto *FD = dyn_cast<FunctionDecl>(D))
     ArgDependent = ArgumentDependenceChecker(FD).referencesArgs(Cond);
   D->addAttr(::new (S.Context) DiagnoseIfAttr(
-      Attr.getRange(), S.Context, Cond, Msg, DiagType, ArgDependent, cast<NamedDecl>(D),
-      Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, Cond, Msg, DiagType, ArgDependent,
+      cast<NamedDecl>(D), AL.getAttributeSpellingListIndex()));
 }
 
 static void handlePassObjectSizeAttr(Sema &S, Decl *D,
-                                     const AttributeList &Attr) {
+                                     const AttributeList &AL) {
   if (D->hasAttr<PassObjectSizeAttr>()) {
     S.Diag(D->getLocStart(), diag::err_attribute_only_once_per_parameter)
-        << Attr.getName();
+        << AL.getName();
     return;
   }
 
-  Expr *E = Attr.getArgAsExpr(0);
+  Expr *E = AL.getArgAsExpr(0);
   uint32_t Type;
-  if (!checkUInt32Argument(S, Attr, E, Type, /*Idx=*/1))
+  if (!checkUInt32Argument(S, AL, E, Type, /*Idx=*/1))
     return;
 
   // pass_object_size's argument is passed in as the second argument of
@@ -1062,7 +1050,7 @@ static void handlePassObjectSizeAttr(Sem
   // argument; namely, it must be in the range [0, 3].
   if (Type > 3) {
     S.Diag(E->getLocStart(), diag::err_attribute_argument_outof_range)
-        << Attr.getName() << 0 << 3 << E->getSourceRange();
+        << AL.getName() << 0 << 3 << E->getSourceRange();
     return;
   }
 
@@ -1072,45 +1060,44 @@ static void handlePassObjectSizeAttr(Sem
   // definition, so we defer the constness check until later.
   if (!cast<ParmVarDecl>(D)->getType()->isPointerType()) {
     S.Diag(D->getLocStart(), diag::err_attribute_pointers_only)
-        << Attr.getName() << 1;
+        << AL.getName() << 1;
     return;
   }
 
-  D->addAttr(::new (S.Context)
-                 PassObjectSizeAttr(Attr.getRange(), S.Context, (int)Type,
-                                    Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) PassObjectSizeAttr(
+      AL.getRange(), S.Context, (int)Type, AL.getAttributeSpellingListIndex()));
 }
 
-static void handleConsumableAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleConsumableAttr(Sema &S, Decl *D, const AttributeList &AL) {
   ConsumableAttr::ConsumedState DefaultState;
 
-  if (Attr.isArgIdent(0)) {
-    IdentifierLoc *IL = Attr.getArgAsIdent(0);
+  if (AL.isArgIdent(0)) {
+    IdentifierLoc *IL = AL.getArgAsIdent(0);
     if (!ConsumableAttr::ConvertStrToConsumedState(IL->Ident->getName(),
                                                    DefaultState)) {
       S.Diag(IL->Loc, diag::warn_attribute_type_not_supported)
-        << Attr.getName() << IL->Ident;
+        << AL.getName() << IL->Ident;
       return;
     }
   } else {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
-        << Attr.getName() << AANT_ArgumentIdentifier;
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
+        << AL.getName() << AANT_ArgumentIdentifier;
     return;
   }
   
   D->addAttr(::new (S.Context)
-             ConsumableAttr(Attr.getRange(), S.Context, DefaultState,
-                            Attr.getAttributeSpellingListIndex()));
+             ConsumableAttr(AL.getRange(), S.Context, DefaultState,
+                            AL.getAttributeSpellingListIndex()));
 }
 
 static bool checkForConsumableClass(Sema &S, const CXXMethodDecl *MD,
-                                        const AttributeList &Attr) {
+                                        const AttributeList &AL) {
   ASTContext &CurrContext = S.getASTContext();
   QualType ThisType = MD->getThisType(CurrContext)->getPointeeType();
   
   if (const CXXRecordDecl *RD = ThisType->getAsCXXRecordDecl()) {
     if (!RD->hasAttr<ConsumableAttr>()) {
-      S.Diag(Attr.getLoc(), diag::warn_attr_on_unconsumable_class) <<
+      S.Diag(AL.getLoc(), diag::warn_attr_on_unconsumable_class) <<
         RD->getNameAsString();
       
       return false;
@@ -1121,32 +1108,32 @@ static bool checkForConsumableClass(Sema
 }
 
 static void handleCallableWhenAttr(Sema &S, Decl *D,
-                                   const AttributeList &Attr) {
-  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+                                   const AttributeList &AL) {
+  if (!checkAttributeAtLeastNumArgs(S, AL, 1))
     return;
   
-  if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), Attr))
+  if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL))
     return;
   
   SmallVector<CallableWhenAttr::ConsumedState, 3> States;
-  for (unsigned ArgIndex = 0; ArgIndex < Attr.getNumArgs(); ++ArgIndex) {
+  for (unsigned ArgIndex = 0; ArgIndex < AL.getNumArgs(); ++ArgIndex) {
     CallableWhenAttr::ConsumedState CallableState;
     
     StringRef StateString;
     SourceLocation Loc;
-    if (Attr.isArgIdent(ArgIndex)) {
-      IdentifierLoc *Ident = Attr.getArgAsIdent(ArgIndex);
+    if (AL.isArgIdent(ArgIndex)) {
+      IdentifierLoc *Ident = AL.getArgAsIdent(ArgIndex);
       StateString = Ident->Ident->getName();
       Loc = Ident->Loc;
     } else {
-      if (!S.checkStringLiteralArgumentAttr(Attr, ArgIndex, StateString, &Loc))
+      if (!S.checkStringLiteralArgumentAttr(AL, ArgIndex, StateString, &Loc))
         return;
     }
 
     if (!CallableWhenAttr::ConvertStrToConsumedState(StateString,
                                                      CallableState)) {
       S.Diag(Loc, diag::warn_attribute_type_not_supported)
-        << Attr.getName() << StateString;
+        << AL.getName() << StateString;
       return;
     }
       
@@ -1154,27 +1141,27 @@ static void handleCallableWhenAttr(Sema
   }
   
   D->addAttr(::new (S.Context)
-             CallableWhenAttr(Attr.getRange(), S.Context, States.data(),
-               States.size(), Attr.getAttributeSpellingListIndex()));
+             CallableWhenAttr(AL.getRange(), S.Context, States.data(),
+               States.size(), AL.getAttributeSpellingListIndex()));
 }
 
 static void handleParamTypestateAttr(Sema &S, Decl *D,
-                                    const AttributeList &Attr) {
+                                    const AttributeList &AL) {
   ParamTypestateAttr::ConsumedState ParamState;
   
-  if (Attr.isArgIdent(0)) {
-    IdentifierLoc *Ident = Attr.getArgAsIdent(0);
+  if (AL.isArgIdent(0)) {
+    IdentifierLoc *Ident = AL.getArgAsIdent(0);
     StringRef StateString = Ident->Ident->getName();
 
     if (!ParamTypestateAttr::ConvertStrToConsumedState(StateString,
                                                        ParamState)) {
       S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported)
-        << Attr.getName() << StateString;
+        << AL.getName() << StateString;
       return;
     }
   } else {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) <<
-      Attr.getName() << AANT_ArgumentIdentifier;
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_type) <<
+      AL.getName() << AANT_ArgumentIdentifier;
     return;
   }
   
@@ -1185,31 +1172,31 @@ static void handleParamTypestateAttr(Sem
   //const CXXRecordDecl *RD = ReturnType->getAsCXXRecordDecl();
   //
   //if (!RD || !RD->hasAttr<ConsumableAttr>()) {
-  //    S.Diag(Attr.getLoc(), diag::warn_return_state_for_unconsumable_type) <<
+  //    S.Diag(AL.getLoc(), diag::warn_return_state_for_unconsumable_type) <<
   //      ReturnType.getAsString();
   //    return;
   //}
   
   D->addAttr(::new (S.Context)
-             ParamTypestateAttr(Attr.getRange(), S.Context, ParamState,
-                                Attr.getAttributeSpellingListIndex()));
+             ParamTypestateAttr(AL.getRange(), S.Context, ParamState,
+                                AL.getAttributeSpellingListIndex()));
 }
 
 static void handleReturnTypestateAttr(Sema &S, Decl *D,
-                                      const AttributeList &Attr) {
+                                      const AttributeList &AL) {
   ReturnTypestateAttr::ConsumedState ReturnState;
   
-  if (Attr.isArgIdent(0)) {
-    IdentifierLoc *IL = Attr.getArgAsIdent(0);
+  if (AL.isArgIdent(0)) {
+    IdentifierLoc *IL = AL.getArgAsIdent(0);
     if (!ReturnTypestateAttr::ConvertStrToConsumedState(IL->Ident->getName(),
                                                         ReturnState)) {
       S.Diag(IL->Loc, diag::warn_attribute_type_not_supported)
-        << Attr.getName() << IL->Ident;
+        << AL.getName() << IL->Ident;
       return;
     }
   } else {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) <<
-      Attr.getName() << AANT_ArgumentIdentifier;
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_type) <<
+      AL.getName() << AANT_ArgumentIdentifier;
     return;
   }
   
@@ -1237,72 +1224,71 @@ static void handleReturnTypestateAttr(Se
   //      ReturnType.getAsString();
   //    return;
   //}
-  
+
   D->addAttr(::new (S.Context)
-             ReturnTypestateAttr(Attr.getRange(), S.Context, ReturnState,
-                                 Attr.getAttributeSpellingListIndex()));
+                 ReturnTypestateAttr(AL.getRange(), S.Context, ReturnState,
+                                     AL.getAttributeSpellingListIndex()));
 }
 
-static void handleSetTypestateAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), Attr))
+static void handleSetTypestateAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL))
     return;
   
   SetTypestateAttr::ConsumedState NewState;
-  if (Attr.isArgIdent(0)) {
-    IdentifierLoc *Ident = Attr.getArgAsIdent(0);
+  if (AL.isArgIdent(0)) {
+    IdentifierLoc *Ident = AL.getArgAsIdent(0);
     StringRef Param = Ident->Ident->getName();
     if (!SetTypestateAttr::ConvertStrToConsumedState(Param, NewState)) {
       S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported)
-        << Attr.getName() << Param;
+        << AL.getName() << Param;
       return;
     }
   } else {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) <<
-      Attr.getName() << AANT_ArgumentIdentifier;
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_type) <<
+      AL.getName() << AANT_ArgumentIdentifier;
     return;
   }
   
   D->addAttr(::new (S.Context)
-             SetTypestateAttr(Attr.getRange(), S.Context, NewState,
-                              Attr.getAttributeSpellingListIndex()));
+             SetTypestateAttr(AL.getRange(), S.Context, NewState,
+                              AL.getAttributeSpellingListIndex()));
 }
 
 static void handleTestTypestateAttr(Sema &S, Decl *D,
-                                    const AttributeList &Attr) {
-  if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), Attr))
+                                    const AttributeList &AL) {
+  if (!checkForConsumableClass(S, cast<CXXMethodDecl>(D), AL))
     return;
   
   TestTypestateAttr::ConsumedState TestState;  
-  if (Attr.isArgIdent(0)) {
-    IdentifierLoc *Ident = Attr.getArgAsIdent(0);
+  if (AL.isArgIdent(0)) {
+    IdentifierLoc *Ident = AL.getArgAsIdent(0);
     StringRef Param = Ident->Ident->getName();
     if (!TestTypestateAttr::ConvertStrToConsumedState(Param, TestState)) {
       S.Diag(Ident->Loc, diag::warn_attribute_type_not_supported)
-        << Attr.getName() << Param;
+        << AL.getName() << Param;
       return;
     }
   } else {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) <<
-      Attr.getName() << AANT_ArgumentIdentifier;
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_type) <<
+      AL.getName() << AANT_ArgumentIdentifier;
     return;
   }
   
   D->addAttr(::new (S.Context)
-             TestTypestateAttr(Attr.getRange(), S.Context, TestState,
-                                Attr.getAttributeSpellingListIndex()));
+             TestTypestateAttr(AL.getRange(), S.Context, TestState,
+                                AL.getAttributeSpellingListIndex()));
 }
 
-static void handleExtVectorTypeAttr(Sema &S, Scope *scope, Decl *D,
-                                    const AttributeList &Attr) {
+static void handleExtVectorTypeAttr(Sema &S, Decl *D, const AttributeList &AL) {
   // Remember this typedef decl, we will need it later for diagnostics.
   S.ExtVectorDecls.push_back(cast<TypedefNameDecl>(D));
 }
 
-static void handlePackedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (TagDecl *TD = dyn_cast<TagDecl>(D))
-    TD->addAttr(::new (S.Context) PackedAttr(Attr.getRange(), S.Context,
-                                        Attr.getAttributeSpellingListIndex()));
-  else if (FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
+static void handlePackedAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (auto *TD = dyn_cast<TagDecl>(D))
+    TD->addAttr(::new (S.Context) PackedAttr(AL.getRange(), S.Context,
+                                        AL.getAttributeSpellingListIndex()));
+  else if (auto *FD = dyn_cast<FieldDecl>(D)) {
     bool BitfieldByteAligned = (!FD->getType()->isDependentType() &&
                                 !FD->getType()->isIncompleteType() &&
                                 FD->isBitField() &&
@@ -1311,81 +1297,81 @@ static void handlePackedAttr(Sema &S, De
     if (S.getASTContext().getTargetInfo().getTriple().isPS4()) {
       if (BitfieldByteAligned)
         // The PS4 target needs to maintain ABI backwards compatibility.
-        S.Diag(Attr.getLoc(), diag::warn_attribute_ignored_for_field_of_type)
-          << Attr.getName() << FD->getType();
+        S.Diag(AL.getLoc(), diag::warn_attribute_ignored_for_field_of_type)
+          << AL.getName() << FD->getType();
       else
         FD->addAttr(::new (S.Context) PackedAttr(
-                    Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+                    AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
     } else {
       // Report warning about changed offset in the newer compiler versions.
       if (BitfieldByteAligned)
-        S.Diag(Attr.getLoc(), diag::warn_attribute_packed_for_bitfield);
+        S.Diag(AL.getLoc(), diag::warn_attribute_packed_for_bitfield);
 
       FD->addAttr(::new (S.Context) PackedAttr(
-                  Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+                  AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
     }
 
   } else
-    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
+    S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL.getName();
 }
 
-static bool checkIBOutletCommon(Sema &S, Decl *D, const AttributeList &Attr) {
+static bool checkIBOutletCommon(Sema &S, Decl *D, const AttributeList &AL) {
   // The IBOutlet/IBOutletCollection attributes only apply to instance
   // variables or properties of Objective-C classes.  The outlet must also
   // have an object reference type.
-  if (const ObjCIvarDecl *VD = dyn_cast<ObjCIvarDecl>(D)) {
+  if (const auto *VD = dyn_cast<ObjCIvarDecl>(D)) {
     if (!VD->getType()->getAs<ObjCObjectPointerType>()) {
-      S.Diag(Attr.getLoc(), diag::warn_iboutlet_object_type)
-        << Attr.getName() << VD->getType() << 0;
+      S.Diag(AL.getLoc(), diag::warn_iboutlet_object_type)
+        << AL.getName() << VD->getType() << 0;
       return false;
     }
   }
-  else if (const ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D)) {
+  else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
     if (!PD->getType()->getAs<ObjCObjectPointerType>()) {
-      S.Diag(Attr.getLoc(), diag::warn_iboutlet_object_type)
-        << Attr.getName() << PD->getType() << 1;
+      S.Diag(AL.getLoc(), diag::warn_iboutlet_object_type)
+        << AL.getName() << PD->getType() << 1;
       return false;
     }
   }
   else {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_iboutlet) << Attr.getName();
+    S.Diag(AL.getLoc(), diag::warn_attribute_iboutlet) << AL.getName();
     return false;
   }
 
   return true;
 }
 
-static void handleIBOutlet(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (!checkIBOutletCommon(S, D, Attr))
+static void handleIBOutlet(Sema &S, Decl *D, const AttributeList &AL) {
+  if (!checkIBOutletCommon(S, D, AL))
     return;
 
   D->addAttr(::new (S.Context)
-             IBOutletAttr(Attr.getRange(), S.Context,
-                          Attr.getAttributeSpellingListIndex()));
+             IBOutletAttr(AL.getRange(), S.Context,
+                          AL.getAttributeSpellingListIndex()));
 }
 
 static void handleIBOutletCollection(Sema &S, Decl *D,
-                                     const AttributeList &Attr) {
+                                     const AttributeList &AL) {
 
   // The iboutletcollection attribute can have zero or one arguments.
-  if (Attr.getNumArgs() > 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
-      << Attr.getName() << 1;
+  if (AL.getNumArgs() > 1) {
+    S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments)
+      << AL.getName() << 1;
     return;
   }
 
-  if (!checkIBOutletCommon(S, D, Attr))
+  if (!checkIBOutletCommon(S, D, AL))
     return;
 
   ParsedType PT;
 
-  if (Attr.hasParsedType())
-    PT = Attr.getTypeArg();
+  if (AL.hasParsedType())
+    PT = AL.getTypeArg();
   else {
-    PT = S.getTypeName(S.Context.Idents.get("NSObject"), Attr.getLoc(),
+    PT = S.getTypeName(S.Context.Idents.get("NSObject"), AL.getLoc(),
                        S.getScopeForContext(D->getDeclContext()->getParent()));
     if (!PT) {
-      S.Diag(Attr.getLoc(), diag::err_iboutletcollection_type) << "NSObject";
+      S.Diag(AL.getLoc(), diag::err_iboutletcollection_type) << "NSObject";
       return;
     }
   }
@@ -1393,22 +1379,22 @@ static void handleIBOutletCollection(Sem
   TypeSourceInfo *QTLoc = nullptr;
   QualType QT = S.GetTypeFromParser(PT, &QTLoc);
   if (!QTLoc)
-    QTLoc = S.Context.getTrivialTypeSourceInfo(QT, Attr.getLoc());
+    QTLoc = S.Context.getTrivialTypeSourceInfo(QT, AL.getLoc());
 
   // Diagnose use of non-object type in iboutletcollection attribute.
   // FIXME. Gnu attribute extension ignores use of builtin types in
   // attributes. So, __attribute__((iboutletcollection(char))) will be
   // treated as __attribute__((iboutletcollection())).
   if (!QT->isObjCIdType() && !QT->isObjCObjectType()) {
-    S.Diag(Attr.getLoc(),
+    S.Diag(AL.getLoc(),
            QT->isBuiltinType() ? diag::err_iboutletcollection_builtintype
                                : diag::err_iboutletcollection_type) << QT;
     return;
   }
 
   D->addAttr(::new (S.Context)
-             IBOutletCollectionAttr(Attr.getRange(), S.Context, QTLoc,
-                                    Attr.getAttributeSpellingListIndex()));
+             IBOutletCollectionAttr(AL.getRange(), S.Context, QTLoc,
+                                    AL.getAttributeSpellingListIndex()));
 }
 
 bool Sema::isValidPointerAttrType(QualType T, bool RefOkay) {
@@ -1435,33 +1421,33 @@ bool Sema::isValidPointerAttrType(QualTy
   return T->isAnyPointerType() || T->isBlockPointerType();
 }
 
-static bool attrNonNullArgCheck(Sema &S, QualType T, const AttributeList &Attr,
+static bool attrNonNullArgCheck(Sema &S, QualType T, const AttributeList &AL,
                                 SourceRange AttrParmRange,
                                 SourceRange TypeRange,
                                 bool isReturnValue = false) {
   if (!S.isValidPointerAttrType(T)) {
     if (isReturnValue)
-      S.Diag(Attr.getLoc(), diag::warn_attribute_return_pointers_only)
-          << Attr.getName() << AttrParmRange << TypeRange;
+      S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only)
+          << AL.getName() << AttrParmRange << TypeRange;
     else
-      S.Diag(Attr.getLoc(), diag::warn_attribute_pointers_only)
-          << Attr.getName() << AttrParmRange << TypeRange << 0;
+      S.Diag(AL.getLoc(), diag::warn_attribute_pointers_only)
+          << AL.getName() << AttrParmRange << TypeRange << 0;
     return false;
   }
   return true;
 }
 
-static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleNonNullAttr(Sema &S, Decl *D, const AttributeList &AL) {
   SmallVector<unsigned, 8> NonNullArgs;
-  for (unsigned I = 0; I < Attr.getNumArgs(); ++I) {
-    Expr *Ex = Attr.getArgAsExpr(I);
+  for (unsigned I = 0; I < AL.getNumArgs(); ++I) {
+    Expr *Ex = AL.getArgAsExpr(I);
     uint64_t Idx;
-    if (!checkFunctionOrMethodParameterIndex(S, D, Attr, I + 1, Ex, Idx))
+    if (!checkFunctionOrMethodParameterIndex(S, D, AL, I + 1, Ex, Idx))
       return;
 
     // Is the function argument a pointer type?
     if (Idx < getFunctionOrMethodNumParams(D) &&
-        !attrNonNullArgCheck(S, getFunctionOrMethodParamType(D, Idx), Attr,
+        !attrNonNullArgCheck(S, getFunctionOrMethodParamType(D, Idx), AL,
                              Ex->getSourceRange(),
                              getFunctionOrMethodParamRange(D, Idx)))
       continue;
@@ -1473,7 +1459,7 @@ static void handleNonNullAttr(Sema &S, D
   // arguments have a nonnull attribute; warn if there aren't any. Skip this
   // check if the attribute came from a macro expansion or a template
   // instantiation.
-  if (NonNullArgs.empty() && Attr.getLoc().isFileID() &&
+  if (NonNullArgs.empty() && AL.getLoc().isFileID() &&
       !S.inTemplateInstantiation()) {
     bool AnyPointers = isFunctionOrMethodVariadic(D);
     for (unsigned I = 0, E = getFunctionOrMethodNumParams(D);
@@ -1484,80 +1470,80 @@ static void handleNonNullAttr(Sema &S, D
     }
 
     if (!AnyPointers)
-      S.Diag(Attr.getLoc(), diag::warn_attribute_nonnull_no_pointers);
+      S.Diag(AL.getLoc(), diag::warn_attribute_nonnull_no_pointers);
   }
 
   unsigned *Start = NonNullArgs.data();
   unsigned Size = NonNullArgs.size();
   llvm::array_pod_sort(Start, Start + Size);
   D->addAttr(::new (S.Context)
-             NonNullAttr(Attr.getRange(), S.Context, Start, Size,
-                         Attr.getAttributeSpellingListIndex()));
+             NonNullAttr(AL.getRange(), S.Context, Start, Size,
+                         AL.getAttributeSpellingListIndex()));
 }
 
 static void handleNonNullAttrParameter(Sema &S, ParmVarDecl *D,
-                                       const AttributeList &Attr) {
-  if (Attr.getNumArgs() > 0) {
+                                       const AttributeList &AL) {
+  if (AL.getNumArgs() > 0) {
     if (D->getFunctionType()) {
-      handleNonNullAttr(S, D, Attr);
+      handleNonNullAttr(S, D, AL);
     } else {
-      S.Diag(Attr.getLoc(), diag::warn_attribute_nonnull_parm_no_args)
+      S.Diag(AL.getLoc(), diag::warn_attribute_nonnull_parm_no_args)
         << D->getSourceRange();
     }
     return;
   }
 
   // Is the argument a pointer type?
-  if (!attrNonNullArgCheck(S, D->getType(), Attr, SourceRange(),
+  if (!attrNonNullArgCheck(S, D->getType(), AL, SourceRange(),
                            D->getSourceRange()))
     return;
 
   D->addAttr(::new (S.Context)
-             NonNullAttr(Attr.getRange(), S.Context, nullptr, 0,
-                         Attr.getAttributeSpellingListIndex()));
+             NonNullAttr(AL.getRange(), S.Context, nullptr, 0,
+                         AL.getAttributeSpellingListIndex()));
 }
 
 static void handleReturnsNonNullAttr(Sema &S, Decl *D,
-                                     const AttributeList &Attr) {
+                                     const AttributeList &AL) {
   QualType ResultType = getFunctionOrMethodResultType(D);
   SourceRange SR = getFunctionOrMethodResultSourceRange(D);
-  if (!attrNonNullArgCheck(S, ResultType, Attr, SourceRange(), SR,
+  if (!attrNonNullArgCheck(S, ResultType, AL, SourceRange(), SR,
                            /* isReturnValue */ true))
     return;
 
   D->addAttr(::new (S.Context)
-            ReturnsNonNullAttr(Attr.getRange(), S.Context,
-                               Attr.getAttributeSpellingListIndex()));
+            ReturnsNonNullAttr(AL.getRange(), S.Context,
+                               AL.getAttributeSpellingListIndex()));
 }
 
-static void handleNoEscapeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleNoEscapeAttr(Sema &S, Decl *D, const AttributeList &AL) {
   if (D->isInvalidDecl())
     return;
 
   // noescape only applies to pointer types.
   QualType T = cast<ParmVarDecl>(D)->getType();
   if (!S.isValidPointerAttrType(T, /* RefOkay */ true)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_pointers_only)
-        << Attr.getName() << Attr.getRange() << 0;
+    S.Diag(AL.getLoc(), diag::warn_attribute_pointers_only)
+        << AL.getName() << AL.getRange() << 0;
     return;
   }
 
   D->addAttr(::new (S.Context) NoEscapeAttr(
-      Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
 }
 
 static void handleAssumeAlignedAttr(Sema &S, Decl *D,
-                                    const AttributeList &Attr) {
-  Expr *E = Attr.getArgAsExpr(0),
-       *OE = Attr.getNumArgs() > 1 ? Attr.getArgAsExpr(1) : nullptr;
-  S.AddAssumeAlignedAttr(Attr.getRange(), D, E, OE,
-                         Attr.getAttributeSpellingListIndex());
+                                    const AttributeList &AL) {
+  Expr *E = AL.getArgAsExpr(0),
+       *OE = AL.getNumArgs() > 1 ? AL.getArgAsExpr(1) : nullptr;
+  S.AddAssumeAlignedAttr(AL.getRange(), D, E, OE,
+                         AL.getAttributeSpellingListIndex());
 }
 
 static void handleAllocAlignAttr(Sema &S, Decl *D,
-                                   const AttributeList &Attr) {
-  S.AddAllocAlignAttr(Attr.getRange(), D, Attr.getArgAsExpr(0),
-                      Attr.getAttributeSpellingListIndex());
+                                   const AttributeList &AL) {
+  S.AddAllocAlignAttr(AL.getRange(), D, AL.getArgAsExpr(0),
+                      AL.getAttributeSpellingListIndex());
 }
 
 void Sema::AddAssumeAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
@@ -1769,16 +1755,14 @@ static void handleOwnershipAttr(Sema &S,
                            AL.getAttributeSpellingListIndex()));
 }
 
-static void handleWeakRefAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleWeakRefAttr(Sema &S, Decl *D, const AttributeList &AL) {
   // Check the attribute arguments.
-  if (Attr.getNumArgs() > 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
-      << Attr.getName() << 1;
+  if (AL.getNumArgs() > 1) {
+    S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments)
+      << AL.getName() << 1;
     return;
   }
 
-  NamedDecl *nd = cast<NamedDecl>(D);
-
   // gcc rejects
   // class c {
   //   static int a __attribute__((weakref ("v2")));
@@ -1791,8 +1775,8 @@ static void handleWeakRefAttr(Sema &S, D
   // we reject them
   const DeclContext *Ctx = D->getDeclContext()->getRedeclContext();
   if (!Ctx->isFileContext()) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_weakref_not_global_context)
-      << nd;
+    S.Diag(AL.getLoc(), diag::err_attribute_weakref_not_global_context)
+        << cast<NamedDecl>(D);
     return;
   }
 
@@ -1822,88 +1806,88 @@ static void handleWeakRefAttr(Sema &S, D
   // of transforming it into an AliasAttr.  The WeakRefAttr never uses the
   // StringRef parameter it was given anyway.
   StringRef Str;
-  if (Attr.getNumArgs() && S.checkStringLiteralArgumentAttr(Attr, 0, Str))
+  if (AL.getNumArgs() && S.checkStringLiteralArgumentAttr(AL, 0, Str))
     // GCC will accept anything as the argument of weakref. Should we
     // check for an existing decl?
-    D->addAttr(::new (S.Context) AliasAttr(Attr.getRange(), S.Context, Str,
-                                        Attr.getAttributeSpellingListIndex()));
+    D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
+                                        AL.getAttributeSpellingListIndex()));
 
   D->addAttr(::new (S.Context)
-             WeakRefAttr(Attr.getRange(), S.Context,
-                         Attr.getAttributeSpellingListIndex()));
+             WeakRefAttr(AL.getRange(), S.Context,
+                         AL.getAttributeSpellingListIndex()));
 }
 
-static void handleIFuncAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleIFuncAttr(Sema &S, Decl *D, const AttributeList &AL) {
   StringRef Str;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
     return;
 
   // Aliases should be on declarations, not definitions.
   const auto *FD = cast<FunctionDecl>(D);
   if (FD->isThisDeclarationADefinition()) {
-    S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << FD << 1;
+    S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 1;
     return;
   }
 
-  D->addAttr(::new (S.Context) IFuncAttr(Attr.getRange(), S.Context, Str,
-                                         Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) IFuncAttr(AL.getRange(), S.Context, Str,
+                                         AL.getAttributeSpellingListIndex()));
 }
 
-static void handleAliasAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleAliasAttr(Sema &S, Decl *D, const AttributeList &AL) {
   StringRef Str;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
     return;
 
   if (S.Context.getTargetInfo().getTriple().isOSDarwin()) {
-    S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_darwin);
+    S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_darwin);
     return;
   }
   if (S.Context.getTargetInfo().getTriple().isNVPTX()) {
-    S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_nvptx);
+    S.Diag(AL.getLoc(), diag::err_alias_not_supported_on_nvptx);
   }
 
   // Aliases should be on declarations, not definitions.
   if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
     if (FD->isThisDeclarationADefinition()) {
-      S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << FD << 0;
+      S.Diag(AL.getLoc(), diag::err_alias_is_definition) << FD << 0;
       return;
     }
   } else {
     const auto *VD = cast<VarDecl>(D);
     if (VD->isThisDeclarationADefinition() && VD->isExternallyVisible()) {
-      S.Diag(Attr.getLoc(), diag::err_alias_is_definition) << VD << 0;
+      S.Diag(AL.getLoc(), diag::err_alias_is_definition) << VD << 0;
       return;
     }
   }
 
   // FIXME: check if target symbol exists in current file
 
-  D->addAttr(::new (S.Context) AliasAttr(Attr.getRange(), S.Context, Str,
-                                         Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
+                                         AL.getAttributeSpellingListIndex()));
 }
 
-static void handleColdAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<HotAttr>(S, D, Attr.getRange(), Attr.getName()))
+static void handleColdAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (checkAttrMutualExclusion<HotAttr>(S, D, AL.getRange(), AL.getName()))
     return;
 
-  D->addAttr(::new (S.Context) ColdAttr(Attr.getRange(), S.Context,
-                                        Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) ColdAttr(AL.getRange(), S.Context,
+                                        AL.getAttributeSpellingListIndex()));
 }
 
-static void handleHotAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<ColdAttr>(S, D, Attr.getRange(), Attr.getName()))
+static void handleHotAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (checkAttrMutualExclusion<ColdAttr>(S, D, AL.getRange(), AL.getName()))
     return;
 
-  D->addAttr(::new (S.Context) HotAttr(Attr.getRange(), S.Context,
-                                       Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) HotAttr(AL.getRange(), S.Context,
+                                       AL.getAttributeSpellingListIndex()));
 }
 
 static void handleTLSModelAttr(Sema &S, Decl *D,
-                               const AttributeList &Attr) {
+                               const AttributeList &AL) {
   StringRef Model;
   SourceLocation LiteralLoc;
   // Check that it is a string.
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Model, &LiteralLoc))
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Model, &LiteralLoc))
     return;
 
   // Check that the value.
@@ -1914,52 +1898,52 @@ static void handleTLSModelAttr(Sema &S,
   }
 
   D->addAttr(::new (S.Context)
-             TLSModelAttr(Attr.getRange(), S.Context, Model,
-                          Attr.getAttributeSpellingListIndex()));
+             TLSModelAttr(AL.getRange(), S.Context, Model,
+                          AL.getAttributeSpellingListIndex()));
 }
 
-static void handleRestrictAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleRestrictAttr(Sema &S, Decl *D, const AttributeList &AL) {
   QualType ResultType = getFunctionOrMethodResultType(D);
   if (ResultType->isAnyPointerType() || ResultType->isBlockPointerType()) {
     D->addAttr(::new (S.Context) RestrictAttr(
-        Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+        AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
     return;
   }
 
-  S.Diag(Attr.getLoc(), diag::warn_attribute_return_pointers_only)
-      << Attr.getName() << getFunctionOrMethodResultSourceRange(D);
+  S.Diag(AL.getLoc(), diag::warn_attribute_return_pointers_only)
+      << AL.getName() << getFunctionOrMethodResultSourceRange(D);
 }
 
-static void handleCommonAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleCommonAttr(Sema &S, Decl *D, const AttributeList &AL) {
   if (S.LangOpts.CPlusPlus) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_not_supported_in_lang)
-        << Attr.getName() << AttributeLangSupport::Cpp;
+    S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang)
+        << AL.getName() << AttributeLangSupport::Cpp;
     return;
   }
 
-  if (CommonAttr *CA = S.mergeCommonAttr(D, Attr.getRange(), Attr.getName(),
-                                         Attr.getAttributeSpellingListIndex()))
+  if (CommonAttr *CA = S.mergeCommonAttr(D, AL.getRange(), AL.getName(),
+                                         AL.getAttributeSpellingListIndex()))
     D->addAttr(CA);
 }
 
-static void handleNakedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<DisableTailCallsAttr>(S, D, Attr.getRange(),
-                                                     Attr.getName()))
+static void handleNakedAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (checkAttrMutualExclusion<DisableTailCallsAttr>(S, D, AL.getRange(),
+                                                     AL.getName()))
     return;
 
-  if (Attr.isDeclspecAttribute()) {
+  if (AL.isDeclspecAttribute()) {
     const auto &Triple = S.getASTContext().getTargetInfo().getTriple();
     const auto &Arch = Triple.getArch();
     if (Arch != llvm::Triple::x86 &&
         (Arch != llvm::Triple::arm && Arch != llvm::Triple::thumb)) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_not_supported_on_arch)
-          << Attr.getName() << Triple.getArchName();
+      S.Diag(AL.getLoc(), diag::err_attribute_not_supported_on_arch)
+          << AL.getName() << Triple.getArchName();
       return;
     }
   }
 
-  D->addAttr(::new (S.Context) NakedAttr(Attr.getRange(), S.Context,
-                                         Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) NakedAttr(AL.getRange(), S.Context,
+                                         AL.getAttributeSpellingListIndex()));
 }
 
 static void handleNoReturnAttr(Sema &S, Decl *D, const AttributeList &Attrs) {
@@ -1979,12 +1963,12 @@ static void handleNoReturnAttr(Sema &S,
 }
 
 static void handleNoCallerSavedRegsAttr(Sema &S, Decl *D,
-                                        const AttributeList &Attr) {
-  if (S.CheckNoCallerSavedRegsAttr(Attr))
+                                        const AttributeList &AL) {
+  if (S.CheckNoCallerSavedRegsAttr(AL))
     return;
 
   D->addAttr(::new (S.Context) AnyX86NoCallerSavedRegistersAttr(
-      Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
 }
 
 bool Sema::CheckNoReturnAttr(const AttributeList &Attrs) {
@@ -1996,16 +1980,16 @@ bool Sema::CheckNoReturnAttr(const Attri
   return false;
 }
 
-bool Sema::CheckNoCallerSavedRegsAttr(const AttributeList &Attr) {
+bool Sema::CheckNoCallerSavedRegsAttr(const AttributeList &AL) {
   // Check whether the attribute is valid on the current target.
-  if (!Attr.existsInTarget(Context.getTargetInfo())) {
-    Diag(Attr.getLoc(), diag::warn_unknown_attribute_ignored) << Attr.getName();
-    Attr.setInvalid();
+  if (!AL.existsInTarget(Context.getTargetInfo())) {
+    Diag(AL.getLoc(), diag::warn_unknown_attribute_ignored) << AL.getName();
+    AL.setInvalid();
     return true;
   }
 
-  if (!checkAttributeNumArgs(*this, Attr, 0)) {
-    Attr.setInvalid();
+  if (!checkAttributeNumArgs(*this, AL, 0)) {
+    AL.setInvalid();
     return true;
   }
 
@@ -2013,7 +1997,7 @@ bool Sema::CheckNoCallerSavedRegsAttr(co
 }
 
 static void handleAnalyzerNoReturnAttr(Sema &S, Decl *D,
-                                       const AttributeList &Attr) {
+                                       const AttributeList &AL) {
   
   // The checking path for 'noreturn' and 'analyzer_noreturn' are different
   // because 'analyzer_noreturn' does not impact the type.
@@ -2021,21 +2005,21 @@ static void handleAnalyzerNoReturnAttr(S
     ValueDecl *VD = dyn_cast<ValueDecl>(D);
     if (!VD || (!VD->getType()->isBlockPointerType() &&
                 !VD->getType()->isFunctionPointerType())) {
-      S.Diag(Attr.getLoc(),
-             Attr.isCXX11Attribute() ? diag::err_attribute_wrong_decl_type
+      S.Diag(AL.getLoc(),
+             AL.isCXX11Attribute() ? diag::err_attribute_wrong_decl_type
                                      : diag::warn_attribute_wrong_decl_type)
-        << Attr.getName() << ExpectedFunctionMethodOrBlock;
+        << AL.getName() << ExpectedFunctionMethodOrBlock;
       return;
     }
   }
   
   D->addAttr(::new (S.Context)
-             AnalyzerNoReturnAttr(Attr.getRange(), S.Context,
-                                  Attr.getAttributeSpellingListIndex()));
+             AnalyzerNoReturnAttr(AL.getRange(), S.Context,
+                                  AL.getAttributeSpellingListIndex()));
 }
 
 // PS3 PPU-specific.
-static void handleVecReturnAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleVecReturnAttr(Sema &S, Decl *D, const AttributeList &AL) {
 /*
   Returning a Vector Class in Registers
   
@@ -2060,99 +2044,98 @@ static void handleVecReturnAttr(Sema &S,
   }
 */
   if (VecReturnAttr *A = D->getAttr<VecReturnAttr>()) {
-    S.Diag(Attr.getLoc(), diag::err_repeat_attribute) << A;
+    S.Diag(AL.getLoc(), diag::err_repeat_attribute) << A;
     return;
   }
 
-  RecordDecl *record = cast<RecordDecl>(D);
+  const auto *R = cast<RecordDecl>(D);
   int count = 0;
 
-  if (!isa<CXXRecordDecl>(record)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_vecreturn_only_vector_member);
+  if (!isa<CXXRecordDecl>(R)) {
+    S.Diag(AL.getLoc(), diag::err_attribute_vecreturn_only_vector_member);
     return;
   }
 
-  if (!cast<CXXRecordDecl>(record)->isPOD()) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_vecreturn_only_pod_record);
+  if (!cast<CXXRecordDecl>(R)->isPOD()) {
+    S.Diag(AL.getLoc(), diag::err_attribute_vecreturn_only_pod_record);
     return;
   }
 
-  for (const auto *I : record->fields()) {
+  for (const auto *I : R->fields()) {
     if ((count == 1) || !I->getType()->isVectorType()) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_vecreturn_only_vector_member);
+      S.Diag(AL.getLoc(), diag::err_attribute_vecreturn_only_vector_member);
       return;
     }
     count++;
   }
 
-  D->addAttr(::new (S.Context)
-             VecReturnAttr(Attr.getRange(), S.Context,
-                           Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) VecReturnAttr(
+      AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
 }
 
 static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D,
-                                 const AttributeList &Attr) {
+                                 const AttributeList &AL) {
   if (isa<ParmVarDecl>(D)) {
     // [[carries_dependency]] can only be applied to a parameter if it is a
     // parameter of a function declaration or lambda.
     if (!(Scope->getFlags() & clang::Scope::FunctionDeclarationScope)) {
-      S.Diag(Attr.getLoc(),
+      S.Diag(AL.getLoc(),
              diag::err_carries_dependency_param_not_function_decl);
       return;
     }
   }
 
   D->addAttr(::new (S.Context) CarriesDependencyAttr(
-                                   Attr.getRange(), S.Context,
-                                   Attr.getAttributeSpellingListIndex()));
+                                   AL.getRange(), S.Context,
+                                   AL.getAttributeSpellingListIndex()));
 }
 
 static void handleNotTailCalledAttr(Sema &S, Decl *D,
-                                    const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<AlwaysInlineAttr>(S, D, Attr.getRange(),
-                                                 Attr.getName()))
+                                    const AttributeList &AL) {
+  if (checkAttrMutualExclusion<AlwaysInlineAttr>(S, D, AL.getRange(),
+                                                 AL.getName()))
     return;
 
   D->addAttr(::new (S.Context) NotTailCalledAttr(
-      Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
 }
 
 static void handleDisableTailCallsAttr(Sema &S, Decl *D,
-                                       const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<NakedAttr>(S, D, Attr.getRange(),
-                                          Attr.getName()))
+                                       const AttributeList &AL) {
+  if (checkAttrMutualExclusion<NakedAttr>(S, D, AL.getRange(),
+                                          AL.getName()))
     return;
 
   D->addAttr(::new (S.Context) DisableTailCallsAttr(
-      Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
 }
 
-static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+static void handleUsedAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (const auto *VD = dyn_cast<VarDecl>(D)) {
     if (VD->hasLocalStorage()) {
-      S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
+      S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL.getName();
       return;
     }
   } else if (!isFunctionOrMethod(D)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-      << Attr.getName() << ExpectedVariableOrFunction;
+    S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << AL.getName() << ExpectedVariableOrFunction;
     return;
   }
 
   D->addAttr(::new (S.Context)
-             UsedAttr(Attr.getRange(), S.Context,
-                      Attr.getAttributeSpellingListIndex()));
+             UsedAttr(AL.getRange(), S.Context,
+                      AL.getAttributeSpellingListIndex()));
 }
 
-static void handleUnusedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  bool IsCXX17Attr = Attr.isCXX11Attribute() && !Attr.getScopeName();
+static void handleUnusedAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  bool IsCXX17Attr = AL.isCXX11Attribute() && !AL.getScopeName();
 
   if (IsCXX17Attr && isa<VarDecl>(D)) {
     // The C++17 spelling of this attribute cannot be applied to a static data
     // member per [dcl.attr.unused]p2.
     if (cast<VarDecl>(D)->isStaticDataMember()) {
-      S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-          << Attr.getName() << ExpectedForMaybeUnused;
+      S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
+          << AL.getName() << ExpectedForMaybeUnused;
       return;
     }
   }
@@ -2160,57 +2143,57 @@ static void handleUnusedAttr(Sema &S, De
   // If this is spelled as the standard C++17 attribute, but not in C++17, warn
   // about using it as an extension.
   if (!S.getLangOpts().CPlusPlus17 && IsCXX17Attr)
-    S.Diag(Attr.getLoc(), diag::ext_cxx17_attr) << Attr.getName();
+    S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL.getName();
 
   D->addAttr(::new (S.Context) UnusedAttr(
-      Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
 }
 
-static void handleConstructorAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleConstructorAttr(Sema &S, Decl *D, const AttributeList &AL) {
   uint32_t priority = ConstructorAttr::DefaultPriority;
-  if (Attr.getNumArgs() &&
-      !checkUInt32Argument(S, Attr, Attr.getArgAsExpr(0), priority))
+  if (AL.getNumArgs() &&
+      !checkUInt32Argument(S, AL, AL.getArgAsExpr(0), priority))
     return;
 
   D->addAttr(::new (S.Context)
-             ConstructorAttr(Attr.getRange(), S.Context, priority,
-                             Attr.getAttributeSpellingListIndex()));
+             ConstructorAttr(AL.getRange(), S.Context, priority,
+                             AL.getAttributeSpellingListIndex()));
 }
 
-static void handleDestructorAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleDestructorAttr(Sema &S, Decl *D, const AttributeList &AL) {
   uint32_t priority = DestructorAttr::DefaultPriority;
-  if (Attr.getNumArgs() &&
-      !checkUInt32Argument(S, Attr, Attr.getArgAsExpr(0), priority))
+  if (AL.getNumArgs() &&
+      !checkUInt32Argument(S, AL, AL.getArgAsExpr(0), priority))
     return;
 
   D->addAttr(::new (S.Context)
-             DestructorAttr(Attr.getRange(), S.Context, priority,
-                            Attr.getAttributeSpellingListIndex()));
+             DestructorAttr(AL.getRange(), S.Context, priority,
+                            AL.getAttributeSpellingListIndex()));
 }
 
 template <typename AttrTy>
 static void handleAttrWithMessage(Sema &S, Decl *D,
-                                  const AttributeList &Attr) {
+                                  const AttributeList &AL) {
   // Handle the case where the attribute has a text message.
   StringRef Str;
-  if (Attr.getNumArgs() == 1 && !S.checkStringLiteralArgumentAttr(Attr, 0, Str))
+  if (AL.getNumArgs() == 1 && !S.checkStringLiteralArgumentAttr(AL, 0, Str))
     return;
 
-  D->addAttr(::new (S.Context) AttrTy(Attr.getRange(), S.Context, Str,
-                                      Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) AttrTy(AL.getRange(), S.Context, Str,
+                                      AL.getAttributeSpellingListIndex()));
 }
 
 static void handleObjCSuppresProtocolAttr(Sema &S, Decl *D,
-                                          const AttributeList &Attr) {
+                                          const AttributeList &AL) {
   if (!cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) {
-    S.Diag(Attr.getLoc(), diag::err_objc_attr_protocol_requires_definition)
-      << Attr.getName() << Attr.getRange();
+    S.Diag(AL.getLoc(), diag::err_objc_attr_protocol_requires_definition)
+      << AL.getName() << AL.getRange();
     return;
   }
 
   D->addAttr(::new (S.Context)
-          ObjCExplicitProtocolImplAttr(Attr.getRange(), S.Context,
-                                       Attr.getAttributeSpellingListIndex()));
+          ObjCExplicitProtocolImplAttr(AL.getRange(), S.Context,
+                                       AL.getAttributeSpellingListIndex()));
 }
 
 static bool checkAvailabilityAttr(Sema &S, SourceRange Range,
@@ -2302,7 +2285,7 @@ AvailabilityAttr *Sema::mergeAvailabilit
   if (D->hasAttrs()) {
     AttrVec &Attrs = D->getAttrs();
     for (unsigned i = 0, e = Attrs.size(); i != e;) {
-      const AvailabilityAttr *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
+      const auto *OldAA = dyn_cast<AvailabilityAttr>(Attrs[i]);
       if (!OldAA) {
         ++i;
         continue;
@@ -2435,36 +2418,34 @@ AvailabilityAttr *Sema::mergeAvailabilit
 }
 
 static void handleAvailabilityAttr(Sema &S, Decl *D,
-                                   const AttributeList &Attr) {
-  if (!checkAttributeNumArgs(S, Attr, 1))
+                                   const AttributeList &AL) {
+  if (!checkAttributeNumArgs(S, AL, 1))
     return;
-  IdentifierLoc *Platform = Attr.getArgAsIdent(0);
-  unsigned Index = Attr.getAttributeSpellingListIndex();
+  IdentifierLoc *Platform = AL.getArgAsIdent(0);
+  unsigned Index = AL.getAttributeSpellingListIndex();
   
   IdentifierInfo *II = Platform->Ident;
   if (AvailabilityAttr::getPrettyPlatformName(II->getName()).empty())
     S.Diag(Platform->Loc, diag::warn_availability_unknown_platform)
       << Platform->Ident;
 
-  NamedDecl *ND = dyn_cast<NamedDecl>(D);
+  auto *ND = dyn_cast<NamedDecl>(D);
   if (!ND) // We warned about this already, so just return.
     return;
 
-  AvailabilityChange Introduced = Attr.getAvailabilityIntroduced();
-  AvailabilityChange Deprecated = Attr.getAvailabilityDeprecated();
-  AvailabilityChange Obsoleted = Attr.getAvailabilityObsoleted();
-  bool IsUnavailable = Attr.getUnavailableLoc().isValid();
-  bool IsStrict = Attr.getStrictLoc().isValid();
+  AvailabilityChange Introduced = AL.getAvailabilityIntroduced();
+  AvailabilityChange Deprecated = AL.getAvailabilityDeprecated();
+  AvailabilityChange Obsoleted = AL.getAvailabilityObsoleted();
+  bool IsUnavailable = AL.getUnavailableLoc().isValid();
+  bool IsStrict = AL.getStrictLoc().isValid();
   StringRef Str;
-  if (const StringLiteral *SE =
-          dyn_cast_or_null<StringLiteral>(Attr.getMessageExpr()))
+  if (const auto *SE = dyn_cast_or_null<StringLiteral>(AL.getMessageExpr()))
     Str = SE->getString();
   StringRef Replacement;
-  if (const StringLiteral *SE =
-          dyn_cast_or_null<StringLiteral>(Attr.getReplacementExpr()))
+  if (const auto *SE = dyn_cast_or_null<StringLiteral>(AL.getReplacementExpr()))
     Replacement = SE->getString();
 
-  AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND, Attr.getRange(), II,
+  AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND, AL.getRange(), II,
                                                       false/*Implicit*/,
                                                       Introduced.Version,
                                                       Deprecated.Version,
@@ -2509,7 +2490,7 @@ static void handleAvailabilityAttr(Sema
         auto NewObsoleted = adjustWatchOSVersion(Obsoleted.Version);
 
         AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND,
-                                                            Attr.getRange(),
+                                                            AL.getRange(),
                                                             NewII,
                                                             true/*Implicit*/,
                                                             NewIntroduced,
@@ -2534,7 +2515,7 @@ static void handleAvailabilityAttr(Sema
 
     if (NewII) {
         AvailabilityAttr *NewAttr = S.mergeAvailabilityAttr(ND,
-                                                            Attr.getRange(),
+                                                            AL.getRange(),
                                                             NewII,
                                                             true/*Implicit*/,
                                                             Introduced.Version,
@@ -2552,23 +2533,23 @@ static void handleAvailabilityAttr(Sema
 }
 
 static void handleExternalSourceSymbolAttr(Sema &S, Decl *D,
-                                           const AttributeList &Attr) {
-  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+                                           const AttributeList &AL) {
+  if (!checkAttributeAtLeastNumArgs(S, AL, 1))
     return;
-  assert(checkAttributeAtMostNumArgs(S, Attr, 3) &&
+  assert(checkAttributeAtMostNumArgs(S, AL, 3) &&
          "Invalid number of arguments in an external_source_symbol attribute");
 
   StringRef Language;
-  if (const auto *SE = dyn_cast_or_null<StringLiteral>(Attr.getArgAsExpr(0)))
+  if (const auto *SE = dyn_cast_or_null<StringLiteral>(AL.getArgAsExpr(0)))
     Language = SE->getString();
   StringRef DefinedIn;
-  if (const auto *SE = dyn_cast_or_null<StringLiteral>(Attr.getArgAsExpr(1)))
+  if (const auto *SE = dyn_cast_or_null<StringLiteral>(AL.getArgAsExpr(1)))
     DefinedIn = SE->getString();
-  bool IsGeneratedDeclaration = Attr.getArgAsIdent(2) != nullptr;
+  bool IsGeneratedDeclaration = AL.getArgAsIdent(2) != nullptr;
 
   D->addAttr(::new (S.Context) ExternalSourceSymbolAttr(
-      Attr.getRange(), S.Context, Language, DefinedIn, IsGeneratedDeclaration,
-      Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, Language, DefinedIn, IsGeneratedDeclaration,
+      AL.getAttributeSpellingListIndex()));
 }
 
 template <class T>
@@ -2601,12 +2582,12 @@ TypeVisibilityAttr *Sema::mergeTypeVisib
                                                    AttrSpellingListIndex);
 }
 
-static void handleVisibilityAttr(Sema &S, Decl *D, const AttributeList &Attr,
+static void handleVisibilityAttr(Sema &S, Decl *D, const AttributeList &AL,
                                  bool isTypeVisibility) {
   // Visibility attributes don't mean anything on a typedef.
   if (isa<TypedefNameDecl>(D)) {
-    S.Diag(Attr.getRange().getBegin(), diag::warn_attribute_ignored)
-      << Attr.getName();
+    S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored)
+      << AL.getName();
     return;
   }
 
@@ -2615,21 +2596,21 @@ static void handleVisibilityAttr(Sema &S
       !(isa<TagDecl>(D) ||
         isa<ObjCInterfaceDecl>(D) ||
         isa<NamespaceDecl>(D))) {
-    S.Diag(Attr.getRange().getBegin(), diag::err_attribute_wrong_decl_type)
-      << Attr.getName() << ExpectedTypeOrNamespace;
+    S.Diag(AL.getRange().getBegin(), diag::err_attribute_wrong_decl_type)
+      << AL.getName() << ExpectedTypeOrNamespace;
     return;
   }
 
   // Check that the argument is a string literal.
   StringRef TypeStr;
   SourceLocation LiteralLoc;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, TypeStr, &LiteralLoc))
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, TypeStr, &LiteralLoc))
     return;
 
   VisibilityAttr::VisibilityType type;
   if (!VisibilityAttr::ConvertStrToVisibilityType(TypeStr, type)) {
     S.Diag(LiteralLoc, diag::warn_attribute_type_not_supported)
-      << Attr.getName() << TypeStr;
+      << AL.getName() << TypeStr;
     return;
   }
   
@@ -2637,62 +2618,61 @@ static void handleVisibilityAttr(Sema &S
   // (like Darwin) that don't support it.
   if (type == VisibilityAttr::Protected &&
       !S.Context.getTargetInfo().hasProtectedVisibility()) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_protected_visibility);
+    S.Diag(AL.getLoc(), diag::warn_attribute_protected_visibility);
     type = VisibilityAttr::Default;
   }
 
-  unsigned Index = Attr.getAttributeSpellingListIndex();
-  clang::Attr *newAttr;
+  unsigned Index = AL.getAttributeSpellingListIndex();
+  Attr *newAttr;
   if (isTypeVisibility) {
-    newAttr = S.mergeTypeVisibilityAttr(D, Attr.getRange(),
+    newAttr = S.mergeTypeVisibilityAttr(D, AL.getRange(),
                                     (TypeVisibilityAttr::VisibilityType) type,
                                         Index);
   } else {
-    newAttr = S.mergeVisibilityAttr(D, Attr.getRange(), type, Index);
+    newAttr = S.mergeVisibilityAttr(D, AL.getRange(), type, Index);
   }
   if (newAttr)
     D->addAttr(newAttr);
 }
 
-static void handleObjCMethodFamilyAttr(Sema &S, Decl *decl,
-                                       const AttributeList &Attr) {
-  ObjCMethodDecl *method = cast<ObjCMethodDecl>(decl);
-  if (!Attr.isArgIdent(0)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-      << Attr.getName() << 1 << AANT_ArgumentIdentifier;
+static void handleObjCMethodFamilyAttr(Sema &S, Decl *D,
+                                       const AttributeList &AL) {
+  const auto *M = cast<ObjCMethodDecl>(D);
+  if (!AL.isArgIdent(0)) {
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
+        << AL.getName() << 1 << AANT_ArgumentIdentifier;
     return;
   }
 
-  IdentifierLoc *IL = Attr.getArgAsIdent(0);
+  IdentifierLoc *IL = AL.getArgAsIdent(0);
   ObjCMethodFamilyAttr::FamilyKind F;
   if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(IL->Ident->getName(), F)) {
-    S.Diag(IL->Loc, diag::warn_attribute_type_not_supported) << Attr.getName()
-      << IL->Ident;
+    S.Diag(IL->Loc, diag::warn_attribute_type_not_supported)
+        << AL.getName() << IL->Ident;
     return;
   }
 
   if (F == ObjCMethodFamilyAttr::OMF_init &&
-      !method->getReturnType()->isObjCObjectPointerType()) {
-    S.Diag(method->getLocation(), diag::err_init_method_bad_return_type)
-        << method->getReturnType();
+      !M->getReturnType()->isObjCObjectPointerType()) {
+    S.Diag(M->getLocation(), diag::err_init_method_bad_return_type)
+        << M->getReturnType();
     // Ignore the attribute.
     return;
   }
 
-  method->addAttr(new (S.Context) ObjCMethodFamilyAttr(Attr.getRange(),
-                                                       S.Context, F,
-                                        Attr.getAttributeSpellingListIndex()));
+  D->addAttr(new (S.Context) ObjCMethodFamilyAttr(
+      AL.getRange(), S.Context, F, AL.getAttributeSpellingListIndex()));
 }
 
-static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) {
+static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &AL) {
+  if (const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
     QualType T = TD->getUnderlyingType();
     if (!T->isCARCBridgableType()) {
       S.Diag(TD->getLocation(), diag::err_nsobject_attribute);
       return;
     }
   }
-  else if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D)) {
+  else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(D)) {
     QualType T = PD->getType();
     if (!T->isCARCBridgableType()) {
       S.Diag(PD->getLocation(), diag::err_nsobject_attribute);
@@ -2709,12 +2689,12 @@ static void handleObjCNSObject(Sema &S,
     S.Diag(D->getLocation(), diag::warn_nsobject_attribute);
   }
   D->addAttr(::new (S.Context)
-             ObjCNSObjectAttr(Attr.getRange(), S.Context,
-                              Attr.getAttributeSpellingListIndex()));
+             ObjCNSObjectAttr(AL.getRange(), S.Context,
+                              AL.getAttributeSpellingListIndex()));
 }
 
-static void handleObjCIndependentClass(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) {
+static void handleObjCIndependentClass(Sema &S, Decl *D, const AttributeList &AL) {
+  if (const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
     QualType T = TD->getUnderlyingType();
     if (!T->isObjCObjectPointerType()) {
       S.Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);
@@ -2725,45 +2705,45 @@ static void handleObjCIndependentClass(S
     return;
   }
   D->addAttr(::new (S.Context)
-             ObjCIndependentClassAttr(Attr.getRange(), S.Context,
-                              Attr.getAttributeSpellingListIndex()));
+             ObjCIndependentClassAttr(AL.getRange(), S.Context,
+                              AL.getAttributeSpellingListIndex()));
 }
 
-static void handleBlocksAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (!Attr.isArgIdent(0)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-      << Attr.getName() << 1 << AANT_ArgumentIdentifier;
+static void handleBlocksAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (!AL.isArgIdent(0)) {
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
+      << AL.getName() << 1 << AANT_ArgumentIdentifier;
     return;
   }
 
-  IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
+  IdentifierInfo *II = AL.getArgAsIdent(0)->Ident;
   BlocksAttr::BlockType type;
   if (!BlocksAttr::ConvertStrToBlockType(II->getName(), type)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
-      << Attr.getName() << II;
+    S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+      << AL.getName() << II;
     return;
   }
 
   D->addAttr(::new (S.Context)
-             BlocksAttr(Attr.getRange(), S.Context, type,
-                        Attr.getAttributeSpellingListIndex()));
+             BlocksAttr(AL.getRange(), S.Context, type,
+                        AL.getAttributeSpellingListIndex()));
 }
 
-static void handleSentinelAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleSentinelAttr(Sema &S, Decl *D, const AttributeList &AL) {
   unsigned sentinel = (unsigned)SentinelAttr::DefaultSentinel;
-  if (Attr.getNumArgs() > 0) {
-    Expr *E = Attr.getArgAsExpr(0);
+  if (AL.getNumArgs() > 0) {
+    Expr *E = AL.getArgAsExpr(0);
     llvm::APSInt Idx(32);
     if (E->isTypeDependent() || E->isValueDependent() ||
         !E->isIntegerConstantExpr(Idx, S.Context)) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-        << Attr.getName() << 1 << AANT_ArgumentIntegerConstant
+      S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
+        << AL.getName() << 1 << AANT_ArgumentIntegerConstant
         << E->getSourceRange();
       return;
     }
 
     if (Idx.isSigned() && Idx.isNegative()) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_sentinel_less_than_zero)
+      S.Diag(AL.getLoc(), diag::err_attribute_sentinel_less_than_zero)
         << E->getSourceRange();
       return;
     }
@@ -2772,13 +2752,13 @@ static void handleSentinelAttr(Sema &S,
   }
 
   unsigned nullPos = (unsigned)SentinelAttr::DefaultNullPos;
-  if (Attr.getNumArgs() > 1) {
-    Expr *E = Attr.getArgAsExpr(1);
+  if (AL.getNumArgs() > 1) {
+    Expr *E = AL.getArgAsExpr(1);
     llvm::APSInt Idx(32);
     if (E->isTypeDependent() || E->isValueDependent() ||
         !E->isIntegerConstantExpr(Idx, S.Context)) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-        << Attr.getName() << 2 << AANT_ArgumentIntegerConstant
+      S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
+        << AL.getName() << 2 << AANT_ArgumentIntegerConstant
         << E->getSourceRange();
       return;
     }
@@ -2787,34 +2767,34 @@ static void handleSentinelAttr(Sema &S,
     if ((Idx.isSigned() && Idx.isNegative()) || nullPos > 1) {
       // FIXME: This error message could be improved, it would be nice
       // to say what the bounds actually are.
-      S.Diag(Attr.getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
+      S.Diag(AL.getLoc(), diag::err_attribute_sentinel_not_zero_or_one)
         << E->getSourceRange();
       return;
     }
   }
 
-  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+  if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
     const FunctionType *FT = FD->getType()->castAs<FunctionType>();
     if (isa<FunctionNoProtoType>(FT)) {
-      S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_named_arguments);
+      S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_named_arguments);
       return;
     }
 
     if (!cast<FunctionProtoType>(FT)->isVariadic()) {
-      S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
+      S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
       return;
     }
-  } else if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
+  } else if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
     if (!MD->isVariadic()) {
-      S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
+      S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 0;
       return;
     }
-  } else if (BlockDecl *BD = dyn_cast<BlockDecl>(D)) {
+  } else if (const auto *BD = dyn_cast<BlockDecl>(D)) {
     if (!BD->isVariadic()) {
-      S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
+      S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << 1;
       return;
     }
-  } else if (const VarDecl *V = dyn_cast<VarDecl>(D)) {
+  } else if (const auto *V = dyn_cast<VarDecl>(D)) {
     QualType Ty = V->getType();
     if (Ty->isBlockPointerType() || Ty->isFunctionPointerType()) {
       const FunctionType *FT = Ty->isFunctionPointerType()
@@ -2822,84 +2802,84 @@ static void handleSentinelAttr(Sema &S,
        : Ty->getAs<BlockPointerType>()->getPointeeType()->getAs<FunctionType>();
       if (!cast<FunctionProtoType>(FT)->isVariadic()) {
         int m = Ty->isFunctionPointerType() ? 0 : 1;
-        S.Diag(Attr.getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
+        S.Diag(AL.getLoc(), diag::warn_attribute_sentinel_not_variadic) << m;
         return;
       }
     } else {
-      S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-        << Attr.getName() << ExpectedFunctionMethodOrBlock;
+      S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
+        << AL.getName() << ExpectedFunctionMethodOrBlock;
       return;
     }
   } else {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-      << Attr.getName() << ExpectedFunctionMethodOrBlock;
+    S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << AL.getName() << ExpectedFunctionMethodOrBlock;
     return;
   }
   D->addAttr(::new (S.Context)
-             SentinelAttr(Attr.getRange(), S.Context, sentinel, nullPos,
-                          Attr.getAttributeSpellingListIndex()));
+             SentinelAttr(AL.getRange(), S.Context, sentinel, nullPos,
+                          AL.getAttributeSpellingListIndex()));
 }
 
-static void handleWarnUnusedResult(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleWarnUnusedResult(Sema &S, Decl *D, const AttributeList &AL) {
   if (D->getFunctionType() &&
       D->getFunctionType()->getReturnType()->isVoidType()) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_void_function_method)
-      << Attr.getName() << 0;
+    S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method)
+      << AL.getName() << 0;
     return;
   }
-  if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
+  if (const auto *MD = dyn_cast<ObjCMethodDecl>(D))
     if (MD->getReturnType()->isVoidType()) {
-      S.Diag(Attr.getLoc(), diag::warn_attribute_void_function_method)
-      << Attr.getName() << 1;
+      S.Diag(AL.getLoc(), diag::warn_attribute_void_function_method)
+      << AL.getName() << 1;
       return;
     }
   
   // If this is spelled as the standard C++17 attribute, but not in C++17, warn
   // about using it as an extension.
-  if (!S.getLangOpts().CPlusPlus17 && Attr.isCXX11Attribute() &&
-      !Attr.getScopeName())
-    S.Diag(Attr.getLoc(), diag::ext_cxx17_attr) << Attr.getName();
+  if (!S.getLangOpts().CPlusPlus17 && AL.isCXX11Attribute() &&
+      !AL.getScopeName())
+    S.Diag(AL.getLoc(), diag::ext_cxx17_attr) << AL.getName();
 
   D->addAttr(::new (S.Context) 
-             WarnUnusedResultAttr(Attr.getRange(), S.Context,
-                                  Attr.getAttributeSpellingListIndex()));
+             WarnUnusedResultAttr(AL.getRange(), S.Context,
+                                  AL.getAttributeSpellingListIndex()));
 }
 
-static void handleWeakImportAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleWeakImportAttr(Sema &S, Decl *D, const AttributeList &AL) {
   // weak_import only applies to variable & function declarations.
   bool isDef = false;
   if (!D->canBeWeakImported(isDef)) {
     if (isDef)
-      S.Diag(Attr.getLoc(), diag::warn_attribute_invalid_on_definition)
+      S.Diag(AL.getLoc(), diag::warn_attribute_invalid_on_definition)
         << "weak_import";
     else if (isa<ObjCPropertyDecl>(D) || isa<ObjCMethodDecl>(D) ||
              (S.Context.getTargetInfo().getTriple().isOSDarwin() &&
               (isa<ObjCInterfaceDecl>(D) || isa<EnumDecl>(D)))) {
       // Nothing to warn about here.
     } else
-      S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-        << Attr.getName() << ExpectedVariableOrFunction;
+      S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
+        << AL.getName() << ExpectedVariableOrFunction;
 
     return;
   }
 
   D->addAttr(::new (S.Context)
-             WeakImportAttr(Attr.getRange(), S.Context,
-                            Attr.getAttributeSpellingListIndex()));
+             WeakImportAttr(AL.getRange(), S.Context,
+                            AL.getAttributeSpellingListIndex()));
 }
 
 // Handles reqd_work_group_size and work_group_size_hint.
 template <typename WorkGroupAttr>
 static void handleWorkGroupSize(Sema &S, Decl *D,
-                                const AttributeList &Attr) {
+                                const AttributeList &AL) {
   uint32_t WGSize[3];
   for (unsigned i = 0; i < 3; ++i) {
-    const Expr *E = Attr.getArgAsExpr(i);
-    if (!checkUInt32Argument(S, Attr, E, WGSize[i], i))
+    const Expr *E = AL.getArgAsExpr(i);
+    if (!checkUInt32Argument(S, AL, E, WGSize[i], i))
       return;
     if (WGSize[i] == 0) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_argument_is_zero)
-        << Attr.getName() << E->getSourceRange();
+      S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero)
+        << AL.getName() << E->getSourceRange();
       return;
     }
   }
@@ -2908,64 +2888,64 @@ static void handleWorkGroupSize(Sema &S,
   if (Existing && !(Existing->getXDim() == WGSize[0] &&
                     Existing->getYDim() == WGSize[1] &&
                     Existing->getZDim() == WGSize[2]))
-    S.Diag(Attr.getLoc(), diag::warn_duplicate_attribute) << Attr.getName();
+    S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL.getName();
 
-  D->addAttr(::new (S.Context) WorkGroupAttr(Attr.getRange(), S.Context,
+  D->addAttr(::new (S.Context) WorkGroupAttr(AL.getRange(), S.Context,
                                              WGSize[0], WGSize[1], WGSize[2],
-                                       Attr.getAttributeSpellingListIndex()));
+                                       AL.getAttributeSpellingListIndex()));
 }
 
 // Handles intel_reqd_sub_group_size.
-static void handleSubGroupSize(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleSubGroupSize(Sema &S, Decl *D, const AttributeList &AL) {
   uint32_t SGSize;
-  const Expr *E = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, E, SGSize))
+  const Expr *E = AL.getArgAsExpr(0);
+  if (!checkUInt32Argument(S, AL, E, SGSize))
     return;
   if (SGSize == 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_is_zero)
-        << Attr.getName() << E->getSourceRange();
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_is_zero)
+        << AL.getName() << E->getSourceRange();
     return;
   }
 
   OpenCLIntelReqdSubGroupSizeAttr *Existing =
       D->getAttr<OpenCLIntelReqdSubGroupSizeAttr>();
   if (Existing && Existing->getSubGroupSize() != SGSize)
-    S.Diag(Attr.getLoc(), diag::warn_duplicate_attribute) << Attr.getName();
+    S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL.getName();
 
   D->addAttr(::new (S.Context) OpenCLIntelReqdSubGroupSizeAttr(
-      Attr.getRange(), S.Context, SGSize,
-      Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, SGSize,
+      AL.getAttributeSpellingListIndex()));
 }
 
-static void handleVecTypeHint(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (!Attr.hasParsedType()) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
-      << Attr.getName() << 1;
+static void handleVecTypeHint(Sema &S, Decl *D, const AttributeList &AL) {
+  if (!AL.hasParsedType()) {
+    S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments)
+      << AL.getName() << 1;
     return;
   }
 
   TypeSourceInfo *ParmTSI = nullptr;
-  QualType ParmType = S.GetTypeFromParser(Attr.getTypeArg(), &ParmTSI);
+  QualType ParmType = S.GetTypeFromParser(AL.getTypeArg(), &ParmTSI);
   assert(ParmTSI && "no type source info for attribute argument");
 
   if (!ParmType->isExtVectorType() && !ParmType->isFloatingType() &&
       (ParmType->isBooleanType() ||
        !ParmType->isIntegralType(S.getASTContext()))) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_vec_type_hint)
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_vec_type_hint)
         << ParmType;
     return;
   }
 
   if (VecTypeHintAttr *A = D->getAttr<VecTypeHintAttr>()) {
     if (!S.Context.hasSameType(A->getTypeHint(), ParmType)) {
-      S.Diag(Attr.getLoc(), diag::warn_duplicate_attribute) << Attr.getName();
+      S.Diag(AL.getLoc(), diag::warn_duplicate_attribute) << AL.getName();
       return;
     }
   }
 
-  D->addAttr(::new (S.Context) VecTypeHintAttr(Attr.getLoc(), S.Context,
+  D->addAttr(::new (S.Context) VecTypeHintAttr(AL.getLoc(), S.Context,
                                                ParmTSI,
-                                        Attr.getAttributeSpellingListIndex()));
+                                        AL.getAttributeSpellingListIndex()));
 }
 
 SectionAttr *Sema::mergeSectionAttr(Decl *D, SourceRange Range,
@@ -2991,12 +2971,12 @@ bool Sema::checkSectionName(SourceLocati
   return true;
 }
 
-static void handleSectionAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleSectionAttr(Sema &S, Decl *D, const AttributeList &AL) {
   // Make sure that there is a string literal as the sections's single
   // argument.
   StringRef Str;
   SourceLocation LiteralLoc;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, &LiteralLoc))
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc))
     return;
 
   if (!S.checkSectionName(LiteralLoc, Str))
@@ -3010,8 +2990,8 @@ static void handleSectionAttr(Sema &S, D
     return;
   }
 
-  unsigned Index = Attr.getAttributeSpellingListIndex();
-  SectionAttr *NewAttr = S.mergeSectionAttr(D, Attr.getRange(), Str, Index);
+  unsigned Index = AL.getAttributeSpellingListIndex();
+  SectionAttr *NewAttr = S.mergeSectionAttr(D, AL.getRange(), Str, Index);
   if (NewAttr)
     D->addAttr(NewAttr);
 }
@@ -3047,27 +3027,27 @@ bool Sema::checkTargetAttr(SourceLocatio
   return true;
 }
 
-static void handleTargetAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleTargetAttr(Sema &S, Decl *D, const AttributeList &AL) {
   StringRef Str;
   SourceLocation LiteralLoc;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, &LiteralLoc) ||
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &LiteralLoc) ||
       !S.checkTargetAttr(LiteralLoc, Str))
     return;
-  unsigned Index = Attr.getAttributeSpellingListIndex();
+  unsigned Index = AL.getAttributeSpellingListIndex();
   TargetAttr *NewAttr =
-      ::new (S.Context) TargetAttr(Attr.getRange(), S.Context, Str, Index);
+      ::new (S.Context) TargetAttr(AL.getRange(), S.Context, Str, Index);
   D->addAttr(NewAttr);
 }
 
-static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  Expr *E = Attr.getArgAsExpr(0);
+static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  Expr *E = AL.getArgAsExpr(0);
   SourceLocation Loc = E->getExprLoc();
   FunctionDecl *FD = nullptr;
   DeclarationNameInfo NI;
 
   // gcc only allows for simple identifiers. Since we support more than gcc, we
   // will warn the user.
-  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
+  if (auto *DRE = dyn_cast<DeclRefExpr>(E)) {
     if (DRE->hasQualifier())
       S.Diag(Loc, diag::warn_cleanup_ext);
     FD = dyn_cast<FunctionDecl>(DRE->getDecl());
@@ -3077,7 +3057,7 @@ static void handleCleanupAttr(Sema &S, D
         << NI.getName();
       return;
     }
-  } else if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
+  } else if (auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
     if (ULE->hasExplicitTemplateArgs())
       S.Diag(Loc, diag::warn_cleanup_ext);
     FD = S.ResolveSingleFunctionTemplateSpecialization(ULE, true);
@@ -3112,38 +3092,38 @@ static void handleCleanupAttr(Sema &S, D
   }
 
   D->addAttr(::new (S.Context)
-             CleanupAttr(Attr.getRange(), S.Context, FD,
-                         Attr.getAttributeSpellingListIndex()));
+             CleanupAttr(AL.getRange(), S.Context, FD,
+                         AL.getAttributeSpellingListIndex()));
 }
 
 static void handleEnumExtensibilityAttr(Sema &S, Decl *D,
-                                        const AttributeList &Attr) {
-  if (!Attr.isArgIdent(0)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-        << Attr.getName() << 0 << AANT_ArgumentIdentifier;
+                                        const AttributeList &AL) {
+  if (!AL.isArgIdent(0)) {
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
+        << AL.getName() << 0 << AANT_ArgumentIdentifier;
     return;
   }
 
   EnumExtensibilityAttr::Kind ExtensibilityKind;
-  IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
+  IdentifierInfo *II = AL.getArgAsIdent(0)->Ident;
   if (!EnumExtensibilityAttr::ConvertStrToKind(II->getName(),
                                                ExtensibilityKind)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
-        << Attr.getName() << II;
+    S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+        << AL.getName() << II;
     return;
   }
 
   D->addAttr(::new (S.Context) EnumExtensibilityAttr(
-      Attr.getRange(), S.Context, ExtensibilityKind,
-      Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, ExtensibilityKind,
+      AL.getAttributeSpellingListIndex()));
 }
 
 /// Handle __attribute__((format_arg((idx)))) attribute based on
 /// http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
-static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  Expr *IdxExpr = Attr.getArgAsExpr(0);
+static void handleFormatArgAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  Expr *IdxExpr = AL.getArgAsExpr(0);
   uint64_t Idx;
-  if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, IdxExpr, Idx))
+  if (!checkFunctionOrMethodParameterIndex(S, D, AL, 1, IdxExpr, Idx))
     return;
 
   // Make sure the format string is really a string.
@@ -3154,7 +3134,7 @@ static void handleFormatArgAttr(Sema &S,
       !isCFStringType(Ty, S.Context) &&
       (!Ty->isPointerType() ||
        !Ty->getAs<PointerType>()->getPointeeType()->isCharType())) {
-    S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
+    S.Diag(AL.getLoc(), diag::err_format_attribute_not)
         << "a string type" << IdxExpr->getSourceRange()
         << getFunctionOrMethodParamRange(D, 0);
     return;
@@ -3164,7 +3144,7 @@ static void handleFormatArgAttr(Sema &S,
       !isCFStringType(Ty, S.Context) &&
       (!Ty->isPointerType() ||
        !Ty->getAs<PointerType>()->getPointeeType()->isCharType())) {
-    S.Diag(Attr.getLoc(), diag::err_format_attribute_result_not)
+    S.Diag(AL.getLoc(), diag::err_format_attribute_result_not)
         << (NotNSStringTy ? "string type" : "NSString")
         << IdxExpr->getSourceRange() << getFunctionOrMethodParamRange(D, 0);
     return;
@@ -3177,8 +3157,8 @@ static void handleFormatArgAttr(Sema &S,
   IdxExpr->EvaluateAsInt(Val, S.Context);
 
   D->addAttr(::new (S.Context)
-             FormatArgAttr(Attr.getRange(), S.Context, Val.getZExtValue(),
-                           Attr.getAttributeSpellingListIndex()));
+             FormatArgAttr(AL.getRange(), S.Context, Val.getZExtValue(),
+                           AL.getAttributeSpellingListIndex()));
 }
 
 enum FormatAttrKind {
@@ -3214,42 +3194,42 @@ static FormatAttrKind getFormatAttrKind(
 /// Handle __attribute__((init_priority(priority))) attributes based on
 /// http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html
 static void handleInitPriorityAttr(Sema &S, Decl *D,
-                                   const AttributeList &Attr) {
+                                   const AttributeList &AL) {
   if (!S.getLangOpts().CPlusPlus) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
+    S.Diag(AL.getLoc(), diag::warn_attribute_ignored) << AL.getName();
     return;
   }
   
   if (S.getCurFunctionOrMethodDecl()) {
-    S.Diag(Attr.getLoc(), diag::err_init_priority_object_attr);
-    Attr.setInvalid();
+    S.Diag(AL.getLoc(), diag::err_init_priority_object_attr);
+    AL.setInvalid();
     return;
   }
   QualType T = cast<VarDecl>(D)->getType();
   if (S.Context.getAsArrayType(T))
     T = S.Context.getBaseElementType(T);
   if (!T->getAs<RecordType>()) {
-    S.Diag(Attr.getLoc(), diag::err_init_priority_object_attr);
-    Attr.setInvalid();
+    S.Diag(AL.getLoc(), diag::err_init_priority_object_attr);
+    AL.setInvalid();
     return;
   }
 
-  Expr *E = Attr.getArgAsExpr(0);
+  Expr *E = AL.getArgAsExpr(0);
   uint32_t prioritynum;
-  if (!checkUInt32Argument(S, Attr, E, prioritynum)) {
-    Attr.setInvalid();
+  if (!checkUInt32Argument(S, AL, E, prioritynum)) {
+    AL.setInvalid();
     return;
   }
 
   if (prioritynum < 101 || prioritynum > 65535) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_outof_range)
-      << E->getSourceRange() << Attr.getName() << 101 << 65535;
-    Attr.setInvalid();
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_outof_range)
+      << E->getSourceRange() << AL.getName() << 101 << 65535;
+    AL.setInvalid();
     return;
   }
   D->addAttr(::new (S.Context)
-             InitPriorityAttr(Attr.getRange(), S.Context, prioritynum,
-                              Attr.getAttributeSpellingListIndex()));
+             InitPriorityAttr(AL.getRange(), S.Context, prioritynum,
+                              AL.getAttributeSpellingListIndex()));
 }
 
 FormatAttr *Sema::mergeFormatAttr(Decl *D, SourceRange Range,
@@ -3275,10 +3255,10 @@ FormatAttr *Sema::mergeFormatAttr(Decl *
 
 /// Handle __attribute__((format(type,idx,firstarg))) attributes based on
 /// http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
-static void handleFormatAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (!Attr.isArgIdent(0)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-      << Attr.getName() << 1 << AANT_ArgumentIdentifier;
+static void handleFormatAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (!AL.isArgIdent(0)) {
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
+      << AL.getName() << 1 << AANT_ArgumentIdentifier;
     return;
   }
 
@@ -3287,7 +3267,7 @@ static void handleFormatAttr(Sema &S, De
   bool HasImplicitThisParam = isInstanceMethod(D);
   unsigned NumArgs = getFunctionOrMethodNumParams(D) + HasImplicitThisParam;
 
-  IdentifierInfo *II = Attr.getArgAsIdent(0)->Ident;
+  IdentifierInfo *II = AL.getArgAsIdent(0)->Ident;
   StringRef Format = II->getName();
 
   if (normalizeName(Format)) {
@@ -3302,20 +3282,20 @@ static void handleFormatAttr(Sema &S, De
     return;
   
   if (Kind == InvalidFormat) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
-      << Attr.getName() << II->getName();
+    S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+      << AL.getName() << II->getName();
     return;
   }
 
   // checks for the 2nd argument
-  Expr *IdxExpr = Attr.getArgAsExpr(1);
+  Expr *IdxExpr = AL.getArgAsExpr(1);
   uint32_t Idx;
-  if (!checkUInt32Argument(S, Attr, IdxExpr, Idx, 2))
+  if (!checkUInt32Argument(S, AL, IdxExpr, Idx, 2))
     return;
 
   if (Idx < 1 || Idx > NumArgs) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
-      << Attr.getName() << 2 << IdxExpr->getSourceRange();
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds)
+      << AL.getName() << 2 << IdxExpr->getSourceRange();
     return;
   }
 
@@ -3324,7 +3304,7 @@ static void handleFormatAttr(Sema &S, De
 
   if (HasImplicitThisParam) {
     if (ArgIdx == 0) {
-      S.Diag(Attr.getLoc(),
+      S.Diag(AL.getLoc(),
              diag::err_format_attribute_implicit_this_format_string)
         << IdxExpr->getSourceRange();
       return;
@@ -3337,7 +3317,7 @@ static void handleFormatAttr(Sema &S, De
 
   if (Kind == CFStringFormat) {
     if (!isCFStringType(Ty, S.Context)) {
-      S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
+      S.Diag(AL.getLoc(), diag::err_format_attribute_not)
         << "a CFString" << IdxExpr->getSourceRange()
         << getFunctionOrMethodParamRange(D, ArgIdx);
       return;
@@ -3346,23 +3326,23 @@ static void handleFormatAttr(Sema &S, De
     // FIXME: do we need to check if the type is NSString*?  What are the
     // semantics?
     if (!isNSStringType(Ty, S.Context)) {
-      S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
+      S.Diag(AL.getLoc(), diag::err_format_attribute_not)
         << "an NSString" << IdxExpr->getSourceRange()
         << getFunctionOrMethodParamRange(D, ArgIdx);
       return;
     }
   } else if (!Ty->isPointerType() ||
              !Ty->getAs<PointerType>()->getPointeeType()->isCharType()) {
-    S.Diag(Attr.getLoc(), diag::err_format_attribute_not)
+    S.Diag(AL.getLoc(), diag::err_format_attribute_not)
       << "a string type" << IdxExpr->getSourceRange()
       << getFunctionOrMethodParamRange(D, ArgIdx);
     return;
   }
 
   // check the 3rd argument
-  Expr *FirstArgExpr = Attr.getArgAsExpr(2);
+  Expr *FirstArgExpr = AL.getArgAsExpr(2);
   uint32_t FirstArg;
-  if (!checkUInt32Argument(S, Attr, FirstArgExpr, FirstArg, 3))
+  if (!checkUInt32Argument(S, AL, FirstArgExpr, FirstArg, 3))
     return;
 
   // check if the function is variadic if the 3rd argument non-zero
@@ -3379,43 +3359,43 @@ static void handleFormatAttr(Sema &S, De
   // variable the input is just the current time + the format string.
   if (Kind == StrftimeFormat) {
     if (FirstArg != 0) {
-      S.Diag(Attr.getLoc(), diag::err_format_strftime_third_parameter)
+      S.Diag(AL.getLoc(), diag::err_format_strftime_third_parameter)
         << FirstArgExpr->getSourceRange();
       return;
     }
   // if 0 it disables parameter checking (to use with e.g. va_list)
   } else if (FirstArg != 0 && FirstArg != NumArgs) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
-      << Attr.getName() << 3 << FirstArgExpr->getSourceRange();
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds)
+      << AL.getName() << 3 << FirstArgExpr->getSourceRange();
     return;
   }
 
-  FormatAttr *NewAttr = S.mergeFormatAttr(D, Attr.getRange(), II,
+  FormatAttr *NewAttr = S.mergeFormatAttr(D, AL.getRange(), II,
                                           Idx, FirstArg,
-                                          Attr.getAttributeSpellingListIndex());
+                                          AL.getAttributeSpellingListIndex());
   if (NewAttr)
     D->addAttr(NewAttr);
 }
 
 static void handleTransparentUnionAttr(Sema &S, Decl *D,
-                                       const AttributeList &Attr) {
+                                       const AttributeList &AL) {
   // Try to find the underlying union declaration.
   RecordDecl *RD = nullptr;
-  TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D);
+  const auto *TD = dyn_cast<TypedefNameDecl>(D);
   if (TD && TD->getUnderlyingType()->isUnionType())
     RD = TD->getUnderlyingType()->getAsUnionType()->getDecl();
   else
     RD = dyn_cast<RecordDecl>(D);
 
   if (!RD || !RD->isUnion()) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-      << Attr.getName() << ExpectedUnion;
+    S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << AL.getName() << ExpectedUnion;
     return;
   }
 
   if (!RD->isCompleteDefinition()) {
     if (!RD->isBeingDefined())
-      S.Diag(Attr.getLoc(),
+      S.Diag(AL.getLoc(),
              diag::warn_transparent_union_attribute_not_definition);
     return;
   }
@@ -3423,7 +3403,7 @@ static void handleTransparentUnionAttr(S
   RecordDecl::field_iterator Field = RD->field_begin(),
                           FieldEnd = RD->field_end();
   if (Field == FieldEnd) {
-    S.Diag(Attr.getLoc(), diag::warn_transparent_union_attribute_zero_fields);
+    S.Diag(AL.getLoc(), diag::warn_transparent_union_attribute_zero_fields);
     return;
   }
 
@@ -3467,15 +3447,15 @@ static void handleTransparentUnionAttr(S
   }
 
   RD->addAttr(::new (S.Context)
-              TransparentUnionAttr(Attr.getRange(), S.Context,
-                                   Attr.getAttributeSpellingListIndex()));
+              TransparentUnionAttr(AL.getRange(), S.Context,
+                                   AL.getAttributeSpellingListIndex()));
 }
 
-static void handleAnnotateAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleAnnotateAttr(Sema &S, Decl *D, const AttributeList &AL) {
   // Make sure that there is a string literal as the annotation's single
   // argument.
   StringRef Str;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str))
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, Str))
     return;
 
   // Don't duplicate annotations that are already set.
@@ -3485,14 +3465,14 @@ static void handleAnnotateAttr(Sema &S,
   }
   
   D->addAttr(::new (S.Context)
-             AnnotateAttr(Attr.getRange(), S.Context, Str,
-                          Attr.getAttributeSpellingListIndex()));
+             AnnotateAttr(AL.getRange(), S.Context, Str,
+                          AL.getAttributeSpellingListIndex()));
 }
 
 static void handleAlignValueAttr(Sema &S, Decl *D,
-                                 const AttributeList &Attr) {
-  S.AddAlignValueAttr(Attr.getRange(), D, Attr.getArgAsExpr(0),
-                      Attr.getAttributeSpellingListIndex());
+                                 const AttributeList &AL) {
+  S.AddAlignValueAttr(AL.getRange(), D, AL.getArgAsExpr(0),
+                      AL.getAttributeSpellingListIndex());
 }
 
 void Sema::AddAlignValueAttr(SourceRange AttrRange, Decl *D, Expr *E,
@@ -3501,9 +3481,9 @@ void Sema::AddAlignValueAttr(SourceRange
   SourceLocation AttrLoc = AttrRange.getBegin();
 
   QualType T;
-  if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D))
+  if (const auto *TD = dyn_cast<TypedefNameDecl>(D))
     T = TD->getUnderlyingType();
-  else if (ValueDecl *VD = dyn_cast<ValueDecl>(D))
+  else if (const auto *VD = dyn_cast<ValueDecl>(D))
     T = VD->getType();
   else
     llvm_unreachable("Unknown decl type for align_value");
@@ -3540,42 +3520,42 @@ void Sema::AddAlignValueAttr(SourceRange
   D->addAttr(::new (Context) AlignValueAttr(TmpAttr));
 }
 
-static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleAlignedAttr(Sema &S, Decl *D, const AttributeList &AL) {
   // check the attribute arguments.
-  if (Attr.getNumArgs() > 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
-      << Attr.getName() << 1;
+  if (AL.getNumArgs() > 1) {
+    S.Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments)
+      << AL.getName() << 1;
     return;
   }
 
-  if (Attr.getNumArgs() == 0) {
-    D->addAttr(::new (S.Context) AlignedAttr(Attr.getRange(), S.Context,
-               true, nullptr, Attr.getAttributeSpellingListIndex()));
+  if (AL.getNumArgs() == 0) {
+    D->addAttr(::new (S.Context) AlignedAttr(AL.getRange(), S.Context,
+               true, nullptr, AL.getAttributeSpellingListIndex()));
     return;
   }
 
-  Expr *E = Attr.getArgAsExpr(0);
-  if (Attr.isPackExpansion() && !E->containsUnexpandedParameterPack()) {
-    S.Diag(Attr.getEllipsisLoc(),
+  Expr *E = AL.getArgAsExpr(0);
+  if (AL.isPackExpansion() && !E->containsUnexpandedParameterPack()) {
+    S.Diag(AL.getEllipsisLoc(),
            diag::err_pack_expansion_without_parameter_packs);
     return;
   }
 
-  if (!Attr.isPackExpansion() && S.DiagnoseUnexpandedParameterPack(E))
+  if (!AL.isPackExpansion() && S.DiagnoseUnexpandedParameterPack(E))
     return;
 
   if (E->isValueDependent()) {
     if (const auto *TND = dyn_cast<TypedefNameDecl>(D)) {
       if (!TND->getUnderlyingType()->isDependentType()) {
-        S.Diag(Attr.getLoc(), diag::err_alignment_dependent_typedef_name)
+        S.Diag(AL.getLoc(), diag::err_alignment_dependent_typedef_name)
             << E->getSourceRange();
         return;
       }
     }
   }
 
-  S.AddAlignedAttr(Attr.getRange(), D, E, Attr.getAttributeSpellingListIndex(),
-                   Attr.isPackExpansion());
+  S.AddAlignedAttr(AL.getRange(), D, E, AL.getAttributeSpellingListIndex(),
+                   AL.isPackExpansion());
 }
 
 void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, Expr *E,
@@ -3599,12 +3579,12 @@ void Sema::AddAlignedAttr(SourceRange At
     int DiagKind = -1;
     if (isa<ParmVarDecl>(D)) {
       DiagKind = 0;
-    } else if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
+    } else if (const auto *VD = dyn_cast<VarDecl>(D)) {
       if (VD->getStorageClass() == SC_Register)
         DiagKind = 1;
       if (VD->isExceptionVariable())
         DiagKind = 2;
-    } else if (FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
+    } else if (const auto *FD = dyn_cast<FieldDecl>(D)) {
       if (FD->isBitField())
         DiagKind = 3;
     } else if (!isa<TagDecl>(D)) {
@@ -3628,7 +3608,7 @@ void Sema::AddAlignedAttr(SourceRange At
     return;
   }
 
-  // FIXME: Cache the number on the Attr object?
+  // FIXME: Cache the number on the AL object?
   llvm::APSInt Alignment;
   ExprResult ICE
     = VerifyIntegerConstantExpression(E, &Alignment,
@@ -3666,7 +3646,7 @@ void Sema::AddAlignedAttr(SourceRange At
     unsigned MaxTLSAlign =
         Context.toCharUnitsFromBits(Context.getTargetInfo().getMaxTLSAlign())
             .getQuantity();
-    auto *VD = dyn_cast<VarDecl>(D);
+    const auto *VD = dyn_cast<VarDecl>(D);
     if (MaxTLSAlign && AlignVal > MaxTLSAlign && VD &&
         VD->getTLSKind() != VarDecl::TLS_None) {
       Diag(VD->getLocation(), diag::err_tls_var_aligned_over_maximum)
@@ -3683,7 +3663,7 @@ void Sema::AddAlignedAttr(SourceRange At
 
 void Sema::AddAlignedAttr(SourceRange AttrRange, Decl *D, TypeSourceInfo *TS,
                           unsigned SpellingListIndex, bool IsPackExpansion) {
-  // FIXME: Cache the number on the Attr object if non-dependent?
+  // FIXME: Cache the number on the AL object if non-dependent?
   // FIXME: Perform checking of type validity
   AlignedAttr *AA = ::new (Context) AlignedAttr(AttrRange, Context, false, TS,
                                                 SpellingListIndex);
@@ -3695,11 +3675,11 @@ void Sema::CheckAlignasUnderalignment(De
   assert(D->hasAttrs() && "no attributes on decl");
 
   QualType UnderlyingTy, DiagTy;
-  if (ValueDecl *VD = dyn_cast<ValueDecl>(D)) {
+  if (const auto *VD = dyn_cast<ValueDecl>(D)) {
     UnderlyingTy = DiagTy = VD->getType();
   } else {
     UnderlyingTy = DiagTy = Context.getTagDeclType(cast<TagDecl>(D));
-    if (EnumDecl *ED = dyn_cast<EnumDecl>(D))
+    if (const auto *ED = dyn_cast<EnumDecl>(D))
       UnderlyingTy = ED->getIntegerType();
   }
   if (DiagTy->isDependentType() || DiagTy->isIncompleteType())
@@ -3819,18 +3799,18 @@ static void parseModeAttrArg(Sema &S, St
 /// Despite what would be logical, the mode attribute is a decl attribute, not a
 /// type attribute: 'int ** __attribute((mode(HI))) *G;' tries to make 'G' be
 /// HImode, not an intermediate pointer.
-static void handleModeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleModeAttr(Sema &S, Decl *D, const AttributeList &AL) {
   // This attribute isn't documented, but glibc uses it.  It changes
   // the width of an int or unsigned int to the specified size.
-  if (!Attr.isArgIdent(0)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr.getName()
+  if (!AL.isArgIdent(0)) {
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_type) << AL.getName()
       << AANT_ArgumentIdentifier;
     return;
   }
 
-  IdentifierInfo *Name = Attr.getArgAsIdent(0)->Ident;
+  IdentifierInfo *Name = AL.getArgAsIdent(0)->Ident;
 
-  S.AddModeAttr(Attr.getRange(), D, Name, Attr.getAttributeSpellingListIndex());
+  S.AddModeAttr(AL.getRange(), D, Name, AL.getAttributeSpellingListIndex());
 }
 
 void Sema::AddModeAttr(SourceRange AttrRange, Decl *D, IdentifierInfo *Name,
@@ -3876,9 +3856,9 @@ void Sema::AddModeAttr(SourceRange AttrR
   }
 
   QualType OldTy;
-  if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D))
+  if (const auto *TD = dyn_cast<TypedefNameDecl>(D))
     OldTy = TD->getUnderlyingType();
-  else if (EnumDecl *ED = dyn_cast<EnumDecl>(D)) {
+  else if (const auto *ED = dyn_cast<EnumDecl>(D)) {
     // Something like 'typedef enum { X } __attribute__((mode(XX))) T;'.
     // Try to get type from enum declaration, default to int.
     OldTy = ED->getIntegerType();
@@ -3896,7 +3876,7 @@ void Sema::AddModeAttr(SourceRange AttrR
   // Base type can also be a vector type (see PR17453).
   // Distinguish between base type and base element type.
   QualType OldElemTy = OldTy;
-  if (const VectorType *VT = OldTy->getAs<VectorType>())
+  if (const auto *VT = OldTy->getAs<VectorType>())
     OldElemTy = VT->getElementType();
 
   // GCC allows 'mode' attribute on enumeration types (even incomplete), except
@@ -3945,7 +3925,7 @@ void Sema::AddModeAttr(SourceRange AttrR
   if (VectorSize.getBoolValue()) {
     NewTy = Context.getVectorType(NewTy, VectorSize.getZExtValue(),
                                   VectorType::GenericVector);
-  } else if (const VectorType *OldVT = OldTy->getAs<VectorType>()) {
+  } else if (const auto *OldVT = OldTy->getAs<VectorType>()) {
     // Complex machine mode does not support base vector types.
     if (ComplexMode) {
       Diag(AttrLoc, diag::err_complex_mode_vector_type);
@@ -3964,9 +3944,9 @@ void Sema::AddModeAttr(SourceRange AttrR
   }
 
   // Install the new type.
-  if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D))
+  if (auto *TD = dyn_cast<TypedefNameDecl>(D))
     TD->setModedTypeSourceInfo(TD->getTypeSourceInfo(), NewTy);
-  else if (EnumDecl *ED = dyn_cast<EnumDecl>(D))
+  else if (auto *ED = dyn_cast<EnumDecl>(D))
     ED->setIntegerType(NewTy);
   else
     cast<ValueDecl>(D)->setType(NewTy);
@@ -3975,10 +3955,10 @@ void Sema::AddModeAttr(SourceRange AttrR
              ModeAttr(AttrRange, Context, Name, SpellingListIndex));
 }
 
-static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleNoDebugAttr(Sema &S, Decl *D, const AttributeList &AL) {
   D->addAttr(::new (S.Context)
-             NoDebugAttr(Attr.getRange(), S.Context,
-                         Attr.getAttributeSpellingListIndex()));
+             NoDebugAttr(AL.getRange(), S.Context,
+                         AL.getAttributeSpellingListIndex()));
 }
 
 AlwaysInlineAttr *Sema::mergeAlwaysInlineAttr(Decl *D, SourceRange Range,
@@ -4010,7 +3990,7 @@ InternalLinkageAttr *
 Sema::mergeInternalLinkageAttr(Decl *D, SourceRange Range,
                                IdentifierInfo *Ident,
                                unsigned AttrSpellingListIndex) {
-  if (auto VD = dyn_cast<VarDecl>(D)) {
+  if (const auto *VD = dyn_cast<VarDecl>(D)) {
     // Attribute applies to Var but not any subclass of it (like ParmVar,
     // ImplicitParm or VarTemplateSpecialization).
     if (VD->getKind() != Decl::Var) {
@@ -4068,71 +4048,71 @@ OptimizeNoneAttr *Sema::mergeOptimizeNon
 }
 
 static void handleAlwaysInlineAttr(Sema &S, Decl *D,
-                                   const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<NotTailCalledAttr>(S, D, Attr.getRange(),
-                                                  Attr.getName()))
+                                   const AttributeList &AL) {
+  if (checkAttrMutualExclusion<NotTailCalledAttr>(S, D, AL.getRange(),
+                                                  AL.getName()))
     return;
 
   if (AlwaysInlineAttr *Inline = S.mergeAlwaysInlineAttr(
-          D, Attr.getRange(), Attr.getName(),
-          Attr.getAttributeSpellingListIndex()))
+          D, AL.getRange(), AL.getName(),
+          AL.getAttributeSpellingListIndex()))
     D->addAttr(Inline);
 }
 
-static void handleMinSizeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleMinSizeAttr(Sema &S, Decl *D, const AttributeList &AL) {
   if (MinSizeAttr *MinSize = S.mergeMinSizeAttr(
-          D, Attr.getRange(), Attr.getAttributeSpellingListIndex()))
+          D, AL.getRange(), AL.getAttributeSpellingListIndex()))
     D->addAttr(MinSize);
 }
 
 static void handleOptimizeNoneAttr(Sema &S, Decl *D,
-                                   const AttributeList &Attr) {
+                                   const AttributeList &AL) {
   if (OptimizeNoneAttr *Optnone = S.mergeOptimizeNoneAttr(
-          D, Attr.getRange(), Attr.getAttributeSpellingListIndex()))
+          D, AL.getRange(), AL.getAttributeSpellingListIndex()))
     D->addAttr(Optnone);
 }
 
-static void handleConstantAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<CUDASharedAttr>(S, D, Attr.getRange(),
-                                               Attr.getName()))
+static void handleConstantAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (checkAttrMutualExclusion<CUDASharedAttr>(S, D, AL.getRange(),
+                                               AL.getName()))
     return;
-  auto *VD = cast<VarDecl>(D);
+  const auto *VD = cast<VarDecl>(D);
   if (!VD->hasGlobalStorage()) {
-    S.Diag(Attr.getLoc(), diag::err_cuda_nonglobal_constant);
+    S.Diag(AL.getLoc(), diag::err_cuda_nonglobal_constant);
     return;
   }
   D->addAttr(::new (S.Context) CUDAConstantAttr(
-      Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
 }
 
-static void handleSharedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<CUDAConstantAttr>(S, D, Attr.getRange(),
-                                                 Attr.getName()))
+static void handleSharedAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (checkAttrMutualExclusion<CUDAConstantAttr>(S, D, AL.getRange(),
+                                                 AL.getName()))
     return;
-  auto *VD = cast<VarDecl>(D);
+  const auto *VD = cast<VarDecl>(D);
   // extern __shared__ is only allowed on arrays with no length (e.g.
   // "int x[]").
   if (!S.getLangOpts().CUDARelocatableDeviceCode && VD->hasExternalStorage() &&
       !isa<IncompleteArrayType>(VD->getType())) {
-    S.Diag(Attr.getLoc(), diag::err_cuda_extern_shared) << VD;
+    S.Diag(AL.getLoc(), diag::err_cuda_extern_shared) << VD;
     return;
   }
   if (S.getLangOpts().CUDA && VD->hasLocalStorage() &&
-      S.CUDADiagIfHostCode(Attr.getLoc(), diag::err_cuda_host_shared)
+      S.CUDADiagIfHostCode(AL.getLoc(), diag::err_cuda_host_shared)
           << S.CurrentCUDATarget())
     return;
   D->addAttr(::new (S.Context) CUDASharedAttr(
-      Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
 }
 
-static void handleGlobalAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<CUDADeviceAttr>(S, D, Attr.getRange(),
-                                               Attr.getName()) ||
-      checkAttrMutualExclusion<CUDAHostAttr>(S, D, Attr.getRange(),
-                                             Attr.getName())) {
+static void handleGlobalAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (checkAttrMutualExclusion<CUDADeviceAttr>(S, D, AL.getRange(),
+                                               AL.getName()) ||
+      checkAttrMutualExclusion<CUDAHostAttr>(S, D, AL.getRange(),
+                                             AL.getName())) {
     return;
   }
-  FunctionDecl *FD = cast<FunctionDecl>(D);
+  const auto *FD = cast<FunctionDecl>(D);
   if (!FD->getReturnType()->isVoidType()) {
     SourceRange RTRange = FD->getReturnTypeSourceRange();
     S.Diag(FD->getTypeSpecStartLoc(), diag::err_kern_type_not_void_return)
@@ -4154,86 +4134,86 @@ static void handleGlobalAttr(Sema &S, De
     S.Diag(FD->getLocStart(), diag::warn_kern_is_inline) << FD;
 
   D->addAttr(::new (S.Context)
-              CUDAGlobalAttr(Attr.getRange(), S.Context,
-                             Attr.getAttributeSpellingListIndex()));
+              CUDAGlobalAttr(AL.getRange(), S.Context,
+                             AL.getAttributeSpellingListIndex()));
 }
 
-static void handleGNUInlineAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  FunctionDecl *Fn = cast<FunctionDecl>(D);
+static void handleGNUInlineAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  const auto *Fn = cast<FunctionDecl>(D);
   if (!Fn->isInlineSpecified()) {
-    S.Diag(Attr.getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
+    S.Diag(AL.getLoc(), diag::warn_gnu_inline_attribute_requires_inline);
     return;
   }
 
   D->addAttr(::new (S.Context)
-             GNUInlineAttr(Attr.getRange(), S.Context,
-                           Attr.getAttributeSpellingListIndex()));
+             GNUInlineAttr(AL.getRange(), S.Context,
+                           AL.getAttributeSpellingListIndex()));
 }
 
-static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleCallConvAttr(Sema &S, Decl *D, const AttributeList &AL) {
   if (hasDeclarator(D)) return;
 
-  // Diagnostic is emitted elsewhere: here we store the (valid) Attr
+  // Diagnostic is emitted elsewhere: here we store the (valid) AL
   // in the Decl node for syntactic reasoning, e.g., pretty-printing.
   CallingConv CC;
-  if (S.CheckCallingConvAttr(Attr, CC, /*FD*/nullptr))
+  if (S.CheckCallingConvAttr(AL, CC, /*FD*/nullptr))
     return;
 
   if (!isa<ObjCMethodDecl>(D)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-      << Attr.getName() << ExpectedFunctionOrMethod;
+    S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << AL.getName() << ExpectedFunctionOrMethod;
     return;
   }
 
-  switch (Attr.getKind()) {
+  switch (AL.getKind()) {
   case AttributeList::AT_FastCall:
     D->addAttr(::new (S.Context)
-               FastCallAttr(Attr.getRange(), S.Context,
-                            Attr.getAttributeSpellingListIndex()));
+               FastCallAttr(AL.getRange(), S.Context,
+                            AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_StdCall:
     D->addAttr(::new (S.Context)
-               StdCallAttr(Attr.getRange(), S.Context,
-                           Attr.getAttributeSpellingListIndex()));
+               StdCallAttr(AL.getRange(), S.Context,
+                           AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_ThisCall:
     D->addAttr(::new (S.Context)
-               ThisCallAttr(Attr.getRange(), S.Context,
-                            Attr.getAttributeSpellingListIndex()));
+               ThisCallAttr(AL.getRange(), S.Context,
+                            AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_CDecl:
     D->addAttr(::new (S.Context)
-               CDeclAttr(Attr.getRange(), S.Context,
-                         Attr.getAttributeSpellingListIndex()));
+               CDeclAttr(AL.getRange(), S.Context,
+                         AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_Pascal:
     D->addAttr(::new (S.Context)
-               PascalAttr(Attr.getRange(), S.Context,
-                          Attr.getAttributeSpellingListIndex()));
+               PascalAttr(AL.getRange(), S.Context,
+                          AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_SwiftCall:
     D->addAttr(::new (S.Context)
-               SwiftCallAttr(Attr.getRange(), S.Context,
-                             Attr.getAttributeSpellingListIndex()));
+               SwiftCallAttr(AL.getRange(), S.Context,
+                             AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_VectorCall:
     D->addAttr(::new (S.Context)
-               VectorCallAttr(Attr.getRange(), S.Context,
-                              Attr.getAttributeSpellingListIndex()));
+               VectorCallAttr(AL.getRange(), S.Context,
+                              AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_MSABI:
     D->addAttr(::new (S.Context)
-               MSABIAttr(Attr.getRange(), S.Context,
-                         Attr.getAttributeSpellingListIndex()));
+               MSABIAttr(AL.getRange(), S.Context,
+                         AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_SysVABI:
     D->addAttr(::new (S.Context)
-               SysVABIAttr(Attr.getRange(), S.Context,
-                           Attr.getAttributeSpellingListIndex()));
+               SysVABIAttr(AL.getRange(), S.Context,
+                           AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_RegCall:
     D->addAttr(::new (S.Context) RegCallAttr(
-        Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+        AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_Pcs: {
     PcsAttr::PCSType PCS;
@@ -4249,37 +4229,37 @@ static void handleCallConvAttr(Sema &S,
     }
 
     D->addAttr(::new (S.Context)
-               PcsAttr(Attr.getRange(), S.Context, PCS,
-                       Attr.getAttributeSpellingListIndex()));
+               PcsAttr(AL.getRange(), S.Context, PCS,
+                       AL.getAttributeSpellingListIndex()));
     return;
   }
   case AttributeList::AT_IntelOclBicc:
     D->addAttr(::new (S.Context)
-               IntelOclBiccAttr(Attr.getRange(), S.Context,
-                                Attr.getAttributeSpellingListIndex()));
+               IntelOclBiccAttr(AL.getRange(), S.Context,
+                                AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_PreserveMost:
     D->addAttr(::new (S.Context) PreserveMostAttr(
-        Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+        AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
     return;
   case AttributeList::AT_PreserveAll:
     D->addAttr(::new (S.Context) PreserveAllAttr(
-        Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+        AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
     return;
   default:
     llvm_unreachable("unexpected attribute kind");
   }
 }
 
-static void handleSuppressAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+static void handleSuppressAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (!checkAttributeAtLeastNumArgs(S, AL, 1))
     return;
 
   std::vector<StringRef> DiagnosticIdentifiers;
-  for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) {
+  for (unsigned I = 0, E = AL.getNumArgs(); I != E; ++I) {
     StringRef RuleName;
 
-    if (!S.checkStringLiteralArgumentAttr(Attr, I, RuleName, nullptr))
+    if (!S.checkStringLiteralArgumentAttr(AL, I, RuleName, nullptr))
       return;
 
     // FIXME: Warn if the rule name is unknown. This is tricky because only
@@ -4287,8 +4267,8 @@ static void handleSuppressAttr(Sema &S,
     DiagnosticIdentifiers.push_back(RuleName);
   }
   D->addAttr(::new (S.Context) SuppressAttr(
-      Attr.getRange(), S.Context, DiagnosticIdentifiers.data(),
-      DiagnosticIdentifiers.size(), Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, DiagnosticIdentifiers.data(),
+      DiagnosticIdentifiers.size(), AL.getAttributeSpellingListIndex()));
 }
 
 bool Sema::CheckCallingConvAttr(const AttributeList &Attrs, CallingConv &CC, 
@@ -4370,36 +4350,36 @@ bool Sema::CheckCallingConvAttr(const At
 }
 
 /// Pointer-like types in the default address space.
-static bool isValidSwiftContextType(QualType type) {
-  if (!type->hasPointerRepresentation())
-    return type->isDependentType();
-  return type->getPointeeType().getAddressSpace() == LangAS::Default;
+static bool isValidSwiftContextType(QualType Ty) {
+  if (!Ty->hasPointerRepresentation())
+    return Ty->isDependentType();
+  return Ty->getPointeeType().getAddressSpace() == LangAS::Default;
 }
 
 /// Pointers and references in the default address space.
-static bool isValidSwiftIndirectResultType(QualType type) {
-  if (auto ptrType = type->getAs<PointerType>()) {
-    type = ptrType->getPointeeType();
-  } else if (auto refType = type->getAs<ReferenceType>()) {
-    type = refType->getPointeeType();
+static bool isValidSwiftIndirectResultType(QualType Ty) {
+  if (const auto *PtrType = Ty->getAs<PointerType>()) {
+    Ty = PtrType->getPointeeType();
+  } else if (const auto *RefType = Ty->getAs<ReferenceType>()) {
+    Ty = RefType->getPointeeType();
   } else {
-    return type->isDependentType();
+    return Ty->isDependentType();
   }
-  return type.getAddressSpace() == LangAS::Default;
+  return Ty.getAddressSpace() == LangAS::Default;
 }
 
 /// Pointers and references to pointers in the default address space.
-static bool isValidSwiftErrorResultType(QualType type) {
-  if (auto ptrType = type->getAs<PointerType>()) {
-    type = ptrType->getPointeeType();
-  } else if (auto refType = type->getAs<ReferenceType>()) {
-    type = refType->getPointeeType();
+static bool isValidSwiftErrorResultType(QualType Ty) {
+  if (const auto *PtrType = Ty->getAs<PointerType>()) {
+    Ty = PtrType->getPointeeType();
+  } else if (const auto *RefType = Ty->getAs<ReferenceType>()) {
+    Ty = RefType->getPointeeType();
   } else {
-    return type->isDependentType();
+    return Ty->isDependentType();
   }
-  if (!type.getQualifiers().empty())
+  if (!Ty.getQualifiers().empty())
     return false;
-  return isValidSwiftContextType(type);
+  return isValidSwiftContextType(Ty);
 }
 
 static void handleParameterABIAttr(Sema &S, Decl *D, const AttributeList &Attrs,
@@ -4461,34 +4441,34 @@ void Sema::AddParameterABIAttr(SourceRan
 
 /// Checks a regparm attribute, returning true if it is ill-formed and
 /// otherwise setting numParams to the appropriate value.
-bool Sema::CheckRegparmAttr(const AttributeList &Attr, unsigned &numParams) {
-  if (Attr.isInvalid())
+bool Sema::CheckRegparmAttr(const AttributeList &AL, unsigned &numParams) {
+  if (AL.isInvalid())
     return true;
 
-  if (!checkAttributeNumArgs(*this, Attr, 1)) {
-    Attr.setInvalid();
+  if (!checkAttributeNumArgs(*this, AL, 1)) {
+    AL.setInvalid();
     return true;
   }
 
   uint32_t NP;
-  Expr *NumParamsExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(*this, Attr, NumParamsExpr, NP)) {
-    Attr.setInvalid();
+  Expr *NumParamsExpr = AL.getArgAsExpr(0);
+  if (!checkUInt32Argument(*this, AL, NumParamsExpr, NP)) {
+    AL.setInvalid();
     return true;
   }
 
   if (Context.getTargetInfo().getRegParmMax() == 0) {
-    Diag(Attr.getLoc(), diag::err_attribute_regparm_wrong_platform)
+    Diag(AL.getLoc(), diag::err_attribute_regparm_wrong_platform)
       << NumParamsExpr->getSourceRange();
-    Attr.setInvalid();
+    AL.setInvalid();
     return true;
   }
 
   numParams = NP;
   if (numParams > Context.getTargetInfo().getRegParmMax()) {
-    Diag(Attr.getLoc(), diag::err_attribute_regparm_invalid_number)
+    Diag(AL.getLoc(), diag::err_attribute_regparm_invalid_number)
       << Context.getTargetInfo().getRegParmMax() << NumParamsExpr->getSourceRange();
-    Attr.setInvalid();
+    AL.setInvalid();
     return true;
   }
 
@@ -4500,7 +4480,7 @@ bool Sema::CheckRegparmAttr(const Attrib
 // non-nullptr Expr result on success. Otherwise, it returns nullptr
 // and may output an error.
 static Expr *makeLaunchBoundsArgExpr(Sema &S, Expr *E,
-                                     const CUDALaunchBoundsAttr &Attr,
+                                     const CUDALaunchBoundsAttr &AL,
                                      const unsigned Idx) {
   if (S.DiagnoseUnexpandedParameterPack(E))
     return nullptr;
@@ -4513,7 +4493,7 @@ static Expr *makeLaunchBoundsArgExpr(Sem
   llvm::APSInt I(64);
   if (!E->isIntegerConstantExpr(I, S.Context)) {
     S.Diag(E->getExprLoc(), diag::err_attribute_argument_n_type)
-        << &Attr << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange();
+        << &AL << Idx << AANT_ArgumentIntegerConstant << E->getSourceRange();
     return nullptr;
   }
   // Make sure we can fit it in 32 bits.
@@ -4524,7 +4504,7 @@ static Expr *makeLaunchBoundsArgExpr(Sem
   }
   if (I < 0)
     S.Diag(E->getExprLoc(), diag::warn_attribute_argument_n_negative)
-        << &Attr << Idx << E->getSourceRange();
+        << &AL << Idx << E->getSourceRange();
 
   // We may need to perform implicit conversion of the argument.
   InitializedEntity Entity = InitializedEntity::InitializeParameter(
@@ -4555,205 +4535,198 @@ void Sema::AddLaunchBoundsAttr(SourceRan
 }
 
 static void handleLaunchBoundsAttr(Sema &S, Decl *D,
-                                   const AttributeList &Attr) {
-  if (!checkAttributeAtLeastNumArgs(S, Attr, 1) ||
-      !checkAttributeAtMostNumArgs(S, Attr, 2))
+                                   const AttributeList &AL) {
+  if (!checkAttributeAtLeastNumArgs(S, AL, 1) ||
+      !checkAttributeAtMostNumArgs(S, AL, 2))
     return;
 
-  S.AddLaunchBoundsAttr(Attr.getRange(), D, Attr.getArgAsExpr(0),
-                        Attr.getNumArgs() > 1 ? Attr.getArgAsExpr(1) : nullptr,
-                        Attr.getAttributeSpellingListIndex());
+  S.AddLaunchBoundsAttr(AL.getRange(), D, AL.getArgAsExpr(0),
+                        AL.getNumArgs() > 1 ? AL.getArgAsExpr(1) : nullptr,
+                        AL.getAttributeSpellingListIndex());
 }
 
 static void handleArgumentWithTypeTagAttr(Sema &S, Decl *D,
-                                          const AttributeList &Attr) {
-  if (!Attr.isArgIdent(0)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-      << Attr.getName() << /* arg num = */ 1 << AANT_ArgumentIdentifier;
+                                          const AttributeList &AL) {
+  if (!AL.isArgIdent(0)) {
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
+      << AL.getName() << /* arg num = */ 1 << AANT_ArgumentIdentifier;
     return;
   }
   
-  if (!checkAttributeNumArgs(S, Attr, 3))
+  if (!checkAttributeNumArgs(S, AL, 3))
     return;
 
-  IdentifierInfo *ArgumentKind = Attr.getArgAsIdent(0)->Ident;
+  IdentifierInfo *ArgumentKind = AL.getArgAsIdent(0)->Ident;
 
   if (!isFunctionOrMethod(D) || !hasFunctionProto(D)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
-      << Attr.getName() << ExpectedFunctionOrMethod;
+    S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type)
+      << AL.getName() << ExpectedFunctionOrMethod;
     return;
   }
 
   uint64_t ArgumentIdx;
-  if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 2, Attr.getArgAsExpr(1),
+  if (!checkFunctionOrMethodParameterIndex(S, D, AL, 2, AL.getArgAsExpr(1),
                                            ArgumentIdx))
     return;
 
   uint64_t TypeTagIdx;
-  if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 3, Attr.getArgAsExpr(2),
+  if (!checkFunctionOrMethodParameterIndex(S, D, AL, 3, AL.getArgAsExpr(2),
                                            TypeTagIdx))
     return;
 
-  bool IsPointer = (Attr.getName()->getName() == "pointer_with_type_tag");
+  bool IsPointer = (AL.getName()->getName() == "pointer_with_type_tag");
   if (IsPointer) {
     // Ensure that buffer has a pointer type.
     QualType BufferTy = getFunctionOrMethodParamType(D, ArgumentIdx);
     if (!BufferTy->isPointerType()) {
-      S.Diag(Attr.getLoc(), diag::err_attribute_pointers_only)
-        << Attr.getName() << 0;
+      S.Diag(AL.getLoc(), diag::err_attribute_pointers_only)
+        << AL.getName() << 0;
     }
   }
 
   D->addAttr(::new (S.Context)
-             ArgumentWithTypeTagAttr(Attr.getRange(), S.Context, ArgumentKind,
+             ArgumentWithTypeTagAttr(AL.getRange(), S.Context, ArgumentKind,
                                      ArgumentIdx, TypeTagIdx, IsPointer,
-                                     Attr.getAttributeSpellingListIndex()));
+                                     AL.getAttributeSpellingListIndex()));
 }
 
 static void handleTypeTagForDatatypeAttr(Sema &S, Decl *D,
-                                         const AttributeList &Attr) {
-  if (!Attr.isArgIdent(0)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_n_type)
-      << Attr.getName() << 1 << AANT_ArgumentIdentifier;
+                                         const AttributeList &AL) {
+  if (!AL.isArgIdent(0)) {
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_n_type)
+      << AL.getName() << 1 << AANT_ArgumentIdentifier;
     return;
   }
   
-  if (!checkAttributeNumArgs(S, Attr, 1))
+  if (!checkAttributeNumArgs(S, AL, 1))
     return;
 
   if (!isa<VarDecl>(D)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)
-      << Attr.getName() << ExpectedVariable;
+    S.Diag(AL.getLoc(), diag::err_attribute_wrong_decl_type)
+      << AL.getName() << ExpectedVariable;
     return;
   }
 
-  IdentifierInfo *PointerKind = Attr.getArgAsIdent(0)->Ident;
+  IdentifierInfo *PointerKind = AL.getArgAsIdent(0)->Ident;
   TypeSourceInfo *MatchingCTypeLoc = nullptr;
-  S.GetTypeFromParser(Attr.getMatchingCType(), &MatchingCTypeLoc);
+  S.GetTypeFromParser(AL.getMatchingCType(), &MatchingCTypeLoc);
   assert(MatchingCTypeLoc && "no type source info for attribute argument");
 
   D->addAttr(::new (S.Context)
-             TypeTagForDatatypeAttr(Attr.getRange(), S.Context, PointerKind,
+             TypeTagForDatatypeAttr(AL.getRange(), S.Context, PointerKind,
                                     MatchingCTypeLoc,
-                                    Attr.getLayoutCompatible(),
-                                    Attr.getMustBeNull(),
-                                    Attr.getAttributeSpellingListIndex()));
+                                    AL.getLayoutCompatible(),
+                                    AL.getMustBeNull(),
+                                    AL.getAttributeSpellingListIndex()));
 }
 
 static void handleXRayLogArgsAttr(Sema &S, Decl *D,
-                                  const AttributeList &Attr) {
+                                  const AttributeList &AL) {
   uint64_t ArgCount;
 
-  if (!checkFunctionOrMethodParameterIndex(S, D, Attr, 1, Attr.getArgAsExpr(0),
+  if (!checkFunctionOrMethodParameterIndex(S, D, AL, 1, AL.getArgAsExpr(0),
                                            ArgCount,
                                            true /* AllowImplicitThis*/))
     return;
 
   // ArgCount isn't a parameter index [0;n), it's a count [1;n] - hence + 1.
   D->addAttr(::new (S.Context)
-                 XRayLogArgsAttr(Attr.getRange(), S.Context, ++ArgCount,
-                                 Attr.getAttributeSpellingListIndex()));
+                 XRayLogArgsAttr(AL.getRange(), S.Context, ++ArgCount,
+                                 AL.getAttributeSpellingListIndex()));
 }
 
 //===----------------------------------------------------------------------===//
 // Checker-specific attribute handlers.
 //===----------------------------------------------------------------------===//
 
-static bool isValidSubjectOfNSReturnsRetainedAttribute(QualType type) {
-  return type->isDependentType() ||
-         type->isObjCRetainableType();
+static bool isValidSubjectOfNSReturnsRetainedAttribute(QualType QT) {
+  return QT->isDependentType() || QT->isObjCRetainableType();
 }
 
-static bool isValidSubjectOfNSAttribute(Sema &S, QualType type) {
-  return type->isDependentType() || 
-         type->isObjCObjectPointerType() || 
-         S.Context.isObjCNSObjectType(type);
+static bool isValidSubjectOfNSAttribute(Sema &S, QualType QT) {
+  return QT->isDependentType() || QT->isObjCObjectPointerType() ||
+         S.Context.isObjCNSObjectType(QT);
 }
 
-static bool isValidSubjectOfCFAttribute(Sema &S, QualType type) {
-  return type->isDependentType() || 
-         type->isPointerType() || 
-         isValidSubjectOfNSAttribute(S, type);
+static bool isValidSubjectOfCFAttribute(Sema &S, QualType QT) {
+  return QT->isDependentType() || QT->isPointerType() ||
+         isValidSubjectOfNSAttribute(S, QT);
 }
 
-static void handleNSConsumedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  S.AddNSConsumedAttr(Attr.getRange(), D, Attr.getAttributeSpellingListIndex(),
-                      Attr.getKind() == AttributeList::AT_NSConsumed,
+static void handleNSConsumedAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  S.AddNSConsumedAttr(AL.getRange(), D, AL.getAttributeSpellingListIndex(),
+                      AL.getKind() == AttributeList::AT_NSConsumed,
                       /*template instantiation*/ false);
 }
 
-void Sema::AddNSConsumedAttr(SourceRange attrRange, Decl *D,
-                             unsigned spellingIndex, bool isNSConsumed,
-                             bool isTemplateInstantiation) {
-  ParmVarDecl *param = cast<ParmVarDecl>(D);
-  bool typeOK;
+void Sema::AddNSConsumedAttr(SourceRange AttrRange, Decl *D,
+                             unsigned SpellingIndex, bool IsNSConsumed,
+                             bool IsTemplateInstantiation) {
+  const auto *Param = cast<ParmVarDecl>(D);
+  bool TypeOK;
 
-  if (isNSConsumed) {
-    typeOK = isValidSubjectOfNSAttribute(*this, param->getType());
-  } else {
-    typeOK = isValidSubjectOfCFAttribute(*this, param->getType());
-  }
+  if (IsNSConsumed)
+    TypeOK = isValidSubjectOfNSAttribute(*this, Param->getType());
+  else
+    TypeOK = isValidSubjectOfCFAttribute(*this, Param->getType());
 
-  if (!typeOK) {
+  if (!TypeOK) {
     // These attributes are normally just advisory, but in ARC, ns_consumed
     // is significant.  Allow non-dependent code to contain inappropriate
     // attributes even in ARC, but require template instantiations to be
     // set up correctly.
-    Diag(D->getLocStart(),
-         (isTemplateInstantiation && isNSConsumed &&
-            getLangOpts().ObjCAutoRefCount
-          ? diag::err_ns_attribute_wrong_parameter_type
-          : diag::warn_ns_attribute_wrong_parameter_type))
-      << attrRange
-      << (isNSConsumed ? "ns_consumed" : "cf_consumed")
-      << (isNSConsumed ? /*objc pointers*/ 0 : /*cf pointers*/ 1);
+    Diag(D->getLocStart(), (IsTemplateInstantiation && IsNSConsumed &&
+                                    getLangOpts().ObjCAutoRefCount
+                                ? diag::err_ns_attribute_wrong_parameter_type
+                                : diag::warn_ns_attribute_wrong_parameter_type))
+        << AttrRange << (IsNSConsumed ? "ns_consumed" : "cf_consumed")
+        << (IsNSConsumed ? /*objc pointers*/ 0 : /*cf pointers*/ 1);
     return;
   }
 
-  if (isNSConsumed)
-    param->addAttr(::new (Context)
-                   NSConsumedAttr(attrRange, Context, spellingIndex));
+  if (IsNSConsumed)
+    D->addAttr(::new (Context)
+                   NSConsumedAttr(AttrRange, Context, SpellingIndex));
   else
-    param->addAttr(::new (Context)
-                   CFConsumedAttr(attrRange, Context, spellingIndex));
+    D->addAttr(::new (Context)
+                   CFConsumedAttr(AttrRange, Context, SpellingIndex));
 }
 
-bool Sema::checkNSReturnsRetainedReturnType(SourceLocation loc,
-                                            QualType type) {
-  if (isValidSubjectOfNSReturnsRetainedAttribute(type))
+bool Sema::checkNSReturnsRetainedReturnType(SourceLocation Loc, QualType QT) {
+  if (isValidSubjectOfNSReturnsRetainedAttribute(QT))
     return false;
 
-  Diag(loc, diag::warn_ns_attribute_wrong_return_type)
-    << "'ns_returns_retained'" << 0 << 0;
+  Diag(Loc, diag::warn_ns_attribute_wrong_return_type)
+      << "'ns_returns_retained'" << 0 << 0;
   return true;
 }
 
 static void handleNSReturnsRetainedAttr(Sema &S, Decl *D,
-                                        const AttributeList &Attr) {
-  QualType returnType;
+                                        const AttributeList &AL) {
+  QualType ReturnType;
 
-  if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D))
-    returnType = MD->getReturnType();
+  if (const auto *MD = dyn_cast<ObjCMethodDecl>(D))
+    ReturnType = MD->getReturnType();
   else if (S.getLangOpts().ObjCAutoRefCount && hasDeclarator(D) &&
-           (Attr.getKind() == AttributeList::AT_NSReturnsRetained))
+           (AL.getKind() == AttributeList::AT_NSReturnsRetained))
     return; // ignore: was handled as a type attribute
-  else if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D))
-    returnType = PD->getType();
-  else if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
-    returnType = FD->getReturnType();
-  else if (auto *Param = dyn_cast<ParmVarDecl>(D)) {
-    returnType = Param->getType()->getPointeeType();
-    if (returnType.isNull()) {
+  else if (const auto *PD = dyn_cast<ObjCPropertyDecl>(D))
+    ReturnType = PD->getType();
+  else if (const auto *FD = dyn_cast<FunctionDecl>(D))
+    ReturnType = FD->getReturnType();
+  else if (const auto *Param = dyn_cast<ParmVarDecl>(D)) {
+    ReturnType = Param->getType()->getPointeeType();
+    if (ReturnType.isNull()) {
       S.Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_parameter_type)
-          << Attr.getName() << /*pointer-to-CF*/2
-          << Attr.getRange();
+          << AL.getName() << /*pointer-to-CF*/2
+          << AL.getRange();
       return;
     }
-  } else if (Attr.isUsedAsTypeAttr()) {
+  } else if (AL.isUsedAsTypeAttr()) {
     return;
   } else {
     AttributeDeclKind ExpectedDeclKind;
-    switch (Attr.getKind()) {
+    switch (AL.getKind()) {
     default: llvm_unreachable("invalid ownership attribute");
     case AttributeList::AT_NSReturnsRetained:
     case AttributeList::AT_NSReturnsAutoreleased:
@@ -4767,40 +4740,40 @@ static void handleNSReturnsRetainedAttr(
       break;
     }
     S.Diag(D->getLocStart(), diag::warn_attribute_wrong_decl_type)
-        << Attr.getRange() << Attr.getName() << ExpectedDeclKind;
+        << AL.getRange() << AL.getName() << ExpectedDeclKind;
     return;
   }
 
-  bool typeOK;
-  bool cf;
-  switch (Attr.getKind()) {
+  bool TypeOK;
+  bool Cf;
+  switch (AL.getKind()) {
   default: llvm_unreachable("invalid ownership attribute");
   case AttributeList::AT_NSReturnsRetained:
-    typeOK = isValidSubjectOfNSReturnsRetainedAttribute(returnType);
-    cf = false;
+    TypeOK = isValidSubjectOfNSReturnsRetainedAttribute(ReturnType);
+    Cf = false;
     break;
       
   case AttributeList::AT_NSReturnsAutoreleased:
   case AttributeList::AT_NSReturnsNotRetained:
-    typeOK = isValidSubjectOfNSAttribute(S, returnType);
-    cf = false;
+    TypeOK = isValidSubjectOfNSAttribute(S, ReturnType);
+    Cf = false;
     break;
 
   case AttributeList::AT_CFReturnsRetained:
   case AttributeList::AT_CFReturnsNotRetained:
-    typeOK = isValidSubjectOfCFAttribute(S, returnType);
-    cf = true;
+    TypeOK = isValidSubjectOfCFAttribute(S, ReturnType);
+    Cf = true;
     break;
   }
 
-  if (!typeOK) {
-    if (Attr.isUsedAsTypeAttr())
+  if (!TypeOK) {
+    if (AL.isUsedAsTypeAttr())
       return;
 
     if (isa<ParmVarDecl>(D)) {
       S.Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_parameter_type)
-          << Attr.getName() << /*pointer-to-CF*/2
-          << Attr.getRange();
+          << AL.getName() << /*pointer-to-CF*/2
+          << AL.getRange();
     } else {
       // Needs to be kept in sync with warn_ns_attribute_wrong_return_type.
       enum : unsigned {
@@ -4813,34 +4786,34 @@ static void handleNSReturnsRetainedAttr(
       else if (isa<ObjCPropertyDecl>(D))
         SubjectKind = Property;
       S.Diag(D->getLocStart(), diag::warn_ns_attribute_wrong_return_type)
-          << Attr.getName() << SubjectKind << cf
-          << Attr.getRange();
+          << AL.getName() << SubjectKind << Cf
+          << AL.getRange();
     }
     return;
   }
 
-  switch (Attr.getKind()) {
+  switch (AL.getKind()) {
     default:
       llvm_unreachable("invalid ownership attribute");
     case AttributeList::AT_NSReturnsAutoreleased:
       D->addAttr(::new (S.Context) NSReturnsAutoreleasedAttr(
-          Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+          AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
       return;
     case AttributeList::AT_CFReturnsNotRetained:
       D->addAttr(::new (S.Context) CFReturnsNotRetainedAttr(
-          Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+          AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
       return;
     case AttributeList::AT_NSReturnsNotRetained:
       D->addAttr(::new (S.Context) NSReturnsNotRetainedAttr(
-          Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+          AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
       return;
     case AttributeList::AT_CFReturnsRetained:
       D->addAttr(::new (S.Context) CFReturnsRetainedAttr(
-          Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+          AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
       return;
     case AttributeList::AT_NSReturnsRetained:
       D->addAttr(::new (S.Context) NSReturnsRetainedAttr(
-          Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+          AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
       return;
   };
 }
@@ -4875,115 +4848,112 @@ static void handleObjCReturnsInnerPointe
 
 static void handleObjCRequiresSuperAttr(Sema &S, Decl *D,
                                         const AttributeList &Attrs) {
-  ObjCMethodDecl *method = cast<ObjCMethodDecl>(D);
-  
-  DeclContext *DC = method->getDeclContext();
-  if (const ObjCProtocolDecl *PDecl = dyn_cast_or_null<ObjCProtocolDecl>(DC)) {
+  const auto *Method = cast<ObjCMethodDecl>(D);
+
+  const DeclContext *DC = Method->getDeclContext();
+  if (const auto *PDecl = dyn_cast_or_null<ObjCProtocolDecl>(DC)) {
     S.Diag(D->getLocStart(), diag::warn_objc_requires_super_protocol)
-    << Attrs.getName() << 0;
+        << Attrs.getName() << 0;
     S.Diag(PDecl->getLocation(), diag::note_protocol_decl);
     return;
   }
-  if (method->getMethodFamily() == OMF_dealloc) {
+  if (Method->getMethodFamily() == OMF_dealloc) {
     S.Diag(D->getLocStart(), diag::warn_objc_requires_super_protocol)
-    << Attrs.getName() << 1;
+        << Attrs.getName() << 1;
     return;
   }
-  
-  method->addAttr(::new (S.Context)
-                  ObjCRequiresSuperAttr(Attrs.getRange(), S.Context,
-                                        Attrs.getAttributeSpellingListIndex()));
+
+  D->addAttr(::new (S.Context) ObjCRequiresSuperAttr(
+      Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
 }
 
 static void handleCFAuditedTransferAttr(Sema &S, Decl *D,
-                                        const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<CFUnknownTransferAttr>(S, D, Attr.getRange(),
-                                                      Attr.getName()))
+                                        const AttributeList &AL) {
+  if (checkAttrMutualExclusion<CFUnknownTransferAttr>(S, D, AL.getRange(),
+                                                      AL.getName()))
     return;
 
   D->addAttr(::new (S.Context)
-             CFAuditedTransferAttr(Attr.getRange(), S.Context,
-                                   Attr.getAttributeSpellingListIndex()));
+             CFAuditedTransferAttr(AL.getRange(), S.Context,
+                                   AL.getAttributeSpellingListIndex()));
 }
 
 static void handleCFUnknownTransferAttr(Sema &S, Decl *D,
-                                        const AttributeList &Attr) {
-  if (checkAttrMutualExclusion<CFAuditedTransferAttr>(S, D, Attr.getRange(),
-                                                      Attr.getName()))
+                                        const AttributeList &AL) {
+  if (checkAttrMutualExclusion<CFAuditedTransferAttr>(S, D, AL.getRange(),
+                                                      AL.getName()))
     return;
 
   D->addAttr(::new (S.Context)
-             CFUnknownTransferAttr(Attr.getRange(), S.Context,
-             Attr.getAttributeSpellingListIndex()));
+             CFUnknownTransferAttr(AL.getRange(), S.Context,
+             AL.getAttributeSpellingListIndex()));
 }
 
-static void handleObjCBridgeAttr(Sema &S, Scope *Sc, Decl *D,
-                                const AttributeList &Attr) {
-  IdentifierLoc * Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : nullptr;
+static void handleObjCBridgeAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  IdentifierLoc *Parm = AL.isArgIdent(0) ? AL.getArgAsIdent(0) : nullptr;
 
   if (!Parm) {
-    S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0;
+    S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << AL.getName() << 0;
     return;
   }
 
   // Typedefs only allow objc_bridge(id) and have some additional checking.
-  if (auto TD = dyn_cast<TypedefNameDecl>(D)) {
+  if (const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
     if (!Parm->Ident->isStr("id")) {
-      S.Diag(Attr.getLoc(), diag::err_objc_attr_typedef_not_id)
-        << Attr.getName();
+      S.Diag(AL.getLoc(), diag::err_objc_attr_typedef_not_id)
+        << AL.getName();
       return;
     }
 
     // Only allow 'cv void *'.
     QualType T = TD->getUnderlyingType();
     if (!T->isVoidPointerType()) {
-      S.Diag(Attr.getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
+      S.Diag(AL.getLoc(), diag::err_objc_attr_typedef_not_void_pointer);
       return;
     }
   }
   
   D->addAttr(::new (S.Context)
-             ObjCBridgeAttr(Attr.getRange(), S.Context, Parm->Ident,
-                           Attr.getAttributeSpellingListIndex()));
+             ObjCBridgeAttr(AL.getRange(), S.Context, Parm->Ident,
+                           AL.getAttributeSpellingListIndex()));
 }
 
-static void handleObjCBridgeMutableAttr(Sema &S, Scope *Sc, Decl *D,
-                                        const AttributeList &Attr) {
-  IdentifierLoc * Parm = Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : nullptr;
+static void handleObjCBridgeMutableAttr(Sema &S, Decl *D,
+                                        const AttributeList &AL) {
+  IdentifierLoc *Parm = AL.isArgIdent(0) ? AL.getArgAsIdent(0) : nullptr;
 
   if (!Parm) {
-    S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0;
+    S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << AL.getName() << 0;
     return;
   }
   
   D->addAttr(::new (S.Context)
-             ObjCBridgeMutableAttr(Attr.getRange(), S.Context, Parm->Ident,
-                            Attr.getAttributeSpellingListIndex()));
+             ObjCBridgeMutableAttr(AL.getRange(), S.Context, Parm->Ident,
+                            AL.getAttributeSpellingListIndex()));
 }
 
-static void handleObjCBridgeRelatedAttr(Sema &S, Scope *Sc, Decl *D,
-                                 const AttributeList &Attr) {
+static void handleObjCBridgeRelatedAttr(Sema &S, Decl *D,
+                                        const AttributeList &AL) {
   IdentifierInfo *RelatedClass =
-    Attr.isArgIdent(0) ? Attr.getArgAsIdent(0)->Ident : nullptr;
+      AL.isArgIdent(0) ? AL.getArgAsIdent(0)->Ident : nullptr;
   if (!RelatedClass) {
-    S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << Attr.getName() << 0;
+    S.Diag(D->getLocStart(), diag::err_objc_attr_not_id) << AL.getName() << 0;
     return;
   }
   IdentifierInfo *ClassMethod =
-    Attr.getArgAsIdent(1) ? Attr.getArgAsIdent(1)->Ident : nullptr;
+    AL.getArgAsIdent(1) ? AL.getArgAsIdent(1)->Ident : nullptr;
   IdentifierInfo *InstanceMethod =
-    Attr.getArgAsIdent(2) ? Attr.getArgAsIdent(2)->Ident : nullptr;
+    AL.getArgAsIdent(2) ? AL.getArgAsIdent(2)->Ident : nullptr;
   D->addAttr(::new (S.Context)
-             ObjCBridgeRelatedAttr(Attr.getRange(), S.Context, RelatedClass,
+             ObjCBridgeRelatedAttr(AL.getRange(), S.Context, RelatedClass,
                                    ClassMethod, InstanceMethod,
-                                   Attr.getAttributeSpellingListIndex()));
+                                   AL.getAttributeSpellingListIndex()));
 }
 
 static void handleObjCDesignatedInitializer(Sema &S, Decl *D,
-                                            const AttributeList &Attr) {
+                                            const AttributeList &AL) {
   ObjCInterfaceDecl *IFace;
-  if (ObjCCategoryDecl *CatDecl =
-          dyn_cast<ObjCCategoryDecl>(D->getDeclContext()))
+  if (auto *CatDecl = dyn_cast<ObjCCategoryDecl>(D->getDeclContext()))
     IFace = CatDecl->getClassInterface();
   else
     IFace = cast<ObjCInterfaceDecl>(D->getDeclContext());
@@ -4993,29 +4963,29 @@ static void handleObjCDesignatedInitiali
 
   IFace->setHasDesignatedInitializers();
   D->addAttr(::new (S.Context)
-                  ObjCDesignatedInitializerAttr(Attr.getRange(), S.Context,
-                                         Attr.getAttributeSpellingListIndex()));
+                  ObjCDesignatedInitializerAttr(AL.getRange(), S.Context,
+                                         AL.getAttributeSpellingListIndex()));
 }
 
 static void handleObjCRuntimeName(Sema &S, Decl *D,
-                                  const AttributeList &Attr) {
+                                  const AttributeList &AL) {
   StringRef MetaDataName;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, MetaDataName))
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, MetaDataName))
     return;
   D->addAttr(::new (S.Context)
-             ObjCRuntimeNameAttr(Attr.getRange(), S.Context,
+             ObjCRuntimeNameAttr(AL.getRange(), S.Context,
                                  MetaDataName,
-                                 Attr.getAttributeSpellingListIndex()));
+                                 AL.getAttributeSpellingListIndex()));
 }
 
 // When a user wants to use objc_boxable with a union or struct
 // but they don't have access to the declaration (legacy/third-party code)
 // then they can 'enable' this feature with a typedef:
 // typedef struct __attribute((objc_boxable)) legacy_struct legacy_struct;
-static void handleObjCBoxable(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleObjCBoxable(Sema &S, Decl *D, const AttributeList &AL) {
   bool notify = false;
 
-  RecordDecl *RD = dyn_cast<RecordDecl>(D);
+  auto *RD = dyn_cast<RecordDecl>(D);
   if (RD && RD->getDefinition()) {
     RD = RD->getDefinition();
     notify = true;
@@ -5023,8 +4993,8 @@ static void handleObjCBoxable(Sema &S, D
 
   if (RD) {
     ObjCBoxableAttr *BoxableAttr = ::new (S.Context)
-                          ObjCBoxableAttr(Attr.getRange(), S.Context,
-                                          Attr.getAttributeSpellingListIndex());
+                          ObjCBoxableAttr(AL.getRange(), S.Context,
+                                          AL.getAttributeSpellingListIndex());
     RD->addAttr(BoxableAttr);
     if (notify) {
       // we need to notify ASTReader/ASTWriter about
@@ -5036,35 +5006,35 @@ static void handleObjCBoxable(Sema &S, D
 }
 
 static void handleObjCOwnershipAttr(Sema &S, Decl *D,
-                                    const AttributeList &Attr) {
+                                    const AttributeList &AL) {
   if (hasDeclarator(D)) return;
 
   S.Diag(D->getLocStart(), diag::err_attribute_wrong_decl_type)
-    << Attr.getRange() << Attr.getName() << ExpectedVariable;
+    << AL.getRange() << AL.getName() << ExpectedVariable;
 }
 
 static void handleObjCPreciseLifetimeAttr(Sema &S, Decl *D,
-                                          const AttributeList &Attr) {
-  ValueDecl *vd = cast<ValueDecl>(D);
-  QualType type = vd->getType();
+                                          const AttributeList &AL) {
+  const auto *VD = cast<ValueDecl>(D);
+  QualType QT = VD->getType();
 
-  if (!type->isDependentType() &&
-      !type->isObjCLifetimeType()) {
-    S.Diag(Attr.getLoc(), diag::err_objc_precise_lifetime_bad_type)
-      << type;
+  if (!QT->isDependentType() &&
+      !QT->isObjCLifetimeType()) {
+    S.Diag(AL.getLoc(), diag::err_objc_precise_lifetime_bad_type)
+      << QT;
     return;
   }
 
-  Qualifiers::ObjCLifetime lifetime = type.getObjCLifetime();
+  Qualifiers::ObjCLifetime Lifetime = QT.getObjCLifetime();
 
   // If we have no lifetime yet, check the lifetime we're presumably
   // going to infer.
-  if (lifetime == Qualifiers::OCL_None && !type->isDependentType())
-    lifetime = type->getObjCARCImplicitLifetime();
+  if (Lifetime == Qualifiers::OCL_None && !QT->isDependentType())
+    Lifetime = QT->getObjCARCImplicitLifetime();
 
-  switch (lifetime) {
+  switch (Lifetime) {
   case Qualifiers::OCL_None:
-    assert(type->isDependentType() &&
+    assert(QT->isDependentType() &&
            "didn't infer lifetime for non-dependent type?");
     break;
 
@@ -5074,14 +5044,14 @@ static void handleObjCPreciseLifetimeAtt
 
   case Qualifiers::OCL_ExplicitNone:
   case Qualifiers::OCL_Autoreleasing:
-    S.Diag(Attr.getLoc(), diag::warn_objc_precise_lifetime_meaningless)
-      << (lifetime == Qualifiers::OCL_Autoreleasing);
+    S.Diag(AL.getLoc(), diag::warn_objc_precise_lifetime_meaningless)
+        << (Lifetime == Qualifiers::OCL_Autoreleasing);
     break;
   }
 
   D->addAttr(::new (S.Context)
-             ObjCPreciseLifetimeAttr(Attr.getRange(), S.Context,
-                                     Attr.getAttributeSpellingListIndex()));
+             ObjCPreciseLifetimeAttr(AL.getRange(), S.Context,
+                                     AL.getAttributeSpellingListIndex()));
 }
 
 //===----------------------------------------------------------------------===//
@@ -5101,16 +5071,16 @@ UuidAttr *Sema::mergeUuidAttr(Decl *D, S
   return ::new (Context) UuidAttr(Range, Context, Uuid, AttrSpellingListIndex);
 }
 
-static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleUuidAttr(Sema &S, Decl *D, const AttributeList &AL) {
   if (!S.LangOpts.CPlusPlus) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_not_supported_in_lang)
-      << Attr.getName() << AttributeLangSupport::C;
+    S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang)
+      << AL.getName() << AttributeLangSupport::C;
     return;
   }
 
   StringRef StrRef;
   SourceLocation LiteralLoc;
-  if (!S.checkStringLiteralArgumentAttr(Attr, 0, StrRef, &LiteralLoc))
+  if (!S.checkStringLiteralArgumentAttr(AL, 0, StrRef, &LiteralLoc))
     return;
 
   // GUID format is "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" or
@@ -5142,25 +5112,25 @@ static void handleUuidAttr(Sema &S, Decl
   // separating attributes nor of the [ and the ] are in the AST.
   // Cf "SourceLocations of attribute list delimiters - [[ ... , ... ]] etc"
   // on cfe-dev.
-  if (Attr.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
-    S.Diag(Attr.getLoc(), diag::warn_atl_uuid_deprecated);
+  if (AL.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
+    S.Diag(AL.getLoc(), diag::warn_atl_uuid_deprecated);
 
-  UuidAttr *UA = S.mergeUuidAttr(D, Attr.getRange(),
-                                 Attr.getAttributeSpellingListIndex(), StrRef);
+  UuidAttr *UA = S.mergeUuidAttr(D, AL.getRange(),
+                                 AL.getAttributeSpellingListIndex(), StrRef);
   if (UA)
     D->addAttr(UA);
 }
 
-static void handleMSInheritanceAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleMSInheritanceAttr(Sema &S, Decl *D, const AttributeList &AL) {
   if (!S.LangOpts.CPlusPlus) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_not_supported_in_lang)
-      << Attr.getName() << AttributeLangSupport::C;
+    S.Diag(AL.getLoc(), diag::err_attribute_not_supported_in_lang)
+      << AL.getName() << AttributeLangSupport::C;
     return;
   }
   MSInheritanceAttr *IA = S.mergeMSInheritanceAttr(
-      D, Attr.getRange(), /*BestCase=*/true,
-      Attr.getAttributeSpellingListIndex(),
-      (MSInheritanceAttr::Spelling)Attr.getSemanticSpelling());
+      D, AL.getRange(), /*BestCase=*/true,
+      AL.getAttributeSpellingListIndex(),
+      (MSInheritanceAttr::Spelling)AL.getSemanticSpelling());
   if (IA) {
     D->addAttr(IA);
     S.Consumer.AssignInheritanceModel(cast<CXXRecordDecl>(D));
@@ -5168,45 +5138,45 @@ static void handleMSInheritanceAttr(Sema
 }
 
 static void handleDeclspecThreadAttr(Sema &S, Decl *D,
-                                     const AttributeList &Attr) {
-  VarDecl *VD = cast<VarDecl>(D);
+                                     const AttributeList &AL) {
+  const auto *VD = cast<VarDecl>(D);
   if (!S.Context.getTargetInfo().isTLSSupported()) {
-    S.Diag(Attr.getLoc(), diag::err_thread_unsupported);
+    S.Diag(AL.getLoc(), diag::err_thread_unsupported);
     return;
   }
   if (VD->getTSCSpec() != TSCS_unspecified) {
-    S.Diag(Attr.getLoc(), diag::err_declspec_thread_on_thread_variable);
+    S.Diag(AL.getLoc(), diag::err_declspec_thread_on_thread_variable);
     return;
   }
   if (VD->hasLocalStorage()) {
-    S.Diag(Attr.getLoc(), diag::err_thread_non_global) << "__declspec(thread)";
+    S.Diag(AL.getLoc(), diag::err_thread_non_global) << "__declspec(thread)";
     return;
   }
-  VD->addAttr(::new (S.Context) ThreadAttr(
-      Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) ThreadAttr(AL.getRange(), S.Context,
+                                          AL.getAttributeSpellingListIndex()));
 }
 
-static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleAbiTagAttr(Sema &S, Decl *D, const AttributeList &AL) {
   SmallVector<StringRef, 4> Tags;
-  for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) {
+  for (unsigned I = 0, E = AL.getNumArgs(); I != E; ++I) {
     StringRef Tag;
-    if (!S.checkStringLiteralArgumentAttr(Attr, I, Tag))
+    if (!S.checkStringLiteralArgumentAttr(AL, I, Tag))
       return;
     Tags.push_back(Tag);
   }
 
   if (const auto *NS = dyn_cast<NamespaceDecl>(D)) {
     if (!NS->isInline()) {
-      S.Diag(Attr.getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
+      S.Diag(AL.getLoc(), diag::warn_attr_abi_tag_namespace) << 0;
       return;
     }
     if (NS->isAnonymousNamespace()) {
-      S.Diag(Attr.getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
+      S.Diag(AL.getLoc(), diag::warn_attr_abi_tag_namespace) << 1;
       return;
     }
-    if (Attr.getNumArgs() == 0)
+    if (AL.getNumArgs() == 0)
       Tags.push_back(NS->getName());
-  } else if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+  } else if (!checkAttributeAtLeastNumArgs(S, AL, 1))
     return;
 
   // Store tags sorted and without duplicates.
@@ -5214,90 +5184,90 @@ static void handleAbiTagAttr(Sema &S, De
   Tags.erase(std::unique(Tags.begin(), Tags.end()), Tags.end());
 
   D->addAttr(::new (S.Context)
-             AbiTagAttr(Attr.getRange(), S.Context, Tags.data(), Tags.size(),
-                        Attr.getAttributeSpellingListIndex()));
+             AbiTagAttr(AL.getRange(), S.Context, Tags.data(), Tags.size(),
+                        AL.getAttributeSpellingListIndex()));
 }
 
 static void handleARMInterruptAttr(Sema &S, Decl *D,
-                                   const AttributeList &Attr) {
+                                   const AttributeList &AL) {
   // Check the attribute arguments.
-  if (Attr.getNumArgs() > 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
-      << Attr.getName() << 1;
+  if (AL.getNumArgs() > 1) {
+    S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments)
+      << AL.getName() << 1;
     return;
   }
 
   StringRef Str;
   SourceLocation ArgLoc;
 
-  if (Attr.getNumArgs() == 0)
+  if (AL.getNumArgs() == 0)
     Str = "";
-  else if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, &ArgLoc))
+  else if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc))
     return;
 
   ARMInterruptAttr::InterruptType Kind;
   if (!ARMInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
-      << Attr.getName() << Str << ArgLoc;
+    S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+      << AL.getName() << Str << ArgLoc;
     return;
   }
 
-  unsigned Index = Attr.getAttributeSpellingListIndex();
+  unsigned Index = AL.getAttributeSpellingListIndex();
   D->addAttr(::new (S.Context)
-             ARMInterruptAttr(Attr.getLoc(), S.Context, Kind, Index));
+             ARMInterruptAttr(AL.getLoc(), S.Context, Kind, Index));
 }
 
 static void handleMSP430InterruptAttr(Sema &S, Decl *D,
-                                      const AttributeList &Attr) {
-  if (!checkAttributeNumArgs(S, Attr, 1))
+                                      const AttributeList &AL) {
+  if (!checkAttributeNumArgs(S, AL, 1))
     return;
 
-  if (!Attr.isArgExpr(0)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_type) << Attr.getName()
+  if (!AL.isArgExpr(0)) {
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_type) << AL.getName()
       << AANT_ArgumentIntegerConstant;
     return;    
   }
 
   // FIXME: Check for decl - it should be void ()(void).
 
-  Expr *NumParamsExpr = static_cast<Expr *>(Attr.getArgAsExpr(0));
+  Expr *NumParamsExpr = static_cast<Expr *>(AL.getArgAsExpr(0));
   llvm::APSInt NumParams(32);
   if (!NumParamsExpr->isIntegerConstantExpr(NumParams, S.Context)) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_type)
-      << Attr.getName() << AANT_ArgumentIntegerConstant
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
+      << AL.getName() << AANT_ArgumentIntegerConstant
       << NumParamsExpr->getSourceRange();
     return;
   }
 
   unsigned Num = NumParams.getLimitedValue(255);
   if ((Num & 1) || Num > 30) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
-      << Attr.getName() << (int)NumParams.getSExtValue()
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds)
+      << AL.getName() << (int)NumParams.getSExtValue()
       << NumParamsExpr->getSourceRange();
     return;
   }
 
   D->addAttr(::new (S.Context)
-              MSP430InterruptAttr(Attr.getLoc(), S.Context, Num,
-                                  Attr.getAttributeSpellingListIndex()));
+              MSP430InterruptAttr(AL.getLoc(), S.Context, Num,
+                                  AL.getAttributeSpellingListIndex()));
   D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
 static void handleMipsInterruptAttr(Sema &S, Decl *D,
-                                    const AttributeList &Attr) {
+                                    const AttributeList &AL) {
   // Only one optional argument permitted.
-  if (Attr.getNumArgs() > 1) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_too_many_arguments)
-        << Attr.getName() << 1;
+  if (AL.getNumArgs() > 1) {
+    S.Diag(AL.getLoc(), diag::err_attribute_too_many_arguments)
+        << AL.getName() << 1;
     return;
   }
 
   StringRef Str;
   SourceLocation ArgLoc;
 
-  if (Attr.getNumArgs() == 0)
+  if (AL.getNumArgs() == 0)
     Str = "";
-  else if (!S.checkStringLiteralArgumentAttr(Attr, 0, Str, &ArgLoc))
+  else if (!S.checkStringLiteralArgumentAttr(AL, 0, Str, &ArgLoc))
     return;
 
   // Semantic checks for a function with the 'interrupt' attribute for MIPS:
@@ -5327,23 +5297,23 @@ static void handleMipsInterruptAttr(Sema
     return;
   }
 
-  if (checkAttrMutualExclusion<Mips16Attr>(S, D, Attr.getRange(),
-                                           Attr.getName()))
+  if (checkAttrMutualExclusion<Mips16Attr>(S, D, AL.getRange(),
+                                           AL.getName()))
     return;
 
   MipsInterruptAttr::InterruptType Kind;
   if (!MipsInterruptAttr::ConvertStrToInterruptType(Str, Kind)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_type_not_supported)
-        << Attr.getName() << "'" + std::string(Str) + "'";
+    S.Diag(AL.getLoc(), diag::warn_attribute_type_not_supported)
+        << AL.getName() << "'" + std::string(Str) + "'";
     return;
   }
 
   D->addAttr(::new (S.Context) MipsInterruptAttr(
-      Attr.getLoc(), S.Context, Kind, Attr.getAttributeSpellingListIndex()));
+      AL.getLoc(), S.Context, Kind, AL.getAttributeSpellingListIndex()));
 }
 
 static void handleAnyX86InterruptAttr(Sema &S, Decl *D,
-                                      const AttributeList &Attr) {
+                                      const AttributeList &AL) {
   // Semantic checks for a function with the 'interrupt' attribute.
   // a) Must be a function.
   // b) Must have the 'void' return type.
@@ -5353,8 +5323,8 @@ static void handleAnyX86InterruptAttr(Se
   if (!isFunctionOrMethod(D) || !hasFunctionProto(D) || isInstanceMethod(D) ||
       CXXMethodDecl::isStaticOverloadedOperator(
           cast<NamedDecl>(D)->getDeclName().getCXXOverloadedOperator())) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-        << Attr.getName() << ExpectedFunctionWithProtoType;
+    S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
+        << AL.getName() << ExpectedFunctionWithProtoType;
     return;
   }
   // Interrupt handler must have void return type.
@@ -5404,182 +5374,182 @@ static void handleAnyX86InterruptAttr(Se
     return;
   }
   D->addAttr(::new (S.Context) AnyX86InterruptAttr(
-      Attr.getLoc(), S.Context, Attr.getAttributeSpellingListIndex()));
+      AL.getLoc(), S.Context, AL.getAttributeSpellingListIndex()));
   D->addAttr(UsedAttr::CreateImplicit(S.Context));
 }
 
-static void handleAVRInterruptAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleAVRInterruptAttr(Sema &S, Decl *D, const AttributeList &AL) {
   if (!isFunctionOrMethod(D)) {
     S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
         << "'interrupt'" << ExpectedFunction;
     return;
   }
 
-  if (!checkAttributeNumArgs(S, Attr, 0))
+  if (!checkAttributeNumArgs(S, AL, 0))
     return;
 
-  handleSimpleAttribute<AVRInterruptAttr>(S, D, Attr);
+  handleSimpleAttribute<AVRInterruptAttr>(S, D, AL);
 }
 
-static void handleAVRSignalAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleAVRSignalAttr(Sema &S, Decl *D, const AttributeList &AL) {
   if (!isFunctionOrMethod(D)) {
     S.Diag(D->getLocation(), diag::warn_attribute_wrong_decl_type)
         << "'signal'" << ExpectedFunction;
     return;
   }
 
-  if (!checkAttributeNumArgs(S, Attr, 0))
+  if (!checkAttributeNumArgs(S, AL, 0))
     return;
 
-  handleSimpleAttribute<AVRSignalAttr>(S, D, Attr);
+  handleSimpleAttribute<AVRSignalAttr>(S, D, AL);
 }
 
-static void handleInterruptAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleInterruptAttr(Sema &S, Decl *D, const AttributeList &AL) {
   // Dispatch the interrupt attribute based on the current target.
   switch (S.Context.getTargetInfo().getTriple().getArch()) {
   case llvm::Triple::msp430:
-    handleMSP430InterruptAttr(S, D, Attr);
+    handleMSP430InterruptAttr(S, D, AL);
     break;
   case llvm::Triple::mipsel:
   case llvm::Triple::mips:
-    handleMipsInterruptAttr(S, D, Attr);
+    handleMipsInterruptAttr(S, D, AL);
     break;
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
-    handleAnyX86InterruptAttr(S, D, Attr);
+    handleAnyX86InterruptAttr(S, D, AL);
     break;
   case llvm::Triple::avr:
-    handleAVRInterruptAttr(S, D, Attr);
+    handleAVRInterruptAttr(S, D, AL);
     break;
   default:
-    handleARMInterruptAttr(S, D, Attr);
+    handleARMInterruptAttr(S, D, AL);
     break;
   }
 }
 
 static void handleAMDGPUFlatWorkGroupSizeAttr(Sema &S, Decl *D,
-                                              const AttributeList &Attr) {
+                                              const AttributeList &AL) {
   uint32_t Min = 0;
-  Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  Expr *MinExpr = AL.getArgAsExpr(0);
+  if (!checkUInt32Argument(S, AL, MinExpr, Min))
     return;
 
   uint32_t Max = 0;
-  Expr *MaxExpr = Attr.getArgAsExpr(1);
-  if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+  Expr *MaxExpr = AL.getArgAsExpr(1);
+  if (!checkUInt32Argument(S, AL, MaxExpr, Max))
     return;
 
   if (Min == 0 && Max != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_invalid)
-      << Attr.getName() << 0;
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid)
+      << AL.getName() << 0;
     return;
   }
   if (Min > Max) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_invalid)
-      << Attr.getName() << 1;
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid)
+      << AL.getName() << 1;
     return;
   }
 
   D->addAttr(::new (S.Context)
-             AMDGPUFlatWorkGroupSizeAttr(Attr.getLoc(), S.Context, Min, Max,
-                                         Attr.getAttributeSpellingListIndex()));
+             AMDGPUFlatWorkGroupSizeAttr(AL.getLoc(), S.Context, Min, Max,
+                                         AL.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUWavesPerEUAttr(Sema &S, Decl *D,
-                                       const AttributeList &Attr) {
+                                       const AttributeList &AL) {
   uint32_t Min = 0;
-  Expr *MinExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, MinExpr, Min))
+  Expr *MinExpr = AL.getArgAsExpr(0);
+  if (!checkUInt32Argument(S, AL, MinExpr, Min))
     return;
 
   uint32_t Max = 0;
-  if (Attr.getNumArgs() == 2) {
-    Expr *MaxExpr = Attr.getArgAsExpr(1);
-    if (!checkUInt32Argument(S, Attr, MaxExpr, Max))
+  if (AL.getNumArgs() == 2) {
+    Expr *MaxExpr = AL.getArgAsExpr(1);
+    if (!checkUInt32Argument(S, AL, MaxExpr, Max))
       return;
   }
 
   if (Min == 0 && Max != 0) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_invalid)
-      << Attr.getName() << 0;
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid)
+      << AL.getName() << 0;
     return;
   }
   if (Max != 0 && Min > Max) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_invalid)
-      << Attr.getName() << 1;
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_invalid)
+      << AL.getName() << 1;
     return;
   }
 
   D->addAttr(::new (S.Context)
-             AMDGPUWavesPerEUAttr(Attr.getLoc(), S.Context, Min, Max,
-                                  Attr.getAttributeSpellingListIndex()));
+             AMDGPUWavesPerEUAttr(AL.getLoc(), S.Context, Min, Max,
+                                  AL.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumSGPRAttr(Sema &S, Decl *D,
-                                    const AttributeList &Attr) {
+                                    const AttributeList &AL) {
   uint32_t NumSGPR = 0;
-  Expr *NumSGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumSGPRExpr, NumSGPR))
+  Expr *NumSGPRExpr = AL.getArgAsExpr(0);
+  if (!checkUInt32Argument(S, AL, NumSGPRExpr, NumSGPR))
     return;
 
   D->addAttr(::new (S.Context)
-             AMDGPUNumSGPRAttr(Attr.getLoc(), S.Context, NumSGPR,
-                               Attr.getAttributeSpellingListIndex()));
+             AMDGPUNumSGPRAttr(AL.getLoc(), S.Context, NumSGPR,
+                               AL.getAttributeSpellingListIndex()));
 }
 
 static void handleAMDGPUNumVGPRAttr(Sema &S, Decl *D,
-                                    const AttributeList &Attr) {
+                                    const AttributeList &AL) {
   uint32_t NumVGPR = 0;
-  Expr *NumVGPRExpr = Attr.getArgAsExpr(0);
-  if (!checkUInt32Argument(S, Attr, NumVGPRExpr, NumVGPR))
+  Expr *NumVGPRExpr = AL.getArgAsExpr(0);
+  if (!checkUInt32Argument(S, AL, NumVGPRExpr, NumVGPR))
     return;
 
   D->addAttr(::new (S.Context)
-             AMDGPUNumVGPRAttr(Attr.getLoc(), S.Context, NumVGPR,
-                               Attr.getAttributeSpellingListIndex()));
+             AMDGPUNumVGPRAttr(AL.getLoc(), S.Context, NumVGPR,
+                               AL.getAttributeSpellingListIndex()));
 }
 
 static void handleX86ForceAlignArgPointerAttr(Sema &S, Decl *D,
-                                              const AttributeList& Attr) {
+                                              const AttributeList& AL) {
   // If we try to apply it to a function pointer, don't warn, but don't
   // do anything, either. It doesn't matter anyway, because there's nothing
   // special about calling a force_align_arg_pointer function.
-  ValueDecl *VD = dyn_cast<ValueDecl>(D);
+  const auto *VD = dyn_cast<ValueDecl>(D);
   if (VD && VD->getType()->isFunctionPointerType())
     return;
   // Also don't warn on function pointer typedefs.
-  TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D);
+  const auto *TD = dyn_cast<TypedefNameDecl>(D);
   if (TD && (TD->getUnderlyingType()->isFunctionPointerType() ||
     TD->getUnderlyingType()->isFunctionType()))
     return;
   // Attribute can only be applied to function types.
   if (!isa<FunctionDecl>(D)) {
-    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type)
-      << Attr.getName() << ExpectedFunction;
+    S.Diag(AL.getLoc(), diag::warn_attribute_wrong_decl_type)
+      << AL.getName() << ExpectedFunction;
     return;
   }
 
   D->addAttr(::new (S.Context)
-              X86ForceAlignArgPointerAttr(Attr.getRange(), S.Context,
-                                        Attr.getAttributeSpellingListIndex()));
+              X86ForceAlignArgPointerAttr(AL.getRange(), S.Context,
+                                        AL.getAttributeSpellingListIndex()));
 }
 
-static void handleLayoutVersion(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleLayoutVersion(Sema &S, Decl *D, const AttributeList &AL) {
   uint32_t Version;
-  Expr *VersionExpr = static_cast<Expr *>(Attr.getArgAsExpr(0));
-  if (!checkUInt32Argument(S, Attr, Attr.getArgAsExpr(0), Version))
+  Expr *VersionExpr = static_cast<Expr *>(AL.getArgAsExpr(0));
+  if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(0), Version))
     return;
 
   // TODO: Investigate what happens with the next major version of MSVC.
   if (Version != LangOptions::MSVC2015) {
-    S.Diag(Attr.getLoc(), diag::err_attribute_argument_out_of_bounds)
-        << Attr.getName() << Version << VersionExpr->getSourceRange();
+    S.Diag(AL.getLoc(), diag::err_attribute_argument_out_of_bounds)
+        << AL.getName() << Version << VersionExpr->getSourceRange();
     return;
   }
 
   D->addAttr(::new (S.Context)
-                 LayoutVersionAttr(Attr.getRange(), S.Context, Version,
-                                   Attr.getAttributeSpellingListIndex()));
+                 LayoutVersionAttr(AL.getRange(), S.Context, Version,
+                                   AL.getAttributeSpellingListIndex()));
 }
 
 DLLImportAttr *Sema::mergeDLLImportAttr(Decl *D, SourceRange Range,
@@ -5616,7 +5586,7 @@ static void handleDLLAttr(Sema &S, Decl
     return;
   }
 
-  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+  if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
     if (FD->isInlined() && A.getKind() == AttributeList::AT_DLLImport &&
         !S.Context.getTargetInfo().getCXXABI().isMicrosoft()) {
       // MinGW doesn't allow dllimport on inline functions.
@@ -5626,7 +5596,7 @@ static void handleDLLAttr(Sema &S, Decl
     }
   }
 
-  if (auto *MD = dyn_cast<CXXMethodDecl>(D)) {
+  if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
     if (S.Context.getTargetInfo().getCXXABI().isMicrosoft() &&
         MD->getParent()->isLambda()) {
       S.Diag(A.getRange().getBegin(), diag::err_attribute_dll_lambda) << A.getName();
@@ -5655,7 +5625,7 @@ Sema::mergeMSInheritanceAttr(Decl *D, So
     D->dropAttr<MSInheritanceAttr>();
   }
 
-  CXXRecordDecl *RD = cast<CXXRecordDecl>(D);
+  auto *RD = cast<CXXRecordDecl>(D);
   if (RD->hasDefinition()) {
     if (checkMSInheritanceAttrOnDefinition(RD, Range, BestCase,
                                            SemanticSpelling)) {
@@ -5678,7 +5648,7 @@ Sema::mergeMSInheritanceAttr(Decl *D, So
       MSInheritanceAttr(Range, Context, BestCase, AttrSpellingListIndex);
 }
 
-static void handleCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleCapabilityAttr(Sema &S, Decl *D, const AttributeList &AL) {
   // The capability attributes take a single string parameter for the name of
   // the capability they represent. The lockable attribute does not take any
   // parameters. However, semantically, both attributes represent the same
@@ -5689,8 +5659,8 @@ static void handleCapabilityAttr(Sema &S
   // literal will be considered a "mutex."
   StringRef N("mutex");
   SourceLocation LiteralLoc;
-  if (Attr.getKind() == AttributeList::AT_Capability &&
-      !S.checkStringLiteralArgumentAttr(Attr, 0, N, &LiteralLoc))
+  if (AL.getKind() == AttributeList::AT_Capability &&
+      !S.checkStringLiteralArgumentAttr(AL, 0, N, &LiteralLoc))
     return;
 
   // Currently, there are only two names allowed for a capability: role and
@@ -5698,80 +5668,80 @@ static void handleCapabilityAttr(Sema &S
   if (!N.equals_lower("mutex") && !N.equals_lower("role"))
     S.Diag(LiteralLoc, diag::warn_invalid_capability_name) << N;
 
-  D->addAttr(::new (S.Context) CapabilityAttr(Attr.getRange(), S.Context, N,
-                                        Attr.getAttributeSpellingListIndex()));
+  D->addAttr(::new (S.Context) CapabilityAttr(AL.getRange(), S.Context, N,
+                                        AL.getAttributeSpellingListIndex()));
 }
 
 static void handleAssertCapabilityAttr(Sema &S, Decl *D,
-                                       const AttributeList &Attr) {
+                                       const AttributeList &AL) {
   SmallVector<Expr*, 1> Args;
-  if (!checkLockFunAttrCommon(S, D, Attr, Args))
+  if (!checkLockFunAttrCommon(S, D, AL, Args))
     return;
 
-  D->addAttr(::new (S.Context) AssertCapabilityAttr(Attr.getRange(), S.Context,
+  D->addAttr(::new (S.Context) AssertCapabilityAttr(AL.getRange(), S.Context,
                                                     Args.data(), Args.size(),
-                                        Attr.getAttributeSpellingListIndex()));
+                                        AL.getAttributeSpellingListIndex()));
 }
 
 static void handleAcquireCapabilityAttr(Sema &S, Decl *D,
-                                        const AttributeList &Attr) {
+                                        const AttributeList &AL) {
   SmallVector<Expr*, 1> Args;
-  if (!checkLockFunAttrCommon(S, D, Attr, Args))
+  if (!checkLockFunAttrCommon(S, D, AL, Args))
     return;
 
-  D->addAttr(::new (S.Context) AcquireCapabilityAttr(Attr.getRange(),
+  D->addAttr(::new (S.Context) AcquireCapabilityAttr(AL.getRange(),
                                                      S.Context,
                                                      Args.data(), Args.size(),
-                                        Attr.getAttributeSpellingListIndex()));
+                                        AL.getAttributeSpellingListIndex()));
 }
 
 static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D,
-                                           const AttributeList &Attr) {
+                                           const AttributeList &AL) {
   SmallVector<Expr*, 2> Args;
-  if (!checkTryLockFunAttrCommon(S, D, Attr, Args))
+  if (!checkTryLockFunAttrCommon(S, D, AL, Args))
     return;
 
-  D->addAttr(::new (S.Context) TryAcquireCapabilityAttr(Attr.getRange(),
+  D->addAttr(::new (S.Context) TryAcquireCapabilityAttr(AL.getRange(),
                                                         S.Context,
-                                                        Attr.getArgAsExpr(0),
+                                                        AL.getArgAsExpr(0),
                                                         Args.data(),
                                                         Args.size(),
-                                        Attr.getAttributeSpellingListIndex()));
+                                        AL.getAttributeSpellingListIndex()));
 }
 
 static void handleReleaseCapabilityAttr(Sema &S, Decl *D,
-                                        const AttributeList &Attr) {
+                                        const AttributeList &AL) {
   // Check that all arguments are lockable objects.
   SmallVector<Expr *, 1> Args;
-  checkAttrArgsAreCapabilityObjs(S, D, Attr, Args, 0, true);
+  checkAttrArgsAreCapabilityObjs(S, D, AL, Args, 0, true);
 
   D->addAttr(::new (S.Context) ReleaseCapabilityAttr(
-      Attr.getRange(), S.Context, Args.data(), Args.size(),
-      Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, Args.data(), Args.size(),
+      AL.getAttributeSpellingListIndex()));
 }
 
 static void handleRequiresCapabilityAttr(Sema &S, Decl *D,
-                                         const AttributeList &Attr) {
-  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+                                         const AttributeList &AL) {
+  if (!checkAttributeAtLeastNumArgs(S, AL, 1))
     return;
 
   // check that all arguments are lockable objects
   SmallVector<Expr*, 1> Args;
-  checkAttrArgsAreCapabilityObjs(S, D, Attr, Args);
+  checkAttrArgsAreCapabilityObjs(S, D, AL, Args);
   if (Args.empty())
     return;
 
   RequiresCapabilityAttr *RCA = ::new (S.Context)
-    RequiresCapabilityAttr(Attr.getRange(), S.Context, Args.data(),
-                           Args.size(), Attr.getAttributeSpellingListIndex());
+    RequiresCapabilityAttr(AL.getRange(), S.Context, Args.data(),
+                           Args.size(), AL.getAttributeSpellingListIndex());
 
   D->addAttr(RCA);
 }
 
-static void handleDeprecatedAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (auto *NSD = dyn_cast<NamespaceDecl>(D)) {
+static void handleDeprecatedAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (const auto *NSD = dyn_cast<NamespaceDecl>(D)) {
     if (NSD->isAnonymousNamespace()) {
-      S.Diag(Attr.getLoc(), diag::warn_deprecated_anonymous_namespace);
+      S.Diag(AL.getLoc(), diag::warn_deprecated_anonymous_namespace);
       // Do not want to attach the attribute to the namespace because that will
       // cause confusing diagnostic reports for uses of declarations within the
       // namespace.
@@ -5781,25 +5751,25 @@ static void handleDeprecatedAttr(Sema &S
 
   // Handle the cases where the attribute has a text message.
   StringRef Str, Replacement;
-  if (Attr.isArgExpr(0) && Attr.getArgAsExpr(0) &&
-      !S.checkStringLiteralArgumentAttr(Attr, 0, Str))
+  if (AL.isArgExpr(0) && AL.getArgAsExpr(0) &&
+      !S.checkStringLiteralArgumentAttr(AL, 0, Str))
     return;
 
   // Only support a single optional message for Declspec and CXX11.
-  if (Attr.isDeclspecAttribute() || Attr.isCXX11Attribute())
-    checkAttributeAtMostNumArgs(S, Attr, 1);
-  else if (Attr.isArgExpr(1) && Attr.getArgAsExpr(1) &&
-           !S.checkStringLiteralArgumentAttr(Attr, 1, Replacement))
+  if (AL.isDeclspecAttribute() || AL.isCXX11Attribute())
+    checkAttributeAtMostNumArgs(S, AL, 1);
+  else if (AL.isArgExpr(1) && AL.getArgAsExpr(1) &&
+           !S.checkStringLiteralArgumentAttr(AL, 1, Replacement))
     return;
 
   if (!S.getLangOpts().CPlusPlus14)
-    if (Attr.isCXX11Attribute() &&
-        !(Attr.hasScope() && Attr.getScopeName()->isStr("gnu")))
-      S.Diag(Attr.getLoc(), diag::ext_cxx14_attr) << Attr.getName();
+    if (AL.isCXX11Attribute() &&
+        !(AL.hasScope() && AL.getScopeName()->isStr("gnu")))
+      S.Diag(AL.getLoc(), diag::ext_cxx14_attr) << AL.getName();
 
   D->addAttr(::new (S.Context)
-                 DeprecatedAttr(Attr.getRange(), S.Context, Str, Replacement,
-                                Attr.getAttributeSpellingListIndex()));
+                 DeprecatedAttr(AL.getRange(), S.Context, Str, Replacement,
+                                AL.getAttributeSpellingListIndex()));
 }
 
 static bool isGlobalVar(const Decl *D) {
@@ -5808,35 +5778,35 @@ static bool isGlobalVar(const Decl *D) {
   return false;
 }
 
-static void handleNoSanitizeAttr(Sema &S, Decl *D, const AttributeList &Attr) {
-  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+static void handleNoSanitizeAttr(Sema &S, Decl *D, const AttributeList &AL) {
+  if (!checkAttributeAtLeastNumArgs(S, AL, 1))
     return;
 
   std::vector<StringRef> Sanitizers;
 
-  for (unsigned I = 0, E = Attr.getNumArgs(); I != E; ++I) {
+  for (unsigned I = 0, E = AL.getNumArgs(); I != E; ++I) {
     StringRef SanitizerName;
     SourceLocation LiteralLoc;
 
-    if (!S.checkStringLiteralArgumentAttr(Attr, I, SanitizerName, &LiteralLoc))
+    if (!S.checkStringLiteralArgumentAttr(AL, I, SanitizerName, &LiteralLoc))
       return;
 
     if (parseSanitizerValue(SanitizerName, /*AllowGroups=*/true) == 0)
       S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << SanitizerName;
     else if (isGlobalVar(D) && SanitizerName != "address")
       S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
-          << Attr.getName() << ExpectedFunctionOrMethod;
+          << AL.getName() << ExpectedFunctionOrMethod;
     Sanitizers.push_back(SanitizerName);
   }
 
   D->addAttr(::new (S.Context) NoSanitizeAttr(
-      Attr.getRange(), S.Context, Sanitizers.data(), Sanitizers.size(),
-      Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, Sanitizers.data(), Sanitizers.size(),
+      AL.getAttributeSpellingListIndex()));
 }
 
 static void handleNoSanitizeSpecificAttr(Sema &S, Decl *D,
-                                         const AttributeList &Attr) {
-  StringRef AttrName = Attr.getName()->getName();
+                                         const AttributeList &AL) {
+  StringRef AttrName = AL.getName()->getName();
   normalizeName(AttrName);
   StringRef SanitizerName = llvm::StringSwitch<StringRef>(AttrName)
                                 .Case("no_address_safety_analysis", "address")
@@ -5845,63 +5815,63 @@ static void handleNoSanitizeSpecificAttr
                                 .Case("no_sanitize_memory", "memory");
   if (isGlobalVar(D) && SanitizerName != "address")
     S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
-        << Attr.getName() << ExpectedFunction;
+        << AL.getName() << ExpectedFunction;
   D->addAttr(::new (S.Context)
-                 NoSanitizeAttr(Attr.getRange(), S.Context, &SanitizerName, 1,
-                                Attr.getAttributeSpellingListIndex()));
+                 NoSanitizeAttr(AL.getRange(), S.Context, &SanitizerName, 1,
+                                AL.getAttributeSpellingListIndex()));
 }
 
 static void handleInternalLinkageAttr(Sema &S, Decl *D,
-                                      const AttributeList &Attr) {
+                                      const AttributeList &AL) {
   if (InternalLinkageAttr *Internal =
-          S.mergeInternalLinkageAttr(D, Attr.getRange(), Attr.getName(),
-                                     Attr.getAttributeSpellingListIndex()))
+          S.mergeInternalLinkageAttr(D, AL.getRange(), AL.getName(),
+                                     AL.getAttributeSpellingListIndex()))
     D->addAttr(Internal);
 }
 
-static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const AttributeList &Attr) {
+static void handleOpenCLNoSVMAttr(Sema &S, Decl *D, const AttributeList &AL) {
   if (S.LangOpts.OpenCLVersion != 200)
-    S.Diag(Attr.getLoc(), diag::err_attribute_requires_opencl_version)
-        << Attr.getName() << "2.0" << 0;
+    S.Diag(AL.getLoc(), diag::err_attribute_requires_opencl_version)
+        << AL.getName() << "2.0" << 0;
   else
-    S.Diag(Attr.getLoc(), diag::warn_opencl_attr_deprecated_ignored)
-        << Attr.getName() << "2.0";
+    S.Diag(AL.getLoc(), diag::warn_opencl_attr_deprecated_ignored)
+        << AL.getName() << "2.0";
 }
 
 /// Handles semantic checking for features that are common to all attributes,
 /// such as checking whether a parameter was properly specified, or the correct
 /// number of arguments were passed, etc.
-static bool handleCommonAttributeFeatures(Sema &S, Scope *scope, Decl *D,
-                                          const AttributeList &Attr) {
+static bool handleCommonAttributeFeatures(Sema &S, Decl *D,
+                                          const AttributeList &AL) {
   // Several attributes carry different semantics than the parsing requires, so
   // those are opted out of the common argument checks.
   //
   // We also bail on unknown and ignored attributes because those are handled
   // as part of the target-specific handling logic.
-  if (Attr.getKind() == AttributeList::UnknownAttribute)
+  if (AL.getKind() == AttributeList::UnknownAttribute)
     return false;
   // Check whether the attribute requires specific language extensions to be
   // enabled.
-  if (!Attr.diagnoseLangOpts(S))
+  if (!AL.diagnoseLangOpts(S))
     return true;
   // Check whether the attribute appertains to the given subject.
-  if (!Attr.diagnoseAppertainsTo(S, D))
+  if (!AL.diagnoseAppertainsTo(S, D))
     return true;
-  if (Attr.hasCustomParsing())
+  if (AL.hasCustomParsing())
     return false;
 
-  if (Attr.getMinArgs() == Attr.getMaxArgs()) {
+  if (AL.getMinArgs() == AL.getMaxArgs()) {
     // If there are no optional arguments, then checking for the argument count
     // is trivial.
-    if (!checkAttributeNumArgs(S, Attr, Attr.getMinArgs()))
+    if (!checkAttributeNumArgs(S, AL, AL.getMinArgs()))
       return true;
   } else {
     // There are optional arguments, so checking is slightly more involved.
-    if (Attr.getMinArgs() &&
-        !checkAttributeAtLeastNumArgs(S, Attr, Attr.getMinArgs()))
+    if (AL.getMinArgs() &&
+        !checkAttributeAtLeastNumArgs(S, AL, AL.getMinArgs()))
       return true;
-    else if (!Attr.hasVariadicArg() && Attr.getMaxArgs() &&
-             !checkAttributeAtMostNumArgs(S, Attr, Attr.getMaxArgs()))
+    else if (!AL.hasVariadicArg() && AL.getMaxArgs() &&
+             !checkAttributeAtMostNumArgs(S, AL, AL.getMaxArgs()))
       return true;
   }
 
@@ -5909,13 +5879,13 @@ static bool handleCommonAttributeFeature
 }
 
 static void handleOpenCLAccessAttr(Sema &S, Decl *D,
-                                   const AttributeList &Attr) {
+                                   const AttributeList &AL) {
   if (D->isInvalidDecl())
     return;
 
   // Check if there is only one access qualifier.
   if (D->hasAttr<OpenCLAccessAttr>()) {
-    S.Diag(Attr.getLoc(), diag::err_opencl_multiple_access_qualifiers)
+    S.Diag(AL.getLoc(), diag::err_opencl_multiple_access_qualifiers)
         << D->getSourceRange();
     D->setInvalidDecl(true);
     return;
@@ -5926,12 +5896,12 @@ static void handleOpenCLAccessAttr(Sema
   // OpenCL v2.0 s6.13.6 - A kernel cannot read from and write to the same pipe
   // object. Using the read_write (or __read_write) qualifier with the pipe
   // qualifier is a compilation error.
-  if (const ParmVarDecl *PDecl = dyn_cast<ParmVarDecl>(D)) {
+  if (const auto *PDecl = dyn_cast<ParmVarDecl>(D)) {
     const Type *DeclTy = PDecl->getType().getCanonicalType().getTypePtr();
-    if (Attr.getName()->getName().find("read_write") != StringRef::npos) {
+    if (AL.getName()->getName().find("read_write") != StringRef::npos) {
       if (S.getLangOpts().OpenCLVersion < 200 || DeclTy->isPipeType()) {
-        S.Diag(Attr.getLoc(), diag::err_opencl_invalid_read_write)
-            << Attr.getName() << PDecl->getType() << DeclTy->isImageType();
+        S.Diag(AL.getLoc(), diag::err_opencl_invalid_read_write)
+            << AL.getName() << PDecl->getType() << DeclTy->isImageType();
         D->setInvalidDecl(true);
         return;
       }
@@ -5939,7 +5909,7 @@ static void handleOpenCLAccessAttr(Sema
   }
 
   D->addAttr(::new (S.Context) OpenCLAccessAttr(
-      Attr.getRange(), S.Context, Attr.getAttributeSpellingListIndex()));
+      AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
 }
 
 //===----------------------------------------------------------------------===//
@@ -5950,444 +5920,444 @@ static void handleOpenCLAccessAttr(Sema
 /// the attribute applies to decls.  If the attribute is a type attribute, just
 /// silently ignore it if a GNU attribute.
 static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
-                                 const AttributeList &Attr,
+                                 const AttributeList &AL,
                                  bool IncludeCXX11Attributes) {
-  if (Attr.isInvalid() || Attr.getKind() == AttributeList::IgnoredAttribute)
+  if (AL.isInvalid() || AL.getKind() == AttributeList::IgnoredAttribute)
     return;
 
   // Ignore C++11 attributes on declarator chunks: they appertain to the type
   // instead.
-  if (Attr.isCXX11Attribute() && !IncludeCXX11Attributes)
+  if (AL.isCXX11Attribute() && !IncludeCXX11Attributes)
     return;
 
   // Unknown attributes are automatically warned on. Target-specific attributes
   // which do not apply to the current target architecture are treated as
   // though they were unknown attributes.
-  if (Attr.getKind() == AttributeList::UnknownAttribute ||
-      !Attr.existsInTarget(S.Context.getTargetInfo())) {
-    S.Diag(Attr.getLoc(), Attr.isDeclspecAttribute()
+  if (AL.getKind() == AttributeList::UnknownAttribute ||
+      !AL.existsInTarget(S.Context.getTargetInfo())) {
+    S.Diag(AL.getLoc(), AL.isDeclspecAttribute()
                               ? diag::warn_unhandled_ms_attribute_ignored
                               : diag::warn_unknown_attribute_ignored)
-        << Attr.getName();
+        << AL.getName();
     return;
   }
 
-  if (handleCommonAttributeFeatures(S, scope, D, Attr))
+  if (handleCommonAttributeFeatures(S, D, AL))
     return;
 
-  switch (Attr.getKind()) {
+  switch (AL.getKind()) {
   default:
-    if (!Attr.isStmtAttr()) {
+    if (!AL.isStmtAttr()) {
       // Type attributes are handled elsewhere; silently move on.
-      assert(Attr.isTypeAttr() && "Non-type attribute not handled");
+      assert(AL.isTypeAttr() && "Non-type attribute not handled");
       break;
     }
-    S.Diag(Attr.getLoc(), diag::err_stmt_attribute_invalid_on_decl)
-        << Attr.getName() << D->getLocation();
+    S.Diag(AL.getLoc(), diag::err_stmt_attribute_invalid_on_decl)
+        << AL.getName() << D->getLocation();
     break;
   case AttributeList::AT_Interrupt:
-    handleInterruptAttr(S, D, Attr);
+    handleInterruptAttr(S, D, AL);
     break;
   case AttributeList::AT_X86ForceAlignArgPointer:
-    handleX86ForceAlignArgPointerAttr(S, D, Attr);
+    handleX86ForceAlignArgPointerAttr(S, D, AL);
     break;
   case AttributeList::AT_DLLExport:
   case AttributeList::AT_DLLImport:
-    handleDLLAttr(S, D, Attr);
+    handleDLLAttr(S, D, AL);
     break;
   case AttributeList::AT_Mips16:
     handleSimpleAttributeWithExclusions<Mips16Attr, MicroMipsAttr,
-                                        MipsInterruptAttr>(S, D, Attr);
+                                        MipsInterruptAttr>(S, D, AL);
     break;
   case AttributeList::AT_NoMips16:
-    handleSimpleAttribute<NoMips16Attr>(S, D, Attr);
+    handleSimpleAttribute<NoMips16Attr>(S, D, AL);
     break;
   case AttributeList::AT_MicroMips:
-    handleSimpleAttributeWithExclusions<MicroMipsAttr, Mips16Attr>(S, D, Attr);
+    handleSimpleAttributeWithExclusions<MicroMipsAttr, Mips16Attr>(S, D, AL);
     break;
   case AttributeList::AT_NoMicroMips:
-    handleSimpleAttribute<NoMicroMipsAttr>(S, D, Attr);
+    handleSimpleAttribute<NoMicroMipsAttr>(S, D, AL);
     break;
   case AttributeList::AT_MipsLongCall:
     handleSimpleAttributeWithExclusions<MipsLongCallAttr, MipsShortCallAttr>(
-        S, D, Attr);
+        S, D, AL);
     break;
   case AttributeList::AT_MipsShortCall:
     handleSimpleAttributeWithExclusions<MipsShortCallAttr, MipsLongCallAttr>(
-        S, D, Attr);
+        S, D, AL);
     break;
   case AttributeList::AT_AMDGPUFlatWorkGroupSize:
-    handleAMDGPUFlatWorkGroupSizeAttr(S, D, Attr);
+    handleAMDGPUFlatWorkGroupSizeAttr(S, D, AL);
     break;
   case AttributeList::AT_AMDGPUWavesPerEU:
-    handleAMDGPUWavesPerEUAttr(S, D, Attr);
+    handleAMDGPUWavesPerEUAttr(S, D, AL);
     break;
   case AttributeList::AT_AMDGPUNumSGPR:
-    handleAMDGPUNumSGPRAttr(S, D, Attr);
+    handleAMDGPUNumSGPRAttr(S, D, AL);
     break;
   case AttributeList::AT_AMDGPUNumVGPR:
-    handleAMDGPUNumVGPRAttr(S, D, Attr);
+    handleAMDGPUNumVGPRAttr(S, D, AL);
     break;
   case AttributeList::AT_AVRSignal:
-    handleAVRSignalAttr(S, D, Attr);
+    handleAVRSignalAttr(S, D, AL);
     break;
   case AttributeList::AT_IBAction:
-    handleSimpleAttribute<IBActionAttr>(S, D, Attr);
+    handleSimpleAttribute<IBActionAttr>(S, D, AL);
     break;
   case AttributeList::AT_IBOutlet:
-    handleIBOutlet(S, D, Attr);
+    handleIBOutlet(S, D, AL);
     break;
   case AttributeList::AT_IBOutletCollection:
-    handleIBOutletCollection(S, D, Attr);
+    handleIBOutletCollection(S, D, AL);
     break;
   case AttributeList::AT_IFunc:
-    handleIFuncAttr(S, D, Attr);
+    handleIFuncAttr(S, D, AL);
     break;
   case AttributeList::AT_Alias:
-    handleAliasAttr(S, D, Attr);
+    handleAliasAttr(S, D, AL);
     break;
   case AttributeList::AT_Aligned:
-    handleAlignedAttr(S, D, Attr);
+    handleAlignedAttr(S, D, AL);
     break;
   case AttributeList::AT_AlignValue:
-    handleAlignValueAttr(S, D, Attr);
+    handleAlignValueAttr(S, D, AL);
     break;
   case AttributeList::AT_AllocSize:
-    handleAllocSizeAttr(S, D, Attr);
+    handleAllocSizeAttr(S, D, AL);
     break;
   case AttributeList::AT_AlwaysInline:
-    handleAlwaysInlineAttr(S, D, Attr);
+    handleAlwaysInlineAttr(S, D, AL);
     break;
   case AttributeList::AT_Artificial:
     handleSimpleAttribute<ArtificialAttr>(S, D, Attr);
     break;
   case AttributeList::AT_AnalyzerNoReturn:
-    handleAnalyzerNoReturnAttr(S, D, Attr);
+    handleAnalyzerNoReturnAttr(S, D, AL);
     break;
   case AttributeList::AT_TLSModel:
-    handleTLSModelAttr(S, D, Attr);
+    handleTLSModelAttr(S, D, AL);
     break;
   case AttributeList::AT_Annotate:
-    handleAnnotateAttr(S, D, Attr);
+    handleAnnotateAttr(S, D, AL);
     break;
   case AttributeList::AT_Availability:
-    handleAvailabilityAttr(S, D, Attr);
+    handleAvailabilityAttr(S, D, AL);
     break;
   case AttributeList::AT_CarriesDependency:
-    handleDependencyAttr(S, scope, D, Attr);
+    handleDependencyAttr(S, scope, D, AL);
     break;
   case AttributeList::AT_Common:
-    handleCommonAttr(S, D, Attr);
+    handleCommonAttr(S, D, AL);
     break;
   case AttributeList::AT_CUDAConstant:
-    handleConstantAttr(S, D, Attr);
+    handleConstantAttr(S, D, AL);
     break;
   case AttributeList::AT_PassObjectSize:
-    handlePassObjectSizeAttr(S, D, Attr);
+    handlePassObjectSizeAttr(S, D, AL);
     break;
   case AttributeList::AT_Constructor:
-    handleConstructorAttr(S, D, Attr);
+    handleConstructorAttr(S, D, AL);
     break;
   case AttributeList::AT_CXX11NoReturn:
-    handleSimpleAttribute<CXX11NoReturnAttr>(S, D, Attr);
+    handleSimpleAttribute<CXX11NoReturnAttr>(S, D, AL);
     break;
   case AttributeList::AT_Deprecated:
-    handleDeprecatedAttr(S, D, Attr);
+    handleDeprecatedAttr(S, D, AL);
     break;
   case AttributeList::AT_Destructor:
-    handleDestructorAttr(S, D, Attr);
+    handleDestructorAttr(S, D, AL);
     break;
   case AttributeList::AT_EnableIf:
-    handleEnableIfAttr(S, D, Attr);
+    handleEnableIfAttr(S, D, AL);
     break;
   case AttributeList::AT_DiagnoseIf:
-    handleDiagnoseIfAttr(S, D, Attr);
+    handleDiagnoseIfAttr(S, D, AL);
     break;
   case AttributeList::AT_ExtVectorType:
-    handleExtVectorTypeAttr(S, scope, D, Attr);
+    handleExtVectorTypeAttr(S, D, AL);
     break;
   case AttributeList::AT_ExternalSourceSymbol:
-    handleExternalSourceSymbolAttr(S, D, Attr);
+    handleExternalSourceSymbolAttr(S, D, AL);
     break;
   case AttributeList::AT_MinSize:
-    handleMinSizeAttr(S, D, Attr);
+    handleMinSizeAttr(S, D, AL);
     break;
   case AttributeList::AT_OptimizeNone:
-    handleOptimizeNoneAttr(S, D, Attr);
+    handleOptimizeNoneAttr(S, D, AL);
     break;
   case AttributeList::AT_FlagEnum:
-    handleSimpleAttribute<FlagEnumAttr>(S, D, Attr);
+    handleSimpleAttribute<FlagEnumAttr>(S, D, AL);
     break;
   case AttributeList::AT_EnumExtensibility:
-    handleEnumExtensibilityAttr(S, D, Attr);
+    handleEnumExtensibilityAttr(S, D, AL);
     break;
   case AttributeList::AT_Flatten:
-    handleSimpleAttribute<FlattenAttr>(S, D, Attr);
+    handleSimpleAttribute<FlattenAttr>(S, D, AL);
     break;
   case AttributeList::AT_Format:
-    handleFormatAttr(S, D, Attr);
+    handleFormatAttr(S, D, AL);
     break;
   case AttributeList::AT_FormatArg:
-    handleFormatArgAttr(S, D, Attr);
+    handleFormatArgAttr(S, D, AL);
     break;
   case AttributeList::AT_CUDAGlobal:
-    handleGlobalAttr(S, D, Attr);
+    handleGlobalAttr(S, D, AL);
     break;
   case AttributeList::AT_CUDADevice:
     handleSimpleAttributeWithExclusions<CUDADeviceAttr, CUDAGlobalAttr>(S, D,
-                                                                        Attr);
+                                                                        AL);
     break;
   case AttributeList::AT_CUDAHost:
     handleSimpleAttributeWithExclusions<CUDAHostAttr, CUDAGlobalAttr>(S, D,
-                                                                      Attr);
+                                                                      AL);
     break;
   case AttributeList::AT_GNUInline:
-    handleGNUInlineAttr(S, D, Attr);
+    handleGNUInlineAttr(S, D, AL);
     break;
   case AttributeList::AT_CUDALaunchBounds:
-    handleLaunchBoundsAttr(S, D, Attr);
+    handleLaunchBoundsAttr(S, D, AL);
     break;
   case AttributeList::AT_Restrict:
-    handleRestrictAttr(S, D, Attr);
+    handleRestrictAttr(S, D, AL);
     break;
   case AttributeList::AT_MayAlias:
-    handleSimpleAttribute<MayAliasAttr>(S, D, Attr);
+    handleSimpleAttribute<MayAliasAttr>(S, D, AL);
     break;
   case AttributeList::AT_Mode:
-    handleModeAttr(S, D, Attr);
+    handleModeAttr(S, D, AL);
     break;
   case AttributeList::AT_NoAlias:
-    handleSimpleAttribute<NoAliasAttr>(S, D, Attr);
+    handleSimpleAttribute<NoAliasAttr>(S, D, AL);
     break;
   case AttributeList::AT_NoCommon:
-    handleSimpleAttribute<NoCommonAttr>(S, D, Attr);
+    handleSimpleAttribute<NoCommonAttr>(S, D, AL);
     break;
   case AttributeList::AT_NoSplitStack:
-    handleSimpleAttribute<NoSplitStackAttr>(S, D, Attr);
+    handleSimpleAttribute<NoSplitStackAttr>(S, D, AL);
     break;
   case AttributeList::AT_NonNull:
-    if (ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(D))
-      handleNonNullAttrParameter(S, PVD, Attr);
+    if (auto *PVD = dyn_cast<ParmVarDecl>(D))
+      handleNonNullAttrParameter(S, PVD, AL);
     else
-      handleNonNullAttr(S, D, Attr);
+      handleNonNullAttr(S, D, AL);
     break;
   case AttributeList::AT_ReturnsNonNull:
-    handleReturnsNonNullAttr(S, D, Attr);
+    handleReturnsNonNullAttr(S, D, AL);
     break;
   case AttributeList::AT_NoEscape:
-    handleNoEscapeAttr(S, D, Attr);
+    handleNoEscapeAttr(S, D, AL);
     break;
   case AttributeList::AT_AssumeAligned:
-    handleAssumeAlignedAttr(S, D, Attr);
+    handleAssumeAlignedAttr(S, D, AL);
     break;
   case AttributeList::AT_AllocAlign:
-    handleAllocAlignAttr(S, D, Attr);
+    handleAllocAlignAttr(S, D, AL);
     break;
   case AttributeList::AT_Overloadable:
-    handleSimpleAttribute<OverloadableAttr>(S, D, Attr);
+    handleSimpleAttribute<OverloadableAttr>(S, D, AL);
     break;
   case AttributeList::AT_Ownership:
-    handleOwnershipAttr(S, D, Attr);
+    handleOwnershipAttr(S, D, AL);
     break;
   case AttributeList::AT_Cold:
-    handleColdAttr(S, D, Attr);
+    handleColdAttr(S, D, AL);
     break;
   case AttributeList::AT_Hot:
-    handleHotAttr(S, D, Attr);
+    handleHotAttr(S, D, AL);
     break;
   case AttributeList::AT_Naked:
-    handleNakedAttr(S, D, Attr);
+    handleNakedAttr(S, D, AL);
     break;
   case AttributeList::AT_NoReturn:
-    handleNoReturnAttr(S, D, Attr);
+    handleNoReturnAttr(S, D, AL);
     break;
   case AttributeList::AT_NoThrow:
-    handleSimpleAttribute<NoThrowAttr>(S, D, Attr);
+    handleSimpleAttribute<NoThrowAttr>(S, D, AL);
     break;
   case AttributeList::AT_CUDAShared:
-    handleSharedAttr(S, D, Attr);
+    handleSharedAttr(S, D, AL);
     break;
   case AttributeList::AT_VecReturn:
-    handleVecReturnAttr(S, D, Attr);
+    handleVecReturnAttr(S, D, AL);
     break;
   case AttributeList::AT_ObjCOwnership:
-    handleObjCOwnershipAttr(S, D, Attr);
+    handleObjCOwnershipAttr(S, D, AL);
     break;
   case AttributeList::AT_ObjCPreciseLifetime:
-    handleObjCPreciseLifetimeAttr(S, D, Attr);
+    handleObjCPreciseLifetimeAttr(S, D, AL);
     break;
   case AttributeList::AT_ObjCReturnsInnerPointer:
-    handleObjCReturnsInnerPointerAttr(S, D, Attr);
+    handleObjCReturnsInnerPointerAttr(S, D, AL);
     break;
   case AttributeList::AT_ObjCRequiresSuper:
-    handleObjCRequiresSuperAttr(S, D, Attr);
+    handleObjCRequiresSuperAttr(S, D, AL);
     break;
   case AttributeList::AT_ObjCBridge:
-    handleObjCBridgeAttr(S, scope, D, Attr);
+    handleObjCBridgeAttr(S, D, AL);
     break;
   case AttributeList::AT_ObjCBridgeMutable:
-    handleObjCBridgeMutableAttr(S, scope, D, Attr);
+    handleObjCBridgeMutableAttr(S, D, AL);
     break;
   case AttributeList::AT_ObjCBridgeRelated:
-    handleObjCBridgeRelatedAttr(S, scope, D, Attr);
+    handleObjCBridgeRelatedAttr(S, D, AL);
     break;
   case AttributeList::AT_ObjCDesignatedInitializer:
-    handleObjCDesignatedInitializer(S, D, Attr);
+    handleObjCDesignatedInitializer(S, D, AL);
     break;
   case AttributeList::AT_ObjCRuntimeName:
-    handleObjCRuntimeName(S, D, Attr);
+    handleObjCRuntimeName(S, D, AL);
     break;
    case AttributeList::AT_ObjCRuntimeVisible:
-    handleSimpleAttribute<ObjCRuntimeVisibleAttr>(S, D, Attr);
+    handleSimpleAttribute<ObjCRuntimeVisibleAttr>(S, D, AL);
     break;
   case AttributeList::AT_ObjCBoxable:
-    handleObjCBoxable(S, D, Attr);
+    handleObjCBoxable(S, D, AL);
     break;
   case AttributeList::AT_CFAuditedTransfer:
-    handleCFAuditedTransferAttr(S, D, Attr);
+    handleCFAuditedTransferAttr(S, D, AL);
     break;
   case AttributeList::AT_CFUnknownTransfer:
-    handleCFUnknownTransferAttr(S, D, Attr);
+    handleCFUnknownTransferAttr(S, D, AL);
     break;
   case AttributeList::AT_CFConsumed:
   case AttributeList::AT_NSConsumed:
-    handleNSConsumedAttr(S, D, Attr);
+    handleNSConsumedAttr(S, D, AL);
     break;
   case AttributeList::AT_NSConsumesSelf:
-    handleSimpleAttribute<NSConsumesSelfAttr>(S, D, Attr);
+    handleSimpleAttribute<NSConsumesSelfAttr>(S, D, AL);
     break;
   case AttributeList::AT_NSReturnsAutoreleased:
   case AttributeList::AT_NSReturnsNotRetained:
   case AttributeList::AT_CFReturnsNotRetained:
   case AttributeList::AT_NSReturnsRetained:
   case AttributeList::AT_CFReturnsRetained:
-    handleNSReturnsRetainedAttr(S, D, Attr);
+    handleNSReturnsRetainedAttr(S, D, AL);
     break;
   case AttributeList::AT_WorkGroupSizeHint:
-    handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, Attr);
+    handleWorkGroupSize<WorkGroupSizeHintAttr>(S, D, AL);
     break;
   case AttributeList::AT_ReqdWorkGroupSize:
-    handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, Attr);
+    handleWorkGroupSize<ReqdWorkGroupSizeAttr>(S, D, AL);
     break;
   case AttributeList::AT_OpenCLIntelReqdSubGroupSize:
-    handleSubGroupSize(S, D, Attr);
+    handleSubGroupSize(S, D, AL);
     break;
   case AttributeList::AT_VecTypeHint:
-    handleVecTypeHint(S, D, Attr);
+    handleVecTypeHint(S, D, AL);
     break;
   case AttributeList::AT_RequireConstantInit:
-    handleSimpleAttribute<RequireConstantInitAttr>(S, D, Attr);
+    handleSimpleAttribute<RequireConstantInitAttr>(S, D, AL);
     break;
   case AttributeList::AT_InitPriority:
-    handleInitPriorityAttr(S, D, Attr);
+    handleInitPriorityAttr(S, D, AL);
     break;
   case AttributeList::AT_Packed:
-    handlePackedAttr(S, D, Attr);
+    handlePackedAttr(S, D, AL);
     break;
   case AttributeList::AT_Section:
-    handleSectionAttr(S, D, Attr);
+    handleSectionAttr(S, D, AL);
     break;
   case AttributeList::AT_Target:
-    handleTargetAttr(S, D, Attr);
+    handleTargetAttr(S, D, AL);
     break;
   case AttributeList::AT_Unavailable:
-    handleAttrWithMessage<UnavailableAttr>(S, D, Attr);
+    handleAttrWithMessage<UnavailableAttr>(S, D, AL);
     break;
   case AttributeList::AT_ArcWeakrefUnavailable:
-    handleSimpleAttribute<ArcWeakrefUnavailableAttr>(S, D, Attr);
+    handleSimpleAttribute<ArcWeakrefUnavailableAttr>(S, D, AL);
     break;
   case AttributeList::AT_ObjCRootClass:
-    handleSimpleAttribute<ObjCRootClassAttr>(S, D, Attr);
+    handleSimpleAttribute<ObjCRootClassAttr>(S, D, AL);
     break;
   case AttributeList::AT_ObjCSubclassingRestricted:
-    handleSimpleAttribute<ObjCSubclassingRestrictedAttr>(S, D, Attr);
+    handleSimpleAttribute<ObjCSubclassingRestrictedAttr>(S, D, AL);
     break;
   case AttributeList::AT_ObjCExplicitProtocolImpl:
-    handleObjCSuppresProtocolAttr(S, D, Attr);
+    handleObjCSuppresProtocolAttr(S, D, AL);
     break;
   case AttributeList::AT_ObjCRequiresPropertyDefs:
-    handleSimpleAttribute<ObjCRequiresPropertyDefsAttr>(S, D, Attr);
+    handleSimpleAttribute<ObjCRequiresPropertyDefsAttr>(S, D, AL);
     break;
   case AttributeList::AT_Unused:
-    handleUnusedAttr(S, D, Attr);
+    handleUnusedAttr(S, D, AL);
     break;
   case AttributeList::AT_ReturnsTwice:
-    handleSimpleAttribute<ReturnsTwiceAttr>(S, D, Attr);
+    handleSimpleAttribute<ReturnsTwiceAttr>(S, D, AL);
     break;
   case AttributeList::AT_NotTailCalled:
-    handleNotTailCalledAttr(S, D, Attr);
+    handleNotTailCalledAttr(S, D, AL);
     break;
   case AttributeList::AT_DisableTailCalls:
-    handleDisableTailCallsAttr(S, D, Attr);
+    handleDisableTailCallsAttr(S, D, AL);
     break;
   case AttributeList::AT_Used:
-    handleUsedAttr(S, D, Attr);
+    handleUsedAttr(S, D, AL);
     break;
   case AttributeList::AT_Visibility:
-    handleVisibilityAttr(S, D, Attr, false);
+    handleVisibilityAttr(S, D, AL, false);
     break;
   case AttributeList::AT_TypeVisibility:
-    handleVisibilityAttr(S, D, Attr, true);
+    handleVisibilityAttr(S, D, AL, true);
     break;
   case AttributeList::AT_WarnUnused:
-    handleSimpleAttribute<WarnUnusedAttr>(S, D, Attr);
+    handleSimpleAttribute<WarnUnusedAttr>(S, D, AL);
     break;
   case AttributeList::AT_WarnUnusedResult:
-    handleWarnUnusedResult(S, D, Attr);
+    handleWarnUnusedResult(S, D, AL);
     break;
   case AttributeList::AT_Weak:
-    handleSimpleAttribute<WeakAttr>(S, D, Attr);
+    handleSimpleAttribute<WeakAttr>(S, D, AL);
     break;
   case AttributeList::AT_WeakRef:
-    handleWeakRefAttr(S, D, Attr);
+    handleWeakRefAttr(S, D, AL);
     break;
   case AttributeList::AT_WeakImport:
-    handleWeakImportAttr(S, D, Attr);
+    handleWeakImportAttr(S, D, AL);
     break;
   case AttributeList::AT_TransparentUnion:
-    handleTransparentUnionAttr(S, D, Attr);
+    handleTransparentUnionAttr(S, D, AL);
     break;
   case AttributeList::AT_ObjCException:
-    handleSimpleAttribute<ObjCExceptionAttr>(S, D, Attr);
+    handleSimpleAttribute<ObjCExceptionAttr>(S, D, AL);
     break;
   case AttributeList::AT_ObjCMethodFamily:
-    handleObjCMethodFamilyAttr(S, D, Attr);
+    handleObjCMethodFamilyAttr(S, D, AL);
     break;
   case AttributeList::AT_ObjCNSObject:
-    handleObjCNSObject(S, D, Attr);
+    handleObjCNSObject(S, D, AL);
     break;
   case AttributeList::AT_ObjCIndependentClass:
-    handleObjCIndependentClass(S, D, Attr);
+    handleObjCIndependentClass(S, D, AL);
     break;
   case AttributeList::AT_Blocks:
-    handleBlocksAttr(S, D, Attr);
+    handleBlocksAttr(S, D, AL);
     break;
   case AttributeList::AT_Sentinel:
-    handleSentinelAttr(S, D, Attr);
+    handleSentinelAttr(S, D, AL);
     break;
   case AttributeList::AT_Const:
-    handleSimpleAttribute<ConstAttr>(S, D, Attr);
+    handleSimpleAttribute<ConstAttr>(S, D, AL);
     break;
   case AttributeList::AT_Pure:
-    handleSimpleAttribute<PureAttr>(S, D, Attr);
+    handleSimpleAttribute<PureAttr>(S, D, AL);
     break;
   case AttributeList::AT_Cleanup:
-    handleCleanupAttr(S, D, Attr);
+    handleCleanupAttr(S, D, AL);
     break;
   case AttributeList::AT_NoDebug:
-    handleNoDebugAttr(S, D, Attr);
+    handleNoDebugAttr(S, D, AL);
     break;
   case AttributeList::AT_NoDuplicate:
-    handleSimpleAttribute<NoDuplicateAttr>(S, D, Attr);
+    handleSimpleAttribute<NoDuplicateAttr>(S, D, AL);
     break;
   case AttributeList::AT_Convergent:
-    handleSimpleAttribute<ConvergentAttr>(S, D, Attr);
+    handleSimpleAttribute<ConvergentAttr>(S, D, AL);
     break;
   case AttributeList::AT_NoInline:
-    handleSimpleAttribute<NoInlineAttr>(S, D, Attr);
+    handleSimpleAttribute<NoInlineAttr>(S, D, AL);
     break;
   case AttributeList::AT_NoInstrumentFunction: // Interacts with -pg.
-    handleSimpleAttribute<NoInstrumentFunctionAttr>(S, D, Attr);
+    handleSimpleAttribute<NoInstrumentFunctionAttr>(S, D, AL);
     break;
   case AttributeList::AT_StdCall:
   case AttributeList::AT_CDecl:
@@ -6403,186 +6373,186 @@ static void ProcessDeclAttribute(Sema &S
   case AttributeList::AT_IntelOclBicc:
   case AttributeList::AT_PreserveMost:
   case AttributeList::AT_PreserveAll:
-    handleCallConvAttr(S, D, Attr);
+    handleCallConvAttr(S, D, AL);
     break;
   case AttributeList::AT_Suppress:
-    handleSuppressAttr(S, D, Attr);
+    handleSuppressAttr(S, D, AL);
     break;
   case AttributeList::AT_OpenCLKernel:
-    handleSimpleAttribute<OpenCLKernelAttr>(S, D, Attr);
+    handleSimpleAttribute<OpenCLKernelAttr>(S, D, AL);
     break;
   case AttributeList::AT_OpenCLAccess:
-    handleOpenCLAccessAttr(S, D, Attr);
+    handleOpenCLAccessAttr(S, D, AL);
     break;
   case AttributeList::AT_OpenCLNoSVM:
-    handleOpenCLNoSVMAttr(S, D, Attr);
+    handleOpenCLNoSVMAttr(S, D, AL);
     break;
   case AttributeList::AT_SwiftContext:
-    handleParameterABIAttr(S, D, Attr, ParameterABI::SwiftContext);
+    handleParameterABIAttr(S, D, AL, ParameterABI::SwiftContext);
     break;
   case AttributeList::AT_SwiftErrorResult:
-    handleParameterABIAttr(S, D, Attr, ParameterABI::SwiftErrorResult);
+    handleParameterABIAttr(S, D, AL, ParameterABI::SwiftErrorResult);
     break;
   case AttributeList::AT_SwiftIndirectResult:
-    handleParameterABIAttr(S, D, Attr, ParameterABI::SwiftIndirectResult);
+    handleParameterABIAttr(S, D, AL, ParameterABI::SwiftIndirectResult);
     break;
   case AttributeList::AT_InternalLinkage:
-    handleInternalLinkageAttr(S, D, Attr);
+    handleInternalLinkageAttr(S, D, AL);
     break;
   case AttributeList::AT_LTOVisibilityPublic:
-    handleSimpleAttribute<LTOVisibilityPublicAttr>(S, D, Attr);
+    handleSimpleAttribute<LTOVisibilityPublicAttr>(S, D, AL);
     break;
 
   // Microsoft attributes:
   case AttributeList::AT_EmptyBases:
-    handleSimpleAttribute<EmptyBasesAttr>(S, D, Attr);
+    handleSimpleAttribute<EmptyBasesAttr>(S, D, AL);
     break;
   case AttributeList::AT_LayoutVersion:
-    handleLayoutVersion(S, D, Attr);
+    handleLayoutVersion(S, D, AL);
     break;
   case AttributeList::AT_TrivialABI:
-    handleSimpleAttribute<TrivialABIAttr>(S, D, Attr);
+    handleSimpleAttribute<TrivialABIAttr>(S, D, AL);
     break;
   case AttributeList::AT_MSNoVTable:
-    handleSimpleAttribute<MSNoVTableAttr>(S, D, Attr);
+    handleSimpleAttribute<MSNoVTableAttr>(S, D, AL);
     break;
   case AttributeList::AT_MSStruct:
-    handleSimpleAttribute<MSStructAttr>(S, D, Attr);
+    handleSimpleAttribute<MSStructAttr>(S, D, AL);
     break;
   case AttributeList::AT_Uuid:
-    handleUuidAttr(S, D, Attr);
+    handleUuidAttr(S, D, AL);
     break;
   case AttributeList::AT_MSInheritance:
-    handleMSInheritanceAttr(S, D, Attr);
+    handleMSInheritanceAttr(S, D, AL);
     break;
   case AttributeList::AT_SelectAny:
-    handleSimpleAttribute<SelectAnyAttr>(S, D, Attr);
+    handleSimpleAttribute<SelectAnyAttr>(S, D, AL);
     break;
   case AttributeList::AT_Thread:
-    handleDeclspecThreadAttr(S, D, Attr);
+    handleDeclspecThreadAttr(S, D, AL);
     break;
 
   case AttributeList::AT_AbiTag:
-    handleAbiTagAttr(S, D, Attr);
+    handleAbiTagAttr(S, D, AL);
     break;
 
   // Thread safety attributes:
   case AttributeList::AT_AssertExclusiveLock:
-    handleAssertExclusiveLockAttr(S, D, Attr);
+    handleAssertExclusiveLockAttr(S, D, AL);
     break;
   case AttributeList::AT_AssertSharedLock:
-    handleAssertSharedLockAttr(S, D, Attr);
+    handleAssertSharedLockAttr(S, D, AL);
     break;
   case AttributeList::AT_GuardedVar:
-    handleSimpleAttribute<GuardedVarAttr>(S, D, Attr);
+    handleSimpleAttribute<GuardedVarAttr>(S, D, AL);
     break;
   case AttributeList::AT_PtGuardedVar:
-    handlePtGuardedVarAttr(S, D, Attr);
+    handlePtGuardedVarAttr(S, D, AL);
     break;
   case AttributeList::AT_ScopedLockable:
-    handleSimpleAttribute<ScopedLockableAttr>(S, D, Attr);
+    handleSimpleAttribute<ScopedLockableAttr>(S, D, AL);
     break;
   case AttributeList::AT_NoSanitize:
-    handleNoSanitizeAttr(S, D, Attr);
+    handleNoSanitizeAttr(S, D, AL);
     break;
   case AttributeList::AT_NoSanitizeSpecific:
-    handleNoSanitizeSpecificAttr(S, D, Attr);
+    handleNoSanitizeSpecificAttr(S, D, AL);
     break;
   case AttributeList::AT_NoThreadSafetyAnalysis:
-    handleSimpleAttribute<NoThreadSafetyAnalysisAttr>(S, D, Attr);
+    handleSimpleAttribute<NoThreadSafetyAnalysisAttr>(S, D, AL);
     break;
   case AttributeList::AT_GuardedBy:
-    handleGuardedByAttr(S, D, Attr);
+    handleGuardedByAttr(S, D, AL);
     break;
   case AttributeList::AT_PtGuardedBy:
-    handlePtGuardedByAttr(S, D, Attr);
+    handlePtGuardedByAttr(S, D, AL);
     break;
   case AttributeList::AT_ExclusiveTrylockFunction:
-    handleExclusiveTrylockFunctionAttr(S, D, Attr);
+    handleExclusiveTrylockFunctionAttr(S, D, AL);
     break;
   case AttributeList::AT_LockReturned:
-    handleLockReturnedAttr(S, D, Attr);
+    handleLockReturnedAttr(S, D, AL);
     break;
   case AttributeList::AT_LocksExcluded:
-    handleLocksExcludedAttr(S, D, Attr);
+    handleLocksExcludedAttr(S, D, AL);
     break;
   case AttributeList::AT_SharedTrylockFunction:
-    handleSharedTrylockFunctionAttr(S, D, Attr);
+    handleSharedTrylockFunctionAttr(S, D, AL);
     break;
   case AttributeList::AT_AcquiredBefore:
-    handleAcquiredBeforeAttr(S, D, Attr);
+    handleAcquiredBeforeAttr(S, D, AL);
     break;
   case AttributeList::AT_AcquiredAfter:
-    handleAcquiredAfterAttr(S, D, Attr);
+    handleAcquiredAfterAttr(S, D, AL);
     break;
 
   // Capability analysis attributes.
   case AttributeList::AT_Capability:
   case AttributeList::AT_Lockable:
-    handleCapabilityAttr(S, D, Attr);
+    handleCapabilityAttr(S, D, AL);
     break;
   case AttributeList::AT_RequiresCapability:
-    handleRequiresCapabilityAttr(S, D, Attr);
+    handleRequiresCapabilityAttr(S, D, AL);
     break;
 
   case AttributeList::AT_AssertCapability:
-    handleAssertCapabilityAttr(S, D, Attr);
+    handleAssertCapabilityAttr(S, D, AL);
     break;
   case AttributeList::AT_AcquireCapability:
-    handleAcquireCapabilityAttr(S, D, Attr);
+    handleAcquireCapabilityAttr(S, D, AL);
     break;
   case AttributeList::AT_ReleaseCapability:
-    handleReleaseCapabilityAttr(S, D, Attr);
+    handleReleaseCapabilityAttr(S, D, AL);
     break;
   case AttributeList::AT_TryAcquireCapability:
-    handleTryAcquireCapabilityAttr(S, D, Attr);
+    handleTryAcquireCapabilityAttr(S, D, AL);
     break;
 
   // Consumed analysis attributes.
   case AttributeList::AT_Consumable:
-    handleConsumableAttr(S, D, Attr);
+    handleConsumableAttr(S, D, AL);
     break;
   case AttributeList::AT_ConsumableAutoCast:
-    handleSimpleAttribute<ConsumableAutoCastAttr>(S, D, Attr);
+    handleSimpleAttribute<ConsumableAutoCastAttr>(S, D, AL);
     break;
   case AttributeList::AT_ConsumableSetOnRead:
-    handleSimpleAttribute<ConsumableSetOnReadAttr>(S, D, Attr);
+    handleSimpleAttribute<ConsumableSetOnReadAttr>(S, D, AL);
     break;
   case AttributeList::AT_CallableWhen:
-    handleCallableWhenAttr(S, D, Attr);
+    handleCallableWhenAttr(S, D, AL);
     break;
   case AttributeList::AT_ParamTypestate:
-    handleParamTypestateAttr(S, D, Attr);
+    handleParamTypestateAttr(S, D, AL);
     break;
   case AttributeList::AT_ReturnTypestate:
-    handleReturnTypestateAttr(S, D, Attr);
+    handleReturnTypestateAttr(S, D, AL);
     break;
   case AttributeList::AT_SetTypestate:
-    handleSetTypestateAttr(S, D, Attr);
+    handleSetTypestateAttr(S, D, AL);
     break;
   case AttributeList::AT_TestTypestate:
-    handleTestTypestateAttr(S, D, Attr);
+    handleTestTypestateAttr(S, D, AL);
     break;
 
   // Type safety attributes.
   case AttributeList::AT_ArgumentWithTypeTag:
-    handleArgumentWithTypeTagAttr(S, D, Attr);
+    handleArgumentWithTypeTagAttr(S, D, AL);
     break;
   case AttributeList::AT_TypeTagForDatatype:
-    handleTypeTagForDatatypeAttr(S, D, Attr);
+    handleTypeTagForDatatypeAttr(S, D, AL);
     break;
   case AttributeList::AT_AnyX86NoCallerSavedRegisters:
-    handleNoCallerSavedRegsAttr(S, D, Attr);
+    handleNoCallerSavedRegsAttr(S, D, AL);
     break;
   case AttributeList::AT_RenderScriptKernel:
-    handleSimpleAttribute<RenderScriptKernelAttr>(S, D, Attr);
+    handleSimpleAttribute<RenderScriptKernelAttr>(S, D, AL);
     break;
   // XRay attributes.
   case AttributeList::AT_XRayInstrument:
-    handleSimpleAttribute<XRayInstrumentAttr>(S, D, Attr);
+    handleSimpleAttribute<XRayInstrumentAttr>(S, D, AL);
     break;
   case AttributeList::AT_XRayLogArgs:
-    handleXRayLogArgsAttr(S, D, Attr);
+    handleXRayLogArgsAttr(S, D, AL);
     break;
   }
 }
@@ -6612,34 +6582,34 @@ void Sema::ProcessDeclAttributeList(Scop
   // attribute must never appear as a group" for attributes like cold and hot.
   if (!D->hasAttr<OpenCLKernelAttr>()) {
     // These attributes cannot be applied to a non-kernel function.
-    if (Attr *A = D->getAttr<ReqdWorkGroupSizeAttr>()) {
+    if (const auto *A = D->getAttr<ReqdWorkGroupSizeAttr>()) {
       // FIXME: This emits a different error message than
       // diag::err_attribute_wrong_decl_type + ExpectedKernelFunction.
       Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
       D->setInvalidDecl();
-    } else if (Attr *A = D->getAttr<WorkGroupSizeHintAttr>()) {
+    } else if (const auto *A = D->getAttr<WorkGroupSizeHintAttr>()) {
       Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
       D->setInvalidDecl();
-    } else if (Attr *A = D->getAttr<VecTypeHintAttr>()) {
+    } else if (const auto *A = D->getAttr<VecTypeHintAttr>()) {
       Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
       D->setInvalidDecl();
-    } else if (Attr *A = D->getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
+    } else if (const auto *A = D->getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
       Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
         << A << ExpectedKernelFunction;
       D->setInvalidDecl();
-    } else if (Attr *A = D->getAttr<AMDGPUWavesPerEUAttr>()) {
+    } else if (const auto *A = D->getAttr<AMDGPUWavesPerEUAttr>()) {
       Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
         << A << ExpectedKernelFunction;
       D->setInvalidDecl();
-    } else if (Attr *A = D->getAttr<AMDGPUNumSGPRAttr>()) {
+    } else if (const auto *A = D->getAttr<AMDGPUNumSGPRAttr>()) {
       Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
         << A << ExpectedKernelFunction;
       D->setInvalidDecl();
-    } else if (Attr *A = D->getAttr<AMDGPUNumVGPRAttr>()) {
+    } else if (const auto *A = D->getAttr<AMDGPUNumVGPRAttr>()) {
       Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
         << A << ExpectedKernelFunction;
       D->setInvalidDecl();
-    } else if (Attr *A = D->getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
+    } else if (const auto *A = D->getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
       Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
       D->setInvalidDecl();
     }
@@ -6648,9 +6618,9 @@ void Sema::ProcessDeclAttributeList(Scop
 
 // Helper for delayed processing TransparentUnion attribute.
 void Sema::ProcessDeclAttributeDelayed(Decl *D, const AttributeList *AttrList) {
-  for (const AttributeList *Attr = AttrList; Attr; Attr = Attr->getNext())
-    if (Attr->getKind() == AttributeList::AT_TransparentUnion) {
-      handleTransparentUnionAttr(*this, D, *Attr);
+  for (const AttributeList *AL = AttrList; AL; AL = AL->getNext())
+    if (AL->getKind() == AttributeList::AT_TransparentUnion) {
+      handleTransparentUnionAttr(*this, D, *AL);
       break;
     }
 }
@@ -6705,7 +6675,7 @@ NamedDecl * Sema::DeclClonePragmaWeak(Na
                                       SourceLocation Loc) {
   assert(isa<FunctionDecl>(ND) || isa<VarDecl>(ND));
   NamedDecl *NewD = nullptr;
-  if (FunctionDecl *FD = dyn_cast<FunctionDecl>(ND)) {
+  if (auto *FD = dyn_cast<FunctionDecl>(ND)) {
     FunctionDecl *NewFD;
     // FIXME: Missing call to CheckFunctionDeclaration().
     // FIXME: Mangling?
@@ -6725,7 +6695,7 @@ NamedDecl * Sema::DeclClonePragmaWeak(Na
     // Fake up parameter variables; they are declared as if this were
     // a typedef.
     QualType FDTy = FD->getType();
-    if (const FunctionProtoType *FT = FDTy->getAs<FunctionProtoType>()) {
+    if (const auto *FT = FDTy->getAs<FunctionProtoType>()) {
       SmallVector<ParmVarDecl*, 16> Params;
       for (const auto &AI : FT->param_types()) {
         ParmVarDecl *Param = BuildParmVarDeclForTypedef(NewFD, Loc, AI);
@@ -6734,15 +6704,13 @@ NamedDecl * Sema::DeclClonePragmaWeak(Na
       }
       NewFD->setParams(Params);
     }
-  } else if (VarDecl *VD = dyn_cast<VarDecl>(ND)) {
+  } else if (auto *VD = dyn_cast<VarDecl>(ND)) {
     NewD = VarDecl::Create(VD->getASTContext(), VD->getDeclContext(),
                            VD->getInnerLocStart(), VD->getLocation(), II,
                            VD->getType(), VD->getTypeSourceInfo(),
                            VD->getStorageClass());
-    if (VD->getQualifier()) {
-      VarDecl *NewVD = cast<VarDecl>(NewD);
-      NewVD->setQualifierInfo(VD->getQualifierLoc());
-    }
+    if (VD->getQualifier())
+	  cast<VarDecl>(NewD)->setQualifierInfo(VD->getQualifierLoc());
   }
   return NewD;
 }
@@ -6778,10 +6746,10 @@ void Sema::ProcessPragmaWeak(Scope *S, D
   LoadExternalWeakUndeclaredIdentifiers();
   if (!WeakUndeclaredIdentifiers.empty()) {
     NamedDecl *ND = nullptr;
-    if (VarDecl *VD = dyn_cast<VarDecl>(D))
+    if (auto *VD = dyn_cast<VarDecl>(D))
       if (VD->isExternC())
         ND = VD;
-    if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D))
+    if (auto *FD = dyn_cast<FunctionDecl>(D))
       if (FD->isExternC())
         ND = FD;
     if (ND) {
@@ -6824,14 +6792,14 @@ void Sema::ProcessDeclAttributes(Scope *
 /// Is the given declaration allowed to use a forbidden type?
 /// If so, it'll still be annotated with an attribute that makes it
 /// illegal to actually use.
-static bool isForbiddenTypeAllowed(Sema &S, Decl *decl,
+static bool isForbiddenTypeAllowed(Sema &S, Decl *D,
                                    const DelayedDiagnostic &diag,
                                    UnavailableAttr::ImplicitReason &reason) {
   // Private ivars are always okay.  Unfortunately, people don't
   // always properly make their ivars private, even in system headers.
   // Plus we need to make fields okay, too.
-  if (!isa<FieldDecl>(decl) && !isa<ObjCPropertyDecl>(decl) &&
-      !isa<FunctionDecl>(decl))
+  if (!isa<FieldDecl>(D) && !isa<ObjCPropertyDecl>(D) &&
+      !isa<FunctionDecl>(D))
     return false;
 
   // Silently accept unsupported uses of __weak in both user and system
@@ -6839,7 +6807,7 @@ static bool isForbiddenTypeAllowed(Sema
   // -fno-objc-arc files.  We do have to take some care against attempts
   // to define such things;  for now, we've only done that for ivars
   // and properties.
-  if ((isa<ObjCIvarDecl>(decl) || isa<ObjCPropertyDecl>(decl))) {
+  if ((isa<ObjCIvarDecl>(D) || isa<ObjCPropertyDecl>(D))) {
     if (diag.getForbiddenTypeDiagnostic() == diag::err_arc_weak_disabled ||
         diag.getForbiddenTypeDiagnostic() == diag::err_arc_weak_no_runtime) {
       reason = UnavailableAttr::IR_ForbiddenWeak;
@@ -6848,7 +6816,7 @@ static bool isForbiddenTypeAllowed(Sema
   }
 
   // Allow all sorts of things in system headers.
-  if (S.Context.getSourceManager().isInSystemHeader(decl->getLocation())) {
+  if (S.Context.getSourceManager().isInSystemHeader(D->getLocation())) {
     // Currently, all the failures dealt with this way are due to ARC
     // restrictions.
     reason = UnavailableAttr::IR_ARCForbiddenType;
@@ -6859,30 +6827,29 @@ static bool isForbiddenTypeAllowed(Sema
 }
 
 /// Handle a delayed forbidden-type diagnostic.
-static void handleDelayedForbiddenType(Sema &S, DelayedDiagnostic &diag,
-                                       Decl *decl) {
-  auto reason = UnavailableAttr::IR_None;
-  if (decl && isForbiddenTypeAllowed(S, decl, diag, reason)) {
-    assert(reason && "didn't set reason?");
-    decl->addAttr(UnavailableAttr::CreateImplicit(S.Context, "", reason,
-                                                  diag.Loc));
+static void handleDelayedForbiddenType(Sema &S, DelayedDiagnostic &DD,
+                                       Decl *D) {
+  auto Reason = UnavailableAttr::IR_None;
+  if (D && isForbiddenTypeAllowed(S, D, DD, Reason)) {
+    assert(Reason && "didn't set reason?");
+    D->addAttr(UnavailableAttr::CreateImplicit(S.Context, "", Reason, DD.Loc));
     return;
   }
   if (S.getLangOpts().ObjCAutoRefCount)
-    if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(decl)) {
+    if (const auto *FD = dyn_cast<FunctionDecl>(D)) {
       // FIXME: we may want to suppress diagnostics for all
-      // kind of forbidden type messages on unavailable functions. 
+      // kind of forbidden type messages on unavailable functions.
       if (FD->hasAttr<UnavailableAttr>() &&
-          diag.getForbiddenTypeDiagnostic() == 
-          diag::err_arc_array_param_no_ownership) {
-        diag.Triggered = true;
+          DD.getForbiddenTypeDiagnostic() ==
+              diag::err_arc_array_param_no_ownership) {
+        DD.Triggered = true;
         return;
       }
     }
 
-  S.Diag(diag.Loc, diag.getForbiddenTypeDiagnostic())
-    << diag.getForbiddenTypeOperand() << diag.getForbiddenTypeArgument();
-  diag.Triggered = true;
+  S.Diag(DD.Loc, DD.getForbiddenTypeDiagnostic())
+      << DD.getForbiddenTypeOperand() << DD.getForbiddenTypeArgument();
+  DD.Triggered = true;
 }
 
 static const AvailabilityAttr *getAttrForPlatform(ASTContext &Context,
@@ -6925,9 +6892,9 @@ ShouldDiagnoseAvailabilityOfDecl(const N
 
   // For typedefs, if the typedef declaration appears available look
   // to the underlying type to see if it is more restrictive.
-  while (const TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) {
+  while (const auto *TD = dyn_cast<TypedefNameDecl>(D)) {
     if (Result == AR_Available) {
-      if (const TagType *TT = TD->getUnderlyingType()->getAs<TagType>()) {
+      if (const auto *TT = TD->getUnderlyingType()->getAs<TagType>()) {
         D = TT->getDecl();
         Result = D->getAvailability(Message);
         continue;
@@ -6937,7 +6904,7 @@ ShouldDiagnoseAvailabilityOfDecl(const N
   }
 
   // Forward class declarations get their attributes from their definition.
-  if (const ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(D)) {
+  if (const auto *IDecl = dyn_cast<ObjCInterfaceDecl>(D)) {
     if (IDecl->getDefinition()) {
       D = IDecl->getDefinition();
       Result = D->getAvailability(Message);
@@ -6985,18 +6952,18 @@ static bool ShouldDiagnoseAvailabilityIn
   // interface when they really shouldn't: they are members of the enclosing
   // context, and can referenced from there.
   if (S.OriginalLexicalContext && cast<Decl>(S.OriginalLexicalContext) != Ctx) {
-    auto *OrigCtx = cast<Decl>(S.OriginalLexicalContext);
+    const auto *OrigCtx = cast<Decl>(S.OriginalLexicalContext);
     if (CheckContext(OrigCtx))
       return false;
 
     // An implementation implicitly has the availability of the interface.
-    if (auto *CatOrImpl = dyn_cast<ObjCImplDecl>(OrigCtx)) {
+    if (const auto *CatOrImpl = dyn_cast<ObjCImplDecl>(OrigCtx)) {
       if (const ObjCInterfaceDecl *Interface = CatOrImpl->getClassInterface())
         if (CheckContext(Interface))
           return false;
     }
     // A category implicitly has the availability of the interface.
-    else if (auto *CatD = dyn_cast<ObjCCategoryDecl>(OrigCtx))
+    else if (const auto *CatD = dyn_cast<ObjCCategoryDecl>(OrigCtx))
       if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
         if (CheckContext(Interface))
           return false;
@@ -7007,13 +6974,13 @@ static bool ShouldDiagnoseAvailabilityIn
       return false;
 
     // An implementation implicitly has the availability of the interface.
-    if (auto *CatOrImpl = dyn_cast<ObjCImplDecl>(Ctx)) {
+    if (const auto *CatOrImpl = dyn_cast<ObjCImplDecl>(Ctx)) {
       if (const ObjCInterfaceDecl *Interface = CatOrImpl->getClassInterface())
         if (CheckContext(Interface))
           return false;
     }
     // A category implicitly has the availability of the interface.
-    else if (auto *CatD = dyn_cast<ObjCCategoryDecl>(Ctx))
+    else if (const auto *CatD = dyn_cast<ObjCCategoryDecl>(Ctx))
       if (const ObjCInterfaceDecl *Interface = CatD->getClassInterface())
         if (CheckContext(Interface))
           return false;
@@ -7184,7 +7151,7 @@ static void DoEmitAvailabilityWarning(Se
         << OffendingDecl << /* partial */ 3;
 
     if (const auto *Enclosing = findEnclosingDeclToAnnotate(Ctx)) {
-      if (auto *TD = dyn_cast<TagDecl>(Enclosing))
+      if (const auto *TD = dyn_cast<TagDecl>(Enclosing))
         if (TD->getDeclName().isEmpty()) {
           S.Diag(TD->getLocation(),
                  diag::note_decl_unguarded_availability_silence)
@@ -7225,8 +7192,8 @@ static void DoEmitAvailabilityWarning(Se
     diag_fwdclass_message = diag::warn_deprecated_fwdclass_message;
     property_note_select = /* deprecated */ 0;
     available_here_select_kind = /* deprecated */ 2;
-    if (const auto *Attr = OffendingDecl->getAttr<DeprecatedAttr>())
-      NoteLocation = Attr->getLocation();
+    if (const auto *AL = OffendingDecl->getAttr<DeprecatedAttr>())
+      NoteLocation = AL->getLocation();
     break;
 
   case AR_Unavailable:
@@ -7237,8 +7204,8 @@ static void DoEmitAvailabilityWarning(Se
     property_note_select = /* unavailable */ 1;
     available_here_select_kind = /* unavailable */ 0;
 
-    if (auto Attr = OffendingDecl->getAttr<UnavailableAttr>()) {
-      if (Attr->isImplicit() && Attr->getImplicitReason()) {
+    if (auto AL = OffendingDecl->getAttr<UnavailableAttr>()) {
+      if (AL->isImplicit() && AL->getImplicitReason()) {
         // Most of these failures are due to extra restrictions in ARC;
         // reflect that in the primary diagnostic when applicable.
         auto flagARCError = [&] {
@@ -7248,7 +7215,7 @@ static void DoEmitAvailabilityWarning(Se
             diag = diag::err_unavailable_in_arc;
         };
 
-        switch (Attr->getImplicitReason()) {
+        switch (AL->getImplicitReason()) {
         case UnavailableAttr::IR_None: break;
 
         case UnavailableAttr::IR_ARCForbiddenType:
@@ -7289,10 +7256,10 @@ static void DoEmitAvailabilityWarning(Se
   CharSourceRange UseRange;
   StringRef Replacement;
   if (K == AR_Deprecated) {
-    if (auto Attr = OffendingDecl->getAttr<DeprecatedAttr>())
-      Replacement = Attr->getReplacement();
-    if (auto Attr = getAttrForPlatform(S.Context, OffendingDecl))
-      Replacement = Attr->getReplacement();
+    if (auto AL = OffendingDecl->getAttr<DeprecatedAttr>())
+      Replacement = AL->getReplacement();
+    if (auto AL = getAttrForPlatform(S.Context, OffendingDecl))
+      Replacement = AL->getReplacement();
 
     if (!Replacement.empty())
       UseRange =
@@ -7688,11 +7655,11 @@ bool DiagnoseUnguardedAvailability::Visi
   if (Range.isInvalid())
     return true;
 
-  if (const TagType *TT = dyn_cast<TagType>(TyPtr)) {
+  if (const auto *TT = dyn_cast<TagType>(TyPtr)) {
     TagDecl *TD = TT->getDecl();
     DiagnoseDeclAvailability(TD, Range);
 
-  } else if (const TypedefType *TD = dyn_cast<TypedefType>(TyPtr)) {
+  } else if (const auto *TD = dyn_cast<TypedefType>(TyPtr)) {
     TypedefNameDecl *D = TD->getDecl();
     DiagnoseDeclAvailability(D, Range);
 
@@ -7776,7 +7743,7 @@ void Sema::DiagnoseAvailabilityOfDecl(Na
   }
 
   const ObjCPropertyDecl *ObjCPDecl = nullptr;
-  if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
+  if (const auto *MD = dyn_cast<ObjCMethodDecl>(D)) {
     if (const ObjCPropertyDecl *PD = MD->findPropertyDecl()) {
       AvailabilityResult PDeclResult = PD->getAvailability(nullptr);
       if (PDeclResult == Result)




More information about the cfe-commits mailing list