-
Notifications
You must be signed in to change notification settings - Fork 15.1k
Open
Labels
Description
With clang-tidy built at current head and applying it on MLIR:
$ clang-tidy -p build mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp --checks=-*,modernize-loop-convert -fix -fix-errors
diff --git a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
index 68ef51992efe..e5c3710971d4 100644
--- a/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
+++ b/mlir/lib/Dialect/Bufferization/Transforms/Bufferize.cpp
@@ -307,8 +307,7 @@ LogicalResult bufferization::bufferizeOp(Operation *op,
// Bufferize all ops.
BufferizationRewriter rewriter(op->getContext(), erasedOps, toBufferOps,
worklist, options, statistics);
- for (unsigned i = 0; i < worklist.size(); ++i) {
- Operation *nextOp = worklist[i];
+ for (auto nextOp : worklist) {
// Skip ops that were erased.
if (erasedOps.contains(nextOp))
continue;
worklist is a vector: however there is a callback that will push_back() to the worklist , which can cause reallocation of the vector and iterator invalidation here.