[lld] r286462 - Replace duplicated '16' with a named constant.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 10 07:41:35 PST 2016


Author: rafael
Date: Thu Nov 10 09:41:34 2016
New Revision: 286462

URL: http://llvm.org/viewvc/llvm-project?rev=286462&view=rev
Log:
Replace duplicated '16' with a named constant.

Thanks to Michael Spencer for the suggestion.

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

Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=286462&r1=286461&r2=286462&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Thu Nov 10 09:41:34 2016
@@ -217,7 +217,7 @@ BuildIdSection<ELFT>::BuildIdSection(siz
       HashSize(HashSize) {
   this->Live = true;
 
-  Buf.resize(16 + HashSize);
+  Buf.resize(HeaderSize + HashSize);
   const endianness E = ELFT::TargetEndianness;
   write32<E>(Buf.data(), 4);                   // Name size
   write32<E>(Buf.data() + 4, HashSize);        // Content size
@@ -229,8 +229,7 @@ BuildIdSection<ELFT>::BuildIdSection(siz
 // Returns the location of the build-id hash value in the output.
 template <class ELFT>
 uint8_t *BuildIdSection<ELFT>::getOutputLoc(uint8_t *Start) const {
-  // First 16 bytes are a header.
-  return Start + this->OutSec->Offset + this->OutSecOff + 16;
+  return Start + this->OutSec->Offset + this->OutSecOff + HeaderSize;
 }
 
 // Split one uint8 array into small pieces of uint8 arrays.

Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=286462&r1=286461&r2=286462&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Thu Nov 10 09:41:34 2016
@@ -95,6 +95,8 @@ protected:
               std::function<void(ArrayRef<uint8_t> Arr, uint8_t *Hash)> Hash);
 
   size_t HashSize;
+  // First 16 bytes are a header.
+  static const unsigned HeaderSize = 16;
 };
 
 template <class ELFT>




More information about the llvm-commits mailing list