1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[llvm-strings] Fix whitespaces to match strings output.

Summary:
The current implementation prepends a space on every line, making it difficult to compare against GNU strings.

The space appears to have come from handling --radix in rL292707. The space is for making sure there's a space between the radix and the value; however the space is still emitted even when there is no radix. This change fixes that so the space is only emitted when there is a radix.

Reviewers: jhenderson

Reviewed By: jhenderson

Subscribers: llvm-commits, compnerd

Differential Revision: https://reviews.llvm.org/D54238

llvm-svn: 346529
This commit is contained in:
Jordan Rupprecht 2018-11-09 18:03:21 +00:00
parent 23d5825904
commit 6ebaed2a1d
6 changed files with 72 additions and 35 deletions

View File

@ -1,3 +1,3 @@
RUN: llvm-strings -f %S/Inputs/abcd | FileCheck %s
RUN: llvm-strings --print-file-name %S/Inputs/abcd | FileCheck %s
RUN: llvm-strings --print-file-name %S/Inputs/abcd | FileCheck %s --strict-whitespace
CHECK: {{[\\/]}}abcd: abcd

View File

@ -1,3 +1,3 @@
# RUN: echo -e "z\0\x80\0a\0" | llvm-strings --bytes 1 - | FileCheck %s
# CHECK: z{{$}}
# CHECK-NEXT: {{^}} a
# CHECK-NEXT: {{^}}a

View File

@ -0,0 +1,36 @@
RUN: llvm-strings --print-file-name %S/Inputs/numbers \
RUN: | FileCheck %s --check-prefix CHECK-NONE
RUN: llvm-strings --print-file-name -t d %S/Inputs/numbers \
RUN: | FileCheck %s --check-prefix CHECK-DEC --strict-whitespace
RUN: llvm-strings --print-file-name -t o %S/Inputs/numbers \
RUN: | FileCheck %s --check-prefix CHECK-OCT --strict-whitespace
RUN: llvm-strings --print-file-name -t x %S/Inputs/numbers \
RUN: | FileCheck %s --check-prefix CHECK-HEX --strict-whitespace
CHECK-NONE: numbers: three
CHECK-NONE: numbers: four
CHECK-NONE: numbers: five
CHECK-NONE: numbers: seven
CHECK-NONE: numbers: eight
CHECK-NONE: numbers: nine
CHECK-DEC: numbers: 8 three
CHECK-DEC: numbers: 14 four
CHECK-DEC: numbers: 19 five
CHECK-DEC: numbers: 28 seven
CHECK-DEC: numbers: 34 eight
CHECK-DEC: numbers: 40 nine
CHECK-OCT: numbers: 10 three
CHECK-OCT: numbers: 16 four
CHECK-OCT: numbers: 23 five
CHECK-OCT: numbers: 34 seven
CHECK-OCT: numbers: 42 eight
CHECK-OCT: numbers: 50 nine
CHECK-HEX: numbers: 8 three
CHECK-HEX: numbers: e four
CHECK-HEX: numbers: 13 five
CHECK-HEX: numbers: 1c seven
CHECK-HEX: numbers: 22 eight
CHECK-HEX: numbers: 28 nine

View File

@ -1,33 +1,32 @@
RUN: llvm-strings %S/Inputs/numbers | FileCheck %s -check-prefix CHECK-NONE
RUN: llvm-strings -t d %S/Inputs/numbers | FileCheck %s -check-prefix CHECK-DEC
RUN: llvm-strings -t o %S/Inputs/numbers | FileCheck %s -check-prefix CHECK-OCT
RUN: llvm-strings -t x %S/Inputs/numbers | FileCheck %s -check-prefix CHECK-HEX
RUN: llvm-strings -t d %S/Inputs/numbers | FileCheck %s -check-prefix CHECK-DEC --strict-whitespace
RUN: llvm-strings -t o %S/Inputs/numbers | FileCheck %s -check-prefix CHECK-OCT --strict-whitespace
RUN: llvm-strings -t x %S/Inputs/numbers | FileCheck %s -check-prefix CHECK-HEX --strict-whitespace
CHECK-NONE: three
CHECK-NONE: four
CHECK-NONE: five
CHECK-NONE: seven
CHECK-NONE: eight
CHECK-NONE: nine
CHECK-NONE: {{^}}three
CHECK-NONE: {{^}}four
CHECK-NONE: {{^}}five
CHECK-NONE: {{^}}seven
CHECK-NONE: {{^}}eight
CHECK-NONE: {{^}}nine
CHECK-DEC: 8 three
CHECK-DEC: 14 four
CHECK-DEC: 19 five
CHECK-DEC: 28 seven
CHECK-DEC: 34 eight
CHECK-DEC: 40 nine
CHECK-DEC: {{^}} 8 three
CHECK-DEC: {{^}} 14 four
CHECK-DEC: {{^}} 19 five
CHECK-DEC: {{^}} 28 seven
CHECK-DEC: {{^}} 34 eight
CHECK-DEC: {{^}} 40 nine
CHECK-OCT: 10 three
CHECK-OCT: 16 four
CHECK-OCT: 23 five
CHECK-OCT: 34 seven
CHECK-OCT: 42 eight
CHECK-OCT: 50 nine
CHECK-HEX: 8 three
CHECK-HEX: e four
CHECK-HEX: 13 five
CHECK-HEX: 1c seven
CHECK-HEX: 22 eight
CHECK-HEX: 28 nine
CHECK-OCT: {{^}} 10 three
CHECK-OCT: {{^}} 16 four
CHECK-OCT: {{^}} 23 five
CHECK-OCT: {{^}} 34 seven
CHECK-OCT: {{^}} 42 eight
CHECK-OCT: {{^}} 50 nine
CHECK-HEX: {{^}} 8 three
CHECK-HEX: {{^}} e four
CHECK-HEX: {{^}} 13 five
CHECK-HEX: {{^}} 1c seven
CHECK-HEX: {{^}} 22 eight
CHECK-HEX: {{^}} 28 nine

View File

@ -0,0 +1,2 @@
RUN: echo -n abcd | llvm-strings - | FileCheck %s --strict-whitespace
CHECK: {{^}}abcd{{$}}

View File

@ -60,21 +60,21 @@ static void strings(raw_ostream &OS, StringRef FileName, StringRef Contents) {
if (L.size() < static_cast<size_t>(MinLength))
return;
if (PrintFileName)
OS << FileName << ":";
OS << FileName << ": ";
switch (Radix) {
case none:
break;
case octal:
OS << format("%8o", Offset);
OS << format("%7o ", Offset);
break;
case hexadecimal:
OS << format("%8x", Offset);
OS << format("%7x ", Offset);
break;
case decimal:
OS << format("%8u", Offset);
OS << format("%7u ", Offset);
break;
}
OS << " " << L << '\n';
OS << L << '\n';
};
const char *B = Contents.begin();