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

Note that use of llvm::for_each is discouraged unless we have functors
readily available.
This commit is contained in:
Kazu Hirata 2025-06-06 09:16:41 -07:00 committed by GitHub
parent 2c0a2261b1
commit 6ab6321d03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 6 additions and 5 deletions

View File

@ -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);
}

View File

@ -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)

View File

@ -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;
}