[PATCH] D43989: MRI delete command

Dmitry Mikulin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 1 17:06:45 PST 2018


dmikulin created this revision.
dmikulin added a reviewer: Bigcheese.

A far-from-perfect attempt at MRI delete command.
llvm-ar is not very well set up to handle multiple types of commands in the same script...
Need to add a test case.


https://reviews.llvm.org/D43989

Files:
  llvm/tools/llvm-ar/llvm-ar.cpp


Index: llvm/tools/llvm-ar/llvm-ar.cpp
===================================================================
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -770,7 +770,7 @@
 }
 
 static void runMRIScript(const MemoryBuffer &Ref) {
-  enum class MRICommand { AddLib, AddMod, Create, Save, End, Invalid };
+  enum class MRICommand { AddLib, AddMod, Create, Delete, Save, End, Invalid };
 
   bool Saved = false;
   std::vector<NewArchiveMember> NewMembers;
@@ -788,6 +788,7 @@
                        .Case("addlib", MRICommand::AddLib)
                        .Case("addmod", MRICommand::AddMod)
                        .Case("create", MRICommand::Create)
+                       .Case("delete", MRICommand::Delete)
                        .Case("save", MRICommand::Save)
                        .Case("end", MRICommand::End)
                        .Default(MRICommand::Invalid);
@@ -822,6 +823,9 @@
         fail("File already saved");
       ArchiveName = Rest;
       break;
+    case MRICommand::Delete:
+      Members.push_back(Rest);
+      break;
     case MRICommand::Save:
       Saved = true;
       break;
@@ -833,8 +837,11 @@
   }
 
   // Nothing to do if not saved.
-  if (Saved)
+  if (Saved) {
     performOperation(ReplaceOrInsert, &NewMembers);
+    if (!Members.empty())
+      performOperation(Delete, nullptr);
+  }
   exit(0);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43989.136648.patch
Type: text/x-patch
Size: 1376 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180302/5a2e8c69/attachment.bin>


More information about the llvm-commits mailing list