[llvm] r326636 - Implementation of MRI "delete" command.
Dmitry Mikulin via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 15:23:48 PST 2018
Author: dmikulin
Date: Fri Mar 2 15:23:48 2018
New Revision: 326636
URL: http://llvm.org/viewvc/llvm-project?rev=326636&view=rev
Log:
Implementation of MRI "delete" command.
Differential Revision: https://reviews.llvm.org/D43989
Added:
llvm/trunk/test/tools/llvm-ar/mri-delete.test
Modified:
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
Added: llvm/trunk/test/tools/llvm-ar/mri-delete.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-ar/mri-delete.test?rev=326636&view=auto
==============================================================================
--- llvm/trunk/test/tools/llvm-ar/mri-delete.test (added)
+++ llvm/trunk/test/tools/llvm-ar/mri-delete.test Fri Mar 2 15:23:48 2018
@@ -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
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=326636&r1=326635&r2=326636&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Fri Mar 2 15:23:48 2018
@@ -758,7 +758,7 @@ static int performOperation(ArchiveOpera
}
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 @@ static void runMRIScript() {
.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 @@ static void runMRIScript() {
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;
More information about the llvm-commits
mailing list