https://github.com/vbvictor created https://github.com/llvm/llvm-project/pull/221420
None >From 3d9787fc328b1a1d5cbba2aabc583ffcf56b14ae Mon Sep 17 00:00:00 2001 From: Victor Baranov <[email protected]> Date: Sat, 5 Sep 2026 11:01:10 +0300 Subject: [PATCH] [clang-tidy][NFC] Fix some clang-tidy violations after bump to 23 version --- .../ExpandModularHeadersPPCallbacks.cpp | 2 +- .../misc/StaticInitializationCycleCheck.cpp | 29 +++++++++---------- .../modernize/UseToUnderlyingCheck.cpp | 8 ++--- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp index c989b4ad3859e..d7c8a31fce3b5 100644 --- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp +++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp @@ -53,7 +53,7 @@ class ExpandModularHeadersPPCallbacks::FileRecorder { /// Ideally `FilesToRecord` should be empty. void checkAllFilesRecorded() { LLVM_DEBUG({ - for (auto FileEntry : FilesToRecord) + for (const auto &FileEntry : FilesToRecord) llvm::dbgs() << "Did not record contents for input file: " << FileEntry.getName() << "\n"; }); diff --git a/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp index a1fde21ac0621..7b1e86b7804fa 100644 --- a/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp +++ b/clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp @@ -51,25 +51,24 @@ static bool shouldIgnoreRef(const DeclRefExpr *DRE, const Decl *ParentD) { if (ParentLambda) return true; ParentLambda = LambdaE; - } else if (const auto *OpCallE = dyn_cast<CXXOperatorCallExpr>(E)) { + } else if (const auto *OpCallE = dyn_cast<CXXOperatorCallExpr>(E); + OpCallE && ParentLambda && + OpCallE->getOperator() == OverloadedOperatorKind::OO_Call && + OpCallE->getCalleeDecl() == ParentLambda->getCallOperator()) { // Check if the last found lambda is called with this 'operator ()'. - if (ParentLambda && - OpCallE->getOperator() == OverloadedOperatorKind::OO_Call && - OpCallE->getCalleeDecl() == ParentLambda->getCallOperator()) - ParentLambda = nullptr; + ParentLambda = nullptr; } - } else if (const Decl *D = Parents[0].get<Decl>()) { + } else if (const Decl *D = Parents[0].get<Decl>(); D && [D, ParentD]() { + if (const auto *ParentF = dyn_cast<FunctionDecl>(ParentD)) { + if (const auto *FD = dyn_cast<FunctionDecl>(D)) + return FD == ParentF->getDefinition(); + return false; + } + return D->getCanonicalDecl() == ParentD->getCanonicalDecl(); + }()) { // Check if we reached the root of the context (variable or function // declaration) to check. - if ([D, ParentD]() { - if (const auto *ParentF = dyn_cast<FunctionDecl>(ParentD)) { - if (const auto *FD = dyn_cast<FunctionDecl>(D)) - return FD == ParentF->getDefinition(); - return false; - } - return D->getCanonicalDecl() == ParentD->getCanonicalDecl(); - }()) - return ParentLambda != nullptr; + return ParentLambda != nullptr; } Parents = PMC.getParents(Parents[0]); } diff --git a/clang-tools-extra/clang-tidy/modernize/UseToUnderlyingCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseToUnderlyingCheck.cpp index 5d6664bb30ff9..ecdcf7d8860a7 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseToUnderlyingCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseToUnderlyingCheck.cpp @@ -116,10 +116,10 @@ void UseToUnderlyingCheck::check(const MatchFinder::MatchResult &Result) { if (!IsPrecise && ImpreciseCasts == ImpreciseCastsKind::Ignore) return; - auto Diag = diag(Cast->getBeginLoc(), - "use '%0' to convert a scoped enumeration to its " - "underlying type") - << ReplacementFunction; + const auto Diag = diag(Cast->getBeginLoc(), + "use '%0' to convert a scoped enumeration to its " + "underlying type") + << ReplacementFunction; if (!IsPrecise && ImpreciseCasts == ImpreciseCastsKind::Warn) return; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
