[PATCH] D43989: MRI delete command
Dmitry Mikulin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 2 10:01:25 PST 2018
dmikulin updated this revision to Diff 136782.
dmikulin added a comment.
llvm-ar supports only a subset of MRI commands, that's why 'delete' as implemented here only works for a specific use case: deleting members added with 'addlib' or 'addmod' commands during archive creation.
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
@@ -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/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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43989.136782.patch
Type: text/x-patch
Size: 1941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180302/9a72524d/attachment.bin>
More information about the llvm-commits
mailing list