[lld] r252661 - Fix Clang-tidy modernize-use-auto warnings, other minor fixes.

Eugene Zelenko via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 10 14:37:39 PST 2015


Author: eugenezelenko
Date: Tue Nov 10 16:37:38 2015
New Revision: 252661

URL: http://llvm.org/viewvc/llvm-project?rev=252661&view=rev
Log:
Fix Clang-tidy modernize-use-auto warnings, other minor fixes.

Differential revision: http://reviews.llvm.org/D14553

Modified:
    lld/trunk/lib/Driver/Driver.cpp
    lld/trunk/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp
    lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp
    lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
    lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.cpp
    lld/trunk/lib/ReaderWriter/LinkerScript.cpp
    lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/File.h
    lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
    lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
    lld/trunk/lib/ReaderWriter/MachO/TLVPass.cpp

Modified: lld/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/Driver.cpp?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/Driver/Driver.cpp (original)
+++ lld/trunk/lib/Driver/Driver.cpp Tue Nov 10 16:37:38 2015
@@ -1,4 +1,4 @@
-//===- lib/Driver/Driver.cpp - Linker Driver Emulator ---------------------===//
+//===- lib/Driver/Driver.cpp - Linker Driver Emulator -----------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -69,7 +69,7 @@ bool Driver::link(LinkingContext &ctx, r
   // Honor -mllvm
   if (!ctx.llvmOptions().empty()) {
     unsigned numArgs = ctx.llvmOptions().size();
-    const char **args = new const char *[numArgs + 2];
+    auto **args = new const char *[numArgs + 2];
     args[0] = "lld (LLVM option parsing)";
     for (unsigned i = 0; i != numArgs; ++i)
       args[i + 1] = ctx.llvmOptions()[i];
@@ -136,4 +136,4 @@ bool Driver::link(LinkingContext &ctx, r
   return true;
 }
 
-} // anonymous namespace
+} // namespace lld

Modified: lld/trunk/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp Tue Nov 10 16:37:38 2015
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp ----------------===//
+//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp -------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -52,7 +52,7 @@ void AMDGPUTargetLayout::assignSectionsT
       if (InputSectionName != ".hsatext")
         continue;
 
-      Segment<ELF64LE> *segment = new (_allocator) Segment<ELF64LE>(
+      auto *segment = new (_allocator) Segment<ELF64LE>(
           _ctx, "PT_AMDGPU_HSA_LOAD_CODE_AGENT", PT_AMDGPU_HSA_LOAD_CODE_AGENT);
       _segments.push_back(segment);
       assert(segment);

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.cpp Tue Nov 10 16:37:38 2015
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ELFFile.cpp -----------------------------------===//
+//===- lib/ReaderWriter/ELF/ELFFile.cpp -------------------------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -462,7 +462,7 @@ std::error_code ELFFile<ELFT>::handleGnu
   std::vector<ELFReference<ELFT> *> refs;
   for (auto ha : atomsForSection[*sectionName]) {
     _groupChild[ha->symbol()] = std::make_pair(*sectionName, section);
-    ELFReference<ELFT> *ref =
+    auto *ref =
         new (_readerStorage) ELFReference<ELFT>(Reference::kindGroupChild);
     ref->setTarget(ha);
     refs.push_back(ref);
@@ -536,7 +536,7 @@ std::error_code ELFFile<ELFT>::handleSec
   for (auto name : sectionNames) {
     for (auto ha : atomsForSection[name]) {
       _groupChild[ha->symbol()] = std::make_pair(*symbolName, section);
-      ELFReference<ELFT> *ref =
+      auto *ref =
           new (_readerStorage) ELFReference<ELFT>(Reference::kindGroupChild);
       ref->setTarget(ha);
       refs.push_back(ref);
@@ -727,7 +727,7 @@ template <class ELFT>
 ELFDefinedAtom<ELFT> *
 ELFFile<ELFT>::createSectionAtom(const Elf_Shdr *section, StringRef sectionName,
                                  ArrayRef<uint8_t> content) {
-  Elf_Sym *sym = new (_readerStorage) Elf_Sym;
+  auto *sym = new (_readerStorage) Elf_Sym;
   sym->st_name = 0;
   sym->setBindingAndType(llvm::ELF::STB_LOCAL, llvm::ELF::STT_SECTION);
   sym->st_other = 0;
@@ -787,7 +787,7 @@ bool ELFFile<ELFT>::redirectReferenceUsi
 template <class ELFT>
 void RuntimeFile<ELFT>::addAbsoluteAtom(StringRef symbolName, bool isHidden) {
   assert(!symbolName.empty() && "AbsoluteAtoms must have a name");
-  Elf_Sym *sym = new (this->_readerStorage) Elf_Sym;
+  auto *sym = new (this->_readerStorage) Elf_Sym;
   sym->st_name = 0;
   sym->st_value = 0;
   sym->st_shndx = llvm::ELF::SHN_ABS;
@@ -804,7 +804,7 @@ void RuntimeFile<ELFT>::addAbsoluteAtom(
 template <class ELFT>
 void RuntimeFile<ELFT>::addUndefinedAtom(StringRef symbolName) {
   assert(!symbolName.empty() && "UndefinedAtoms must have a name");
-  Elf_Sym *sym = new (this->_readerStorage) Elf_Sym;
+  auto *sym = new (this->_readerStorage) Elf_Sym;
   sym->st_name = 0;
   sym->st_value = 0;
   sym->st_shndx = llvm::ELF::SHN_UNDEF;

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Tue Nov 10 16:37:38 2015
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/ELFFile.h -------------------------------------===//
+//===- lib/ReaderWriter/ELF/ELFFile.h ---------------------------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -291,7 +291,7 @@ protected:
                                          const Elf_Shdr *sectionHdr,
                                          ArrayRef<uint8_t> contentData,
                                          unsigned int offset) {
-    ELFMergeAtom<ELFT> *mergeAtom = new (_readerStorage)
+    auto *mergeAtom = new (_readerStorage)
         ELFMergeAtom<ELFT>(*this, sectionName, sectionHdr, contentData, offset);
     const MergeSectionKey mergedSectionKey = {sectionHdr, offset};
     if (_mergedSectionMap.find(mergedSectionKey) == _mergedSectionMap.end())

Modified: lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.cpp?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.cpp (original)
+++ lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.cpp Tue Nov 10 16:37:38 2015
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/ELF/HeaderChunks.cpp ------------------------------===//
+//===- lib/ReaderWriter/ELF/HeaderChunks.cpp --------------------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -135,7 +135,7 @@ SectionHeader<ELFT>::SectionHeader(const
   this->_alignment = 8;
   this->setOrder(order);
   // The first element in the list is always NULL
-  Elf_Shdr *nullshdr = new (_sectionAllocate.Allocate<Elf_Shdr>()) Elf_Shdr;
+  auto *nullshdr = new (_sectionAllocate.Allocate<Elf_Shdr>()) Elf_Shdr;
   ::memset(nullshdr, 0, sizeof(Elf_Shdr));
   _sectionInfo.push_back(nullshdr);
   this->_fsize += sizeof(Elf_Shdr);
@@ -143,7 +143,7 @@ SectionHeader<ELFT>::SectionHeader(const
 
 template <class ELFT>
 void SectionHeader<ELFT>::appendSection(OutputSection<ELFT> *section) {
-  Elf_Shdr *shdr = new (_sectionAllocate.Allocate<Elf_Shdr>()) Elf_Shdr;
+  auto *shdr = new (_sectionAllocate.Allocate<Elf_Shdr>()) Elf_Shdr;
   shdr->sh_name = _stringSection->addString(section->name());
   shdr->sh_type = section->type();
   shdr->sh_flags = section->flags();

Modified: lld/trunk/lib/ReaderWriter/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/LinkerScript.cpp?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/LinkerScript.cpp (original)
+++ lld/trunk/lib/ReaderWriter/LinkerScript.cpp Tue Nov 10 16:37:38 2015
@@ -1,4 +1,4 @@
-//===- ReaderWriter/LinkerScript.cpp --------------------------------------===//
+//===- ReaderWriter/LinkerScript.cpp ----------------------------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -1019,7 +1019,6 @@ void Extern::dump(raw_ostream &os) const
   os << ")\n";
 }
 
-
 // Parser functions
 std::error_code Parser::parse() {
   // Get the first token.
@@ -1183,7 +1182,7 @@ const Expression *Parser::parseExprOpera
   case Token::identifier: {
     if (peek()._kind== Token::l_paren)
       return parseFunctionCall();
-    Symbol *sym = new (_alloc) Symbol(*this, _tok._range);
+    auto *sym = new (_alloc) Symbol(*this, _tok._range);
     consumeToken();
     return sym;
   }
@@ -1201,7 +1200,7 @@ const Expression *Parser::parseExprOpera
       error(_tok, "Unrecognized number constant");
       return nullptr;
     }
-    Constant *c = new (_alloc) Constant(*this, *val);
+    auto *c = new (_alloc) Constant(*this, *val);
     consumeToken();
     return c;
   }
@@ -2354,8 +2353,7 @@ Memory *Parser::parseMemory() {
       if (!length)
         return nullptr;
 
-      MemoryBlock *block =
-          new (_alloc) MemoryBlock(name, attrs, origin, length);
+      auto *block = new (_alloc) MemoryBlock(name, attrs, origin, length);
       blocks.push_back(block);
     } else {
       unrecognizedToken = true;
@@ -2649,11 +2647,10 @@ int Sema::getLayoutOrder(const SectionKe
 
   // If we still couldn't find a rule for this input section, try to match
   // wildcards
-  for (auto I = _memberNameWildcards.begin(), E = _memberNameWildcards.end();
-       I != E; ++I) {
-    if (!wildcardMatch(I->first, key.memberPath))
+  for (const auto &I : _memberNameWildcards) {
+    if (!wildcardMatch(I.first, key.memberPath))
       continue;
-    int order = I->second;
+    int order = I.second;
     int exprOrder = -1;
 
     if ((exprOrder = matchSectionName(order, key)) >= 0) {
@@ -2894,5 +2891,5 @@ void Sema::linearizeAST(const Sections *
   }
 }
 
-} // End namespace script
+} // end namespace script
 } // end namespace lld

Modified: lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/CompactUnwindPass.cpp Tue Nov 10 16:37:38 2015
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/MachO/CompactUnwindPass.cpp -----------------------===//
+//===- lib/ReaderWriter/MachO/CompactUnwindPass.cpp -------------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -342,7 +342,7 @@ private:
             << " has " << entriesInPage << " entries\n");
     } while (pageStart < unwindInfos.size());
 
-    UnwindInfoAtom *unwind = new (_file.allocator())
+    auto *unwind = new (_file.allocator())
         UnwindInfoAtom(_archHandler, _file, _isBig, personalities,
                        commonEncodings, pages, numLSDAs);
     mergedFile.addAtom(*unwind);
@@ -520,7 +520,6 @@ private:
     });
   }
 
-
   CompactUnwindEntry finalizeUnwindInfoEntryForAtom(
       const DefinedAtom *function,
       const std::map<const Atom *, CompactUnwindEntry> &unwindLocs,
@@ -549,7 +548,6 @@ private:
       }
     }
 
-
     auto personality = std::find(personalities.begin(), personalities.end(),
                                  entry.personalityFunction);
     uint32_t personalityIdx = personality == personalities.end()

Modified: lld/trunk/lib/ReaderWriter/MachO/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/File.h?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/File.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/File.h Tue Nov 10 16:37:38 2015
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/MachO/File.h --------------------------------------===//
+//===- lib/ReaderWriter/MachO/File.h ----------------------------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -45,7 +45,7 @@ public:
     DefinedAtom::Alignment align(
         inSection->alignment,
         sectionOffset % inSection->alignment);
-    MachODefinedAtom *atom =
+    auto *atom =
         new (allocator()) MachODefinedAtom(*this, name, scope, type, merge,
                                            thumb, noDeadStrip, content, align);
     addAtomForSection(inSection, atom, sectionOffset);
@@ -68,7 +68,7 @@ public:
     DefinedAtom::Alignment align(
         inSection->alignment,
         sectionOffset % inSection->alignment);
-    MachODefinedCustomSectionAtom *atom =
+    auto *atom =
         new (allocator()) MachODefinedCustomSectionAtom(*this, name, scope, type,
                                                         merge, thumb,
                                                         noDeadStrip, content,
@@ -87,7 +87,7 @@ public:
     DefinedAtom::Alignment align(
         inSection->alignment,
         sectionOffset % inSection->alignment);
-    MachODefinedAtom *atom =
+    auto *atom =
        new (allocator()) MachODefinedAtom(*this, name, scope, size, noDeadStrip,
                                           align);
     addAtomForSection(inSection, atom, sectionOffset);
@@ -98,8 +98,7 @@ public:
       // Make a copy of the atom's name that is owned by this file.
       name = name.copy(allocator());
     }
-    SimpleUndefinedAtom *atom =
-        new (allocator()) SimpleUndefinedAtom(*this, name);
+    auto *atom = new (allocator()) SimpleUndefinedAtom(*this, name);
     addAtom(*atom);
     _undefAtoms[name] = atom;
   }
@@ -110,7 +109,7 @@ public:
       // Make a copy of the atom's name that is owned by this file.
       name = name.copy(allocator());
     }
-    MachOTentativeDefAtom *atom =
+    auto *atom =
         new (allocator()) MachOTentativeDefAtom(*this, name, scope, size, align);
     addAtom(*atom);
     _undefAtoms[name] = atom;
@@ -200,7 +199,6 @@ private:
     addAtom(*atom);
   }
 
-
   typedef llvm::DenseMap<const normalized::Section *,
                          std::vector<SectionOffsetAndAtom>>  SectionToAtoms;
   typedef llvm::StringMap<const lld::Atom *> NameToAtom;
@@ -298,7 +296,6 @@ private:
     return nullptr;
   }
 
-
   struct ReExportedDylib {
     ReExportedDylib(StringRef p) : path(p), file(nullptr) { }
     StringRef       path;
@@ -324,4 +321,4 @@ private:
 } // end namespace mach_o
 } // end namespace lld
 
-#endif
+#endif // LLD_READER_WRITER_MACHO_FILE_H

Modified: lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/GOTPass.cpp Tue Nov 10 16:37:38 2015
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/MachO/GOTPass.cpp ---------------------------------===//
+//===- lib/ReaderWriter/MachO/GOTPass.cpp -----------------------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -46,7 +46,6 @@
 namespace lld {
 namespace mach_o {
 
-
 //
 //  GOT Entry Atom created by the GOT pass.
 //
@@ -86,7 +85,6 @@ private:
   StringRef _name;
 };
 
-
 /// Pass for instantiating and optimizing GOT slots.
 ///
 class GOTPass : public Pass {
@@ -155,7 +153,7 @@ private:
   const DefinedAtom *makeGOTEntry(const Atom *target) {
     auto pos = _targetToGOT.find(target);
     if (pos == _targetToGOT.end()) {
-      GOTEntryAtom *gotEntry = new (_file.allocator())
+      auto *gotEntry = new (_file.allocator())
           GOTEntryAtom(_file, _ctx.is64Bit(), target->name());
       _targetToGOT[target] = gotEntry;
       const ArchHandler::ReferenceInfo &nlInfo = _archHandler.stubInfo().
@@ -173,13 +171,10 @@ private:
   llvm::DenseMap<const Atom*, const GOTEntryAtom*> _targetToGOT;
 };
 
-
-
 void addGOTPass(PassManager &pm, const MachOLinkingContext &ctx) {
   assert(ctx.needsGOTPass());
   pm.add(llvm::make_unique<GOTPass>(ctx));
 }
 
-
 } // end namesapce mach_o
 } // end namesapce lld

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp Tue Nov 10 16:37:38 2015
@@ -149,6 +149,7 @@ private:
     const uint8_t *bytes() {
       return reinterpret_cast<const uint8_t*>(_ostream.str().data());
     }
+
   private:
     SmallVector<char, 128>        _bytes;
     // Stream ivar must be after SmallVector ivar to construct properly.
@@ -168,14 +169,14 @@ private:
     TrieNode(StringRef s)
         : _cummulativeString(s), _address(0), _flags(0), _other(0),
           _trieOffset(0), _hasExportInfo(false) {}
-    ~TrieNode() {}
+    ~TrieNode() = default;
 
     void addSymbol(const Export &entry, BumpPtrAllocator &allocator,
                    std::vector<TrieNode *> &allNodes);
     bool updateOffset(uint32_t &offset);
     void appendToByteBuffer(ByteBuffer &out);
 
-private:
+  private:
     StringRef                 _cummulativeString;
     std::list<TrieEdge>       _children;
     uint64_t                  _address;
@@ -262,7 +263,6 @@ size_t MachOFileLayout::headerAndLoadCom
   return _endOfLoadCommands;
 }
 
-
 MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
     : _file(file),
       _is64(MachOLinkingContext::is64Bit(file.arch)),
@@ -548,7 +548,6 @@ void MachOFileLayout::buildFileOffsets()
   _startOfLinkEdit = fileOffset;
 }
 
-
 size_t MachOFileLayout::size() const {
   return _endOfSymbolStrings;
 }
@@ -881,7 +880,6 @@ std::error_code MachOFileLayout::writeLo
   return ec;
 }
 
-
 void MachOFileLayout::writeSectionContent() {
   for (const Section &s : _file.sections) {
     // Copy all section content to output buffer.
@@ -908,7 +906,6 @@ void MachOFileLayout::writeRelocations()
   }
 }
 
-
 void MachOFileLayout::appendSymbols(const std::vector<Symbol> &symbols,
                                    uint32_t &symOffset, uint32_t &strOffset) {
   for (const Symbol &sym : symbols) {
@@ -1099,7 +1096,7 @@ void MachOFileLayout::TrieNode::addSymbo
         // Splice in new node:  was A -> C,  now A -> B -> C
         StringRef bNodeStr = edge._child->_cummulativeString;
         bNodeStr = bNodeStr.drop_back(edgeStr.size()-n).copy(allocator);
-        TrieNode* bNode = new (allocator) TrieNode(bNodeStr);
+        auto *bNode = new (allocator) TrieNode(bNodeStr);
         allNodes.push_back(bNode);
         TrieNode* cNode = edge._child;
         StringRef abEdgeStr = edgeStr.substr(0,n).copy(allocator);
@@ -1112,7 +1109,7 @@ void MachOFileLayout::TrieNode::addSymbo
         TrieEdge& abEdge = edge;
         abEdge._subString = abEdgeStr;
         abEdge._child = bNode;
-        TrieEdge *bcEdge = new (allocator) TrieEdge(bcEdgeStr, cNode);
+        auto *bcEdge = new (allocator) TrieEdge(bcEdgeStr, cNode);
         bNode->_children.push_back(std::move(*bcEdge));
         bNode->addSymbol(entry, allocator, allNodes);
         return;
@@ -1126,8 +1123,8 @@ void MachOFileLayout::TrieNode::addSymbo
     assert(entry.otherOffset != 0);
   }
   // No commonality with any existing child, make a new edge.
-  TrieNode* newNode = new (allocator) TrieNode(entry.name.copy(allocator));
-  TrieEdge *newEdge = new (allocator) TrieEdge(partialStr, newNode);
+  auto *newNode = new (allocator) TrieNode(entry.name.copy(allocator));
+  auto *newEdge = new (allocator) TrieEdge(partialStr, newNode);
   _children.push_back(std::move(*newEdge));
   DEBUG_WITH_TYPE("trie-builder", llvm::dbgs()
                    << "new TrieNode('" << entry.name << "') with edge '"
@@ -1239,7 +1236,7 @@ void MachOFileLayout::buildExportTrie()
   BumpPtrAllocator allocator;
 
   // Build trie of all exported symbols.
-  TrieNode* rootNode = new (allocator) TrieNode(StringRef());
+  auto *rootNode = new (allocator) TrieNode(StringRef());
   std::vector<TrieNode*> allNodes;
   allNodes.reserve(_file.exportInfo.size()*2);
   allNodes.push_back(rootNode);
@@ -1266,7 +1263,6 @@ void MachOFileLayout::buildExportTrie()
   _exportTrie.align(_is64 ? 8 : 4);
 }
 
-
 void MachOFileLayout::computeSymbolTableSizes() {
   // MachO symbol tables have three ranges: locals, globals, and undefines
   const size_t nlistSize = (_is64 ? sizeof(nlist_64) : sizeof(nlist));
@@ -1340,14 +1336,12 @@ std::error_code MachOFileLayout::writeBi
   return std::error_code();
 }
 
-
 /// Takes in-memory normalized view and writes a mach-o object file.
 std::error_code writeBinary(const NormalizedFile &file, StringRef path) {
   MachOFileLayout layout(file);
   return layout.writeBinary(path);
 }
 
-
 } // namespace normalized
 } // namespace mach_o
 } // namespace lld

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp Tue Nov 10 16:37:38 2015
@@ -90,7 +90,6 @@ SegmentInfo::SegmentInfo(StringRef n)
  : name(n), address(0), size(0), access(0), normalizedSegmentIndex(0) {
 }
 
-
 class Util {
 public:
   Util(const MachOLinkingContext &ctxt)
@@ -207,7 +206,7 @@ SectionInfo *Util::getRelocatableSection
     }
   }
   // Otherwise allocate new SectionInfo object.
-  SectionInfo *sect = new (_allocator)
+  auto *sect = new (_allocator)
       SectionInfo(segmentName, sectionName, sectionType, _ctx, sectionAttrs);
   _sectionInfos.push_back(sect);
   _sectionMap[type] = sect;
@@ -259,7 +258,6 @@ const MachOFinalSectionFromAtomType sect
 };
 #undef ENTRY
 
-
 SectionInfo *Util::getFinalSection(DefinedAtom::ContentType atomType) {
   for (auto &p : sectsToAtomType) {
     if (p.atomType != atomType)
@@ -286,7 +284,7 @@ SectionInfo *Util::getFinalSection(Defin
       }
     }
     // Otherwise allocate new SectionInfo object.
-    SectionInfo *sect = new (_allocator) SectionInfo(
+    auto *sect = new (_allocator) SectionInfo(
         p.segmentName, p.sectionName, p.sectionType, _ctx, sectionAttrs);
     _sectionInfos.push_back(sect);
     _sectionMap[atomType] = sect;
@@ -295,8 +293,6 @@ SectionInfo *Util::getFinalSection(Defin
   llvm_unreachable("content type not yet supported");
 }
 
-
-
 SectionInfo *Util::sectionForAtom(const DefinedAtom *atom) {
   if (atom->sectionChoice() == DefinedAtom::sectionBasedOnContent) {
     // Section for this atom is derived from content type.
@@ -321,7 +317,7 @@ SectionInfo *Util::sectionForAtom(const
     assert(seperatorIndex != StringRef::npos);
     StringRef segName = customName.slice(0, seperatorIndex);
     StringRef sectName = customName.drop_front(seperatorIndex + 1);
-    SectionInfo *sect =
+    auto *sect =
         new (_allocator) SectionInfo(segName, sectName, S_REGULAR, _ctx);
     _customSections.push_back(sect);
     _sectionInfos.push_back(sect);
@@ -329,7 +325,6 @@ SectionInfo *Util::sectionForAtom(const
   }
 }
 
-
 void Util::appendAtom(SectionInfo *sect, const DefinedAtom *atom) {
   // Figure out offset for atom in this section given alignment constraints.
   uint64_t offset = sect->size;
@@ -367,7 +362,7 @@ SegmentInfo *Util::segmentForName(String
     if ( si->name.equals(segName) )
       return si;
   }
-  SegmentInfo *info = new (_allocator) SegmentInfo(segName);
+  auto *info = new (_allocator) SegmentInfo(segName);
   if (segName.equals("__TEXT"))
     info->access = VM_PROT_READ | VM_PROT_EXECUTE;
   else if (segName.equals("__DATA"))
@@ -408,7 +403,6 @@ bool Util::TextSectionSorter::operator()
   return (weight(left) < weight(right));
 }
 
-
 void Util::organizeSections() {
   if (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT) {
     // Leave sections ordered as normalized file specified.
@@ -456,10 +450,8 @@ void Util::organizeSections() {
       }
     }
   }
-
 }
 
-
 void Util::layoutSectionsInSegment(SegmentInfo *seg, uint64_t &addr) {
   seg->address = addr;
   for (SectionInfo *sect : seg->sections) {
@@ -469,7 +461,6 @@ void Util::layoutSectionsInSegment(Segme
   seg->size = llvm::RoundUpToAlignment(addr - seg->address, _ctx.pageSize());
 }
 
-
 // __TEXT segment lays out backwards so padding is at front after load commands.
 void Util::layoutSectionsInTextSegment(size_t hlcSize, SegmentInfo *seg,
                                                                uint64_t &addr) {
@@ -493,7 +484,6 @@ void Util::layoutSectionsInTextSegment(s
   seg->size = llvm::RoundUpToAlignment(addr - seg->address, _ctx.pageSize());
 }
 
-
 void Util::assignAddressesToSections(const NormalizedFile &file) {
   size_t hlcSize = headerAndLoadCommandsSize(file);
   uint64_t address = 0;
@@ -545,7 +535,6 @@ void Util::assignAddressesToSections(con
   }
 }
 
-
 void Util::copySegmentInfo(NormalizedFile &file) {
   for (SegmentInfo *sgi : _segmentInfos) {
     Segment seg;
@@ -611,7 +600,6 @@ void Util::copySectionContent(Normalized
   }
 }
 
-
 void Util::copySectionInfo(NormalizedFile &file) {
   file.sections.reserve(_sectionInfos.size());
   // For final linked images, write sections grouped by segment.
@@ -717,13 +705,11 @@ uint16_t Util::descBits(const DefinedAto
   return desc;
 }
 
-
 bool Util::AtomSorter::operator()(const AtomAndIndex &left,
                                   const AtomAndIndex &right) {
   return (left.atom->name().compare(right.atom->name()) < 0);
 }
 
-
 std::error_code Util::getSymbolTableRegion(const DefinedAtom* atom,
                                            bool &inGlobalsRegion,
                                            SymbolScope &scope) {
@@ -837,7 +823,6 @@ std::error_code Util::addSymbols(const l
     file.globalSymbols.push_back(sym);
   }
 
-
   // Sort undefined symbol alphabetically, then add to symbol table.
   std::vector<AtomAndIndex> undefs;
   undefs.reserve(128);
@@ -895,7 +880,6 @@ const Atom *Util::targetOfStub(const Def
   return nullptr;
 }
 
-
 void Util::addIndirectSymbols(const lld::File &atomFile, NormalizedFile &file) {
   for (SectionInfo *si : _sectionInfos) {
     Section &normSect = file.sections[si->normalizedSectionIndex];
@@ -944,7 +928,6 @@ void Util::addIndirectSymbols(const lld:
       break;
     }
   }
-
 }
 
 void Util::addDependentDylibs(const lld::File &atomFile,NormalizedFile &nFile) {
@@ -994,7 +977,6 @@ void Util::addDependentDylibs(const lld:
   }
 }
 
-
 int Util::dylibOrdinal(const SharedLibraryAtom *sa) {
   return _dylibInfo[sa->loadName()].ordinal;
 }
@@ -1013,7 +995,6 @@ void Util::segIndexForSection(const Sect
   llvm_unreachable("section not in any segment");
 }
 
-
 uint32_t Util::sectionIndexForAtom(const Atom *atom) {
   uint64_t address = _atomToAddress[atom];
   uint32_t index = 1;
@@ -1029,7 +1010,6 @@ void Util::addSectionRelocs(const lld::F
   if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT)
     return;
 
-
   // Utility function for ArchHandler to find symbol index for an atom.
   auto symIndexForAtom = [&] (const Atom &atom) -> uint32_t {
     auto pos = _atomToSymbolIndex.find(&atom);
@@ -1207,7 +1187,6 @@ uint32_t Util::fileFlags() {
 
 } // end anonymous namespace
 
-
 namespace lld {
 namespace mach_o {
 namespace normalized {
@@ -1252,7 +1231,6 @@ normalizedFromAtoms(const lld::File &ato
   return std::move(f);
 }
 
-
 } // namespace normalized
 } // namespace mach_o
 } // namespace lld

Modified: lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp Tue Nov 10 16:37:38 2015
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/MachO/StubsPass.cpp -------------------------------===//
+//===- lib/ReaderWriter/MachO/StubsPass.cpp ---------------------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -26,11 +26,9 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 
-
 namespace lld {
 namespace mach_o {
 
-
 //
 //  Lazy Pointer Atom created by the stubs pass.
 //
@@ -65,7 +63,6 @@ private:
   const bool _is64;
 };
 
-
 //
 //  NonLazyPointer (GOT) Atom created by the stubs pass.
 //
@@ -100,8 +97,6 @@ private:
   const bool _is64;
 };
 
-
-
 //
 // Stub Atom created by the stubs pass.
 //
@@ -134,7 +129,6 @@ private:
   const ArchHandler::StubInfo   &_stubInfo;
 };
 
-
 //
 // Stub Helper Atom created by the stubs pass.
 //
@@ -168,7 +162,6 @@ private:
   const ArchHandler::StubInfo   &_stubInfo;
 };
 
-
 //
 // Stub Helper Common Atom created by the stubs pass.
 //
@@ -202,7 +195,6 @@ private:
   const ArchHandler::StubInfo   &_stubInfo;
 };
 
-
 class StubsPass : public Pass {
 public:
   StubsPass(const MachOLinkingContext &context)
@@ -284,11 +276,10 @@ public:
     // Make and append stubs, lazy pointers, and helpers in alphabetical order.
     unsigned lazyOffset = 0;
     for (const Atom *target : targetsNeedingStubs) {
-      StubAtom *stub = new (_file.allocator()) StubAtom(_file, _stubInfo);
-      LazyPointerAtom *lp =
+      auto *stub = new (_file.allocator()) StubAtom(_file, _stubInfo);
+      auto *lp =
           new (_file.allocator()) LazyPointerAtom(_file, _ctx.is64Bit());
-      StubHelperAtom *helper =
-          new (_file.allocator()) StubHelperAtom(_file, _stubInfo);
+      auto *helper = new (_file.allocator()) StubHelperAtom(_file, _stubInfo);
 
       addReference(stub, _stubInfo.stubReferenceToLP, lp);
       addOptReference(stub, _stubInfo.stubReferenceToLP,
@@ -320,7 +311,6 @@ public:
   }
 
 private:
-
   bool noTextRelocs() {
     return true;
   }
@@ -365,8 +355,6 @@ private:
   TargetToUses                                    _targetToUses;
 };
 
-
-
 void addStubsPass(PassManager &pm, const MachOLinkingContext &ctx) {
   pm.add(std::unique_ptr<Pass>(new StubsPass(ctx)));
 }

Modified: lld/trunk/lib/ReaderWriter/MachO/TLVPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/TLVPass.cpp?rev=252661&r1=252660&r2=252661&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/TLVPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/TLVPass.cpp Tue Nov 10 16:37:38 2015
@@ -1,4 +1,4 @@
-//===- lib/ReaderWriter/MachO/TLVPass.cpp ---------------------------------===//
+//===- lib/ReaderWriter/MachO/TLVPass.cpp -----------------------*- C++ -*-===//
 //
 //                             The LLVM Linker
 //
@@ -68,9 +68,7 @@ public:
         _file("<mach-o TLV Pass>") {}
 
 private:
-
   std::error_code perform(SimpleFile &mergedFile) override {
-
     bool allowTLV = _ctx.minOS("10.7", "1.0");
 
     for (const DefinedAtom *atom : mergedFile.defined()) {
@@ -114,7 +112,7 @@ private:
     if (pos != _targetToTLVP.end())
       return pos->second;
 
-    TLVPEntryAtom *tlvpEntry = new (_file.allocator())
+    auto *tlvpEntry = new (_file.allocator())
       TLVPEntryAtom(_file, _ctx.is64Bit(), target->name());
     _targetToTLVP[target] = tlvpEntry;
     const ArchHandler::ReferenceInfo &nlInfo =
@@ -135,6 +133,5 @@ void addTLVPass(PassManager &pm, const M
   pm.add(llvm::make_unique<TLVPass>(ctx));
 }
 
-
 } // end namesapce mach_o
 } // end namesapce lld




More information about the llvm-commits mailing list