1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[llvm-ar] Support * as comment char in MRI scripts

MRI scripts have two comment chars, * and ;, but only the latter was
supported before.

Also allow leading spaces before comment chars (and before any command
string), and allow comments after a command.

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

llvm-svn: 341571
This commit is contained in:
Martin Storsjo 2018-09-06 18:10:45 +00:00
parent b6ac7f553d
commit 1d8b300a4a
2 changed files with 15 additions and 4 deletions

View File

@ -1,11 +1,17 @@
RUN: yaml2obj %S/Inputs/elf.yaml -o %t.o
RUN: rm -f %t.ar
RUN: echo "create %t.ar" > %t.mri
RUN: echo "addmod %t.o" >> %t.mri
RUN: echo "create %t.ar;comment" > %t.mri
RUN: echo "addmod %t.o * comment" >> %t.mri
RUN: echo "; comment" >> %t.mri
RUN: echo " ;comment" >> %t.mri
RUN: echo "* comment" >> %t.mri
RUN: echo " *comment" >> %t.mri
RUN: echo "" >> %t.mri
RUN: echo " " >> %t.mri
RUN: echo "addmod %S/Inputs/elf.yaml" >> %t.mri
RUN: echo "delete %t.o" >> %t.mri
RUN: echo "save" >> %t.mri
RUN: echo " save" >> %t.mri
RUN: echo "end" >> %t.mri
RUN: llvm-ar -M < %t.mri

View File

@ -789,9 +789,14 @@ static void runMRIScript() {
std::vector<std::unique_ptr<MemoryBuffer>> ArchiveBuffers;
std::vector<std::unique_ptr<object::Archive>> Archives;
for (line_iterator I(Ref, /*SkipBlanks*/ true, ';'), E; I != E; ++I) {
for (line_iterator I(Ref, /*SkipBlanks*/ false), E; I != E; ++I) {
StringRef Line = *I;
StringRef CommandStr, Rest;
Line = Line.split(';').first;
Line = Line.split('*').first;
Line = Line.trim();
if (Line.empty())
continue;
std::tie(CommandStr, Rest) = Line.split(' ');
Rest = Rest.trim();
if (!Rest.empty() && Rest.front() == '"' && Rest.back() == '"')