[PATCH] D43989: MRI delete command

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 2 10:10:04 PST 2018



> On Mar 2, 2018, at 10:00 AM, Rafael Avila de Espindola <rafael.espindola at gmail.com> wrote:
> 
> This only supports a script that is all adds or all deletes, right?

Actually, the use case I was fixing is ‘addlib’/‘addmod' mixed with ‘delete' during archive creation, ‘delete’ is used as a means to replace objects pulled from an archive with ‘addlib'. There is no support for MRI ‘open’, so there is no way to run ‘delete’ commands on an existing archive now.

> 
> If that is the case We should explicitly error if the script has both.
> 
> Do add a testcase.

Just added a test case.

> 
> Cheers,
> Rafael
> 
> 
> Dmitry Mikulin via Phabricator via llvm-commits
> <llvm-commits at lists.llvm.org> writes:
> 
>> 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);
>> }
>> 
>> 
>> 
>> 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);
>> }
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list