diff options
| author | Martin Storsjo <martin@martin.st> | 2018-09-06 18:10:45 +0000 | 
|---|---|---|
| committer | Martin Storsjo <martin@martin.st> | 2018-09-06 18:10:45 +0000 | 
| commit | 1e8edd13ee60d59a3b9c578f6be0d9a3cf6e1bd2 (patch) | |
| tree | a5c57b8b7e10f4b04fc2f664fcd6fee03555eb1d | |
| parent | d2c1dd5902782fb773c64dbf4e0b529aa4044b05 (diff) | |
| download | bcm5719-llvm-1e8edd13ee60d59a3b9c578f6be0d9a3cf6e1bd2.tar.gz bcm5719-llvm-1e8edd13ee60d59a3b9c578f6be0d9a3cf6e1bd2.zip  | |
[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
| -rw-r--r-- | llvm/test/tools/llvm-ar/mri-delete.test | 12 | ||||
| -rw-r--r-- | llvm/tools/llvm-ar/llvm-ar.cpp | 7 | 
2 files changed, 15 insertions, 4 deletions
diff --git a/llvm/test/tools/llvm-ar/mri-delete.test b/llvm/test/tools/llvm-ar/mri-delete.test index 82ebc54b66b..bb829ce13c7 100644 --- a/llvm/test/tools/llvm-ar/mri-delete.test +++ b/llvm/test/tools/llvm-ar/mri-delete.test @@ -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 diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp index 16fee89d89d..1751bad5119 100644 --- a/llvm/tools/llvm-ar/llvm-ar.cpp +++ b/llvm/tools/llvm-ar/llvm-ar.cpp @@ -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() == '"')  | 

