[flang-commits] [flang] [mlir] [mlir] allow function type cloning to fail (PR #137130)

Oleksandr Alex Zinenko via flang-commits flang-commits at lists.llvm.org
Fri Apr 25 00:49:07 PDT 2025


================
@@ -232,7 +232,10 @@ LLVMFunctionType::getChecked(function_ref<InFlightDiagnostic()> emitError,
 
 LLVMFunctionType LLVMFunctionType::clone(TypeRange inputs,
                                          TypeRange results) const {
-  assert(results.size() == 1 && "expected a single result type");
+  if (results.size() != 1 || !isValidResultType(results[0]))
+    return {};
+  if (!llvm::all_of(inputs, isValidArgumentType))
+    return {};
   return get(results[0], llvm::to_vector(inputs), isVarArg());
----------------
ftynse wrote:

It emits a diagnostic that we don't want here. And we don't have an equivalent of `llvm::nulls` for diagnostics were we could just send it to the void. Overriding the handler locally sounds a bit too heavy here...

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


More information about the flang-commits mailing list