[clang-tools-extra] [clang-tidy][NFC] Apply const-correctness for auto 4/N (PR #213842)
Baranov Victor via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 3 22:28:53 PDT 2026
https://github.com/vbvictor created https://github.com/llvm/llvm-project/pull/213842
None
>From 83b0125c19c5ef1208d5f1259e033040e8503d7f Mon Sep 17 00:00:00 2001
From: Victor Baranov <bar.victor.2002 at gmail.com>
Date: Tue, 4 Aug 2026 08:28:37 +0300
Subject: [PATCH] [clang-tidy][NFC] Apply const-correctness for auto 4/N
---
.../cppcoreguidelines/AvoidGotoCheck.cpp | 4 ++--
.../AvoidNonConstGlobalVariablesCheck.cpp | 8 +++----
.../cppcoreguidelines/InitVariablesCheck.cpp | 2 +-
.../MisleadingCaptureDefaultByValueCheck.cpp | 10 ++++-----
.../MissingStdForwardCheck.cpp | 6 ++---
.../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/llvm/IncludeOrderCheck.cpp | 6 ++---
.../PreferIsaOrDynCastInConditionalsCheck.cpp | 8 +++----
.../llvm/PreferRegisterOverUnsignedCheck.cpp | 2 +-
.../clang-tidy/llvm/RedundantCastingCheck.cpp | 8 +++----
.../clang-tidy/llvm/TwineLocalCheck.cpp | 6 ++---
.../llvm/TypeSwitchCaseTypesCheck.cpp | 3 ++-
.../llvm/UseNewMLIROpBuilderCheck.cpp | 7 +++---
.../clang-tidy/llvm/UseVectorUtilsCheck.cpp | 3 ++-
.../llvmlibc/InlineFunctionDeclCheck.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 | 6 ++---
.../clang-tidy/objc/SuperSelfCheck.cpp | 9 ++++----
.../clang-tidy/performance/AvoidEndlCheck.cpp | 12 +++++-----
33 files changed, 102 insertions(+), 93 deletions(-)
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 7f5e27d4554db..ee30b22fb1700 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidNonConstGlobalVariablesCheck.cpp
@@ -25,11 +25,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(),
@@ -40,11 +40,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 cf3e97ad500ab..500f0e266d481 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -108,7 +108,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 a8f2dcc8f5e1b..57b72b5b9a02f 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 = [&](StringRef Name) {
+ const auto AppendName = [&](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 8c998778f096b..4a77bd7948615 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
@@ -104,7 +104,7 @@ AST_MATCHER_P(ValueDecl, refersToBoundParm, std::string, ParamID) {
} // namespace
void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
- auto CapturedVar = varDecl(refersToBoundParm("param"));
+ const auto CapturedVar = varDecl(refersToBoundParm("param"));
auto CaptureInRef =
allOf(hasCaptureDefaultKind(LambdaCaptureDefault::LCD_ByRef),
@@ -123,9 +123,9 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
anyOf(CapturedInCaptureList, CapturedInBody),
hasAncestor(functionDecl(equalsBoundNode("func")))))));
- auto ToParam = hasAnyParameter(parmVarDecl(equalsBoundNode("param")));
+ const auto ToParam = hasAnyParameter(parmVarDecl(equalsBoundNode("param")));
- auto ForwardCallMatcher =
+ const auto ForwardCallMatcher =
callExpr(callExpr().bind("call"), argumentCountIs(1),
hasArgument(0, declRefExpr(to(CapturedVar)).bind("var")),
forCallable(anyOf(equalsBoundNode("func"), CapturedInLambda)),
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/NoSuspendWithLockCheck.cpp
index f2460aec3b2fd..80172bdb06472 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 f04b5e87a084c..74c47e23044f4 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 83afaa07b37ed..2622647455c08 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 0d51717a88ef4..b507ab16798ad 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -79,7 +79,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")))))),
@@ -321,7 +321,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 daa9f983b7886..95a6f2486b4a3 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 '...'
@@ -195,7 +195,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 44b1eb3fa169e..22bb053663831 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 6f2ab250e441b..2b4034517a082 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) {
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 a79519325e745..84720d10c233e 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/UseEnumClassCheck.cpp
@@ -26,7 +26,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/llvm/IncludeOrderCheck.cpp b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
index 93f13c8770481..0b0ca54dfc21e 100644
--- a/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/IncludeOrderCheck.cpp
@@ -151,8 +151,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) {
@@ -169,7 +169,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 7c9833aa6ee24..584568a6ef154 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"}),
@@ -94,7 +94,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/RedundantCastingCheck.cpp b/clang-tools-extra/clang-tidy/llvm/RedundantCastingCheck.cpp
index 16a55b3ab1a12..1b2b1ed6118e8 100644
--- a/clang-tools-extra/clang-tidy/llvm/RedundantCastingCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/RedundantCastingCheck.cpp
@@ -47,9 +47,9 @@ static constexpr StringRef IsaFunctionNames[] = {"isa", "isa_and_nonnull",
"isa_and_present"};
void RedundantCastingCheck::registerMatchers(MatchFinder *Finder) {
- auto IsInLLVMNamespace = hasDeclContext(
+ const auto IsInLLVMNamespace = hasDeclContext(
namespaceDecl(hasName("llvm"), hasDeclContext(translationUnitDecl())));
- auto AnyCastCalleeName =
+ const auto AnyCastCalleeName =
allOf(unless(isMacroID()), unless(cxxMemberCallExpr()),
callee(expr(declRefExpr(to(namedDecl(hasAnyName(CastFunctionNames),
IsInLLVMNamespace)),
@@ -67,7 +67,7 @@ void RedundantCastingCheck::registerMatchers(MatchFinder *Finder) {
.bind("call"),
this);
- auto AnyIsaCalleeName =
+ const auto AnyIsaCalleeName =
allOf(unless(isMacroID()), unless(cxxMemberCallExpr()),
callee(expr(declRefExpr(to(namedDecl(hasAnyName(IsaFunctionNames),
IsInLLVMNamespace)),
@@ -103,7 +103,7 @@ static QualType stripPointerOrReference(QualType Ty) {
static bool isLLVMNamespace(NestedNameSpecifier NNS) {
if (NNS.getKind() != NestedNameSpecifier::Kind::Namespace)
return false;
- auto Pair = NNS.getAsNamespaceAndPrefix();
+ const auto Pair = NNS.getAsNamespaceAndPrefix();
if (Pair.Namespace->getNamespace()->getName() != "llvm")
return false;
const NestedNameSpecifier::Kind Kind = Pair.Prefix.getKind();
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/TypeSwitchCaseTypesCheck.cpp b/clang-tools-extra/clang-tidy/llvm/TypeSwitchCaseTypesCheck.cpp
index 98453c21ca822..0d89c1cbe9933 100644
--- a/clang-tools-extra/clang-tidy/llvm/TypeSwitchCaseTypesCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/TypeSwitchCaseTypesCheck.cpp
@@ -84,7 +84,8 @@ void TypeSwitchCaseTypesCheck::check(const MatchFinder::MatchResult &Result) {
ParamBaseType->getCanonicalTypeUnqualified())
return;
- auto Diag = diag(Call->getExprLoc(), "redundant explicit template argument");
+ const auto Diag =
+ diag(Call->getExprLoc(), "redundant explicit template argument");
// Skip fixit if template argument involves macros.
const SourceLocation LAngleLoc = MemExpr->getLAngleLoc();
diff --git a/clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp b/clang-tools-extra/clang-tidy/llvm/UseNewMLIROpBuilderCheck.cpp
index ca3e778e573c1..346cace9ce994 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(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 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/llvm/UseVectorUtilsCheck.cpp b/clang-tools-extra/clang-tidy/llvm/UseVectorUtilsCheck.cpp
index bd915eb55b448..94723fded2f19 100644
--- a/clang-tools-extra/clang-tidy/llvm/UseVectorUtilsCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvm/UseVectorUtilsCheck.cpp
@@ -64,7 +64,8 @@ void UseVectorUtilsCheck::check(const MatchFinder::MatchResult &Result) {
InnerFuncNameToReplacementFuncName.lookup(InnerFuncName);
assert(!ReplacementFuncName.empty() && "Unhandled function?");
- auto Diag = diag(OuterCall->getBeginLoc(), "use '%0'") << ReplacementFuncName;
+ const auto Diag = diag(OuterCall->getBeginLoc(), "use '%0'")
+ << ReplacementFuncName;
// Replace the outer function name (preserving qualifier and template args),
// and then remove the inner call's callee and opening paren and closing
diff --git a/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp b/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
index 69393781918e1..3120c5c6c86d5 100644
--- a/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
+++ b/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
@@ -74,8 +74,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 StringRef SrcText = Loc.getBufferData().drop_front(Loc.getFileOffset());
if (SrcText.starts_with("LIBC_INLINE"))
return;
diff --git a/clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp b/clang-tools-extra/clang-tidy/mpi/BufferDerefCheck.cpp
index 347059e65f453..3e296b5a87173 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 688dd57cde1d4..c3aed13466363 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 0080a389ce9cb..911494a6d69e9 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(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,10 @@ static bool hasCategoryPropertyPrefix(StringRef PropertyName) {
static bool prefixedPropertyNameValid(StringRef PropertyName) {
const size_t Start = PropertyName.find_first_of('_');
assert(Start != 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(StringRef(validPropertyNameRegex(false)));
+ const auto RegexExp = llvm::Regex(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 4433cdf5ac0db..1a075bc747923 100644
--- a/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/AvoidEndlCheck.cpp
@@ -49,9 +49,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 {
@@ -65,9 +65,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());
More information about the cfe-commits
mailing list