[clang] [CIR] Better handling of `void` function return (PR #128089)
Ronan Keryell via cfe-commits
cfe-commits at lists.llvm.org
Fri Feb 21 13:39:04 PST 2025
================
@@ -331,9 +335,38 @@ FuncType FuncType::clone(TypeRange inputs, TypeRange results) const {
return get(llvm::to_vector(inputs), results[0], isVarArg());
}
-mlir::ParseResult parseFuncTypeArgs(mlir::AsmParser &p,
- llvm::SmallVector<mlir::Type> ¶ms,
- bool &isVarArg) {
+// A special parser is needed for function returning void to handle the missing
+// type.
+static mlir::ParseResult parseFuncTypeReturn(mlir::AsmParser &p,
+ mlir::Type &optionalReturnType) {
+ if (succeeded(p.parseOptionalLParen())) {
+ // If we have already a '(', the function has no return type
+ optionalReturnType = {};
+ return mlir::success();
+ }
+ mlir::Type type;
+ if (p.parseType(type))
+ return mlir::failure();
+ if (isa<cir::VoidType>(type))
+ // An explicit !cir.void means also no return type.
----------------
keryell wrote:
We could put the comment before the if otherwise.
https://github.com/llvm/llvm-project/pull/128089
More information about the cfe-commits
mailing list