[lld] r321186 - Use a reference for a value that is never null. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 20 08:19:48 PST 2017


Author: rafael
Date: Wed Dec 20 08:19:48 2017
New Revision: 321186

URL: http://llvm.org/viewvc/llvm-project?rev=321186&view=rev
Log:
Use a reference for a value that is never null. NFC.

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

Modified: lld/trunk/ELF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputFiles.cpp?rev=321186&r1=321185&r2=321186&view=diff
==============================================================================
--- lld/trunk/ELF/InputFiles.cpp (original)
+++ lld/trunk/ELF/InputFiles.cpp Wed Dec 20 08:19:48 2017
@@ -636,7 +636,7 @@ template <class ELFT> Symbol *ObjFile<EL
     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
   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);

Modified: lld/trunk/ELF/SymbolTable.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=321186&r1=321185&r2=321186&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.cpp (original)
+++ lld/trunk/ELF/SymbolTable.cpp Wed Dec 20 08:19:48 2017
@@ -377,19 +377,19 @@ static int compareDefinedNonCommon(Symbo
 
 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
 
     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;
     }
   }

Modified: lld/trunk/ELF/SymbolTable.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.h?rev=321186&r1=321185&r2=321186&view=diff
==============================================================================
--- lld/trunk/ELF/SymbolTable.h (original)
+++ lld/trunk/ELF/SymbolTable.h Wed Dec 20 08:19:48 2017
@@ -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,




More information about the llvm-commits mailing list