[Mlir-commits] [mlir] a82b63a - [mlir][DialectConversion] Forward capture callback to fix build on older

River Riddle llvmlistbot at llvm.org
Tue Feb 18 17:43:41 PST 2020


Author: River Riddle
Date: 2020-02-18T17:43:05-08:00
New Revision: a82b63a7411b34e0e6d4e96d4d2c2deaeb266e47

URL: https://github.com/llvm/llvm-project/commit/a82b63a7411b34e0e6d4e96d4d2c2deaeb266e47
DIFF: https://github.com/llvm/llvm-project/commit/a82b63a7411b34e0e6d4e96d4d2c2deaeb266e47.diff

LOG: [mlir][DialectConversion] Forward capture callback to fix build on older
GCC

Older GCC confuses the type of 'callback' after it gets captured, so
add a forward capture to move it properly.

Added: 
    

Modified: 
    mlir/include/mlir/Transforms/DialectConversion.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h
index 664005402ead..cbba8209d402 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -174,7 +174,8 @@ class TypeConverter {
   template <typename T, typename FnT>
   std::enable_if_t<is_invocable<FnT, T>::value, ConversionCallbackFn>
   wrapCallback(FnT &&callback) {
-    return wrapCallback<T>([=](T type, SmallVectorImpl<Type> &results) {
+    return wrapCallback<T>([callback = std::forward<FnT>(callback)](
+                               T type, SmallVectorImpl<Type> &results) {
       if (Optional<Type> resultOpt = callback(type)) {
         bool wasSuccess = static_cast<bool>(resultOpt.getValue());
         if (wasSuccess)
@@ -188,7 +189,8 @@ class TypeConverter {
   template <typename T, typename FnT>
   std::enable_if_t<!is_invocable<FnT, T>::value, ConversionCallbackFn>
   wrapCallback(FnT &&callback) {
-    return [=](Type type,
+    return [callback = std::forward<FnT>(callback)](
+               Type type,
                SmallVectorImpl<Type> &results) -> Optional<LogicalResult> {
       T derivedType = type.dyn_cast<T>();
       if (!derivedType)


        


More information about the Mlir-commits mailing list