================
@@ -152,31 +152,71 @@ void CIRDialect::printType(Type type, DialectAsmPrinter 
&os) const {
 
 // Shared helpers for StructType and UnionType parse/print.
 
-/// Parse "incomplete" or "{type, type, ...}", writing results into
-/// \p incomplete and \p members.  Returns failure if member parsing fails.
+llvm::ArrayRef<RecordMemberKind>
+cir::normalizeRecordMemberKinds(llvm::ArrayRef<RecordMemberKind> memberKinds) {
+  if (llvm::all_of(memberKinds, [](RecordMemberKind kind) {
+        return kind == RecordMemberKind::Data;
+      }))
+    return {};
+  return memberKinds;
+}
+
+/// A mark list either is absent or names every member.  An incomplete record
+/// has no members, so a mark on one is caught by the same length check.
+static mlir::LogicalResult
+verifyRecordMemberKinds(function_ref<mlir::InFlightDiagnostic()> emitError,
+                        size_t numMembers,
+                        llvm::ArrayRef<RecordMemberKind> memberKinds) {
+  if (!memberKinds.empty() && memberKinds.size() != numMembers)
+    return emitError() << "expected " << numMembers << " member kinds, got "
+                       << memberKinds.size();
+  return mlir::success();
+}
+
+/// Parse the optional mark that precedes a member type.  Only a mark keyword 
is
+/// consumed, so a member spelled as a bare builtin type still reaches the type
+/// parser, and anything else that is not a mark fails there.  A data member is
+/// spelled without a mark.
+static void parseMemberKind(mlir::AsmParser &parser, RecordMemberKind &kind) {
+  static const llvm::StringRef marks[] = {"pad", "empty"};
----------------
adams381 wrote:

The `data` mark is now optional and parses correctly.

https://github.com/llvm/llvm-project/pull/215174
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to