Skip to content

Commit 4e9e20f

Browse files
committed
Use OS.indent() + add comments
1 parent 8285c1b commit 4e9e20f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,18 +291,20 @@ void MatchTable::emitDeclaration(raw_ostream &OS) const {
291291
OS << " constexpr static uint8_t MatchTable" << ID << "[] = {";
292292
LineBreak.emit(OS, true, *this);
293293

294+
// We want to display the table index of each line in a consistent
295+
// manner. It has to appear as a column on the left side of the table.
296+
// To determine how wide the column needs to be, check how many characters
297+
// we need to fit the largest possible index in the current table.
294298
const unsigned NumColsForIdx = llvm::to_string(CurrentSize).size();
295299

296300
unsigned CurIndex = 0;
297301
const auto BeginLine = [&]() {
298-
OS << std::string(BaseIndent, ' ');
299-
// To keep the /* index */ column consistent, pad
300-
// the string at the start so we can always fit the
301-
// exact number of characters to print the largest possible index.
302+
OS.indent(BaseIndent);
302303
std::string IdxStr = llvm::to_string(CurIndex);
304+
// Pad the string with spaces to keep the size of the prefix consistent.
303305
OS << " /* " << std::string(NumColsForIdx - IdxStr.size(), ' ') << IdxStr
304306
<< " */ ";
305-
OS << std::string(Indentation, ' ');
307+
OS.indent(Indentation);
306308
};
307309

308310
BeginLine();

0 commit comments

Comments
 (0)