Skip to content

Commit 0db0c79

Browse files
[mlir] Use range-based for loops (NFC) (#146946)
Note that LLVM Coding Standards discourages std::for_each and llvm::for_each unless the callable object already exists.
1 parent 60d1c4e commit 0db0c79

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

mlir/lib/Dialect/Mesh/Transforms/ShardingPropagation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ static llvm::raw_ostream &operator<<(llvm::raw_ostream &stream,
5656
template <typename Stream, typename Range>
5757
static Stream &printRange(Stream &stream, Range &&range) {
5858
stream << "[";
59-
llvm::for_each(range, [&stream](auto &v) {
59+
for (auto &v : range) {
6060
stream << v;
6161
stream << ", ";
62-
});
62+
}
6363
return stream << "]";
6464
}
6565

mlir/lib/Dialect/Tosa/Transforms/TosaReduceTransposes.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,8 +602,7 @@ void TosaReduceTransposes::runOnOperation() {
602602
!llvm::isa<RankedTensorType>(output.getType()))
603603
return;
604604

605-
llvm::for_each(transposeOp.getPerms(),
606-
[&perms](const auto i) { perms.emplace_back(i); });
605+
llvm::append_range(perms, transposeOp.getPerms());
607606

608607
// We let --canonicalize deal with identity transpose.
609608
if (llvm::equal(llvm::seq<int32_t>(0, perms.size()), perms))

mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,8 @@ void DefGen::createParentWithTraits() {
245245
? cast<NativeTrait>(&trait)->getFullyQualifiedTraitName()
246246
: cast<InterfaceTrait>(&trait)->getFullyQualifiedTraitName();
247247
}));
248-
llvm::for_each(traitNames, [&](auto &traitName) {
248+
for (auto &traitName : traitNames)
249249
defParent.addTemplateParam(traitName);
250-
});
251250

252251
// Add OpAsmInterface::Trait if we automatically generate mnemonic alias
253252
// method.

0 commit comments

Comments
 (0)