Author: Kazu Hirata Date: 2022-07-23T12:17:27-07:00 New Revision: c730f9a164eacc30fdd0f6ae202211ef8a63b64a
URL: https://github.com/llvm/llvm-project/commit/c730f9a164eacc30fdd0f6ae202211ef8a63b64a DIFF: https://github.com/llvm/llvm-project/commit/c730f9a164eacc30fdd0f6ae202211ef8a63b64a.diff LOG: Convert for_each to range-based for loops (NFC) Added: Modified: clang-tools-extra/clangd/refactor/Rename.cpp lld/COFF/DebugTypes.cpp lld/COFF/PDB.cpp mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/refactor/Rename.cpp b/clang-tools-extra/clangd/refactor/Rename.cpp index 46d884578d462..83df990d35cd9 100644 --- a/clang-tools-extra/clangd/refactor/Rename.cpp +++ b/clang-tools-extra/clangd/refactor/Rename.cpp @@ -768,9 +768,8 @@ llvm::Expected<RenameResult> rename(const RenameInputs &RInputs) { RenameResult Result; Result.Target = CurrentIdentifier; Edit MainFileEdits = Edit(MainFileCode, std::move(*MainFileRenameEdit)); - llvm::for_each(MainFileEdits.asTextEdits(), [&Result](const TextEdit &TE) { + for (const TextEdit &TE : MainFileEdits.asTextEdits()) Result.LocalChanges.push_back(TE.range); - }); // return the main file edit if this is a within-file rename or the symbol // being renamed is function local. diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp index 5878386aeb934..800b40f343aa9 100644 --- a/lld/COFF/DebugTypes.cpp +++ b/lld/COFF/DebugTypes.cpp @@ -1126,9 +1126,8 @@ void TypeMerger::mergeTypesWithGHash() { } // In parallel, remap all types. - for_each(dependencySources, [&](TpiSource *source) { + for (TpiSource *source : dependencySources) source->remapTpiWithGHashes(&ghashState); - }); parallelForEach(objectSources, [&](TpiSource *source) { source->remapTpiWithGHashes(&ghashState); }); diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp index 2ceb4fb98031c..87b6bb55d6101 100644 --- a/lld/COFF/PDB.cpp +++ b/lld/COFF/PDB.cpp @@ -296,14 +296,14 @@ static void addGHashTypeInfo(COFFLinkerContext &ctx, // Start the TPI or IPI stream header. builder.getTpiBuilder().setVersionHeader(pdb::PdbTpiV80); builder.getIpiBuilder().setVersionHeader(pdb::PdbTpiV80); - for_each(ctx.tpiSourceList, [&](TpiSource *source) { + for (TpiSource *source : ctx.tpiSourceList) { builder.getTpiBuilder().addTypeRecords(source->mergedTpi.recs, source->mergedTpi.recSizes, source->mergedTpi.recHashes); builder.getIpiBuilder().addTypeRecords(source->mergedIpi.recs, source->mergedIpi.recSizes, source->mergedIpi.recHashes); - }); + } } static void @@ -1134,7 +1134,8 @@ void PDBLinker::addObjectsToPDB() { ScopedTimer t1(ctx.addObjectsTimer); // Create module descriptors - for_each(ctx.objFileInstances, [&](ObjFile *obj) { createModuleDBI(obj); }); + for (ObjFile *obj : ctx.objFileInstances) + createModuleDBI(obj); // Reorder dependency type sources to come first. tMerger.sortDependencies(); @@ -1144,9 +1145,10 @@ void PDBLinker::addObjectsToPDB() { tMerger.mergeTypesWithGHash(); // Merge dependencies and then regular objects. - for_each(tMerger.dependencySources, - [&](TpiSource *source) { addDebug(source); }); - for_each(tMerger.objectSources, [&](TpiSource *source) { addDebug(source); }); + for (TpiSource *source : tMerger.dependencySources) + addDebug(source); + for (TpiSource *source : tMerger.objectSources) + addDebug(source); builder.getStringTableBuilder().setStrings(pdbStrTab); t1.stop(); @@ -1163,10 +1165,10 @@ void PDBLinker::addObjectsToPDB() { t2.stop(); if (config->showSummary) { - for_each(ctx.tpiSourceList, [&](TpiSource *source) { + for (TpiSource *source : ctx.tpiSourceList) { nbTypeRecords += source->nbTypeRecords; nbTypeRecordsBytes += source->nbTypeRecordsBytes; - }); + } } } diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp index cf4f96dbcf6a6..6bcceb6ed08a5 100644 --- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp +++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp @@ -880,9 +880,8 @@ struct UnrollTransferReadConversion void getInsertionIndices(TransferReadOp xferOp, SmallVector<int64_t, 8> &indices) const { if (auto insertOp = getInsertOp(xferOp)) { - llvm::for_each(insertOp.getPosition(), [&](Attribute attr) { + for (Attribute attr : insertOp.getPosition()) indices.push_back(attr.dyn_cast<IntegerAttr>().getInt()); - }); } } @@ -1008,9 +1007,8 @@ struct UnrollTransferWriteConversion void getExtractionIndices(TransferWriteOp xferOp, SmallVector<int64_t, 8> &indices) const { if (auto extractOp = getExtractOp(xferOp)) { - llvm::for_each(extractOp.getPosition(), [&](Attribute attr) { + for (Attribute attr : extractOp.getPosition()) indices.push_back(attr.dyn_cast<IntegerAttr>().getInt()); - }); } } diff --git a/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp b/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp index 07b48363fbecc..2f7ede7adc2e2 100644 --- a/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp +++ b/mlir/lib/Dialect/Bufferization/Transforms/BufferDeallocation.cpp @@ -225,12 +225,12 @@ class BufferDeallocation : public BufferPlacementTransformationBase { aliasToAllocations[alloc] = allocationInterface; // Get the alias information for the current allocation node. - llvm::for_each(aliases.resolve(alloc), [&](Value alias) { + for (Value alias : aliases.resolve(alloc)) { // TODO: check for incompatible implementations of the // AllocationOpInterface. This could be realized by promoting the // AllocationOpInterface to a DialectInterface. aliasToAllocations[alias] = allocationInterface; - }); + } } return success(); } diff --git a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp index 3422ab7c0a76e..99883e4e19644 100644 --- a/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Vectorization.cpp @@ -665,14 +665,14 @@ static int64_t getIntFromAttr(Attribute attr) { static SmallVector<Value> ofrToIndexValues(OpBuilder &builder, Location loc, ArrayRef<OpFoldResult> ofrs) { SmallVector<Value> result; - llvm::for_each(ofrs, [&](auto o) { + for (auto o : ofrs) { if (auto val = o.template dyn_cast<Value>()) { result.push_back(val); } else { result.push_back(builder.create<arith::ConstantIndexOp>( loc, getIntFromAttr(o.template get<Attribute>()))); } - }); + } return result; } diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp index 6e32109cd64d7..6e9489ebc47c8 100644 --- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp @@ -328,7 +328,8 @@ void DefGen::emitDefaultBuilder() { getBuilderParams({{"::mlir::MLIRContext *", "context"}})); MethodBody &body = m->body().indent(); auto scope = body.scope("return Base::get(context", ");"); - llvm::for_each(params, [&](auto ¶m) { body << ", " << param.getName(); }); + for (const auto ¶m : params) + body << ", " << param.getName(); } void DefGen::emitCheckedBuilder() { @@ -339,7 +340,8 @@ void DefGen::emitCheckedBuilder() { {"::mlir::MLIRContext *", "context"}})); MethodBody &body = m->body().indent(); auto scope = body.scope("return Base::getChecked(emitError, context", ");"); - llvm::for_each(params, [&](auto ¶m) { body << ", " << param.getName(); }); + for (const auto ¶m : params) + body << ", " << param.getName(); } static SmallVector<MethodParameter> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits