================
@@ -301,6 +301,50 @@ DataMemberAttr::verify(function_ref<InFlightDiagnostic()>
emitError,
return success();
}
+//===----------------------------------------------------------------------===//
+// MethodAttr definitions
+//===----------------------------------------------------------------------===//
+
+Attribute MethodAttr::parse(AsmParser &parser, Type odsType) {
+ auto ty = mlir::cast<cir::MethodType>(odsType);
+
+ if (parser.parseLess().failed())
+ return {};
+
+ // Try to parse the null pointer constant.
+ if (parser.parseOptionalKeyword("null").succeeded()) {
+ if (parser.parseGreater())
+ return {};
+ return get(ty);
+ }
+
+ // Try to parse a flat symbol ref for a pointer to non-virtual member
+ // function.
+ FlatSymbolRefAttr symbol;
+ auto parseSymbolRefResult = parser.parseOptionalAttribute(symbol);
+ if (parseSymbolRefResult.has_value()) {
+ if (parseSymbolRefResult.value().failed())
+ return {};
+ if (parser.parseGreater())
+ return {};
+ return get(ty, symbol);
+ }
+
+ return {};
+}
+
+void MethodAttr::print(AsmPrinter &printer) const {
+ auto symbol = getSymbol();
+
+ printer << '<';
+ if (symbol.has_value()) {
+ printer << *symbol;
+ } else {
+ printer << "null";
----------------
erichkeane wrote:
Beginning to question the value of having this be `null` and not just treating
the lack of a `MethodAttr` to mean `null` rather than an empty `MethodAttr`.
Can you explain the reasoning (that is, make `MethodAttr` ALWAYS have a valid
reference)?
https://github.com/llvm/llvm-project/pull/174640
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits