[lld] r285082 - Be a bit more consistent about using getters. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 25 09:42:46 PDT 2016


Author: rafael
Date: Tue Oct 25 11:42:46 2016
New Revision: 285082

URL: http://llvm.org/viewvc/llvm-project?rev=285082&view=rev
Log:
Be a bit more consistent about using getters. NFC.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/InputSection.h

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=285082&r1=285081&r2=285082&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Oct 25 11:42:46 2016
@@ -54,7 +54,7 @@ InputSectionBase<ELFT>::InputSectionBase
       Header(Hdr), File(File), Repl(this) {
   // The ELF spec states that a value of 0 means the section has
   // no alignment constraits.
-  uint64_t V = std::max<uint64_t>(Header->sh_addralign, 1);
+  uint64_t V = std::max<uint64_t>(Hdr->sh_addralign, 1);
   if (!isPowerOf2_64(V))
     fatal(getFilename(File) + ": section sh_addralign is not a power of 2");
 
@@ -150,7 +150,7 @@ template <class ELFT> void InputSectionB
   // shouldn't be significant in ELF.) We need to be able to read both.
   ArrayRef<uint8_t> Buf; // Compressed data
   size_t Size;           // Uncompressed size
-  if (Header->sh_flags & SHF_COMPRESSED)
+  if (getFlags() & SHF_COMPRESSED)
     std::tie(Buf, Size) = getElfCompressedData(Data);
   else
     std::tie(Buf, Size) = getRawCompressedData(Data);
@@ -188,9 +188,9 @@ bool InputSection<ELFT>::classof(const I
 
 template <class ELFT>
 InputSectionBase<ELFT> *InputSection<ELFT>::getRelocatedSection() {
-  assert(this->Header->sh_type == SHT_RELA || this->Header->sh_type == SHT_REL);
+  assert(this->getType() == SHT_RELA || this->getType() == SHT_REL);
   ArrayRef<InputSectionBase<ELFT> *> Sections = this->File->getSections();
-  return Sections[this->Header->sh_info];
+  return Sections[this->getInfo()];
 }
 
 template <class ELFT> void InputSection<ELFT>::addThunk(const Thunk<ELFT> *T) {
@@ -400,7 +400,7 @@ void InputSectionBase<ELFT>::relocate(ui
   // vector only for SHF_ALLOC'ed sections. For other sections,
   // we handle relocations directly here.
   auto *IS = dyn_cast<InputSection<ELFT>>(this);
-  if (IS && !(IS->Header->sh_flags & SHF_ALLOC)) {
+  if (IS && !(IS->getFlags() & SHF_ALLOC)) {
     for (const Elf_Shdr *RelSec : IS->RelocSections) {
       if (RelSec->sh_type == SHT_RELA)
         IS->relocateNonAlloc(Buf, IS->File->getObj().relas(RelSec));
@@ -456,16 +456,16 @@ void InputSectionBase<ELFT>::relocate(ui
 }
 
 template <class ELFT> void InputSection<ELFT>::writeTo(uint8_t *Buf) {
-  if (this->Header->sh_type == SHT_NOBITS)
+  if (this->getType() == SHT_NOBITS)
     return;
   ELFFile<ELFT> &EObj = this->File->getObj();
 
   // If -r is given, then an InputSection may be a relocation section.
-  if (this->Header->sh_type == SHT_RELA) {
+  if (this->getType() == SHT_RELA) {
     copyRelocations(Buf + OutSecOff, EObj.relas(this->Header));
     return;
   }
-  if (this->Header->sh_type == SHT_REL) {
+  if (this->getType() == SHT_REL) {
     copyRelocations(Buf + OutSecOff, EObj.rels(this->Header));
     return;
   }
@@ -635,8 +635,8 @@ MergeInputSection<ELFT>::MergeInputSecti
 
 template <class ELFT> void MergeInputSection<ELFT>::splitIntoPieces() {
   ArrayRef<uint8_t> Data = this->Data;
-  uintX_t EntSize = this->Header->sh_entsize;
-  if (this->Header->sh_flags & SHF_STRINGS)
+  uintX_t EntSize = this->getEntsize();
+  if (this->getFlags() & SHF_STRINGS)
     this->Pieces = splitStrings(Data, EntSize);
   else
     this->Pieces = splitNonStrings(Data, EntSize);

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=285082&r1=285081&r2=285082&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Tue Oct 25 11:42:46 2016
@@ -105,6 +105,7 @@ public:
   uint32_t getType() const { return Header->sh_type; }
   uintX_t getEntsize() const { return Header->sh_entsize; }
   uint32_t getLink() const { return Header->sh_link; }
+  uint32_t getInfo() const { return Header->sh_info; }
   ObjectFile<ELFT> *getFile() const { return File; }
   uintX_t getOffset(const DefinedRegular<ELFT> &Sym) const;
   InputSectionBase *getLinkOrderDep() const;




More information about the llvm-commits mailing list