[lld] r246886 - [elf2] Add basic archive file support.

Michael Spencer via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 8 13:37:59 PDT 2015


On Tue, Sep 8, 2015 at 6:50 AM, Rafael EspĂ­ndola
<rafael.espindola at gmail.com> wrote:
>> +MemoryBufferRef ArchiveFile::getMember(const Archive::Symbol *Sym) {
>> +  ErrorOr<Archive::child_iterator> ItOrErr = Sym->getMember();
>> +  error(ItOrErr,
>> +        Twine("Could not get the member for symbol ") + Sym->getName());
>> +  Archive::child_iterator It = *ItOrErr;
>> +
>> +  if (!Seen.insert(It->getChildOffset()).second) {
>> +    return MemoryBufferRef();
>> +  }
>
>
> Drop the {}

Fixed in r247064.

>
>> +template <template <class> class T>
>> +std::unique_ptr<ELFFileBase> createELFFile(MemoryBufferRef MB) {
>
> Interesting use of a template parameter :-)

Yep, was the simplest way to avoid code duplication.

>
>> +  const llvm::object::Archive::Symbol Sym;
>
> Could this hold a "const llvm::object::Archive::Symbol &"?

No. Symbol is a value type. symbol_iterator holds a temporary of it,
so the reference would be invalidated when the iterator is changed.

>
> Cheers,
> Rafael



- Michael Spencer


More information about the llvm-commits mailing list