[clang] [CIR] Function type return type improvements (PR #128787)

David Olsen via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 26 14:04:47 PST 2025


================
@@ -424,6 +424,10 @@ LogicalResult cir::FuncOp::verifyType() {
   if (!isa<cir::FuncType>(type))
     return emitOpError("requires '" + getFunctionTypeAttrName().str() +
                        "' attribute of function type");
+  if (auto rt = type.getReturnTypes();
----------------
dkolsen-pgi wrote:

`rt.size() > 1` is an impossible situation.  `FuncType` stores only one `mlir::Type` return type.  There is no possible code path where `FuncType::getReturnTypes` could create an `llvm::ArrayRef<mlir::Type>` with more than one member, even if `FuncType`'s invariants were broken.

But adding a check for that here doesn't hurt.  I'll do that.

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


More information about the cfe-commits mailing list