@@ -2619,53 +2619,18 @@ ParseResult cir::FuncOp::parse(OpAsmParser &parser, OperationState &state) {
2619
2619
state.addAttribute (annotationsNameAttr, annotations);
2620
2620
}
2621
2621
2622
- // Add CXXSpecialMember attributes .
2623
- if (mlir::succeeded (parser.parseOptionalKeyword (" ctor " ))) {
2622
+ // Add CXXSpecialMember attribute .
2623
+ if (mlir::succeeded (parser.parseOptionalKeyword (" cxx_special_member " ))) {
2624
2624
if (parser.parseLess ().failed ())
2625
2625
return failure ();
2626
-
2627
- mlir::Type type;
2628
- if (parser.parseType (type).failed ())
2629
- return failure ();
2630
-
2631
- bool defaultCtor = false , copyCtor = false ;
2632
- if (mlir::succeeded (parser.parseOptionalComma ())) {
2633
- if (parser
2634
- .parseCommaSeparatedList ([&]() {
2635
- if (mlir::succeeded (parser.parseOptionalKeyword (" default" )))
2636
- defaultCtor = true ;
2637
- else if (mlir::succeeded (parser.parseOptionalKeyword (" copy" )))
2638
- copyCtor = true ;
2639
- else
2640
- return failure ();
2641
- return success ();
2642
- })
2643
- .failed ())
2644
- return failure ();
2645
- }
2646
-
2626
+ cir::CXXCtorAttr ctor;
2627
+ if (auto oa = parser.parseOptionalAttribute (ctor); oa.has_value ())
2628
+ state.addAttribute (cxxSpecialMemberAttr, ctor);
2629
+ cir::CXXDtorAttr dtor;
2630
+ if (auto oa = parser.parseOptionalAttribute (dtor); oa.has_value ())
2631
+ state.addAttribute (cxxSpecialMemberAttr, dtor);
2647
2632
if (parser.parseGreater ().failed ())
2648
2633
return failure ();
2649
-
2650
- cir::CtorKind ctorKind = cir::CtorKind::None;
2651
- if (defaultCtor)
2652
- ctorKind = cir::CtorKind::Default;
2653
- if (copyCtor)
2654
- ctorKind = cir::CtorKind::Copy;
2655
- state.addAttribute (cxxSpecialMemberAttr, CXXCtorAttr::get (type, ctorKind));
2656
- }
2657
-
2658
- if (mlir::succeeded (parser.parseOptionalKeyword (" dtor" ))) {
2659
- if (parser.parseLess ().failed ())
2660
- return failure ();
2661
-
2662
- mlir::Type type;
2663
- if (parser.parseType (type).failed ())
2664
- return failure ();
2665
- if (parser.parseGreater ().failed ())
2666
- return failure ();
2667
-
2668
- state.addAttribute (cxxSpecialMemberAttr, CXXDtorAttr::get (type));
2669
2634
}
2670
2635
2671
2636
// If additional attributes are present, parse them.
@@ -2849,18 +2814,12 @@ void cir::FuncOp::print(OpAsmPrinter &p) {
2849
2814
}
2850
2815
2851
2816
if (getCxxSpecialMember ()) {
2852
- if (auto cxxCtor = dyn_cast<cir::CXXCtorAttr>(*getCxxSpecialMember ())) {
2853
- p << " ctor<" << cxxCtor.getType ();
2854
- if (cxxCtor.getCtorKind () == cir::CtorKind::Default)
2855
- p << " , default" ;
2856
- if (cxxCtor.getCtorKind () == cir::CtorKind::Copy)
2857
- p << " , copy" ;
2858
- p << ' >' ;
2859
- }
2860
-
2861
- if (auto cxxDtor = dyn_cast<cir::CXXDtorAttr>(*getCxxSpecialMember ())) {
2862
- p << " dtor<" << cxxDtor.getType () << " >" ;
2863
- }
2817
+ p << " cxx_special_member<" ;
2818
+ if (auto cxxCtor = dyn_cast<cir::CXXCtorAttr>(*getCxxSpecialMember ()))
2819
+ p.printAttribute (cxxCtor);
2820
+ if (auto cxxDtor = dyn_cast<cir::CXXDtorAttr>(*getCxxSpecialMember ()))
2821
+ p.printAttribute (cxxDtor);
2822
+ p << ' >' ;
2864
2823
}
2865
2824
2866
2825
function_interface_impl::printFunctionAttributes (
0 commit comments