[clang] [CIR][NFC] Fix regression in clang/test/CIR/IR/func.cir (PR #188069)

Sirui Mu via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 24 06:50:21 PDT 2026


================
@@ -2215,17 +2215,21 @@ ParseResult cir::FuncOp::parse(OpAsmParser &parser, OperationState &state) {
 
   // Parse CXXSpecialMember attribute
   if (parser.parseOptionalKeyword("special_member").succeeded()) {
-    cir::CXXCtorAttr ctorAttr;
-    cir::CXXDtorAttr dtorAttr;
-    cir::CXXAssignAttr assignAttr;
     if (parser.parseLess().failed())
       return failure();
-    if (parser.parseOptionalAttribute(ctorAttr).has_value())
-      state.addAttribute(specialMemberAttr, ctorAttr);
-    else if (parser.parseOptionalAttribute(dtorAttr).has_value())
-      state.addAttribute(specialMemberAttr, dtorAttr);
-    else if (parser.parseOptionalAttribute(assignAttr).has_value())
-      state.addAttribute(specialMemberAttr, assignAttr);
+
+    mlir::Attribute attr;
+    mlir::OptionalParseResult parseResult = parser.parseOptionalAttribute(attr);
+    if (parseResult.has_value()) {
+      if (failed(*parseResult))
+        return failure();
+      if (!mlir::isa<cir::CXXCtorAttr, cir::CXXDtorAttr, cir::CXXAssignAttr>(
+              attr))
+        return parser.emitError(parser.getCurrentLocation(),
+                                "expected a C++ special member attribute");
+      state.addAttribute(specialMemberAttr, attr);
+    }
----------------
Lancern wrote:

Updated.

https://github.com/llvm/llvm-project/pull/188069


More information about the cfe-commits mailing list