From e2f16be5991af84e508fcd197bb5deb841aa0dc2 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Tue, 19 Oct 2021 17:13:54 +0000 Subject: [PATCH] Fix clang-tidy warnings in MLIR Python bindings (NFC) --- mlir/lib/Bindings/Python/IRAffine.cpp | 1 + mlir/lib/Bindings/Python/IRCore.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mlir/lib/Bindings/Python/IRAffine.cpp b/mlir/lib/Bindings/Python/IRAffine.cpp index 0027b68ee073..50a96c8c8ced 100644 --- a/mlir/lib/Bindings/Python/IRAffine.cpp +++ b/mlir/lib/Bindings/Python/IRAffine.cpp @@ -555,6 +555,7 @@ void mlir::python::populateIRAffine(py::module &m) { mlirAffineMapCompressUnusedSymbols( maps.data(), maps.size(), compressed.data(), populate); std::vector res; + res.reserve(compressed.size()); for (auto m : compressed) res.push_back(PyAffineMap(context->getRef(), m)); return res; diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp index ed96bafe4191..4fc581b5dee7 100644 --- a/mlir/lib/Bindings/Python/IRCore.cpp +++ b/mlir/lib/Bindings/Python/IRCore.cpp @@ -1976,7 +1976,7 @@ void mlir::python::populateIRCore(py::module &m) { if (frames.empty()) throw py::value_error("No caller frames provided"); MlirLocation caller = frames.back().get(); - for (PyLocation frame : + for (const PyLocation &frame : llvm::reverse(llvm::makeArrayRef(frames).drop_back())) caller = mlirLocationCallSiteGet(frame.get(), caller); return PyLocation(context->getRef(),