[Mlir-commits] [mlir] [MLIR][ODS] Parse prop-dict fields with custom parsers (PR #217590)
Mehdi Amini
llvmlistbot at llvm.org
Fri Aug 21 04:26:09 PDT 2026
================
@@ -167,14 +180,51 @@ namespace detail {
template <typename T>
using has_push_back_t = decltype(std::declval<T>().push_back(
std::declval<typename T::value_type &&>()));
+
+template <typename StorageType, typename = void>
+struct HasFieldParser : std::false_type {};
+
+template <typename StorageType>
+struct HasFieldParser<StorageType,
+ std::void_t<decltype(sizeof(FieldParser<StorageType>)),
+ decltype(FieldParser<StorageType>::parse(
+ std::declval<OpAsmParser &>()))>>
+ : std::true_type {};
+
+template <typename ContainerT, typename = void>
+struct HasFieldParserContainer : std::false_type {};
+
+template <typename ContainerT>
+struct HasFieldParserContainer<ContainerT,
+ std::void_t<has_push_back_t<ContainerT>>>
+ : HasFieldParser<typename ContainerT::value_type> {};
+
+template <typename Parser, typename = void>
+struct IsKeyValueCompositional : std::true_type {};
+
+template <typename Parser>
+struct IsKeyValueCompositional<
+ Parser, std::void_t<decltype(Parser::isKeyValueCompositional)>>
+ : std::bool_constant<Parser::isKeyValueCompositional> {};
+
+/// Whether the selected FieldParser consumes exactly one value in a keyed
+/// property list. Parser specializations may set isKeyValueCompositional to
+/// false if they can succeed without consuming a token or consume an
+/// undelimited comma-separated list.
+template <typename StorageType>
+struct HasKeyValueFieldParser
+ : std::conjunction<HasFieldParser<StorageType>,
+ IsKeyValueCompositional<FieldParser<StorageType>>> {};
} // namespace detail
/// Parse any container that supports back insertion as a list.
template <typename ContainerT>
-struct FieldParser<ContainerT,
- std::enable_if_t<llvm::is_detected<detail::has_push_back_t,
- ContainerT>::value,
- ContainerT>> {
+struct FieldParser<
----------------
joker-eph wrote:
The containers don't do that for being able to compose with the enclosing context which manages the brackets...
https://github.com/llvm/llvm-project/pull/217590
More information about the Mlir-commits
mailing list