From: Rafael Espindola Date: Thu, 28 May 2015 18:03:20 +0000 (+0000) Subject: Use range loops for accessing file names. NFC. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=fd64e0f71a38c69a3b8d120937bc0d1cfa62b59e;p=oota-llvm.git Use range loops for accessing file names. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238446 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 593504ce060..f8108501de9 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -564,9 +564,6 @@ public: typedef iterator_range symbol_range; typedef iterator_range const_symbol_range; - typedef std::vector FileNameVectorType; - typedef FileNameVectorType::const_iterator const_file_name_iterator; - typedef std::vector::const_iterator const_indirect_symbol_iterator; typedef std::vector::iterator indirect_symbol_iterator; @@ -613,7 +610,7 @@ private: std::vector> LinkerOptions; /// List of declared file names - FileNameVectorType FileNames; + std::vector FileNames; /// The set of function symbols for which a .thumb_func directive has /// been seen. @@ -907,15 +904,11 @@ public: return Symbol.getData(); } - const_file_name_iterator file_names_begin() const { - return FileNames.begin(); - } - - const_file_name_iterator file_names_end() const { return FileNames.end(); } + ArrayRef getFileNames() { return FileNames; } void addFileName(StringRef FileName) { - if (std::find(file_names_begin(), file_names_end(), FileName) == - file_names_end()) + if (std::find(FileNames.begin(), FileNames.end(), FileName) == + FileNames.end()) FileNames.push_back(FileName); } diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 6c5df9c22a1..2975a9bfbcd 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -931,13 +931,13 @@ void ELFObjectWriter::computeSymbolTable( SymtabShndxSection->setAlignment(4); } - for (auto i = Asm.file_names_begin(), e = Asm.file_names_end(); i != e; ++i) - StrTabBuilder.add(*i); + for (const std::string &Name : Asm.getFileNames()) + StrTabBuilder.add(Name); StrTabBuilder.finalize(StringTableBuilder::ELF); - for (auto i = Asm.file_names_begin(), e = Asm.file_names_end(); i != e; ++i) - FileSymbolData.push_back(StrTabBuilder.getOffset(*i)); + for (const std::string &Name : Asm.getFileNames()) + FileSymbolData.push_back(StrTabBuilder.getOffset(Name)); // Symbols are required to be in lexicographic order. array_pod_sort(LocalSymbolData.begin(), LocalSymbolData.end()); diff --git a/lib/MC/WinCOFFObjectWriter.cpp b/lib/MC/WinCOFFObjectWriter.cpp index c94508563e5..8108d7c2fa2 100644 --- a/lib/MC/WinCOFFObjectWriter.cpp +++ b/lib/MC/WinCOFFObjectWriter.cpp @@ -853,11 +853,10 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm, Header.NumberOfSections = NumberOfSections; Header.NumberOfSymbols = 0; - for (auto FI = Asm.file_names_begin(), FE = Asm.file_names_end(); FI != FE; - ++FI) { + for (const std::string &Name : Asm.getFileNames()) { // round up to calculate the number of auxiliary symbols required unsigned SymbolSize = UseBigObj ? COFF::Symbol32Size : COFF::Symbol16Size; - unsigned Count = (FI->size() + SymbolSize - 1) / SymbolSize; + unsigned Count = (Name.size() + SymbolSize - 1) / SymbolSize; COFFSymbol *file = createSymbol(".file"); file->Data.SectionNumber = COFF::IMAGE_SYM_DEBUG; @@ -865,15 +864,15 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm, file->Aux.resize(Count); unsigned Offset = 0; - unsigned Length = FI->size(); + unsigned Length = Name.size(); for (auto &Aux : file->Aux) { Aux.AuxType = ATFile; if (Length > SymbolSize) { - memcpy(&Aux.Aux, FI->c_str() + Offset, SymbolSize); + memcpy(&Aux.Aux, Name.c_str() + Offset, SymbolSize); Length = Length - SymbolSize; } else { - memcpy(&Aux.Aux, FI->c_str() + Offset, Length); + memcpy(&Aux.Aux, Name.c_str() + Offset, Length); memset((char *)&Aux.Aux + Length, 0, SymbolSize - Length); break; }