[clang] [Lex] Use a range-based for loop (NFC) (PR #169174)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sat Nov 22 09:33:00 PST 2025


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

Identified with modernize-loop-convert.


>From 91c68d52ad88bb3a5e9893806c910b77f02128f0 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 20 Nov 2025 23:24:17 -0800
Subject: [PATCH] [Lex] Use a range-based for loop (NFC)

Identified with modernize-loop-convert.
---
 clang/lib/Lex/Preprocessor.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index e003ad3a95570..0a25dc19548ec 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -1458,10 +1458,8 @@ void Preprocessor::removeCommentHandler(CommentHandler *Handler) {
 
 bool Preprocessor::HandleComment(Token &result, SourceRange Comment) {
   bool AnyPendingTokens = false;
-  for (std::vector<CommentHandler *>::iterator H = CommentHandlers.begin(),
-       HEnd = CommentHandlers.end();
-       H != HEnd; ++H) {
-    if ((*H)->HandleComment(*this, Comment))
+  for (CommentHandler *H : CommentHandlers) {
+    if (H->HandleComment(*this, Comment))
       AnyPendingTokens = true;
   }
   if (!AnyPendingTokens || getCommentRetentionState())



More information about the cfe-commits mailing list