[llvm] r342791 - [llvm-size] Berkeley formatting: use tabs instead of spaces as field delimeters.
Jordan Rupprecht via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 21 16:48:12 PDT 2018
Author: rupprecht
Date: Fri Sep 21 16:48:12 2018
New Revision: 342791
URL: http://llvm.org/viewvc/llvm-project?rev=342791&view=rev
Log:
[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.
Added:
llvm/trunk/test/tools/llvm-size/X86/format-berkeley-tabs.s
Modified:
llvm/trunk/tools/llvm-size/llvm-size.cpp
Added: llvm/trunk/test/tools/llvm-size/X86/format-berkeley-tabs.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-size/X86/format-berkeley-tabs.s?rev=342791&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-size/X86/format-berkeley-tabs.s (added)
+++ llvm/trunk/test/tools/llvm-size/X86/format-berkeley-tabs.s Fri Sep 21 16:48:12 2018
@@ -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)
Modified: llvm/trunk/tools/llvm-size/llvm-size.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-size/llvm-size.cpp?rev=342791&r1=342790&r2=342791&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-size/llvm-size.cpp (original)
+++ llvm/trunk/tools/llvm-size/llvm-size.cpp Fri Sep 21 16:48:12 2018
@@ -479,19 +479,25 @@ static void printObjectSectionSizes(Obje
}
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";
}
More information about the llvm-commits
mailing list