https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/143153
Note that use of llvm::for_each is discouraged unless we have functors readily available. >From 1467cc073272b8d0b4d1ebeccc88fa12e07e882e Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Thu, 5 Jun 2025 22:03:06 -0700 Subject: [PATCH] [clang] Use range-based for loops (NFC) Note that use of llvm::for_each is discouraged unless we have functors readily available. --- clang/lib/Sema/ParsedAttr.cpp | 3 ++- clang/tools/clang-installapi/Options.cpp | 4 ++-- clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) 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