[llvm] [nfc][ProfileData] Fix -Wrange-loop-construct in SampleProfileWriter (PR #220726)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 2 13:47:46 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo
Author: Razvan Lupusoru (razvanlupusoru)
<details>
<summary>Changes</summary>
Fixes warnings:
```
SampleProfWriter.cpp:804:12: note: use reference type 'std::pair<llvm::sampleprof::FunctionId, unsigned long> const &' to prevent copying
804 | for (const auto [TypeName, Count] : *Map) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| &
SampleProfWriter.cpp:829:12: note: use reference type
'std::pair<llvm::sampleprof::FunctionId, unsigned lo
ng> const &' to prevent copying
829 | for (const auto [TypeId, Count] : *Map) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
| &
```
---
Full diff: https://github.com/llvm/llvm-project/pull/220726.diff
1 Files Affected:
- (modified) llvm/lib/ProfileData/SampleProfWriter.cpp (+2-2)
``````````diff
diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp
index 2d317a7f6f744..3a4b588f1e442 100644
--- a/llvm/lib/ProfileData/SampleProfWriter.cpp
+++ b/llvm/lib/ProfileData/SampleProfWriter.cpp
@@ -801,7 +801,7 @@ std::error_code SampleProfileWriterText::writeSample(const FunctionSamples &S) {
Loc.print(OS);
OS << ": ";
OS << kVTableProfPrefix;
- for (const auto [TypeName, Count] : *Map) {
+ for (const auto &[TypeName, Count] : *Map) {
OS << TypeName << ":" << Count << " ";
}
OS << "\n";
@@ -826,7 +826,7 @@ std::error_code SampleProfileWriterText::writeSample(const FunctionSamples &S) {
Loc.print(OS);
OS << ": ";
OS << kVTableProfPrefix;
- for (const auto [TypeId, Count] : *Map) {
+ for (const auto &[TypeId, Count] : *Map) {
OS << TypeId << ":" << Count << " ";
}
OS << "\n";
``````````
</details>
https://github.com/llvm/llvm-project/pull/220726
More information about the llvm-commits
mailing list