[llvm-size] Berkeley formatting: use tabs instead of spaces as field delimeters.

This matches GNU behavior for size and allows use of cut to parse the output of llvm-size.

llvm-svn: 342791
This commit is contained in:
Jordan Rupprecht 2018-09-21 23:48:12 +00:00
parent 4e6afcfc11
commit 8d60f9b6d2
2 changed files with 33 additions and 12 deletions

View File

@ -0,0 +1,15 @@
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
// RUN: llvm-size -B -t %t.o | FileCheck %s --strict-whitespace
.text
.zero 4
.data
.long foo
.bss
.zero 4
// Note: this test enables --strict-whitespace to check for literal tabs
// between each field.
// CHECK: text {{ *}}data {{ *}}bss {{ *}}dec {{ *}}hex {{ *}}filename
// CHECK-NEXT: 4 {{ *}}4 {{ *}}4 {{ *}}12 {{ *}}c {{ *}}{{[ -\(\)_A-Za-z0-9.\\/:]+}}
// CHECK-NEXT: 4 {{ *}}4 {{ *}}4 {{ *}}12 {{ *}}c {{ *}}(TOTALS)

View File

@ -479,19 +479,25 @@ static void printObjectSectionSizes(ObjectFile *Obj) {
}
if (!BerkeleyHeaderPrinted) {
outs() << " text data bss "
<< (Radix == octal ? "oct" : "dec") << " hex filename\n";
outs() << " text\t"
" data\t"
" bss\t"
" "
<< (Radix == octal ? "oct" : "dec")
<< "\t"
" hex\t"
"filename\n";
BerkeleyHeaderPrinted = true;
}
// Print result.
fmt << "%#7" << radix_fmt << " "
<< "%#7" << radix_fmt << " "
<< "%#7" << radix_fmt << " ";
fmt << "%#7" << radix_fmt << "\t"
<< "%#7" << radix_fmt << "\t"
<< "%#7" << radix_fmt << "\t";
outs() << format(fmt.str().c_str(), total_text, total_data, total_bss);
fmtbuf.clear();
fmt << "%7" << (Radix == octal ? PRIo64 : PRIu64) << " "
<< "%7" PRIx64 " ";
fmt << "%7" << (Radix == octal ? PRIo64 : PRIu64) << "\t"
<< "%7" PRIx64 "\t";
outs() << format(fmt.str().c_str(), total, total);
}
}
@ -839,14 +845,14 @@ static void printBerkelyTotals() {
std::string fmtbuf;
raw_string_ostream fmt(fmtbuf);
const char *radix_fmt = getRadixFmt();
fmt << "%#7" << radix_fmt << " "
<< "%#7" << radix_fmt << " "
<< "%#7" << radix_fmt << " ";
fmt << "%#7" << radix_fmt << "\t"
<< "%#7" << radix_fmt << "\t"
<< "%#7" << radix_fmt << "\t";
outs() << format(fmt.str().c_str(), TotalObjectText, TotalObjectData,
TotalObjectBss);
fmtbuf.clear();
fmt << "%7" << (Radix == octal ? PRIo64 : PRIu64) << " "
<< "%7" PRIx64 " ";
fmt << "%7" << (Radix == octal ? PRIo64 : PRIu64) << "\t"
<< "%7" PRIx64 "\t";
outs() << format(fmt.str().c_str(), TotalObjectTotal, TotalObjectTotal)
<< "(TOTALS)\n";
}