[Mlir-commits] [mlir] [MLIR] Fix a use-after-free in OpFormatGen.cpp (PR #114789)

Haojian Wu llvmlistbot at llvm.org
Mon Nov 4 05:04:57 PST 2024


https://github.com/hokein created https://github.com/llvm/llvm-project/pull/114789

None

>From 5503c64cb05bfbe24415adeb613a8068f1cfd202 Mon Sep 17 00:00:00 2001
From: Haojian Wu <hokein.wu at gmail.com>
Date: Mon, 4 Nov 2024 14:03:50 +0100
Subject: [PATCH] [MLIR] Fix a use-after-free in OpFormatGen.cpp

---
 mlir/tools/mlir-tblgen/OpFormatGen.cpp | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/mlir/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index 3bf6f2f6d38176..7e2b0694a860a3 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -229,10 +229,9 @@ class OIListElement : public DirectiveElementBase<DirectiveElement::OIList> {
 
   /// Returns a range to iterate over the LiteralElements.
   auto getLiteralElements() const {
-    function_ref<LiteralElement *(FormatElement * el)>
-        literalElementCastConverter =
-            [](FormatElement *el) { return cast<LiteralElement>(el); };
-    return llvm::map_range(literalElements, literalElementCastConverter);
+    return llvm::map_range(literalElements, [](FormatElement *el) {
+      return cast<LiteralElement>(el);
+    });
   }
 
   /// Returns a range to iterate over the parsing elements corresponding to the



More information about the Mlir-commits mailing list