Skip to content

Commit 248d75b

Browse files
kazutakahiratarorth
authored andcommitted
[clang] Use range-based for loops (NFC) (llvm#143153)
Note that use of llvm::for_each is discouraged unless we have functors readily available.
1 parent 9e082f3 commit 248d75b

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

clang/lib/Sema/ParsedAttr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ void AttributePool::takePool(AttributePool &pool) {
9191

9292
void AttributePool::takeFrom(ParsedAttributesView &List, AttributePool &Pool) {
9393
assert(&Pool != this && "AttributePool can't take attributes from itself");
94-
llvm::for_each(List.AttrList, [&Pool](ParsedAttr *A) { Pool.remove(A); });
94+
for (ParsedAttr *A : List.AttrList)
95+
Pool.remove(A);
9596
llvm::append_range(Attrs, List.AttrList);
9697
}
9798

clang/tools/clang-installapi/Options.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,10 +1083,10 @@ void Options::addConditionalCC1Args(std::vector<std::string> &ArgStrings,
10831083
// Add specific to platform arguments.
10841084
PathSeq PlatformSearchPaths =
10851085
getPathsForPlatform(FEOpts.SystemFwkPaths, mapToPlatformType(Targ));
1086-
llvm::for_each(PlatformSearchPaths, [&ArgStrings](const StringRef Path) {
1086+
for (StringRef Path : PlatformSearchPaths) {
10871087
ArgStrings.push_back("-iframework");
10881088
ArgStrings.push_back(Path.str());
1089-
});
1089+
}
10901090

10911091
// Add specific to header type arguments.
10921092
if (Type == HeaderType::Project)

clang/unittests/StaticAnalyzer/BlockEntranceCallbackTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ llvm::SmallVector<StringRef> parseEachDiag(StringRef Diags) {
111111
llvm::SmallVector<StringRef> Fragments;
112112
llvm::SplitString(Diags, Fragments, "\n");
113113
// Drop the prefix like "test.BlockEntranceTester: " from each fragment.
114-
llvm::for_each(Fragments, [](StringRef &Fragment) {
114+
for (StringRef &Fragment : Fragments) {
115115
Fragment = Fragment.drop_until([](char Ch) { return Ch == ' '; });
116116
Fragment.consume_front(" ");
117-
});
117+
}
118118
llvm::sort(Fragments);
119119
return Fragments;
120120
}

0 commit comments

Comments
 (0)