[mlir][PDL] Forward captured single entity constraint functions instead of copy-capture
authorRiver Riddle <riddleriver@gmail.com>
Wed, 2 Dec 2020 05:05:13 +0000 (21:05 -0800)
committerRiver Riddle <riddleriver@gmail.com>
Wed, 2 Dec 2020 05:08:34 +0000 (21:08 -0800)
mlir/include/mlir/IR/PatternMatch.h

index 4fdc087..0bbb221 100644 (file)
@@ -355,12 +355,14 @@ public:
   std::enable_if_t<!llvm::is_invocable<SingleEntityFn, ArrayRef<PDLValue>,
                                        ArrayAttr, PatternRewriter &>::value>
   registerConstraintFunction(StringRef name, SingleEntityFn &&constraintFn) {
-    registerConstraintFunction(name, [=](ArrayRef<PDLValue> values,
-                                         ArrayAttr constantParams,
-                                         PatternRewriter &rewriter) {
-      assert(values.size() == 1 && "expected values to have a single entity");
-      return constraintFn(values[0], constantParams, rewriter);
-    });
+    registerConstraintFunction(
+        name, [constraintFn = std::forward<SingleEntityFn>(constraintFn)](
+                  ArrayRef<PDLValue> values, ArrayAttr constantParams,
+                  PatternRewriter &rewriter) {
+          assert(values.size() == 1 &&
+                 "expected values to have a single entity");
+          return constraintFn(values[0], constantParams, rewriter);
+        });
   }
 
   /// Register a creation function.