From b5af3784a6b9c67f67a11a9308b043b877f01095 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Thu, 21 Nov 2019 04:24:52 -0800 Subject: Don't force newline before function attributes Due to legacy reasons, a newline character followed by two spaces was always inserted before the attributes of the function Op in pretty form. This breaks formatting when functions are nested in some other operations. Don't print the newline and just put the attributes on the same line, which is also more consistent with module Op. Line breaking aware of indentation can be introduced separately into the parser if deemed useful. PiperOrigin-RevId: 281721793 --- mlir/lib/IR/FunctionSupport.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'mlir/lib/IR') diff --git a/mlir/lib/IR/FunctionSupport.cpp b/mlir/lib/IR/FunctionSupport.cpp index 6b27eb833bf..1f39575331c 100644 --- a/mlir/lib/IR/FunctionSupport.cpp +++ b/mlir/lib/IR/FunctionSupport.cpp @@ -299,11 +299,7 @@ void mlir::impl::printFunctionLikeOp(OpAsmPrinter &p, Operation *op, resultAttrStorage.emplace_back(attrNameBuf); ignoredAttrs.append(resultAttrStorage.begin(), resultAttrStorage.end()); - auto attrs = op->getAttrs(); - if (attrs.size() > ignoredAttrs.size()) { - p << "\n attributes "; - p.printOptionalAttrDict(attrs, ignoredAttrs); - } + p.printOptionalAttrDictWithKeyword(op->getAttrs(), ignoredAttrs); // Print the body if this is not an external function. Region &body = op->getRegion(0); -- cgit v1.2.3