[Mlir-commits] [mlir] f11925e - [mlir] Use std::enable_if_t (NFC)

Kazu Hirata llvmlistbot at llvm.org
Sat Sep 3 23:27:52 PDT 2022


Author: Kazu Hirata
Date: 2022-09-03T23:27:20-07:00
New Revision: f11925e0f0c49737509216403136204624dc2a29

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

LOG: [mlir] Use std::enable_if_t (NFC)

Added: 
    

Modified: 
    mlir/include/mlir/IR/Block.h
    mlir/include/mlir/IR/Builders.h
    mlir/include/mlir/IR/BuiltinAttributes.h
    mlir/include/mlir/IR/BuiltinAttributes.td
    mlir/include/mlir/IR/Diagnostics.h
    mlir/include/mlir/IR/ImplicitLocOpBuilder.h
    mlir/include/mlir/IR/Matchers.h
    mlir/include/mlir/IR/OpDefinition.h
    mlir/include/mlir/IR/OpImplementation.h
    mlir/include/mlir/IR/Operation.h
    mlir/include/mlir/IR/Region.h
    mlir/include/mlir/IR/Types.h
    mlir/include/mlir/IR/Visitors.h
    mlir/include/mlir/Support/StorageUniquer.h
    mlir/include/mlir/Transforms/DialectConversion.h
    mlir/include/mlir/Transforms/FoldUtils.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/IR/Block.h b/mlir/include/mlir/IR/Block.h
index 723dda3f7208c..6c753cb5d0185 100644
--- a/mlir/include/mlir/IR/Block.h
+++ b/mlir/include/mlir/IR/Block.h
@@ -284,7 +284,7 @@ class Block : public IRObjectWithUseList<BlockOperand>,
   /// See Operation::walk for more details.
   template <WalkOrder Order = WalkOrder::PostOrder, typename FnT,
             typename RetT = detail::walkResultType<FnT>>
-  typename std::enable_if<std::is_same<RetT, void>::value, RetT>::type
+  std::enable_if_t<std::is_same<RetT, void>::value, RetT>
   walk(Block::iterator begin, Block::iterator end, FnT &&callback) {
     for (auto &op : llvm::make_early_inc_range(llvm::make_range(begin, end)))
       detail::walk<Order>(&op, callback);
@@ -303,7 +303,7 @@ class Block : public IRObjectWithUseList<BlockOperand>,
   /// See Operation::walk for more details.
   template <WalkOrder Order = WalkOrder::PostOrder, typename FnT,
             typename RetT = detail::walkResultType<FnT>>
-  typename std::enable_if<std::is_same<RetT, WalkResult>::value, RetT>::type
+  std::enable_if_t<std::is_same<RetT, WalkResult>::value, RetT>
   walk(Block::iterator begin, Block::iterator end, FnT &&callback) {
     for (auto &op : llvm::make_early_inc_range(llvm::make_range(begin, end)))
       if (detail::walk<Order>(&op, callback).wasInterrupted())

diff  --git a/mlir/include/mlir/IR/Builders.h b/mlir/include/mlir/IR/Builders.h
index 687f6679913a8..9fa683a92e47d 100644
--- a/mlir/include/mlir/IR/Builders.h
+++ b/mlir/include/mlir/IR/Builders.h
@@ -482,8 +482,7 @@ class OpBuilder : public Builder {
 
   /// Overload to create or fold a single result operation.
   template <typename OpTy, typename... Args>
-  typename std::enable_if<OpTy::template hasTrait<OpTrait::OneResult>(),
-                          Value>::type
+  std::enable_if_t<OpTy::template hasTrait<OpTrait::OneResult>(), Value>
   createOrFold(Location location, Args &&...args) {
     SmallVector<Value, 1> results;
     createOrFold<OpTy>(results, location, std::forward<Args>(args)...);
@@ -492,8 +491,7 @@ class OpBuilder : public Builder {
 
   /// Overload to create or fold a zero result operation.
   template <typename OpTy, typename... Args>
-  typename std::enable_if<OpTy::template hasTrait<OpTrait::ZeroResults>(),
-                          OpTy>::type
+  std::enable_if_t<OpTy::template hasTrait<OpTrait::ZeroResults>(), OpTy>
   createOrFold(Location location, Args &&...args) {
     auto op = create<OpTy>(location, std::forward<Args>(args)...);
     SmallVector<Value, 0> unused;

diff  --git a/mlir/include/mlir/IR/BuiltinAttributes.h b/mlir/include/mlir/IR/BuiltinAttributes.h
index 5e9370061597d..17687eda5e4b8 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.h
+++ b/mlir/include/mlir/IR/BuiltinAttributes.h
@@ -109,9 +109,9 @@ class DenseElementsAttr : public Attribute {
   /// or floating-point values. Each value is expected to be the same bitwidth
   /// of the element type of 'type'. 'type' must be a vector or tensor with
   /// static shape.
-  template <typename T, typename = typename std::enable_if<
-                            std::numeric_limits<T>::is_integer ||
-                            is_valid_cpp_fp_type<T>::value>::type>
+  template <typename T,
+            typename = std::enable_if_t<std::numeric_limits<T>::is_integer ||
+                                        is_valid_cpp_fp_type<T>::value>>
   static DenseElementsAttr get(const ShapedType &type, ArrayRef<T> values) {
     const char *data = reinterpret_cast<const char *>(values.data());
     return getRawIntOrFloat(
@@ -120,10 +120,10 @@ class DenseElementsAttr : public Attribute {
   }
 
   /// Constructs a dense integer elements attribute from a single element.
-  template <typename T, typename = typename std::enable_if<
-                            std::numeric_limits<T>::is_integer ||
-                            is_valid_cpp_fp_type<T>::value ||
-                            detail::is_complex_t<T>::value>::type>
+  template <typename T,
+            typename = std::enable_if_t<std::numeric_limits<T>::is_integer ||
+                                        is_valid_cpp_fp_type<T>::value ||
+                                        detail::is_complex_t<T>::value>>
   static DenseElementsAttr get(const ShapedType &type, T value) {
     return get(type, llvm::makeArrayRef(value));
   }
@@ -131,11 +131,11 @@ class DenseElementsAttr : public Attribute {
   /// Constructs a dense complex elements attribute from an array of complex
   /// values. Each value is expected to be the same bitwidth of the element type
   /// of 'type'. 'type' must be a vector or tensor with static shape.
-  template <typename T, typename ElementT = typename T::value_type,
-            typename = typename std::enable_if<
-                detail::is_complex_t<T>::value &&
-                (std::numeric_limits<ElementT>::is_integer ||
-                 is_valid_cpp_fp_type<ElementT>::value)>::type>
+  template <
+      typename T, typename ElementT = typename T::value_type,
+      typename = std::enable_if_t<detail::is_complex_t<T>::value &&
+                                  (std::numeric_limits<ElementT>::is_integer ||
+                                   is_valid_cpp_fp_type<ElementT>::value)>>
   static DenseElementsAttr get(const ShapedType &type, ArrayRef<T> values) {
     const char *data = reinterpret_cast<const char *>(values.data());
     return getRawComplex(type, ArrayRef<char>(data, values.size() * sizeof(T)),
@@ -376,18 +376,18 @@ class DenseElementsAttr : public Attribute {
   /// Return the splat value for this attribute. This asserts that the attribute
   /// corresponds to a splat.
   template <typename T>
-  typename std::enable_if<!std::is_base_of<Attribute, T>::value ||
-                              std::is_same<Attribute, T>::value,
-                          T>::type
+  std::enable_if_t<!std::is_base_of<Attribute, T>::value ||
+                       std::is_same<Attribute, T>::value,
+                   T>
   getSplatValue() const {
     assert(isSplat() && "expected the attribute to be a splat");
     return *value_begin<T>();
   }
   /// Return the splat value for derived attribute element types.
   template <typename T>
-  typename std::enable_if<std::is_base_of<Attribute, T>::value &&
-                              !std::is_same<Attribute, T>::value,
-                          T>::type
+  std::enable_if_t<std::is_base_of<Attribute, T>::value &&
+                       !std::is_same<Attribute, T>::value,
+                   T>
   getSplatValue() const {
     return getSplatValue<Attribute>().template cast<T>();
   }
@@ -434,9 +434,9 @@ class DenseElementsAttr : public Attribute {
   /// values.
   template <typename T>
   using IntFloatValueTemplateCheckT =
-      typename std::enable_if<(!std::is_same<T, bool>::value &&
-                               std::numeric_limits<T>::is_integer) ||
-                              is_valid_cpp_fp_type<T>::value>::type;
+      std::enable_if_t<(!std::is_same<T, bool>::value &&
+                        std::numeric_limits<T>::is_integer) ||
+                       is_valid_cpp_fp_type<T>::value>;
   template <typename T, typename = IntFloatValueTemplateCheckT<T>>
   FailureOr<iterator_range_impl<ElementIterator<T>>> tryGetValues() const {
     if (!isValidIntOrFloat(sizeof(T), std::numeric_limits<T>::is_integer,
@@ -452,9 +452,9 @@ class DenseElementsAttr : public Attribute {
   /// Try to get the held element values as a range of std::complex.
   template <typename T, typename ElementT>
   using ComplexValueTemplateCheckT =
-      typename std::enable_if<detail::is_complex_t<T>::value &&
-                              (std::numeric_limits<ElementT>::is_integer ||
-                               is_valid_cpp_fp_type<ElementT>::value)>::type;
+      std::enable_if_t<detail::is_complex_t<T>::value &&
+                       (std::numeric_limits<ElementT>::is_integer ||
+                        is_valid_cpp_fp_type<ElementT>::value)>;
   template <typename T, typename ElementT = typename T::value_type,
             typename = ComplexValueTemplateCheckT<T, ElementT>>
   FailureOr<iterator_range_impl<ElementIterator<T>>> tryGetValues() const {
@@ -471,7 +471,7 @@ class DenseElementsAttr : public Attribute {
   /// Try to get the held element values as a range of StringRef.
   template <typename T>
   using StringRefValueTemplateCheckT =
-      typename std::enable_if<std::is_same<T, StringRef>::value>::type;
+      std::enable_if_t<std::is_same<T, StringRef>::value>;
   template <typename T, typename = StringRefValueTemplateCheckT<T>>
   FailureOr<iterator_range_impl<ElementIterator<StringRef>>>
   tryGetValues() const {
@@ -486,7 +486,7 @@ class DenseElementsAttr : public Attribute {
   /// Try to get the held element values as a range of Attributes.
   template <typename T>
   using AttributeValueTemplateCheckT =
-      typename std::enable_if<std::is_same<T, Attribute>::value>::type;
+      std::enable_if_t<std::is_same<T, Attribute>::value>;
   template <typename T, typename = AttributeValueTemplateCheckT<T>>
   FailureOr<iterator_range_impl<AttributeElementIterator>>
   tryGetValues() const {
@@ -499,8 +499,8 @@ class DenseElementsAttr : public Attribute {
   /// attribute type.
   template <typename T>
   using DerivedAttrValueTemplateCheckT =
-      typename std::enable_if<std::is_base_of<Attribute, T>::value &&
-                              !std::is_same<Attribute, T>::value>::type;
+      std::enable_if_t<std::is_base_of<Attribute, T>::value &&
+                       !std::is_same<Attribute, T>::value>;
   template <typename T>
   struct DerivedAttributeElementIterator
       : public llvm::mapped_iterator_base<DerivedAttributeElementIterator<T>,
@@ -525,7 +525,7 @@ class DenseElementsAttr : public Attribute {
   /// this attribute must be of integer type of bitwidth 1.
   template <typename T>
   using BoolValueTemplateCheckT =
-      typename std::enable_if<std::is_same<T, bool>::value>::type;
+      std::enable_if_t<std::is_same<T, bool>::value>;
   template <typename T, typename = BoolValueTemplateCheckT<T>>
   FailureOr<iterator_range_impl<BoolElementIterator>> tryGetValues() const {
     if (!isValidBool())
@@ -539,7 +539,7 @@ class DenseElementsAttr : public Attribute {
   /// of this attribute must be of integer type.
   template <typename T>
   using APIntValueTemplateCheckT =
-      typename std::enable_if<std::is_same<T, APInt>::value>::type;
+      std::enable_if_t<std::is_same<T, APInt>::value>;
   template <typename T, typename = APIntValueTemplateCheckT<T>>
   FailureOr<iterator_range_impl<IntElementIterator>> tryGetValues() const {
     if (!getElementType().isIntOrIndex())
@@ -551,8 +551,8 @@ class DenseElementsAttr : public Attribute {
   /// Try to get the held element values as a range of complex APInts. The
   /// element type of this attribute must be a complex of integer type.
   template <typename T>
-  using ComplexAPIntValueTemplateCheckT = typename std::enable_if<
-      std::is_same<T, std::complex<APInt>>::value>::type;
+  using ComplexAPIntValueTemplateCheckT =
+      std::enable_if_t<std::is_same<T, std::complex<APInt>>::value>;
   template <typename T, typename = ComplexAPIntValueTemplateCheckT<T>>
   FailureOr<iterator_range_impl<ComplexIntElementIterator>>
   tryGetValues() const {
@@ -563,7 +563,7 @@ class DenseElementsAttr : public Attribute {
   /// of this attribute must be of float type.
   template <typename T>
   using APFloatValueTemplateCheckT =
-      typename std::enable_if<std::is_same<T, APFloat>::value>::type;
+      std::enable_if_t<std::is_same<T, APFloat>::value>;
   template <typename T, typename = APFloatValueTemplateCheckT<T>>
   FailureOr<iterator_range_impl<FloatElementIterator>> tryGetValues() const {
     return tryGetFloatValues();
@@ -572,8 +572,8 @@ class DenseElementsAttr : public Attribute {
   /// Try to get the held element values as a range of complex APFloat. The
   /// element type of this attribute must be a complex of float type.
   template <typename T>
-  using ComplexAPFloatValueTemplateCheckT = typename std::enable_if<
-      std::is_same<T, std::complex<APFloat>>::value>::type;
+  using ComplexAPFloatValueTemplateCheckT =
+      std::enable_if_t<std::is_same<T, std::complex<APFloat>>::value>;
   template <typename T, typename = ComplexAPFloatValueTemplateCheckT<T>>
   FailureOr<iterator_range_impl<ComplexFloatElementIterator>>
   tryGetValues() const {

diff  --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td
index da24332b1c567..06eb6cb5f0424 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.td
+++ b/mlir/include/mlir/IR/BuiltinAttributes.td
@@ -926,32 +926,30 @@ def Builtin_SparseElementsAttr : Builtin_Attr<
     /// by the 'iterator' class.
     /// Get a zero for a given attribute type.
     template <typename T>
-    typename std::enable_if<std::is_base_of<Attribute, T>::value, T>::type
+    std::enable_if_t<std::is_base_of<Attribute, T>::value, T>
     getZeroValue() const {
       return getZeroAttr().template cast<T>();
     }
     /// Get a zero for an APInt.
     template <typename T>
-    typename std::enable_if<std::is_same<APInt, T>::value, T>::type
+    std::enable_if_t<std::is_same<APInt, T>::value, T>
     getZeroValue() const {
       return getZeroAPInt();
     }
     template <typename T>
-    typename std::enable_if<std::is_same<std::complex<APInt>, T>::value,
-                            T>::type
+    std::enable_if_t<std::is_same<std::complex<APInt>, T>::value, T>
     getZeroValue() const {
       APInt intZero = getZeroAPInt();
       return {intZero, intZero};
     }
     /// Get a zero for an APFloat.
     template <typename T>
-    typename std::enable_if<std::is_same<APFloat, T>::value, T>::type
+    std::enable_if_t<std::is_same<APFloat, T>::value, T>
     getZeroValue() const {
       return getZeroAPFloat();
     }
     template <typename T>
-    typename std::enable_if<std::is_same<std::complex<APFloat>, T>::value,
-                            T>::type
+    std::enable_if_t<std::is_same<std::complex<APFloat>, T>::value, T>
     getZeroValue() const {
       APFloat floatZero = getZeroAPFloat();
       return {floatZero, floatZero};
@@ -959,14 +957,13 @@ def Builtin_SparseElementsAttr : Builtin_Attr<
 
     /// Get a zero for an C++ integer, float, StringRef, or complex type.
     template <typename T>
-    typename std::enable_if<
-        std::numeric_limits<T>::is_integer ||
-            DenseElementsAttr::is_valid_cpp_fp_type<T>::value ||
-            std::is_same<T, StringRef>::value ||
-            (detail::is_complex_t<T>::value &&
-             !llvm::is_one_of<T, std::complex<APInt>,
-                              std::complex<APFloat>>::value),
-        T>::type
+    std::enable_if_t<std::numeric_limits<T>::is_integer ||
+                         DenseElementsAttr::is_valid_cpp_fp_type<T>::value ||
+                         std::is_same<T, StringRef>::value ||
+                         (detail::is_complex_t<T>::value &&
+                          !llvm::is_one_of<T, std::complex<APInt>,
+                                           std::complex<APFloat>>::value),
+                     T>
     getZeroValue() const {
       return T();
     }

diff  --git a/mlir/include/mlir/IR/Diagnostics.h b/mlir/include/mlir/IR/Diagnostics.h
index 0494cdaca0342..1123adc814364 100644
--- a/mlir/include/mlir/IR/Diagnostics.h
+++ b/mlir/include/mlir/IR/Diagnostics.h
@@ -62,18 +62,16 @@ class DiagnosticArgument {
   // Construct from a signed integer.
   template <typename T>
   explicit DiagnosticArgument(
-      T val,
-      typename std::enable_if<std::is_signed<T>::value &&
+      T val, std::enable_if_t<std::is_signed<T>::value &&
                               std::numeric_limits<T>::is_integer &&
-                              sizeof(T) <= sizeof(int64_t)>::type * = nullptr)
+                              sizeof(T) <= sizeof(int64_t)> * = nullptr)
       : kind(DiagnosticArgumentKind::Integer), opaqueVal(int64_t(val)) {}
   // Construct from an unsigned integer.
   template <typename T>
   explicit DiagnosticArgument(
-      T val,
-      typename std::enable_if<std::is_unsigned<T>::value &&
+      T val, std::enable_if_t<std::is_unsigned<T>::value &&
                               std::numeric_limits<T>::is_integer &&
-                              sizeof(T) <= sizeof(uint64_t)>::type * = nullptr)
+                              sizeof(T) <= sizeof(uint64_t)> * = nullptr)
       : kind(DiagnosticArgumentKind::Unsigned), opaqueVal(uint64_t(val)) {}
   // Construct from a string reference.
   explicit DiagnosticArgument(StringRef val)
@@ -175,10 +173,9 @@ class Diagnostic {
 
   /// Stream operator for inserting new diagnostic arguments.
   template <typename Arg>
-  typename std::enable_if<
-      !std::is_convertible<Arg, StringRef>::value &&
-          std::is_constructible<DiagnosticArgument, Arg>::value,
-      Diagnostic &>::type
+  std::enable_if_t<!std::is_convertible<Arg, StringRef>::value &&
+                       std::is_constructible<DiagnosticArgument, Arg>::value,
+                   Diagnostic &>
   operator<<(Arg &&val) {
     arguments.push_back(DiagnosticArgument(std::forward<Arg>(val)));
     return *this;

diff  --git a/mlir/include/mlir/IR/ImplicitLocOpBuilder.h b/mlir/include/mlir/IR/ImplicitLocOpBuilder.h
index 8bbee78f85812..f2985d4dd9dfc 100644
--- a/mlir/include/mlir/IR/ImplicitLocOpBuilder.h
+++ b/mlir/include/mlir/IR/ImplicitLocOpBuilder.h
@@ -77,16 +77,14 @@ class ImplicitLocOpBuilder : public mlir::OpBuilder {
 
   /// Overload to create or fold a single result operation.
   template <typename OpTy, typename... Args>
-  typename std::enable_if<OpTy::template hasTrait<mlir::OpTrait::OneResult>(),
-                          Value>::type
+  std::enable_if_t<OpTy::template hasTrait<mlir::OpTrait::OneResult>(), Value>
   createOrFold(Args &&...args) {
     return OpBuilder::createOrFold<OpTy>(curLoc, std::forward<Args>(args)...);
   }
 
   /// Overload to create or fold a zero result operation.
   template <typename OpTy, typename... Args>
-  typename std::enable_if<OpTy::template hasTrait<mlir::OpTrait::ZeroResults>(),
-                          OpTy>::type
+  std::enable_if_t<OpTy::template hasTrait<mlir::OpTrait::ZeroResults>(), OpTy>
   createOrFold(Args &&...args) {
     return OpBuilder::createOrFold<OpTy>(curLoc, std::forward<Args>(args)...);
   }

diff  --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h
index fc7619b620657..ae8cef4a6e63e 100644
--- a/mlir/include/mlir/IR/Matchers.h
+++ b/mlir/include/mlir/IR/Matchers.h
@@ -28,11 +28,10 @@ template <
     typename AttrClass,
     // Require AttrClass to be a derived class from Attribute and get its
     // value type
-    typename ValueType =
-        typename std::enable_if<std::is_base_of<Attribute, AttrClass>::value,
-                                AttrClass>::type::ValueType,
+    typename ValueType = typename std::enable_if_t<
+        std::is_base_of<Attribute, AttrClass>::value, AttrClass>::ValueType,
     // Require the ValueType is not void
-    typename = typename std::enable_if<!std::is_void<ValueType>::value>::type>
+    typename = std::enable_if_t<!std::is_void<ValueType>::value>>
 struct attr_value_binder {
   ValueType *bind_value;
 

diff  --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h
index 8bd3402745f11..6d49a8f9e9cf4 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -147,8 +147,8 @@ class OpState {
   /// See Operation::walk for more details.
   template <WalkOrder Order = WalkOrder::PostOrder, typename FnT,
             typename RetT = detail::walkResultType<FnT>>
-  typename std::enable_if<
-      llvm::function_traits<std::decay_t<FnT>>::num_args == 1, RetT>::type
+  std::enable_if_t<llvm::function_traits<std::decay_t<FnT>>::num_args == 1,
+                   RetT>
   walk(FnT &&callback) {
     return state->walk<Order>(std::forward<FnT>(callback));
   }
@@ -175,8 +175,8 @@ class OpState {
   ///         return WalkResult::advance();
   ///       });
   template <typename FnT, typename RetT = detail::walkResultType<FnT>>
-  typename std::enable_if<
-      llvm::function_traits<std::decay_t<FnT>>::num_args == 2, RetT>::type
+  std::enable_if_t<llvm::function_traits<std::decay_t<FnT>>::num_args == 2,
+                   RetT>
   walk(FnT &&callback) {
     return state->walk(std::forward<FnT>(callback));
   }

diff  --git a/mlir/include/mlir/IR/OpImplementation.h b/mlir/include/mlir/IR/OpImplementation.h
index 332b242129971..541b3c9caab0d 100644
--- a/mlir/include/mlir/IR/OpImplementation.h
+++ b/mlir/include/mlir/IR/OpImplementation.h
@@ -272,15 +272,14 @@ operator<<(AsmPrinterT &p, double value) {
 // Support printing anything that isn't convertible to one of the other
 // streamable types, even if it isn't exactly one of them. For example, we want
 // to print FunctionType with the Type version above, not have it match this.
-template <
-    typename AsmPrinterT, typename T,
-    typename std::enable_if<!std::is_convertible<T &, Value &>::value &&
-                                !std::is_convertible<T &, Type &>::value &&
-                                !std::is_convertible<T &, Attribute &>::value &&
-                                !std::is_convertible<T &, ValueRange>::value &&
-                                !std::is_convertible<T &, APFloat &>::value &&
-                                !llvm::is_one_of<T, bool, float, double>::value,
-                            T>::type * = nullptr>
+template <typename AsmPrinterT, typename T,
+          std::enable_if_t<!std::is_convertible<T &, Value &>::value &&
+                               !std::is_convertible<T &, Type &>::value &&
+                               !std::is_convertible<T &, Attribute &>::value &&
+                               !std::is_convertible<T &, ValueRange>::value &&
+                               !std::is_convertible<T &, APFloat &>::value &&
+                               !llvm::is_one_of<T, bool, float, double>::value,
+                           T> * = nullptr>
 inline std::enable_if_t<std::is_base_of<AsmPrinter, AsmPrinterT>::value,
                         AsmPrinterT &>
 operator<<(AsmPrinterT &p, const T &other) {
@@ -429,9 +428,9 @@ inline OpAsmPrinter &operator<<(OpAsmPrinter &p, Value value) {
 }
 
 template <typename T,
-          typename std::enable_if<std::is_convertible<T &, ValueRange>::value &&
-                                      !std::is_convertible<T &, Value &>::value,
-                                  T>::type * = nullptr>
+          std::enable_if_t<std::is_convertible<T &, ValueRange>::value &&
+                               !std::is_convertible<T &, Value &>::value,
+                           T> * = nullptr>
 inline OpAsmPrinter &operator<<(OpAsmPrinter &p, const T &values) {
   p.printOperands(values);
   return p;

diff  --git a/mlir/include/mlir/IR/Operation.h b/mlir/include/mlir/IR/Operation.h
index f785214cd8cb0..2b87dca6578e4 100644
--- a/mlir/include/mlir/IR/Operation.h
+++ b/mlir/include/mlir/IR/Operation.h
@@ -569,8 +569,8 @@ class alignas(8) Operation final
   ///       });
   template <WalkOrder Order = WalkOrder::PostOrder, typename FnT,
             typename RetT = detail::walkResultType<FnT>>
-  typename std::enable_if<
-      llvm::function_traits<std::decay_t<FnT>>::num_args == 1, RetT>::type
+  std::enable_if_t<llvm::function_traits<std::decay_t<FnT>>::num_args == 1,
+                   RetT>
   walk(FnT &&callback) {
     return detail::walk<Order>(this, std::forward<FnT>(callback));
   }
@@ -597,8 +597,8 @@ class alignas(8) Operation final
   ///         return WalkResult::advance();
   ///       });
   template <typename FnT, typename RetT = detail::walkResultType<FnT>>
-  typename std::enable_if<
-      llvm::function_traits<std::decay_t<FnT>>::num_args == 2, RetT>::type
+  std::enable_if_t<llvm::function_traits<std::decay_t<FnT>>::num_args == 2,
+                   RetT>
   walk(FnT &&callback) {
     return detail::walk(this, std::forward<FnT>(callback));
   }

diff  --git a/mlir/include/mlir/IR/Region.h b/mlir/include/mlir/IR/Region.h
index 6e4b141cdc510..d726d93b287e6 100644
--- a/mlir/include/mlir/IR/Region.h
+++ b/mlir/include/mlir/IR/Region.h
@@ -275,8 +275,7 @@ class Region {
   /// for pre-order erasure. See Operation::walk for more details.
   template <WalkOrder Order = WalkOrder::PostOrder, typename FnT,
             typename RetT = detail::walkResultType<FnT>>
-  typename std::enable_if<std::is_same<RetT, void>::value, RetT>::type
-  walk(FnT &&callback) {
+  std::enable_if_t<std::is_same<RetT, void>::value, RetT> walk(FnT &&callback) {
     for (auto &block : *this)
       block.walk<Order>(callback);
   }
@@ -294,7 +293,7 @@ class Region {
   /// See Operation::walk for more details.
   template <WalkOrder Order = WalkOrder::PostOrder, typename FnT,
             typename RetT = detail::walkResultType<FnT>>
-  typename std::enable_if<std::is_same<RetT, WalkResult>::value, RetT>::type
+  std::enable_if_t<std::is_same<RetT, WalkResult>::value, RetT>
   walk(FnT &&callback) {
     for (auto &block : *this)
       if (block.walk<Order>(callback).wasInterrupted())

diff  --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h
index 7aafd7fe88ccf..5cac1e240d653 100644
--- a/mlir/include/mlir/IR/Types.h
+++ b/mlir/include/mlir/IR/Types.h
@@ -325,10 +325,10 @@ struct PointerLikeTypeTraits<mlir::Type> {
 /// We provide a cast between To and From if From is mlir::Type or derives from
 /// it
 template <typename To, typename From>
-struct CastInfo<To, From,
-                typename std::enable_if<
-                    std::is_same_v<mlir::Type, std::remove_const_t<From>> ||
-                    std::is_base_of_v<mlir::Type, From>>::type>
+struct CastInfo<
+    To, From,
+    std::enable_if_t<std::is_same_v<mlir::Type, std::remove_const_t<From>> ||
+                     std::is_base_of_v<mlir::Type, From>>>
     : NullableValueCastFailed<To>,
       DefaultDoCastIfPossible<To, From, CastInfo<To, From>> {
   /// Arguments are taken as mlir::Type here and not as From.

diff  --git a/mlir/include/mlir/IR/Visitors.h b/mlir/include/mlir/IR/Visitors.h
index 661541a555233..756b05de6ac4c 100644
--- a/mlir/include/mlir/IR/Visitors.h
+++ b/mlir/include/mlir/IR/Visitors.h
@@ -164,8 +164,8 @@ template <
     WalkOrder Order = WalkOrder::PostOrder, typename FuncTy,
     typename ArgT = detail::first_argument<FuncTy>,
     typename RetT = decltype(std::declval<FuncTy>()(std::declval<ArgT>()))>
-typename std::enable_if<
-    llvm::is_one_of<ArgT, Operation *, Region *, Block *>::value, RetT>::type
+std::enable_if_t<llvm::is_one_of<ArgT, Operation *, Region *, Block *>::value,
+                 RetT>
 walk(Operation *op, FuncTy &&callback) {
   return detail::walk(op, function_ref<RetT(ArgT)>(callback), Order);
 }
@@ -185,10 +185,10 @@ template <
     WalkOrder Order = WalkOrder::PostOrder, typename FuncTy,
     typename ArgT = detail::first_argument<FuncTy>,
     typename RetT = decltype(std::declval<FuncTy>()(std::declval<ArgT>()))>
-typename std::enable_if<
+std::enable_if_t<
     !llvm::is_one_of<ArgT, Operation *, Region *, Block *>::value &&
         std::is_same<RetT, void>::value,
-    RetT>::type
+    RetT>
 walk(Operation *op, FuncTy &&callback) {
   auto wrapperFn = [&](Operation *op) {
     if (auto derivedOp = dyn_cast<ArgT>(op))
@@ -220,10 +220,10 @@ template <
     WalkOrder Order = WalkOrder::PostOrder, typename FuncTy,
     typename ArgT = detail::first_argument<FuncTy>,
     typename RetT = decltype(std::declval<FuncTy>()(std::declval<ArgT>()))>
-typename std::enable_if<
+std::enable_if_t<
     !llvm::is_one_of<ArgT, Operation *, Region *, Block *>::value &&
         std::is_same<RetT, WalkResult>::value,
-    RetT>::type
+    RetT>
 walk(Operation *op, FuncTy &&callback) {
   auto wrapperFn = [&](Operation *op) {
     if (auto derivedOp = dyn_cast<ArgT>(op))
@@ -261,7 +261,7 @@ walk(Operation *op,
 template <typename FuncTy, typename ArgT = detail::first_argument<FuncTy>,
           typename RetT = decltype(std::declval<FuncTy>()(
               std::declval<ArgT>(), std::declval<const WalkStage &>()))>
-typename std::enable_if<std::is_same<ArgT, Operation *>::value, RetT>::type
+std::enable_if_t<std::is_same<ArgT, Operation *>::value, RetT>
 walk(Operation *op, FuncTy &&callback) {
   return detail::walk(op,
                       function_ref<RetT(ArgT, const WalkStage &)>(callback));
@@ -276,9 +276,9 @@ walk(Operation *op, FuncTy &&callback) {
 template <typename FuncTy, typename ArgT = detail::first_argument<FuncTy>,
           typename RetT = decltype(std::declval<FuncTy>()(
               std::declval<ArgT>(), std::declval<const WalkStage &>()))>
-typename std::enable_if<!std::is_same<ArgT, Operation *>::value &&
-                            std::is_same<RetT, void>::value,
-                        RetT>::type
+std::enable_if_t<!std::is_same<ArgT, Operation *>::value &&
+                     std::is_same<RetT, void>::value,
+                 RetT>
 walk(Operation *op, FuncTy &&callback) {
   auto wrapperFn = [&](Operation *op, const WalkStage &stage) {
     if (auto derivedOp = dyn_cast<ArgT>(op))
@@ -301,9 +301,9 @@ walk(Operation *op, FuncTy &&callback) {
 template <typename FuncTy, typename ArgT = detail::first_argument<FuncTy>,
           typename RetT = decltype(std::declval<FuncTy>()(
               std::declval<ArgT>(), std::declval<const WalkStage &>()))>
-typename std::enable_if<!std::is_same<ArgT, Operation *>::value &&
-                            std::is_same<RetT, WalkResult>::value,
-                        RetT>::type
+std::enable_if_t<!std::is_same<ArgT, Operation *>::value &&
+                     std::is_same<RetT, WalkResult>::value,
+                 RetT>
 walk(Operation *op, FuncTy &&callback) {
   auto wrapperFn = [&](Operation *op, const WalkStage &stage) {
     if (auto derivedOp = dyn_cast<ArgT>(op))

diff  --git a/mlir/include/mlir/Support/StorageUniquer.h b/mlir/include/mlir/Support/StorageUniquer.h
index f0ea28c743ee9..dc4a6921bc183 100644
--- a/mlir/include/mlir/Support/StorageUniquer.h
+++ b/mlir/include/mlir/Support/StorageUniquer.h
@@ -296,18 +296,18 @@ class StorageUniquer {
   /// Used to construct an instance of 'ImplTy::KeyTy' if there is an
   /// 'ImplTy::getKey' function for the provided arguments.
   template <typename ImplTy, typename... Args>
-  static typename std::enable_if<
+  static std::enable_if_t<
       llvm::is_detected<detail::has_impltype_getkey_t, ImplTy, Args...>::value,
-      typename ImplTy::KeyTy>::type
+      typename ImplTy::KeyTy>
   getKey(Args &&...args) {
     return ImplTy::getKey(args...);
   }
   /// If there is no 'ImplTy::getKey' method, then we try to directly construct
   /// the 'ImplTy::KeyTy' with the provided arguments.
   template <typename ImplTy, typename... Args>
-  static typename std::enable_if<
+  static std::enable_if_t<
       !llvm::is_detected<detail::has_impltype_getkey_t, ImplTy, Args...>::value,
-      typename ImplTy::KeyTy>::type
+      typename ImplTy::KeyTy>
   getKey(Args &&...args) {
     return typename ImplTy::KeyTy(args...);
   }
@@ -319,18 +319,18 @@ class StorageUniquer {
   /// Used to generate a hash for the 'ImplTy::KeyTy' of a storage instance if
   /// there is an 'ImplTy::hashKey' overload for 'DerivedKey'.
   template <typename ImplTy, typename DerivedKey>
-  static typename std::enable_if<
+  static std::enable_if_t<
       llvm::is_detected<detail::has_impltype_hash_t, ImplTy, DerivedKey>::value,
-      ::llvm::hash_code>::type
+      ::llvm::hash_code>
   getHash(const DerivedKey &derivedKey) {
     return ImplTy::hashKey(derivedKey);
   }
   /// If there is no 'ImplTy::hashKey' default to using the 'llvm::DenseMapInfo'
   /// definition for 'DerivedKey' for generating a hash.
   template <typename ImplTy, typename DerivedKey>
-  static typename std::enable_if<!llvm::is_detected<detail::has_impltype_hash_t,
-                                                    ImplTy, DerivedKey>::value,
-                                 ::llvm::hash_code>::type
+  static std::enable_if_t<!llvm::is_detected<detail::has_impltype_hash_t,
+                                             ImplTy, DerivedKey>::value,
+                          ::llvm::hash_code>
   getHash(const DerivedKey &derivedKey) {
     return DenseMapInfo<DerivedKey>::getHashValue(derivedKey);
   }

diff  --git a/mlir/include/mlir/Transforms/DialectConversion.h b/mlir/include/mlir/Transforms/DialectConversion.h
index 72ab780ee9b61..061edb196f0fc 100644
--- a/mlir/include/mlir/Transforms/DialectConversion.h
+++ b/mlir/include/mlir/Transforms/DialectConversion.h
@@ -721,7 +721,7 @@ class ConversionTarget {
     addDynamicallyLegalOp<OpT2, OpTs...>(callback);
   }
   template <typename OpT, class Callable>
-  typename std::enable_if<!std::is_invocable_v<Callable, Operation *>>::type
+  std::enable_if_t<!std::is_invocable_v<Callable, Operation *>>
   addDynamicallyLegalOp(Callable &&callback) {
     addDynamicallyLegalOp<OpT>(
         [=](Operation *op) { return callback(cast<OpT>(op)); });
@@ -760,7 +760,7 @@ class ConversionTarget {
     markOpRecursivelyLegal<OpT2, OpTs...>(callback);
   }
   template <typename OpT, class Callable>
-  typename std::enable_if<!std::is_invocable_v<Callable, Operation *>>::type
+  std::enable_if_t<!std::is_invocable_v<Callable, Operation *>>
   markOpRecursivelyLegal(Callable &&callback) {
     markOpRecursivelyLegal<OpT>(
         [=](Operation *op) { return callback(cast<OpT>(op)); });

diff  --git a/mlir/include/mlir/Transforms/FoldUtils.h b/mlir/include/mlir/Transforms/FoldUtils.h
index 11ff8b30f5b99..2e5a80cbce35d 100644
--- a/mlir/include/mlir/Transforms/FoldUtils.h
+++ b/mlir/include/mlir/Transforms/FoldUtils.h
@@ -86,8 +86,7 @@ class OperationFolder {
 
   /// Overload to create or fold a single result operation.
   template <typename OpTy, typename... Args>
-  typename std::enable_if<OpTy::template hasTrait<OpTrait::OneResult>(),
-                          Value>::type
+  std::enable_if_t<OpTy::template hasTrait<OpTrait::OneResult>(), Value>
   create(OpBuilder &builder, Location location, Args &&...args) {
     SmallVector<Value, 1> results;
     create<OpTy>(builder, results, location, std::forward<Args>(args)...);
@@ -96,8 +95,7 @@ class OperationFolder {
 
   /// Overload to create or fold a zero result operation.
   template <typename OpTy, typename... Args>
-  typename std::enable_if<OpTy::template hasTrait<OpTrait::ZeroResults>(),
-                          OpTy>::type
+  std::enable_if_t<OpTy::template hasTrait<OpTrait::ZeroResults>(), OpTy>
   create(OpBuilder &builder, Location location, Args &&...args) {
     auto op = builder.create<OpTy>(location, std::forward<Args>(args)...);
     SmallVector<Value, 0> unused;


        


More information about the Mlir-commits mailing list