1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

DWARFEmitter.cpp - use auto const& iterators in for-range loops to avoid copies. NFCI.

This commit is contained in:
Simon Pilgrim 2020-09-21 15:15:51 +01:00
parent 0f7c7ec819
commit 9143c682a5

View File

@ -110,7 +110,7 @@ StringRef DWARFYAML::Data::getAbbrevTableContentByIndex(uint64_t Index) const {
encodeULEB128(AbbrevCode, OS); encodeULEB128(AbbrevCode, OS);
encodeULEB128(AbbrevDecl.Tag, OS); encodeULEB128(AbbrevDecl.Tag, OS);
OS.write(AbbrevDecl.Children); OS.write(AbbrevDecl.Children);
for (auto Attr : AbbrevDecl.Attributes) { for (const auto &Attr : AbbrevDecl.Attributes) {
encodeULEB128(Attr.Attribute, OS); encodeULEB128(Attr.Attribute, OS);
encodeULEB128(Attr.Form, OS); encodeULEB128(Attr.Form, OS);
if (Attr.Form == dwarf::DW_FORM_implicit_const) if (Attr.Form == dwarf::DW_FORM_implicit_const)
@ -140,7 +140,7 @@ Error DWARFYAML::emitDebugAbbrev(raw_ostream &OS, const DWARFYAML::Data &DI) {
Error DWARFYAML::emitDebugAranges(raw_ostream &OS, const DWARFYAML::Data &DI) { Error DWARFYAML::emitDebugAranges(raw_ostream &OS, const DWARFYAML::Data &DI) {
assert(DI.DebugAranges && "unexpected emitDebugAranges() call"); assert(DI.DebugAranges && "unexpected emitDebugAranges() call");
for (auto Range : *DI.DebugAranges) { for (const auto &Range : *DI.DebugAranges) {
uint8_t AddrSize; uint8_t AddrSize;
if (Range.AddrSize) if (Range.AddrSize)
AddrSize = *Range.AddrSize; AddrSize = *Range.AddrSize;
@ -172,7 +172,7 @@ Error DWARFYAML::emitDebugAranges(raw_ostream &OS, const DWARFYAML::Data &DI) {
writeInteger((uint8_t)Range.SegSize, OS, DI.IsLittleEndian); writeInteger((uint8_t)Range.SegSize, OS, DI.IsLittleEndian);
ZeroFillBytes(OS, PaddedHeaderLength - HeaderLength); ZeroFillBytes(OS, PaddedHeaderLength - HeaderLength);
for (auto Descriptor : Range.Descriptors) { for (const auto &Descriptor : Range.Descriptors) {
if (Error Err = writeVariableSizedInteger(Descriptor.Address, AddrSize, if (Error Err = writeVariableSizedInteger(Descriptor.Address, AddrSize,
OS, DI.IsLittleEndian)) OS, DI.IsLittleEndian))
return createStringError(errc::not_supported, return createStringError(errc::not_supported,
@ -190,7 +190,7 @@ Error DWARFYAML::emitDebugAranges(raw_ostream &OS, const DWARFYAML::Data &DI) {
Error DWARFYAML::emitDebugRanges(raw_ostream &OS, const DWARFYAML::Data &DI) { Error DWARFYAML::emitDebugRanges(raw_ostream &OS, const DWARFYAML::Data &DI) {
const size_t RangesOffset = OS.tell(); const size_t RangesOffset = OS.tell();
uint64_t EntryIndex = 0; uint64_t EntryIndex = 0;
for (auto DebugRanges : *DI.DebugRanges) { for (const auto &DebugRanges : *DI.DebugRanges) {
const size_t CurrOffset = OS.tell() - RangesOffset; const size_t CurrOffset = OS.tell() - RangesOffset;
if (DebugRanges.Offset && (uint64_t)*DebugRanges.Offset < CurrOffset) if (DebugRanges.Offset && (uint64_t)*DebugRanges.Offset < CurrOffset)
return createStringError(errc::invalid_argument, return createStringError(errc::invalid_argument,
@ -207,7 +207,7 @@ Error DWARFYAML::emitDebugRanges(raw_ostream &OS, const DWARFYAML::Data &DI) {
AddrSize = *DebugRanges.AddrSize; AddrSize = *DebugRanges.AddrSize;
else else
AddrSize = DI.Is64BitAddrSize ? 8 : 4; AddrSize = DI.Is64BitAddrSize ? 8 : 4;
for (auto Entry : DebugRanges.Entries) { for (const auto &Entry : DebugRanges.Entries) {
if (Error Err = writeVariableSizedInteger(Entry.LowOffset, AddrSize, OS, if (Error Err = writeVariableSizedInteger(Entry.LowOffset, AddrSize, OS,
DI.IsLittleEndian)) DI.IsLittleEndian))
return createStringError( return createStringError(
@ -230,14 +230,13 @@ static Error emitPubSection(raw_ostream &OS, const DWARFYAML::PubSection &Sect,
writeInteger((uint16_t)Sect.Version, OS, IsLittleEndian); writeInteger((uint16_t)Sect.Version, OS, IsLittleEndian);
writeInteger((uint32_t)Sect.UnitOffset, OS, IsLittleEndian); writeInteger((uint32_t)Sect.UnitOffset, OS, IsLittleEndian);
writeInteger((uint32_t)Sect.UnitSize, OS, IsLittleEndian); writeInteger((uint32_t)Sect.UnitSize, OS, IsLittleEndian);
for (auto Entry : Sect.Entries) { for (const auto &Entry : Sect.Entries) {
writeInteger((uint32_t)Entry.DieOffset, OS, IsLittleEndian); writeInteger((uint32_t)Entry.DieOffset, OS, IsLittleEndian);
if (IsGNUPubSec) if (IsGNUPubSec)
writeInteger((uint8_t)Entry.Descriptor, OS, IsLittleEndian); writeInteger((uint8_t)Entry.Descriptor, OS, IsLittleEndian);
OS.write(Entry.Name.data(), Entry.Name.size()); OS.write(Entry.Name.data(), Entry.Name.size());
OS.write('\0'); OS.write('\0');
} }
return Error::success(); return Error::success();
} }