[PATCH] D43989: MRI delete command
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 14:42:56 PST 2018
LGTM
Thanks,
Rafael
Dmitry Mikulin via Phabricator <reviews at reviews.llvm.org> writes:
> dmikulin updated this revision to Diff 136846.
> dmikulin added a comment.
>
> Changed deleteMember() to erase_if()
>
>
> https://reviews.llvm.org/D43989
>
> Files:
> llvm/test/tools/llvm-ar/mri-delete.test
> 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
> @@ -758,7 +758,7 @@
> }
>
> static void runMRIScript() {
> - enum class MRICommand { AddLib, AddMod, Create, Save, End, Invalid };
> + enum class MRICommand { AddLib, AddMod, Create, Delete, Save, End, Invalid };
>
> ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getSTDIN();
> failIfError(Buf.getError());
> @@ -779,6 +779,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);
> @@ -813,6 +814,12 @@
> fail("File already saved");
> ArchiveName = Rest;
> break;
> + case MRICommand::Delete: {
> + StringRef Name = sys::path::filename(Rest);
> + llvm::erase_if(NewMembers,
> + [=](NewArchiveMember &M) { return M.MemberName == Name; });
> + break;
> + }
> case MRICommand::Save:
> Saved = true;
> break;
> Index: llvm/test/tools/llvm-ar/mri-delete.test
> ===================================================================
> --- /dev/null
> +++ llvm/test/tools/llvm-ar/mri-delete.test
> @@ -0,0 +1,14 @@
> +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 "addmod %S/Inputs/elf.yaml" >> %t.mri
> +RUN: echo "delete %t.o" >> %t.mri
> +RUN: echo "save" >> %t.mri
> +RUN: echo "end" >> %t.mri
> +
> +RUN: llvm-ar -M < %t.mri
> +RUN: llvm-ar tv %t.ar | FileCheck %s
> +
> +CHECK-NOT: mri-delete.test{{.*}}.o
>
>
> Index: llvm/tools/llvm-ar/llvm-ar.cpp
> ===================================================================
> --- llvm/tools/llvm-ar/llvm-ar.cpp
> +++ llvm/tools/llvm-ar/llvm-ar.cpp
> @@ -758,7 +758,7 @@
> }
>
> static void runMRIScript() {
> - enum class MRICommand { AddLib, AddMod, Create, Save, End, Invalid };
> + enum class MRICommand { AddLib, AddMod, Create, Delete, Save, End, Invalid };
>
> ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getSTDIN();
> failIfError(Buf.getError());
> @@ -779,6 +779,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);
> @@ -813,6 +814,12 @@
> fail("File already saved");
> ArchiveName = Rest;
> break;
> + case MRICommand::Delete: {
> + StringRef Name = sys::path::filename(Rest);
> + llvm::erase_if(NewMembers,
> + [=](NewArchiveMember &M) { return M.MemberName == Name; });
> + break;
> + }
> case MRICommand::Save:
> Saved = true;
> break;
> Index: llvm/test/tools/llvm-ar/mri-delete.test
> ===================================================================
> --- /dev/null
> +++ llvm/test/tools/llvm-ar/mri-delete.test
> @@ -0,0 +1,14 @@
> +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 "addmod %S/Inputs/elf.yaml" >> %t.mri
> +RUN: echo "delete %t.o" >> %t.mri
> +RUN: echo "save" >> %t.mri
> +RUN: echo "end" >> %t.mri
> +
> +RUN: llvm-ar -M < %t.mri
> +RUN: llvm-ar tv %t.ar | FileCheck %s
> +
> +CHECK-NOT: mri-delete.test{{.*}}.o
More information about the llvm-commits
mailing list