Skip to content

Commit 4b25f4d

Browse files
committed
Followup to void return functions in CIR
Fix some comments and some formatting. Change which function prints the opening `(` of the parameter list of a function type. No changes in behavior.
1 parent 88e90df commit 4b25f4d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

clang/include/clang/CIR/Dialect/IR/CIRTypes.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def CIR_FuncType : CIR_Type<"Func", "func"> {
296296
}];
297297

298298
let builders = [
299-
// Construct with an actual return type or explicit !cir.void
299+
// Construct with an actual return type or implicit !cir.void.
300300
TypeBuilderWithInferredContext<(ins
301301
"llvm::ArrayRef<mlir::Type>":$inputs, "mlir::Type":$returnType,
302302
CArg<"bool", "false">:$isVarArg), [{
@@ -317,7 +317,7 @@ def CIR_FuncType : CIR_Type<"Func", "func"> {
317317
unsigned getNumInputs() const { return getInputs().size(); }
318318

319319
/// Returns the result type of the function as an actual return type or
320-
/// explicit !cir.void
320+
/// explicit !cir.void.
321321
mlir::Type getReturnType() const;
322322

323323
/// Returns the result type of the function as an ArrayRef, enabling better

clang/lib/CIR/Dialect/IR/CIRTypes.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,13 @@ static mlir::ParseResult parseFuncTypeReturn(mlir::AsmParser &p,
347347
mlir::Type type;
348348
if (p.parseType(type))
349349
return mlir::failure();
350-
if (isa<cir::VoidType>(type))
350+
if (isa<cir::VoidType>(type)) {
351351
// An explicit !cir.void means also no return type.
352352
optionalReturnType = {};
353-
else
353+
} else {
354354
// Otherwise use the actual type.
355355
optionalReturnType = type;
356+
}
356357
return p.parseLParen();
357358
}
358359

@@ -361,7 +362,6 @@ static void printFuncTypeReturn(mlir::AsmPrinter &p,
361362
mlir::Type optionalReturnType) {
362363
if (optionalReturnType)
363364
p << optionalReturnType << ' ';
364-
p << '(';
365365
}
366366

367367
static mlir::ParseResult
@@ -399,6 +399,7 @@ parseFuncTypeArgs(mlir::AsmParser &p, llvm::SmallVector<mlir::Type> &params,
399399
static void printFuncTypeArgs(mlir::AsmPrinter &p,
400400
mlir::ArrayRef<mlir::Type> params,
401401
bool isVarArg) {
402+
p << '(';
402403
llvm::interleaveComma(params, p,
403404
[&p](mlir::Type type) { p.printType(type); });
404405
if (isVarArg) {

0 commit comments

Comments
 (0)