Inline trivial symbol constructors.
authorRui Ueyama <ruiu@google.com>
Fri, 27 Oct 2017 23:26:46 +0000 (23:26 +0000)
committerRui Ueyama <ruiu@google.com>
Fri, 27 Oct 2017 23:26:46 +0000 (23:26 +0000)
llvm-svn: 316811

lld/ELF/Symbols.cpp
lld/ELF/Symbols.h

index 6af89e4..5f5c383 100644 (file)
@@ -119,13 +119,6 @@ static uint64_t getSymVA(const SymbolBody &Body, int64_t &Addend) {
   llvm_unreachable("invalid symbol kind");
 }
 
-SymbolBody::SymbolBody(Kind K, StringRefZ Name, bool IsLocal, uint8_t StOther,
-                       uint8_t Type)
-    : SymbolKind(K), IsLocal(IsLocal), NeedsPltAddr(false),
-      IsInGlobalMipsGot(false), Is32BitMipsGot(false), IsInIplt(false),
-      IsInIgot(false), IsPreemptible(false), Type(Type), StOther(StOther),
-      Name(Name) {}
-
 // Returns true if this is a weak undefined symbol.
 bool SymbolBody::isUndefWeak() const {
   // See comment on Lazy in Symbols.h for the details.
@@ -257,10 +250,6 @@ void SymbolBody::parseSymbolVersion() {
           Verstr);
 }
 
-Defined::Defined(Kind K, StringRefZ Name, bool IsLocal, uint8_t StOther,
-                 uint8_t Type)
-    : SymbolBody(K, Name, IsLocal, StOther, Type) {}
-
 template <class ELFT> bool DefinedRegular::isMipsPIC() const {
   typedef typename ELFT::Ehdr Elf_Ehdr;
   if (!Section || !isFunc())
@@ -272,16 +261,6 @@ template <class ELFT> bool DefinedRegular::isMipsPIC() const {
          (Hdr->e_flags & EF_MIPS_PIC);
 }
 
-Undefined::Undefined(StringRefZ Name, bool IsLocal, uint8_t StOther,
-                     uint8_t Type)
-    : SymbolBody(SymbolBody::UndefinedKind, Name, IsLocal, StOther, Type) {}
-
-DefinedCommon::DefinedCommon(StringRef Name, uint64_t Size, uint32_t Alignment,
-                             uint8_t StOther, uint8_t Type)
-    : Defined(SymbolBody::DefinedCommonKind, Name, /*IsLocal=*/false, StOther,
-              Type),
-      Alignment(Alignment), Size(Size) {}
-
 // If a shared symbol is referred via a copy relocation, its alignment
 // becomes part of the ABI. This function returns a symbol alignment.
 // Because symbols don't have alignment attributes, we need to infer that.
@@ -299,12 +278,6 @@ InputFile *Lazy::fetch() {
   return cast<LazyObject>(this)->fetch();
 }
 
-LazyArchive::LazyArchive(const llvm::object::Archive::Symbol S, uint8_t Type)
-    : Lazy(LazyArchiveKind, S.getName(), Type), Sym(S) {}
-
-LazyObject::LazyObject(StringRef Name, uint8_t Type)
-    : Lazy(LazyObjectKind, Name, Type) {}
-
 ArchiveFile *LazyArchive::getFile() {
   return cast<ArchiveFile>(SymbolBody::getFile());
 }
index a988989..d05c7db 100644 (file)
@@ -104,7 +104,11 @@ public:
 
 protected:
   SymbolBody(Kind K, StringRefZ Name, bool IsLocal, uint8_t StOther,
-             uint8_t Type);
+             uint8_t Type)
+      : SymbolKind(K), IsLocal(IsLocal), NeedsPltAddr(false),
+        IsInGlobalMipsGot(false), Is32BitMipsGot(false), IsInIplt(false),
+        IsInIgot(false), IsPreemptible(false), Type(Type), StOther(StOther),
+        Name(Name) {}
 
   const unsigned SymbolKind : 8;
 
@@ -154,14 +158,19 @@ protected:
 // The base class for any defined symbols.
 class Defined : public SymbolBody {
 public:
-  Defined(Kind K, StringRefZ Name, bool IsLocal, uint8_t StOther, uint8_t Type);
+  Defined(Kind K, StringRefZ Name, bool IsLocal, uint8_t StOther, uint8_t Type)
+      : SymbolBody(K, Name, IsLocal, StOther, Type) {}
+
   static bool classof(const SymbolBody *S) { return S->isDefined(); }
 };
 
 class DefinedCommon : public Defined {
 public:
-  DefinedCommon(StringRef N, uint64_t Size, uint32_t Alignment, uint8_t StOther,
-                uint8_t Type);
+  DefinedCommon(StringRef Name, uint64_t Size, uint32_t Alignment,
+                uint8_t StOther, uint8_t Type)
+      : Defined(SymbolBody::DefinedCommonKind, Name, /*IsLocal=*/false, StOther,
+                Type),
+        Alignment(Alignment), Size(Size) {}
 
   static bool classof(const SymbolBody *S) {
     return S->kind() == SymbolBody::DefinedCommonKind;
@@ -198,7 +207,8 @@ public:
 
 class Undefined : public SymbolBody {
 public:
-  Undefined(StringRefZ Name, bool IsLocal, uint8_t StOther, uint8_t Type);
+  Undefined(StringRefZ Name, bool IsLocal, uint8_t StOther, uint8_t Type)
+      : SymbolBody(SymbolBody::UndefinedKind, Name, IsLocal, StOther, Type) {}
 
   static bool classof(const SymbolBody *S) {
     return S->kind() == UndefinedKind;
@@ -295,7 +305,8 @@ protected:
 // symbol.
 class LazyArchive : public Lazy {
 public:
-  LazyArchive(const llvm::object::Archive::Symbol S, uint8_t Type);
+  LazyArchive(const llvm::object::Archive::Symbol S, uint8_t Type)
+      : Lazy(LazyArchiveKind, S.getName(), Type), Sym(S) {}
 
   static bool classof(const SymbolBody *S) {
     return S->kind() == LazyArchiveKind;
@@ -312,7 +323,7 @@ private:
 // --start-lib and --end-lib options.
 class LazyObject : public Lazy {
 public:
-  LazyObject(StringRef Name, uint8_t Type);
+  LazyObject(StringRef Name, uint8_t Type) : Lazy(LazyObjectKind, Name, Type) {}
 
   static bool classof(const SymbolBody *S) {
     return S->kind() == LazyObjectKind;