[clang-tools-extra] [clang-tidy][NFC] Fix some clang-tidy violations after bump to 23 version (PR #221420)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 5 01:02:42 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tidy
Author: Baranov Victor (vbvictor)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/221420.diff
3 Files Affected:
- (modified) clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp (+1-1)
- (modified) clang-tools-extra/clang-tidy/misc/StaticInitializationCycleCheck.cpp (+14-15)
- (modified) clang-tools-extra/clang-tidy/modernize/UseToUnderlyingCheck.cpp (+4-4)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/221420
More information about the cfe-commits
mailing list