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
This commit is contained in:
Rafael Espindola 2015-05-28 18:03:20 +00:00
parent ca67e337bf
commit fd64e0f71a
3 changed files with 13 additions and 21 deletions

View File

@ -564,9 +564,6 @@ public:
typedef iterator_range<symbol_iterator> symbol_range;
typedef iterator_range<const_symbol_iterator> const_symbol_range;
typedef std::vector<std::string> FileNameVectorType;
typedef FileNameVectorType::const_iterator const_file_name_iterator;
typedef std::vector<IndirectSymbolData>::const_iterator
const_indirect_symbol_iterator;
typedef std::vector<IndirectSymbolData>::iterator indirect_symbol_iterator;
@ -613,7 +610,7 @@ private:
std::vector<std::vector<std::string>> LinkerOptions;
/// List of declared file names
FileNameVectorType FileNames;
std::vector<std::string> 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<std::string> 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);
}

View File

@ -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());

View File

@ -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;
}