[llvm] [ProfileData] Use a range-based for loop (NFC) (PR #94856)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 8 07:20:06 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/94856

While I am at it, this patch adds const to a couple of places.

>From 076160d318051f0610075158559c94cd83255516 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 8 Jun 2024 07:05:45 -0700
Subject: [PATCH] [ProfileData] Use a range-based for loop (NFC)

While I am at it, this patch adds const to a couple of places.
---
 llvm/lib/ProfileData/InstrProfReader.cpp | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 7758363d9c952..27855bf92b871 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -145,11 +145,11 @@ readBinaryIdsInternal(const MemoryBuffer &DataBuffer,
 
 static void
 printBinaryIdsInternal(raw_ostream &OS,
-                       std::vector<llvm::object::BuildID> &BinaryIds) {
+                       const std::vector<llvm::object::BuildID> &BinaryIds) {
   OS << "Binary IDs: \n";
-  for (auto BI : BinaryIds) {
-    for (uint64_t I = 0; I < BI.size(); I++)
-      OS << format("%02x", BI[I]);
+  for (const auto &BI : BinaryIds) {
+    for (auto I : BI)
+      OS << format("%02x", I);
     OS << "\n";
   }
 }



More information about the llvm-commits mailing list