https://github.com/flovent created 
https://github.com/llvm/llvm-project/pull/157468

Closes [#156154](https://github.com/llvm/llvm-project/issues/156154)

>From a7306f175d55388158587ab4ee5e33e4e119b795 Mon Sep 17 00:00:00 2001
From: flovent <flb...@protonmail.com>
Date: Mon, 8 Sep 2025 22:02:25 +0800
Subject: [PATCH] [clang-tidy][NFC] Enable `modernize-use-auto` in clang-tidy
 config and fix warnings

---
 clang-tools-extra/clang-tidy/.clang-tidy                    | 1 -
 .../clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp  | 6 +++---
 .../clang-tidy/modernize/UseScopedLockCheck.cpp             | 2 +-
 .../clang-tidy/readability/UseStdMinMaxCheck.cpp            | 2 +-
 4 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/clang-tools-extra/clang-tidy/.clang-tidy 
b/clang-tools-extra/clang-tidy/.clang-tidy
index 0e33364442e76..51e04876d655d 100644
--- a/clang-tools-extra/clang-tidy/.clang-tidy
+++ b/clang-tools-extra/clang-tidy/.clang-tidy
@@ -11,7 +11,6 @@ Checks: >
   modernize-*,
   -modernize-avoid-c-arrays,
   -modernize-pass-by-value,
-  -modernize-use-auto,
   -modernize-use-nodiscard,
   -modernize-use-trailing-return-type,
   performance-*,
diff --git 
a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
index eeba5cce80da5..4726674be66fd 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp
@@ -138,9 +138,9 @@ void UseIntegerSignComparisonCheck::check(
     return;
   const Expr *SubExprLHS = nullptr;
   const Expr *SubExprRHS = nullptr;
-  SourceRange R1 = SourceRange(LHS->getBeginLoc());
-  SourceRange R2 = SourceRange(BinaryOp->getOperatorLoc());
-  SourceRange R3 = SourceRange(Lexer::getLocForEndOfToken(
+  SourceRange R1(LHS->getBeginLoc());
+  SourceRange R2(BinaryOp->getOperatorLoc());
+  SourceRange R3(Lexer::getLocForEndOfToken(
       RHS->getEndLoc(), 0, *Result.SourceManager, getLangOpts()));
   if (const auto *LHSCast = llvm::dyn_cast<ExplicitCastExpr>(LHS)) {
     SubExprLHS = LHSCast->getSubExpr();
diff --git a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
index c74db0ed861b4..4041c81526d2f 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp
@@ -98,7 +98,7 @@ static SourceRange getLockGuardRange(const TypeSourceInfo 
*SourceInfo) {
 
 // Find the exact source range of the 'lock_guard' name token
 static SourceRange getLockGuardNameRange(const TypeSourceInfo *SourceInfo) {
-  const TemplateSpecializationTypeLoc TemplateLoc =
+  const auto TemplateLoc =
       SourceInfo->getTypeLoc().getAs<TemplateSpecializationTypeLoc>();
   if (!TemplateLoc)
     return {};
diff --git a/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
index 718467ed02f0a..511256332cee9 100644
--- a/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/UseStdMinMaxCheck.cpp
@@ -62,7 +62,7 @@ static bool maxCondition(const BinaryOperator::Opcode Op, 
const Expr *CondLhs,
 static QualType getNonTemplateAlias(QualType QT) {
   while (true) {
     // cast to a TypedefType
-    if (const TypedefType *TT = dyn_cast<TypedefType>(QT)) {
+    if (const auto *TT = dyn_cast<TypedefType>(QT)) {
       // check if the typedef is a template and if it is dependent
       if (!TT->getDecl()->getDescribedTemplate() &&
           !TT->getDecl()->getDeclContext()->isDependentContext())

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to