[llvm] r265065 - Object: Correctly read thin archives containing absolute paths.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 31 15:08:32 PDT 2016
Author: pcc
Date: Thu Mar 31 17:08:31 2016
New Revision: 265065
URL: http://llvm.org/viewvc/llvm-project?rev=265065&view=rev
Log:
Object: Correctly read thin archives containing absolute paths.
Differential Revision: http://reviews.llvm.org/D18666
Added:
llvm/trunk/test/Object/archive-thin-read.test
Modified:
llvm/trunk/lib/Object/Archive.cpp
Modified: llvm/trunk/lib/Object/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=265065&r1=265064&r2=265065&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Archive.cpp (original)
+++ llvm/trunk/lib/Object/Archive.cpp Thu Mar 31 17:08:31 2016
@@ -146,9 +146,14 @@ ErrorOr<StringRef> Archive::Child::getBu
ErrorOr<StringRef> Name = getName();
if (std::error_code EC = Name.getError())
return EC;
- SmallString<128> FullName = sys::path::parent_path(
- Parent->getMemoryBufferRef().getBufferIdentifier());
- sys::path::append(FullName, *Name);
+ SmallString<128> FullName;
+ if (sys::path::is_absolute(*Name))
+ FullName = *Name;
+ else {
+ FullName = sys::path::parent_path(
+ Parent->getMemoryBufferRef().getBufferIdentifier());
+ sys::path::append(FullName, *Name);
+ }
ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getFile(FullName);
if (std::error_code EC = Buf.getError())
return EC;
Added: llvm/trunk/test/Object/archive-thin-read.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/archive-thin-read.test?rev=265065&view=auto
==============================================================================
--- llvm/trunk/test/Object/archive-thin-read.test (added)
+++ llvm/trunk/test/Object/archive-thin-read.test Thu Mar 31 17:08:31 2016
@@ -0,0 +1,5 @@
+RUN: echo hello > %t.file
+RUN: llvm-ar rcsT %t.a %t.file
+RUN: llvm-ar p %t.a | FileCheck %s
+
+CHECK: hello
More information about the llvm-commits
mailing list