[llvm] r268226 - Expose a getFullName for thin archive members.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon May 2 06:45:06 PDT 2016
Author: rafael
Date: Mon May 2 08:45:06 2016
New Revision: 268226
URL: http://llvm.org/viewvc/llvm-project?rev=268226&view=rev
Log:
Expose a getFullName for thin archive members.
It will be used in lld.
Modified:
llvm/trunk/include/llvm/Object/Archive.h
llvm/trunk/lib/Object/Archive.cpp
Modified: llvm/trunk/include/llvm/Object/Archive.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Archive.h?rev=268226&r1=268225&r2=268226&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/Archive.h (original)
+++ llvm/trunk/include/llvm/Object/Archive.h Mon May 2 08:45:06 2016
@@ -78,6 +78,7 @@ public:
ErrorOr<Child> getNext() const;
ErrorOr<StringRef> getName() const;
+ ErrorOr<std::string> getFullName() const;
StringRef getRawName() const { return getHeader()->getName(); }
sys::TimeValue getLastModified() const {
return getHeader()->getLastModified();
Modified: llvm/trunk/lib/Object/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=268226&r1=268225&r2=268226&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Archive.cpp (original)
+++ llvm/trunk/lib/Object/Archive.cpp Mon May 2 08:45:06 2016
@@ -135,6 +135,21 @@ bool Archive::Child::isThinMember() cons
return Parent->IsThin && Name != "/" && Name != "//";
}
+ErrorOr<std::string> Archive::Child::getFullName() const {
+ assert(isThinMember());
+ ErrorOr<StringRef> NameOrErr = getName();
+ if (std::error_code EC = NameOrErr.getError())
+ return EC;
+ StringRef Name = *NameOrErr;
+ if (sys::path::is_absolute(Name))
+ return Name;
+
+ SmallString<128> FullName = sys::path::parent_path(
+ Parent->getMemoryBufferRef().getBufferIdentifier());
+ sys::path::append(FullName, Name);
+ return StringRef(FullName);
+}
+
ErrorOr<StringRef> Archive::Child::getBuffer() const {
if (!isThinMember()) {
ErrorOr<uint32_t> Size = getSize();
@@ -142,17 +157,10 @@ ErrorOr<StringRef> Archive::Child::getBu
return EC;
return StringRef(Data.data() + StartOfFile, Size.get());
}
- ErrorOr<StringRef> Name = getName();
- if (std::error_code EC = Name.getError())
+ ErrorOr<std::string> FullNameOrEr = getFullName();
+ if (std::error_code EC = FullNameOrEr.getError())
return EC;
- 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);
- }
+ const std::string &FullName = *FullNameOrEr;
ErrorOr<std::unique_ptr<MemoryBuffer>> Buf = MemoryBuffer::getFile(FullName);
if (std::error_code EC = Buf.getError())
return EC;
More information about the llvm-commits
mailing list