[PATCH] D27217: Only computeRelativePath() on new members
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 30 12:29:32 PST 2016
This looks good. Do you have commit access or do you need someone to
commit it for you?
Thanks!
Mark Santaniello via Phabricator <reviews at reviews.llvm.org> writes:
> marksantaniello updated this revision to Diff 79741.
> marksantaniello added a comment.
>
> Previous diff was a mistake. Got the revisions mixed up. Here I add the final newline to the new test.
>
>
> https://reviews.llvm.org/D27217
>
> Files:
> include/llvm/Object/ArchiveWriter.h
> lib/Object/ArchiveWriter.cpp
> test/Object/archive-thin-create.test
>
>
> Index: test/Object/archive-thin-create.test
> ===================================================================
> --- /dev/null
> +++ test/Object/archive-thin-create.test
> @@ -0,0 +1,14 @@
> +RUN: mkdir -p %t
> +RUN: cd %t
> +RUN: mkdir -p foo
> +RUN: touch foo/test1.o
> +RUN: touch foo/test2.o
> +RUN: llvm-ar qcT foo/libtest.a foo/test1.o
> +RUN: llvm-ar qcT foo/libtest.a foo/test1.o
> +RUN: llvm-ar qcT foo/libtest.a foo/test2.o
> +RUN: llvm-ar t foo/libtest.a | FileCheck %s
> +
> +CHECK: test1.o
> +CHECK: test1.o
> +CHECK: test2.o
> +
> Index: lib/Object/ArchiveWriter.cpp
> ===================================================================
> --- lib/Object/ArchiveWriter.cpp
> +++ lib/Object/ArchiveWriter.cpp
> @@ -45,6 +45,7 @@
> return BufOrErr.takeError();
>
> NewArchiveMember M;
> + assert(M.IsNew == false);
> M.Buf = MemoryBuffer::getMemBuffer(*BufOrErr, false);
> if (!Deterministic) {
> auto ModTimeOrErr = OldMember.getLastModified();
> @@ -93,6 +94,7 @@
> return errorCodeToError(std::error_code(errno, std::generic_category()));
>
> NewArchiveMember M;
> + M.IsNew = true;
> M.Buf = std::move(*MemberBufferOrErr);
> if (!Deterministic) {
> M.ModTime = std::chrono::time_point_cast<std::chrono::seconds>(
> @@ -231,9 +233,12 @@
> }
> StringMapIndexes.push_back(Out.tell() - StartOffset);
>
> - if (Thin)
> - Out << computeRelativePath(ArcName, Path);
> - else
> + if (Thin) {
> + if (M.IsNew)
> + Out << computeRelativePath(ArcName, Path);
> + else
> + Out << M.Buf->getBufferIdentifier();
> + } else
> Out << Name;
>
> Out << "/\n";
> Index: include/llvm/Object/ArchiveWriter.h
> ===================================================================
> --- include/llvm/Object/ArchiveWriter.h
> +++ include/llvm/Object/ArchiveWriter.h
> @@ -25,6 +25,7 @@
> sys::TimePoint<std::chrono::seconds> ModTime;
> unsigned UID = 0, GID = 0, Perms = 0644;
>
> + bool IsNew = false;
> NewArchiveMember() = default;
> NewArchiveMember(MemoryBufferRef BufRef);
>
>
>
> Index: test/Object/archive-thin-create.test
> ===================================================================
> --- /dev/null
> +++ test/Object/archive-thin-create.test
> @@ -0,0 +1,14 @@
> +RUN: mkdir -p %t
> +RUN: cd %t
> +RUN: mkdir -p foo
> +RUN: touch foo/test1.o
> +RUN: touch foo/test2.o
> +RUN: llvm-ar qcT foo/libtest.a foo/test1.o
> +RUN: llvm-ar qcT foo/libtest.a foo/test1.o
> +RUN: llvm-ar qcT foo/libtest.a foo/test2.o
> +RUN: llvm-ar t foo/libtest.a | FileCheck %s
> +
> +CHECK: test1.o
> +CHECK: test1.o
> +CHECK: test2.o
> +
> Index: lib/Object/ArchiveWriter.cpp
> ===================================================================
> --- lib/Object/ArchiveWriter.cpp
> +++ lib/Object/ArchiveWriter.cpp
> @@ -45,6 +45,7 @@
> return BufOrErr.takeError();
>
> NewArchiveMember M;
> + assert(M.IsNew == false);
> M.Buf = MemoryBuffer::getMemBuffer(*BufOrErr, false);
> if (!Deterministic) {
> auto ModTimeOrErr = OldMember.getLastModified();
> @@ -93,6 +94,7 @@
> return errorCodeToError(std::error_code(errno, std::generic_category()));
>
> NewArchiveMember M;
> + M.IsNew = true;
> M.Buf = std::move(*MemberBufferOrErr);
> if (!Deterministic) {
> M.ModTime = std::chrono::time_point_cast<std::chrono::seconds>(
> @@ -231,9 +233,12 @@
> }
> StringMapIndexes.push_back(Out.tell() - StartOffset);
>
> - if (Thin)
> - Out << computeRelativePath(ArcName, Path);
> - else
> + if (Thin) {
> + if (M.IsNew)
> + Out << computeRelativePath(ArcName, Path);
> + else
> + Out << M.Buf->getBufferIdentifier();
> + } else
> Out << Name;
>
> Out << "/\n";
> Index: include/llvm/Object/ArchiveWriter.h
> ===================================================================
> --- include/llvm/Object/ArchiveWriter.h
> +++ include/llvm/Object/ArchiveWriter.h
> @@ -25,6 +25,7 @@
> sys::TimePoint<std::chrono::seconds> ModTime;
> unsigned UID = 0, GID = 0, Perms = 0644;
>
> + bool IsNew = false;
> NewArchiveMember() = default;
> NewArchiveMember(MemoryBufferRef BufRef);
>
More information about the llvm-commits
mailing list