[PATCH] D51338: [llvm-ar] Support * as comment char in MIR scripts

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 29 14:00:18 PDT 2018


mstorsjo updated this revision to Diff 163188.
mstorsjo edited the summary of this revision.
mstorsjo added a comment.

Handle the comment char appearing anywhere in a command line - by discarding anything after the comment char.


https://reviews.llvm.org/D51338

Files:
  test/tools/llvm-ar/mri-delete.test
  tools/llvm-ar/llvm-ar.cpp


Index: tools/llvm-ar/llvm-ar.cpp
===================================================================
--- tools/llvm-ar/llvm-ar.cpp
+++ tools/llvm-ar/llvm-ar.cpp
@@ -807,6 +807,11 @@
   for (line_iterator I(Ref, /*SkipBlanks*/ true, ';'), E; I != E; ++I) {
     StringRef Line = *I;
     StringRef CommandStr, Rest;
+    std::tie(Line, Rest) = Line.split(';');
+    std::tie(Line, Rest) = Line.split('*');
+    Line = Line.trim();
+    if (Line.empty())
+      continue;
     std::tie(CommandStr, Rest) = Line.split(' ');
     Rest = Rest.trim();
     if (!Rest.empty() && Rest.front() == '"' && Rest.back() == '"')
Index: test/tools/llvm-ar/mri-delete.test
===================================================================
--- test/tools/llvm-ar/mri-delete.test
+++ test/tools/llvm-ar/mri-delete.test
@@ -1,11 +1,15 @@
 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 "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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51338.163188.patch
Type: text/x-patch
Size: 1369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180829/912aeb70/attachment.bin>


More information about the llvm-commits mailing list