Skip to content

Commit 1bcbf02

Browse files
authored
Merge pull request #3564 from bnbarham/cherry-split-file
[20210726][split-file] Default to --no-leading-lines
2 parents f0f0299 + 8394532 commit 1bcbf02

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

lld/test/ELF/linkerscript/overwrite-sections.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# REQUIRES: x86
2-
# RUN: rm -rf %t && split-file %s %t
2+
# RUN: rm -rf %t && split-file --leading-lines %s %t
33
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
44

55
## There is no main linker script. OVERWRITE_SECTIONS defines output section

llvm/test/tools/split-file/basic.test

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ cc
99
//--- end
1010

1111
# RUN: rm -rf %t
12-
# RUN: split-file %s %t
12+
# RUN: split-file --leading-lines %s %t
1313
# RUN: diff %S/Inputs/basic-aa.txt %t/aa
1414
# RUN: diff %S/Inputs/basic-bb.txt %t/bb
1515
# RUN: diff %S/Inputs/basic-cc.txt %t/subdir/cc
1616
# RUN: FileCheck %s --check-prefix=END < %t/end
1717

1818
## Can be called on a non-empty directory.
19-
# RUN: split-file %s %t
19+
# RUN: split-file --leading-lines %s %t
2020
# RUN: diff %S/Inputs/basic-aa.txt %t/aa
2121

2222
## Test that we will delete the output if it is a file, so that we can create
2323
## a directory.
2424
# RUN: rm -rf %t && touch %t
25-
# RUN: split-file %s %t
25+
# RUN: split-file --leading-lines %s %t
2626
# RUN: diff %S/Inputs/basic-aa.txt %t/aa
2727

2828
# END: RUN: split-file %s %t

llvm/tools/split-file/split-file.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ static cl::opt<std::string> input(cl::Positional, cl::desc("filename"),
3535
static cl::opt<std::string> output(cl::Positional, cl::desc("directory"),
3636
cl::value_desc("directory"), cl::cat(cat));
3737

38+
static cl::opt<bool> leadingLines("leading-lines",
39+
cl::desc("Preserve line numbers"),
40+
cl::cat(cat));
41+
3842
static cl::opt<bool> noLeadingLines("no-leading-lines",
39-
cl::desc("Don't preserve line numbers"),
43+
cl::desc("Don't preserve line numbers (default)"),
4044
cl::cat(cat));
4145

4246
static StringRef toolName;
@@ -97,9 +101,9 @@ static int handle(MemoryBuffer &inputBuf, StringRef input) {
97101
Part &cur = res.first->second;
98102
if (!i.is_at_eof())
99103
cur.begin = i->data();
100-
// If --no-leading-lines is not specified, numEmptyLines is 0. Append
101-
// newlines so that the extracted part preserves line numbers.
102-
cur.leadingLines = noLeadingLines ? 0 : i.line_number() - 1;
104+
// If --leading-lines is specified, numEmptyLines is 0. Append newlines so
105+
// that the extracted part preserves line numbers.
106+
cur.leadingLines = leadingLines ? i.line_number() - 1 : 0;
103107

104108
lastPart = partName;
105109
}

0 commit comments

Comments
 (0)