Skip to content

Conversation

@hokein
Copy link
Collaborator

@hokein hokein commented Nov 4, 2024

No description provided.

@hokein hokein requested a review from usx95 November 4, 2024 13:04
@llvmbot llvmbot added mlir:core MLIR Core Infrastructure mlir labels Nov 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 4, 2024

@llvm/pr-subscribers-mlir-core

Author: Haojian Wu (hokein)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/114789.diff

1 Files Affected:

  • (modified) mlir/tools/mlir-tblgen/OpFormatGen.cpp (+3-4)
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

@llvmbot
Copy link
Member

llvmbot commented Nov 4, 2024

@llvm/pr-subscribers-mlir

Author: Haojian Wu (hokein)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/114789.diff

1 Files Affected:

  • (modified) mlir/tools/mlir-tblgen/OpFormatGen.cpp (+3-4)
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

@joker-eph joker-eph changed the title [MLIR] Fix a use-after-free in OpFormatGen.cpp [MLIR] Fix a stack-use-after-scope error in OpFormatGen.cpp Nov 4, 2024
@joker-eph
Copy link
Collaborator

I just tweaked the title, hopefully it makes sense.

Thanks for the fix!

@hokein
Copy link
Collaborator Author

hokein commented Nov 4, 2024

Make senses, thanks for the prompt review.

@hokein hokein merged commit 790cbee into llvm:main Nov 4, 2024
9 of 11 checks passed
@hokein hokein deleted the fix-use-after-free branch November 4, 2024 13:38
PhilippRados pushed a commit to PhilippRados/llvm-project that referenced this pull request Nov 6, 2024
hokein added a commit that referenced this pull request Nov 7, 2024
This helps catch dangling llvm::function_ref references, see #114950,
#114949, #114808, #114789
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mlir:core MLIR Core Infrastructure mlir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants