llvm.org GIT mirror llvm / 4c7d166
Expose a getFullName for thin archive members. It will be used in lld. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268226 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
2 changed file(s) with 20 addition(s) and 11 deletion(s). Raw diff Collapse all Expand all
7777 ErrorOr getNext() const;
7878
7979 ErrorOr getName() const;
80 ErrorOr getFullName() const;
8081 StringRef getRawName() const { return getHeader()->getName(); }
8182 sys::TimeValue getLastModified() const {
8283 return getHeader()->getLastModified();
134134 return Parent->IsThin && Name != "/" && Name != "//";
135135 }
136136
137 ErrorOr Archive::Child::getFullName() const {
138 assert(isThinMember());
139 ErrorOr NameOrErr = getName();
140 if (std::error_code EC = NameOrErr.getError())
141 return EC;
142 StringRef Name = *NameOrErr;
143 if (sys::path::is_absolute(Name))
144 return Name;
145
146 SmallString<128> FullName = sys::path::parent_path(
147 Parent->getMemoryBufferRef().getBufferIdentifier());
148 sys::path::append(FullName, Name);
149 return StringRef(FullName);
150 }
151
137152 ErrorOr Archive::Child::getBuffer() const {
138153 if (!isThinMember()) {
139154 ErrorOr Size = getSize();
141156 return EC;
142157 return StringRef(Data.data() + StartOfFile, Size.get());
143158 }
144 ErrorOr Name = getName();
145 if (std::error_code EC = Name.getError())
146 return EC;
147 SmallString<128> FullName;
148 if (sys::path::is_absolute(*Name))
149 FullName = *Name;
150 else {
151 FullName = sys::path::parent_path(
152 Parent->getMemoryBufferRef().getBufferIdentifier());
153 sys::path::append(FullName, *Name);
154 }
159 ErrorOr FullNameOrEr = getFullName();
160 if (std::error_code EC = FullNameOrEr.getError())
161 return EC;
162 const std::string &FullName = *FullNameOrEr;
155163 ErrorOr> Buf = MemoryBuffer::getFile(FullName);
156164 if (std::error_code EC = Buf.getError())
157165 return EC;