[clang-tools-extra] [clang-tidy][NFC] Mark `auto` variables const where possible (PR #175467)

Victor Chernyakin via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 11 14:34:23 PST 2026


https://github.com/localspook created https://github.com/llvm/llvm-project/pull/175467

None

>From 9143c1bce7930d2da097364e13110a58edf81a0d Mon Sep 17 00:00:00 2001
From: Victor Chernyakin <chernyakin.victor.j at outlook.com>
Date: Sun, 11 Jan 2026 14:26:25 -0800
Subject: [PATCH] [clang-tidy][NFC] Mark `auto` variables const where possible

---
 clang-tools-extra/clang-tidy/ClangTidy.cpp    | 13 ++--
 .../clang-tidy/ClangTidyCheck.cpp             | 17 +++--
 .../ClangTidyDiagnosticConsumer.cpp           | 13 ++--
 .../clang-tidy/ClangTidyOptions.cpp           | 10 +--
 clang-tools-extra/clang-tidy/GlobList.cpp     |  2 +-
 .../clang-tidy/NoLintDirectiveHandler.cpp     |  4 +-
 .../clang-tidy/abseil/AbseilMatcher.h         |  2 +-
 .../clang-tidy/abseil/CleanupCtadCheck.cpp    |  5 +-
 .../abseil/DurationComparisonCheck.cpp        |  8 +-
 .../abseil/DurationConversionCastCheck.cpp    |  2 +-
 .../clang-tidy/abseil/DurationRewriter.cpp    |  6 +-
 .../DurationUnnecessaryConversionCheck.cpp    |  2 +-
 .../abseil/FasterStrsplitDelimiterCheck.cpp   |  2 +-
 .../abseil/StringFindStartswithCheck.cpp      | 12 +--
 .../abseil/StringFindStrContainsCheck.cpp     | 12 +--
 .../clang-tidy/abseil/TimeComparisonCheck.cpp |  2 +-
 .../abseil/TimeSubtractionCheck.cpp           |  6 +-
 .../abseil/UncheckedStatusOrAccessCheck.cpp   |  2 +-
 .../altera/IdDependentBackwardBranchCheck.cpp |  4 +-
 .../altera/SingleWorkItemBarrierCheck.cpp     |  2 +-
 .../altera/StructPackAlignCheck.cpp           |  2 +-
 .../android/CloexecAccept4Check.cpp           |  5 +-
 .../clang-tidy/android/CloexecAcceptCheck.cpp |  5 +-
 .../clang-tidy/android/CloexecCreatCheck.cpp  |  4 +-
 .../clang-tidy/android/CloexecFopenCheck.cpp  |  2 +-
 .../android/CloexecMemfdCreateCheck.cpp       |  2 +-
 .../clang-tidy/android/CloexecOpenCheck.cpp   |  2 +-
 .../clang-tidy/boost/UseToStringCheck.cpp     |  6 +-
 .../bugprone/ArgumentCommentCheck.cpp         |  7 +-
 .../bugprone/AssertSideEffectCheck.cpp        |  6 +-
 .../bugprone/BitwisePointerCastCheck.cpp      |  4 +-
 .../clang-tidy/bugprone/BranchCloneCheck.cpp  |  2 +-
 .../CapturingThisInMemberVariableCheck.cpp    |  6 +-
 ...arePointerToMemberVirtualFunctionCheck.cpp |  4 +-
 .../bugprone/CopyConstructorInitCheck.cpp     |  7 +-
 .../CrtpConstructorAccessibilityCheck.cpp     |  4 +-
 .../EasilySwappableParametersCheck.cpp        | 30 ++++----
 .../clang-tidy/bugprone/EmptyCatchCheck.cpp   |  4 +-
 .../bugprone/ExceptionEscapeCheck.cpp         |  2 +-
 .../ForwardDeclarationNamespaceCheck.cpp      |  2 +-
 .../ForwardingReferenceOverloadCheck.cpp      |  4 +-
 ...citWideningOfMultiplicationResultCheck.cpp | 25 ++++---
 .../bugprone/IncDecInConditionsCheck.cpp      |  2 +-
 .../bugprone/IncorrectEnableIfCheck.cpp       |  6 +-
 .../bugprone/IncorrectRoundingsCheck.cpp      |  4 +-
 .../InvalidEnumDefaultInitializationCheck.cpp |  4 +-
 .../bugprone/LambdaFunctionNameCheck.cpp      |  2 +-
 .../MisleadingSetterOfReferenceCheck.cpp      | 22 +++---
 .../MisplacedOperatorInStrlenInAllocCheck.cpp |  2 +-
 .../bugprone/MoveForwardingReferenceCheck.cpp |  2 +-
 .../MultipleNewInOneExpressionCheck.cpp       | 19 +++--
 .../bugprone/MultipleStatementMacroCheck.cpp  |  2 +-
 .../NonZeroEnumToBoolConversionCheck.cpp      |  2 +-
 ...eterministicPointerIterationOrderCheck.cpp |  4 +-
 .../bugprone/NotNullTerminatedResultCheck.cpp | 51 ++++++-------
 .../bugprone/OptionalValueConversionCheck.cpp |  8 +-
 .../bugprone/ParentVirtualCallCheck.cpp       | 11 +--
 .../bugprone/RandomGeneratorSeedCheck.cpp     |  7 +-
 .../RawMemoryCallOnNonTrivialTypeCheck.cpp    |  4 +-
 .../RedundantBranchConditionCheck.cpp         |  3 +-
 .../bugprone/ReservedIdentifierCheck.cpp      |  4 +-
 .../bugprone/SignalHandlerCheck.cpp           |  7 +-
 .../bugprone/SizeofContainerCheck.cpp         |  2 +-
 .../bugprone/SizeofExpressionCheck.cpp        |  2 +-
 .../bugprone/SmartPtrArrayMismatchCheck.cpp   | 17 +++--
 .../StdNamespaceModificationCheck.cpp         |  8 +-
 .../bugprone/StringIntegerAssignmentCheck.cpp |  2 +-
 .../bugprone/StringviewNullptrCheck.cpp       | 73 ++++++++++---------
 .../bugprone/SuspiciousEnumUsageCheck.cpp     |  2 +-
 .../bugprone/SuspiciousMemsetUsageCheck.cpp   |  8 +-
 .../bugprone/SuspiciousMissingCommaCheck.cpp  |  2 +-
 .../bugprone/SuspiciousReallocUsageCheck.cpp  |  4 +-
 .../bugprone/SuspiciousSemicolonCheck.cpp     |  2 +-
 .../SuspiciousStringviewDataUsageCheck.cpp    |  6 +-
 .../bugprone/TaggedUnionMemberCountCheck.cpp  | 12 +--
 .../bugprone/TerminatingContinueCheck.cpp     |  2 +-
 .../bugprone/UncheckedOptionalAccessCheck.cpp |  5 +-
 .../bugprone/UnhandledExceptionAtNewCheck.cpp |  7 +-
 .../bugprone/UniquePtrArrayMismatchCheck.cpp  |  2 +-
 .../bugprone/UnsafeFunctionsCheck.cpp         |  8 +-
 .../clang-tidy/bugprone/UnusedRaiiCheck.cpp   |  5 +-
 .../bugprone/UnusedReturnValueCheck.cpp       |  4 +-
 .../clang-tidy/bugprone/UseAfterMoveCheck.cpp | 22 +++---
 .../bugprone/VirtualNearMissCheck.cpp         |  6 +-
 .../cppcoreguidelines/AvoidGotoCheck.cpp      |  4 +-
 .../AvoidNonConstGlobalVariablesCheck.cpp     |  8 +-
 .../cppcoreguidelines/InitVariablesCheck.cpp  |  2 +-
 .../MisleadingCaptureDefaultByValueCheck.cpp  | 10 +--
 .../MissingStdForwardCheck.cpp                |  4 +-
 .../NoSuspendWithLockCheck.cpp                |  2 +-
 .../cppcoreguidelines/OwningMemoryCheck.cpp   |  2 +-
 .../PreferMemberInitializerCheck.cpp          |  9 ++-
 ...undsAvoidUncheckedContainerAccessCheck.cpp | 22 +++---
 .../ProBoundsConstantArrayIndexCheck.cpp      |  6 +-
 .../ProTypeCstyleCastCheck.cpp                |  4 +-
 .../ProTypeMemberInitCheck.cpp                |  4 +-
 .../cppcoreguidelines/ProTypeVarargCheck.cpp  |  8 +-
 .../RvalueReferenceParamNotMovedCheck.cpp     |  2 +-
 .../SpecialMemberFunctionsCheck.cpp           |  8 +-
 .../cppcoreguidelines/UseEnumClassCheck.cpp   |  2 +-
 .../VirtualClassDestructorCheck.cpp           |  2 +-
 .../clang-tidy/custom/QueryCheck.cpp          |  9 ++-
 .../AvoidThrowingObjCExceptionCheck.cpp       |  7 +-
 .../google/ExplicitConstructorCheck.cpp       | 10 +--
 .../google/GlobalVariableDeclarationCheck.cpp |  6 +-
 .../clang-tidy/google/IntegerTypesCheck.cpp   |  6 +-
 .../google/UpgradeGoogletestCaseCheck.cpp     | 10 +--
 .../linuxkernel/MustCheckErrsCheck.cpp        |  9 ++-
 .../clang-tidy/llvm/IncludeOrderCheck.cpp     |  6 +-
 .../PreferIsaOrDynCastInConditionalsCheck.cpp |  8 +-
 .../llvm/PreferRegisterOverUnsignedCheck.cpp  |  2 +-
 .../clang-tidy/llvm/TwineLocalCheck.cpp       |  6 +-
 .../llvm/UseNewMLIROpBuilderCheck.cpp         |  7 +-
 .../llvmlibc/InlineFunctionDeclCheck.cpp      |  4 +-
 .../ConfusableTable/BuildConfusableTable.cpp  |  4 +-
 .../clang-tidy/misc/ConstCorrectnessCheck.cpp | 12 +--
 .../misc/CoroutineHostileRAIICheck.cpp        |  4 +-
 .../misc/DefinitionsInHeadersCheck.cpp        |  2 +-
 .../misc/MisleadingBidirectionalCheck.cpp     |  2 +-
 .../clang-tidy/misc/MisplacedConstCheck.cpp   |  2 +-
 .../clang-tidy/misc/NoRecursionCheck.cpp      |  2 +-
 .../misc/NonCopyableObjectsCheck.cpp          |  2 +-
 ...onPrivateMemberVariablesInClassesCheck.cpp |  6 +-
 .../misc/RedundantExpressionCheck.cpp         | 12 +--
 .../clang-tidy/misc/StaticAssertCheck.cpp     |  4 +-
 .../ThrowByValueCatchByReferenceCheck.cpp     |  8 +-
 .../misc/UniqueptrResetReleaseCheck.cpp       |  7 +-
 .../clang-tidy/misc/UnusedParametersCheck.cpp |  3 +-
 .../clang-tidy/misc/UnusedUsingDeclsCheck.cpp |  9 ++-
 .../misc/UseInternalLinkageCheck.cpp          |  2 +-
 .../clang-tidy/modernize/AvoidBindCheck.cpp   |  2 +-
 .../modernize/AvoidCStyleCastCheck.cpp        |  8 +-
 .../modernize/DeprecatedHeadersCheck.cpp      |  8 +-
 .../DeprecatedIosBaseAliasesCheck.cpp         | 14 ++--
 .../IntegralLiteralExpressionMatcher.cpp      |  2 +-
 .../clang-tidy/modernize/LoopConvertCheck.cpp | 19 ++---
 .../clang-tidy/modernize/LoopConvertUtils.cpp |  2 +-
 .../clang-tidy/modernize/MacroToEnumCheck.cpp | 13 ++--
 .../modernize/MakeSmartPtrCheck.cpp           |  6 +-
 .../MinMaxUseInitializerListCheck.cpp         |  6 +-
 .../clang-tidy/modernize/PassByValueCheck.cpp |  7 +-
 .../modernize/RedundantVoidArgCheck.cpp       |  8 +-
 .../modernize/ReplaceAutoPtrCheck.cpp         | 20 ++---
 .../modernize/ReplaceRandomShuffleCheck.cpp   | 11 +--
 .../modernize/ReturnBracedInitListCheck.cpp   |  7 +-
 .../clang-tidy/modernize/TypeTraitsCheck.cpp  | 17 +++--
 .../clang-tidy/modernize/UseAutoCheck.cpp     | 12 +--
 .../modernize/UseBoolLiteralsCheck.cpp        |  2 +-
 .../modernize/UseConstraintsCheck.cpp         |  4 +-
 .../modernize/UseDefaultMemberInitCheck.cpp   |  4 +-
 .../clang-tidy/modernize/UseEmplaceCheck.cpp  | 21 +++---
 .../modernize/UseEqualsDefaultCheck.cpp       | 20 ++---
 .../UseIntegerSignComparisonCheck.cpp         |  2 +-
 .../modernize/UseNodiscardCheck.cpp           |  6 +-
 .../clang-tidy/modernize/UseNullptrCheck.cpp  |  2 +-
 .../clang-tidy/modernize/UseOverrideCheck.cpp | 10 +--
 .../modernize/UseScopedLockCheck.cpp          |  6 +-
 .../modernize/UseStartsEndsWithCheck.cpp      |  5 +-
 .../modernize/UseStdNumbersCheck.cpp          |  2 +-
 .../modernize/UseTrailingReturnTypeCheck.cpp  | 12 +--
 .../modernize/UseTransparentFunctorsCheck.cpp |  2 +-
 .../modernize/UseUncaughtExceptionsCheck.cpp  |  7 +-
 .../clang-tidy/modernize/UseUsingCheck.cpp    |  4 +-
 .../clang-tidy/mpi/BufferDerefCheck.cpp       |  4 +-
 .../clang-tidy/mpi/TypeMismatchCheck.cpp      |  5 +-
 .../clang-tidy/objc/AssertEqualsCheck.cpp     |  2 +-
 .../NSInvocationArgumentLifetimeCheck.cpp     |  9 ++-
 .../objc/PropertyDeclarationCheck.cpp         |  7 +-
 .../clang-tidy/objc/SuperSelfCheck.cpp        |  9 ++-
 .../clang-tidy/performance/AvoidEndlCheck.cpp | 12 +--
 .../clang-tidy/performance/EnumSizeCheck.cpp  |  2 +-
 .../performance/FasterStringFindCheck.cpp     |  4 +-
 .../performance/ForRangeCopyCheck.cpp         |  8 +-
 .../InefficientVectorOperationCheck.cpp       |  9 ++-
 .../performance/NoexceptFunctionBaseCheck.cpp |  2 +-
 .../TypePromotionInMathFnCheck.cpp            | 21 +++---
 .../UnnecessaryCopyInitializationCheck.cpp    | 13 ++--
 .../UnnecessaryValueParamCheck.cpp            | 14 ++--
 .../RestrictSystemIncludesCheck.cpp           |  4 +-
 .../portability/StdAllocatorConstCheck.cpp    |  4 +-
 .../AvoidConstParamsInDeclsCheck.cpp          |  9 ++-
 .../BracesAroundStatementsCheck.cpp           |  4 +-
 .../readability/ConstReturnTypeCheck.cpp      |  2 +-
 .../readability/ContainerContainsCheck.cpp    |  6 +-
 .../readability/ContainerSizeEmptyCheck.cpp   |  7 +-
 .../readability/DeleteNullPointerCheck.cpp    |  2 +-
 .../readability/ElseAfterReturnCheck.cpp      |  6 +-
 .../readability/IdentifierNamingCheck.cpp     | 20 ++---
 .../ImplicitBoolConversionCheck.cpp           |  9 ++-
 ...onsistentDeclarationParameterNameCheck.cpp |  4 +-
 .../readability/IsolateDeclarationCheck.cpp   |  2 +-
 .../MakeMemberFunctionConstCheck.cpp          | 11 +--
 .../MathMissingParenthesesCheck.cpp           |  2 +-
 .../MisleadingIndentationCheck.cpp            |  2 +-
 .../readability/MisplacedArrayIndexCheck.cpp  |  7 +-
 .../readability/NamedParameterCheck.cpp       |  6 +-
 .../readability/NonConstParameterCheck.cpp    |  4 +-
 .../readability/QualifiedAutoCheck.cpp        | 15 ++--
 .../readability/RedundantCastingCheck.cpp     |  7 +-
 .../readability/RedundantDeclarationCheck.cpp |  2 +-
 .../readability/RedundantMemberInitCheck.cpp  |  4 +-
 .../readability/SimplifyBooleanExprCheck.cpp  | 19 ++---
 .../SimplifySubscriptExprCheck.cpp            |  2 +-
 .../StaticAccessedThroughInstanceCheck.cpp    |  4 +-
 ...ticDefinitionInAnonymousNamespaceCheck.cpp |  2 +-
 .../readability/StringCompareCheck.cpp        |  2 +-
 .../SuspiciousCallArgumentCheck.cpp           |  8 +-
 .../UniqueptrDeleteReleaseCheck.cpp           |  4 +-
 .../UppercaseLiteralSuffixCheck.cpp           |  9 ++-
 .../readability/UseAnyOfAllOfCheck.cpp        |  6 +-
 .../readability/UseStdMinMaxCheck.cpp         |  6 +-
 .../clang-tidy/tool/ClangTidyMain.cpp         |  6 +-
 .../clang-tidy/utils/DeclRefExprUtils.cpp     | 25 ++++---
 .../clang-tidy/utils/ExceptionAnalyzer.cpp    |  4 +-
 .../clang-tidy/utils/FixItHintUtils.cpp       |  4 +-
 .../clang-tidy/utils/IncludeSorter.cpp        |  2 +-
 .../clang-tidy/utils/NamespaceAliaser.cpp     |  2 +-
 .../utils/RenamerClangTidyCheck.cpp           |  6 +-
 .../utils/TransformerClangTidyCheck.cpp       |  4 +-
 .../clang-tidy/utils/TypeTraits.cpp           |  8 +-
 .../clang-tidy/utils/UseRangesCheck.cpp       |  2 +-
 .../clang-tidy/utils/UsingInserter.cpp        |  2 +-
 222 files changed, 813 insertions(+), 743 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index da2b4e577c9ed..c84ac9fc4c4bd 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -130,8 +130,9 @@ class ErrorReporter {
         Level = DiagnosticsEngine::Error;
         WarningsAsErrors++;
       }
-      auto Diag = Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
-                  << Message.Message << Name;
+      const auto Diag =
+          Diags.Report(Loc, Diags.getCustomDiagID(Level, "%0 [%1]"))
+          << Message.Message << Name;
       for (const FileByteRange &FBR : Error.Message.Ranges)
         Diag << getRange(FBR);
       // FIXME: explore options to support interactive fix selection.
@@ -183,7 +184,7 @@ class ErrorReporter {
       }
       reportFix(Diag, Error.Message.Fix);
     }
-    for (auto Fix : FixLocations) {
+    for (const auto Fix : FixLocations) {
       Diags.Report(Fix.first, Fix.second ? diag::note_fixit_applied
                                          : diag::note_fixit_failed);
     }
@@ -284,7 +285,7 @@ class ErrorReporter {
   void reportNote(const tooling::DiagnosticMessage &Message) {
     const SourceLocation Loc =
         getLocation(Message.FilePath, Message.FileOffset);
-    auto Diag =
+    const auto Diag =
         Diags.Report(Loc, Diags.getCustomDiagID(DiagnosticsEngine::Note, "%0"))
         << Message.Message;
     for (const FileByteRange &FBR : Message.Ranges)
@@ -355,7 +356,7 @@ ClangTidyASTConsumerFactory::ClangTidyASTConsumerFactory(
 #endif
   for (const ClangTidyModuleRegistry::entry E :
        ClangTidyModuleRegistry::entries()) {
-    std::unique_ptr<ClangTidyModule> Module = E.instantiate();
+    const std::unique_ptr<ClangTidyModule> Module = E.instantiate();
     Module->addCheckFactories(*CheckFactories);
   }
 }
@@ -458,7 +459,7 @@ ClangTidyASTConsumerFactory::createASTConsumer(
     PP->addPPCallbacks(std::move(ModuleExpander));
   }
 
-  for (auto &Check : Checks) {
+  for (const auto &Check : Checks) {
     Check->registerMatchers(&*Finder);
     Check->registerPPCallbacks(*SM, PP, ModuleExpanderPP);
   }
diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 30ba36737571a..ced8d2ab45437 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -84,7 +84,8 @@ findPriorityOption(const ClangTidyOptions::OptionMap &Options,
 
 std::optional<StringRef>
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
-  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
+  const auto Iter =
+      findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
   if (Iter != CheckOptions.end())
     return StringRef(Iter->getValue().Value);
   return std::nullopt;
@@ -115,7 +116,8 @@ ClangTidyCheck::OptionsView::get<bool>(StringRef LocalName) const {
 template <>
 std::optional<bool>
 ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName) const {
-  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
+  const auto Iter =
+      findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
   if (Iter != CheckOptions.end()) {
     if (auto Result = getAsBool(Iter->getValue().Value))
       return Result;
@@ -155,9 +157,10 @@ ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName,
                                         bool CheckGlobal) const {
   if (!CheckGlobal && Context->getOptionsCollector())
     Context->getOptionsCollector()->insert((NamePrefix + LocalName).str());
-  auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix,
-                                               LocalName, Context)
-                          : CheckOptions.find((NamePrefix + LocalName).str());
+  const auto Iter =
+      CheckGlobal
+          ? findPriorityOption(CheckOptions, NamePrefix, LocalName, Context)
+          : CheckOptions.find((NamePrefix + LocalName).str());
   if (Iter == CheckOptions.end())
     return std::nullopt;
 
@@ -207,8 +210,8 @@ void ClangTidyCheck::OptionsView::diagnoseBadIntegerOption(
 void ClangTidyCheck::OptionsView::diagnoseBadEnumOption(
     const Twine &Lookup, StringRef Unparsed, StringRef Suggestion) const {
   SmallString<64> Buffer;
-  auto Diag = Context->configurationDiag(ConfigWarning)
-              << Unparsed << Lookup.toStringRef(Buffer);
+  const auto Diag = Context->configurationDiag(ConfigWarning)
+                    << Unparsed << Lookup.toStringRef(Buffer);
   if (Suggestion.empty())
     Diag << 0;
   else
diff --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 7d6827f0af653..32de80d4f6d18 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -64,7 +64,7 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
     const std::string CheckNameInMessage = " [" + Error.DiagnosticName + "]";
     Message.consume_back(CheckNameInMessage);
 
-    auto TidyMessage =
+    const auto TidyMessage =
         Loc.isValid()
             ? tooling::DiagnosticMessage(Message, Loc.getManager(), Loc)
             : tooling::DiagnosticMessage(Message);
@@ -73,7 +73,7 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
     // into a real CharRange for the diagnostic printer later.
     // Whatever we store here gets decoupled from the current SourceManager, so
     // we **have to** know the exact position and length of the highlight.
-    auto ToCharRange = [this, &Loc](const CharSourceRange &SourceRange) {
+    const auto ToCharRange = [this, &Loc](const CharSourceRange &SourceRange) {
       if (SourceRange.isCharRange())
         return SourceRange;
       assert(SourceRange.isTokenRange());
@@ -83,7 +83,7 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
     };
 
     // We are only interested in valid ranges.
-    auto ValidRanges =
+    const auto ValidRanges =
         llvm::make_filter_range(Ranges, [](const CharSourceRange &R) {
           return R.getAsRange().isValid();
         });
@@ -489,17 +489,18 @@ bool ClangTidyDiagnosticConsumer::passesLineFilter(StringRef FileName,
 
 void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
   // Acquire a diagnostic ID also in the external diagnostics engine.
-  auto DiagLevelAndFormatString =
+  const auto DiagLevelAndFormatString =
       Context.getDiagLevelAndFormatString(Info.getID(), Info.getLocation());
   const unsigned ExternalID =
       ExternalDiagEngine->getDiagnosticIDs()->getCustomDiagID(
           DiagLevelAndFormatString.first, DiagLevelAndFormatString.second);
 
   // Forward the details.
-  auto Builder = ExternalDiagEngine->Report(Info.getLocation(), ExternalID);
+  const auto Builder =
+      ExternalDiagEngine->Report(Info.getLocation(), ExternalID);
   for (const FixItHint &Hint : Info.getFixItHints())
     Builder << Hint;
-  for (auto Range : Info.getRanges())
+  for (const auto Range : Info.getRanges())
     Builder << Range;
   for (unsigned Index = 0; Index < Info.getNumArgs(); ++Index) {
     const DiagnosticsEngine::ArgumentKind Kind = Info.getArgKind(Index);
diff --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 317fbd9173af7..ef21d8be5a88b 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -113,7 +113,7 @@ void yamlize(IO &IO, ClangTidyOptions::OptionMap &Val, bool,
   } else {
     // We need custom logic here to support the old method of specifying check
     // options using a list of maps containing key and value keys.
-    auto &I = reinterpret_cast<Input &>(IO);
+    const auto &I = reinterpret_cast<Input &>(IO);
     if (isa<SequenceNode>(I.getCurrentNode())) {
       MappingNormalization<NOptionMap, ClangTidyOptions::OptionMap> NOpts(IO,
                                                                           Val);
@@ -194,7 +194,7 @@ void yamlize(IO &IO, GlobListVariant &Val, bool, EmptyContext &Ctx) {
   if (!IO.outputting()) {
     // Special case for reading from YAML
     // Must support reading from both a string or a list
-    auto &I = reinterpret_cast<Input &>(IO);
+    const auto &I = reinterpret_cast<Input &>(IO);
     if (isa<ScalarNode, BlockScalarNode>(I.getCurrentNode())) {
       Val.AsString = std::string();
       yamlize(IO, *Val.AsString, true, Ctx);
@@ -328,7 +328,7 @@ ClangTidyOptions
 ClangTidyOptionsProvider::getOptions(llvm::StringRef FileName) {
   ClangTidyOptions Result;
   unsigned Priority = 0;
-  for (auto &Source : getRawOptions(FileName))
+  for (const auto &Source : getRawOptions(FileName))
     Result.mergeWith(Source.first, ++Priority);
   return Result;
 }
@@ -403,11 +403,11 @@ FileOptionsBaseProvider::getNormalizedAbsolutePath(llvm::StringRef Path) {
 
 void FileOptionsBaseProvider::addRawFileOptions(
     llvm::StringRef AbsolutePath, std::vector<OptionsSource> &CurOptions) {
-  auto CurSize = CurOptions.size();
+  const auto CurSize = CurOptions.size();
   // Look for a suitable configuration file in all parent directories of the
   // file. Start with the immediate parent directory and move up.
   StringRef RootPath = llvm::sys::path::parent_path(AbsolutePath);
-  auto MemorizedConfigFile =
+  const auto MemorizedConfigFile =
       [this, &RootPath](StringRef CurrentPath) -> std::optional<OptionsSource> {
     const auto Iter = CachedOptions.Memorized.find(CurrentPath);
     if (Iter != CachedOptions.Memorized.end())
diff --git a/clang-tools-extra/clang-tidy/GlobList.cpp b/clang-tools-extra/clang-tidy/GlobList.cpp
index 7c72af9d06b12..605d7c51bc912 100644
--- a/clang-tools-extra/clang-tidy/GlobList.cpp
+++ b/clang-tools-extra/clang-tidy/GlobList.cpp
@@ -66,7 +66,7 @@ bool GlobList::contains(StringRef S) const {
 }
 
 bool CachedGlobList::contains(StringRef S) const {
-  auto Entry = Cache.try_emplace(S);
+  const auto Entry = Cache.try_emplace(S);
   bool &Value = Entry.first->getValue();
   // If the entry was just inserted, determine its required value.
   if (Entry.second)
diff --git a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
index 612da6f1efeb3..5da90dc3d6007 100644
--- a/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
+++ b/clang-tools-extra/clang-tidy/NoLintDirectiveHandler.cpp
@@ -356,13 +356,13 @@ bool NoLintDirectiveHandler::Impl::diagHasNoLint(
     return false;
 
   // Check if there's a NOLINT on this line.
-  auto ThisLine = getLineStartAndEnd(*Buffer, Pos);
+  const auto ThisLine = getLineStartAndEnd(*Buffer, Pos);
   if (lineHasNoLint(*Buffer, ThisLine, NoLintType::NoLint, DiagName))
     return true;
 
   // Check if there's a NOLINTNEXTLINE on the previous line.
   if (ThisLine.first > 0) {
-    auto PrevLine = getLineStartAndEnd(*Buffer, ThisLine.first - 1);
+    const auto PrevLine = getLineStartAndEnd(*Buffer, ThisLine.first - 1);
     if (lineHasNoLint(*Buffer, PrevLine, NoLintType::NoLintNextLine, DiagName))
       return true;
   }
diff --git a/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h b/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
index 86746bfac0257..3f24603988801 100644
--- a/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
+++ b/clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h
@@ -33,7 +33,7 @@ namespace clang::ast_matchers {
 AST_POLYMORPHIC_MATCHER(
     isInAbseilFile, AST_POLYMORPHIC_SUPPORTED_TYPES(Decl, Stmt, TypeLoc,
                                                     NestedNameSpecifierLoc)) {
-  auto &SourceManager = Finder->getASTContext().getSourceManager();
+  const auto &SourceManager = Finder->getASTContext().getSourceManager();
   const SourceLocation Loc = SourceManager.getSpellingLoc(Node.getBeginLoc());
   if (Loc.isInvalid())
     return false;
diff --git a/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp b/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
index dd20ad8a4c269..7053309dd26f8 100644
--- a/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/CleanupCtadCheck.cpp
@@ -19,8 +19,9 @@ using namespace ::clang::transformer;
 namespace clang::tidy::abseil {
 
 static RewriteRuleWith<std::string> cleanupCtadCheckImpl() {
-  auto WarningMessage = cat("prefer absl::Cleanup's class template argument "
-                            "deduction pattern in C++17 and higher");
+  const auto WarningMessage =
+      cat("prefer absl::Cleanup's class template argument "
+          "deduction pattern in C++17 and higher");
 
   return makeRule(
       declStmt(hasSingleDecl(varDecl(
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp
index f00877754f952..c2dce68b4569e 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationComparisonCheck.cpp
@@ -16,10 +16,10 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::abseil {
 
 void DurationComparisonCheck::registerMatchers(MatchFinder *Finder) {
-  auto Matcher = expr(comparisonOperatorWithCallee(functionDecl(
-                          functionDecl(durationConversionFunction())
-                              .bind("function_decl"))))
-                     .bind("binop");
+  const auto Matcher = expr(comparisonOperatorWithCallee(functionDecl(
+                                functionDecl(durationConversionFunction())
+                                    .bind("function_decl"))))
+                           .bind("binop");
 
   Finder->addMatcher(Matcher, this);
 }
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp
index ef06a9e2ba572..b944fd4d52d66 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationConversionCastCheck.cpp
@@ -18,7 +18,7 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::abseil {
 
 void DurationConversionCastCheck::registerMatchers(MatchFinder *Finder) {
-  auto CallMatcher = ignoringImpCasts(callExpr(
+  const auto CallMatcher = ignoringImpCasts(callExpr(
       callee(functionDecl(durationConversionFunction()).bind("func_decl")),
       hasArgument(0, expr().bind("arg"))));
 
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
index a78d07d2e5861..b115746cdf43d 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp
@@ -111,7 +111,7 @@ llvm::StringRef getTimeInverseForScale(DurationScale Scale) {
 
 /// Returns `true` if `Node` is a value which evaluates to a literal `0`.
 bool isLiteralZero(const MatchFinder::MatchResult &Result, const Expr &Node) {
-  auto ZeroMatcher =
+  const auto ZeroMatcher =
       anyOf(integerLiteral(equals(0)), floatLiteral(equals(0.0)));
 
   // Check to see if we're using a zero directly.
@@ -196,7 +196,7 @@ std::optional<DurationScale> getScaleForDurationInverse(llvm::StringRef Name) {
        {"ToDoubleNanoseconds", DurationScale::Nanoseconds},
        {"ToInt64Nanoseconds", DurationScale::Nanoseconds}});
 
-  auto ScaleIter = ScaleMap.find(Name);
+  const auto ScaleIter = ScaleMap.find(Name);
   if (ScaleIter == ScaleMap.end())
     return std::nullopt;
 
@@ -212,7 +212,7 @@ std::optional<DurationScale> getScaleForTimeInverse(llvm::StringRef Name) {
        {"ToUnixMicros", DurationScale::Microseconds},
        {"ToUnixNanos", DurationScale::Nanoseconds}});
 
-  auto ScaleIter = ScaleMap.find(Name);
+  const auto ScaleIter = ScaleMap.find(Name);
   if (ScaleIter == ScaleMap.end())
     return std::nullopt;
 
diff --git a/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp b/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
index 5867fb630315d..9e11d262b5290 100644
--- a/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/DurationUnnecessaryConversionCheck.cpp
@@ -27,7 +27,7 @@ void DurationUnnecessaryConversionCheck::registerMatchers(MatchFinder *Finder) {
 
     // Matcher which matches the current scale's factory with a `1` argument,
     // e.g. `absl::Seconds(1)`.
-    auto FactoryMatcher = ignoringElidableConstructorCall(
+    const auto FactoryMatcher = ignoringElidableConstructorCall(
         callExpr(callee(functionDecl(hasName(DurationFactory))),
                  hasArgument(0, ignoringImpCasts(integerLiteral(equals(1))))));
 
diff --git a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
index 0827526ba3b5d..eb5a547dabc6d 100644
--- a/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/FasterStrsplitDelimiterCheck.cpp
@@ -62,7 +62,7 @@ void FasterStrsplitDelimiterCheck::registerMatchers(MatchFinder *Finder) {
 
   // Binds to a string_view (either absl or std) that was passed by value and
   // constructed from string literal.
-  auto StringViewArg = ignoringElidableConstructorCall(ignoringImpCasts(
+  const auto StringViewArg = ignoringElidableConstructorCall(ignoringImpCasts(
       cxxConstructExpr(hasType(recordDecl(hasName("::absl::string_view"))),
                        hasArgument(0, ignoringParenImpCasts(SingleChar)))));
 
diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
index e1063c4f8a46e..5bd328a3cc7af 100644
--- a/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
@@ -34,12 +34,12 @@ StringFindStartswithCheck::StringFindStartswithCheck(StringRef Name,
           Options.get("AbseilStringsMatchHeader", "absl/strings/match.h")) {}
 
 void StringFindStartswithCheck::registerMatchers(MatchFinder *Finder) {
-  auto ZeroLiteral = integerLiteral(equals(0));
-  auto StringClassMatcher = cxxRecordDecl(hasAnyName(StringLikeClasses));
-  auto StringType = hasUnqualifiedDesugaredType(
+  const auto ZeroLiteral = integerLiteral(equals(0));
+  const auto StringClassMatcher = cxxRecordDecl(hasAnyName(StringLikeClasses));
+  const auto StringType = hasUnqualifiedDesugaredType(
       recordType(hasDeclaration(StringClassMatcher)));
 
-  auto StringFind = cxxMemberCallExpr(
+  const auto StringFind = cxxMemberCallExpr(
       // .find()-call on a string...
       callee(cxxMethodDecl(hasName("find")).bind("findfun")),
       on(hasType(StringType)),
@@ -57,7 +57,7 @@ void StringFindStartswithCheck::registerMatchers(MatchFinder *Finder) {
           .bind("expr"),
       this);
 
-  auto StringRFind = cxxMemberCallExpr(
+  const auto StringRFind = cxxMemberCallExpr(
       // .rfind()-call on a string...
       callee(cxxMethodDecl(hasName("rfind")).bind("findfun")),
       on(hasType(StringType)),
@@ -110,7 +110,7 @@ void StringFindStartswithCheck::check(const MatchFinder::MatchResult &Result) {
   const bool Neg = ComparisonExpr->getOpcode() == BO_NE;
 
   // Create the warning message and a FixIt hint replacing the original expr.
-  auto Diagnostic =
+  const auto Diagnostic =
       diag(ComparisonExpr->getBeginLoc(),
            "use %select{absl::StartsWith|!absl::StartsWith}0 "
            "instead of %select{find()|rfind()}1 %select{==|!=}0 0")
diff --git a/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp b/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
index 5b31c002fce2b..e02263a81f47e 100644
--- a/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/StringFindStrContainsCheck.cpp
@@ -42,15 +42,15 @@ static constexpr char DefaultAbseilStringsMatchHeader[] =
 static transformer::RewriteRuleWith<std::string>
 makeRewriteRule(ArrayRef<StringRef> StringLikeClassNames,
                 StringRef AbseilStringsMatchHeader) {
-  auto StringLikeClass = cxxRecordDecl(hasAnyName(StringLikeClassNames));
-  auto StringType =
+  const auto StringLikeClass = cxxRecordDecl(hasAnyName(StringLikeClassNames));
+  const auto StringType =
       hasUnqualifiedDesugaredType(recordType(hasDeclaration(StringLikeClass)));
-  auto CharStarType =
+  const auto CharStarType =
       hasUnqualifiedDesugaredType(pointerType(pointee(isAnyCharacter())));
-  auto CharType = hasUnqualifiedDesugaredType(isCharType());
-  auto StringNpos = declRefExpr(
+  const auto CharType = hasUnqualifiedDesugaredType(isCharType());
+  const auto StringNpos = declRefExpr(
       to(varDecl(hasName("npos"), hasDeclContext(StringLikeClass))));
-  auto StringFind = cxxMemberCallExpr(
+  const auto StringFind = cxxMemberCallExpr(
       callee(cxxMethodDecl(
           hasName("find"), parameterCountIs(2),
           hasParameter(
diff --git a/clang-tools-extra/clang-tidy/abseil/TimeComparisonCheck.cpp b/clang-tools-extra/clang-tidy/abseil/TimeComparisonCheck.cpp
index 5d80b16239838..7f3bc9b783308 100644
--- a/clang-tools-extra/clang-tidy/abseil/TimeComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/TimeComparisonCheck.cpp
@@ -16,7 +16,7 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::abseil {
 
 void TimeComparisonCheck::registerMatchers(MatchFinder *Finder) {
-  auto Matcher =
+  const auto Matcher =
       expr(comparisonOperatorWithCallee(functionDecl(
                functionDecl(timeConversionFunction()).bind("function_decl"))))
           .bind("binop");
diff --git a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
index 4ae49d285930d..03e048093f52e 100644
--- a/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/TimeSubtractionCheck.cpp
@@ -97,7 +97,7 @@ void TimeSubtractionCheck::registerMatchers(MatchFinder *Finder) {
     std::optional<DurationScale> Scale = getScaleForTimeInverse(TimeInverse);
     assert(Scale && "Unknown scale encountered");
 
-    auto TimeInverseMatcher = callExpr(callee(
+    const auto TimeInverseMatcher = callExpr(callee(
         functionDecl(hasName((llvm::Twine("::absl::") + TimeInverse).str()))
             .bind("func_decl")));
 
@@ -106,7 +106,7 @@ void TimeSubtractionCheck::registerMatchers(MatchFinder *Finder) {
     // is not sufficient, since the second operand could be either a 'Time' or
     // a 'Duration'. If we know the result is a 'Duration', we can then infer
     // that the second operand must be a 'Time'.
-    auto CallMatcher =
+    const auto CallMatcher =
         callExpr(
             callee(functionDecl(hasName(getDurationFactoryForScale(*Scale)))),
             hasArgument(0, binaryOperator(hasOperatorName("-"),
@@ -118,7 +118,7 @@ void TimeSubtractionCheck::registerMatchers(MatchFinder *Finder) {
     // Match cases where we know the second operand is a 'Time'. Since
     // subtracting a 'Time' from a 'Duration' is not defined, in these cases,
     // we always know the first operand is a 'Time' if the second is a 'Time'.
-    auto OperandMatcher =
+    const auto OperandMatcher =
         binaryOperator(hasOperatorName("-"), hasRHS(TimeInverseMatcher))
             .bind("binop");
     Finder->addMatcher(OperandMatcher, this);
diff --git a/clang-tools-extra/clang-tidy/abseil/UncheckedStatusOrAccessCheck.cpp b/clang-tools-extra/clang-tidy/abseil/UncheckedStatusOrAccessCheck.cpp
index b61c0e63f84e3..9e1848e3852e7 100644
--- a/clang-tools-extra/clang-tidy/abseil/UncheckedStatusOrAccessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/abseil/UncheckedStatusOrAccessCheck.cpp
@@ -26,7 +26,7 @@ static constexpr StringRef FuncID = "fun";
 void UncheckedStatusOrAccessCheck::registerMatchers(MatchFinder *Finder) {
   using namespace ast_matchers;
 
-  auto HasStatusOrCallDescendant =
+  const auto HasStatusOrCallDescendant =
       hasDescendant(callExpr(callee(cxxMethodDecl(ofClass(hasAnyName(
           "absl::StatusOr", "absl::internal_statusor::OperatorBase"))))));
   Finder->addMatcher(functionDecl(unless(isExpansionInSystemHeader()),
diff --git a/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp b/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
index 519d90914580f..5ecf1fad1f458 100644
--- a/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
@@ -87,7 +87,7 @@ IdDependentBackwardBranchCheck::hasIdDepVar(const Expr *Expression) {
         dyn_cast_if_present<VarDecl>(Declaration->getDecl());
     if (!CheckVariable)
       return nullptr;
-    auto FoundVariable = IdDepVarsMap.find(CheckVariable);
+    const auto FoundVariable = IdDepVarsMap.find(CheckVariable);
     if (FoundVariable == IdDepVarsMap.end())
       return nullptr;
     return &(FoundVariable->second);
@@ -109,7 +109,7 @@ IdDependentBackwardBranchCheck::hasIdDepField(const Expr *Expression) {
         dyn_cast_if_present<FieldDecl>(MemberExpression->getMemberDecl());
     if (!CheckField)
       return nullptr;
-    auto FoundField = IdDepFieldsMap.find(CheckField);
+    const auto FoundField = IdDepFieldsMap.find(CheckField);
     if (FoundField == IdDepFieldsMap.end())
       return nullptr;
     return &(FoundField->second);
diff --git a/clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp b/clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp
index c9df658d9bd67..22abf51c52879 100644
--- a/clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/SingleWorkItemBarrierCheck.cpp
@@ -54,7 +54,7 @@ void SingleWorkItemBarrierCheck::check(const MatchFinder::MatchResult &Result) {
     bool IsNDRange = false;
     if (MatchedDecl->hasAttr<ReqdWorkGroupSizeAttr>()) {
       const auto *Attribute = MatchedDecl->getAttr<ReqdWorkGroupSizeAttr>();
-      auto Eval = [&](Expr *E) {
+      const auto Eval = [&](Expr *E) {
         return E->EvaluateKnownConstInt(MatchedDecl->getASTContext())
             .getExtValue();
       };
diff --git a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
index d90305d14c48d..2573704f37a7e 100644
--- a/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
+++ b/clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
@@ -109,7 +109,7 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
   }
 
   FixItHint FixIt;
-  auto *Attribute = Struct->getAttr<AlignedAttr>();
+  const auto *Attribute = Struct->getAttr<AlignedAttr>();
   const std::string NewAlignQuantity = std::to_string(NewAlign.getQuantity());
   if (Attribute) {
     FixIt = FixItHint::CreateReplacement(
diff --git a/clang-tools-extra/clang-tidy/android/CloexecAccept4Check.cpp b/clang-tools-extra/clang-tidy/android/CloexecAccept4Check.cpp
index 8cf22ba2acb4a..7f8616c1cddbd 100644
--- a/clang-tools-extra/clang-tidy/android/CloexecAccept4Check.cpp
+++ b/clang-tools-extra/clang-tidy/android/CloexecAccept4Check.cpp
@@ -14,9 +14,10 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::android {
 
 void CloexecAccept4Check::registerMatchers(MatchFinder *Finder) {
-  auto SockAddrPointerType =
+  const auto SockAddrPointerType =
       hasType(pointsTo(recordDecl(isStruct(), hasName("sockaddr"))));
-  auto SockLenPointerType = hasType(pointsTo(namedDecl(hasName("socklen_t"))));
+  const auto SockLenPointerType =
+      hasType(pointsTo(namedDecl(hasName("socklen_t"))));
 
   registerMatchersImpl(Finder,
                        functionDecl(returns(isInteger()), hasName("accept4"),
diff --git a/clang-tools-extra/clang-tidy/android/CloexecAcceptCheck.cpp b/clang-tools-extra/clang-tidy/android/CloexecAcceptCheck.cpp
index a624523b18137..216d97043ce32 100644
--- a/clang-tools-extra/clang-tidy/android/CloexecAcceptCheck.cpp
+++ b/clang-tools-extra/clang-tidy/android/CloexecAcceptCheck.cpp
@@ -14,9 +14,10 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::android {
 
 void CloexecAcceptCheck::registerMatchers(MatchFinder *Finder) {
-  auto SockAddrPointerType =
+  const auto SockAddrPointerType =
       hasType(pointsTo(recordDecl(isStruct(), hasName("sockaddr"))));
-  auto SockLenPointerType = hasType(pointsTo(namedDecl(hasName("socklen_t"))));
+  const auto SockLenPointerType =
+      hasType(pointsTo(namedDecl(hasName("socklen_t"))));
 
   registerMatchersImpl(Finder,
                        functionDecl(returns(isInteger()), hasName("accept"),
diff --git a/clang-tools-extra/clang-tidy/android/CloexecCreatCheck.cpp b/clang-tools-extra/clang-tidy/android/CloexecCreatCheck.cpp
index ae44efb629893..a43a0768c03f1 100644
--- a/clang-tools-extra/clang-tidy/android/CloexecCreatCheck.cpp
+++ b/clang-tools-extra/clang-tidy/android/CloexecCreatCheck.cpp
@@ -14,8 +14,8 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::android {
 
 void CloexecCreatCheck::registerMatchers(MatchFinder *Finder) {
-  auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
-  auto MODETType = hasType(namedDecl(hasName("mode_t")));
+  const auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
+  const auto MODETType = hasType(namedDecl(hasName("mode_t")));
   registerMatchersImpl(Finder, functionDecl(isExternC(), returns(isInteger()),
                                             hasName("creat"),
                                             hasParameter(0, CharPointerType),
diff --git a/clang-tools-extra/clang-tidy/android/CloexecFopenCheck.cpp b/clang-tools-extra/clang-tidy/android/CloexecFopenCheck.cpp
index 8ddd6a0523156..06521f87119a3 100644
--- a/clang-tools-extra/clang-tidy/android/CloexecFopenCheck.cpp
+++ b/clang-tools-extra/clang-tidy/android/CloexecFopenCheck.cpp
@@ -14,7 +14,7 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::android {
 
 void CloexecFopenCheck::registerMatchers(MatchFinder *Finder) {
-  auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
+  const auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
   registerMatchersImpl(
       Finder, functionDecl(isExternC(), returns(asString("FILE *")),
                            hasName("fopen"), hasParameter(0, CharPointerType),
diff --git a/clang-tools-extra/clang-tidy/android/CloexecMemfdCreateCheck.cpp b/clang-tools-extra/clang-tidy/android/CloexecMemfdCreateCheck.cpp
index 5ecf908aabb59..97f20ee7f3310 100644
--- a/clang-tools-extra/clang-tidy/android/CloexecMemfdCreateCheck.cpp
+++ b/clang-tools-extra/clang-tidy/android/CloexecMemfdCreateCheck.cpp
@@ -13,7 +13,7 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::android {
 
 void CloexecMemfdCreateCheck::registerMatchers(MatchFinder *Finder) {
-  auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
+  const auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
   registerMatchersImpl(
       Finder, functionDecl(returns(isInteger()), hasName("memfd_create"),
                            hasParameter(0, CharPointerType),
diff --git a/clang-tools-extra/clang-tidy/android/CloexecOpenCheck.cpp b/clang-tools-extra/clang-tidy/android/CloexecOpenCheck.cpp
index 9938027c53b0e..7c70f1a71a79f 100644
--- a/clang-tools-extra/clang-tidy/android/CloexecOpenCheck.cpp
+++ b/clang-tools-extra/clang-tidy/android/CloexecOpenCheck.cpp
@@ -14,7 +14,7 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::android {
 
 void CloexecOpenCheck::registerMatchers(MatchFinder *Finder) {
-  auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
+  const auto CharPointerType = hasType(pointerType(pointee(isAnyCharacter())));
   registerMatchersImpl(Finder,
                        functionDecl(isExternC(), returns(isInteger()),
                                     hasAnyName("open", "open64"),
diff --git a/clang-tools-extra/clang-tidy/boost/UseToStringCheck.cpp b/clang-tools-extra/clang-tidy/boost/UseToStringCheck.cpp
index 3574108ee5697..011ffaff7ca12 100644
--- a/clang-tools-extra/clang-tidy/boost/UseToStringCheck.cpp
+++ b/clang-tools-extra/clang-tidy/boost/UseToStringCheck.cpp
@@ -37,7 +37,7 @@ void UseToStringCheck::registerMatchers(MatchFinder *Finder) {
 
 void UseToStringCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *Call = Result.Nodes.getNodeAs<CallExpr>("to_string");
-  auto CharType =
+  const auto CharType =
       Result.Nodes.getNodeAs<TemplateArgument>("char_type")->getAsType();
 
   StringRef StringType;
@@ -50,8 +50,8 @@ void UseToStringCheck::check(const MatchFinder::MatchResult &Result) {
   else
     return;
 
-  auto Loc = Call->getBeginLoc();
-  auto Diag =
+  const auto Loc = Call->getBeginLoc();
+  const auto Diag =
       diag(Loc, "use std::to_%0 instead of boost::lexical_cast<std::%0>")
       << StringType;
 
diff --git a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
index 16a0fb1b037bf..29057b4101fa8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp
@@ -80,7 +80,7 @@ void ArgumentCommentCheck::registerMatchers(MatchFinder *Finder) {
 static std::vector<std::pair<SourceLocation, StringRef>>
 getCommentsInRange(ASTContext *Ctx, CharSourceRange Range) {
   std::vector<std::pair<SourceLocation, StringRef>> Comments;
-  auto &SM = Ctx->getSourceManager();
+  const auto &SM = Ctx->getSourceManager();
   const std::pair<FileID, unsigned> BeginLoc =
                                         SM.getDecomposedLoc(Range.getBegin()),
                                     EndLoc =
@@ -273,7 +273,8 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
   if ((NumArgs == 0) || (IgnoreSingleArgument && NumArgs == 1))
     return;
 
-  auto MakeFileCharRange = [Ctx](SourceLocation Begin, SourceLocation End) {
+  const auto MakeFileCharRange = [Ctx](SourceLocation Begin,
+                                       SourceLocation End) {
     return Lexer::makeFileCharRange(CharSourceRange::getCharRange(Begin, End),
                                     Ctx->getSourceManager(),
                                     Ctx->getLangOpts());
@@ -309,7 +310,7 @@ void ArgumentCommentCheck::checkCallArgs(ASTContext *Ctx,
       Comments = getCommentsBeforeLoc(Ctx, ArgsRange.getBegin());
     }
 
-    for (auto Comment : Comments) {
+    for (const auto Comment : Comments) {
       llvm::SmallVector<StringRef, 2> Matches;
       if (IdentRE.match(Comment.second, &Matches) &&
           !sameName(Matches[2], II->getName(), StrictMode)) {
diff --git a/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
index 6eadae21fae2f..a41ec93a9ca89 100644
--- a/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/AssertSideEffectCheck.cpp
@@ -103,13 +103,13 @@ void AssertSideEffectCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void AssertSideEffectCheck::registerMatchers(MatchFinder *Finder) {
-  auto IgnoredFunctionsMatcher =
+  const auto IgnoredFunctionsMatcher =
       matchers::matchesAnyListedRegexName(IgnoredFunctions);
 
-  auto DescendantWithSideEffect =
+  const auto DescendantWithSideEffect =
       traverse(TK_AsIs, hasDescendant(expr(hasSideEffect(
                             CheckFunctionCalls, IgnoredFunctionsMatcher))));
-  auto ConditionWithSideEffect = hasCondition(DescendantWithSideEffect);
+  const auto ConditionWithSideEffect = hasCondition(DescendantWithSideEffect);
   Finder->addMatcher(
       stmt(
           anyOf(conditionalOperator(ConditionWithSideEffect),
diff --git a/clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.cpp
index a9e7ae8734677..b8b4948665b0f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BitwisePointerCastCheck.cpp
@@ -15,7 +15,7 @@ namespace clang::tidy::bugprone {
 
 void BitwisePointerCastCheck::registerMatchers(MatchFinder *Finder) {
   if (getLangOpts().CPlusPlus20) {
-    auto IsPointerType = refersToType(qualType(isAnyPointer()));
+    const auto IsPointerType = refersToType(qualType(isAnyPointer()));
     Finder->addMatcher(callExpr(hasDeclaration(functionDecl(allOf(
                                     hasName("::std::bit_cast"),
                                     hasTemplateArgument(0, IsPointerType),
@@ -24,7 +24,7 @@ void BitwisePointerCastCheck::registerMatchers(MatchFinder *Finder) {
                        this);
   }
 
-  auto IsDoublePointerType =
+  const auto IsDoublePointerType =
       hasType(qualType(pointsTo(qualType(isAnyPointer()))));
   Finder->addMatcher(callExpr(hasArgument(0, IsDoublePointerType),
                               hasArgument(1, IsDoublePointerType),
diff --git a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
index e1bca0e459c71..64c64b2579bf9 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -402,7 +402,7 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) {
         Branches.back().push_back(S);
     }
 
-    auto *End = Branches.end();
+    const auto *End = Branches.end();
     auto *BeginCurrent = Branches.begin();
     while (BeginCurrent < End) {
       if (isFallthroughSwitchBranch(*BeginCurrent)) {
diff --git a/clang-tools-extra/clang-tidy/bugprone/CapturingThisInMemberVariableCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CapturingThisInMemberVariableCheck.cpp
index 5adf8f97ee8f0..a78af8aa2fea3 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CapturingThisInMemberVariableCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/CapturingThisInMemberVariableCheck.cpp
@@ -83,11 +83,11 @@ void CapturingThisInMemberVariableCheck::storeOptions(
 }
 
 void CapturingThisInMemberVariableCheck::registerMatchers(MatchFinder *Finder) {
-  auto IsStdFunctionField =
+  const auto IsStdFunctionField =
       fieldDecl(hasType(cxxRecordDecl(
                     matchers::matchesAnyListedRegexName(FunctionWrapperTypes))))
           .bind("field");
-  auto CaptureThis = lambdaCapture(anyOf(
+  const auto CaptureThis = lambdaCapture(anyOf(
       // [this]
       capturesThis(),
       // [self = this]
@@ -102,7 +102,7 @@ void CapturingThisInMemberVariableCheck::registerMatchers(MatchFinder *Finder) {
                hasAnyArgument(cxxThisExpr()))
           .bind("bind");
 
-  auto IsInitWithLambdaOrBind =
+  const auto IsInitWithLambdaOrBind =
       anyOf(IsLambdaCapturingThis, IsBindCapturingThis,
             cxxConstructExpr(hasArgument(
                 0, anyOf(IsLambdaCapturingThis, IsBindCapturingThis))));
diff --git a/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
index 5e6eda674d35b..f22ca388d12ee 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ComparePointerToMemberVirtualFunctionCheck.cpp
@@ -34,10 +34,10 @@ static constexpr StringRef ErrorMsg =
 
 void ComparePointerToMemberVirtualFunctionCheck::registerMatchers(
     MatchFinder *Finder) {
-  auto DirectMemberVirtualFunctionPointer = unaryOperator(
+  const auto DirectMemberVirtualFunctionPointer = unaryOperator(
       allOf(hasOperatorName("&"),
             hasUnaryOperand(declRefExpr(to(cxxMethodDecl(isVirtual()))))));
-  auto IndirectMemberPointer =
+  const auto IndirectMemberPointer =
       ignoringImpCasts(declRefExpr().bind("indirect_member_pointer"));
 
   Finder->addMatcher(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.cpp
index ccbc86ae74cc6..5809dcfb4bd1c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/CopyConstructorInitCheck.cpp
@@ -87,9 +87,10 @@ void CopyConstructorInitCheck::check(const MatchFinder::MatchResult &Result) {
   if (!HasRelevantBaseInit)
     return;
 
-  auto Diag = diag(Ctor->getLocation(),
-                   "calling a base constructor other than the copy constructor")
-              << SafeFixIts;
+  const auto Diag =
+      diag(Ctor->getLocation(),
+           "calling a base constructor other than the copy constructor")
+      << SafeFixIts;
 
   if (FixItInitList.empty() || ParamName.empty() || ShouldNotDoFixit)
     return;
diff --git a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
index 8c8a9020011b0..13d9750234b0d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/CrtpConstructorAccessibilityCheck.cpp
@@ -129,8 +129,8 @@ void CrtpConstructorAccessibilityCheck::check(
         << HintFriend;
   }
 
-  auto WithFriendHintIfNeeded = [&](const DiagnosticBuilder &Diag,
-                                    bool NeedsFriend) {
+  const auto WithFriendHintIfNeeded = [&](const DiagnosticBuilder &Diag,
+                                          bool NeedsFriend) {
     if (NeedsFriend)
       Diag << HintFriend;
   };
diff --git a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
index c5cf62a78441f..5da957cc880dc 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EasilySwappableParametersCheck.cpp
@@ -278,7 +278,7 @@ struct ConversionSequence {
   /// the conversion sequence. This method does **NOT** return Begin and End.
   SmallVector<QualType, 4> getInvolvedTypesInSequence() const {
     SmallVector<QualType, 4> Ret;
-    auto EmplaceIfDifferent = [&Ret](QualType QT) {
+    const auto EmplaceIfDifferent = [&Ret](QualType QT) {
       if (QT.isNull())
         return;
       if (Ret.empty())
@@ -976,7 +976,7 @@ approximateStandardConversionSequence(const TheCheck &Check, QualType From,
   // Get out the qualifiers of the original type. This will always be
   // re-applied to the WorkType to ensure it is the same qualification as the
   // original From was.
-  auto FastQualifiersToApply = static_cast<unsigned>(
+  const auto FastQualifiersToApply = static_cast<unsigned>(
       From.split().Quals.getAsOpaqueValue() & Qualifiers::FastMask);
 
   // LValue->RValue is irrelevant for the check, because it is a thing to be
@@ -1593,7 +1593,7 @@ using ParamToSmallPtrSetMap =
 template <typename MapTy, typename ElemTy>
 static bool lazyMapOfSetsIntersectionExists(const MapTy &Map, const ElemTy &E1,
                                             const ElemTy &E2) {
-  auto E1Iterator = Map.find(E1);
+  const auto E1Iterator = Map.find(E1);
   auto E2Iterator = Map.find(E2);
   if (E1Iterator == Map.end() || E2Iterator == Map.end())
     return false;
@@ -1635,7 +1635,7 @@ class AppearsInSameExpr : public RecursiveASTVisitor<AppearsInSameExpr> {
   }
 
   bool TraverseStmt(Stmt *S, DataRecursionQueue *Queue = nullptr) {
-    if (auto *E = dyn_cast_or_null<Expr>(S)) {
+    if (const auto *E = dyn_cast_or_null<Expr>(S)) {
       bool RootSetInCurrentStackFrame = false;
       if (!CurrentExprOnlyTreeRoot) {
         CurrentExprOnlyTreeRoot = E;
@@ -1659,7 +1659,7 @@ class AppearsInSameExpr : public RecursiveASTVisitor<AppearsInSameExpr> {
     if (!CurrentExprOnlyTreeRoot)
       return true;
 
-    if (auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
+    if (const auto *PVD = dyn_cast<ParmVarDecl>(DRE->getDecl()))
       if (llvm::find(FD->parameters(), PVD))
         ParentExprsForParamRefs[PVD].insert(CurrentExprOnlyTreeRoot);
 
@@ -1676,7 +1676,7 @@ class PassedToSameFunction {
 
 public:
   void setup(const FunctionDecl *FD) {
-    auto ParamsAsArgsInFnCalls =
+    const auto ParamsAsArgsInFnCalls =
         match(functionDecl(forEachDescendant(
                   callExpr(forEachArgumentWithParam(
                                paramRefExpr(), parmVarDecl().bind("passed-to")))
@@ -1716,7 +1716,7 @@ class AccessedSameMemberOf {
 
 public:
   void setup(const FunctionDecl *FD) {
-    auto MembersCalledOnParams = match(
+    const auto MembersCalledOnParams = match(
         functionDecl(forEachDescendant(
             memberExpr(hasObjectExpression(paramRefExpr())).bind("mem-expr"))),
         *FD, FD->getASTContext());
@@ -1743,9 +1743,9 @@ class Returned {
 public:
   void setup(const FunctionDecl *FD) {
     // TODO: Handle co_return.
-    auto ParamReturns = match(functionDecl(forEachDescendant(
-                                  returnStmt(hasReturnValue(paramRefExpr())))),
-                              *FD, FD->getASTContext());
+    const auto ParamReturns = match(functionDecl(forEachDescendant(returnStmt(
+                                        hasReturnValue(paramRefExpr())))),
+                                    *FD, FD->getASTContext());
     for (const auto &Match : ParamReturns) {
       const auto *ReturnedParam = Match.getNodeAs<ParmVarDecl>("param");
       assert(ReturnedParam);
@@ -1999,7 +1999,7 @@ struct FormattedConversionSequence {
       Trivial = false;
     }
 
-    auto AddType = [&](StringRef ToAdd) {
+    const auto AddType = [&](StringRef ToAdd) {
       if (LastAddedType != ToAdd && ToAdd != SeqEndTypeStr) {
         OS << " -> '" << ToAdd << "'";
         LastAddedType = ToAdd.str();
@@ -2215,8 +2215,8 @@ void EasilySwappableParametersCheck::check(
         DiagText = "%0 adjacent parameters of %1 of similar type ('%2') are "
                    "easily swapped by mistake";
 
-      auto Diag = diag(First->getOuterLocStart(), DiagText)
-                  << static_cast<unsigned>(R.NumParamsChecked) << FD;
+      const auto Diag = diag(First->getOuterLocStart(), DiagText)
+                        << static_cast<unsigned>(R.NumParamsChecked) << FD;
       if (!NeedsAnyTypeNote)
         Diag << FirstParamTypeAsWritten;
 
@@ -2279,7 +2279,7 @@ void EasilySwappableParametersCheck::check(
           ExplicitlyPrintCommonType = true;
         }
 
-        auto Diag =
+        const auto Diag =
             diag(LVar->getOuterLocStart(), DiagText, DiagnosticIDs::Note)
             << LTypeStr << RTypeStr;
         if (ExplicitlyPrintCommonType)
@@ -2310,7 +2310,7 @@ void EasilySwappableParametersCheck::check(
           DiagText = "'%0' and '%1' may be implicitly converted: %2, %3";
 
         {
-          auto Diag =
+          const auto Diag =
               diag(RVar->getOuterLocStart(), DiagText, DiagnosticIDs::Note)
               << LTypeStr << RTypeStr;
 
diff --git a/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp
index a2a60233d0e05..e2914779eec0b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/EmptyCatchCheck.cpp
@@ -77,13 +77,13 @@ std::optional<TraversalKind> EmptyCatchCheck::getCheckTraversalKind() const {
 }
 
 void EmptyCatchCheck::registerMatchers(MatchFinder *Finder) {
-  auto AllowedNamedExceptionDecl = namedDecl(
+  const auto AllowedNamedExceptionDecl = namedDecl(
       matchers::matchesAnyListedRegexName(AllowEmptyCatchForExceptions));
   auto AllowedNamedExceptionTypes =
       qualType(anyOf(hasDeclaration(AllowedNamedExceptionDecl),
                      references(AllowedNamedExceptionDecl),
                      pointsTo(AllowedNamedExceptionDecl)));
-  auto IgnoredExceptionType =
+  const auto IgnoredExceptionType =
       qualType(anyOf(AllowedNamedExceptionTypes,
                      hasCanonicalType(AllowedNamedExceptionTypes)));
 
diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
index 1cfb1511fa94e..ed198faf7c6f7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
@@ -71,7 +71,7 @@ void ExceptionEscapeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void ExceptionEscapeCheck::registerMatchers(MatchFinder *Finder) {
-  auto MatchIf = [](bool Enabled, const auto &Matcher) {
+  const auto MatchIf = [](bool Enabled, const auto &Matcher) {
     const ast_matchers::internal::Matcher<FunctionDecl> Nothing =
         unless(anything());
     return Enabled ? Matcher : Nothing;
diff --git a/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
index 65578f7d81254..476bb25b77cac 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ForwardDeclarationNamespaceCheck.cpp
@@ -143,7 +143,7 @@ void ForwardDeclarationNamespaceCheck::onEndOfTranslationUnit() {
       }
       // Check if a definition in another namespace exists.
       const auto DeclName = CurDecl->getName();
-      auto It = DeclNameToDefinitions.find(DeclName);
+      const auto It = DeclNameToDefinitions.find(DeclName);
       if (It == DeclNameToDefinitions.end())
         continue; // No definition in this translation unit, we can skip it.
       // Make a warning for each definition with the same name (in other
diff --git a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
index 263ab635d9458..aad06992fd0fa 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp
@@ -17,7 +17,7 @@ namespace clang::tidy::bugprone {
 namespace {
 // Check if the given type is related to std::enable_if.
 AST_MATCHER(QualType, isEnableIf) {
-  auto CheckTemplate = [](const TemplateSpecializationType *Spec) {
+  const auto CheckTemplate = [](const TemplateSpecializationType *Spec) {
     if (!Spec)
       return false;
 
@@ -58,7 +58,7 @@ AST_MATCHER(TemplateDecl, hasAssociatedConstraints) {
 } // namespace
 
 void ForwardingReferenceOverloadCheck::registerMatchers(MatchFinder *Finder) {
-  auto ForwardingRefParm =
+  const auto ForwardingRefParm =
       parmVarDecl(
           hasType(qualType(rValueReferenceType(),
                            references(templateTypeParmType(hasDeclaration(
diff --git a/clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp
index 634d54c2b9bd3..83e9aa8800584 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp
@@ -111,10 +111,10 @@ void ImplicitWideningOfMultiplicationResultCheck::handleImplicitCastExpr(
       << Ty << E->getType();
 
   {
-    auto Diag = diag(E->getBeginLoc(),
-                     "make conversion explicit to silence this warning",
-                     DiagnosticIDs::Note)
-                << E->getSourceRange();
+    const auto Diag = diag(E->getBeginLoc(),
+                           "make conversion explicit to silence this warning",
+                           DiagnosticIDs::Note)
+                      << E->getSourceRange();
     const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
         E->getEndLoc(), 0, *Result->SourceManager, getLangOpts());
     if (ShouldUseCXXStaticCast)
@@ -146,9 +146,10 @@ void ImplicitWideningOfMultiplicationResultCheck::handleImplicitCastExpr(
   }
 
   {
-    auto Diag = diag(E->getBeginLoc(), "perform multiplication in a wider type",
-                     DiagnosticIDs::Note)
-                << LHS->getSourceRange();
+    const auto Diag =
+        diag(E->getBeginLoc(), "perform multiplication in a wider type",
+             DiagnosticIDs::Note)
+        << LHS->getSourceRange();
 
     if (ShouldUseCXXStaticCast)
       Diag << FixItHint::CreateInsertion(LHS->getBeginLoc(),
@@ -224,10 +225,10 @@ void ImplicitWideningOfMultiplicationResultCheck::handlePointerOffsetting(
       << IndexExprType << TyAsString;
 
   {
-    auto Diag = diag(IndexExpr->getBeginLoc(),
-                     "make conversion explicit to silence this warning",
-                     DiagnosticIDs::Note)
-                << IndexExpr->getSourceRange();
+    const auto Diag = diag(IndexExpr->getBeginLoc(),
+                           "make conversion explicit to silence this warning",
+                           DiagnosticIDs::Note)
+                      << IndexExpr->getSourceRange();
     const SourceLocation EndLoc = Lexer::getLocForEndOfToken(
         IndexExpr->getEndLoc(), 0, *Result->SourceManager, getLangOpts());
     if (ShouldUseCXXStaticCast)
@@ -243,7 +244,7 @@ void ImplicitWideningOfMultiplicationResultCheck::handlePointerOffsetting(
   }
 
   {
-    auto Diag =
+    const auto Diag =
         diag(IndexExpr->getBeginLoc(), "perform multiplication in a wider type",
              DiagnosticIDs::Note)
         << LHS->getSourceRange();
diff --git a/clang-tools-extra/clang-tidy/bugprone/IncDecInConditionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/IncDecInConditionsCheck.cpp
index 553c45c2a9541..353a724c102bd 100644
--- a/clang-tools-extra/clang-tidy/bugprone/IncDecInConditionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/IncDecInConditionsCheck.cpp
@@ -31,7 +31,7 @@ AST_MATCHER(CXXOperatorCallExpr, isPrePostOperator) {
 } // namespace
 
 void IncDecInConditionsCheck::registerMatchers(MatchFinder *Finder) {
-  auto OperatorMatcher = expr(
+  const auto OperatorMatcher = expr(
       anyOf(binaryOperator(anyOf(isComparisonOperator(), isLogicalOperator())),
             cxxOperatorCallExpr(isComparisonOperator())));
 
diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp
index 6181ac84f36e3..e16cfa4855952 100644
--- a/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableIfCheck.cpp
@@ -54,9 +54,9 @@ void IncorrectEnableIfCheck::check(const MatchFinder::MatchResult &Result) {
   const SourceLocation RAngleLoc =
       SM.getExpansionLoc(EnableIfSpecializationLoc->getRAngleLoc());
 
-  auto Diag = diag(EnableIf->getBeginLoc(),
-                   "incorrect std::enable_if usage detected; use "
-                   "'typename std::enable_if<...>::type'");
+  const auto Diag = diag(EnableIf->getBeginLoc(),
+                         "incorrect std::enable_if usage detected; use "
+                         "'typename std::enable_if<...>::type'");
   // FIXME: This should handle the enable_if specialization already having an
   // elaborated keyword.
   if (!getLangOpts().CPlusPlus20) {
diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp
index a4965c298adbc..1ba3297c023cd 100644
--- a/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectRoundingsCheck.cpp
@@ -26,10 +26,10 @@ AST_MATCHER(FloatingLiteral, floatHalf) {
 
 void IncorrectRoundingsCheck::registerMatchers(MatchFinder *MatchFinder) {
   // Match a floating literal with value 0.5.
-  auto FloatHalf = floatLiteral(floatHalf());
+  const auto FloatHalf = floatLiteral(floatHalf());
 
   // Match a floating point expression.
-  auto FloatType = expr(hasType(realFloatingPointType()));
+  const auto FloatType = expr(hasType(realFloatingPointType()));
 
   // Find expressions of cast to int of the sum of a floating point expression
   // and 0.5.
diff --git a/clang-tools-extra/clang-tidy/bugprone/InvalidEnumDefaultInitializationCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/InvalidEnumDefaultInitializationCheck.cpp
index 65efb9adff3ac..09d84391d8ba3 100644
--- a/clang-tools-extra/clang-tidy/bugprone/InvalidEnumDefaultInitializationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/InvalidEnumDefaultInitializationCheck.cpp
@@ -81,7 +81,7 @@ class FindEnumMember : public TypeVisitor<FindEnumMember, bool> {
     const RecordDecl *RD = T->getDecl()->getDefinition();
     if (!RD || RD->isUnion())
       return false;
-    auto VisitField = [this](const FieldDecl *F) {
+    const auto VisitField = [this](const FieldDecl *F) {
       return Visit(F->getType().getTypePtr());
     };
     return llvm::any_of(RD->fields(), VisitField);
@@ -110,7 +110,7 @@ void InvalidEnumDefaultInitializationCheck::registerMatchers(
       enumDecl(isCompleteAndHasNoZeroValue(),
                unless(matchers::matchesAnyListedRegexName(IgnoredEnums)))
           .bind("enum")));
-  auto EnumOrArrayOfEnum = qualType(hasUnqualifiedDesugaredType(
+  const auto EnumOrArrayOfEnum = qualType(hasUnqualifiedDesugaredType(
       anyOf(EnumWithoutZeroValue,
             arrayType(hasElementType(qualType(
                 hasUnqualifiedDesugaredType(EnumWithoutZeroValue)))))));
diff --git a/clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
index 11e2d2e6a72f4..c6bf0fbbc1f54 100644
--- a/clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/LambdaFunctionNameCheck.cpp
@@ -94,7 +94,7 @@ void LambdaFunctionNameCheck::check(const MatchFinder::MatchResult &Result) {
     if (IgnoreMacros)
       return;
 
-    auto ER =
+    const auto ER =
         Result.SourceManager->getImmediateExpansionRange(E->getLocation());
     if (SuppressMacroExpansions.contains(ER.getAsRange())) {
       // This is a macro expansion for which we should not warn.
diff --git a/clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp
index ff7f3020102ad..36715e662e71c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MisleadingSetterOfReferenceCheck.cpp
@@ -15,25 +15,25 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::bugprone {
 
 void MisleadingSetterOfReferenceCheck::registerMatchers(MatchFinder *Finder) {
-  auto RefField = fieldDecl(hasType(hasCanonicalType(referenceType(
-                                pointee(equalsBoundNode("type"))))))
-                      .bind("member");
-  auto AssignLHS = memberExpr(
+  const auto RefField = fieldDecl(hasType(hasCanonicalType(referenceType(
+                                      pointee(equalsBoundNode("type"))))))
+                            .bind("member");
+  const auto AssignLHS = memberExpr(
       hasObjectExpression(ignoringParenCasts(cxxThisExpr())), member(RefField));
-  auto DerefOperand = expr(ignoringParenCasts(
+  const auto DerefOperand = expr(ignoringParenCasts(
       declRefExpr(to(parmVarDecl(equalsBoundNode("parm"))))));
-  auto AssignRHS = expr(ignoringParenCasts(
+  const auto AssignRHS = expr(ignoringParenCasts(
       unaryOperator(hasOperatorName("*"), hasUnaryOperand(DerefOperand))));
 
-  auto BinaryOpAssign = binaryOperator(hasOperatorName("="), hasLHS(AssignLHS),
-                                       hasRHS(AssignRHS));
-  auto CXXOperatorCallAssign = cxxOperatorCallExpr(
+  const auto BinaryOpAssign = binaryOperator(
+      hasOperatorName("="), hasLHS(AssignLHS), hasRHS(AssignRHS));
+  const auto CXXOperatorCallAssign = cxxOperatorCallExpr(
       hasOverloadedOperatorName("="), hasLHS(AssignLHS), hasRHS(AssignRHS));
 
-  auto SetBody =
+  const auto SetBody =
       compoundStmt(statementCountIs(1),
                    anyOf(has(BinaryOpAssign), has(CXXOperatorCallAssign)));
-  auto BadSetFunction =
+  const auto BadSetFunction =
       cxxMethodDecl(
           parameterCountIs(1),
           hasParameter(
diff --git a/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp
index 5925e28eed734..968cb4c0cc73a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MisplacedOperatorInStrlenInAllocCheck.cpp
@@ -96,7 +96,7 @@ void MisplacedOperatorInStrlenInAllocCheck::check(
       CharSourceRange::getTokenRange(BinOp->getRHS()->getSourceRange()),
       *Result.SourceManager, getLangOpts());
 
-  auto Hint = FixItHint::CreateReplacement(
+  const auto Hint = FixItHint::CreateReplacement(
       StrLen->getSourceRange(),
       (StrLenBegin + LHSText + StrLenEnd + " + " + RHSText).str());
 
diff --git a/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
index e182df75b1d9a..ffb0461922981 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MoveForwardingReferenceCheck.cpp
@@ -71,7 +71,7 @@ static void replaceMoveWithForward(const UnresolvedLookupExpr *Callee,
 void MoveForwardingReferenceCheck::registerMatchers(MatchFinder *Finder) {
   // Matches a ParmVarDecl for a forwarding reference, i.e. a non-const rvalue
   // reference of a function template parameter type.
-  auto ForwardingReferenceParmMatcher =
+  const auto ForwardingReferenceParmMatcher =
       parmVarDecl(
           hasType(qualType(rValueReferenceType(),
                            references(templateTypeParmType(hasDeclaration(
diff --git a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
index b81d2b438d58d..aef000c66eb3b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
@@ -83,16 +83,19 @@ void MultipleNewInOneExpressionCheck::registerMatchers(MatchFinder *Finder) {
   auto BadAllocReferenceType = referenceType(pointee(BadAllocType));
   auto ExceptionReferenceType = referenceType(pointee(ExceptionType));
 
-  auto CatchBadAllocType =
+  const auto CatchBadAllocType =
       qualType(hasCanonicalType(anyOf(BadAllocType, BadAllocReferenceType,
                                       ExceptionType, ExceptionReferenceType)));
-  auto BadAllocCatchingTryBlock = cxxTryStmt(hasHandlerFor(CatchBadAllocType));
-
-  auto NewExprMayThrow = cxxNewExpr(mayThrow());
-  auto HasNewExpr1 = expr(anyOf(NewExprMayThrow.bind("new1"),
-                                hasDescendant(NewExprMayThrow.bind("new1"))));
-  auto HasNewExpr2 = expr(anyOf(NewExprMayThrow.bind("new2"),
-                                hasDescendant(NewExprMayThrow.bind("new2"))));
+  const auto BadAllocCatchingTryBlock =
+      cxxTryStmt(hasHandlerFor(CatchBadAllocType));
+
+  const auto NewExprMayThrow = cxxNewExpr(mayThrow());
+  const auto HasNewExpr1 =
+      expr(anyOf(NewExprMayThrow.bind("new1"),
+                 hasDescendant(NewExprMayThrow.bind("new1"))));
+  const auto HasNewExpr2 =
+      expr(anyOf(NewExprMayThrow.bind("new2"),
+                 hasDescendant(NewExprMayThrow.bind("new2"))));
 
   Finder->addMatcher(
       callExpr(
diff --git a/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp
index 54ed8994d0352..bf026f9374437 100644
--- a/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/MultipleStatementMacroCheck.cpp
@@ -23,7 +23,7 @@ AST_MATCHER(Expr, isInMacro) { return Node.getBeginLoc().isMacroID(); }
 /// Find the next statement after `S`.
 static const Stmt *nextStmt(const MatchFinder::MatchResult &Result,
                             const Stmt *S) {
-  auto Parents = Result.Context->getParents(*S);
+  const auto Parents = Result.Context->getParents(*S);
   if (Parents.empty())
     return nullptr;
   const auto *Parent = Parents[0].get<Stmt>();
diff --git a/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp
index f2fc1e1832133..c21f5ed06b991 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NonZeroEnumToBoolConversionCheck.cpp
@@ -49,7 +49,7 @@ bool NonZeroEnumToBoolConversionCheck::isLanguageVersionSupported(
 void NonZeroEnumToBoolConversionCheck::registerMatchers(MatchFinder *Finder) {
   // Excluding bitwise operators (binary and overload) to avoid false-positives
   // in code like this 'if (e & SUCCESS) {'.
-  auto ExcludedOperators = binaryOperation(hasAnyOperatorName(
+  const auto ExcludedOperators = binaryOperation(hasAnyOperatorName(
       "|", "&", "^", "<<", ">>", "~", "|=", "&=", "^=", "<<=", ">>="));
 
   Finder->addMatcher(
diff --git a/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerIterationOrderCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerIterationOrderCheck.cpp
index fdb903a333234..d896887f93ee9 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerIterationOrderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NondeterministicPointerIterationOrderCheck.cpp
@@ -15,10 +15,10 @@ namespace clang::tidy::bugprone {
 
 void NondeterministicPointerIterationOrderCheck::registerMatchers(
     MatchFinder *Finder) {
-  auto LoopVariable = varDecl(hasType(
+  const auto LoopVariable = varDecl(hasType(
       qualType(hasCanonicalType(anyOf(referenceType(), pointerType())))));
 
-  auto RangeInit = declRefExpr(to(varDecl(
+  const auto RangeInit = declRefExpr(to(varDecl(
       hasType(recordDecl(hasAnyName("std::unordered_set", "std::unordered_map",
                                     "std::unordered_multiset",
                                     "std::unordered_multimap"))
diff --git a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index 6e1626668d7f1..6ae350a38b70f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -522,14 +522,14 @@ AST_MATCHER_P(Expr, hasDefinition, ast_matchers::internal::Matcher<Expr>,
   if (InnerMatcher.matches(*SimpleNode, Finder, Builder))
     return true;
 
-  auto DREHasInit = ignoringImpCasts(
+  const auto DREHasInit = ignoringImpCasts(
       declRefExpr(to(varDecl(hasInitializer(ignoringImpCasts(InnerMatcher))))));
 
   if (DREHasInit.matches(*SimpleNode, Finder, Builder))
     return true;
 
   const char *const VarDeclName = "variable-declaration";
-  auto DREHasDefinition = ignoringImpCasts(declRefExpr(
+  const auto DREHasDefinition = ignoringImpCasts(declRefExpr(
       to(varDecl().bind(VarDeclName)),
       hasAncestor(compoundStmt(hasDescendant(binaryOperator(
           hasLHS(declRefExpr(to(varDecl(equalsBoundNode(VarDeclName))))),
@@ -543,25 +543,26 @@ AST_MATCHER_P(Expr, hasDefinition, ast_matchers::internal::Matcher<Expr>,
 } // namespace
 
 void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
-  auto IncOp =
+  const auto IncOp =
       binaryOperator(hasOperatorName("+"),
                      hasEitherOperand(ignoringParenImpCasts(integerLiteral())));
 
-  auto DecOp =
+  const auto DecOp =
       binaryOperator(hasOperatorName("-"),
                      hasEitherOperand(ignoringParenImpCasts(integerLiteral())));
 
-  auto HasIncOp = anyOf(ignoringImpCasts(IncOp), hasDescendant(IncOp));
-  auto HasDecOp = anyOf(ignoringImpCasts(DecOp), hasDescendant(DecOp));
+  const auto HasIncOp = anyOf(ignoringImpCasts(IncOp), hasDescendant(IncOp));
+  const auto HasDecOp = anyOf(ignoringImpCasts(DecOp), hasDescendant(DecOp));
 
-  auto Container = ignoringImpCasts(cxxMemberCallExpr(hasDescendant(declRefExpr(
-      hasType(hasUnqualifiedDesugaredType(recordType(hasDeclaration(recordDecl(
-          hasAnyName("::std::vector", "::std::list", "::std::deque"))))))))));
+  const auto Container = ignoringImpCasts(cxxMemberCallExpr(
+      hasDescendant(declRefExpr(hasType(hasUnqualifiedDesugaredType(
+          recordType(hasDeclaration(recordDecl(hasAnyName(
+              "::std::vector", "::std::list", "::std::deque"))))))))));
 
-  auto StringTy = type(hasUnqualifiedDesugaredType(recordType(
+  const auto StringTy = type(hasUnqualifiedDesugaredType(recordType(
       hasDeclaration(cxxRecordDecl(hasName("::std::basic_string"))))));
 
-  auto AnyOfStringTy =
+  const auto AnyOfStringTy =
       anyOf(hasType(StringTy), hasType(qualType(pointsTo(StringTy))));
 
   auto CharTyArray = hasType(qualType(hasCanonicalType(
@@ -570,7 +571,7 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
   auto CharTyPointer = hasType(
       qualType(hasCanonicalType(pointerType(pointee(isAnyCharacter())))));
 
-  auto AnyOfCharTy = anyOf(CharTyArray, CharTyPointer);
+  const auto AnyOfCharTy = anyOf(CharTyArray, CharTyPointer);
 
   //===--------------------------------------------------------------------===//
   // The following six cases match problematic length expressions.
@@ -608,7 +609,7 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
   auto DREHasReturnWithoutInc = ignoringImpCasts(
       declRefExpr(to(varDecl(hasInitializer(CallExprReturnWithoutInc)))));
 
-  auto AnyOfWrongLengthInit =
+  const auto AnyOfWrongLengthInit =
       anyOf(WrongLength, AnyOfCallOrDREWithoutInc, CallExprReturnWithoutInc,
             DREHasReturnWithoutInc);
 
@@ -620,7 +621,7 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
   // Note: Sometimes the size of char is explicitly written out.
   auto SizeExpr = anyOf(SizeOfCharExpr, integerLiteral(equals(1)));
 
-  auto MallocLengthExpr = allOf(
+  const auto MallocLengthExpr = allOf(
       callee(functionDecl(
           hasAnyName("::alloca", "::calloc", "malloc", "realloc"))),
       hasAnyArgument(allOf(unless(SizeExpr), expr().bind(DestMallocExprName))));
@@ -646,13 +647,13 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
                   expr().bind(UnknownDestName))
           .bind(DestExprName);
 
-  auto AnyOfDestDecl = ignoringImpCasts(
+  const auto AnyOfDestDecl = ignoringImpCasts(
       anyOf(allOf(hasDefinition(anyOf(AnyOfDestInit, DestArrayTyDecl,
                                       hasDescendant(DestArrayTyDecl))),
                   expr().bind(DestExprName)),
             anyOf(DestUnknownDecl, hasDescendant(DestUnknownDecl))));
 
-  auto NullTerminatorExpr = binaryOperator(
+  const auto NullTerminatorExpr = binaryOperator(
       hasLHS(anyOf(hasDescendant(declRefExpr(to(varDecl(
                        equalsBoundNode(std::string(DestVarDeclName)))))),
                    hasDescendant(declRefExpr(
@@ -665,7 +666,7 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
                   anyOf(hasAncestor(cxxMemberCallExpr().bind(SrcExprName)),
                         expr().bind(SrcExprName)));
 
-  auto AnyOfSrcDecl =
+  const auto AnyOfSrcDecl =
       ignoringImpCasts(anyOf(stringLiteral().bind(SrcExprName),
                              hasDescendant(stringLiteral().bind(SrcExprName)),
                              SrcDecl, hasDescendant(SrcDecl)));
@@ -688,7 +689,7 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
     bool WithIncrease;
   };
 
-  auto MatchDestination = [=](CallContext CC) {
+  const auto MatchDestination = [=](CallContext CC) {
     return hasArgument(*CC.DestinationPos,
                        allOf(AnyOfDestDecl,
                              unless(hasAncestor(compoundStmt(
@@ -696,11 +697,11 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
                              unless(Container)));
   };
 
-  auto MatchSource = [=](CallContext CC) {
+  const auto MatchSource = [=](CallContext CC) {
     return hasArgument(*CC.SourcePos, AnyOfSrcDecl);
   };
 
-  auto MatchGivenLength = [=](CallContext CC) {
+  const auto MatchGivenLength = [=](CallContext CC) {
     return hasArgument(
         CC.LengthPos,
         allOf(
@@ -717,7 +718,7 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
             expr().bind(LengthExprName)));
   };
 
-  auto MatchCall = [=](CallContext CC) {
+  const auto MatchCall = [=](CallContext CC) {
     const std::string CharHandlerFuncName = "::" + CC.Name.str();
 
     // Try to match with 'wchar_t' based function calls.
@@ -730,7 +731,7 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
                  MatchGivenLength(CC));
   };
 
-  auto Match = [=](CallContext CC) {
+  const auto Match = [=](CallContext CC) {
     if (CC.DestinationPos && CC.SourcePos)
       return allOf(MatchCall(CC), MatchDestination(CC), MatchSource(CC));
 
@@ -752,7 +753,7 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
   auto MemcpyS = Match({"memcpy_s", 0, 2, 3, false});
 
   // void *memchr(const void *src, int c, size_t count)
-  auto Memchr = Match({"memchr", std::nullopt, 0, 2, false});
+  const auto Memchr = Match({"memchr", std::nullopt, 0, 2, false});
 
   // void *memmove(void *dest, const void *src, size_t count)
   auto Memmove = Match({"memmove", 0, 1, 2, false});
@@ -770,8 +771,8 @@ void NotNullTerminatedResultCheck::registerMatchers(MatchFinder *Finder) {
   // errno_t strerror_s(char *buffer, size_t bufferSize, int errnum);
   auto StrerrorS = Match({"strerror_s", 0, std::nullopt, 1, false});
 
-  auto AnyOfMatchers = anyOf(Memcpy, MemcpyS, Memmove, MemmoveS, StrncmpRHS,
-                             StrncmpLHS, Strxfrm, StrerrorS);
+  const auto AnyOfMatchers = anyOf(Memcpy, MemcpyS, Memmove, MemmoveS,
+                                   StrncmpRHS, StrncmpLHS, Strxfrm, StrerrorS);
 
   Finder->addMatcher(callExpr(AnyOfMatchers).bind(FunctionExprName), this);
 
diff --git a/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
index c1264d03a9009..14364d1b1c057 100644
--- a/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/OptionalValueConversionCheck.cpp
@@ -51,12 +51,12 @@ OptionalValueConversionCheck::getCheckTraversalKind() const {
 }
 
 void OptionalValueConversionCheck::registerMatchers(MatchFinder *Finder) {
-  auto BindOptionalType = qualType(hasCleanType(
+  const auto BindOptionalType = qualType(hasCleanType(
       qualType(hasDeclaration(namedDecl(
                    matchers::matchesAnyListedRegexName(OptionalTypes))))
           .bind("optional-type")));
 
-  auto EqualsBoundOptionalType =
+  const auto EqualsBoundOptionalType =
       qualType(hasCleanType(equalsBoundNode("optional-type")));
 
   auto OptionalDerefMatcherImpl = callExpr(
@@ -75,7 +75,7 @@ void OptionalValueConversionCheck::registerMatchers(MatchFinder *Finder) {
   auto StdMoveCallMatcher =
       callExpr(argumentCountIs(1), callee(functionDecl(hasName("::std::move"))),
                hasArgument(0, ignoringImpCasts(OptionalDerefMatcherImpl)));
-  auto OptionalDerefMatcher =
+  const auto OptionalDerefMatcher =
       ignoringImpCasts(anyOf(OptionalDerefMatcherImpl, StdMoveCallMatcher));
 
   Finder->addMatcher(
@@ -145,7 +145,7 @@ void OptionalValueConversionCheck::check(
         utils::lexer::getPreviousToken(CallExpr->getExprLoc(),
                                        *Result.SourceManager, getLangOpts())
             .getLocation();
-    auto Diag =
+    const auto Diag =
         diag(CallExpr->getExprLoc(),
              "remove call to %0 to silence this warning", DiagnosticIDs::Note);
     Diag << CallExpr->getMethodDecl()
diff --git a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
index 3c0ced96c05ac..3299b746e118d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
@@ -129,11 +129,12 @@ void ParentVirtualCallCheck::check(const MatchFinder::MatchResult &Result) {
   }
 
   assert(Member->getQualifierLoc().getSourceRange().getBegin().isValid());
-  auto Diag = diag(Member->getQualifierLoc().getSourceRange().getBegin(),
-                   "qualified name '%0' refers to a member overridden "
-                   "in %plural{1:subclass|:subclasses}1; did you mean %2?")
-              << getExprAsString(*Member, *Result.Context)
-              << static_cast<unsigned>(Parents.size()) << ParentsStr;
+  const auto Diag =
+      diag(Member->getQualifierLoc().getSourceRange().getBegin(),
+           "qualified name '%0' refers to a member overridden "
+           "in %plural{1:subclass|:subclasses}1; did you mean %2?")
+      << getExprAsString(*Member, *Result.Context)
+      << static_cast<unsigned>(Parents.size()) << ParentsStr;
 
   // Propose a fix if there's only one parent class...
   if (Parents.size() == 1 &&
diff --git a/clang-tools-extra/clang-tidy/bugprone/RandomGeneratorSeedCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/RandomGeneratorSeedCheck.cpp
index 3e32e9b8a704c..f74eecf714a4b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/RandomGeneratorSeedCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/RandomGeneratorSeedCheck.cpp
@@ -28,12 +28,13 @@ void RandomGeneratorSeedCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void RandomGeneratorSeedCheck::registerMatchers(MatchFinder *Finder) {
-  auto RandomGeneratorEngineDecl = cxxRecordDecl(hasAnyName(
+  const auto RandomGeneratorEngineDecl = cxxRecordDecl(hasAnyName(
       "::std::linear_congruential_engine", "::std::mersenne_twister_engine",
       "::std::subtract_with_carry_engine", "::std::discard_block_engine",
       "::std::independent_bits_engine", "::std::shuffle_order_engine"));
-  auto RandomGeneratorEngineTypeMatcher = hasType(hasUnqualifiedDesugaredType(
-      recordType(hasDeclaration(RandomGeneratorEngineDecl))));
+  const auto RandomGeneratorEngineTypeMatcher =
+      hasType(hasUnqualifiedDesugaredType(
+          recordType(hasDeclaration(RandomGeneratorEngineDecl))));
 
   // std::mt19937 engine;
   // engine.seed();
diff --git a/clang-tools-extra/clang-tidy/bugprone/RawMemoryCallOnNonTrivialTypeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/RawMemoryCallOnNonTrivialTypeCheck.cpp
index e212301047ce2..4b93d963ffdf5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/RawMemoryCallOnNonTrivialTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/RawMemoryCallOnNonTrivialTypeCheck.cpp
@@ -75,8 +75,8 @@ void RawMemoryCallOnNonTrivialTypeCheck::registerMatchers(MatchFinder *Finder) {
   };
   auto IsRecordSizeOf =
       expr(sizeOfExpr(hasArgumentOfType(equalsBoundNode("Record"))));
-  auto ArgChecker = [&](const Matcher<CXXRecordDecl> &RecordConstraint,
-                        const BindableMatcher<Stmt> &SecondArg = expr()) {
+  const auto ArgChecker = [&](const Matcher<CXXRecordDecl> &RecordConstraint,
+                              const BindableMatcher<Stmt> &SecondArg = expr()) {
     return allOf(argumentCountIs(3),
                  hasArgument(0, IsStructPointer(RecordConstraint, true)),
                  hasArgument(1, SecondArg), hasArgument(2, IsRecordSizeOf));
diff --git a/clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
index 705b8e41f9ab7..bbbf420847aa0 100644
--- a/clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/RedundantBranchConditionCheck.cpp
@@ -104,7 +104,8 @@ void RedundantBranchConditionCheck::check(
   if (hasPtrOrReferenceInFunc(Func, CondVar))
     return;
 
-  auto Diag = diag(InnerIf->getBeginLoc(), "redundant condition %0") << CondVar;
+  const auto Diag = diag(InnerIf->getBeginLoc(), "redundant condition %0")
+                    << CondVar;
 
   // For standalone condition variables and for "or" binary operations we simply
   // remove the inner `if`.
diff --git a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
index 62e22450800ea..7cc59c6db4912 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
@@ -140,7 +140,7 @@ getFailureInfoImpl(StringRef Name, bool IsInGlobalNamespace, bool IsMacro,
   using FailureInfo = RenamerClangTidyCheck::FailureInfo;
   if (!Invert) {
     std::optional<FailureInfo> Info;
-    auto AppendFailure = [&](StringRef Kind, std::string &&Fixup) {
+    const auto AppendFailure = [&](StringRef Kind, std::string &&Fixup) {
       if (!Info) {
         Info = FailureInfo{std::string(Kind), std::move(Fixup)};
       } else {
@@ -148,7 +148,7 @@ getFailureInfoImpl(StringRef Name, bool IsInGlobalNamespace, bool IsMacro,
         Info->Fixup = std::move(Fixup);
       }
     };
-    auto InProgressFixup = [&] {
+    const auto InProgressFixup = [&] {
       return llvm::transformOptional(
                  Info,
                  [](const FailureInfo &Info) { return StringRef(Info.Fixup); })
diff --git a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
index 6479ede6bf606..bd45019892034 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SignalHandlerCheck.cpp
@@ -352,8 +352,9 @@ bool SignalHandlerCheck::isLanguageVersionSupported(
 }
 
 void SignalHandlerCheck::registerMatchers(MatchFinder *Finder) {
-  auto SignalFunction = functionDecl(hasAnyName("::signal", "::std::signal"),
-                                     parameterCountIs(2), isStandard());
+  const auto SignalFunction =
+      functionDecl(hasAnyName("::signal", "::std::signal"), parameterCountIs(2),
+                   isStandard());
   auto HandlerExpr =
       declRefExpr(hasDeclaration(functionDecl().bind("handler_decl")),
                   unless(isExpandedFromMacro("SIG_IGN")),
@@ -488,7 +489,7 @@ bool SignalHandlerCheck::checkFunctionCPP14(
 
   bool StmtProblemsFound = false;
   ASTContext &Ctx = FBody->getASTContext();
-  auto Matches =
+  const auto Matches =
       match(decl(forEachDescendant(stmt().bind("stmt"))), *FBody, Ctx);
   for (const auto &Match : Matches) {
     const auto *FoundS = Match.getNodeAs<Stmt>("stmt");
diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp
index 08ff82f57e3c2..cec93c9417947 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SizeofContainerCheck.cpp
@@ -35,7 +35,7 @@ void SizeofContainerCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *SizeOf =
       Result.Nodes.getNodeAs<UnaryExprOrTypeTraitExpr>("sizeof");
 
-  auto Diag =
+  const auto Diag =
       diag(SizeOf->getBeginLoc(), "sizeof() doesn't return the size of the "
                                   "container; did you mean .size()?");
 }
diff --git a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
index 49ba3b83795dd..12b5a5de55618 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -97,7 +97,7 @@ void SizeofExpressionCheck::registerMatchers(MatchFinder *Finder) {
   // Some of the checks should not match in template code to avoid false
   // positives if sizeof is applied on template argument.
 
-  auto LoopCondExpr =
+  const auto LoopCondExpr =
       [](const ast_matchers::internal::Matcher<Stmt> &InnerMatcher) {
         return stmt(anyOf(forStmt(hasCondition(InnerMatcher)),
                           whileStmt(hasCondition(InnerMatcher)),
diff --git a/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
index af478b105fdd1..2735979a2b657 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SmartPtrArrayMismatchCheck.cpp
@@ -54,11 +54,11 @@ void SmartPtrArrayMismatchCheck::registerMatchers(MatchFinder *Finder) {
   // For both shared and unique pointers, we need to find constructor with
   // exactly one parameter that has the pointer type. Other constructors are
   // not applicable for this check.
-  auto FindConstructor =
+  const auto FindConstructor =
       cxxConstructorDecl(ofClass(getSmartPointerClassMatcher()),
                          parameterCountIs(1), isExplicit())
           .bind(ConstructorN);
-  auto FindConstructExpr =
+  const auto FindConstructExpr =
       cxxConstructExpr(
           hasDeclaration(FindConstructor), argumentCountIs(1),
           hasArgument(0,
@@ -81,15 +81,16 @@ void SmartPtrArrayMismatchCheck::check(const MatchFinder::MatchResult &Result) {
   const DeclaratorDecl *VarOrField =
       getConstructedVarOrField(FoundConstructExpr, Ctx);
 
-  auto D = diag(FoundNewExpr->getBeginLoc(),
-                "%0 pointer to non-array is initialized with array")
-           << SmartPointerName;
+  const auto D = diag(FoundNewExpr->getBeginLoc(),
+                      "%0 pointer to non-array is initialized with array")
+                 << SmartPointerName;
   D << FoundNewExpr->getSourceRange();
 
   if (VarOrField) {
-    auto TSTypeLoc = VarOrField->getTypeSourceInfo()
-                         ->getTypeLoc()
-                         .getAsAdjusted<clang::TemplateSpecializationTypeLoc>();
+    const auto TSTypeLoc =
+        VarOrField->getTypeSourceInfo()
+            ->getTypeLoc()
+            .getAsAdjusted<clang::TemplateSpecializationTypeLoc>();
     assert(TSTypeLoc.getNumArgs() >= 1 &&
            "Matched type should have at least 1 template argument.");
 
diff --git a/clang-tools-extra/clang-tidy/bugprone/StdNamespaceModificationCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StdNamespaceModificationCheck.cpp
index 1dff741be3c08..5052d3624e339 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StdNamespaceModificationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StdNamespaceModificationCheck.cpp
@@ -39,17 +39,17 @@ AST_POLYMORPHIC_MATCHER_P(
 namespace clang::tidy::bugprone {
 
 void StdNamespaceModificationCheck::registerMatchers(MatchFinder *Finder) {
-  auto HasStdParent =
+  const auto HasStdParent =
       hasDeclContext(namespaceDecl(hasAnyName("std", "posix"),
                                    unless(hasParent(namespaceDecl())))
                          .bind("nmspc"));
-  auto UserDefinedType = qualType(
+  const auto UserDefinedType = qualType(
       hasUnqualifiedDesugaredType(tagType(unless(hasDeclaration(tagDecl(
           hasAncestor(namespaceDecl(hasAnyName("std", "posix"),
                                     unless(hasParent(namespaceDecl()))))))))));
-  auto HasNoProgramDefinedTemplateArgument = unless(
+  const auto HasNoProgramDefinedTemplateArgument = unless(
       hasAnyTemplateArgumentIncludingPack(refersToType(UserDefinedType)));
-  auto InsideStdClassOrClassTemplateSpecialization = hasDeclContext(
+  const auto InsideStdClassOrClassTemplateSpecialization = hasDeclContext(
       anyOf(cxxRecordDecl(HasStdParent),
             classTemplateSpecializationDecl(
                 HasStdParent, HasNoProgramDefinedTemplateArgument)));
diff --git a/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
index 701c0e56e6f99..3b60bc980169c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp
@@ -140,7 +140,7 @@ void StringIntegerAssignmentCheck::check(
           .isLikelyCharExpression(Argument))
     return;
 
-  auto Diag =
+  const auto Diag =
       diag(Loc, "an integer is interpreted as a character code when assigning "
                 "it to a string; if this is intended, cast the integer to the "
                 "appropriate character type; if you want a string "
diff --git a/clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
index faa07fff5a369..1b56b098f0efe 100644
--- a/clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
@@ -34,22 +34,22 @@ AST_MATCHER(clang::VarDecl, isDirectInitialization) {
 } // namespace
 
 static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
-  auto ConstructionWarning =
+  const auto ConstructionWarning =
       cat("constructing basic_string_view from null is undefined; replace with "
           "the default constructor");
-  auto StaticCastWarning =
+  const auto StaticCastWarning =
       cat("casting to basic_string_view from null is undefined; replace with "
           "the empty string");
-  auto ArgumentConstructionWarning =
+  const auto ArgumentConstructionWarning =
       cat("passing null as basic_string_view is undefined; replace with the "
           "empty string");
-  auto AssignmentWarning =
+  const auto AssignmentWarning =
       cat("assignment to basic_string_view from null is undefined; replace "
           "with the default constructor");
-  auto RelativeComparisonWarning =
+  const auto RelativeComparisonWarning =
       cat("comparing basic_string_view to null is undefined; replace with the "
           "empty string");
-  auto EqualityComparisonWarning =
+  const auto EqualityComparisonWarning =
       cat("comparing basic_string_view to null is undefined; replace with the "
           "emptiness query");
 
@@ -69,7 +69,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
   auto EmptyInitList = initListExpr(initCountIs(0));
 
   // Matches null construction without `basic_string_view` type spelling
-  auto BasicStringViewConstructingFromNullExpr =
+  const auto BasicStringViewConstructingFromNullExpr =
       cxxConstructExpr(
           HasBasicStringViewType, argumentCountIs(1),
           hasAnyArgument(/* `hasArgument` would skip over parens */ anyOf(
@@ -79,34 +79,35 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
           .bind("construct_expr");
 
   // `std::string_view(null_arg_expr)`
-  auto HandleTemporaryCXXFunctionalCastExpr =
+  const auto HandleTemporaryCXXFunctionalCastExpr =
       makeRule(cxxFunctionalCastExpr(hasSourceExpression(
                    BasicStringViewConstructingFromNullExpr)),
                remove(node("null_arg_expr")), ConstructionWarning);
 
   // `std::string_view{null_arg_expr}` and `(std::string_view){null_arg_expr}`
-  auto HandleTemporaryCXXTemporaryObjectExprAndCompoundLiteralExpr = makeRule(
-      cxxTemporaryObjectExpr(cxxConstructExpr(
-          HasBasicStringViewType, argumentCountIs(1),
-          hasAnyArgument(/* `hasArgument` would skip over parens */ anyOf(
-              NullLiteral, NullInitList, EmptyInitList)),
-          has(expr().bind("null_arg_expr")))),
-      remove(node("null_arg_expr")), ConstructionWarning);
+  const auto HandleTemporaryCXXTemporaryObjectExprAndCompoundLiteralExpr =
+      makeRule(
+          cxxTemporaryObjectExpr(cxxConstructExpr(
+              HasBasicStringViewType, argumentCountIs(1),
+              hasAnyArgument(/* `hasArgument` would skip over parens */ anyOf(
+                  NullLiteral, NullInitList, EmptyInitList)),
+              has(expr().bind("null_arg_expr")))),
+          remove(node("null_arg_expr")), ConstructionWarning);
 
   // `(std::string_view) null_arg_expr`
-  auto HandleTemporaryCStyleCastExpr =
+  const auto HandleTemporaryCStyleCastExpr =
       makeRule(cStyleCastExpr(hasSourceExpression(
                    BasicStringViewConstructingFromNullExpr)),
                changeTo(node("null_arg_expr"), cat("{}")), ConstructionWarning);
 
   // `static_cast<std::string_view>(null_arg_expr)`
-  auto HandleTemporaryCXXStaticCastExpr =
+  const auto HandleTemporaryCXXStaticCastExpr =
       makeRule(cxxStaticCastExpr(hasSourceExpression(
                    BasicStringViewConstructingFromNullExpr)),
                changeTo(node("null_arg_expr"), cat("\"\"")), StaticCastWarning);
 
   // `std::string_view sv = null_arg_expr;`
-  auto HandleStackCopyInitialization =
+  const auto HandleStackCopyInitialization =
       makeRule(varDecl(HasBasicStringViewType,
                        hasInitializer(ignoringImpCasts(cxxConstructExpr(
                            BasicStringViewConstructingFromNullExpr,
@@ -115,7 +116,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
                changeTo(node("null_arg_expr"), cat("{}")), ConstructionWarning);
 
   // `std::string_view sv = {null_arg_expr};`
-  auto HandleStackCopyListInitialization =
+  const auto HandleStackCopyListInitialization =
       makeRule(varDecl(HasBasicStringViewType,
                        hasInitializer(cxxConstructExpr(
                            BasicStringViewConstructingFromNullExpr,
@@ -124,7 +125,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
                remove(node("null_arg_expr")), ConstructionWarning);
 
   // `std::string_view sv(null_arg_expr);`
-  auto HandleStackDirectInitialization =
+  const auto HandleStackDirectInitialization =
       makeRule(varDecl(HasBasicStringViewType,
                        hasInitializer(cxxConstructExpr(
                            BasicStringViewConstructingFromNullExpr,
@@ -135,7 +136,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
                ConstructionWarning);
 
   // `std::string_view sv{null_arg_expr};`
-  auto HandleStackDirectListInitialization =
+  const auto HandleStackDirectListInitialization =
       makeRule(varDecl(HasBasicStringViewType,
                        hasInitializer(cxxConstructExpr(
                            BasicStringViewConstructingFromNullExpr,
@@ -144,7 +145,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
                remove(node("null_arg_expr")), ConstructionWarning);
 
   // `struct S { std::string_view sv = null_arg_expr; };`
-  auto HandleFieldInClassCopyInitialization = makeRule(
+  const auto HandleFieldInClassCopyInitialization = makeRule(
       fieldDecl(HasBasicStringViewType,
                 hasInClassInitializer(ignoringImpCasts(
                     cxxConstructExpr(BasicStringViewConstructingFromNullExpr,
@@ -153,7 +154,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
 
   // `struct S { std::string_view sv = {null_arg_expr}; };` and
   // `struct S { std::string_view sv{null_arg_expr}; };`
-  auto HandleFieldInClassCopyListAndDirectListInitialization = makeRule(
+  const auto HandleFieldInClassCopyListAndDirectListInitialization = makeRule(
       fieldDecl(HasBasicStringViewType,
                 hasInClassInitializer(ignoringImpCasts(
                     cxxConstructExpr(BasicStringViewConstructingFromNullExpr,
@@ -161,7 +162,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
       remove(node("null_arg_expr")), ConstructionWarning);
 
   // `class C { std::string_view sv; C() : sv(null_arg_expr) {} };`
-  auto HandleConstructorDirectInitialization =
+  const auto HandleConstructorDirectInitialization =
       makeRule(cxxCtorInitializer(forField(fieldDecl(HasBasicStringViewType)),
                                   withInitializer(cxxConstructExpr(
                                       BasicStringViewConstructingFromNullExpr,
@@ -169,7 +170,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
                remove(node("null_arg_expr")), ConstructionWarning);
 
   // `class C { std::string_view sv; C() : sv{null_arg_expr} {} };`
-  auto HandleConstructorDirectListInitialization =
+  const auto HandleConstructorDirectListInitialization =
       makeRule(cxxCtorInitializer(forField(fieldDecl(HasBasicStringViewType)),
                                   withInitializer(cxxConstructExpr(
                                       BasicStringViewConstructingFromNullExpr,
@@ -177,7 +178,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
                remove(node("null_arg_expr")), ConstructionWarning);
 
   // `void f(std::string_view sv = null_arg_expr);`
-  auto HandleDefaultArgumentCopyInitialization =
+  const auto HandleDefaultArgumentCopyInitialization =
       makeRule(parmVarDecl(HasBasicStringViewType,
                            hasInitializer(ignoringImpCasts(cxxConstructExpr(
                                BasicStringViewConstructingFromNullExpr,
@@ -185,7 +186,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
                changeTo(node("null_arg_expr"), cat("{}")), ConstructionWarning);
 
   // `void f(std::string_view sv = {null_arg_expr});`
-  auto HandleDefaultArgumentCopyListInitialization =
+  const auto HandleDefaultArgumentCopyListInitialization =
       makeRule(parmVarDecl(HasBasicStringViewType,
                            hasInitializer(cxxConstructExpr(
                                BasicStringViewConstructingFromNullExpr,
@@ -193,21 +194,21 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
                remove(node("null_arg_expr")), ConstructionWarning);
 
   // `new std::string_view(null_arg_expr)`
-  auto HandleHeapDirectInitialization = makeRule(
+  const auto HandleHeapDirectInitialization = makeRule(
       cxxNewExpr(has(cxxConstructExpr(BasicStringViewConstructingFromNullExpr,
                                       unless(isListInitialization()))),
                  unless(isArray()), unless(hasAnyPlacementArg(anything()))),
       remove(node("null_arg_expr")), ConstructionWarning);
 
   // `new std::string_view{null_arg_expr}`
-  auto HandleHeapDirectListInitialization = makeRule(
+  const auto HandleHeapDirectListInitialization = makeRule(
       cxxNewExpr(has(cxxConstructExpr(BasicStringViewConstructingFromNullExpr,
                                       isListInitialization())),
                  unless(isArray()), unless(hasAnyPlacementArg(anything()))),
       remove(node("null_arg_expr")), ConstructionWarning);
 
   // `function(null_arg_expr)`
-  auto HandleFunctionArgumentInitialization =
+  const auto HandleFunctionArgumentInitialization =
       makeRule(callExpr(hasAnyArgument(ignoringImpCasts(
                             BasicStringViewConstructingFromNullExpr)),
                         unless(cxxOperatorCallExpr())),
@@ -215,21 +216,21 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
                ArgumentConstructionWarning);
 
   // `sv = null_arg_expr`
-  auto HandleAssignment = makeRule(
+  const auto HandleAssignment = makeRule(
       cxxOperatorCallExpr(hasOverloadedOperatorName("="),
                           hasRHS(materializeTemporaryExpr(
                               has(BasicStringViewConstructingFromNullExpr)))),
       changeTo(node("construct_expr"), cat("{}")), AssignmentWarning);
 
   // `sv < null_arg_expr`
-  auto HandleRelativeComparison = makeRule(
+  const auto HandleRelativeComparison = makeRule(
       cxxOperatorCallExpr(hasAnyOverloadedOperatorName("<", "<=", ">", ">="),
                           hasEitherOperand(ignoringImpCasts(
                               BasicStringViewConstructingFromNullExpr))),
       changeTo(node("construct_expr"), cat("\"\"")), RelativeComparisonWarning);
 
   // `sv == null_arg_expr`
-  auto HandleEmptyEqualityComparison = makeRule(
+  const auto HandleEmptyEqualityComparison = makeRule(
       cxxOperatorCallExpr(
           hasOverloadedOperatorName("=="),
           hasOperands(ignoringImpCasts(BasicStringViewConstructingFromNullExpr),
@@ -240,7 +241,7 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
       EqualityComparisonWarning);
 
   // `sv != null_arg_expr`
-  auto HandleNonEmptyEqualityComparison = makeRule(
+  const auto HandleNonEmptyEqualityComparison = makeRule(
       cxxOperatorCallExpr(
           hasOverloadedOperatorName("!="),
           hasOperands(ignoringImpCasts(BasicStringViewConstructingFromNullExpr),
@@ -251,13 +252,13 @@ static RewriteRuleWith<std::string> stringviewNullptrCheckImpl() {
       EqualityComparisonWarning);
 
   // `return null_arg_expr;`
-  auto HandleReturnStatement = makeRule(
+  const auto HandleReturnStatement = makeRule(
       returnStmt(hasReturnValue(
           ignoringImpCasts(BasicStringViewConstructingFromNullExpr))),
       changeTo(node("construct_expr"), cat("{}")), ConstructionWarning);
 
   // `T(null_arg_expr)`
-  auto HandleConstructorInvocation =
+  const auto HandleConstructorInvocation =
       makeRule(cxxConstructExpr(
                    hasAnyArgument(/* `hasArgument` would skip over parens */
                                   ignoringImpCasts(
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
index f28bdbeb6db84..cea813b18230f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousEnumUsageCheck.cpp
@@ -74,7 +74,7 @@ static bool isNonPowerOf2NorNullLiteral(const EnumConstantDecl *EnumConst) {
 }
 
 static bool isMaxValAllBitSetLiteral(const EnumDecl *EnumDec) {
-  auto EnumConst = std::max_element(
+  const auto EnumConst = std::max_element(
       EnumDec->enumerator_begin(), EnumDec->enumerator_end(),
       [](const EnumConstantDecl *E1, const EnumConstantDecl *E2) {
         return E1->getInitVal() < E2->getInitVal();
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
index 63ba2edf2015a..703d69a093f6f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMemsetUsageCheck.cpp
@@ -20,7 +20,7 @@ namespace clang::tidy::bugprone {
 void SuspiciousMemsetUsageCheck::registerMatchers(MatchFinder *Finder) {
   // Match the standard memset:
   // void *memset(void *buffer, int fill_char, size_t byte_count);
-  auto MemsetDecl =
+  const auto MemsetDecl =
       functionDecl(hasName("::memset"), parameterCountIs(3),
                    hasParameter(0, hasType(pointerType(pointee(voidType())))),
                    hasParameter(1, hasType(isInteger())),
@@ -61,7 +61,7 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) {
     // integer zero was intended.
 
     const SourceRange CharRange = CharZeroFill->getSourceRange();
-    auto Diag =
+    const auto Diag =
         diag(CharZeroFill->getBeginLoc(), "memset fill value is char '0', "
                                           "potentially mistaken for int 0");
 
@@ -114,8 +114,8 @@ void SuspiciousMemsetUsageCheck::check(const MatchFinder::MatchResult &Result) {
     // `byte_count` is known to be zero at compile time, and `fill_char` is
     // either not known or known to be a positive integer. Emit a warning
     // and fix-its to swap the arguments.
-    auto D = diag(Call->getBeginLoc(),
-                  "memset of size zero, potentially swapped arguments");
+    const auto D = diag(Call->getBeginLoc(),
+                        "memset of size zero, potentially swapped arguments");
     const StringRef RHSString =
         tooling::fixit::getText(*ByteCount, *Result.Context);
     const StringRef LHSString =
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
index 4f0d819d2147b..1ada9e5eba86c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousMissingCommaCheck.cpp
@@ -20,7 +20,7 @@ static bool isConcatenatedLiteralsOnPurpose(ASTContext *Ctx,
   //    i.e.:  const char* Array[] = { ("a" "b" "c"), "d", [...] };
 
   const TraversalKindScope RAII(*Ctx, TK_AsIs);
-  auto Parents = Ctx->getParents(*Lit);
+  const auto Parents = Ctx->getParents(*Lit);
   if (Parents.size() == 1 && Parents[0].get<ParenExpr>() != nullptr)
     return true;
 
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp
index bf31218131d5e..03fc3c56f428c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp
@@ -104,13 +104,13 @@ namespace clang::tidy::bugprone {
 
 void SuspiciousReallocUsageCheck::registerMatchers(MatchFinder *Finder) {
   // void *realloc(void *ptr, size_t size);
-  auto ReallocDecl =
+  const auto ReallocDecl =
       functionDecl(hasName("::realloc"), parameterCountIs(2),
                    hasParameter(0, hasType(pointerType(pointee(voidType())))),
                    hasParameter(1, hasType(isInteger())))
           .bind("realloc");
 
-  auto ReallocCall =
+  const auto ReallocCall =
       callExpr(callee(ReallocDecl), hasArgument(0, expr().bind("ptr_input")),
                hasAncestor(functionDecl().bind("parent_function")))
           .bind("call");
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
index 9d37fc1e8728e..84ba50d9b70d9 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
@@ -39,7 +39,7 @@ void SuspiciousSemicolonCheck::check(const MatchFinder::MatchResult &Result) {
   ASTContext &Ctxt = *Result.Context;
   auto Token = utils::lexer::getPreviousToken(LocStart, Ctxt.getSourceManager(),
                                               Ctxt.getLangOpts());
-  auto &SM = *Result.SourceManager;
+  const auto &SM = *Result.SourceManager;
   const unsigned SemicolonLine = SM.getSpellingLineNumber(LocStart);
 
   const auto *Statement = Result.Nodes.getNodeAs<Stmt>("stmt");
diff --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp
index 342a6e8480fa7..660b022714682 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousStringviewDataUsageCheck.cpp
@@ -43,16 +43,16 @@ SuspiciousStringviewDataUsageCheck::getCheckTraversalKind() const {
 }
 
 void SuspiciousStringviewDataUsageCheck::registerMatchers(MatchFinder *Finder) {
-  auto AncestorCall = anyOf(
+  const auto AncestorCall = anyOf(
       cxxConstructExpr(), callExpr(unless(cxxOperatorCallExpr())), lambdaExpr(),
       initListExpr(
           hasType(qualType(hasCanonicalType(hasDeclaration(recordDecl()))))));
 
-  auto DataMethod = cxxMethodDecl(
+  const auto DataMethod = cxxMethodDecl(
       hasName("data"),
       ofClass(matchers::matchesAnyListedRegexName(StringViewTypes)));
 
-  auto SizeCall = cxxMemberCallExpr(
+  const auto SizeCall = cxxMemberCallExpr(
       callee(cxxMethodDecl(hasAnyName("size", "length"))),
       on(ignoringParenImpCasts(
           matchers::isStatementIdenticalToBoundNode("self"))));
diff --git a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
index 3e43a1802c43f..b19019b9fcb06 100644
--- a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
@@ -101,18 +101,20 @@ void TaggedUnionMemberCountCheck::storeOptions(
 }
 
 void TaggedUnionMemberCountCheck::registerMatchers(MatchFinder *Finder) {
-  auto NotFromSystemHeaderOrStdNamespace =
+  const auto NotFromSystemHeaderOrStdNamespace =
       unless(anyOf(isExpansionInSystemHeader(), isInStdNamespace()));
 
-  auto UnionField =
+  const auto UnionField =
       fieldDecl(hasType(qualType(hasCanonicalType(recordType(hasDeclaration(
           recordDecl(isUnion(), NotFromSystemHeaderOrStdNamespace)))))));
 
-  auto EnumField = fieldDecl(hasType(qualType(hasCanonicalType(
+  const auto EnumField = fieldDecl(hasType(qualType(hasCanonicalType(
       enumType(hasDeclaration(enumDecl(NotFromSystemHeaderOrStdNamespace)))))));
 
-  auto HasOneUnionField = fieldCountOfKindIsOne(UnionField, UnionMatchBindName);
-  auto HasOneEnumField = fieldCountOfKindIsOne(EnumField, TagMatchBindName);
+  const auto HasOneUnionField =
+      fieldCountOfKindIsOne(UnionField, UnionMatchBindName);
+  const auto HasOneEnumField =
+      fieldCountOfKindIsOne(EnumField, TagMatchBindName);
 
   Finder->addMatcher(recordDecl(anyOf(isStruct(), isClass()), HasOneUnionField,
                                 HasOneEnumField, unless(isImplicit()))
diff --git a/clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp
index c8ce77ed6a4ab..199ff80fc7026 100644
--- a/clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/TerminatingContinueCheck.cpp
@@ -35,7 +35,7 @@ void TerminatingContinueCheck::registerMatchers(MatchFinder *Finder) {
 void TerminatingContinueCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *ContStmt = Result.Nodes.getNodeAs<ContinueStmt>("continue");
 
-  auto Diag =
+  const auto Diag =
       diag(ContStmt->getBeginLoc(),
            "'continue' in loop with false condition is equivalent to 'break'")
       << tooling::fixit::createReplacement(*ContStmt, "break");
diff --git a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
index cfb9e9652a2d9..9d3ae1fe37a47 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp
@@ -27,8 +27,9 @@ static constexpr StringRef FuncID = "fun";
 void UncheckedOptionalAccessCheck::registerMatchers(MatchFinder *Finder) {
   using namespace ast_matchers;
 
-  auto HasOptionalCallDescendant = hasDescendant(callExpr(callee(cxxMethodDecl(
-      ofClass(UncheckedOptionalAccessModel::optionalClassDecl())))));
+  const auto HasOptionalCallDescendant =
+      hasDescendant(callExpr(callee(cxxMethodDecl(
+          ofClass(UncheckedOptionalAccessModel::optionalClassDecl())))));
   Finder->addMatcher(
       decl(anyOf(functionDecl(unless(isExpansionInSystemHeader()),
                               // FIXME: Remove the filter below when lambdas are
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp
index 340b136700c5f..2529a2567b98d 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnhandledExceptionAtNewCheck.cpp
@@ -52,12 +52,13 @@ void UnhandledExceptionAtNewCheck::registerMatchers(MatchFinder *Finder) {
   auto BadAllocReferenceType = referenceType(pointee(BadAllocType));
   auto ExceptionReferenceType = referenceType(pointee(ExceptionType));
 
-  auto CatchBadAllocType =
+  const auto CatchBadAllocType =
       qualType(hasCanonicalType(anyOf(BadAllocType, BadAllocReferenceType,
                                       ExceptionType, ExceptionReferenceType)));
-  auto BadAllocCatchingTryBlock = cxxTryStmt(hasHandlerFor(CatchBadAllocType));
+  const auto BadAllocCatchingTryBlock =
+      cxxTryStmt(hasHandlerFor(CatchBadAllocType));
 
-  auto FunctionMayNotThrow = functionDecl(isNoThrow());
+  const auto FunctionMayNotThrow = functionDecl(isNoThrow());
 
   Finder->addMatcher(cxxNewExpr(mayThrow(),
                                 unless(hasAncestor(BadAllocCatchingTryBlock)),
diff --git a/clang-tools-extra/clang-tidy/bugprone/UniquePtrArrayMismatchCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UniquePtrArrayMismatchCheck.cpp
index 34c2c6dd4642d..8cf3cb4eb52ba 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UniquePtrArrayMismatchCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UniquePtrArrayMismatchCheck.cpp
@@ -18,7 +18,7 @@ UniquePtrArrayMismatchCheck::UniquePtrArrayMismatchCheck(
 
 UniquePtrArrayMismatchCheck::SmartPtrClassMatcher
 UniquePtrArrayMismatchCheck::getSmartPointerClassMatcher() const {
-  auto DeleterDecl = classTemplateSpecializationDecl(
+  const auto DeleterDecl = classTemplateSpecializationDecl(
       hasName("::std::default_delete"), templateArgumentCountIs(1),
       hasTemplateArgument(0, templateArgument(refersToType(
                                  qualType(equalsBoundNode(PointerTypeN))))));
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
index dc749924fb700..7a703d3da380c 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnsafeFunctionsCheck.cpp
@@ -199,7 +199,7 @@ void UnsafeFunctionsCheck::registerMatchers(MatchFinder *Finder) {
   if (ReportDefaultFunctions) {
     if (getLangOpts().C11) {
       // Matching functions with safe replacements only in Annex K.
-      auto FunctionNamesWithAnnexKReplacementMatcher = hasAnyName(
+      const auto FunctionNamesWithAnnexKReplacementMatcher = hasAnyName(
           "::bsearch", "::ctime", "::fopen", "::fprintf", "::freopen",
           "::fscanf", "::fwprintf", "::fwscanf", "::getenv", "::gmtime",
           "::localtime", "::mbsrtowcs", "::mbstowcs", "::memcpy", "::memmove",
@@ -220,7 +220,7 @@ void UnsafeFunctionsCheck::registerMatchers(MatchFinder *Finder) {
     }
 
     // Matching functions with replacements without Annex K.
-    auto FunctionNamesMatcher =
+    const auto FunctionNamesMatcher =
         hasAnyName("::asctime", "asctime_r", "::gets", "::rewind", "::setbuf");
     Finder->addMatcher(
         declRefExpr(
@@ -230,7 +230,7 @@ void UnsafeFunctionsCheck::registerMatchers(MatchFinder *Finder) {
 
     if (ReportMoreUnsafeFunctions) {
       // Matching functions with replacements without Annex K, at user request.
-      auto AdditionalFunctionNamesMatcher =
+      const auto AdditionalFunctionNamesMatcher =
           hasAnyName("::bcmp", "::bcopy", "::bzero", "::getpw", "::vfork");
       Finder->addMatcher(
           declRefExpr(to(functionDecl(AdditionalFunctionNamesMatcher)
@@ -247,7 +247,7 @@ void UnsafeFunctionsCheck::registerMatchers(MatchFinder *Finder) {
     for (const auto &Entry : CustomFunctions)
       FunctionNames.emplace_back(Entry.Name);
 
-    auto CustomFunctionsMatcher =
+    const auto CustomFunctionsMatcher =
         matchers::matchesAnyListedRegexName(FunctionNames);
 
     Finder->addMatcher(declRefExpr(to(functionDecl(CustomFunctionsMatcher)
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
index 6502fc9bfb89e..0a9818d3936b0 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnusedRaiiCheck.cpp
@@ -72,8 +72,9 @@ void UnusedRaiiCheck::check(const MatchFinder::MatchResult &Result) {
     return;
 
   // Emit a warning.
-  auto D = diag(E->getBeginLoc(), "object destroyed immediately after "
-                                  "creation; did you mean to name the object?");
+  const auto D =
+      diag(E->getBeginLoc(), "object destroyed immediately after "
+                             "creation; did you mean to name the object?");
 
   if (const auto *Node = dyn_cast<CXXConstructExpr>(E))
     reportDiagnostic(D, Node, Node->getParenOrBraceRange(),
diff --git a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
index 7aee725cae434..91719a1959796 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
@@ -184,9 +184,9 @@ void UnusedReturnValueCheck::registerMatchers(MatchFinder *Finder) {
                                  CheckedReturnTypes)))))))))
           .bind("match"));
 
-  auto CheckCastToVoid =
+  const auto CheckCastToVoid =
       AllowCastToVoid ? castExpr(unless(hasCastKind(CK_ToVoid))) : castExpr();
-  auto MatchedCallExpr = expr(
+  const auto MatchedCallExpr = expr(
       anyOf(MatchedDirectCallExpr,
             explicitCastExpr(unless(cxxFunctionalCastExpr()), CheckCastToVoid,
                              hasSourceExpression(MatchedDirectCallExpr))));
diff --git a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
index a31dd1e5dbdcd..bd842bc8afa53 100644
--- a/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -194,7 +194,7 @@ UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr *MovingCall,
   CFG::BuildOptions Options;
   Options.AddImplicitDtors = true;
   Options.AddTemporaryDtors = true;
-  std::unique_ptr<CFG> TheCFG =
+  const std::unique_ptr<CFG> TheCFG =
       CFG::buildCFG(nullptr, CodeBlock, Context, Options);
   if (!TheCFG)
     return std::nullopt;
@@ -352,8 +352,8 @@ void UseAfterMoveFinder::getDeclRefs(
     if (!S)
       continue;
 
-    auto AddDeclRefs = [this, Block,
-                        DeclRefs](const ArrayRef<BoundNodes> Matches) {
+    const auto AddDeclRefs = [this, Block,
+                              DeclRefs](const ArrayRef<BoundNodes> Matches) {
       for (const auto &Match : Matches) {
         const auto *DeclRef = Match.getNodeAs<DeclRefExpr>("declref");
         const auto *Operator = Match.getNodeAs<CXXOperatorCallExpr>("operator");
@@ -366,9 +366,10 @@ void UseAfterMoveFinder::getDeclRefs(
       }
     };
 
-    auto DeclRefMatcher = declRefExpr(hasDeclaration(equalsNode(MovedVariable)),
-                                      unless(inDecltypeOrTemplateArg()))
-                              .bind("declref");
+    const auto DeclRefMatcher =
+        declRefExpr(hasDeclaration(equalsNode(MovedVariable)),
+                    unless(inDecltypeOrTemplateArg()))
+            .bind("declref");
 
     AddDeclRefs(match(traverse(TK_AsIs, findAll(DeclRefMatcher)), *S->getStmt(),
                       *Context));
@@ -481,11 +482,12 @@ void UseAfterMoveCheck::registerMatchers(MatchFinder *Finder) {
   // bool to tell callers whether it moved. Ignore std::move inside
   // try_emplace to avoid false positives as we don't track uses of
   // the bool.
-  auto TryEmplaceMatcher =
+  const auto TryEmplaceMatcher =
       cxxMemberCallExpr(callee(cxxMethodDecl(hasName("try_emplace"))));
-  auto Arg = declRefExpr().bind("arg");
-  auto IsMemberCallee = callee(functionDecl(unless(isStaticStorageClass())));
-  auto CallMoveMatcher =
+  const auto Arg = declRefExpr().bind("arg");
+  const auto IsMemberCallee =
+      callee(functionDecl(unless(isStaticStorageClass())));
+  const auto CallMoveMatcher =
       callExpr(callee(functionDecl(getNameMatcher(InvalidationFunctions))
                           .bind("move-decl")),
                anyOf(cxxMemberCallExpr(IsMemberCallee, on(Arg)),
diff --git a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
index 0fd965f88e0d5..67a44d155bd2b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/VirtualNearMissCheck.cpp
@@ -193,7 +193,7 @@ bool VirtualNearMissCheck::isPossibleToBeOverridden(
 bool VirtualNearMissCheck::isOverriddenByDerivedClass(
     const CXXMethodDecl *BaseMD, const CXXRecordDecl *DerivedRD) {
   const std::pair Key(BaseMD, DerivedRD);
-  auto Iter = OverriddenMap.find(Key);
+  const auto Iter = OverriddenMap.find(Key);
   if (Iter != OverriddenMap.end())
     return Iter->second;
 
@@ -244,12 +244,12 @@ void VirtualNearMissCheck::check(const MatchFinder::MatchResult &Result) {
         if (EditDistance > 0 && EditDistance <= EditDistanceThreshold) {
           if (checkOverrideWithoutName(Context, BaseMD, DerivedMD)) {
             // A "virtual near miss" is found.
-            auto Range = CharSourceRange::getTokenRange(
+            const auto Range = CharSourceRange::getTokenRange(
                 SourceRange(DerivedMD->getLocation()));
 
             const bool ApplyFix = !BaseMD->isTemplateInstantiation() &&
                                   !DerivedMD->isTemplateInstantiation();
-            auto Diag =
+            const auto Diag =
                 diag(DerivedMD->getBeginLoc(),
                      "method '%0' has a similar name and the same signature as "
                      "virtual method '%1'; did you mean to override it?")
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp
index 4fb0029cc4323..a8b2e24f13c8f 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidGotoCheck.cpp
@@ -38,8 +38,8 @@ void AvoidGotoCheck::registerMatchers(MatchFinder *Finder) {
 
   // Check if the 'goto' is used for control flow other than jumping
   // out of a nested loop.
-  auto Loop = mapAnyOf(forStmt, cxxForRangeStmt, whileStmt, doStmt);
-  auto NestedLoop = Loop.with(hasAncestor(Loop));
+  const auto Loop = mapAnyOf(forStmt, cxxForRangeStmt, whileStmt, doStmt);
+  const auto NestedLoop = Loop.with(hasAncestor(Loop));
 
   const ast_matchers::internal::Matcher<GotoStmt> Anything = anything();
 
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
index 2c0baa5716954..b873ef8ab266e 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
@@ -24,11 +24,11 @@ void AvoidNonConstGlobalVariablesCheck::registerMatchers(MatchFinder *Finder) {
   auto NamespaceMatcher = AllowInternalLinkage
                               ? namespaceDecl(unless(isAnonymous()))
                               : namespaceDecl();
-  auto GlobalContext =
+  const auto GlobalContext =
       varDecl(hasGlobalStorage(),
               hasDeclContext(anyOf(NamespaceMatcher, translationUnitDecl())));
 
-  auto GlobalVariable = varDecl(
+  const auto GlobalVariable = varDecl(
       GlobalContext,
       AllowInternalLinkage ? varDecl(unless(isStaticStorageClass()))
                            : varDecl(),
@@ -39,11 +39,11 @@ void AvoidNonConstGlobalVariablesCheck::registerMatchers(MatchFinder *Finder) {
           hasType(referenceType())))); // References can't be changed, only the
                                        // data they reference can be changed.
 
-  auto GlobalReferenceToNonConst =
+  const auto GlobalReferenceToNonConst =
       varDecl(GlobalContext, hasType(referenceType()),
               unless(hasType(references(qualType(isConstQualified())))));
 
-  auto GlobalPointerToNonConst = varDecl(
+  const auto GlobalPointerToNonConst = varDecl(
       GlobalContext, hasType(pointerType(pointee(unless(isConstQualified())))));
 
   Finder->addMatcher(GlobalVariable.bind("non-const_variable"), this);
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
index 93b5b96926865..351eb7048670b 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -103,7 +103,7 @@ void InitVariablesCheck::check(const MatchFinder::MatchResult &Result) {
   }
 
   if (InitializationString) {
-    auto Diagnostic =
+    const auto Diagnostic =
         diag(MatchedDecl->getLocation(), "variable %0 is not initialized")
         << MatchedDecl;
     if (*InitializationString != nullptr)
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
index e1636e40507ea..4b56b6023df08 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MisleadingCaptureDefaultByValueCheck.cpp
@@ -48,7 +48,7 @@ static std::string createReplacementText(const LambdaExpr *Lambda) {
   std::string Replacement;
   llvm::raw_string_ostream Stream(Replacement);
 
-  auto AppendName = [&](llvm::StringRef Name) {
+  const auto AppendName = [&](llvm::StringRef Name) {
     if (!Replacement.empty())
       Stream << ", ";
     if (Lambda->getCaptureDefault() == LCD_ByRef && Name != "this")
@@ -81,10 +81,10 @@ void MisleadingCaptureDefaultByValueCheck::check(
     const bool IsThisImplicitlyCaptured = std::any_of(
         Lambda->implicit_capture_begin(), Lambda->implicit_capture_end(),
         [](const LambdaCapture &Capture) { return Capture.capturesThis(); });
-    auto Diag = diag(Lambda->getCaptureDefaultLoc(),
-                     "lambdas that %select{|implicitly }0capture 'this' "
-                     "should not specify a by-value capture default")
-                << IsThisImplicitlyCaptured;
+    const auto Diag = diag(Lambda->getCaptureDefaultLoc(),
+                           "lambdas that %select{|implicitly }0capture 'this' "
+                           "should not specify a by-value capture default")
+                      << IsThisImplicitlyCaptured;
 
     const std::string ReplacementText = createReplacementText(Lambda);
     const SourceLocation DefaultCaptureEnd =
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
index d1d81d510c8fb..d85e957760d71 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
@@ -110,9 +110,9 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
       hasParent(lambdaExpr(forCallable(equalsBoundNode("func")),
                            anyOf(CapturedInCaptureList, CapturedInBody)))));
 
-  auto ToParam = hasAnyParameter(parmVarDecl(equalsBoundNode("param")));
+  const auto ToParam = hasAnyParameter(parmVarDecl(equalsBoundNode("param")));
 
-  auto ForwardCallMatcher = callExpr(
+  const auto ForwardCallMatcher = callExpr(
       callExpr().bind("call"), argumentCountIs(1),
       hasArgument(0, declRefExpr(to(varDecl().bind("var")))),
       forCallable(
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
index ee3a45c171e32..198ca031b8877 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
@@ -23,7 +23,7 @@ void NoSuspendWithLockCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void NoSuspendWithLockCheck::registerMatchers(MatchFinder *Finder) {
-  auto LockType = templateSpecializationType(
+  const auto LockType = templateSpecializationType(
       hasDeclaration(namedDecl(matchers::matchesAnyListedRegexName(
           utils::options::parseStringList(LockGuards)))));
 
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
index f4e89470a80da..161e17c47b1f5 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
@@ -155,7 +155,7 @@ void OwningMemoryCheck::registerMatchers(MatchFinder *Finder) {
                              .bind("bad_owner_creation_parameter"))),
                      this);
 
-  auto IsNotInSubLambda = stmt(
+  const auto IsNotInSubLambda = stmt(
       hasAncestor(
           stmt(anyOf(equalsBoundNode("body"), lambdaExpr())).bind("scope")),
       hasAncestor(stmt(equalsBoundNode("scope"), equalsBoundNode("body"))));
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
index ab34eb805aad9..01d3ee002c823 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -67,7 +67,7 @@ static bool canAdvanceAssignment(AssignedLevel Level) {
 static void updateAssignmentLevel(
     const FieldDecl *Field, const Expr *Init, const CXXConstructorDecl *Ctor,
     llvm::DenseMap<const FieldDecl *, AssignedLevel> &AssignedFields) {
-  auto It = AssignedFields.try_emplace(Field, AssignedLevel::None).first;
+  const auto It = AssignedFields.try_emplace(Field, AssignedLevel::None).first;
 
   if (!canAdvanceAssignment(It->second))
     // fast path for already decided field.
@@ -275,9 +275,10 @@ void PreferMemberInitializerCheck::check(
     else
       InvalidFix = true;
 
-    auto Diag = diag(S->getBeginLoc(), "%0 should be initialized in a member"
-                                       " initializer of the constructor")
-                << Field;
+    const auto Diag =
+        diag(S->getBeginLoc(), "%0 should be initialized in a member"
+                               " initializer of the constructor")
+        << Field;
     if (InvalidFix)
       continue;
     const StringRef NewInit = Lexer::getSourceText(
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp
index 73f43d3cd3b1a..f8a952a41f544 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsAvoidUncheckedContainerAccessCheck.cpp
@@ -153,11 +153,12 @@ void ProBoundsAvoidUncheckedContainerAccessCheck::check(
           MatchedExpr->getDirectCallee()->getNumParams() == 0;
 
       if (EmptySubscript) {
-        auto D = diag(MatchedExpr->getCallee()->getBeginLoc(),
-                      "possibly unsafe 'operator[]'%select{, use safe "
-                      "function '%1() instead|}0")
-                 << FixFunctionEmptyArgs.empty() << FixFunctionEmptyArgs.str()
-                 << MatchedExpr->getCallee()->getSourceRange();
+        const auto D = diag(MatchedExpr->getCallee()->getBeginLoc(),
+                            "possibly unsafe 'operator[]'%select{, use safe "
+                            "function '%1() instead|}0")
+                       << FixFunctionEmptyArgs.empty()
+                       << FixFunctionEmptyArgs.str()
+                       << MatchedExpr->getCallee()->getSourceRange();
         if (!FixFunctionEmptyArgs.empty()) {
           D << FixItHint::CreateInsertion(OCE->getArg(0)->getBeginLoc(),
                                           FixFunctionEmptyArgs.str() + "(")
@@ -219,11 +220,12 @@ void ProBoundsAvoidUncheckedContainerAccessCheck::check(
       // Since C++23, the subscript operator may also be called without an
       // argument, which makes the following distinction necessary
       if (EmptySubscript) {
-        auto D = diag(MatchedExpr->getCallee()->getBeginLoc(),
-                      "possibly unsafe 'operator[]'%select{, use safe "
-                      "function '%1()' instead|}0")
-                 << FixFunctionEmptyArgs.empty() << FixFunctionEmptyArgs.str()
-                 << Callee->getSourceRange();
+        const auto D = diag(MatchedExpr->getCallee()->getBeginLoc(),
+                            "possibly unsafe 'operator[]'%select{, use safe "
+                            "function '%1()' instead|}0")
+                       << FixFunctionEmptyArgs.empty()
+                       << FixFunctionEmptyArgs.str()
+                       << Callee->getSourceRange();
 
         if (!FixFunctionEmptyArgs.empty()) {
           D << FixItHint::CreateInsertion(MatchedExpr->getBeginLoc(),
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
index 82fc9f253ac1c..5b478b3cb8135 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -80,9 +80,9 @@ void ProBoundsConstantArrayIndexCheck::check(
           cast<CXXOperatorCallExpr>(Matched)->getArg(0)->getSourceRange();
     const SourceRange IndexRange = IndexExpr->getSourceRange();
 
-    auto Diag = diag(Matched->getExprLoc(),
-                     "do not use array subscript when the index is "
-                     "not an integer constant expression");
+    const auto Diag = diag(Matched->getExprLoc(),
+                           "do not use array subscript when the index is "
+                           "not an integer constant expression");
     if (!GslHeader.empty()) {
       Diag << FixItHint::CreateInsertion(BaseRange.getBegin(), "gsl::at(")
            << FixItHint::CreateReplacement(
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
index fcd9c6d37d99f..d9af322455754 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeCstyleCastCheck.cpp
@@ -64,7 +64,7 @@ void ProTypeCstyleCastCheck::check(const MatchFinder::MatchResult &Result) {
               MatchedCast->getRParenLoc().getLocWithOffset(-1)),
           *Result.SourceManager, getLangOpts());
 
-      auto DiagBuilder = diag(
+      const auto DiagBuilder = diag(
           MatchedCast->getBeginLoc(),
           "do not use C-style cast to downcast from a base to a derived class; "
           "use dynamic_cast instead");
@@ -79,7 +79,7 @@ void ProTypeCstyleCastCheck::check(const MatchFinder::MatchResult &Result) {
                                        *Result.SourceManager, getLangOpts()),
             ")");
       }
-      auto ParenRange = CharSourceRange::getTokenRange(
+      const auto ParenRange = CharSourceRange::getTokenRange(
           MatchedCast->getLParenLoc(), MatchedCast->getRParenLoc());
       DiagBuilder << FixItHint::CreateReplacement(ParenRange, CastText);
     } else {
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
index 5306690e22eeb..db4d050ab95fa 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -78,7 +78,7 @@ removeFieldInitialized(const FieldDecl *M,
 static void
 removeFieldsInitializedInBody(const Stmt &Stmt, ASTContext &Context,
                               SmallPtrSetImpl<const FieldDecl *> &FieldDecls) {
-  auto Matches =
+  const auto Matches =
       match(findAll(binaryOperator(
                 hasOperatorName("="),
                 hasLHS(memberExpr(member(fieldDecl().bind("fieldDecl")))))),
@@ -318,7 +318,7 @@ void ProTypeMemberInitCheck::registerMatchers(MatchFinder *Finder) {
           .bind("record"),
       this);
 
-  auto HasDefaultConstructor = hasInitializer(
+  const auto HasDefaultConstructor = hasInitializer(
       cxxConstructExpr(unless(requiresZeroInitialization()),
                        hasDeclaration(cxxConstructorDecl(
                            isDefaultConstructor(), unless(isUserProvided())))));
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
index d5ff4af84b0b7..222a9321fa5d6 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -69,8 +69,8 @@ AST_MATCHER(QualType, isVAList) {
   const QualType Desugar = Node.getDesugaredType(Context);
   const QualType NodeTy = Node.getUnqualifiedType();
 
-  auto CheckVaList = [](QualType NodeTy, QualType Expected,
-                        const ASTContext &Context) {
+  const auto CheckVaList = [](QualType NodeTy, QualType Expected,
+                              const ASTContext &Context) {
     if (NodeTy == Expected)
       return true;
     QualType Desugar = NodeTy;
@@ -159,7 +159,7 @@ static bool hasSingleVariadicArgumentWithValue(const CallExpr *C, uint64_t I) {
   if (!FDecl)
     return false;
 
-  auto N = FDecl->getNumParams(); // Number of parameters without '...'
+  const auto N = FDecl->getNumParams(); // Number of parameters without '...'
   if (C->getNumArgs() != N + 1)
     return false; // more/less than one argument passed to '...'
 
@@ -185,7 +185,7 @@ void ProTypeVarargCheck::check(const MatchFinder::MatchResult &Result) {
     diag(Matched->getExprLoc(), VaArgWarningMessage);
 
   if (const auto *Matched = Result.Nodes.getNodeAs<VarDecl>("va_list")) {
-    auto SR = Matched->getSourceRange();
+    const auto SR = Matched->getSourceRange();
     if (SR.isInvalid())
       return; // some implicitly generated builtins take va_list
     diag(SR.getBegin(), "do not declare variables of type va_list; "
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
index a5fdd211efd22..cd0f3fa229fec 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
@@ -36,7 +36,7 @@ AST_MATCHER_P2(Stmt, argumentOf, bool, AllowPartialMove, StatementMatcher,
 } // namespace
 
 void RvalueReferenceParamNotMovedCheck::registerMatchers(MatchFinder *Finder) {
-  auto ToParam = hasAnyParameter(parmVarDecl(equalsBoundNode("param")));
+  const auto ToParam = hasAnyParameter(parmVarDecl(equalsBoundNode("param")));
 
   const StatementMatcher MoveCallMatcher =
       callExpr(
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
index a8ef59157958f..24bd5d0359a05 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
@@ -125,7 +125,7 @@ void SpecialMemberFunctionsCheck::check(
   ClassDefId ID(MatchedDecl->getLocation(),
                 std::string(MatchedDecl->getName()));
 
-  auto StoreMember = [this, &ID](SpecialMemberFunctionData Data) {
+  const auto StoreMember = [this, &ID](SpecialMemberFunctionData Data) {
     llvm::SmallVectorImpl<SpecialMemberFunctionData> &Members =
         ClassWithSpecialMembers[ID];
     if (!llvm::is_contained(Members, Data))
@@ -179,14 +179,14 @@ void SpecialMemberFunctionsCheck::checkForMissingMembers(
     });
   };
 
-  auto IsDeleted = [&](SpecialMemberFunctionKind Kind) {
+  const auto IsDeleted = [&](SpecialMemberFunctionKind Kind) {
     return llvm::any_of(DefinedMembers, [Kind](const auto &Data) {
       return Data.FunctionKind == Kind && Data.IsDeleted;
     });
   };
 
-  auto RequireMembers = [&](SpecialMemberFunctionKind Kind1,
-                            SpecialMemberFunctionKind Kind2) {
+  const auto RequireMembers = [&](SpecialMemberFunctionKind Kind1,
+                                  SpecialMemberFunctionKind Kind2) {
     if (AllowImplicitlyDeletedCopyOrMove && HasImplicitDeletedMember(Kind1) &&
         HasImplicitDeletedMember(Kind2))
       return;
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.cpp
index 9e809e0bedb49..c3730aa3a9b61 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.cpp
@@ -24,7 +24,7 @@ void UseEnumClassCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void UseEnumClassCheck::registerMatchers(MatchFinder *Finder) {
-  auto EnumDecl =
+  const auto EnumDecl =
       IgnoreUnscopedEnumsInClasses
           ? enumDecl(unless(isScoped()), unless(hasParent(recordDecl())))
           : enumDecl(unless(isScoped()));
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
index e6b06d3ec4dcb..e43a652ed9d0c 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
@@ -159,7 +159,7 @@ static FixItHint changePrivateDestructorVisibilityTo(
   else
     EndLocation = Destructor.getEndLoc().getLocWithOffset(1);
 
-  auto OriginalDestructorRange =
+  const auto OriginalDestructorRange =
       CharSourceRange::getCharRange(Destructor.getBeginLoc(), EndLocation);
   return FixItHint::CreateReplacement(OriginalDestructorRange,
                                       DestructorString);
diff --git a/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp b/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp
index 315ce5840e5d4..7dc707eb2e3ff 100644
--- a/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp
+++ b/clang-tools-extra/clang-tidy/custom/QueryCheck.cpp
@@ -104,12 +104,12 @@ QueryCheck::QueryCheck(llvm::StringRef Name,
                        ClangTidyContext *Context)
     : ClangTidyCheck(Name, Context) {
   for (const ClangTidyOptions::CustomCheckDiag &D : V.Diags) {
-    auto DiagnosticIdIt =
+    const auto DiagnosticIdIt =
         Diags
             .try_emplace(D.Level.value_or(DiagnosticIDs::Warning),
                          llvm::StringMap<llvm::SmallVector<std::string>>{})
             .first;
-    auto DiagMessageIt =
+    const auto DiagMessageIt =
         DiagnosticIdIt->getSecond()
             .try_emplace(D.BindName, llvm::SmallVector<std::string>{})
             .first;
@@ -124,8 +124,9 @@ void QueryCheck::registerMatchers(MatchFinder *Finder) {
 }
 
 void QueryCheck::check(const MatchFinder::MatchResult &Result) {
-  auto Emit = [this](const DiagMaps &DiagMaps, const std::string &BindName,
-                     const DynTypedNode &Node, DiagnosticIDs::Level Level) {
+  const auto Emit = [this](
+                        const DiagMaps &DiagMaps, const std::string &BindName,
+                        const DynTypedNode &Node, DiagnosticIDs::Level Level) {
     const DiagMaps::const_iterator DiagMapIt = DiagMaps.find(Level);
     if (DiagMapIt == DiagMaps.end())
       return;
diff --git a/clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp b/clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
index 92d590cb394c3..97147dcd64ada 100644
--- a/clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/AvoidThrowingObjCExceptionCheck.cpp
@@ -29,8 +29,9 @@ void AvoidThrowingObjCExceptionCheck::check(
       Result.Nodes.getNodeAs<ObjCAtThrowStmt>("throwStmt");
   const auto *MatchedExpr =
       Result.Nodes.getNodeAs<ObjCMessageExpr>("raiseException");
-  auto SourceLoc = MatchedStmt == nullptr ? MatchedExpr->getSelectorStartLoc()
-                                          : MatchedStmt->getThrowLoc();
+  const auto SourceLoc = MatchedStmt == nullptr
+                             ? MatchedExpr->getSelectorStartLoc()
+                             : MatchedStmt->getThrowLoc();
 
   // Early return on invalid locations.
   if (SourceLoc.isInvalid())
@@ -40,7 +41,7 @@ void AvoidThrowingObjCExceptionCheck::check(
   // header.
   if (SourceLoc.isMacroID()) {
     const SourceManager &SM = *Result.SourceManager;
-    auto MacroLoc = SM.getImmediateMacroCallerLoc(SourceLoc);
+    const auto MacroLoc = SM.getImmediateMacroCallerLoc(SourceLoc);
 
     // Matches in system header macros should be ignored.
     if (SM.isInSystemHeader(MacroLoc))
diff --git a/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp b/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
index ac604b7b9f1b4..055f63b584695 100644
--- a/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
@@ -109,7 +109,7 @@ void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) {
       Ctor->getParamDecl(0)->getType().getNonReferenceType());
   if (ExplicitSpec.isExplicit() &&
       (Ctor->isCopyOrMoveConstructor() || TakesInitializerList)) {
-    auto IsKwExplicit = [](const Token &Tok) {
+    const auto IsKwExplicit = [](const Token &Tok) {
       return Tok.is(tok::raw_identifier) &&
              Tok.getRawIdentifier() == "explicit";
     };
@@ -124,9 +124,9 @@ void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) {
     else
       ConstructorDescription = "initializer-list";
 
-    auto Diag = diag(Ctor->getLocation(),
-                     "%0 constructor should not be declared explicit")
-                << ConstructorDescription;
+    const auto Diag = diag(Ctor->getLocation(),
+                           "%0 constructor should not be declared explicit")
+                      << ConstructorDescription;
     if (ExplicitTokenRange.isValid()) {
       Diag << FixItHint::CreateRemoval(
           CharSourceRange::getCharRange(ExplicitTokenRange));
@@ -150,7 +150,7 @@ void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) {
   const bool SingleArgument =
       Ctor->getNumParams() == 1 && !Ctor->getParamDecl(0)->isParameterPack();
   const SourceLocation Loc = Ctor->getLocation();
-  auto Diag =
+  const auto Diag =
       diag(Loc, ExplicitExpr ? WithExpressionWarningMessage
                              : NoExpressionWarningMessage)
       << (SingleArgument
diff --git a/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
index 7470b1eb206bb..ab0468327f8c4 100644
--- a/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/GlobalVariableDeclarationCheck.cpp
@@ -46,9 +46,9 @@ static FixItHint generateFixItHint(const VarDecl *Decl, bool IsConst) {
     return {};
   }
 
-  auto NewName = (IsConst ? "k" : "g") +
-                 llvm::StringRef(std::string(1, FC)).upper() +
-                 Decl->getName().substr(1).str();
+  const auto NewName = (IsConst ? "k" : "g") +
+                       llvm::StringRef(std::string(1, FC)).upper() +
+                       Decl->getName().substr(1).str();
 
   return FixItHint::CreateReplacement(
       CharSourceRange::getTokenRange(SourceRange(Decl->getLocation())),
diff --git a/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp b/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
index 52bcf1b1719a4..2ac57e988b08e 100644
--- a/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/IntegerTypesCheck.cpp
@@ -48,7 +48,7 @@ AST_MATCHER(TypeLoc, isValidAndNotInMacro) {
 
 AST_MATCHER(TypeLoc, isBuiltinType) {
   TypeLoc TL = Node;
-  if (auto QualLoc = Node.getAs<QualifiedTypeLoc>())
+  if (const auto QualLoc = Node.getAs<QualifiedTypeLoc>())
     TL = QualLoc.getUnqualifiedLoc();
 
   const auto BuiltinLoc = TL.getAs<BuiltinTypeLoc>();
@@ -106,10 +106,10 @@ void IntegerTypesCheck::check(const MatchFinder::MatchResult &Result) {
   const SourceLocation Loc = TL.getBeginLoc();
 
   // Look through qualification.
-  if (auto QualLoc = TL.getAs<QualifiedTypeLoc>())
+  if (const auto QualLoc = TL.getAs<QualifiedTypeLoc>())
     TL = QualLoc.getUnqualifiedLoc();
 
-  auto BuiltinLoc = TL.getAs<BuiltinTypeLoc>();
+  const auto BuiltinLoc = TL.getAs<BuiltinTypeLoc>();
   if (!BuiltinLoc)
     return;
 
diff --git a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
index 9ca23aaeb6211..72292257c67fa 100644
--- a/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp
@@ -125,14 +125,14 @@ void UpgradeGoogletestCaseCheck::registerPPCallbacks(const SourceManager &,
 }
 
 void UpgradeGoogletestCaseCheck::registerMatchers(MatchFinder *Finder) {
-  auto LocationFilter =
+  const auto LocationFilter =
       unless(isExpansionInFileMatching("gtest/gtest(-typed-test)?\\.h$"));
 
   // Matchers for the member functions that are being renamed. In each matched
   // Google Test class, we check for the existence of one new method name. This
   // makes sure the check gives warnings only if the included version of Google
   // Test is recent enough.
-  auto Methods =
+  const auto Methods =
       cxxMethodDecl(
           anyOf(
               cxxMethodDecl(
@@ -182,7 +182,7 @@ void UpgradeGoogletestCaseCheck::registerMatchers(MatchFinder *Finder) {
   // Matchers for `TestCase` -> `TestSuite`. The fact that `TestCase` is an
   // alias and not a class declaration ensures we only match with a recent
   // enough version of Google Test.
-  auto TestCaseTypeAlias =
+  const auto TestCaseTypeAlias =
       typeAliasDecl(hasName("::testing::TestCase")).bind("test-case");
   Finder->addMatcher(
       typeLoc(loc(qualType(typedefType(hasDeclaration(TestCaseTypeAlias)))),
@@ -255,10 +255,10 @@ getAliasNameRange(const MatchFinder::MatchResult &Result) {
         Using->getNameInfo().getSourceRange());
   }
   TypeLoc TL = *Result.Nodes.getNodeAs<TypeLoc>("typeloc");
-  if (auto QTL = TL.getAs<QualifiedTypeLoc>())
+  if (const auto QTL = TL.getAs<QualifiedTypeLoc>())
     TL = QTL.getUnqualifiedLoc();
 
-  if (auto TTL = TL.getAs<TypedefTypeLoc>())
+  if (const auto TTL = TL.getAs<TypedefTypeLoc>())
     return CharSourceRange::getTokenRange(TTL.getNameLoc());
   return CharSourceRange::getTokenRange(TL.castAs<UsingTypeLoc>().getNameLoc());
 }
diff --git a/clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.cpp b/clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.cpp
index 14f54571885f2..67c0425d9c7d4 100644
--- a/clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/linuxkernel/MustCheckErrsCheck.cpp
@@ -14,15 +14,16 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::linuxkernel {
 
 void MustCheckErrsCheck::registerMatchers(MatchFinder *Finder) {
-  auto ErrFn =
+  const auto ErrFn =
       functionDecl(hasAnyName("ERR_PTR", "PTR_ERR", "IS_ERR", "IS_ERR_OR_NULL",
                               "ERR_CAST", "PTR_ERR_OR_ZERO"));
-  auto NonCheckingStmts = stmt(anyOf(compoundStmt(), labelStmt()));
+  const auto NonCheckingStmts = stmt(anyOf(compoundStmt(), labelStmt()));
   Finder->addMatcher(
       callExpr(callee(ErrFn), hasParent(NonCheckingStmts)).bind("call"), this);
 
-  auto ReturnToCheck = returnStmt(hasReturnValue(callExpr(callee(ErrFn))));
-  auto ReturnsErrFn = functionDecl(hasDescendant(ReturnToCheck));
+  const auto ReturnToCheck =
+      returnStmt(hasReturnValue(callExpr(callee(ErrFn))));
+  const auto ReturnsErrFn = functionDecl(hasDescendant(ReturnToCheck));
   Finder->addMatcher(callExpr(callee(ReturnsErrFn), hasParent(NonCheckingStmts))
                          .bind("transitive_call"),
                      this);
diff --git a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
index 592a4313dc197..af6e7d2dd2d9f 100644
--- a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -153,8 +153,8 @@ void IncludeOrderPPCallbacks::EndOfMainFile() {
         continue;
 
       // Emit a warning.
-      auto D = Check.diag(FileDirectives[I].Loc,
-                          "#includes are not sorted properly");
+      const auto D = Check.diag(FileDirectives[I].Loc,
+                                "#includes are not sorted properly");
 
       // Emit fix-its for all following includes in this block.
       for (; I != E; ++I) {
@@ -171,7 +171,7 @@ void IncludeOrderPPCallbacks::EndOfMainFile() {
         const SourceLocation ToLoc = FileDirectives[I].Range.getBegin();
         const char *ToData = SM.getCharacterData(ToLoc);
         const unsigned ToLen = std::strcspn(ToData, "\n");
-        auto ToRange =
+        const auto ToRange =
             CharSourceRange::getCharRange(ToLoc, ToLoc.getLocWithOffset(ToLen));
 
         D << FixItHint::CreateReplacement(ToRange, FixedName);
diff --git a/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp b/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp
index 8966745eb44a7..9bc05acf430a3 100644
--- a/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/PreferIsaOrDynCastInConditionalsCheck.cpp
@@ -22,7 +22,7 @@ AST_MATCHER(Expr, isMacroID) { return Node.getExprLoc().isMacroID(); }
 
 void PreferIsaOrDynCastInConditionalsCheck::registerMatchers(
     MatchFinder *Finder) {
-  auto AnyCalleeName = [](ArrayRef<StringRef> CalleeName) {
+  const auto AnyCalleeName = [](ArrayRef<StringRef> CalleeName) {
     return allOf(unless(isMacroID()), unless(cxxMemberCallExpr()),
                  callee(expr(ignoringImpCasts(
                      declRefExpr(to(namedDecl(hasAnyName(CalleeName))),
@@ -33,13 +33,13 @@ void PreferIsaOrDynCastInConditionalsCheck::registerMatchers(
   auto CondExpr = hasCondition(implicitCastExpr(
       has(callExpr(AnyCalleeName({"cast", "dyn_cast"})).bind("cond"))));
 
-  auto CondExprOrCondVar =
+  const auto CondExprOrCondVar =
       anyOf(hasConditionVariableStatement(containsDeclaration(
                 0, varDecl(hasInitializer(callExpr(AnyCalleeName({"cast"}))))
                        .bind("var"))),
             CondExpr);
 
-  auto CallWithBindedArg =
+  const auto CallWithBindedArg =
       callExpr(
           AnyCalleeName(
               {"isa", "cast", "cast_or_null", "dyn_cast", "dyn_cast_or_null"}),
@@ -93,7 +93,7 @@ void PreferIsaOrDynCastInConditionalsCheck::check(
     assert(RHS && "RHS is null");
     assert(Arg && "Arg is null");
 
-    auto GetText = [&](SourceRange R) {
+    const auto GetText = [&](SourceRange R) {
       return Lexer::getSourceText(CharSourceRange::getTokenRange(R),
                                   *Result.SourceManager, getLangOpts());
     };
diff --git a/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp b/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp
index c5ee240b64ea8..60baee7fdba6a 100644
--- a/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/PreferRegisterOverUnsignedCheck.cpp
@@ -14,7 +14,7 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::llvm_check {
 
 void PreferRegisterOverUnsignedCheck::registerMatchers(MatchFinder *Finder) {
-  auto RegisterClassMatch = hasType(
+  const auto RegisterClassMatch = hasType(
       cxxRecordDecl(hasName("::llvm::Register")).bind("registerClassDecl"));
 
   Finder->addMatcher(
diff --git a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp b/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
index 7dea84516502b..dc872cdb38e53 100644
--- a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -16,7 +16,7 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::llvm_check {
 
 void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
-  auto TwineType =
+  const auto TwineType =
       qualType(hasDeclaration(cxxRecordDecl(hasName("::llvm::Twine"))));
   Finder->addMatcher(
       varDecl(unless(parmVarDecl()), hasType(TwineType)).bind("variable"),
@@ -25,8 +25,8 @@ void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
 
 void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *VD = Result.Nodes.getNodeAs<VarDecl>("variable");
-  auto Diag = diag(VD->getLocation(),
-                   "twine variables are prone to use-after-free bugs");
+  const auto Diag = diag(VD->getLocation(),
+                         "twine variables are prone to use-after-free bugs");
 
   // If this VarDecl has an initializer try to fix it.
   if (VD->hasInit()) {
diff --git a/clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp b/clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp
index e4564149066bd..d687aefc22a89 100644
--- a/clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp
@@ -47,7 +47,7 @@ static EditGenerator rewrite(RangeSelector Call, RangeSelector Builder) {
 
     // This will try to extract the template argument as written so that the
     // rewritten code looks closest to original.
-    auto NextToken = [&](std::optional<Token> CurrentToken) {
+    const auto NextToken = [&](std::optional<Token> CurrentToken) {
       if (!CurrentToken)
         return CurrentToken;
       if (CurrentToken->is(clang::tok::eof))
@@ -92,7 +92,7 @@ static EditGenerator rewrite(RangeSelector Call, RangeSelector Builder) {
       return BuilderRange.takeError();
 
     // Helper for concatting below.
-    auto GetText = [&](const CharSourceRange &Range) {
+    const auto GetText = [&](const CharSourceRange &Range) {
       return clang::Lexer::getSourceText(Range, SM, LangOpts);
     };
 
@@ -120,7 +120,8 @@ static RewriteRuleWith<std::string> useNewMlirOpBuilderCheckRule() {
   const Stencil Message = cat("use 'OpType::create(builder, ...)' instead of "
                               "'builder.create<OpType>(...)'");
   // Match a create call on an OpBuilder.
-  auto BuilderType = cxxRecordDecl(isSameOrDerivedFrom("::mlir::OpBuilder"));
+  const auto BuilderType =
+      cxxRecordDecl(isSameOrDerivedFrom("::mlir::OpBuilder"));
   const ast_matchers::internal::Matcher<Stmt> Base =
       cxxMemberCallExpr(
           on(expr(anyOf(hasType(BuilderType), hasType(pointsTo(BuilderType))))
diff --git a/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp b/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
index 9f09947c4da29..6497af62d6d1d 100644
--- a/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
@@ -76,8 +76,8 @@ void InlineFunctionDeclCheck::check(const MatchFinder::MatchResult &Result) {
       return;
 
   // Check if decl starts with LIBC_INLINE
-  auto Loc = FullSourceLoc(Result.SourceManager->getFileLoc(SrcBegin),
-                           *Result.SourceManager);
+  const auto Loc = FullSourceLoc(Result.SourceManager->getFileLoc(SrcBegin),
+                                 *Result.SourceManager);
   const llvm::StringRef SrcText =
       Loc.getBufferData().drop_front(Loc.getFileOffset());
   if (SrcText.starts_with("LIBC_INLINE"))
diff --git a/clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp b/clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp
index f5dcc7f4edcb6..3ce6528c2c83c 100644
--- a/clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp
@@ -18,7 +18,7 @@ int main(int argc, char *argv[]) {
   auto ErrorOrBuffer = MemoryBuffer::getFile(argv[1], true);
   if (!ErrorOrBuffer)
     return 1;
-  std::unique_ptr<MemoryBuffer> Buffer = std::move(ErrorOrBuffer.get());
+  const std::unique_ptr<MemoryBuffer> Buffer = std::move(ErrorOrBuffer.get());
   StringRef Content = Buffer->getBuffer();
   Content = Content.drop_until([](char C) { return C == '#'; });
   SmallVector<StringRef> Lines;
@@ -73,7 +73,7 @@ int main(int argc, char *argv[]) {
     Os << "  { ";
     Os << Values.first;
     Os << ", {";
-    for (auto CP : Values.second)
+    for (const auto CP : Values.second)
       Os << CP << ", ";
 
     Os << "}},\n";
diff --git a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
index 762144ea6deea..1ba89c494de68 100644
--- a/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ConstCorrectnessCheck.cpp
@@ -175,7 +175,7 @@ void ConstCorrectnessCheck::check(const MatchFinder::MatchResult &Result) {
       VC = VariableCategory::Pointer;
   }
 
-  auto CheckValue = [&]() {
+  const auto CheckValue = [&]() {
     // The scope is only registered if the analysis shall be run.
     registerScope(LocalScope, Result.Context);
 
@@ -183,9 +183,9 @@ void ConstCorrectnessCheck::check(const MatchFinder::MatchResult &Result) {
     if (ScopesCache[LocalScope]->isMutated(Variable))
       return;
 
-    auto Diag = diag(Variable->getBeginLoc(),
-                     "variable %0 of type %1 can be declared 'const'")
-                << Variable << VT;
+    const auto Diag = diag(Variable->getBeginLoc(),
+                           "variable %0 of type %1 can be declared 'const'")
+                      << Variable << VT;
     if (IsNormalVariableInTemplate)
       TemplateDiagnosticsCache.insert(Variable->getBeginLoc());
     if (!CanBeFixIt)
@@ -215,12 +215,12 @@ void ConstCorrectnessCheck::check(const MatchFinder::MatchResult &Result) {
     }
   };
 
-  auto CheckPointee = [&]() {
+  const auto CheckPointee = [&]() {
     assert(VC == VariableCategory::Pointer);
     registerScope(LocalScope, Result.Context);
     if (ScopesCache[LocalScope]->isPointeeMutated(Variable))
       return;
-    auto Diag =
+    const auto Diag =
         diag(Variable->getBeginLoc(),
              "pointee of variable %0 of type %1 can be declared 'const'")
         << Variable << VT;
diff --git a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
index 75693a0c563e9..2169dffca5c51 100644
--- a/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/CoroutineHostileRAIICheck.cpp
@@ -29,7 +29,7 @@ AST_MATCHER_P(Stmt, forEachPrevStmt, ast_matchers::internal::Matcher<Stmt>,
   DynTypedNode P;
   bool IsHostile = false;
   for (const Stmt *Child = &Node; Child; Child = P.get<Stmt>()) {
-    auto Parents = Finder->getASTContext().getParents(*Child);
+    const auto Parents = Finder->getASTContext().getParents(*Child);
     if (Parents.empty())
       break;
     P = *Parents.begin();
@@ -68,7 +68,7 @@ static auto typeWithNameIn(const std::vector<StringRef> &Names) {
 }
 
 static auto functionWithNameIn(const std::vector<StringRef> &Names) {
-  auto Call = callExpr(callee(functionDecl(hasAnyName(Names))));
+  const auto Call = callExpr(callee(functionDecl(hasAnyName(Names))));
   return anyOf(expr(cxxBindTemporaryExpr(has(Call))), expr(Call));
 }
 
diff --git a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
index c10ee1d92cd59..c41ba2be8f47f 100644
--- a/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
@@ -31,7 +31,7 @@ DefinitionsInHeadersCheck::DefinitionsInHeadersCheck(StringRef Name,
       HeaderFileExtensions(Context->getHeaderFileExtensions()) {}
 
 void DefinitionsInHeadersCheck::registerMatchers(MatchFinder *Finder) {
-  auto DefinitionMatcher =
+  const auto DefinitionMatcher =
       anyOf(functionDecl(isDefinition(), unless(isDeleted())),
             varDecl(isDefinition()));
   Finder->addMatcher(namedDecl(DefinitionMatcher,
diff --git a/clang-tools-extra/clang-tidy/misc/MisleadingBidirectionalCheck.cpp b/clang-tools-extra/clang-tidy/misc/MisleadingBidirectionalCheck.cpp
index 8a10f70c12f93..a7add8cc899c2 100644
--- a/clang-tools-extra/clang-tidy/misc/MisleadingBidirectionalCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MisleadingBidirectionalCheck.cpp
@@ -76,7 +76,7 @@ static bool containsMisleadingBidi(StringRef Buffer,
       BidiContexts.push_back(PDI);
     // Close a PDI Context.
     else if (CodePoint == PDI) {
-      auto R = llvm::find(llvm::reverse(BidiContexts), PDI);
+      const auto R = llvm::find(llvm::reverse(BidiContexts), PDI);
       if (R != BidiContexts.rend())
         BidiContexts.resize(BidiContexts.rend() - R - 1);
     }
diff --git a/clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp b/clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
index c8c0cfd1c6ad5..8997efc636c61 100644
--- a/clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/MisplacedConstCheck.cpp
@@ -15,7 +15,7 @@ using namespace clang::ast_matchers;
 namespace clang::tidy::misc {
 
 void MisplacedConstCheck::registerMatchers(MatchFinder *Finder) {
-  auto NonConstAndNonFunctionPointerType = hasType(pointerType(unless(
+  const auto NonConstAndNonFunctionPointerType = hasType(pointerType(unless(
       pointee(anyOf(isConstQualified(), ignoringParens(functionType()))))));
 
   Finder->addMatcher(
diff --git a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
index 8bcbb61961fa6..bfc17da71cb4d 100644
--- a/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NoRecursionCheck.cpp
@@ -162,7 +162,7 @@ static CallStackTy pathfindSomeCycle(ArrayRef<CallGraphNode *> SCC) {
   const ImmutableSmallSet<CallGraphNode *, SmallSCCSize> SCCElts(SCC);
 
   // Is node N part if the current SCC?
-  auto NodeIsPartOfSCC = [&SCCElts](CallGraphNode *N) {
+  const auto NodeIsPartOfSCC = [&SCCElts](CallGraphNode *N) {
     return SCCElts.count(N) != 0;
   };
 
diff --git a/clang-tools-extra/clang-tidy/misc/NonCopyableObjectsCheck.cpp b/clang-tools-extra/clang-tidy/misc/NonCopyableObjectsCheck.cpp
index bfeb5fa855af6..eb3915bb3965b 100644
--- a/clang-tools-extra/clang-tidy/misc/NonCopyableObjectsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NonCopyableObjectsCheck.cpp
@@ -36,7 +36,7 @@ void NonCopyableObjectsCheck::registerMatchers(MatchFinder *Finder) {
       hasType(namedDecl(hasAnyName("::pthread_cond_t", "::pthread_mutex_t",
                                    "pthread_cond_t", "pthread_mutex_t"))
                   .bind("type_decl"));
-  auto BadEitherType = anyOf(BadFILEType, BadPOSIXType);
+  const auto BadEitherType = anyOf(BadFILEType, BadPOSIXType);
 
   Finder->addMatcher(
       namedDecl(anyOf(varDecl(BadFILEType), fieldDecl(BadFILEType)))
diff --git a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
index fffce2095d8d5..54cc5803956db 100644
--- a/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/NonPrivateMemberVariablesInClassesCheck.cpp
@@ -65,9 +65,9 @@ void NonPrivateMemberVariablesInClassesCheck::registerMatchers(
   // If we are ok with public fields, then we only want to complain about
   // protected fields, else we want to complain about all non-private fields.
   // We can ignore public member variables in structs/classes, in unions.
-  auto InterestingField = IgnorePublicMemberVariables
-                              ? fieldDecl(isProtected())
-                              : fieldDecl(unless(isPrivate()));
+  const auto InterestingField = IgnorePublicMemberVariables
+                                    ? fieldDecl(isProtected())
+                                    : fieldDecl(unless(isPrivate()));
 
   // We only want the records that not only contain the mutable data (non-static
   // member variables), but also have some logic (non-static, non-implicit
diff --git a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
index 63be9dd47dca7..d9eed43bff512 100644
--- a/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -725,7 +725,7 @@ static bool areSidesBinaryConstExpressions(const BinaryOperator *&BinOp,
   if (!LhsBinOp || !RhsBinOp)
     return false;
 
-  auto IsIntegerConstantExpr = [AstCtx](const Expr *E) {
+  const auto IsIntegerConstantExpr = [AstCtx](const Expr *E) {
     return !E->isValueDependent() && E->isIntegerConstantExpr(*AstCtx);
   };
 
@@ -748,7 +748,7 @@ static bool areSidesBinaryConstExpressionsOrDefinesOrIntegerConstant(
   if (!Lhs || !Rhs)
     return false;
 
-  auto IsDefineExpr = [AstCtx](const Expr *E) {
+  const auto IsDefineExpr = [AstCtx](const Expr *E) {
     const SourceRange Lsr = E->getSourceRange();
     if (!Lsr.getBegin().isMacroID() || E->isValueDependent() ||
         !E->isIntegerConstantExpr(*AstCtx))
@@ -776,7 +776,7 @@ static bool retrieveConstExprFromBothSides(const BinaryOperator *&BinOp,
   const auto *BinOpLhs = cast<BinaryOperator>(BinOp->getLHS());
   const auto *BinOpRhs = cast<BinaryOperator>(BinOp->getRHS());
 
-  auto IsIntegerConstantExpr = [AstCtx](const Expr *E) {
+  const auto IsIntegerConstantExpr = [AstCtx](const Expr *E) {
     return !E->isValueDependent() && E->isIntegerConstantExpr(*AstCtx);
   };
 
@@ -1407,7 +1407,7 @@ void RedundantExpressionCheck::check(const MatchFinder::MatchResult &Result) {
           Result.Nodes.getNodeAs<UnaryOperator>("logical-bitwise-confusion")) {
     const SourceLocation OperatorLoc = NegateOperator->getOperatorLoc();
 
-    auto Diag =
+    const auto Diag =
         diag(OperatorLoc,
              "ineffective logical negation operator used; did you mean '~'?");
     const SourceLocation LogicalNotLocation = OperatorLoc.getLocWithOffset(1);
@@ -1440,8 +1440,8 @@ void RedundantExpressionCheck::check(const MatchFinder::MatchResult &Result) {
     if (AndValue->getActiveBits() > *ShiftingValue)
       return;
 
-    auto Diag = diag(BinaryAndExpr->getOperatorLoc(),
-                     "ineffective bitwise and operation");
+    const auto Diag = diag(BinaryAndExpr->getOperatorLoc(),
+                           "ineffective bitwise and operation");
   }
 
   // Check for the following bound expressions:
diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
index 554e759268330..f6189aaf5f928 100644
--- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp
@@ -31,7 +31,7 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
       expr(anyOf(cxxBoolLiteral(equals(false)), integerLiteral(equals(0)),
                  cxxNullPtrLiteralExpr(), gnuNullExpr(), NegatedString))
           .bind("isAlwaysFalse");
-  auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(
+  const auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(
       IsAlwaysFalse, cStyleCastExpr(has(ignoringParenImpCasts(IsAlwaysFalse)))
                          .bind("castExpr")));
   auto AssertExprRoot = anyOf(
@@ -56,7 +56,7 @@ void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
                                    ignoringParenCasts(AssertExprRoot))))))),
            unless(NonConstexprCode), unless(hasDescendant(NonConstexprCode)))
           .bind("condition");
-  auto Condition =
+  const auto Condition =
       anyOf(ignoringParenImpCasts(callExpr(
                 hasDeclaration(functionDecl(hasName("__builtin_expect"))),
                 hasArgument(0, AssertCondition))),
diff --git a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
index db3a69029c069..32ee428a8d2b0 100644
--- a/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/ThrowByValueCatchByReferenceCheck.cpp
@@ -68,7 +68,7 @@ void ThrowByValueCatchByReferenceCheck::diagnoseThrowLocations(
   auto *SubExpr = ThrowExpr->getSubExpr();
   if (!SubExpr)
     return;
-  auto QualType = SubExpr->getType();
+  const auto QualType = SubExpr->getType();
   if (QualType->isPointerType()) {
     // The code is throwing a pointer.
     // In case it is string literal, it is safe and we return.
@@ -110,7 +110,7 @@ void ThrowByValueCatchByReferenceCheck::diagnoseThrowLocations(
       // If we have a copy / move construction, we emit a diagnosis message if
       // the object that we copy construct from is neither a function parameter
       // nor a variable declared in a catch statement
-      auto ArgIter =
+      const auto ArgIter =
           ConstructorCall
               ->arg_begin(); // there's only one for copy constructors
       auto *CurrentSubExpr = (*ArgIter)->IgnoreImpCasts();
@@ -131,10 +131,10 @@ void ThrowByValueCatchByReferenceCheck::diagnoseCatchLocations(
     const CXXCatchStmt *CatchStmt, ASTContext &Context) {
   if (!CatchStmt)
     return;
-  auto CaughtType = CatchStmt->getCaughtType();
+  const auto CaughtType = CatchStmt->getCaughtType();
   if (CaughtType.isNull())
     return;
-  auto *VarDecl = CatchStmt->getExceptionDecl();
+  const auto *VarDecl = CatchStmt->getExceptionDecl();
   if (const auto *PT = CaughtType.getCanonicalType()->getAs<PointerType>()) {
     const char *DiagMsgCatchReference =
         "catch handler catches a pointer value; "
diff --git a/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp b/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
index ab2077b304f13..fcc2a3db79e7d 100644
--- a/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UniqueptrResetReleaseCheck.cpp
@@ -59,7 +59,7 @@ getDeleterForUniquePtr(const MatchFinder::MatchResult &Result, StringRef ID) {
       Result.Nodes.getNodeAs<ClassTemplateSpecializationDecl>(ID);
   if (!Class)
     return nullptr;
-  auto DeleterArgument = Class->getTemplateArgs()[1];
+  const auto DeleterArgument = Class->getTemplateArgs()[1];
   if (DeleterArgument.getKind() != TemplateArgument::Type)
     return nullptr;
   return DeleterArgument.getAsType().getTypePtr();
@@ -126,8 +126,9 @@ void UniqueptrResetReleaseCheck::check(const MatchFinder::MatchResult &Result) {
     NeedsUtilityInclude = true;
   }
 
-  auto D = diag(ResetMember->getExprLoc(),
-                "prefer 'unique_ptr<>' assignment over 'release' and 'reset'");
+  const auto D =
+      diag(ResetMember->getExprLoc(),
+           "prefer 'unique_ptr<>' assignment over 'release' and 'reset'");
   if (ResetMember->isArrow())
     D << FixItHint::CreateInsertion(ResetMember->getBeginLoc(), "*");
   D << FixItHint::CreateReplacement(
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
index 6cebb35a9dad7..36c72315007fa 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnusedParametersCheck.cpp
@@ -144,7 +144,8 @@ void UnusedParametersCheck::warnOnUnusedParameter(
   // Don't bother to diagnose invalid parameters as being unused.
   if (Param->isInvalidDecl())
     return;
-  auto MyDiag = diag(Param->getLocation(), "parameter %0 is unused") << Param;
+  const auto MyDiag = diag(Param->getLocation(), "parameter %0 is unused")
+                      << Param;
 
   if (!Indexer)
     Indexer = std::make_unique<IndexerVisitor>(*Result.Context);
diff --git a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
index 6d1b253530628..c6bbbaee0cc9d 100644
--- a/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -56,7 +56,7 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   if (utils::isFileExtension(getCurrentMainFile(), HeaderFileExtensions))
     return;
   Finder->addMatcher(usingDecl(isExpansionInMainFile()).bind("using"), this);
-  auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
+  const auto DeclMatcher = hasDeclaration(namedDecl().bind("used"));
   Finder->addMatcher(loc(templateSpecializationType(DeclMatcher)), this);
   Finder->addMatcher(loc(deducedTemplateSpecializationType(
                          refsToTemplatedDecl(namedDecl().bind("used")))),
@@ -75,7 +75,8 @@ void UnusedUsingDeclsCheck::registerMatchers(MatchFinder *Finder) {
   // Cases where we can identify the UsingShadowDecl directly, rather than
   // just its target.
   // FIXME: cover more cases in this way, as the AST supports it.
-  auto ThroughShadowMatcher = throughUsingDecl(namedDecl().bind("usedShadow"));
+  const auto ThroughShadowMatcher =
+      throughUsingDecl(namedDecl().bind("usedShadow"));
   Finder->addMatcher(declRefExpr(ThroughShadowMatcher), this);
   Finder->addMatcher(loc(usingType(ThroughShadowMatcher)), this);
 }
@@ -118,7 +119,7 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
   }
 
   // Mark a corresponding using declaration as used.
-  auto RemoveNamedDecl = [&](const NamedDecl *Used) {
+  const auto RemoveNamedDecl = [&](const NamedDecl *Used) {
     removeFromFoundDecls(Used);
     // Also remove variants of Used.
     if (const auto *FD = dyn_cast<FunctionDecl>(Used)) {
@@ -156,7 +157,7 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
     }
 
     if (Used->getKind() == TemplateArgument::Type) {
-      if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
+      if (const auto *RD = Used->getAsType()->getAsCXXRecordDecl())
         removeFromFoundDecls(RD);
       return;
     }
diff --git a/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp b/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp
index 68115cb28e7c8..a3a991dd31565 100644
--- a/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/UseInternalLinkageCheck.cpp
@@ -134,7 +134,7 @@ void UseInternalLinkageCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void UseInternalLinkageCheck::registerMatchers(MatchFinder *Finder) {
-  auto Common =
+  const auto Common =
       allOf(isFirstDecl(), isAllRedeclsInMainFile(HeaderFileExtensions),
             unless(anyOf(
                 // 1. internal linkage
diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
index 94a28cef30a80..fe94d292d450d 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
@@ -651,7 +651,7 @@ void AvoidBindCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *MatchedDecl = Result.Nodes.getNodeAs<CallExpr>("bind");
 
   LambdaProperties LP = getLambdaProperties(Result);
-  auto Diag =
+  const auto Diag =
       diag(MatchedDecl->getBeginLoc(),
            formatv("prefer a lambda to {0}::bind", LP.BindNamespace).str());
   if (!LP.IsFixitSupported)
diff --git a/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp b/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp
index 76f2030158c81..481f7e58561b8 100644
--- a/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/AvoidCStyleCastCheck.cpp
@@ -92,7 +92,7 @@ static bool sameTypeAsWritten(QualType X, QualType Y) {
   if (X.getCanonicalType() != Y.getCanonicalType())
     return false;
 
-  auto TC = X->getTypeClass();
+  const auto TC = X->getTypeClass();
   if (TC != Y->getTypeClass())
     return false;
 
@@ -124,7 +124,7 @@ void AvoidCStyleCastCheck::check(const MatchFinder::MatchResult &Result) {
   if (CastExpr->getCastKind() == CK_ToVoid)
     return;
 
-  auto IsFunction = [](QualType T) {
+  const auto IsFunction = [](QualType T) {
     T = T.getCanonicalType().getNonReferenceType();
     return T->isFunctionType() || T->isFunctionPointerType() ||
            T->isMemberFunctionPointerType();
@@ -197,11 +197,11 @@ void AvoidCStyleCastCheck::check(const MatchFinder::MatchResult &Result) {
     }
     Diag << FixItHint::CreateReplacement(ReplaceRange, CastText);
   };
-  auto ReplaceWithNamedCast = [&](StringRef CastType) {
+  const auto ReplaceWithNamedCast = [&](StringRef CastType) {
     Diag << CastType;
     ReplaceWithCast((CastType + "<" + DestTypeString + ">").str());
   };
-  auto ReplaceWithConstructorCall = [&]() {
+  const auto ReplaceWithConstructorCall = [&]() {
     Diag << "constructor call syntax";
     // FIXME: Validate DestTypeString, maybe.
     ReplaceWithCast(DestTypeString.str());
diff --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
index eff7c2f36d49d..753475a8e3e75 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedHeadersCheck.cpp
@@ -61,9 +61,9 @@ class ExternCRefutationVisitor
         !LinkSpecDecl->hasBraces())
       return true;
 
-    auto ExternCBlockBegin = LinkSpecDecl->getBeginLoc();
-    auto ExternCBlockEnd = LinkSpecDecl->getEndLoc();
-    auto IsWrapped = [=, &SM = SM](const IncludeMarker &Marker) -> bool {
+    const auto ExternCBlockBegin = LinkSpecDecl->getBeginLoc();
+    const auto ExternCBlockEnd = LinkSpecDecl->getEndLoc();
+    const auto IsWrapped = [=, &SM = SM](const IncludeMarker &Marker) -> bool {
       return SM.isBeforeInTranslationUnit(ExternCBlockBegin, Marker.DiagLoc) &&
              SM.isBeforeInTranslationUnit(Marker.DiagLoc, ExternCBlockEnd);
     };
@@ -183,7 +183,7 @@ void IncludeModernizePPCallbacks::InclusionDirective(
   // 2. Insert `using namespace std;` to the beginning of TU.
   // 3. Do nothing and let the user deal with the migration himself.
   const SourceLocation DiagLoc = FilenameRange.getBegin();
-  if (auto It = CStyledHeaderToCxx.find(FileName);
+  if (const auto It = CStyledHeaderToCxx.find(FileName);
       It != CStyledHeaderToCxx.end()) {
     IncludesToBeProcessed.emplace_back(IncludeMarker{
         It->second, FileName, FilenameRange.getAsRange(), DiagLoc});
diff --git a/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp b/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
index 7e43165fb09f1..11f5497b1036c 100644
--- a/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/DeprecatedIosBaseAliasesCheck.cpp
@@ -28,8 +28,9 @@ static std::optional<const char *> getReplacementType(StringRef Type) {
 }
 
 void DeprecatedIosBaseAliasesCheck::registerMatchers(MatchFinder *Finder) {
-  auto IoStateDecl = typedefDecl(hasAnyName(DeprecatedTypes)).bind("TypeDecl");
-  auto IoStateType = typedefType(hasDeclaration(IoStateDecl));
+  const auto IoStateDecl =
+      typedefDecl(hasAnyName(DeprecatedTypes)).bind("TypeDecl");
+  const auto IoStateType = typedefType(hasDeclaration(IoStateDecl));
 
   Finder->addMatcher(typeLoc(loc(IoStateType)).bind("TypeLoc"), this);
 }
@@ -43,7 +44,7 @@ void DeprecatedIosBaseAliasesCheck::check(
   auto Replacement = getReplacementType(TypeName);
 
   TypeLoc TL = *Result.Nodes.getNodeAs<TypeLoc>("TypeLoc");
-  if (auto QTL = TL.getAs<QualifiedTypeLoc>())
+  if (const auto QTL = TL.getAs<QualifiedTypeLoc>())
     TL = QTL.getUnqualifiedLoc();
 
   SourceLocation IoStateLoc = TL.castAs<TypedefTypeLoc>().getNameLoc();
@@ -60,9 +61,10 @@ void DeprecatedIosBaseAliasesCheck::check(
 
   if (Replacement) {
     const char *FixName = *Replacement;
-    auto Builder = diag(IoStateLoc, "'std::ios_base::%0' is deprecated; use "
-                                    "'std::ios_base::%1' instead")
-                   << TypeName << FixName;
+    const auto Builder =
+        diag(IoStateLoc, "'std::ios_base::%0' is deprecated; use "
+                         "'std::ios_base::%1' instead")
+        << TypeName << FixName;
 
     if (Fix)
       Builder << FixItHint::CreateReplacement(SourceRange(IoStateLoc, EndLoc),
diff --git a/clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp b/clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp
index 862ca184ecd97..c5bbd514787a5 100644
--- a/clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/IntegralLiteralExpressionMatcher.cpp
@@ -277,7 +277,7 @@ bool IntegralLiteralExpressionMatcher::conditionalExpr() {
 }
 
 bool IntegralLiteralExpressionMatcher::commaExpr() {
-  auto NonTerminal = [this] { return conditionalExpr(); };
+  const auto NonTerminal = [this] { return conditionalExpr(); };
   if (CommaAllowed)
     return nonTerminalChainedExpr<tok::TokenKind::comma>(NonTerminal);
   return nonTerminalChainedExpr(NonTerminal, [](Token) { return false; });
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
index 2d63da2fef974..9aa323aa543c7 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp
@@ -156,15 +156,16 @@ static StatementMatcher makeArrayLoopMatcher() {
 /// Client code will need to make sure that:
 ///   - The two containers on which 'begin' and 'end' are called are the same.
 static StatementMatcher makeIteratorLoopMatcher(bool IsReverse) {
-  auto BeginNameMatcher = IsReverse ? hasAnyName("rbegin", "crbegin")
-                                    : hasAnyName("begin", "cbegin");
-  auto BeginNameMatcherStd = IsReverse
-                                 ? hasAnyName("::std::rbegin", "::std::crbegin")
-                                 : hasAnyName("::std::begin", "::std::cbegin");
+  const auto BeginNameMatcher = IsReverse ? hasAnyName("rbegin", "crbegin")
+                                          : hasAnyName("begin", "cbegin");
+  const auto BeginNameMatcherStd =
+      IsReverse ? hasAnyName("::std::rbegin", "::std::crbegin")
+                : hasAnyName("::std::begin", "::std::cbegin");
 
-  auto EndNameMatcher =
+  const auto EndNameMatcher =
       IsReverse ? hasAnyName("rend", "crend") : hasAnyName("end", "cend");
-  auto EndNameMatcherStd = IsReverse ? hasAnyName("::std::rend", "::std::crend")
+  const auto EndNameMatcherStd = IsReverse
+                                     ? hasAnyName("::std::rend", "::std::crend")
                                      : hasAnyName("::std::end", "::std::cend");
 
   const StatementMatcher BeginCallMatcher =
@@ -497,7 +498,7 @@ static bool isDirectMemberExpr(const Expr *E) {
 static bool canBeModified(ASTContext *Context, const Expr *E) {
   if (E->getType().isConstQualified())
     return false;
-  auto Parents = Context->getParents(*E);
+  const auto Parents = Context->getParents(*E);
   if (Parents.size() != 1)
     return true;
   if (const auto *Cast = Parents[0].get<ImplicitCastExpr>()) {
@@ -878,7 +879,7 @@ void LoopConvertCheck::getIteratorLoopQualifiers(ASTContext *Context,
     // A node will only be bound with DerefByRefResultName if we're dealing
     // with a user-defined iterator type. Test the const qualification of
     // the reference type.
-    auto ValueType = DerefType->getNonReferenceType();
+    const auto ValueType = DerefType->getNonReferenceType();
 
     Descriptor.DerefByConstRef = ValueType.isConstQualified();
     Descriptor.ElemType = ValueType;
diff --git a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
index c899018ba439e..99a8e199bf693 100644
--- a/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
@@ -589,7 +589,7 @@ bool ForLoopIndexUseVisitor::TraverseMemberExpr(MemberExpr *Member) {
 /// operator->(). The one exception is allowing vector::at() for pseudoarrays.
 bool ForLoopIndexUseVisitor::TraverseCXXMemberCallExpr(
     CXXMemberCallExpr *MemberCall) {
-  auto *Member =
+  const auto *Member =
       dyn_cast<MemberExpr>(MemberCall->getCallee()->IgnoreParenImpCasts());
   if (!Member)
     return VisitorBase::TraverseCXXMemberCallExpr(MemberCall);
diff --git a/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
index 1c49c32f9fecb..66886c47f1e60 100644
--- a/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MacroToEnumCheck.cpp
@@ -286,7 +286,7 @@ void MacroToEnumCallbacks::checkName(const Token &MacroNameTok) {
 
 void MacroToEnumCallbacks::rememberExpressionName(const Token &Tok) {
   const std::string Id = getTokenName(Tok).str();
-  auto Pos = llvm::lower_bound(ExpressionNames, Id);
+  const auto Pos = llvm::lower_bound(ExpressionNames, Id);
   if (Pos == ExpressionNames.end() || *Pos != Id)
     ExpressionNames.insert(Pos, Id);
 }
@@ -366,13 +366,14 @@ void MacroToEnumCallbacks::MacroUndefined(const Token &MacroNameTok,
                                           const MacroDirective *Undef) {
   rememberExpressionName(MacroNameTok);
 
-  auto MatchesToken = [&MacroNameTok](const EnumMacro &Macro) {
+  const auto MatchesToken = [&MacroNameTok](const EnumMacro &Macro) {
     return getTokenName(Macro.Name) == getTokenName(MacroNameTok);
   };
 
-  auto *It = llvm::find_if(Enums, [MatchesToken](const MacroList &MacroList) {
-    return llvm::any_of(MacroList, MatchesToken);
-  });
+  const auto *It =
+      llvm::find_if(Enums, [MatchesToken](const MacroList &MacroList) {
+        return llvm::any_of(MacroList, MatchesToken);
+      });
   if (It != Enums.end())
     Enums.erase(It);
 
@@ -517,7 +518,7 @@ void MacroToEnumCheck::registerPPCallbacks(const SourceManager &SM,
 
 void MacroToEnumCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
   using namespace ast_matchers;
-  auto TopLevelDecl = hasParent(translationUnitDecl());
+  const auto TopLevelDecl = hasParent(translationUnitDecl());
   Finder->addMatcher(decl(TopLevelDecl).bind("top"), this);
 }
 
diff --git a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
index 1fdb479b9a032..4200b37763eff 100644
--- a/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -70,7 +70,7 @@ void MakeSmartPtrCheck::registerPPCallbacks(const SourceManager &SM,
 void MakeSmartPtrCheck::registerMatchers(ast_matchers::MatchFinder *Finder) {
   // Calling make_smart_ptr from within a member function of a type with a
   // private or protected constructor would be ill-formed.
-  auto CanCallCtor = unless(has(ignoringImpCasts(
+  const auto CanCallCtor = unless(has(ignoringImpCasts(
       cxxConstructExpr(hasDeclaration(decl(unless(isPublic())))))));
 
   auto IsPlacement = hasAnyPlacementArg(anything());
@@ -256,7 +256,7 @@ void MakeSmartPtrCheck::checkReset(SourceManager &SM, ASTContext *Ctx,
 bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
                                    const CXXNewExpr *New, SourceManager &SM,
                                    ASTContext *Ctx) {
-  auto SkipParensParents = [&](const Expr *E) {
+  const auto SkipParensParents = [&](const Expr *E) {
     const TraversalKindScope RAII(*Ctx, TK_AsIs);
 
     for (const Expr *OldE = nullptr; E != OldE;) {
@@ -292,7 +292,7 @@ bool MakeSmartPtrCheck::replaceNew(DiagnosticBuilder &Diag,
   //   Foo(Bar{1, 2}) => true
   //   Foo(1) => false
   //   Foo{1} => false
-  auto HasListIntializedArgument = [](const CXXConstructExpr *CE) {
+  const auto HasListIntializedArgument = [](const CXXConstructExpr *CE) {
     for (const auto *Arg : CE->arguments()) {
       Arg = Arg->IgnoreImplicit();
 
diff --git a/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp b/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp
index f4592950fc05e..70f8014c572dc 100644
--- a/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/MinMaxUseInitializerListCheck.cpp
@@ -220,9 +220,9 @@ void MinMaxUseInitializerListCheck::storeOptions(
 }
 
 void MinMaxUseInitializerListCheck::registerMatchers(MatchFinder *Finder) {
-  auto CreateMatcher = [](const StringRef FunctionName) {
-    auto FuncDecl = functionDecl(hasName(FunctionName));
-    auto Expression = callExpr(callee(FuncDecl));
+  const auto CreateMatcher = [](const StringRef FunctionName) {
+    const auto FuncDecl = functionDecl(hasName(FunctionName));
+    const auto Expression = callExpr(callee(FuncDecl));
 
     return callExpr(callee(FuncDecl),
                     anyOf(hasArgument(0, Expression),
diff --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
index 9f2c3eb65a3ca..ebe6ba096470c 100644
--- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp
@@ -288,7 +288,8 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) {
   if (hasRValueOverload(Ctor, ParamDecl))
     return;
 
-  auto Diag = diag(ParamDecl->getBeginLoc(), "pass by value and use std::move");
+  const auto Diag =
+      diag(ParamDecl->getBeginLoc(), "pass by value and use std::move");
 
   // If we received a `const&` type, we need to rewrite the function
   // declarations.
@@ -296,7 +297,7 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) {
     // Check if we can succesfully rewrite all declarations of the constructor.
     for (const ParmVarDecl *ParmDecl : collectParamDecls(Ctor, ParamDecl)) {
       const TypeLoc ParamTL = ParmDecl->getTypeSourceInfo()->getTypeLoc();
-      auto RefTL = ParamTL.getAs<ReferenceTypeLoc>();
+      const auto RefTL = ParamTL.getAs<ReferenceTypeLoc>();
       if (RefTL.isNull()) {
         // We cannot rewrite this instance. The type is probably hidden behind
         // some `typedef`. Do not offer a fix-it in this case.
@@ -306,7 +307,7 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) {
     // Rewrite all declarations.
     for (const ParmVarDecl *ParmDecl : collectParamDecls(Ctor, ParamDecl)) {
       const TypeLoc ParamTL = ParmDecl->getTypeSourceInfo()->getTypeLoc();
-      auto RefTL = ParamTL.getAs<ReferenceTypeLoc>();
+      const auto RefTL = ParamTL.getAs<ReferenceTypeLoc>();
 
       const TypeLoc ValueTL = RefTL.getPointeeLoc();
       const CharSourceRange TypeRange = CharSourceRange::getTokenRange(
diff --git a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
index 831c8565eb74d..caca80b297a3f 100644
--- a/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -41,14 +41,14 @@ void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) {
                      this);
   Finder->addMatcher(typedefNameDecl(unless(isImplicit())).bind(TypedefId),
                      this);
-  auto ParenFunctionType = parenType(innerType(functionType()));
-  auto PointerToFunctionType = pointee(ParenFunctionType);
-  auto FunctionOrMemberPointer =
+  const auto ParenFunctionType = parenType(innerType(functionType()));
+  const auto PointerToFunctionType = pointee(ParenFunctionType);
+  const auto FunctionOrMemberPointer =
       anyOf(hasType(pointerType(PointerToFunctionType)),
             hasType(memberPointerType(PointerToFunctionType)));
   Finder->addMatcher(fieldDecl(FunctionOrMemberPointer).bind(FieldId), this);
   Finder->addMatcher(varDecl(FunctionOrMemberPointer).bind(VarId), this);
-  auto CastDestinationIsFunction =
+  const auto CastDestinationIsFunction =
       hasDestinationType(pointsTo(ParenFunctionType));
   Finder->addMatcher(
       cStyleCastExpr(CastDestinationIsFunction).bind(CStyleCastId), this);
diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
index 6af05b11bb395..b55abf5fdae43 100644
--- a/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ReplaceAutoPtrCheck.cpp
@@ -49,8 +49,9 @@ void ReplaceAutoPtrCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void ReplaceAutoPtrCheck::registerMatchers(MatchFinder *Finder) {
-  auto AutoPtrDecl = recordDecl(hasName("auto_ptr"), isInStdNamespace());
-  auto AutoPtrType = hasCanonicalType(recordType(hasDeclaration(AutoPtrDecl)));
+  const auto AutoPtrDecl = recordDecl(hasName("auto_ptr"), isInStdNamespace());
+  const auto AutoPtrType =
+      hasCanonicalType(recordType(hasDeclaration(AutoPtrDecl)));
 
   //   std::auto_ptr<int> a;
   //        ^~~~~~~~~~~~~
@@ -76,7 +77,7 @@ void ReplaceAutoPtrCheck::registerMatchers(MatchFinder *Finder) {
   //   std::auto_ptr<int> i, j;
   //   i = j;
   //   ~~~~^
-  auto MovableArgumentMatcher =
+  const auto MovableArgumentMatcher =
       expr(isLValue(), hasType(AutoPtrType)).bind(AutoPtrOwnershipTransferId);
 
   Finder->addMatcher(
@@ -107,10 +108,11 @@ void ReplaceAutoPtrCheck::check(const MatchFinder::MatchResult &Result) {
     if (Range.isInvalid())
       return;
 
-    auto Diag = diag(Range.getBegin(), "use std::move to transfer ownership")
-                << FixItHint::CreateInsertion(Range.getBegin(), "std::move(")
-                << FixItHint::CreateInsertion(Range.getEnd(), ")")
-                << Inserter.createMainFileIncludeInsertion("<utility>");
+    const auto Diag =
+        diag(Range.getBegin(), "use std::move to transfer ownership")
+        << FixItHint::CreateInsertion(Range.getBegin(), "std::move(")
+        << FixItHint::CreateInsertion(Range.getEnd(), ")")
+        << Inserter.createMainFileIncludeInsertion("<utility>");
 
     return;
   }
@@ -118,11 +120,11 @@ void ReplaceAutoPtrCheck::check(const MatchFinder::MatchResult &Result) {
   SourceLocation AutoPtrLoc;
   if (const auto *PTL = Result.Nodes.getNodeAs<TypeLoc>(AutoPtrTokenId)) {
     auto TL = *PTL;
-    if (auto QTL = TL.getAs<QualifiedTypeLoc>())
+    if (const auto QTL = TL.getAs<QualifiedTypeLoc>())
       TL = QTL.getUnqualifiedLoc();
     //   std::auto_ptr<int> i;
     //        ^
-    if (auto Loc = TL.getAs<TemplateSpecializationTypeLoc>())
+    if (const auto Loc = TL.getAs<TemplateSpecializationTypeLoc>())
       AutoPtrLoc = Loc.getTemplateNameLoc();
   } else if (const auto *D =
                  Result.Nodes.getNodeAs<UsingDecl>(AutoPtrTokenId)) {
diff --git a/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
index cfc546a06b40c..e59898d60d9d3 100644
--- a/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ReplaceRandomShuffleCheck.cpp
@@ -57,9 +57,9 @@ void ReplaceRandomShuffleCheck::check(const MatchFinder::MatchResult &Result) {
   if (MatchedCallExpr->getBeginLoc().isMacroID())
     return;
 
-  auto Diag = [&] {
+  const auto Diag = [&] {
     if (MatchedCallExpr->getNumArgs() == 3) {
-      auto DiagL =
+      const auto DiagL =
           diag(MatchedCallExpr->getBeginLoc(),
                "'std::random_shuffle' has been removed in C++17; use "
                "'std::shuffle' and an alternative random mechanism instead");
@@ -68,9 +68,10 @@ void ReplaceRandomShuffleCheck::check(const MatchFinder::MatchResult &Result) {
           "std::mt19937(std::random_device()())");
       return DiagL;
     }
-    auto DiagL = diag(MatchedCallExpr->getBeginLoc(),
-                      "'std::random_shuffle' has been removed in C++17; use "
-                      "'std::shuffle' instead");
+    const auto DiagL =
+        diag(MatchedCallExpr->getBeginLoc(),
+             "'std::random_shuffle' has been removed in C++17; use "
+             "'std::shuffle' instead");
     DiagL << FixItHint::CreateInsertion(
         MatchedCallExpr->getRParenLoc(),
         ", std::mt19937(std::random_device()())");
diff --git a/clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.cpp b/clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.cpp
index 15b64bc413be8..5e0e71ce86d11 100644
--- a/clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.cpp
@@ -28,7 +28,7 @@ void ReturnBracedInitListCheck::registerMatchers(MatchFinder *Finder) {
                                        "::std::deque", "::std::forward_list",
                                        "::std::list"))));
 
-  auto ConstructExpr =
+  const auto ConstructExpr =
       cxxConstructExpr(
           unless(anyOf(
               // Skip explicit constructor.
@@ -66,8 +66,9 @@ void ReturnBracedInitListCheck::check(const MatchFinder::MatchResult &Result) {
   if (ReturnType != ConstructType)
     return;
 
-  auto Diag = diag(Loc, "avoid repeating the return type from the "
-                        "declaration; use a braced initializer list instead");
+  const auto Diag =
+      diag(Loc, "avoid repeating the return type from the "
+                "declaration; use a braced initializer list instead");
 
   const SourceRange CallParensRange =
       MatchedConstructExpr->getParenOrBraceRange();
diff --git a/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
index 0d03006750d07..e967f576266de 100644
--- a/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp
@@ -175,11 +175,11 @@ AST_POLYMORPHIC_MATCHER(isValue, AST_POLYMORPHIC_SUPPORTED_TYPES(
 }
 
 AST_MATCHER(TypeLoc, isType) {
-  if (auto TL = Node.getAs<TypedefTypeLoc>()) {
+  if (const auto TL = Node.getAs<TypedefTypeLoc>()) {
     const auto *TD = TL.getDecl();
     return TD->getDeclName().isIdentifier() && TD->getName() == "type";
   }
-  if (auto TL = Node.getAs<DependentNameTypeLoc>())
+  if (const auto TL = Node.getAs<DependentNameTypeLoc>())
     return TL.getTypePtr()->getIdentifier()->getName() == "type";
   return false;
 }
@@ -221,10 +221,11 @@ TypeTraitsCheck::TypeTraitsCheck(StringRef Name, ClangTidyContext *Context)
       IgnoreMacros(Options.get("IgnoreMacros", false)) {}
 
 void TypeTraitsCheck::check(const MatchFinder::MatchResult &Result) {
-  auto EmitValueWarning = [this, &Result](const NestedNameSpecifierLoc &QualLoc,
+  const auto EmitValueWarning = [this,
+                                 &Result](const NestedNameSpecifierLoc &QualLoc,
                                           SourceLocation EndLoc) {
     SourceLocation TemplateNameEndLoc;
-    if (auto TSTL =
+    if (const auto TSTL =
             QualLoc.getAsTypeLoc().getAs<TemplateSpecializationTypeLoc>())
       TemplateNameEndLoc = Lexer::getLocForEndOfToken(
           TSTL.getTemplateNameLoc(), 0, *Result.SourceManager,
@@ -244,11 +245,12 @@ void TypeTraitsCheck::check(const MatchFinder::MatchResult &Result) {
         << FixItHint::CreateRemoval({QualLoc.getEndLoc(), EndLoc});
   };
 
-  auto EmitTypeWarning = [this, &Result](const NestedNameSpecifierLoc &QualLoc,
+  const auto EmitTypeWarning = [this,
+                                &Result](const NestedNameSpecifierLoc &QualLoc,
                                          SourceLocation EndLoc,
                                          SourceLocation TypenameLoc) {
     SourceLocation TemplateNameEndLoc;
-    if (auto TSTL =
+    if (const auto TSTL =
             QualLoc.getAsTypeLoc().getAs<TemplateSpecializationTypeLoc>())
       TemplateNameEndLoc = Lexer::getLocForEndOfToken(
           TSTL.getTemplateNameLoc(), 0, *Result.SourceManager,
@@ -263,7 +265,8 @@ void TypeTraitsCheck::check(const MatchFinder::MatchResult &Result) {
       diag(QualLoc.getBeginLoc(), "use c++14 style type templates");
       return;
     }
-    auto Diag = diag(QualLoc.getBeginLoc(), "use c++14 style type templates");
+    const auto Diag =
+        diag(QualLoc.getBeginLoc(), "use c++14 style type templates");
 
     if (TypenameLoc.isValid())
       Diag << FixItHint::CreateRemoval(TypenameLoc);
diff --git a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
index 1666987411790..13622b8defcf3 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseAutoCheck.cpp
@@ -188,10 +188,10 @@ static TypeMatcher nestedIterator() {
 /// Returns a TypeMatcher that matches types declared with using
 /// declarations and which name standard iterators for standard containers.
 static TypeMatcher iteratorFromUsingDeclaration() {
-  auto HasIteratorDecl = hasDeclaration(namedDecl(hasStdIteratorName()));
+  const auto HasIteratorDecl = hasDeclaration(namedDecl(hasStdIteratorName()));
   // Unwrap the nested name specifier to test for one of the standard
   // containers.
-  auto Qualifier = hasQualifier(specifiesType(templateSpecializationType(
+  const auto Qualifier = hasQualifier(specifiesType(templateSpecializationType(
       hasDeclaration(namedDecl(hasStdContainerName(), isInStdNamespace())))));
   // the named type is what comes after the final '::' in the type. It should
   // name one of the standard iterator names.
@@ -238,14 +238,14 @@ static StatementMatcher makeDeclWithTemplateCastMatcher() {
   auto ST =
       substTemplateTypeParmType(hasReplacementType(equalsBoundNode("arg")));
 
-  auto ExplicitCall =
+  const auto ExplicitCall =
       anyOf(has(memberExpr(hasExplicitTemplateArgs())),
             has(ignoringImpCasts(declRefExpr(hasExplicitTemplateArgs()))));
 
-  auto TemplateArg =
+  const auto TemplateArg =
       hasTemplateArgument(0, refersToType(qualType().bind("arg")));
 
-  auto TemplateCall = callExpr(
+  const auto TemplateCall = callExpr(
       ExplicitCall,
       callee(functionDecl(TemplateArg,
                           returns(anyOf(ST, pointsTo(ST), references(ST))))));
@@ -421,7 +421,7 @@ void UseAutoCheck::replaceExpr(
           MinTypeNameLength)
     return;
 
-  auto Diag = diag(Range.getBegin(), Message);
+  const auto Diag = diag(Range.getBegin(), Message);
 
   const bool ShouldReplenishVariableName = isMultiLevelPointerToTypeLocClasses(
       TSI->getTypeLoc(), {TypeLoc::FunctionProto, TypeLoc::ConstantArray});
diff --git a/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
index 6e2118787f9b4..a87811b368767 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseBoolLiteralsCheck.cpp
@@ -62,7 +62,7 @@ void UseBoolLiteralsCheck::check(const MatchFinder::MatchResult &Result) {
   if (InMacro && IgnoreMacros)
     return;
 
-  auto Diag =
+  const auto Diag =
       diag(Expression->getExprLoc(),
            "converting integer literal to bool, use bool literal instead");
 
diff --git a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
index 3e9c0e85fe96c..5f429ff32b3ec 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
@@ -29,7 +29,7 @@ struct EnableIfData {
 
 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;
@@ -333,7 +333,7 @@ static std::optional<std::string> getConditionText(const Expr *ConditionExpr,
   if (Invalid)
     return std::nullopt;
 
-  auto AddParens = [&](llvm::StringRef Text) -> std::string {
+  const auto AddParens = [&](llvm::StringRef Text) -> std::string {
     if (isPrimaryExpression(ConditionExpr))
       return Text.str();
     return "(" + Text.str() + ")";
diff --git a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
index cc6b7bfd4fd5b..b18c5f0084774 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -246,7 +246,7 @@ void UseDefaultMemberInitCheck::storeOptions(
 }
 
 void UseDefaultMemberInitCheck::registerMatchers(MatchFinder *Finder) {
-  auto Init = anyOf(
+  const auto Init = anyOf(
       initListExpr(anyOf(allOf(initCountIs(1), hasInit(0, allowedInitExpr())),
                          initCountIs(0), hasType(arrayType()))),
       allowedInitExpr());
@@ -318,7 +318,7 @@ void UseDefaultMemberInitCheck::checkDefaultInit(
       UseAssignment && (!ValueInit || !InitType->isEnumeralType());
   const bool NeedsBraces = !CanAssign || isa<ArrayType>(InitType);
 
-  auto Diag =
+  const auto Diag =
       diag(Field->getLocation(), "use default member initializer for %0")
       << Field;
 
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
index c37f23665b68a..fe537d14836f2 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -150,13 +150,14 @@ void UseEmplaceCheck::registerMatchers(MatchFinder *Finder) {
   // because this requires special treatment (it could cause performance
   // regression)
   // + match for emplace calls that should be replaced with insertion
-  auto CallPushBack =
+  const auto CallPushBack =
       cxxMemberCallExprOnContainer("push_back", ContainersWithPushBack);
-  auto CallPush = cxxMemberCallExprOnContainer("push", ContainersWithPush);
-  auto CallPushFront =
+  const auto CallPush =
+      cxxMemberCallExprOnContainer("push", ContainersWithPush);
+  const auto CallPushFront =
       cxxMemberCallExprOnContainer("push_front", ContainersWithPushFront);
 
-  auto CallEmplacy = cxxMemberCallExpr(
+  const auto CallEmplacy = cxxMemberCallExpr(
       hasDeclaration(
           functionDecl(hasAnyNameIgnoringTemplates(EmplacyFunctions))),
       on(hasTypeOrPointeeType(
@@ -195,7 +196,7 @@ void UseEmplaceCheck::registerMatchers(MatchFinder *Finder) {
 
   // FIXME: Discard 0/NULL (as nullptr), static inline const data members,
   // overloaded functions and template names.
-  auto SoughtConstructExpr =
+  const auto SoughtConstructExpr =
       cxxConstructExpr(
           unless(anyOf(IsCtorOfSmartPtr, HasInitList, BitFieldAsArgument,
                        InitializerListAsArgument, NewExprAsArgument,
@@ -214,7 +215,7 @@ void UseEmplaceCheck::registerMatchers(MatchFinder *Finder) {
       anyOf(has(cxxBindTemporaryExpr(HasConstructInitListExpr)),
             HasConstructInitListExpr);
 
-  auto MakeTuple = ignoringImplicit(
+  const auto MakeTuple = ignoringImplicit(
       callExpr(callee(expr(ignoringImplicit(declRefExpr(
                    unless(hasExplicitTemplateArgs()),
                    to(functionDecl(hasAnyName(TupleMakeFunctions))))))))
@@ -222,11 +223,11 @@ void UseEmplaceCheck::registerMatchers(MatchFinder *Finder) {
 
   // make_something can return type convertible to container's element type.
   // Allow the conversion only on containers of pairs.
-  auto MakeTupleCtor = ignoringImplicit(cxxConstructExpr(
+  const auto MakeTupleCtor = ignoringImplicit(cxxConstructExpr(
       has(materializeTemporaryExpr(MakeTuple)),
       hasDeclaration(cxxConstructorDecl(ofClass(hasAnyName(TupleTypes))))));
 
-  auto SoughtParam =
+  const auto SoughtParam =
       materializeTemporaryExpr(
           anyOf(has(MakeTuple), has(MakeTupleCtor), HasConstructExpr,
                 HasBracedInitListExpr,
@@ -247,7 +248,7 @@ void UseEmplaceCheck::registerMatchers(MatchFinder *Finder) {
                                has(initListExpr(hasType(hasCanonicalType(
                                    type(equalsBoundNode("value_type")))))))));
 
-  auto HasConstructExprWithValueTypeTypeAsLastArgument = hasLastArgument(
+  const auto HasConstructExprWithValueTypeTypeAsLastArgument = hasLastArgument(
       materializeTemporaryExpr(
           anyOf(HasConstructExprWithValueTypeType,
                 HasBracedInitListWithValueTypeType,
@@ -330,7 +331,7 @@ void UseEmplaceCheck::check(const MatchFinder::MatchResult &Result) {
   const auto FunctionNameSourceRange = CharSourceRange::getCharRange(
       Call->getExprLoc(), Call->getArg(0)->getExprLoc());
 
-  auto Diag =
+  const auto Diag =
       EmplacyCall
           ? diag(TemporaryExpr ? TemporaryExpr->getBeginLoc()
                  : CtorCall    ? CtorCall->getBeginLoc()
diff --git a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
index 137fdb577fca2..1535fa79676ab 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseEqualsDefaultCheck.cpp
@@ -38,7 +38,7 @@ getAllNamedFields(const CXXRecordDecl *Record) {
 static llvm::SmallPtrSet<const Type *, 0>
 getAllDirectBases(const CXXRecordDecl *Record) {
   llvm::SmallPtrSet<const Type *, 0> Result;
-  for (auto Base : Record->bases()) {
+  for (const auto Base : Record->bases()) {
     // CXXBaseSpecifier.
     const auto *BaseType = Base.getTypeSourceInfo()->getType().getTypePtr();
     Result.insert(BaseType);
@@ -68,8 +68,8 @@ static bool isCopyConstructorAndCanBeDefaulted(ASTContext *Context,
   const auto *Param = Ctor->getParamDecl(0);
 
   // Base classes and members that have to be copied.
-  auto BasesToInit = getAllDirectBases(Record);
-  auto FieldsToInit = getAllNamedFields(Record);
+  const auto BasesToInit = getAllDirectBases(Record);
+  const auto FieldsToInit = getAllNamedFields(Record);
 
   // Ensure that all the bases are copied.
   for (const auto *Base : BasesToInit) {
@@ -128,8 +128,8 @@ static bool isCopyAssignmentAndCanBeDefaulted(ASTContext *Context,
   const auto *Param = Operator->getParamDecl(0);
 
   // Base classes and members that have to be copied.
-  auto BasesToInit = getAllDirectBases(Record);
-  auto FieldsToInit = getAllNamedFields(Record);
+  const auto BasesToInit = getAllDirectBases(Record);
+  const auto FieldsToInit = getAllNamedFields(Record);
 
   const auto *Compound = cast<CompoundStmt>(Operator->getBody());
 
@@ -183,9 +183,9 @@ static bool isCopyAssignmentAndCanBeDefaulted(ASTContext *Context,
     //   Field = Other.Field;
     // Is a BinaryOperator in non-class types, and a CXXOperatorCallExpr
     // otherwise.
-    auto LHS = memberExpr(hasObjectExpression(cxxThisExpr()),
-                          member(fieldDecl(equalsNode(Field))));
-    auto RHS = accessToFieldInVar(Field, Param);
+    const auto LHS = memberExpr(hasObjectExpression(cxxThisExpr()),
+                                member(fieldDecl(equalsNode(Field))));
+    const auto RHS = accessToFieldInVar(Field, Param);
     if (match(traverse(TK_AsIs,
                        compoundStmt(has(ignoringParenImpCasts(binaryOperation(
                            hasOperatorName("="), hasLHS(LHS), hasRHS(RHS)))))),
@@ -224,7 +224,7 @@ AST_MATCHER(CXXMethodDecl, isOutOfLine) { return Node.isOutOfLine(); }
 void UseEqualsDefaultCheck::registerMatchers(MatchFinder *Finder) {
   // Skip unions/union-like classes since their constructors behave differently
   // when defaulted vs. empty.
-  auto IsUnionLikeClass = recordDecl(
+  const auto IsUnionLikeClass = recordDecl(
       anyOf(isUnion(),
             has(fieldDecl(isImplicit(), hasType(cxxRecordDecl(isUnion()))))));
 
@@ -339,7 +339,7 @@ void UseEqualsDefaultCheck::check(const MatchFinder::MatchResult &Result) {
   if (Location.isMacroID())
     Location = Body->getBeginLoc();
 
-  auto Diag = diag(
+  const auto Diag = diag(
       Location,
       "use '= default' to define a trivial %select{default constructor|copy "
       "constructor|destructor|copy-assignment operator}0");
diff --git a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
index 574cbea46124b..69ef4c70c3377 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
@@ -38,7 +38,7 @@ intCastExpression(bool IsSigned, StringRef CastBindName = {}) {
   // std::cmp_{} functions trigger a compile-time error if either LHS or RHS
   // is a non-integer type, char, enum or bool
   // (unsigned char/ signed char are Ok and can be used).
-  auto IntTypeExpr = expr(hasType(hasCanonicalType(qualType(
+  const auto IntTypeExpr = expr(hasType(hasCanonicalType(qualType(
       IsSigned ? isSignedInteger() : isUnsignedInteger(),
       unless(isActualChar()), unless(booleanType()), unless(enumType())))));
 
diff --git a/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
index 7e8d98241118a..5ecc5a773fda4 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNodiscardCheck.cpp
@@ -82,7 +82,7 @@ void UseNodiscardCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void UseNodiscardCheck::registerMatchers(MatchFinder *Finder) {
-  auto FunctionObj =
+  const auto FunctionObj =
       cxxRecordDecl(hasAnyName("::std::function", "::boost::function"));
 
   // Find all non-void const methods which have not already been marked to
@@ -118,8 +118,8 @@ void UseNodiscardCheck::check(const MatchFinder::MatchResult &Result) {
 
   ASTContext &Context = *Result.Context;
 
-  auto Diag = diag(RetLoc, "function %0 should be marked %1")
-              << MatchedDecl << NoDiscardMacro;
+  const auto Diag = diag(RetLoc, "function %0 should be marked %1")
+                    << MatchedDecl << NoDiscardMacro;
 
   // Check for the existence of the keyword being used as the ``[[nodiscard]]``.
   if (!doesNoDiscardMacroExist(Context, NoDiscardMacro))
diff --git a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
index cc371a1ab55a7..6ed831e6c24b0 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseNullptrCheck.cpp
@@ -56,7 +56,7 @@ makeCastSequenceMatcher(llvm::ArrayRef<StringRef> NameList) {
       unless(hasImplicitDestinationType(
           qualType(matchers::matchesAnyListedTypeName(NameList)))));
 
-  auto IsOrHasDescendant = [](const auto &InnerMatcher) {
+  const auto IsOrHasDescendant = [](const auto &InnerMatcher) {
     return anyOf(InnerMatcher, hasDescendant(InnerMatcher));
   };
 
diff --git a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
index dd516f8e51264..a684025b88ce6 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
@@ -35,10 +35,10 @@ void UseOverrideCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void UseOverrideCheck::registerMatchers(MatchFinder *Finder) {
-  auto IgnoreDestructorMatcher =
+  const auto IgnoreDestructorMatcher =
       IgnoreDestructors ? cxxMethodDecl(unless(cxxDestructorDecl()))
                         : cxxMethodDecl();
-  auto IgnoreTemplateInstantiationsMatcher =
+  const auto IgnoreTemplateInstantiationsMatcher =
       IgnoreTemplateInstantiations
           ? cxxMethodDecl(unless(ast_matchers::isTemplateInstantiation()))
           : cxxMethodDecl();
@@ -127,8 +127,8 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
                   .str();
   }
 
-  auto Diag = diag(Method->getLocation(), Message)
-              << OverrideSpelling << FinalSpelling;
+  const auto Diag = diag(Method->getLocation(), Message)
+                    << OverrideSpelling << FinalSpelling;
 
   const CharSourceRange FileRange = Lexer::makeFileCharRange(
       CharSourceRange::getTokenRange(Method->getSourceRange()), Sources,
@@ -139,7 +139,7 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
 
   // FIXME: Instead of re-lexing and looking for the 'virtual' token,
   // store the location of 'virtual' in each FunctionDecl.
-  SmallVector<Token, 16> Tokens = parseTokens(FileRange, Result);
+  const SmallVector<Token, 16> Tokens = parseTokens(FileRange, Result);
 
   // Add 'override' on inline declarations that don't already have it.
   if (!HasFinal && !HasOverride) {
diff --git a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
index 8849c331608f9..bee376ec91255 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
@@ -65,7 +65,7 @@ findLocksInCompoundStmt(const CompoundStmt *Block,
   llvm::SmallVector<llvm::SmallVector<const VarDecl *>> LockGuardGroups;
   llvm::SmallVector<const VarDecl *> CurrentLockGuardGroup;
 
-  auto AddAndClearCurrentGroup = [&]() {
+  const auto AddAndClearCurrentGroup = [&]() {
     if (!CurrentLockGuardGroup.empty()) {
       LockGuardGroups.push_back(CurrentLockGuardGroup);
       CurrentLockGuardGroup.clear();
@@ -208,7 +208,7 @@ void UseScopedLockCheck::check(const MatchFinder::MatchResult &Result) {
 
 void UseScopedLockCheck::diagOnSingleLock(
     const VarDecl *LockGuard, const MatchFinder::MatchResult &Result) {
-  auto Diag = diag(LockGuard->getBeginLoc(), UseScopedLockMessage);
+  const auto Diag = diag(LockGuard->getBeginLoc(), UseScopedLockMessage);
 
   const SourceRange LockGuardTypeRange =
       getLockGuardRange(LockGuard->getTypeSourceInfo());
@@ -278,7 +278,7 @@ void UseScopedLockCheck::diagOnSourceInfo(
   const TypeLoc TL = LockGuardSourceInfo->getTypeLoc();
 
   if (const auto TTL = TL.getAs<TemplateSpecializationTypeLoc>()) {
-    auto Diag = diag(TTL.getBeginLoc(), UseScopedLockMessage);
+    const auto Diag = diag(TTL.getBeginLoc(), UseScopedLockMessage);
 
     const SourceRange LockGuardRange =
         getLockGuardNameRange(LockGuardSourceInfo);
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
index eebd609cc84a8..ffe9913fba2c1 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
@@ -247,8 +247,9 @@ void UseStartsEndsWithCheck::check(const MatchFinder::MatchResult &Result) {
       CharSourceRange::getTokenRange(SearchExpr->getSourceRange()),
       *Result.SourceManager, Result.Context->getLangOpts());
 
-  auto Diagnostic = diag(FindExpr->getExprLoc(), "use %0 instead of %1")
-                    << ReplacementFunction->getName() << FindFun->getName();
+  const auto Diagnostic = diag(FindExpr->getExprLoc(), "use %0 instead of %1")
+                          << ReplacementFunction->getName()
+                          << FindFun->getName();
 
   // Remove everything before the function call.
   Diagnostic << FixItHint::CreateRemoval(CharSourceRange::getCharRange(
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
index 2b84dcbe4eab8..952259ac7b126 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.cpp
@@ -91,7 +91,7 @@ struct MatchBuilder {
 
   auto matchMathCall(const StringRef FunctionName,
                      const Matcher<clang::Expr> &ArgumentMatcher) const {
-    auto HasAnyPrecisionName = hasAnyName(
+    const auto HasAnyPrecisionName = hasAnyName(
         FunctionName, (FunctionName + "l").str(),
         (FunctionName + "f").str()); // Support long double(l) and float(f).
     return expr(ignoreParenAndFloatingCasting(
diff --git a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
index 8ff94709d2529..8964cc7b45650 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
@@ -71,7 +71,7 @@ struct UnqualNameVisitor : public RecursiveASTVisitor<UnqualNameVisitor> {
     case TypeLoc::InjectedClassName:
     case TypeLoc::Record:
     case TypeLoc::Enum: {
-      auto TTL = TL.getAs<TagTypeLoc>();
+      const auto TTL = TL.getAs<TagTypeLoc>();
       const auto *T = TTL.getTypePtr();
       if (T->getKeyword() != ElaboratedTypeKeyword::None ||
           TTL.getQualifierLoc())
@@ -81,7 +81,7 @@ struct UnqualNameVisitor : public RecursiveASTVisitor<UnqualNameVisitor> {
       break;
     }
     case TypeLoc::TemplateSpecialization: {
-      auto TTL = TL.getAs<TemplateSpecializationTypeLoc>();
+      const auto TTL = TL.getAs<TemplateSpecializationTypeLoc>();
       const auto *T = TTL.getTypePtr();
       if (T->getKeyword() != ElaboratedTypeKeyword::None ||
           TTL.getQualifierLoc())
@@ -91,7 +91,7 @@ struct UnqualNameVisitor : public RecursiveASTVisitor<UnqualNameVisitor> {
       break;
     }
     case TypeLoc::Typedef: {
-      auto TTL = TL.getAs<TypedefTypeLoc>();
+      const auto TTL = TL.getAs<TypedefTypeLoc>();
       const auto *T = TTL.getTypePtr();
       if (T->getKeyword() != ElaboratedTypeKeyword::None ||
           TTL.getQualifierLoc())
@@ -101,7 +101,7 @@ struct UnqualNameVisitor : public RecursiveASTVisitor<UnqualNameVisitor> {
       break;
     }
     case TypeLoc::Using: {
-      auto TTL = TL.getAs<UsingTypeLoc>();
+      const auto TTL = TL.getAs<UsingTypeLoc>();
       const auto *T = TTL.getTypePtr();
       if (T->getKeyword() != ElaboratedTypeKeyword::None ||
           TTL.getQualifierLoc())
@@ -471,7 +471,7 @@ void UseTrailingReturnTypeCheck::storeOptions(
 }
 
 void UseTrailingReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
-  auto F =
+  const auto F =
       functionDecl(
           unless(anyOf(
               hasTrailingReturn(), returns(voidType()), cxxConversionDecl(),
@@ -537,7 +537,7 @@ void UseTrailingReturnTypeCheck::check(const MatchFinder::MatchResult &Result) {
   if (!TSI)
     return;
 
-  auto FTL = TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>();
+  const auto FTL = TSI->getTypeLoc().IgnoreParens().getAs<FunctionTypeLoc>();
   if (!FTL) {
     // FIXME: This may happen if we have __attribute__((...)) on the function.
     // We abort for now. Remove this when the function type location gets
diff --git a/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
index 9623c885534a6..73d602b7e4e40 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTransparentFunctorsCheck.cpp
@@ -106,7 +106,7 @@ void UseTransparentFunctorsCheck::check(
   if (ArgNum == FunctorParentType->template_arguments().size())
     return;
   const TemplateArgumentLoc FunctorLoc = FunctorParentLoc.getArgLoc(ArgNum);
-  auto FunctorTypeLoc = getInnerTypeLocAs<TemplateSpecializationTypeLoc>(
+  const auto FunctorTypeLoc = getInnerTypeLocAs<TemplateSpecializationTypeLoc>(
       FunctorLoc.getTypeSourceInfo()->getTypeLoc());
   if (FunctorTypeLoc.isNull())
     return;
diff --git a/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
index ae61ffa3ba863..c382334925be5 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUncaughtExceptionsCheck.cpp
@@ -29,7 +29,7 @@ void UseUncaughtExceptionsCheck::registerMatchers(MatchFinder *Finder) {
           .bind("decl_ref_expr"),
       this);
 
-  auto DirectCallToUncaughtException = callee(expr(ignoringImpCasts(
+  const auto DirectCallToUncaughtException = callee(expr(ignoringImpCasts(
       declRefExpr(hasDeclaration(functionDecl(hasName(MatchText)))))));
 
   // CallExpr: warning, fix-it.
@@ -69,8 +69,9 @@ void UseUncaughtExceptionsCheck::check(const MatchFinder::MatchResult &Result) {
     EndLoc = U->getNameInfo().getEndLoc();
   }
 
-  auto Diag = diag(BeginLoc, "'std::uncaught_exception' is deprecated, use "
-                             "'std::uncaught_exceptions' instead");
+  const auto Diag =
+      diag(BeginLoc, "'std::uncaught_exception' is deprecated, use "
+                     "'std::uncaught_exceptions' instead");
 
   if (!BeginLoc.isMacroID()) {
     StringRef Text =
diff --git a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
index 085dbde60db61..e384a75de4433 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseUsingCheck.cpp
@@ -212,10 +212,10 @@ void UseUsingCheck::check(const MatchFinder::MatchResult &Result) {
     LastReplacementEnd = ReplaceRange.getEnd().getLocWithOffset(Offset);
   }
 
-  auto Diag = diag(ReplaceRange.getBegin(), UseUsingWarning);
+  const auto Diag = diag(ReplaceRange.getBegin(), UseUsingWarning);
 
   // If typedef contains a full tag declaration, extract its full text.
-  auto LastTagDeclRange = LastTagDeclRanges.find(ParentDecl);
+  const auto LastTagDeclRange = LastTagDeclRanges.find(ParentDecl);
   if (LastTagDeclRange != LastTagDeclRanges.end() &&
       LastTagDeclRange->second.isValid() &&
       ReplaceRange.fullyContains(LastTagDeclRange->second)) {
diff --git a/clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp b/clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp
index 632185295b12f..0e2843cc55459 100644
--- a/clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp
+++ b/clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp
@@ -37,8 +37,8 @@ void BufferDerefCheck::check(const MatchFinder::MatchResult &Result) {
 
   // Adds the type and expression of a buffer that is used in the MPI call
   // expression to the captured containers.
-  auto AddBuffer = [&CE, &Result, &BufferTypes,
-                    &BufferExprs](const size_t BufferIdx) {
+  const auto AddBuffer = [&CE, &Result, &BufferTypes,
+                          &BufferExprs](const size_t BufferIdx) {
     // Skip null pointer constants and in place 'operators'.
     if (CE->getArg(BufferIdx)->isNullPointerConstant(
             *Result.Context, Expr::NPC_ValueDependentIsNull) ||
diff --git a/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp b/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
index 370a54d892809..4b360978391d2 100644
--- a/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
+++ b/clang-tools-extra/clang-tidy/mpi/TypeMismatchCheck.cpp
@@ -255,8 +255,9 @@ void TypeMismatchCheck::check(const MatchFinder::MatchResult &Result) {
 
   // Adds a buffer, MPI datatype pair of an MPI call expression to the
   // containers. For buffers, the type and expression is captured.
-  auto AddPair = [&CE, &Result, &BufferTypes, &BufferExprs, &MPIDatatypes](
-                     const size_t BufferIdx, const size_t DatatypeIdx) {
+  const auto AddPair = [&CE, &Result, &BufferTypes, &BufferExprs,
+                        &MPIDatatypes](const size_t BufferIdx,
+                                       const size_t DatatypeIdx) {
     // Skip null pointer constants and in place 'operators'.
     if (CE->getArg(BufferIdx)->isNullPointerConstant(
             *Result.Context, Expr::NPC_ValueDependentIsNull) ||
diff --git a/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp b/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp
index a9e6a4b9ea9bb..62936df6d8650 100644
--- a/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/AssertEqualsCheck.cpp
@@ -41,7 +41,7 @@ void AssertEqualsCheck::check(
     if (const auto *Root = Result.Nodes.getNodeAs<BinaryOperator>(CurrName)) {
       const SourceManager *Sm = Result.SourceManager;
       // The macros are nested two levels, so going up twice.
-      auto MacroCallsite = Sm->getImmediateMacroCallerLoc(
+      const auto MacroCallsite = Sm->getImmediateMacroCallerLoc(
           Sm->getImmediateMacroCallerLoc(Root->getBeginLoc()));
       diag(MacroCallsite,
            (Twine("use ") + TargetName + " for comparing objects").str())
diff --git a/clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp b/clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp
index 69caaed2b8542..a66787eb80b1d 100644
--- a/clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/NSInvocationArgumentLifetimeCheck.cpp
@@ -125,10 +125,11 @@ void NSInvocationArgumentLifetimeCheck::check(
     const MatchFinder::MatchResult &Result) {
   const auto *MatchedExpr = Result.Nodes.getNodeAs<ObjCMessageExpr>("call");
 
-  auto Diag = diag(MatchedExpr->getArg(0)->getBeginLoc(),
-                   "NSInvocation %objcinstance0 should only pass pointers to "
-                   "objects with ownership __unsafe_unretained")
-              << MatchedExpr->getSelector();
+  const auto Diag =
+      diag(MatchedExpr->getArg(0)->getBeginLoc(),
+           "NSInvocation %objcinstance0 should only pass pointers to "
+           "objects with ownership __unsafe_unretained")
+      << MatchedExpr->getSelector();
 
   // Only provide fix-it hints for references to local variables; fixes for
   // instance variable references don't have as clear an automated fix.
diff --git a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp b/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
index e8c49eed190f3..dea9598175f58 100644
--- a/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/PropertyDeclarationCheck.cpp
@@ -79,7 +79,7 @@ static std::string validPropertyNameRegex(bool UsedInMatcher) {
 }
 
 static bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
-  auto RegexExp =
+  const auto RegexExp =
       llvm::Regex("^[a-zA-Z][a-zA-Z0-9]*_[a-zA-Z0-9][a-zA-Z0-9_]+$");
   return RegexExp.match(PropertyName);
 }
@@ -87,10 +87,11 @@ static bool hasCategoryPropertyPrefix(llvm::StringRef PropertyName) {
 static bool prefixedPropertyNameValid(llvm::StringRef PropertyName) {
   const size_t Start = PropertyName.find_first_of('_');
   assert(Start != llvm::StringRef::npos && Start + 1 < PropertyName.size());
-  auto Prefix = PropertyName.substr(0, Start);
+  const auto Prefix = PropertyName.substr(0, Start);
   if (Prefix.lower() != Prefix)
     return false;
-  auto RegexExp = llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
+  const auto RegexExp =
+      llvm::Regex(llvm::StringRef(validPropertyNameRegex(false)));
   return RegexExp.match(PropertyName.substr(Start + 1));
 }
 
diff --git a/clang-tools-extra/clang-tidy/objc/SuperSelfCheck.cpp b/clang-tools-extra/clang-tidy/objc/SuperSelfCheck.cpp
index 3887afe703389..edd6f3f14464e 100644
--- a/clang-tools-extra/clang-tidy/objc/SuperSelfCheck.cpp
+++ b/clang-tools-extra/clang-tidy/objc/SuperSelfCheck.cpp
@@ -85,10 +85,11 @@ void SuperSelfCheck::registerMatchers(MatchFinder *Finder) {
 void SuperSelfCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *Message = Result.Nodes.getNodeAs<ObjCMessageExpr>("message");
 
-  auto Diag = diag(Message->getExprLoc(), "suspicious invocation of %0 in "
-                                          "initializer; did you mean to "
-                                          "invoke a superclass initializer?")
-              << Message->getMethodDecl();
+  const auto Diag =
+      diag(Message->getExprLoc(), "suspicious invocation of %0 in "
+                                  "initializer; did you mean to "
+                                  "invoke a superclass initializer?")
+      << Message->getMethodDecl();
 
   const SourceLocation ReceiverLoc = Message->getReceiverRange().getBegin();
   if (ReceiverLoc.isMacroID() || ReceiverLoc.isInvalid())
diff --git a/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp b/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
index 747994c9a3c7f..5b09292047dd8 100644
--- a/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
@@ -50,9 +50,9 @@ void AvoidEndlCheck::check(const MatchFinder::MatchResult &Result) {
         TokenRange, *Result.SourceManager, Result.Context->getLangOpts());
     if (SourceText.empty())
       SourceText = "std::endl";
-    auto Diag = diag(Expression->getBeginLoc(),
-                     "do not use '%0' with streams; use '\\n' instead")
-                << SourceText;
+    const auto Diag = diag(Expression->getBeginLoc(),
+                           "do not use '%0' with streams; use '\\n' instead")
+                      << SourceText;
     if (TokenRange.isValid())
       Diag << FixItHint::CreateReplacement(TokenRange, "'\\n'");
   } else {
@@ -66,9 +66,9 @@ void AvoidEndlCheck::check(const MatchFinder::MatchResult &Result) {
         *Result.SourceManager, Result.Context->getLangOpts());
     if (SourceText.empty())
       SourceText = "std::endl";
-    auto Diag = diag(CallExpression->getBeginLoc(),
-                     "do not use '%0' with streams; use '\\n' instead")
-                << SourceText;
+    const auto Diag = diag(CallExpression->getBeginLoc(),
+                           "do not use '%0' with streams; use '\\n' instead")
+                      << SourceText;
 
     const CharSourceRange ArgTokenRange = CharSourceRange::getTokenRange(
         CallExpression->getArg(0)->getSourceRange());
diff --git a/clang-tools-extra/clang-tidy/performance/EnumSizeCheck.cpp b/clang-tools-extra/clang-tidy/performance/EnumSizeCheck.cpp
index 8147ae4163ea7..4f7e6ca5a19be 100644
--- a/clang-tools-extra/clang-tidy/performance/EnumSizeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/EnumSizeCheck.cpp
@@ -117,7 +117,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/FasterStringFindCheck.cpp b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
index 7c90130c826f0..27afc0d7b7e42 100644
--- a/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
@@ -25,12 +25,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/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 814a4f854319c..fa13bdd4765bd 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/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/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 d4566bc59b7e5..f3d19a1f7a5b1 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitializationCheck.cpp
@@ -58,10 +58,11 @@ static void recordRemoval(const DeclStmt &Stmt, ASTContext &Context,
   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;
@@ -120,7 +121,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(),
@@ -162,7 +163,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
@@ -188,7 +189,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);
@@ -232,7 +233,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 ffb2a81b862f6..f0bf9e084c730 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/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 ff58505e8f87c..c2791a17f080c 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 5207c99c10d83..4462061ed8e8c 100644
--- a/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/BracesAroundStatementsCheck.cpp
@@ -158,8 +158,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 cfdf0e9c4a331..bd13e8323fd60 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 efcf13d63b4ff..b5ea7a28c7a7d 100644
--- a/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ContainerContainsCheck.cpp
@@ -47,7 +47,7 @@ void ContainerContainsCheck::registerMatchers(MatchFinder *Finder) {
   const auto StringNpos = anyOf(declRefExpr(to(varDecl(hasName("npos")))),
                                 memberExpr(member(hasName("npos"))));
 
-  auto AddSimpleMatcher = [&](const auto &Matcher) {
+  const auto AddSimpleMatcher = [&](const auto &Matcher) {
     Finder->addMatcher(traverse(TK_IgnoreUnlessSpelledInSource, Matcher), this);
   };
 
@@ -116,8 +116,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 073fdce5018bf..55d88ff357e24 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()))),
@@ -389,8 +389,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;
diff --git a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
index e96bfe7fe7271..394f82c266760 100644
--- a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
@@ -49,7 +49,7 @@ void DeleteNullPointerCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *IfWithDelete = Result.Nodes.getNodeAs<IfStmt>("ifWithDelete");
   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 (IfWithDelete->getElse())
diff --git a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
index fccda912947eb..c1b048ae7de45 100644
--- a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -113,10 +113,10 @@ static bool containsDeclInScope(const Stmt *Node) {
 
 static void removeElseAndBrackets(DiagnosticBuilder &Diag, ASTContext &Context,
                                   const Stmt *Else, SourceLocation ElseLoc) {
-  auto Remap = [&](SourceLocation Loc) {
+  const auto Remap = [&](SourceLocation Loc) {
     return Context.getSourceManager().getExpansionLoc(Loc);
   };
-  auto TokLen = [&](SourceLocation Loc) {
+  const auto TokLen = [&](SourceLocation Loc) {
     return Lexer::MeasureTokenLength(Loc, Context.getSourceManager(),
                                      Context.getLangOpts());
   };
@@ -195,7 +195,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/IdentifierNamingCheck.cpp b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
index 9cee6ddb93d4d..5f12be149262d 100644
--- a/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
@@ -264,7 +264,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;
@@ -305,7 +305,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;
@@ -404,7 +404,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");
@@ -432,7 +432,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;
 
@@ -1034,7 +1034,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())
@@ -1047,7 +1047,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 =
@@ -1415,7 +1415,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;
@@ -1430,21 +1430,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 llvm::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 a0b15603b36e8..7ed4daf965765 100644
--- a/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ImplicitBoolConversionCheck.cpp
@@ -269,7 +269,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),
@@ -322,9 +322,10 @@ 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)))));
+  const auto BitfieldConstruct =
+      cxxConstructorDecl(hasDescendant(cxxCtorInitializer(
+          withInitializer(equalsBoundNode("implicitCastFromBool")),
+          forField(hasBitWidth(1)))));
   Finder->addMatcher(
       traverse(
           TK_AsIs,
diff --git a/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp b/clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp
index e406532d78a01..ae54138bf20d2 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,
                   "differing 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 fa5a0b7cd3647..0105648ed9b33 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 2e6edd706b131..1c560d508bdea 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 1d52aaa6de008..1fd8ceb164512 100644
--- a/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/MathMissingParenthesesCheck.cpp
@@ -71,7 +71,7 @@ static void addParentheses(const Expr *E, const BinaryOperator *ParentBinOp,
     const clang::SourceLocation EndLoc =
         clang::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 46f11027c970e..71b941a0964d0 100644
--- a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
@@ -90,10 +90,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 a8767db4a4ffc..072a2cf4a722b 100644
--- a/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
@@ -126,7 +126,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;
 }
@@ -223,7 +223,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 9390c29c27f48..5c26be80ca9f4 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,
          llvm::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,
          llvm::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(
@@ -197,7 +198,7 @@ void QualifiedAutoCheck::check(const MatchFinder::MatchResult &Result) {
       return;
 
     llvm::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 eae0b3f6d0e7d..3db0ea2d57ecd 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp
@@ -156,9 +156,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 1bbb9c86fee14..fb55ed18b2cb8 100644
--- a/clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/RedundantMemberInitCheck.cpp
@@ -39,7 +39,7 @@ void RedundantMemberInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 }
 
 void RedundantMemberInitCheck::registerMatchers(MatchFinder *Finder) {
-  auto ConstructorMatcher =
+  const auto ConstructorMatcher =
       cxxConstructExpr(
           argumentCountIs(0),
           hasDeclaration(cxxConstructorDecl(
@@ -49,7 +49,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(
diff --git a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp
index 4469e564e83f9..64f8c18ba01bd 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)
@@ -394,8 +394,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 {};
@@ -411,7 +411,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 {};
         };
@@ -637,8 +637,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());
@@ -966,7 +967,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 6091e162cd4c0..153f10fe572c3 100644
--- a/clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
@@ -49,7 +49,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 e1a73aa47919e..dcf43185caf9d 100644
--- a/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp
@@ -500,12 +500,12 @@ SuspiciousCallArgumentCheck::SuspiciousCallArgumentCheck(
     : ClangTidyCheck(Name, Context),
       MinimumIdentifierNameLength(Options.get(
           "MinimumIdentifierNameLength", DefaultMinimumIdentifierNameLength)) {
-  auto GetToggleOpt = [this](Heuristic H) -> bool {
+  const auto GetToggleOpt = [this](Heuristic H) -> bool {
     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 {
+  const auto GetBoundOpt = [this](Heuristic H, BoundKind BK) -> int8_t {
     auto Idx = static_cast<std::size_t>(H);
     assert(Idx < HeuristicCount);
 
@@ -518,7 +518,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),
@@ -554,7 +554,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);
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 6463a82ff68f1..92f03027e660a 100644
--- a/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
@@ -83,7 +83,7 @@ getNewSuffix(llvm::StringRef OldSuffix,
   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);
       });
@@ -213,9 +213,10 @@ bool UppercaseLiteralSuffixCheck::checkBoundMatch(
           *Literal, NewSuffixes, *Result.SourceManager, getLangOpts())) {
     if (Details->LiteralLocation.getBegin().isMacroID() && IgnoreMacros)
       return true;
-    auto Complaint = diag(Details->LiteralLocation.getBegin(),
-                          "%0 literal has suffix '%1', which is not uppercase")
-                     << LiteralType::Name << Details->OldSuffix;
+    const auto Complaint =
+        diag(Details->LiteralLocation.getBegin(),
+             "%0 literal has suffix '%1', which is not uppercase")
+        << LiteralType::Name << 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 63649150b17e3..9451ae2077660 100644
--- a/clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UseAnyOfAllOfCheck.cpp
@@ -40,13 +40,13 @@ AST_MATCHER_P(Stmt, nextStmt, ast_matchers::internal::Matcher<Stmt>,
 namespace tidy::readability {
 
 void UseAnyOfAllOfCheck::registerMatchers(MatchFinder *Finder) {
-  auto Returns = [](bool V) {
+  const auto Returns = [](bool V) {
     return returnStmt(hasReturnValue(cxxBoolLiteral(equals(V))));
   };
 
-  auto ReturnsButNotTrue =
+  const auto ReturnsButNotTrue =
       returnStmt(hasReturnValue(unless(cxxBoolLiteral(equals(true)))));
-  auto ReturnsButNotFalse =
+  const auto ReturnsButNotFalse =
       returnStmt(hasReturnValue(unless(cxxBoolLiteral(equals(false)))));
 
   Finder->addMatcher(
diff --git a/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp b/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
index 6255bbd9e5778..ea51fae4d216f 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();
   const SourceLocation ThenLocation = If->getEndLoc();
 
-  auto ReplaceAndDiagnose = [&](const llvm::StringRef FunctionName) {
+  const auto ReplaceAndDiagnose = [&](const llvm::StringRef FunctionName) {
     const SourceManager &Source = *Result.SourceManager;
     llvm::SmallString<64> Comment;
 
diff --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index 2b2e53dc0be19..1a4a4a4cb8c67 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -437,7 +437,7 @@ createOptionsProvider(llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS) {
   if (RemovedArgs.getNumOccurrences() > 0)
     OverrideOptions.RemovedArgs = RemovedArgs;
 
-  auto LoadConfig =
+  const auto LoadConfig =
       [&](StringRef Configuration,
           StringRef Source) -> std::unique_ptr<ClangTidyOptionsProvider> {
     llvm::ErrorOr<ClangTidyOptions> ParsedConfig =
@@ -502,7 +502,7 @@ getVfsFromFile(const std::string &OverlayFile, vfs::FileSystem &BaseFS) {
 static StringRef closest(StringRef Value, const StringSet<> &Allowed) {
   unsigned MaxEdit = 5U;
   StringRef Closest;
-  for (auto Item : Allowed.keys()) {
+  for (const auto Item : Allowed.keys()) {
     const unsigned Cur = Value.edit_distance_insensitive(Item, true, MaxEdit);
     if (Cur < MaxEdit) {
       Closest = Item;
@@ -566,7 +566,7 @@ static bool verifyOptions(const llvm::StringSet<> &ValidOptions,
                           const ClangTidyOptions::OptionMap &OptionMap,
                           StringRef Source) {
   bool AnyInvalid = false;
-  for (auto Key : OptionMap.keys()) {
+  for (const auto Key : OptionMap.keys()) {
     if (ValidOptions.contains(Key))
       continue;
     AnyInvalid = true;
diff --git a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
index 3510b3546bbba..e8eb4705343bd 100644
--- a/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
@@ -343,10 +343,11 @@ AST_MATCHER_P(DeclRefExpr, doesNotMutateObject, int, Indirections) {
 SmallPtrSet<const DeclRefExpr *, 16>
 constReferenceDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt,
                            ASTContext &Context, int Indirections) {
-  auto Matches = match(findAll(declRefExpr(to(varDecl(equalsNode(&VarDecl))),
-                                           doesNotMutateObject(Indirections))
-                                   .bind("declRef")),
-                       Stmt, Context);
+  const auto Matches =
+      match(findAll(declRefExpr(to(varDecl(equalsNode(&VarDecl))),
+                                doesNotMutateObject(Indirections))
+                        .bind("declRef")),
+            Stmt, Context);
   SmallPtrSet<const DeclRefExpr *, 16> DeclRefs;
   extractNodesByIdTo(Matches, "declRef", DeclRefs);
 
@@ -360,15 +361,15 @@ bool isOnlyUsedAsConst(const VarDecl &Var, const Stmt &Stmt,
   // reference parameter.
   // If the difference is empty it is safe for the loop variable to be a const
   // reference.
-  auto AllDeclRefs = allDeclRefExprs(Var, Stmt, Context);
-  auto ConstReferenceDeclRefs =
+  const auto AllDeclRefs = allDeclRefExprs(Var, Stmt, Context);
+  const auto ConstReferenceDeclRefs =
       constReferenceDeclRefExprs(Var, Stmt, Context, Indirections);
   return isSetDifferenceEmpty(AllDeclRefs, ConstReferenceDeclRefs);
 }
 
 SmallPtrSet<const DeclRefExpr *, 16>
 allDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt, ASTContext &Context) {
-  auto Matches = match(
+  const auto Matches = match(
       findAll(declRefExpr(to(varDecl(equalsNode(&VarDecl)))).bind("declRef")),
       Stmt, Context);
   SmallPtrSet<const DeclRefExpr *, 16> DeclRefs;
@@ -378,7 +379,7 @@ allDeclRefExprs(const VarDecl &VarDecl, const Stmt &Stmt, ASTContext &Context) {
 
 SmallPtrSet<const DeclRefExpr *, 16>
 allDeclRefExprs(const VarDecl &VarDecl, const Decl &Decl, ASTContext &Context) {
-  auto Matches = match(
+  const auto Matches = match(
       decl(forEachDescendant(
           declRefExpr(to(varDecl(equalsNode(&VarDecl)))).bind("declRef"))),
       Decl, Context);
@@ -389,10 +390,10 @@ allDeclRefExprs(const VarDecl &VarDecl, const Decl &Decl, ASTContext &Context) {
 
 bool isCopyConstructorArgument(const DeclRefExpr &DeclRef, const Decl &Decl,
                                ASTContext &Context) {
-  auto UsedAsConstRefArg = forEachArgumentWithParam(
+  const auto UsedAsConstRefArg = forEachArgumentWithParam(
       declRefExpr(equalsNode(&DeclRef)),
       parmVarDecl(hasType(matchers::isReferenceToConst())));
-  auto Matches = match(
+  const auto Matches = match(
       decl(hasDescendant(
           cxxConstructExpr(UsedAsConstRefArg, hasDeclaration(cxxConstructorDecl(
                                                   isCopyConstructor())))
@@ -403,10 +404,10 @@ bool isCopyConstructorArgument(const DeclRefExpr &DeclRef, const Decl &Decl,
 
 bool isCopyAssignmentArgument(const DeclRefExpr &DeclRef, const Decl &Decl,
                               ASTContext &Context) {
-  auto UsedAsConstRefArg = forEachArgumentWithParam(
+  const auto UsedAsConstRefArg = forEachArgumentWithParam(
       declRefExpr(equalsNode(&DeclRef)),
       parmVarDecl(hasType(matchers::isReferenceToConst())));
-  auto Matches = match(
+  const auto Matches = match(
       decl(hasDescendant(
           cxxOperatorCallExpr(UsedAsConstRefArg, hasOverloadedOperatorName("="),
                               callee(cxxMethodDecl(isCopyAssignmentOperator())))
diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
index f766a1bca655c..0329f43a3b3de 100644
--- a/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ b/clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -253,8 +253,8 @@ static bool isQualificationConvertiblePointer(QualType From, QualType To,
 
   int I = 0;
   bool ConstUntilI = true;
-  auto SatisfiesCVRules = [&I, &ConstUntilI](const QualType &From,
-                                             const QualType &To) {
+  const auto SatisfiesCVRules = [&I, &ConstUntilI](const QualType &From,
+                                                   const QualType &To) {
     if (I > 1) {
       if (From.getQualifiers() != To.getQualifiers() && !ConstUntilI)
         return false;
diff --git a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
index 5fcf5ed30fb81..5288cb7bbf33d 100644
--- a/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/FixItHintUtils.cpp
@@ -19,7 +19,7 @@ namespace clang::tidy::utils::fixit {
 
 FixItHint changeVarDeclToReference(const VarDecl &Var, ASTContext &Context) {
   SourceLocation AmpLocation = Var.getLocation();
-  auto Token = utils::lexer::getPreviousToken(
+  const auto Token = utils::lexer::getPreviousToken(
       AmpLocation, Context.getSourceManager(), Context.getLangOpts());
 
   // For parameter packs the '&' must go before the '...' token
@@ -52,7 +52,7 @@ skipLParensBackwards(SourceLocation Start, const ASTContext &Context) {
   if (locDangerous(Start))
     return std::nullopt;
 
-  auto PreviousTokenLParen = [&Start, &Context]() {
+  const auto PreviousTokenLParen = [&Start, &Context]() {
     Token T;
     T = lexer::getPreviousToken(Start, Context.getSourceManager(),
                                 Context.getLangOpts());
diff --git a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
index a4251d5249e4a..e6249a4ff4e98 100644
--- a/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp
@@ -161,7 +161,7 @@ IncludeSorter::createIncludeInsertion(StringRef FileName, bool IsAngled) {
         SourceMgr->getLocForStartOfFile(CurrentFileID), IncludeStmt);
   }
 
-  auto IncludeKind =
+  const auto IncludeKind =
       determineIncludeKind(CanonicalFile, FileName, IsAngled, Style);
 
   if (!IncludeBucket[IncludeKind].empty()) {
diff --git a/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp b/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
index e039965a68253..8aa47e452cc61 100644
--- a/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
+++ b/clang-tools-extra/clang-tidy/utils/NamespaceAliaser.cpp
@@ -82,7 +82,7 @@ std::string NamespaceAliaser::getNamespaceName(ASTContext &Context,
                                                const Stmt &Statement,
                                                StringRef Namespace) const {
   const auto *Function = getSurroundingFunction(Context, Statement);
-  auto FunctionAliases = AddedAliases.find(Function);
+  const auto FunctionAliases = AddedAliases.find(Function);
   if (FunctionAliases != AddedAliases.end()) {
     if (FunctionAliases->second.contains(Namespace))
       return FunctionAliases->second.find(Namespace)->getValue();
diff --git a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
index a82e44705d300..f5555dde47316 100644
--- a/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -160,7 +160,7 @@ static NameLookup findDeclInBases(const CXXRecordDecl &Parent,
     }
     if (!Record)
       continue;
-    if (auto Search =
+    if (const auto Search =
             findDeclInBases(*Record, DeclName, AggressiveTemplateLookup)) {
       if (*Search) {
         if (Found)
@@ -496,7 +496,7 @@ void RenamerClangTidyCheck::addUsage(const NamedDecl *Decl,
   if (!Failure.shouldFix())
     return;
   const IdentifierTable &Idents = FailureDecl->getASTContext().Idents;
-  auto CheckNewIdentifier = Idents.find(Failure.Info.Fixup);
+  const auto CheckNewIdentifier = Idents.find(Failure.Info.Fixup);
   if (CheckNewIdentifier != Idents.end()) {
     const IdentifierInfo *Ident = CheckNewIdentifier->second;
     if (Ident->isKeyword(getLangOpts()))
@@ -546,7 +546,7 @@ void RenamerClangTidyCheck::expandMacro(const Token &MacroNameTok,
   const StringRef Name = MacroNameTok.getIdentifierInfo()->getName();
   const NamingCheckId ID(MI->getDefinitionLoc(), Name);
 
-  auto Failure = NamingCheckFailures.find(ID);
+  const auto Failure = NamingCheckFailures.find(ID);
   if (Failure == NamingCheckFailures.end())
     return;
 
diff --git a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
index 6fa623022ee9c..2b682091d967a 100644
--- a/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp
@@ -43,7 +43,7 @@ static std::string escapeForDiagnostic(std::string ToEscape) {
   Result.append(ToEscape, 0, Pos);
   Result += '%';
 
-  for (auto N = ToEscape.size(); Pos < N; ++Pos) {
+  for (const auto N = ToEscape.size(); Pos < N; ++Pos) {
     const char C = ToEscape.at(Pos);
     Result += C;
     if (C == '%')
@@ -95,7 +95,7 @@ void TransformerClangTidyCheck::registerPPCallbacks(
 void TransformerClangTidyCheck::registerMatchers(
     ast_matchers::MatchFinder *Finder) {
   if (!Rule.Cases.empty())
-    for (auto &Matcher : transformer::detail::buildMatchers(Rule))
+    for (const auto &Matcher : transformer::detail::buildMatchers(Rule))
       Finder->addDynamicMatcher(Matcher, this);
 }
 
diff --git a/clang-tools-extra/clang-tidy/utils/TypeTraits.cpp b/clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
index c15d90b19d359..26e7b1ba4e410 100644
--- a/clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
+++ b/clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
@@ -14,14 +14,14 @@
 namespace clang::tidy::utils::type_traits {
 
 static bool classHasTrivialCopyAndDestroy(QualType Type) {
-  auto *Record = Type->getAsCXXRecordDecl();
+  const auto *Record = Type->getAsCXXRecordDecl();
   return Record && Record->hasDefinition() &&
          !Record->hasNonTrivialCopyConstructor() &&
          !Record->hasNonTrivialDestructor();
 }
 
 static bool hasDeletedCopyConstructor(QualType Type) {
-  auto *Record = Type->getAsCXXRecordDecl();
+  const auto *Record = Type->getAsCXXRecordDecl();
   if (!Record || !Record->hasDefinition())
     return false;
   return llvm::any_of(Record->ctors(), [](const auto *Constructor) {
@@ -135,13 +135,13 @@ bool isTriviallyDestructible(QualType Type) {
 }
 
 bool hasNonTrivialMoveConstructor(QualType Type) {
-  auto *Record = Type->getAsCXXRecordDecl();
+  const auto *Record = Type->getAsCXXRecordDecl();
   return Record && Record->hasDefinition() &&
          Record->hasNonTrivialMoveConstructor();
 }
 
 bool hasNonTrivialMoveAssignment(QualType Type) {
-  auto *Record = Type->getAsCXXRecordDecl();
+  const auto *Record = Type->getAsCXXRecordDecl();
   return Record && Record->hasDefinition() &&
          Record->hasNonTrivialMoveAssignment();
 }
diff --git a/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp b/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
index 004e61526b778..474a468cfa86d 100644
--- a/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/utils/UseRangesCheck.cpp
@@ -117,7 +117,7 @@ void UseRangesCheck::registerMatchers(MatchFinder *Finder) {
   Replacers.clear();
   llvm::DenseSet<Replacer *> SeenRepl;
   for (auto I = Replaces.begin(), E = Replaces.end(); I != E; ++I) {
-    auto Replacer = I->getValue();
+    const auto Replacer = I->getValue();
     if (!SeenRepl.insert(Replacer.get()).second)
       continue;
     Replacers.push_back(Replacer);
diff --git a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
index 2040f42231118..f1bed2e53f075 100644
--- a/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
+++ b/clang-tools-extra/clang-tidy/utils/UsingInserter.cpp
@@ -57,7 +57,7 @@ std::optional<FixItHint> UsingInserter::createUsingDeclaration(
     return std::nullopt;
   }
   // Find conflicting declarations and references.
-  auto ConflictingDecl = namedDecl(hasName(UnqualifiedName));
+  const auto ConflictingDecl = namedDecl(hasName(UnqualifiedName));
   const bool HasConflictingDeclaration =
       !match(findAll(ConflictingDecl), *Function, Context).empty();
   const bool HasConflictingDeclRef =



More information about the cfe-commits mailing list