[PATCH] D43989: MRI delete command
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 10:00:04 PST 2018
This only supports a script that is all adds or all deletes, right?
If that is the case We should explicitly error if the script has both.
Do add a testcase.
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