[lld] r321198 - Use a reference to a file in the LazyArchive symbol.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 20 09:59:44 PST 2017


Author: rafael
Date: Wed Dec 20 09:59:43 2017
New Revision: 321198

URL: http://llvm.org/viewvc/llvm-project?rev=321198&view=rev
Log:
Use a reference to a file in the LazyArchive symbol.

It is never null.

Modified:
    lld/trunk/ELF/SymbolTable.cpp
    lld/trunk/ELF/Symbols.cpp
    lld/trunk/ELF/Symbols.h

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=321198&r1=321197&r2=321198&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Dec 20 09:59:43 2017
@@ -538,7 +538,7 @@ Symbol *SymbolTable::addLazyArchive(Stri
   bool WasInserted;
   std::tie(S, WasInserted) = insert(Name);
   if (WasInserted) {
-    replaceSymbol<LazyArchive>(S, &F, Sym, Symbol::UnknownType);
+    replaceSymbol<LazyArchive>(S, F, Sym, Symbol::UnknownType);
     return S;
   }
   if (!S->isUndefined())
@@ -547,7 +547,7 @@ Symbol *SymbolTable::addLazyArchive(Stri
   // An undefined weak will not fetch archive members. See comment on Lazy in
   // Symbols.h for the details.
   if (S->isWeak()) {
-    replaceSymbol<LazyArchive>(S, &F, Sym, S->Type);
+    replaceSymbol<LazyArchive>(S, F, Sym, S->Type);
     S->Binding = STB_WEAK;
     return S;
   }

Modified: lld/trunk/ELF/Symbols.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.cpp?rev=321198&r1=321197&r2=321198&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.cpp (original)
+++ lld/trunk/ELF/Symbols.cpp Wed Dec 20 09:59:43 2017
@@ -224,16 +224,16 @@ InputFile *Lazy::fetch() {
   return cast<LazyObject>(this)->fetch();
 }
 
-ArchiveFile *LazyArchive::getFile() { return cast<ArchiveFile>(File); }
+ArchiveFile &LazyArchive::getFile() { return *cast<ArchiveFile>(File); }
 
 InputFile *LazyArchive::fetch() {
-  std::pair<MemoryBufferRef, uint64_t> MBInfo = getFile()->getMember(&Sym);
+  std::pair<MemoryBufferRef, uint64_t> MBInfo = getFile().getMember(&Sym);
 
   // getMember returns an empty buffer if the member was already
   // read from the library.
   if (MBInfo.first.getBuffer().empty())
     return nullptr;
-  return createObjectFile(MBInfo.first, getFile()->getName(), MBInfo.second);
+  return createObjectFile(MBInfo.first, getFile().getName(), MBInfo.second);
 }
 
 LazyObjFile &LazyObject::getFile() { return *cast<LazyObjFile>(File); }

Modified: lld/trunk/ELF/Symbols.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Symbols.h?rev=321198&r1=321197&r2=321198&view=diff
==============================================================================
--- lld/trunk/ELF/Symbols.h (original)
+++ lld/trunk/ELF/Symbols.h Wed Dec 20 09:59:43 2017
@@ -278,13 +278,13 @@ protected:
 // symbol.
 class LazyArchive : public Lazy {
 public:
-  LazyArchive(InputFile *File, const llvm::object::Archive::Symbol S,
+  LazyArchive(InputFile &File, const llvm::object::Archive::Symbol S,
               uint8_t Type)
-      : Lazy(LazyArchiveKind, File, S.getName(), Type), Sym(S) {}
+      : Lazy(LazyArchiveKind, &File, S.getName(), Type), Sym(S) {}
 
   static bool classof(const Symbol *S) { return S->kind() == LazyArchiveKind; }
 
-  ArchiveFile *getFile();
+  ArchiveFile &getFile();
   InputFile *fetch();
 
 private:




More information about the llvm-commits mailing list