[llvm] [llvm-cov] Use a range-based for loop (NFC) (PR #168671)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 18 22:38:35 PST 2025


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

Identified with modernize-loop-convert.


>From 0309430cb409b9a10f9c7fa05ceb10d580a26dd7 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 17 Nov 2025 23:38:24 -0800
Subject: [PATCH] [llvm-cov] Use a range-based for loop (NFC)

Identified with modernize-loop-convert.
---
 llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
index c94d3853fc014..bdef0994d1841 100644
--- a/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
+++ b/llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
@@ -955,8 +955,8 @@ void SourceCoverageViewHTML::renderLine(raw_ostream &OS, LineRef L,
 
   // 2. Escape all of the snippets.
 
-  for (unsigned I = 0, E = Snippets.size(); I < E; ++I)
-    Snippets[I] = escape(Snippets[I], getOptions());
+  for (std::string &Snippet : Snippets)
+    Snippet = escape(Snippet, getOptions());
 
   // 3. Use \p WrappedSegment to set the highlight for snippet 0. Use segment
   //    1 to set the highlight for snippet 2, segment 2 to set the highlight for



More information about the llvm-commits mailing list