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

Martin Storsjo via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 6 11:10:45 PDT 2018


Author: mstorsjo
Date: Thu Sep  6 11:10:45 2018
New Revision: 341571

URL: http://llvm.org/viewvc/llvm-project?rev=341571&view=rev
Log:
[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

Modified:
    llvm/trunk/test/tools/llvm-ar/mri-delete.test
    llvm/trunk/tools/llvm-ar/llvm-ar.cpp

Modified: llvm/trunk/test/tools/llvm-ar/mri-delete.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/mri-delete.test?rev=341571&r1=341570&r2=341571&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-ar/mri-delete.test (original)
+++ llvm/trunk/test/tools/llvm-ar/mri-delete.test Thu Sep  6 11:10:45 2018
@@ -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

Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=341571&r1=341570&r2=341571&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Thu Sep  6 11:10:45 2018
@@ -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() == '"')




More information about the llvm-commits mailing list