[clang-tools-extra] [clang-tidy] Fix a -Wrange-loop-construct warning (PR #215775)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 12 04:15:13 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
@llvm/pr-subscribers-clang-tidy
Author: Björn Pettersson (bjope)
<details>
<summary>Changes</summary>
As a follow up to commit d4c991d34c8c8568c
([clang-tidy][NFC] Apply const-correctness for auto 1/N (#<!-- -->213839)) we make sure to use a const reference when iterating of FixLocations.
As indicated by -Wrange-loop-construct this prevents a copy from type 'std::pair<clang::SourceLocation, bool> const'.
---
Full diff: https://github.com/llvm/llvm-project/pull/215775.diff
1 Files Affected:
- (modified) clang-tools-extra/clang-tidy/ClangTidy.cpp (+1-1)
``````````diff
diff --git a/clang-tools-extra/clang-tidy/ClangTidy.cpp b/clang-tools-extra/clang-tidy/ClangTidy.cpp
index 32e18645880e1..8135826ef660d 100644
--- a/clang-tools-extra/clang-tidy/ClangTidy.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidy.cpp
@@ -188,7 +188,7 @@ class ErrorReporter {
}
reportFix(Diag, Error.Message.Fix);
}
- for (const auto Fix : FixLocations) {
+ for (const auto &Fix : FixLocations) {
Diags.Report(Fix.first, Fix.second ? diag::note_fixit_applied
: diag::note_fixit_failed);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/215775
More information about the cfe-commits
mailing list