Skip to content

Commit 8d60f9b

Browse files
committed
[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
1 parent 4e6afcf commit 8d60f9b

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
2+
// RUN: llvm-size -B -t %t.o | FileCheck %s --strict-whitespace
3+
4+
.text
5+
.zero 4
6+
.data
7+
.long foo
8+
.bss
9+
.zero 4
10+
11+
// Note: this test enables --strict-whitespace to check for literal tabs
12+
// between each field.
13+
// CHECK: text {{ *}}data {{ *}}bss {{ *}}dec {{ *}}hex {{ *}}filename
14+
// CHECK-NEXT: 4 {{ *}}4 {{ *}}4 {{ *}}12 {{ *}}c {{ *}}{{[ -\(\)_A-Za-z0-9.\\/:]+}}
15+
// CHECK-NEXT: 4 {{ *}}4 {{ *}}4 {{ *}}12 {{ *}}c {{ *}}(TOTALS)

llvm/tools/llvm-size/llvm-size.cpp

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -479,19 +479,25 @@ static void printObjectSectionSizes(ObjectFile *Obj) {
479479
}
480480

481481
if (!BerkeleyHeaderPrinted) {
482-
outs() << " text data bss "
483-
<< (Radix == octal ? "oct" : "dec") << " hex filename\n";
482+
outs() << " text\t"
483+
" data\t"
484+
" bss\t"
485+
" "
486+
<< (Radix == octal ? "oct" : "dec")
487+
<< "\t"
488+
" hex\t"
489+
"filename\n";
484490
BerkeleyHeaderPrinted = true;
485491
}
486492

487493
// Print result.
488-
fmt << "%#7" << radix_fmt << " "
489-
<< "%#7" << radix_fmt << " "
490-
<< "%#7" << radix_fmt << " ";
494+
fmt << "%#7" << radix_fmt << "\t"
495+
<< "%#7" << radix_fmt << "\t"
496+
<< "%#7" << radix_fmt << "\t";
491497
outs() << format(fmt.str().c_str(), total_text, total_data, total_bss);
492498
fmtbuf.clear();
493-
fmt << "%7" << (Radix == octal ? PRIo64 : PRIu64) << " "
494-
<< "%7" PRIx64 " ";
499+
fmt << "%7" << (Radix == octal ? PRIo64 : PRIu64) << "\t"
500+
<< "%7" PRIx64 "\t";
495501
outs() << format(fmt.str().c_str(), total, total);
496502
}
497503
}
@@ -839,14 +845,14 @@ static void printBerkelyTotals() {
839845
std::string fmtbuf;
840846
raw_string_ostream fmt(fmtbuf);
841847
const char *radix_fmt = getRadixFmt();
842-
fmt << "%#7" << radix_fmt << " "
843-
<< "%#7" << radix_fmt << " "
844-
<< "%#7" << radix_fmt << " ";
848+
fmt << "%#7" << radix_fmt << "\t"
849+
<< "%#7" << radix_fmt << "\t"
850+
<< "%#7" << radix_fmt << "\t";
845851
outs() << format(fmt.str().c_str(), TotalObjectText, TotalObjectData,
846852
TotalObjectBss);
847853
fmtbuf.clear();
848-
fmt << "%7" << (Radix == octal ? PRIo64 : PRIu64) << " "
849-
<< "%7" PRIx64 " ";
854+
fmt << "%7" << (Radix == octal ? PRIo64 : PRIu64) << "\t"
855+
<< "%7" PRIx64 "\t";
850856
outs() << format(fmt.str().c_str(), TotalObjectTotal, TotalObjectTotal)
851857
<< "(TOTALS)\n";
852858
}

0 commit comments

Comments
 (0)