[PATCH] D78384: [mlir] omit extra newlines if there are no aliases
Matthias Kramm via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 17 10:14:56 PDT 2020
matthiaskramm created this revision.
matthiaskramm added a reviewer: rriddle.
Herald added subscribers: llvm-commits, frgossen, grosul1, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, burmako, jpienaar, mehdi_amini.
Herald added 1 blocking reviewer(s): rriddle.
Herald added a project: LLVM.
rriddle accepted this revision.
rriddle added inline comments.
This revision is now accepted and ready to land.
================
Comment at: mlir/lib/IR/AsmPrinter.cpp:384
auto &aliasAttrsPair = kindAlias.second;
- for (unsigned i = 0, e = aliasAttrsPair.second.size(); i != e; ++i)
- printAlias(aliasAttrsPair.first, aliasAttrsPair.second[i], i);
- os << newLine;
+ unsigned size = aliasAttrsPair.second.size();
+ if (size > 0) {
----------------
nit:
```
if (aliasAttrsPair.second.empty())
continue;
```
We used to always print an extra newline after every kindAlias
group, even if the groups were empty. This is now omitted. In
particular, an empty module is now printed as "module {\n}", not
"\n\nmodule {\n}".
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78384
Files:
mlir/lib/IR/AsmPrinter.cpp
Index: mlir/lib/IR/AsmPrinter.cpp
===================================================================
--- mlir/lib/IR/AsmPrinter.cpp
+++ mlir/lib/IR/AsmPrinter.cpp
@@ -381,9 +381,12 @@
// Print all of the attribute kind aliases.
for (auto &kindAlias : attrKindToAlias) {
auto &aliasAttrsPair = kindAlias.second;
- for (unsigned i = 0, e = aliasAttrsPair.second.size(); i != e; ++i)
- printAlias(aliasAttrsPair.first, aliasAttrsPair.second[i], i);
- os << newLine;
+ unsigned size = aliasAttrsPair.second.size();
+ if (size > 0) {
+ for (unsigned i = 0; i != size; ++i)
+ printAlias(aliasAttrsPair.first, aliasAttrsPair.second[i], i);
+ os << newLine;
+ }
}
// In a second pass print all of the remaining attribute aliases that aren't
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78384.258358.patch
Type: text/x-patch
Size: 790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200417/efb6aacd/attachment.bin>
More information about the llvm-commits
mailing list