Make the DefinedRegular constructors more regular. NFC.
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 26 Oct 2016 20:34:59 +0000 (20:34 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 26 Oct 2016 20:34:59 +0000 (20:34 +0000)
All the global ones now just forward to the same constructor. This
makes it easier to construct them without creating a Elf_Sym.

llvm-svn: 285238

lld/ELF/Symbols.h

index eda23c1..a0e4848 100644 (file)
@@ -186,16 +186,31 @@ template <class ELFT> class DefinedRegular : public Defined {
   typedef typename ELFT::uint uintX_t;
 
 public:
-  DefinedRegular(StringRef Name, const Elf_Sym &Sym,
-                 InputSectionBase<ELFT> *Section)
-      : Defined(SymbolBody::DefinedRegularKind, Name, Sym.st_other,
-                Sym.getType()),
-        Value(Sym.st_value), Size(Sym.st_size),
+  DefinedRegular(StringRef Name, uint8_t StOther, uint8_t Type, uintX_t Value,
+                 uintX_t Size, InputSectionBase<ELFT> *Section, InputFile *File)
+      : Defined(SymbolBody::DefinedRegularKind, Name, StOther, Type),
+        Value(Value), Size(Size),
         Section(Section ? Section->Repl : NullInputSection) {
-    if (Section)
-      this->File = Section->getFile();
+    this->File = File;
   }
 
+  DefinedRegular(StringRef Name, uint8_t StOther, uint8_t Type, uintX_t Value,
+                 uintX_t Size, InputSectionBase<ELFT> *Section)
+      : DefinedRegular(Name, StOther, Type, Value, Size, Section,
+                       Section ? Section->getFile() : nullptr) {}
+
+  DefinedRegular(StringRef Name, const Elf_Sym &Sym,
+                 InputSectionBase<ELFT> *Section)
+      : DefinedRegular(Name, Sym.st_other, Sym.getType(), Sym.st_value,
+                       Sym.st_size, Section) {}
+
+  DefinedRegular(StringRef Name, uint8_t StOther)
+      : DefinedRegular(Name, StOther, llvm::ELF::STT_NOTYPE, 0, 0,
+                       NullInputSection) {}
+
+  DefinedRegular(StringRef Name, uint8_t StOther, uint8_t Type, BitcodeFile *F)
+      : DefinedRegular(Name, StOther, Type, 0, 0, NullInputSection, F) {}
+
   DefinedRegular(const Elf_Sym &Sym, InputSectionBase<ELFT> *Section)
       : Defined(SymbolBody::DefinedRegularKind, Sym.st_name, Sym.st_other,
                 Sym.getType()),
@@ -206,17 +221,6 @@ public:
       this->File = Section->getFile();
   }
 
-  DefinedRegular(StringRef Name, uint8_t StOther)
-      : Defined(SymbolBody::DefinedRegularKind, Name, StOther,
-                llvm::ELF::STT_NOTYPE),
-        Value(0), Size(0), Section(NullInputSection) {}
-
-  DefinedRegular(StringRef Name, uint8_t StOther, uint8_t Type, BitcodeFile *F)
-      : Defined(SymbolBody::DefinedRegularKind, Name, StOther, Type), Value(0),
-        Size(0), Section(NullInputSection) {
-    this->File = F;
-  }
-
   // Return true if the symbol is a PIC function.
   bool isMipsPIC() const;