[lld] r233859 - Use C++ non-static member initialization.

Rui Ueyama ruiu at google.com
Wed Apr 1 15:28:01 PDT 2015


Author: ruiu
Date: Wed Apr  1 17:28:00 2015
New Revision: 233859

URL: http://llvm.org/viewvc/llvm-project?rev=233859&view=rev
Log:
Use C++ non-static member initialization.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/Atoms.h
    lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h
    lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
    lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp

Modified: lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp?rev=233859&r1=233858&r2=233859&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AArch64/AArch64RelocationPass.cpp Wed Apr  1 17:28:00 2015
@@ -244,9 +244,7 @@ protected:
   }
 
 public:
-  AArch64RelocationPass(const ELFLinkingContext &ctx)
-      : _file(ctx), _ctx(ctx), _null(nullptr), _plt0(nullptr), _got0(nullptr),
-        _got1(nullptr) {}
+  AArch64RelocationPass(const ELFLinkingContext &ctx) : _file(ctx), _ctx(ctx) {}
 
   /// \brief Do the pass.
   ///
@@ -337,14 +335,14 @@ protected:
   std::vector<ObjectAtom *> _objectVector;
 
   /// \brief GOT entry that is always 0. Used for undefined weaks.
-  GOTAtom *_null;
+  GOTAtom *_null = nullptr;
 
   /// \brief The got and plt entries for .PLT0. This is used to call into the
   /// dynamic linker for symbol resolution.
   /// @{
-  PLT0Atom *_plt0;
-  GOTAtom *_got0;
-  GOTAtom *_got1;
+  PLT0Atom *_plt0 = nullptr;
+  GOTAtom *_got0 = nullptr;
+  GOTAtom *_got1 = nullptr;
   /// @}
 };
 

Modified: lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp?rev=233859&r1=233858&r2=233859&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ARM/ARMRelocationPass.cpp Wed Apr  1 17:28:00 2015
@@ -346,8 +346,7 @@ protected:
   }
 
 public:
-  ARMRelocationPass(const ELFLinkingContext &ctx)
-      : _file(ctx), _ctx(ctx), _null(nullptr) {}
+  ARMRelocationPass(const ELFLinkingContext &ctx) : _file(ctx), _ctx(ctx) {}
 
   /// \brief Do the pass.
   ///
@@ -433,7 +432,7 @@ protected:
   std::vector<VeneerAtom *> _veneerVector;
 
   /// \brief GOT entry that is always 0. Used for undefined weaks.
-  GOTAtom *_null;
+  GOTAtom *_null = nullptr;
 };
 
 /// This implements the static relocation model. Meaning GOT and PLT entries are

Modified: lld/trunk/lib/ReaderWriter/ELF/Atoms.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Atoms.h?rev=233859&r1=233858&r2=233859&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Atoms.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Atoms.h Wed Apr  1 17:28:00 2015
@@ -41,19 +41,16 @@ public:
   ELFReference(const Elf_Rela *rela, uint64_t off, Reference::KindArch arch,
                Reference::KindValue relocType, uint32_t idx)
       : Reference(Reference::KindNamespace::ELF, arch, relocType),
-        _target(nullptr), _targetSymbolIndex(idx), _offsetInAtom(off),
-        _addend(rela->r_addend) {}
+        _targetSymbolIndex(idx), _offsetInAtom(off), _addend(rela->r_addend) {}
 
   ELFReference(uint64_t off, Reference::KindArch arch,
                Reference::KindValue relocType, uint32_t idx)
       : Reference(Reference::KindNamespace::ELF, arch, relocType),
-        _target(nullptr), _targetSymbolIndex(idx), _offsetInAtom(off),
-        _addend(0) {}
+        _targetSymbolIndex(idx), _offsetInAtom(off) {}
 
   ELFReference(uint32_t edgeKind)
       : Reference(Reference::KindNamespace::all, Reference::KindArch::all,
-                  edgeKind),
-        _target(nullptr), _targetSymbolIndex(0), _offsetInAtom(0), _addend(0) {}
+                  edgeKind) {}
 
   uint64_t offsetInAtom() const override { return _offsetInAtom; }
 
@@ -73,10 +70,10 @@ public:
   void setTarget(const Atom *newAtom) override { _target = newAtom; }
 
 private:
-  const Atom *_target;
-  uint64_t _targetSymbolIndex;
-  uint64_t _offsetInAtom;
-  Addend _addend;
+  const Atom *_target = nullptr;
+  uint64_t _targetSymbolIndex = 0;
+  uint64_t _offsetInAtom = 0;
+  Addend _addend = 0;
 };
 
 /// \brief These atoms store symbols that are fixed to a particular address.
@@ -88,8 +85,7 @@ template <class ELFT> class ELFAbsoluteA
 public:
   ELFAbsoluteAtom(const ELFFile<ELFT> &file, StringRef name,
                   const Elf_Sym *symbol, uint64_t value)
-      : _owningFile(file), _name(name), _symbol(symbol), _value(value) {
-  }
+      : _owningFile(file), _name(name), _symbol(symbol), _value(value) {}
 
   const ELFFile<ELFT> &file() const override { return _owningFile; }
 

Modified: lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h?rev=233859&r1=233858&r2=233859&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/DynamicFile.h Wed Apr  1 17:28:00 2015
@@ -99,9 +99,8 @@ private:
   StringRef _soname;
 
   struct SymAtomPair {
-    SymAtomPair() : _symbol(nullptr), _atom(nullptr) {}
-    const typename llvm::object::ELFFile<ELFT>::Elf_Sym *_symbol;
-    const SharedLibraryAtom *_atom;
+    const typename llvm::object::ELFFile<ELFT>::Elf_Sym *_symbol = nullptr;
+    const SharedLibraryAtom *_atom = nullptr;
   };
 
   std::unique_ptr<MemoryBuffer> _mb;

Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp?rev=233859&r1=233858&r2=233859&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsRelocationPass.cpp Wed Apr  1 17:28:00 2015
@@ -319,7 +319,7 @@ private:
   llvm::DenseMap<const Atom *, GOTAtom *> _gotTLSGdMap;
 
   /// \brief GOT entry for the R_xxxMIPS_TLS_LDM relocations.
-  GOTTLSGdAtom<ELFT> *_gotLDMEntry;
+  GOTTLSGdAtom<ELFT> *_gotLDMEntry = nullptr;
 
   /// \brief the list of local GOT atoms.
   std::vector<GOTAtom *> _localGotVector;
@@ -411,7 +411,7 @@ private:
 
 template <typename ELFT>
 RelocationPass<ELFT>::RelocationPass(MipsLinkingContext &ctx)
-    : _ctx(ctx), _file(ctx), _gotLDMEntry(nullptr) {
+    : _ctx(ctx), _file(ctx) {
   _localGotVector.push_back(new (_file._alloc) GOT0Atom<ELFT>(_file));
   _localGotVector.push_back(new (_file._alloc)
                                 GOTModulePointerAtom<ELFT>(_file));

Modified: lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp?rev=233859&r1=233858&r2=233859&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/X86_64/X86_64RelocationPass.cpp Wed Apr  1 17:28:00 2015
@@ -243,9 +243,7 @@ protected:
   }
 
 public:
-  RelocationPass(const ELFLinkingContext &ctx)
-      : _file(ctx), _ctx(ctx), _null(nullptr), _plt0(nullptr), _got0(nullptr),
-        _got1(nullptr) {}
+  RelocationPass(const ELFLinkingContext &ctx) : _file(ctx), _ctx(ctx) {}
 
   /// \brief Do the pass.
   ///
@@ -322,14 +320,14 @@ protected:
   std::vector<GOTAtom *> _tlsGotVector;
 
   /// \brief GOT entry that is always 0. Used for undefined weaks.
-  GOTAtom *_null;
+  GOTAtom *_null = nullptr;
 
   /// \brief The got and plt entries for .PLT0. This is used to call into the
   /// dynamic linker for symbol resolution.
   /// @{
-  PLT0Atom *_plt0;
-  GOTAtom *_got0;
-  GOTAtom *_got1;
+  PLT0Atom *_plt0 = nullptr;
+  GOTAtom *_got0 = nullptr;
+  GOTAtom *_got1 = nullptr;
   /// @}
 };
 





More information about the llvm-commits mailing list