llvm.org GIT mirror llvm / bcdc161
Only computeRelativePath() on new members Summary: When using thin archives, and processing the same archive multiple times, we were mangling existing entries. The root cause is that we were calling computeRelativePath() more than once. Here, we only call it when adding new members to an archive. Note that D27218 changes the way thin archives are printed, and will break the new unit test included here. Depending on which one lands first, the other will need to be slightly modified. Reviewers: rafael, davide Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D27217 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288280 91177308-0d34-0410-b5e6-96231b3b80d8 David Callahan 3 years ago
3 changed file(s) with 23 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
2424 sys::TimePoint ModTime;
2525 unsigned UID = 0, GID = 0, Perms = 0644;
2626
27 bool IsNew = false;
2728 NewArchiveMember() = default;
2829 NewArchiveMember(MemoryBufferRef BufRef);
2930
4444 return BufOrErr.takeError();
4545
4646 NewArchiveMember M;
47 assert(M.IsNew == false);
4748 M.Buf = MemoryBuffer::getMemBuffer(*BufOrErr, false);
4849 if (!Deterministic) {
4950 auto ModTimeOrErr = OldMember.getLastModified();
9293 return errorCodeToError(std::error_code(errno, std::generic_category()));
9394
9495 NewArchiveMember M;
96 M.IsNew = true;
9597 M.Buf = std::move(*MemberBufferOrErr);
9698 if (!Deterministic) {
9799 M.ModTime = std::chrono::time_point_cast(
230232 }
231233 StringMapIndexes.push_back(Out.tell() - StartOffset);
232234
233 if (Thin)
234 Out << computeRelativePath(ArcName, Path);
235 else
235 if (Thin) {
236 if (M.IsNew)
237 Out << computeRelativePath(ArcName, Path);
238 else
239 Out << M.Buf->getBufferIdentifier();
240 } else
236241 Out << Name;
237242
238243 Out << "/\n";
0 RUN: mkdir -p %t
1 RUN: cd %t
2 RUN: mkdir -p foo
3 RUN: touch foo/test1.o
4 RUN: touch foo/test2.o
5 RUN: llvm-ar qcT foo/libtest.a foo/test1.o
6 RUN: llvm-ar qcT foo/libtest.a foo/test1.o
7 RUN: llvm-ar qcT foo/libtest.a foo/test2.o
8 RUN: llvm-ar t foo/libtest.a | FileCheck %s
9
10 CHECK: test1.o
11 CHECK: test1.o
12 CHECK: test2.o
13