Author: Baranov Victor
Date: 2026-08-04T16:36:29+03:00
New Revision: 61ccfbfca52d078e1aa92f0d53ea6b3eee7dee59

URL: 
https://github.com/llvm/llvm-project/commit/61ccfbfca52d078e1aa92f0d53ea6b3eee7dee59
DIFF: 
https://github.com/llvm/llvm-project/commit/61ccfbfca52d078e1aa92f0d53ea6b3eee7dee59.diff

LOG: [clang-tidy][NFC] Apply const-correctness for auto 6/N (#213844)

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/performance/EnumSizeCheck.cpp
    clang-tools-extra/clang-tidy/performance/ExpensiveValueOrCheck.cpp
    clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
    clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
    clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
    clang-tools-extra/clang-tidy/performance/NoexceptFunctionBaseCheck.cpp
    clang-tools-extra/clang-tidy/performance/PreferSingleCharOverloadsCheck.cpp
    clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
    
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
    clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
    clang-tools-extra/clang-tidy/performance/UseStdMoveCheck.cpp
    clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp
    clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp
    clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDeclsCheck.cpp
    clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
    clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
    clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
    clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
    
clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp
    clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
    clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
    clang-tools-extra/clang-tidy/readability/IdentifierLengthCheck.cpp
    clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
    clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
    
clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
    clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
    clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
    clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
    clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp
    clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp
    clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
    clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
    clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
    clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
    clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
    clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp
    clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
    clang-tools-extra/clang-tidy/readability/RedundantQualifiedAliasCheck.cpp
    clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
    clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
    
clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
    
clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp
    clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp
    clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
    clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
    clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
    clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp
    clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/clang-tidy/performance/EnumSizeCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/EnumSizeCheck.cpp
index 70692d37f2729..7078fd3731e9e 100644
--- a/clang-tools-extra/clang-tidy/performance/EnumSizeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/EnumSizeCheck.cpp
@@ -130,7 +130,7 @@ void EnumSizeCheck::check(const MatchFinder::MatchResult 
&Result) {
       MinV = std::max<std::uint64_t>(MinV, InitVal.abs().getZExtValue());
   }
 
-  auto NewType = getNewType(Size, MinV, MaxV);
+  const auto NewType = getNewType(Size, MinV, MaxV);
   if (!NewType.first || Size <= NewType.second)
     return;
 

diff  --git 
a/clang-tools-extra/clang-tidy/performance/ExpensiveValueOrCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/ExpensiveValueOrCheck.cpp
index 97ac63dfbe985..9dbe8dca3c8e2 100644
--- a/clang-tools-extra/clang-tidy/performance/ExpensiveValueOrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/ExpensiveValueOrCheck.cpp
@@ -110,10 +110,10 @@ void 
ExpensiveValueOrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void ExpensiveValueOrCheck::registerMatchers(MatchFinder *Finder) {
-  auto OptionalTypesMatcher =
+  const auto OptionalTypesMatcher =
       matchers::matchesAnyListedRegexName(OptionalTypes);
-  auto ValueOrMatcher = hasAnyName("value_or", "valueOr", "ValueOr");
-  auto ValueOrCall = cxxMemberCallExpr(
+  const auto ValueOrMatcher = hasAnyName("value_or", "valueOr", "ValueOr");
+  const auto ValueOrCall = cxxMemberCallExpr(
       callee(cxxMethodDecl(ValueOrMatcher, ofClass(OptionalTypesMatcher))),
       anyOf(on(isLValueExpr()),
             hasType(qualType(unless(hasNonTrivialMoveCtor())))),
@@ -162,9 +162,9 @@ void ExpensiveValueOrCheck::check(const 
MatchFinder::MatchResult &Result) {
   const bool HasSideEffects = FallbackArg->HasSideEffects(Ctx);
 
   {
-    auto Diag = diag(Call->getExprLoc(), "'%0' copies expensive type %1; %2")
-                << Method->getName() << ValueType
-                << buildSuggestion(OptionalClass);
+    const auto Diag =
+        diag(Call->getExprLoc(), "'%0' copies expensive type %1; %2")
+        << Method->getName() << ValueType << buildSuggestion(OptionalClass);
 
     if (!HasSideEffects) {
       if (auto Fix = buildFixIt(Call, ObjExpr, FallbackArg, OptionalClass, 
Ctx))

diff  --git a/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
index 23feab88c92a3..ac4922db3a924 100644
--- a/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/ForRangeCopyCheck.cpp
@@ -35,7 +35,7 @@ void ForRangeCopyCheck::registerMatchers(MatchFinder *Finder) 
{
   // Match loop variables that are not references or pointers or are already
   // initialized through MaterializeTemporaryExpr which indicates a type
   // conversion.
-  auto HasReferenceOrPointerTypeOrIsAllowed = hasType(qualType(
+  const auto HasReferenceOrPointerTypeOrIsAllowed = hasType(qualType(
       unless(anyOf(hasCanonicalType(anyOf(referenceType(), pointerType())),
                    hasDeclaration(namedDecl(
                        matchers::matchesAnyListedRegexName(AllowedTypes)))))));
@@ -46,7 +46,7 @@ void ForRangeCopyCheck::registerMatchers(MatchFinder *Finder) 
{
   auto NotConstructedByCopy = cxxConstructExpr(
       hasDeclaration(cxxConstructorDecl(unless(isCopyConstructor()))));
   auto ConstructedByConversion = 
cxxMemberCallExpr(callee(cxxConversionDecl()));
-  auto LoopVar =
+  const auto LoopVar =
       varDecl(HasReferenceOrPointerTypeOrIsAllowed,
               unless(hasInitializer(expr(hasDescendant(expr(
                   anyOf(materializeTemporaryExpr(), IteratorReturnsValueType,
@@ -83,7 +83,7 @@ bool ForRangeCopyCheck::handleConstValueCopy(const VarDecl 
&LoopVar,
       utils::type_traits::isExpensiveToCopy(LoopVar.getType(), Context);
   if (!Expensive || !*Expensive)
     return false;
-  auto Diagnostic =
+  const auto Diagnostic =
       diag(LoopVar.getLocation(),
            "the loop variable's type is not a reference type; this creates a "
            "copy in each iteration; consider making this a reference")
@@ -122,7 +122,7 @@ bool ForRangeCopyCheck::handleCopyIsOnlyConstReferenced(
   // Since this case is very rare, it is safe to ignore it.
   if (!ExprMutationAnalyzer(*ForRange.getBody(), Context).isMutated(&LoopVar) 
&&
       isReferenced(LoopVar, *ForRange.getBody(), Context)) {
-    auto Diag = diag(
+    const auto Diag = diag(
         LoopVar.getLocation(),
         "loop variable is copied but only used as const reference; consider "
         "making it a const reference");

diff  --git 
a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
index d073f00878020..93cd3a2229a25 100644
--- 
a/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/performance/InefficientVectorOperationCheck.cpp
@@ -259,10 +259,11 @@ void InefficientVectorOperationCheck::check(
     ReserveSize = std::string(LoopEndSource);
   }
 
-  auto Diag = diag(AppendCall->getBeginLoc(),
-                   "%0 is called inside a loop; consider pre-allocating the "
-                   "container capacity before the loop")
-              << AppendCall->getMethodDecl()->getDeclName();
+  const auto Diag =
+      diag(AppendCall->getBeginLoc(),
+           "%0 is called inside a loop; consider pre-allocating the "
+           "container capacity before the loop")
+      << AppendCall->getMethodDecl()->getDeclName();
   if (!ReserveSize.empty()) {
     const std::string ReserveStmt =
         (VarName + PartialReserveStmt + "(" + ReserveSize + ");\n").str();

diff  --git a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
index 8ea860fb7907a..be6a4f30e610e 100644
--- a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
@@ -154,16 +154,16 @@ void MoveConstArgCheck::check(const 
MatchFinder::MatchResult &Result) {
         IsVariable ? dyn_cast<DeclRefExpr>(Arg)->getDecl() : nullptr;
 
     {
-      auto Diag = diag(FileMoveRange.getBegin(),
-                       "std::move of the %select{|const }0"
-                       "%select{expression|variable %5}1 "
-                       "%select{|of the trivially-copyable type %6 }2"
-                       "has no effect%select{; remove std::move()|}3"
-                       "%select{| or make the variable non-const}4")
-                  << IsConstArg << IsVariable << IsTriviallyCopyable
-                  << IsRVRefParam
-                  << (IsConstArg && IsVariable && !IsTriviallyCopyable) << Var
-                  << Arg->getType();
+      const auto Diag = diag(FileMoveRange.getBegin(),
+                             "std::move of the %select{|const }0"
+                             "%select{expression|variable %5}1 "
+                             "%select{|of the trivially-copyable type %6 }2"
+                             "has no effect%select{; remove std::move()|}3"
+                             "%select{| or make the variable non-const}4")
+                        << IsConstArg << IsVariable << IsTriviallyCopyable
+                        << IsRVRefParam
+                        << (IsConstArg && IsVariable && !IsTriviallyCopyable)
+                        << Var << Arg->getType();
       if (!IsRVRefParam)
         replaceCallWithArg(CallMove, Diag, SM, getLangOpts());
     }
@@ -209,9 +209,10 @@ void MoveConstArgCheck::check(const 
MatchFinder::MatchResult &Result) {
       return;
 
     {
-      auto Diag = diag(FileMoveRange.getBegin(),
-                       "passing result of std::move() as a const reference "
-                       "argument; no move will actually happen");
+      const auto Diag =
+          diag(FileMoveRange.getBegin(),
+               "passing result of std::move() as a const reference "
+               "argument; no move will actually happen");
 
       replaceCallWithArg(CallMove, Diag, SM, getLangOpts());
     }

diff  --git 
a/clang-tools-extra/clang-tidy/performance/NoexceptFunctionBaseCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/NoexceptFunctionBaseCheck.cpp
index 895bd702d3834..33d80615fb19f 100644
--- a/clang-tools-extra/clang-tidy/performance/NoexceptFunctionBaseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/NoexceptFunctionBaseCheck.cpp
@@ -35,7 +35,7 @@ void NoexceptFunctionBaseCheck::check(const 
MatchFinder::MatchResult &Result) {
     return;
   }
 
-  auto Diag = reportMissingNoexcept(FuncDecl);
+  const auto Diag = reportMissingNoexcept(FuncDecl);
 
   // Add FixIt hints.
   const SourceManager &SM = *Result.SourceManager;

diff  --git 
a/clang-tools-extra/clang-tidy/performance/PreferSingleCharOverloadsCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/PreferSingleCharOverloadsCheck.cpp
index c29fef3b71c5e..d5d1784c0a0b7 100644
--- 
a/clang-tools-extra/clang-tidy/performance/PreferSingleCharOverloadsCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/performance/PreferSingleCharOverloadsCheck.cpp
@@ -34,12 +34,12 @@ makeCharacterLiteral(const StringLiteral *Literal) {
     Literal->outputString(OS);
   }
   // Now replace the " with '.
-  auto OpenPos = Result.find_first_of('"');
+  const auto OpenPos = Result.find_first_of('"');
   if (OpenPos == std::string::npos)
     return std::nullopt;
   Result[OpenPos] = '\'';
 
-  auto ClosePos = Result.find_last_of('"');
+  const auto ClosePos = Result.find_last_of('"');
   if (ClosePos == std::string::npos)
     return std::nullopt;
   Result[ClosePos] = '\'';

diff  --git 
a/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
index 9825cf254c97c..123d846213fd8 100644
--- a/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/TypePromotionInMathFnCheck.cpp
@@ -49,15 +49,15 @@ void 
TypePromotionInMathFnCheck::registerMatchers(MatchFinder *Finder) {
   constexpr BuiltinType::Kind DoubleTy = BuiltinType::Double;
   constexpr BuiltinType::Kind LongDoubleTy = BuiltinType::LongDouble;
 
-  auto HasBuiltinTyParam = [](int Pos, BuiltinType::Kind Kind) {
+  const auto HasBuiltinTyParam = [](int Pos, BuiltinType::Kind Kind) {
     return hasParameter(Pos, hasType(isBuiltinType(Kind)));
   };
-  auto HasBuiltinTyArg = [](int Pos, BuiltinType::Kind Kind) {
+  const auto HasBuiltinTyArg = [](int Pos, BuiltinType::Kind Kind) {
     return hasArgument(Pos, hasType(isBuiltinType(Kind)));
   };
 
   // Match calls to foo(double) with a float argument.
-  auto OneDoubleArgFns = hasAnyName(
+  const auto OneDoubleArgFns = hasAnyName(
       "::acos", "::acosh", "::asin", "::asinh", "::atan", "::atanh", "::cbrt",
       "::ceil", "::cos", "::cosh", "::erf", "::erfc", "::exp", "::exp2",
       "::expm1", "::fabs", "::floor", "::ilogb", "::lgamma", "::llrint",
@@ -72,9 +72,9 @@ void TypePromotionInMathFnCheck::registerMatchers(MatchFinder 
*Finder) {
       this);
 
   // Match calls to foo(double, double) where both args are floats.
-  auto TwoDoubleArgFns = hasAnyName("::atan2", "::copysign", "::fdim", 
"::fmax",
-                                    "::fmin", "::fmod", "::hypot", "::ldexp",
-                                    "::nextafter", "::pow", "::remainder");
+  const auto TwoDoubleArgFns = hasAnyName(
+      "::atan2", "::copysign", "::fdim", "::fmax", "::fmin", "::fmod",
+      "::hypot", "::ldexp", "::nextafter", "::pow", "::remainder");
   Finder->addMatcher(
       callExpr(callee(functionDecl(TwoDoubleArgFns, parameterCountIs(2),
                                    HasBuiltinTyParam(0, DoubleTy),
@@ -177,10 +177,11 @@ void TypePromotionInMathFnCheck::check(const 
MatchFinder::MatchResult &Result) {
     NewFnName = (OldFnName + "f").str();
   }
 
-  auto Diag = diag(Call->getExprLoc(), "call to '%0' promotes float to double")
-              << OldFnName
-              << FixItHint::CreateReplacement(
-                     Call->getCallee()->getSourceRange(), NewFnName);
+  const auto Diag =
+      diag(Call->getExprLoc(), "call to '%0' promotes float to double")
+      << OldFnName
+      << FixItHint::CreateReplacement(Call->getCallee()->getSourceRange(),
+                                      NewFnName);
 
   // Suggest including <cmath> if the function we're suggesting is declared in
   // <cmath> and it's not already included.  We never have to suggest including

diff  --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
index 36dc028248fee..1c61029ffc47b 100644
--- 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
@@ -50,17 +50,18 @@ firstLocAfterNewLine(SourceLocation Loc, const 
SourceManager &SM) {
 
 static void recordRemoval(const DeclStmt &Stmt, ASTContext &Context,
                           const DiagnosticBuilder &Diagnostic) {
-  auto &SM = Context.getSourceManager();
+  const auto &SM = Context.getSourceManager();
   // Attempt to remove trailing comments as well.
   auto Tok = utils::lexer::findNextTokenSkippingComments(Stmt.getEndLoc(), SM,
                                                          
Context.getLangOpts());
   std::optional<SourceLocation> PastNewLine =
       firstLocAfterNewLine(Stmt.getEndLoc(), SM);
   if (Tok && PastNewLine) {
-    auto BeforeFirstTokenAfterComment = 
Tok->getLocation().getLocWithOffset(-1);
+    const auto BeforeFirstTokenAfterComment =
+        Tok->getLocation().getLocWithOffset(-1);
     // Remove until the end of the line or the end of a trailing comment which
     // ever comes first.
-    auto End =
+    const auto End =
         SM.isBeforeInTranslationUnit(*PastNewLine, 
BeforeFirstTokenAfterComment)
             ? *PastNewLine
             : BeforeFirstTokenAfterComment;
@@ -119,7 +120,7 @@ AST_MATCHER_FUNCTION(StatementMatcher, 
isConstRefReturningFunctionCall) {
 
 AST_MATCHER_FUNCTION_P(StatementMatcher, initializerReturnsReferenceToConst,
                        std::vector<StringRef>, ExcludedContainerTypes) {
-  auto OldVarDeclRef =
+  const auto OldVarDeclRef =
       declRefExpr(to(varDecl(hasLocalStorage()).bind(OldVarDeclId)));
   return expr(
       anyOf(isConstRefReturningFunctionCall(),
@@ -161,7 +162,7 @@ static bool isInitializingVariableImmutable(
   if (!InitializingVar.isLocalVarDecl() || !InitializingVar.hasInit())
     return true;
 
-  auto Matches =
+  const auto Matches =
       match(initializerReturnsReferenceToConst(ExcludedContainerTypes),
             *InitializingVar.getInit(), Context);
   // The reference is initialized from a free function without arguments
@@ -187,7 +188,7 @@ static bool isVariableUnused(const VarDecl &Var, const Stmt 
&BlockStmt,
 
 static const SubstTemplateTypeParmType *
 getSubstitutedType(const QualType &Type, ASTContext &Context) {
-  auto Matches = match(
+  const auto Matches = match(
       qualType(anyOf(substTemplateTypeParmType().bind("subst"),
                      
hasDescendant(substTemplateTypeParmType().bind("subst")))),
       Type, Context);
@@ -231,7 +232,7 @@ 
UnnecessaryCopyInitializationCheck::UnnecessaryCopyInitializationCheck(
           Options.get("ExcludedContainerTypes", ""))) {}
 
 void UnnecessaryCopyInitializationCheck::registerMatchers(MatchFinder *Finder) 
{
-  auto LocalVarCopiedFrom =
+  const auto LocalVarCopiedFrom =
       [this](const ast_matchers::internal::Matcher<Expr> &CopyCtorArg) {
         return compoundStmt(
                    forEachDescendant(

diff  --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
index f126dbe678238..4a122f56a03aa 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -29,7 +29,7 @@ static std::string paramNameOrIndex(StringRef Name, size_t 
Index) {
 
 static bool hasLoopStmtAncestor(const DeclRefExpr &DeclRef, const Decl &Decl,
                                 ASTContext &Context) {
-  auto Matches = match(
+  const auto Matches = match(
       traverse(TK_AsIs,
                decl(forEachDescendant(declRefExpr(
                    equalsNode(&DeclRef),
@@ -90,10 +90,10 @@ void UnnecessaryValueParamCheck::check(const 
MatchFinder::MatchResult &Result) {
   // In this case wrap DeclRefExpr with std::move() to avoid the unnecessary
   // copy.
   if (!IsConstQualified) {
-    auto AllDeclRefExprs = utils::decl_ref_expr::allDeclRefExprs(
+    const auto AllDeclRefExprs = utils::decl_ref_expr::allDeclRefExprs(
         *Param, *Function, *Result.Context);
     if (AllDeclRefExprs.size() == 1) {
-      auto CanonicalType = Param->getType().getCanonicalType();
+      const auto CanonicalType = Param->getType().getCanonicalType();
       const auto &DeclRefExpr = **AllDeclRefExprs.begin();
 
       if (!hasLoopStmtAncestor(DeclRefExpr, *Function, *Result.Context) &&
@@ -137,7 +137,7 @@ void UnnecessaryValueParamCheck::handleConstRefFix(const 
FunctionDecl &Function,
   const bool IsConstQualified =
       Param.getType().getCanonicalType().isConstQualified();
 
-  auto Diag =
+  const auto Diag =
       diag(Param.getLocation(),
            "the %select{|const qualified }0parameter %1 of type %2 is copied "
            "for each "
@@ -171,7 +171,7 @@ void UnnecessaryValueParamCheck::handleConstRefFix(const 
FunctionDecl &Function,
 void UnnecessaryValueParamCheck::handleMoveFix(const ParmVarDecl &Param,
                                                const DeclRefExpr &CopyArgument,
                                                ASTContext &Context) {
-  auto Diag =
+  const auto Diag =
       diag(CopyArgument.getBeginLoc(),
            "parameter %0 of type %1 is passed by value and only copied once; "
            "consider moving it to avoid unnecessary copies")
@@ -180,8 +180,8 @@ void UnnecessaryValueParamCheck::handleMoveFix(const 
ParmVarDecl &Param,
   if (CopyArgument.getBeginLoc().isMacroID())
     return;
   const auto &SM = Context.getSourceManager();
-  auto EndLoc = Lexer::getLocForEndOfToken(CopyArgument.getLocation(), 0, SM,
-                                           Context.getLangOpts());
+  const auto EndLoc = Lexer::getLocForEndOfToken(CopyArgument.getLocation(), 0,
+                                                 SM, Context.getLangOpts());
   Diag << FixItHint::CreateInsertion(CopyArgument.getBeginLoc(), "std::move(")
        << FixItHint::CreateInsertion(EndLoc, ")")
        << Inserter.createIncludeInsertion(

diff  --git a/clang-tools-extra/clang-tidy/performance/UseStdMoveCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/UseStdMoveCheck.cpp
index 7c3bbc3187cd9..e2ea0cd112a3f 100644
--- a/clang-tools-extra/clang-tidy/performance/UseStdMoveCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UseStdMoveCheck.cpp
@@ -59,7 +59,7 @@ AST_POLYMORPHIC_MATCHER(isInMacro,
 using utils::decl_ref_expr::allDeclRefExprs;
 
 void UseStdMoveCheck::registerMatchers(MatchFinder *Finder) {
-  auto AssignOperatorExpr =
+  const auto AssignOperatorExpr =
       cxxOperatorCallExpr(
           isCopyAssignmentOperator(),
           hasArgument(0, hasType(cxxRecordDecl(

diff  --git 
a/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp 
b/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp
index 4225c3e15af98..69b110d12f1f9 100644
--- a/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/portability/RestrictSystemIncludesCheck.cpp
@@ -49,14 +49,14 @@ void RestrictedIncludesPPCallbacks::EndOfMainFile() {
           Include.Loc, Include.Loc.getLocWithOffset(ToLen));
 
       if (!Include.IsInMainFile) {
-        auto D = Check.diag(
+        const auto D = Check.diag(
             Include.Loc,
             "system include %0 not allowed, transitively included from %1");
         D << Include.IncludeFile << SM.getFilename(Include.Loc);
         D << FixItHint::CreateRemoval(ToRange);
         continue;
       }
-      auto D = Check.diag(Include.Loc, "system include %0 not allowed");
+      const auto D = Check.diag(Include.Loc, "system include %0 not allowed");
       D << Include.IncludeFile;
       D << FixItHint::CreateRemoval(ToRange);
     }

diff  --git 
a/clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp 
b/clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp
index b2cd846278479..2743af4bf4693 100644
--- a/clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp
+++ b/clang-tools-extra/clang-tidy/portability/StdAllocatorConstCheck.cpp
@@ -15,13 +15,13 @@ namespace clang::tidy::portability {
 
 void StdAllocatorConstCheck::registerMatchers(MatchFinder *Finder) {
   // Match std::allocator<const T>.
-  auto AllocatorConst = qualType(hasCanonicalType(
+  const auto AllocatorConst = qualType(hasCanonicalType(
       recordType(hasDeclaration(classTemplateSpecializationDecl(
           hasName("::std::allocator"),
           hasTemplateArgument(0,
                               refersToType(qualType(isConstQualified()))))))));
 
-  auto HasContainerName =
+  const auto HasContainerName =
       hasAnyName("::std::vector", "::std::deque", "::std::list",
                  "::std::multiset", "::std::set", "::std::unordered_multiset",
                  "::std::unordered_set", "::absl::flat_hash_set");

diff  --git 
a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDeclsCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDeclsCheck.cpp
index 506f8e2ddf934..2b778d22dfe4c 100644
--- a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDeclsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDeclsCheck.cpp
@@ -68,10 +68,11 @@ void AvoidConstParamsInDeclsCheck::check(
   const auto Tok = findConstToRemove(*Param, Result);
   const auto ConstLocation = Tok ? Tok->getLocation() : Param->getBeginLoc();
 
-  auto Diag = diag(ConstLocation,
-                   "parameter %0 is const-qualified in the function "
-                   "declaration; const-qualification of parameters only has an 
"
-                   "effect in function definitions");
+  const auto Diag =
+      diag(ConstLocation,
+           "parameter %0 is const-qualified in the function "
+           "declaration; const-qualification of parameters only has an "
+           "effect in function definitions");
   if (Param->getName().empty()) {
     for (unsigned int I = 0; I < Func->getNumParams(); ++I) {
       if (Param == Func->getParamDecl(I)) {

diff  --git 
a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
index 710b538317626..66af6fd26b5f7 100644
--- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -159,8 +159,8 @@ bool BracesAroundStatementsCheck::checkStmt(
         BraceInsertionHints.resultingCompoundLineExtent(*Result.SourceManager) 
<
             ShortStatementLines)
       return false;
-    auto Diag = diag(BraceInsertionHints.DiagnosticPos,
-                     "statement should be inside braces");
+    const auto Diag = diag(BraceInsertionHints.DiagnosticPos,
+                           "statement should be inside braces");
     if (BraceInsertionHints.offersFixIts())
       Diag << BraceInsertionHints.openingBraceFixIt()
            << BraceInsertionHints.closingBraceFixIt();

diff  --git a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
index 405174ee0209b..4e5756d0975cd 100644
--- a/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -139,7 +139,7 @@ void ConstReturnTypeCheck::check(const 
MatchFinder::MatchResult &Result) {
     for (auto &Hint : CR.Hints)
       Diagnostic << Hint;
   }
-  for (auto Loc : CR.DeclLocs)
+  for (const auto Loc : CR.DeclLocs)
     diag(Loc, "could not transform this declaration", DiagnosticIDs::Note);
 }
 

diff  --git 
a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
index 3b4113c4e2ed0..701fab500f646 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
@@ -96,8 +96,8 @@ void ContainerContainsCheck::check(const 
MatchFinder::MatchResult &Result) {
   const Expr *SearchExpr = Call->getArg(0)->IgnoreParenImpCasts();
 
   // Diagnose the issue.
-  auto Diag = diag(Call->getExprLoc(), "use '%0' to check for membership")
-              << ContainsFunName;
+  const auto Diag = diag(Call->getExprLoc(), "use '%0' to check for 
membership")
+                    << ContainsFunName;
 
   // Don't fix it if it's in a macro invocation. Leave fixing it to the user.
   const SourceLocation FuncCallLoc = Comparison->getEndLoc();

diff  --git 
a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
index 33fe48048b356..5dda3f3297d2f 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -58,7 +58,7 @@ AST_POLYMORPHIC_MATCHER_P2(hasAnyArgumentWithParam,
 
 AST_MATCHER(Expr, usedInBooleanContext) {
   const char *ExprName = "__booleanContextExpr";
-  auto Result =
+  const auto Result =
       expr(expr().bind(ExprName),
            anyOf(hasParent(
                      mapAnyOf(varDecl, 
fieldDecl).with(hasType(booleanType()))),
@@ -408,8 +408,9 @@ void ContainerSizeEmptyCheck::check(const 
MatchFinder::MatchResult &Result) {
   auto WarnLoc = MemberCall ? MemberCall->getBeginLoc() : SourceLocation{};
 
   if (WarnLoc.isValid()) {
-    auto Diag = diag(WarnLoc, "the 'empty' method should be used to check "
-                              "for emptiness instead of %0");
+    const auto Diag =
+        diag(WarnLoc, "the 'empty' method should be used to check "
+                      "for emptiness instead of %0");
     if (const auto *SizeMethod =
             Result.Nodes.getNodeAs<NamedDecl>("SizeMethod"))
       Diag << SizeMethod->getDeclName();

diff  --git 
a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp
 
b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp
index 1587c63eea10e..62c786abaf174 100644
--- 
a/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStaticCheck.cpp
@@ -91,8 +91,8 @@ AST_MATCHER(CXXMethodDecl, hasNonConstOverload) {
   if (LookupResult.isSingleResult())
     return false;
 
-  auto HasSameParameterTypes = [](const CXXMethodDecl &MD1,
-                                  const CXXMethodDecl &MD2) {
+  const auto HasSameParameterTypes = [](const CXXMethodDecl &MD1,
+                                        const CXXMethodDecl &MD2) {
     if (MD1.getNumParams() != MD2.getNumParams())
       return false;
     for (unsigned I = 0, E = MD1.getNumParams(); I < E; ++I)

diff  --git 
a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
index f469115594611..d30a6e816832b 100644
--- a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
@@ -57,7 +57,7 @@ void DeleteNullPointerCheck::check(const 
MatchFinder::MatchResult &Result) {
       Result.Nodes.getNodeAs<IfStmt>("ifWithScopedCondition") != nullptr;
   const auto *Compound = Result.Nodes.getNodeAs<CompoundStmt>("compound");
 
-  auto Diag = diag(
+  const auto Diag = diag(
       IfWithDelete->getBeginLoc(),
       "'if' statement is unnecessary; deleting null pointer has no effect");
   if (HasScopedCondition || IfWithDelete->hasElseStorage())

diff  --git a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
index dcdb013190df3..be1257da1f5e4 100644
--- a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -127,7 +127,7 @@ static bool containsDeclInScope(const Stmt *Node) {
 static void removeElseAndBrackets(const DiagnosticBuilder &Diag,
                                   ASTContext &Context, const Stmt *Else,
                                   SourceLocation ElseLoc) {
-  auto Remap = [&](SourceLocation Loc) {
+  const auto Remap = [&](SourceLocation Loc) {
     return Context.getSourceManager().getExpansionLoc(Loc);
   };
 
@@ -190,7 +190,7 @@ static bool hasPreprocessorBranchEndBetweenLocations(
 
   assert(ExpandedStartLoc < ExpandedEndLoc);
 
-  auto Iter = ConditionalBranchMap.find(SM.getFileID(ExpandedEndLoc));
+  const auto Iter = ConditionalBranchMap.find(SM.getFileID(ExpandedEndLoc));
 
   if (Iter == ConditionalBranchMap.end() || Iter->getSecond().empty())
     return false;

diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierLengthCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierLengthCheck.cpp
index 379714a9ae2ba..60af9e6503daf 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierLengthCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierLengthCheck.cpp
@@ -138,8 +138,9 @@ static bool isShortLived(const ValueDecl *Var, const 
SourceManager *SrcMgr,
 }
 
 void IdentifierLengthCheck::check(const MatchFinder::MatchResult &Result) {
-  auto WarnIfTooShort = [&](const ValueDecl *Var, unsigned MinNameLength,
-                            const llvm::Regex &IgnoredNames, unsigned VarKind) 
{
+  const auto WarnIfTooShort = [&](const ValueDecl *Var, unsigned MinNameLength,
+                                  const llvm::Regex &IgnoredNames,
+                                  unsigned VarKind) {
     if (!Var->getIdentifier())
       return;
 

diff  --git 
a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 42f3101592758..86cc399611a83 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -263,7 +263,7 @@ IdentifierNamingCheck::FileStyle 
IdentifierNamingCheck::getFileStyleFromOptions(
     const size_t StyleSize = StyleNames[I].size();
     StyleString.assign({StyleNames[I], "HungarianPrefix"});
 
-    auto HPTOpt =
+    const auto HPTOpt =
         Options.get<IdentifierNamingCheck::HungarianPrefixType>(StyleString);
     if (HPTOpt && !HungarianNotation.checkOptionValid(I))
       configurationDiag("invalid identifier naming option '%0'") << 
StyleString;
@@ -304,7 +304,7 @@ std::string 
IdentifierNamingCheck::HungarianNotation::getDeclTypeName(
     return {};
 
   // Get type text of variable declarations.
-  auto &SM = VD->getASTContext().getSourceManager();
+  const auto &SM = VD->getASTContext().getSourceManager();
   const char *Begin = SM.getCharacterData(VD->getBeginLoc());
   const char *End = SM.getCharacterData(VD->getEndLoc());
   intptr_t StrLen = End - Begin;
@@ -403,7 +403,7 @@ IdentifierNamingCheck::IdentifierNamingCheck(StringRef Name,
     : RenamerClangTidyCheck(Name, Context), Context(Context),
       GetConfigPerFile(Options.get("GetConfigPerFile", true)),
       IgnoreFailedSplit(Options.get("IgnoreFailedSplit", false)) {
-  auto IterAndInserted = NamingStylesCache.try_emplace(
+  const auto IterAndInserted = NamingStylesCache.try_emplace(
       llvm::sys::path::parent_path(Context->getCurrentFile()),
       getFileStyleFromOptions(Options));
   assert(IterAndInserted.second && "Couldn't insert Style");
@@ -431,7 +431,7 @@ bool 
IdentifierNamingCheck::HungarianNotation::isOptionEnabled(
   if (OptionKey.empty())
     return false;
 
-  auto Iter = StrMap.find(OptionKey);
+  const auto Iter = StrMap.find(OptionKey);
   if (Iter == StrMap.end())
     return false;
 
@@ -1035,7 +1035,7 @@ bool IdentifierNamingCheck::isParamInMainLikeFunction(
   if (!FDecl->getDeclName().isIdentifier())
     return false;
   enum MainType { None, Main, WMain };
-  auto IsCharPtrPtr = [](QualType QType) -> MainType {
+  const auto IsCharPtrPtr = [](QualType QType) -> MainType {
     if (QType.isNull())
       return None;
     if (QType = QType->getPointeeType(), QType.isNull())
@@ -1048,7 +1048,7 @@ bool IdentifierNamingCheck::isParamInMainLikeFunction(
       return WMain;
     return None;
   };
-  auto IsIntType = [](QualType QType) {
+  const auto IsIntType = [](QualType QType) {
     if (QType.isNull())
       return false;
     if (const auto *Builtin =
@@ -1437,7 +1437,7 @@ IdentifierNamingCheck::getDiagInfo(const NamingCheckId 
&ID,
 }
 
 StringRef IdentifierNamingCheck::getRealFileName(StringRef FileName) const {
-  auto Iter = RealFileNameCache.try_emplace(FileName);
+  const auto Iter = RealFileNameCache.try_emplace(FileName);
   SmallString<256U> &RealFileName = Iter.first->getValue();
   if (!Iter.second)
     return RealFileName;
@@ -1452,21 +1452,21 @@ IdentifierNamingCheck::getStyleForFile(StringRef 
FileName) const {
 
   const StringRef RealFileName = getRealFileName(FileName);
   const StringRef Parent = llvm::sys::path::parent_path(RealFileName);
-  auto Iter = NamingStylesCache.find(Parent);
+  const auto Iter = NamingStylesCache.find(Parent);
   if (Iter != NamingStylesCache.end())
     return Iter->getValue();
 
   const StringRef CheckName = getID();
   ClangTidyOptions Options = Context->getOptionsForFile(RealFileName);
   if (Options.Checks && GlobList(*Options.Checks).contains(CheckName)) {
-    auto It = NamingStylesCache.try_emplace(
+    const auto It = NamingStylesCache.try_emplace(
         Parent,
         getFileStyleFromOptions({CheckName, Options.CheckOptions, Context}));
     assert(It.second);
     return It.first->getValue();
   }
   // Default construction gives an empty style.
-  auto It = NamingStylesCache.try_emplace(Parent);
+  const auto It = NamingStylesCache.try_emplace(Parent);
   assert(It.second);
   return It.first->getValue();
 }

diff  --git 
a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
index 636872e2ed187..ed63a8ec044b3 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -282,7 +282,7 @@ void 
ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
                  expr(hasType(qualType().bind("type")),
                       hasParent(initListExpr(hasParent(explicitCastExpr(
                           hasType(qualType(equalsBoundNode("type"))))))))));
-  auto ImplicitCastFromBool = implicitCastExpr(
+  const auto ImplicitCastFromBool = implicitCastExpr(
       anyOf(hasCastKind(CK_IntegralCast), hasCastKind(CK_IntegralToFloating),
             // Prior to C++11 cast from bool literal to pointer was allowed.
             allOf(anyOf(hasCastKind(CK_NullToPointer),
@@ -335,10 +335,11 @@ void 
ImplicitBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
                                          hasLHS(expr(hasType(booleanType()))));
   auto BitfieldAssignment = binaryOperator(
       hasLHS(memberExpr(hasDeclaration(fieldDecl(hasBitWidth(1))))));
-  auto BitfieldConstruct = cxxConstructorDecl(hasDescendant(cxxCtorInitializer(
-      withInitializer(equalsBoundNode("implicitCastFromBool")),
-      forField(hasBitWidth(1)))));
-  auto BoolTernaryCondition = conditionalOperator(
+  const auto BitfieldConstruct =
+      cxxConstructorDecl(hasDescendant(cxxCtorInitializer(
+          withInitializer(equalsBoundNode("implicitCastFromBool")),
+          forField(hasBitWidth(1)))));
+  const auto BoolTernaryCondition = conditionalOperator(
       hasCondition(equalsBoundNode("implicitCastFromBool")));
   Finder->addMatcher(
       traverse(
@@ -407,9 +408,10 @@ void ImplicitBoolConversionCheck::handleCastToBool(const 
ImplicitCastExpr *Cast,
     return;
   }
 
-  auto Diag = diag(Context.getSourceManager().getFileLoc(Cast->getBeginLoc()),
-                   "implicit conversion %0 -> 'bool'")
-              << Cast->getSubExpr()->getType();
+  const auto Diag =
+      diag(Context.getSourceManager().getFileLoc(Cast->getBeginLoc()),
+           "implicit conversion %0 -> 'bool'")
+      << Cast->getSubExpr()->getType();
 
   const StringRef EquivalentLiteral =
       getEquivalentBoolLiteralForExpr(Cast->getSubExpr(), Context);
@@ -426,9 +428,10 @@ void ImplicitBoolConversionCheck::handleCastFromBool(
     ASTContext &Context) {
   const QualType DestType =
       NextImplicitCast ? NextImplicitCast->getType() : Cast->getType();
-  auto Diag = diag(Context.getSourceManager().getFileLoc(Cast->getBeginLoc()),
-                   "implicit conversion 'bool' -> %0")
-              << DestType;
+  const auto Diag =
+      diag(Context.getSourceManager().getFileLoc(Cast->getBeginLoc()),
+           "implicit conversion 'bool' -> %0")
+      << DestType;
 
   if (const auto *BoolLiteral =
           dyn_cast<CXXBoolLiteralExpr>(Cast->getSubExpr()->IgnoreParens())) {

diff  --git 
a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
 
b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
index eb7bb6f14e382..97d6fa5605a98 100644
--- 
a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
@@ -18,7 +18,7 @@ namespace {
 
 AST_MATCHER(FunctionDecl, hasOtherDeclarations) {
   auto It = Node.redecls_begin();
-  auto EndIt = Node.redecls_end();
+  const auto EndIt = Node.redecls_end();
 
   if (It == EndIt)
     return false;
@@ -218,7 +218,7 @@ static void formatDifferingParamsDiagnostic(
     return ParamInfo.SourceName;
   };
 
-  auto ParamDiag =
+  const auto ParamDiag =
       Check->diag(Location,
                   "
diff ering parameters are named here: (%0), in %1: (%2)",
                   DiagnosticIDs::Level::Note)

diff  --git 
a/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
index 88a54917a5ef5..07673e3207f3b 100644
--- a/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IsolateDeclarationCheck.cpp
@@ -246,7 +246,7 @@ createIsolatedDecls(llvm::ArrayRef<StringRef> Snippets) {
 void IsolateDeclarationCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *WholeDecl = Result.Nodes.getNodeAs<DeclStmt>("decl_stmt");
 
-  auto Diag =
+  const auto Diag =
       diag(WholeDecl->getBeginLoc(),
            "multiple declarations in a single statement reduces readability");
 

diff  --git 
a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
index e8875d014fe21..967c63db51dd7 100644
--- a/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp
@@ -244,7 +244,7 @@ static SourceLocation getConstInsertionPoint(const 
CXXMethodDecl *M) {
   if (!TSI)
     return {};
 
-  auto FTL = TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>();
+  const auto FTL = TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>();
   if (!FTL)
     return {};
 
@@ -257,10 +257,11 @@ void MakeMemberFunctionConstCheck::check(
 
   const auto *Declaration = Definition->getCanonicalDecl();
 
-  auto Diag = diag(Definition->getLocation(), "method %0 can be made const")
-              << Definition
-              << FixItHint::CreateInsertion(getConstInsertionPoint(Definition),
-                                            " const");
+  const auto Diag =
+      diag(Definition->getLocation(), "method %0 can be made const")
+      << Definition
+      << FixItHint::CreateInsertion(getConstInsertionPoint(Definition),
+                                    " const");
   if (Declaration != Definition) {
     Diag << FixItHint::CreateInsertion(getConstInsertionPoint(Declaration),
                                        " const");

diff  --git 
a/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
index a9c1b6a688d98..fa76333ba63ef 100644
--- a/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
@@ -70,7 +70,7 @@ static void addParentheses(const Expr *E, const 
BinaryOperator *ParentBinOp,
     const SourceLocation EndLoc =
         Lexer::getLocForEndOfToken(BinOp->getEndLoc(), 0, SM, LangOpts);
 
-    auto Diag =
+    const auto Diag =
         Check->diag(StartLoc,
                     "'%0' has higher precedence than '%1'; add parentheses to "
                     "explicitly specify the order of operations")

diff  --git 
a/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp
index 450961c8b4fee..72d791f896039 100644
--- a/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MisleadingIndentationCheck.cpp
@@ -17,7 +17,7 @@ namespace clang::tidy::readability {
 
 static const IfStmt *getPrecedingIf(const SourceManager &SM,
                                     ASTContext *Context, const IfStmt *If) {
-  auto Parents = Context->getParents(*If);
+  const auto Parents = Context->getParents(*If);
   if (Parents.size() != 1)
     return nullptr;
   if (const auto *PrecedingIf = Parents[0].get<IfStmt>()) {

diff  --git 
a/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp
index 0052af6f5d1d1..405362938b351 100644
--- a/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MisplacedArrayIndexCheck.cpp
@@ -28,9 +28,10 @@ void MisplacedArrayIndexCheck::check(const 
MatchFinder::MatchResult &Result) {
   const auto *ArraySubscriptE =
       Result.Nodes.getNodeAs<ArraySubscriptExpr>("expr");
 
-  auto Diag = diag(ArraySubscriptE->getBeginLoc(), "confusing array subscript "
-                                                   "expression, usually the "
-                                                   "index is inside the []");
+  const auto Diag =
+      diag(ArraySubscriptE->getBeginLoc(), "confusing array subscript "
+                                           "expression, usually the "
+                                           "index is inside the []");
 
   // Only try to fixit when LHS and RHS can be swapped directly without 
changing
   // the logic.

diff  --git a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
index ebe8148bc4fbf..a7bd42e7b39f0 100644
--- a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
@@ -132,10 +132,10 @@ void NamedParameterCheck::check(const 
MatchFinder::MatchResult &Result) {
   if (!UnnamedParams.empty()) {
     const ParmVarDecl *FirstParm =
         
UnnamedParams.front().first->getParamDecl(UnnamedParams.front().second);
-    auto D = diag(FirstParm->getLocation(),
-                  "all parameters should be named in a function");
+    const auto D = diag(FirstParm->getLocation(),
+                        "all parameters should be named in a function");
 
-    for (auto P : UnnamedParams) {
+    for (const auto P : UnnamedParams) {
       // Fallback to an unused marker.
       static constexpr StringRef FallbackName = "unused";
       StringRef NewName = FallbackName;

diff  --git 
a/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
index 004df8b9af929..4cc72bb14917a 100644
--- a/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
@@ -185,7 +185,7 @@ void NonConstParameterCheck::addParm(const ParmVarDecl 
*Parm) {
 }
 
 void NonConstParameterCheck::setReferenced(const DeclRefExpr *Ref) {
-  auto It = Parameters.find(dyn_cast<ParmVarDecl>(Ref->getDecl()));
+  const auto It = Parameters.find(dyn_cast<ParmVarDecl>(Ref->getDecl()));
   if (It != Parameters.end())
     It->second.IsReferenced = true;
 }
@@ -298,7 +298,7 @@ void NonConstParameterCheck::markCanNotBeConst(const Expr 
*E,
   } else if (CanNotBeConst) {
     // Referencing parameter.
     if (const auto *D = dyn_cast<DeclRefExpr>(E)) {
-      auto It = Parameters.find(dyn_cast<ParmVarDecl>(D->getDecl()));
+      const auto It = Parameters.find(dyn_cast<ParmVarDecl>(D->getDecl()));
       if (It != Parameters.end())
         It->second.CanBeConst = false;
     }

diff  --git a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
index 4ba80541ad565..c9d619dcf0240 100644
--- a/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/QualifiedAutoCheck.cpp
@@ -118,7 +118,7 @@ void 
QualifiedAutoCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void QualifiedAutoCheck::registerMatchers(MatchFinder *Finder) {
-  auto ExplicitSingleVarDecl =
+  const auto ExplicitSingleVarDecl =
       [](const ast_matchers::internal::Matcher<VarDecl> &InnerMatcher,
          StringRef ID) {
         return declStmt(
@@ -126,7 +126,7 @@ void QualifiedAutoCheck::registerMatchers(MatchFinder 
*Finder) {
             hasSingleDecl(
                 varDecl(unless(isImplicit()), InnerMatcher).bind(ID)));
       };
-  auto ExplicitSingleVarDeclInTemplate =
+  const auto ExplicitSingleVarDeclInTemplate =
       [](const ast_matchers::internal::Matcher<VarDecl> &InnerMatcher,
          StringRef ID) {
         return declStmt(
@@ -135,10 +135,11 @@ void QualifiedAutoCheck::registerMatchers(MatchFinder 
*Finder) {
                 varDecl(unless(isImplicit()), InnerMatcher).bind(ID)));
       };
 
-  auto IsBoundToType = refersToType(equalsBoundNode("type"));
-  auto UnlessFunctionType = 
unless(hasUnqualifiedDesugaredType(functionType()));
+  const auto IsBoundToType = refersToType(equalsBoundNode("type"));
+  const auto UnlessFunctionType =
+      unless(hasUnqualifiedDesugaredType(functionType()));
 
-  auto IsPointerType = [this](const auto &...InnerMatchers) {
+  const auto IsPointerType = [this](const auto &...InnerMatchers) {
     if (this->IgnoreAliasing) {
       return qualType(
           hasUnqualifiedDesugaredType(pointerType(pointee(InnerMatchers...))));
@@ -148,7 +149,7 @@ void QualifiedAutoCheck::registerMatchers(MatchFinder 
*Finder) {
                               pointerType(pointee(InnerMatchers...)))))));
   };
 
-  auto IsAutoDeducedToPointer =
+  const auto IsAutoDeducedToPointer =
       [IsPointerType](const std::vector<StringRef> &AllowedTypes,
                       const auto &...InnerMatchers) {
         return autoType(hasDeducedType(
@@ -198,7 +199,7 @@ void QualifiedAutoCheck::check(const 
MatchFinder::MatchResult &Result) {
     }
 
     SmallVector<SourceRange, 4> RemoveQualifiersRange;
-    auto CheckQualifier = [&](bool IsPresent, Qualifier Qual) {
+    const auto CheckQualifier = [&](bool IsPresent, Qualifier Qual) {
       if (IsPresent) {
         std::optional<Token> Token = findQualToken(Var, Qual, Result);
         if (!Token || Token->getLocation().isMacroID())

diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
index e35466158f800..6145883262d37 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
@@ -167,9 +167,10 @@ void RedundantCastingCheck::check(const 
MatchFinder::MatchResult &Result) {
     return;
 
   {
-    auto Diag = diag(CastExpr->getExprLoc(),
-                     "redundant explicit casting to the same type %0 as the "
-                     "sub-expression, remove this casting");
+    const auto Diag =
+        diag(CastExpr->getExprLoc(),
+             "redundant explicit casting to the same type %0 as the "
+             "sub-expression, remove this casting");
     Diag << TypeD;
 
     const SourceManager &SM = *Result.SourceManager;

diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
index 0f12b8bcea6fb..5d1088940b0f0 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantDeclarationCheck.cpp
@@ -82,7 +82,7 @@ void RedundantDeclarationCheck::check(const 
MatchFinder::MatchResult &Result) {
   const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
       D->getSourceRange().getEnd(), 0, SM, Result.Context->getLangOpts());
   {
-    auto Diag = diag(D->getLocation(), "redundant %0 declaration") << D;
+    const auto Diag = diag(D->getLocation(), "redundant %0 declaration") << D;
     if (!MultiVar && !DifferentHeaders) {
       SourceLocation BeginLoc;
       if (const auto *Extern =

diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp
index 15c9669aa0a8e..7785f9f78ce3a 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp
@@ -60,7 +60,7 @@ void 
RedundantMemberInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void RedundantMemberInitCheck::registerMatchers(MatchFinder *Finder) {
-  auto ConstructorMatcher =
+  const auto ConstructorMatcher =
       cxxConstructExpr(
           argumentCountIs(0),
           hasDeclaration(cxxConstructorDecl(
@@ -74,7 +74,7 @@ void RedundantMemberInitCheck::registerMatchers(MatchFinder 
*Finder) {
 
   auto HasUnionAsParent = hasParent(recordDecl(isUnion()));
 
-  auto HasTypeEqualToConstructorClass = hasType(qualType(
+  const auto HasTypeEqualToConstructorClass = hasType(qualType(
       hasCanonicalType(qualType(hasDeclaration(equalsBoundNode("class"))))));
 
   Finder->addMatcher(
@@ -103,7 +103,7 @@ void RedundantMemberInitCheck::check(const 
MatchFinder::MatchResult &Result) {
 
   if (const auto *Field = Result.Nodes.getNodeAs<FieldDecl>("field")) {
     const Expr *Init = Field->getInClassInitializer();
-    auto Diag =
+    const auto Diag =
         diag(Construct->getExprLoc(), "initializer for member %0 is redundant")
         << Field;
     if (!Init->getBeginLoc().isMacroID() && !Init->getEndLoc().isMacroID())

diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
index a0ae94891f552..8435c438360a5 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantParenthesesCheck.cpp
@@ -39,7 +39,7 @@ static FixItHint createSpacedRemoval(SourceLocation Loc,
                                      const SourceManager &SM,
                                      const LangOptions &LangOpts) {
   if (Loc.isValid() && !Loc.isMacroID()) {
-    auto LocInfo = SM.getDecomposedLoc(Loc);
+    const auto LocInfo = SM.getDecomposedLoc(Loc);
     bool Invalid = false;
     StringRef Buffer = SM.getBufferData(LocInfo.first, &Invalid);
     if (!Invalid && LocInfo.second > 0 && LocInfo.second + 1 < Buffer.size() &&

diff  --git 
a/clang-tools-extra/clang-tidy/readability/RedundantQualifiedAliasCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/RedundantQualifiedAliasCheck.cpp
index a306f205a8447..b11eb06fb6a67 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantQualifiedAliasCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantQualifiedAliasCheck.cpp
@@ -210,8 +210,9 @@ void RedundantQualifiedAliasCheck::check(
   if (EqualRange.isInvalid())
     return;
 
-  auto Diag = diag(Alias->getLocation(),
-                   "type alias is redundant; use a using-declaration instead");
+  const auto Diag =
+      diag(Alias->getLocation(),
+           "type alias is redundant; use a using-declaration instead");
 
   Diag << FixItHint::CreateRemoval(Alias->getLocation())
        << FixItHint::CreateRemoval(EqualRange.getBegin());

diff  --git 
a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
index b0e95c0afc184..cc82e052d58da 100644
--- a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
@@ -56,7 +56,7 @@ static std::pair<BinaryOperatorKind, BinaryOperatorKind> 
Opposites[] = {
 
 static StringRef negatedOperator(const BinaryOperator *BinOp) {
   const BinaryOperatorKind Opcode = BinOp->getOpcode();
-  for (auto NegatableOp : Opposites) {
+  for (const auto NegatableOp : Opposites) {
     if (Opcode == NegatableOp.first)
       return BinaryOperator::getOpcodeStr(NegatableOp.second);
     if (Opcode == NegatableOp.second)
@@ -70,7 +70,7 @@ static std::pair<OverloadedOperatorKind, StringRef> 
OperatorNames[] = {
     {OO_GreaterEqual, ">="}, {OO_Greater, ">"},       {OO_LessEqual, "<="}};
 
 static StringRef getOperatorName(OverloadedOperatorKind OpKind) {
-  for (auto Name : OperatorNames)
+  for (const auto Name : OperatorNames)
     if (Name.first == OpKind)
       return Name.second;
 
@@ -84,7 +84,7 @@ static std::pair<OverloadedOperatorKind, 
OverloadedOperatorKind>
 
 static StringRef negatedOperator(const CXXOperatorCallExpr *OpCall) {
   const OverloadedOperatorKind Opcode = OpCall->getOperator();
-  for (auto NegatableOp : OppositeOverloads) {
+  for (const auto NegatableOp : OppositeOverloads) {
     if (Opcode == NegatableOp.first)
       return getOperatorName(NegatableOp.second);
     if (Opcode == NegatableOp.second)
@@ -395,8 +395,8 @@ class SimplifyBooleanExprCheck::Visitor : public 
RecursiveASTVisitor<Visitor> {
          */
         Expr *Var = nullptr;
         SourceLocation Loc;
-        auto VarBoolAssignmentMatcher = [&Var,
-                                         &Loc](const Stmt *S) -> DeclAndBool {
+        const auto VarBoolAssignmentMatcher =
+            [&Var, &Loc](const Stmt *S) -> DeclAndBool {
           const auto *BO = dyn_cast<BinaryOperator>(S);
           if (!BO || BO->getOpcode() != BO_Assign)
             return {};
@@ -412,7 +412,7 @@ class SimplifyBooleanExprCheck::Visitor : public 
RecursiveASTVisitor<Visitor> {
           }
           if (auto *DRE = dyn_cast<DeclRefExpr>(IgnImp))
             return {DRE->getDecl(), *RightasBool};
-          if (auto *ME = dyn_cast<MemberExpr>(IgnImp))
+          if (const auto *ME = dyn_cast<MemberExpr>(IgnImp))
             return {ME->getMemberDecl(), *RightasBool};
           return {};
         };
@@ -638,8 +638,9 @@ void SimplifyBooleanExprCheck::reportBinOp(const ASTContext 
&Context,
 
   const bool BoolValue = Bool->getValue();
 
-  auto ReplaceWithExpression = [this, &Context, LHS, RHS,
-                                Bool](const Expr *ReplaceWith, bool Negated) {
+  const auto ReplaceWithExpression = [this, &Context, LHS, RHS,
+                                      Bool](const Expr *ReplaceWith,
+                                            bool Negated) {
     const std::string Replacement =
         replacementExpression(Context, Negated, ReplaceWith);
     const SourceRange Range(LHS->getBeginLoc(), RHS->getEndLoc());
@@ -967,7 +968,7 @@ bool SimplifyBooleanExprCheck::reportDeMorgan(const 
ASTContext &Context,
   assert(Inner);
   assert(Inner->isLogicalOp());
 
-  auto Diag =
+  const auto Diag =
       diag(Outer->getBeginLoc(),
            "boolean expression can be simplified by DeMorgan's theorem");
   Diag << Outer->getSourceRange();

diff  --git 
a/clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
index 4b039170ed56a..79926074b387c 100644
--- a/clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
@@ -46,7 +46,7 @@ void SimplifySubscriptExprCheck::check(const 
MatchFinder::MatchResult &Result) {
     return;
 
   const auto *Member = Result.Nodes.getNodeAs<MemberExpr>("member");
-  auto DiagBuilder =
+  const auto DiagBuilder =
       diag(Member->getMemberLoc(),
            "accessing an element of the container does not require a call to "
            "'data()'; did you mean to use 'operator[]'?");

diff  --git 
a/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
 
b/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
index 7ef8ef3d947f3..459cc010f729e 100644
--- 
a/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/StaticAccessedThroughInstanceCheck.cpp
@@ -91,7 +91,7 @@ void StaticAccessedThroughInstanceCheck::check(
     return;
 
   SourceLocation MemberExprStartLoc = MemberExpression->getBeginLoc();
-  auto CreateFix = [&] {
+  const auto CreateFix = [&] {
     return FixItHint::CreateReplacement(
         CharSourceRange::getCharRange(MemberExprStartLoc,
                                       MemberExpression->getMemberLoc()),
@@ -99,7 +99,7 @@ void StaticAccessedThroughInstanceCheck::check(
   };
 
   {
-    auto Diag =
+    const auto Diag =
         diag(MemberExprStartLoc, "static member accessed through instance");
 
     if (getNameSpecifierNestingLevel(BaseType) > NameSpecifierNestingThreshold)

diff  --git 
a/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp
 
b/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp
index abc9f6709125b..0f64cea3efd59 100644
--- 
a/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/readability/StaticDefinitionInAnonymousNamespaceCheck.cpp
@@ -36,7 +36,7 @@ void StaticDefinitionInAnonymousNamespaceCheck::check(
   if (DC->getDeclKind() != Decl::Namespace)
     return;
 
-  auto Diag =
+  const auto Diag =
       diag(Def->getLocation(), "%0 is a static definition in "
                                "anonymous namespace; static is redundant here")
       << Def;

diff  --git a/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp
index 6bd3674de6f8f..e095b22fa24b3 100644
--- a/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/StringCompareCheck.cpp
@@ -78,7 +78,7 @@ void StringCompareCheck::check(const MatchFinder::MatchResult 
&Result) {
       const auto *Str2 = Result.Nodes.getNodeAs<Stmt>("str2");
       const auto *Compare = Result.Nodes.getNodeAs<Stmt>("compare");
 
-      auto Diag = diag(Matched->getBeginLoc(), CompareMessage);
+      const auto Diag = diag(Matched->getBeginLoc(), CompareMessage);
 
       if (Str1->isArrow())
         Diag << FixItHint::CreateInsertion(Str1->getBeginLoc(), "*");

diff  --git 
a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
index b057ec61e547a..854bd1dae9e30 100644
--- a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
@@ -501,13 +501,13 @@ SuspiciousCallArgumentCheck::SuspiciousCallArgumentCheck(
     : ClangTidyCheck(Name, Context),
       MinimumIdentifierNameLength(Options.get(
           "MinimumIdentifierNameLength", DefaultMinimumIdentifierNameLength)) {
-  auto GetToggleOpt = [this](Heuristic H) -> bool {
-    auto Idx = static_cast<std::size_t>(H);
+  const auto GetToggleOpt = [this](Heuristic H) -> bool {
+    const auto Idx = static_cast<std::size_t>(H);
     assert(Idx < HeuristicCount);
     return Options.get(HeuristicToString[Idx], Defaults[Idx].Enabled);
   };
-  auto GetBoundOpt = [this](Heuristic H, BoundKind BK) -> int8_t {
-    auto Idx = static_cast<std::size_t>(H);
+  const auto GetBoundOpt = [this](Heuristic H, BoundKind BK) -> int8_t {
+    const auto Idx = static_cast<std::size_t>(H);
     assert(Idx < HeuristicCount);
 
     SmallString<32> Key = HeuristicToString[Idx];
@@ -519,7 +519,7 @@ SuspiciousCallArgumentCheck::SuspiciousCallArgumentCheck(
     return Options.get(Key, Default);
   };
   for (std::size_t Idx = 0; Idx < HeuristicCount; ++Idx) {
-    auto H = static_cast<Heuristic>(Idx);
+    const auto H = static_cast<Heuristic>(Idx);
     if (GetToggleOpt(H))
       AppliedHeuristics.emplace_back(H);
     ConfiguredBounds.emplace_back(GetBoundOpt(H, BoundKind::DissimilarBelow),
@@ -543,11 +543,11 @@ void SuspiciousCallArgumentCheck::storeOptions(
   Options.store(Opts, "MinimumIdentifierNameLength",
                 MinimumIdentifierNameLength);
   const auto &SetToggleOpt = [this, &Opts](Heuristic H) -> void {
-    auto Idx = static_cast<std::size_t>(H);
+    const auto Idx = static_cast<std::size_t>(H);
     Options.store(Opts, HeuristicToString[Idx], isHeuristicEnabled(H));
   };
   const auto &SetBoundOpt = [this, &Opts](Heuristic H, BoundKind BK) -> void {
-    auto Idx = static_cast<std::size_t>(H);
+    const auto Idx = static_cast<std::size_t>(H);
     assert(Idx < HeuristicCount);
     if (!Defaults[Idx].hasBounds())
       return;
@@ -559,7 +559,7 @@ void SuspiciousCallArgumentCheck::storeOptions(
   };
 
   for (std::size_t Idx = 0; Idx < HeuristicCount; ++Idx) {
-    auto H = static_cast<Heuristic>(Idx);
+    const auto H = static_cast<Heuristic>(Idx);
     SetToggleOpt(H);
     SetBoundOpt(H, BoundKind::DissimilarBelow);
     SetBoundOpt(H, BoundKind::SimilarAbove);
@@ -586,7 +586,7 @@ bool 
SuspiciousCallArgumentCheck::isHeuristicEnabled(Heuristic H) const {
 
 std::optional<int8_t>
 SuspiciousCallArgumentCheck::getBound(Heuristic H, BoundKind BK) const {
-  auto Idx = static_cast<std::size_t>(H);
+  const auto Idx = static_cast<std::size_t>(H);
   assert(Idx < HeuristicCount);
 
   if (!Defaults[Idx].hasBounds())

diff  --git 
a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
index 1dff808923a62..daf8fa40664ba 100644
--- a/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UniqueptrDeleteReleaseCheck.cpp
@@ -28,7 +28,7 @@ UniqueptrDeleteReleaseCheck::UniqueptrDeleteReleaseCheck(
       PreferResetCall(Options.get("PreferResetCall", false)) {}
 
 void UniqueptrDeleteReleaseCheck::registerMatchers(MatchFinder *Finder) {
-  auto UniquePtrWithDefaultDelete = classTemplateSpecializationDecl(
+  const auto UniquePtrWithDefaultDelete = classTemplateSpecializationDecl(
       hasName("::std::unique_ptr"),
       hasTemplateArgument(1, refersToType(hasDeclaration(cxxRecordDecl(
                                  hasName("::std::default_delete"))))));
@@ -58,7 +58,7 @@ void UniqueptrDeleteReleaseCheck::check(
   if (ReleaseExpr->getBeginLoc().isMacroID())
     return;
 
-  auto D =
+  const auto D =
       diag(DeleteExpr->getBeginLoc(), "prefer '%select{= nullptr|reset()}0' "
                                       "to reset 'unique_ptr<>' objects");
   D << PreferResetCall << DeleteExpr->getSourceRange()

diff  --git 
a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
index 812ade0df42c1..8d9e68c8147f8 100644
--- a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -84,7 +84,7 @@ getNewSuffix(StringRef OldSuffix, const 
std::vector<StringRef> &NewSuffixes) {
   if (NewSuffixes.empty())
     return OldSuffix.upper();
   // Else, find matching suffix, case-*insensitive*ly.
-  auto NewSuffix =
+  const auto NewSuffix =
       llvm::find_if(NewSuffixes, [OldSuffix](StringRef PotentialNewSuffix) {
         return OldSuffix.equals_insensitive(PotentialNewSuffix);
       });
@@ -210,10 +210,11 @@ void UppercaseLiteralSuffixCheck::check(
           NewSuffixes, *Result.SourceManager, getLangOpts())) {
     if (Details->LiteralLocation.getBegin().isMacroID() && IgnoreMacros)
       return;
-    auto Complaint = diag(Details->LiteralLocation.getBegin(),
-                          "%select{floating point|integer}0 literal has suffix 
"
-                          "'%1', which is not uppercase")
-                     << IsInteger << Details->OldSuffix;
+    const auto Complaint =
+        diag(Details->LiteralLocation.getBegin(),
+             "%select{floating point|integer}0 literal has suffix "
+             "'%1', which is not uppercase")
+        << IsInteger << Details->OldSuffix;
     if (Details->FixIt) // Similarly, a fix-it is not always possible.
       Complaint << *(Details->FixIt);
   }

diff  --git a/clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp
index d4a9d43edf0d6..68565a21e848a 100644
--- a/clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp
@@ -44,7 +44,7 @@ AST_MATCHER(Expr, isUnsafeTemporaryRangeInit) {
 namespace tidy::readability {
 
 void UseAnyOfAllOfCheck::registerMatchers(MatchFinder *Finder) {
-  auto Returns = [](bool V) {
+  const auto Returns = [](bool V) {
     return returnStmt(hasReturnValue(cxxBoolLiteral(equals(V))));
   };
 

diff  --git a/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
index 38e6dfb5328fa..d0d9908acbf4c 100644
--- a/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
@@ -130,11 +130,11 @@ void 
UseStdMinMaxCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void UseStdMinMaxCheck::registerMatchers(MatchFinder *Finder) {
-  auto AssignOperator =
+  const auto AssignOperator =
       binaryOperator(hasOperatorName("="),
                      hasLHS(expr(unless(isTypeDependent())).bind("AssignLhs")),
                      
hasRHS(expr(unless(isTypeDependent())).bind("AssignRhs")));
-  auto BinaryOperator =
+  const auto BinaryOperator =
       binaryOperator(hasAnyOperatorName("<", ">", "<=", ">="),
                      hasLHS(expr(unless(isTypeDependent())).bind("CondLhs")),
                      hasRHS(expr(unless(isTypeDependent())).bind("CondRhs")))
@@ -169,7 +169,7 @@ void UseStdMinMaxCheck::check(const 
MatchFinder::MatchResult &Result) {
   const SourceLocation IfLocation = If->getIfLoc();
   SourceLocation ThenLocation = If->getEndLoc();
 
-  auto ReplaceAndDiagnose = [&](const StringRef FunctionName) {
+  const auto ReplaceAndDiagnose = [&](const StringRef FunctionName) {
     const SourceManager &Source = *Result.SourceManager;
     SmallString<64> Comment;
 


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to