Use a reference for a value that is never null. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 20 Dec 2017 16:19:48 +0000 (16:19 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 20 Dec 2017 16:19:48 +0000 (16:19 +0000)
llvm-svn: 321186

lld/ELF/InputFiles.cpp
lld/ELF/SymbolTable.cpp
lld/ELF/SymbolTable.h

index c9aa9da..f649493 100644 (file)
@@ -636,7 +636,7 @@ template <class ELFT> Symbol *ObjFile<ELFT>::createSymbol(const Elf_Sym *Sym) {
     if (Value == 0 || Value >= UINT32_MAX)
       fatal(toString(this) + ": common symbol '" + Name +
             "' has invalid alignment: " + Twine(Value));
-    return Symtab->addCommon(Name, Size, Value, Binding, StOther, Type, this);
+    return Symtab->addCommon(Name, Size, Value, Binding, StOther, Type, *this);
   }
 
   switch (Binding) {
@@ -945,7 +945,7 @@ static Symbol *createBitcodeSymbol(const std::vector<bool> &KeptComdats,
   if (ObjSym.isCommon())
     return Symtab->addCommon(NameRef, ObjSym.getCommonSize(),
                              ObjSym.getCommonAlignment(), Binding, Visibility,
-                             STT_OBJECT, &F);
+                             STT_OBJECT, F);
 
   return Symtab->addBitcode(NameRef, Binding, Visibility, Type,
                             CanOmitFromDynSym, F);
index 3ef8fcb..cf63eac 100644 (file)
@@ -377,19 +377,19 @@ static int compareDefinedNonCommon(Symbol *S, bool WasInserted, uint8_t Binding,
 
 Symbol *SymbolTable::addCommon(StringRef N, uint64_t Size, uint32_t Alignment,
                                uint8_t Binding, uint8_t StOther, uint8_t Type,
-                               InputFile *File) {
+                               InputFile &File) {
   Symbol *S;
   bool WasInserted;
   std::tie(S, WasInserted) = insert(N, Type, getVisibility(StOther),
-                                    /*CanOmitFromDynSym*/ false, File);
+                                    /*CanOmitFromDynSym*/ false, &File);
   int Cmp = compareDefined(S, WasInserted, Binding, N);
   if (Cmp > 0) {
     auto *Bss = make<BssSection>("COMMON", Size, Alignment);
-    Bss->File = File;
+    Bss->File = &File;
     Bss->Live = !Config->GcSections;
     InputSections.push_back(Bss);
 
-    replaceSymbol<Defined>(S, File, N, Binding, StOther, Type, 0, Size, Bss);
+    replaceSymbol<Defined>(S, &File, N, Binding, StOther, Type, 0, Size, Bss);
   } else if (Cmp == 0) {
     auto *D = cast<Defined>(S);
     auto *Bss = dyn_cast_or_null<BssSection>(D->Section);
@@ -405,7 +405,7 @@ Symbol *SymbolTable::addCommon(StringRef N, uint64_t Size, uint32_t Alignment,
 
     Bss->Alignment = std::max(Bss->Alignment, Alignment);
     if (Size > Bss->Size) {
-      D->File = Bss->File = File;
+      D->File = Bss->File = &File;
       D->Size = Bss->Size = Size;
     }
   }
index 2783a21..cb8a45c 100644 (file)
@@ -72,7 +72,7 @@ public:
 
   Symbol *addCommon(StringRef Name, uint64_t Size, uint32_t Alignment,
                     uint8_t Binding, uint8_t StOther, uint8_t Type,
-                    InputFile *File);
+                    InputFile &File);
 
   std::pair<Symbol *, bool> insert(StringRef Name);
   std::pair<Symbol *, bool> insert(StringRef Name, uint8_t Type,