[Mlir-commits] [mlir] [mlir] Report line number from file rather than split (PR #150982)

Jacques Pienaar llvmlistbot at llvm.org
Mon Jul 28 20:14:03 PDT 2025


================
@@ -138,6 +138,11 @@ LogicalResult mlir::mlirTranslateMain(int argc, char **argv,
   // Processes the memory buffer with a new MLIRContext.
   auto processBuffer = [&](std::unique_ptr<llvm::MemoryBuffer> ownedBuffer,
                            raw_ostream &os) {
+    // Many of the translations expect a null-terminated buffer while splitting
+    // the buffer does not guarantee null-termination. Make a copy of the buffer
+    // to ensure null-termination.
+    ownedBuffer = llvm::MemoryBuffer::getMemBufferCopy(
+        ownedBuffer->getBuffer(), ownedBuffer->getBufferIdentifier());
----------------
jpienaar wrote:

Good point, checked for null-termination before copying.

https://github.com/llvm/llvm-project/pull/150982


More information about the Mlir-commits mailing list