Author: Kazu Hirata
Date: 2025-06-06T09:16:41-07:00
New Revision: 6ab6321d03d5676756d16d9bec23ec08c8191d4d

URL: 
https://github.com/llvm/llvm-project/commit/6ab6321d03d5676756d16d9bec23ec08c8191d4d
DIFF: 
https://github.com/llvm/llvm-project/commit/6ab6321d03d5676756d16d9bec23ec08c8191d4d.diff

LOG: [clang] Use range-based for loops (NFC) (#143153)

Note that use of llvm::for_each is discouraged unless we have functors
readily available.

Added: 
    

Modified: 
    clang/lib/Sema/ParsedAttr.cpp
    clang/tools/clang-installapi/Options.cpp
    clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp
index 4e4859d538cd6..294f88eae931c 100644
--- a/clang/lib/Sema/ParsedAttr.cpp
+++ b/clang/lib/Sema/ParsedAttr.cpp
@@ -91,7 +91,8 @@ void AttributePool::takePool(AttributePool &pool) {
 
 void AttributePool::takeFrom(ParsedAttributesView &List, AttributePool &Pool) {
   assert(&Pool != this && "AttributePool can't take attributes from itself");
-  llvm::for_each(List.AttrList, [&Pool](ParsedAttr *A) { Pool.remove(A); });
+  for (ParsedAttr *A : List.AttrList)
+    Pool.remove(A);
   llvm::append_range(Attrs, List.AttrList);
 }
 

diff  --git a/clang/tools/clang-installapi/Options.cpp 
b/clang/tools/clang-installapi/Options.cpp
index d0638b644df52..52b48a34d361c 100644
--- a/clang/tools/clang-installapi/Options.cpp
+++ b/clang/tools/clang-installapi/Options.cpp
@@ -1083,10 +1083,10 @@ void 
Options::addConditionalCC1Args(std::vector<std::string> &ArgStrings,
   // Add specific to platform arguments.
   PathSeq PlatformSearchPaths =
       getPathsForPlatform(FEOpts.SystemFwkPaths, mapToPlatformType(Targ));
-  llvm::for_each(PlatformSearchPaths, [&ArgStrings](const StringRef Path) {
+  for (StringRef Path : PlatformSearchPaths) {
     ArgStrings.push_back("-iframework");
     ArgStrings.push_back(Path.str());
-  });
+  }
 
   // Add specific to header type arguments.
   if (Type == HeaderType::Project)

diff  --git a/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp 
b/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp
index 9f62d8b87d96d..0f05c39df93e0 100644
--- a/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp
+++ b/clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp
@@ -111,10 +111,10 @@ llvm::SmallVector<StringRef> parseEachDiag(StringRef 
Diags) {
   llvm::SmallVector<StringRef> Fragments;
   llvm::SplitString(Diags, Fragments, "\n");
   // Drop the prefix like "test.BlockEntranceTester: " from each fragment.
-  llvm::for_each(Fragments, [](StringRef &Fragment) {
+  for (StringRef &Fragment : Fragments) {
     Fragment = Fragment.drop_until([](char Ch) { return Ch == ' '; });
     Fragment.consume_front(" ");
-  });
+  }
   llvm::sort(Fragments);
   return Fragments;
 }


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to