mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-26 07:24:25 +00:00
Use std::unique_ptr for DIE children
Got bored, removed some manual memory management. Pushed references (rather than pointers) through a few APIs rather than replacing *x with x.get(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206222 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1798,20 +1798,20 @@ void DwarfDebug::recordSourceLine(unsigned Line, unsigned Col, const MDNode *S,
|
||||
|
||||
// Compute the size and offset of a DIE. The offset is relative to start of the
|
||||
// CU. It returns the offset after laying out the DIE.
|
||||
unsigned DwarfFile::computeSizeAndOffset(DIE *Die, unsigned Offset) {
|
||||
unsigned DwarfFile::computeSizeAndOffset(DIE &Die, unsigned Offset) {
|
||||
// Record the abbreviation.
|
||||
assignAbbrevNumber(Die->getAbbrev());
|
||||
assignAbbrevNumber(Die.getAbbrev());
|
||||
|
||||
// Get the abbreviation for this DIE.
|
||||
const DIEAbbrev &Abbrev = Die->getAbbrev();
|
||||
const DIEAbbrev &Abbrev = Die.getAbbrev();
|
||||
|
||||
// Set DIE offset
|
||||
Die->setOffset(Offset);
|
||||
Die.setOffset(Offset);
|
||||
|
||||
// Start the size with the size of abbreviation code.
|
||||
Offset += getULEB128Size(Die->getAbbrevNumber());
|
||||
Offset += getULEB128Size(Die.getAbbrevNumber());
|
||||
|
||||
const SmallVectorImpl<DIEValue *> &Values = Die->getValues();
|
||||
const SmallVectorImpl<DIEValue *> &Values = Die.getValues();
|
||||
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
||||
|
||||
// Size the DIE attribute values.
|
||||
@ -1820,20 +1820,20 @@ unsigned DwarfFile::computeSizeAndOffset(DIE *Die, unsigned Offset) {
|
||||
Offset += Values[i]->SizeOf(Asm, AbbrevData[i].getForm());
|
||||
|
||||
// Get the children.
|
||||
const std::vector<DIE *> &Children = Die->getChildren();
|
||||
const auto &Children = Die.getChildren();
|
||||
|
||||
// Size the DIE children if any.
|
||||
if (!Children.empty()) {
|
||||
assert(Abbrev.hasChildren() && "Children flag not set");
|
||||
|
||||
for (DIE *Child : Children)
|
||||
Offset = computeSizeAndOffset(Child, Offset);
|
||||
for (auto &Child : Children)
|
||||
Offset = computeSizeAndOffset(*Child, Offset);
|
||||
|
||||
// End of children marker.
|
||||
Offset += sizeof(int8_t);
|
||||
}
|
||||
|
||||
Die->setSize(Offset - Die->getOffset());
|
||||
Die.setSize(Offset - Die.getOffset());
|
||||
return Offset;
|
||||
}
|
||||
|
||||
@ -1853,7 +1853,7 @@ void DwarfFile::computeSizeAndOffsets() {
|
||||
|
||||
// EndOffset here is CU-relative, after laying out
|
||||
// all of the CU DIE.
|
||||
unsigned EndOffset = computeSizeAndOffset(TheU->getUnitDie(), Offset);
|
||||
unsigned EndOffset = computeSizeAndOffset(*TheU->getUnitDie(), Offset);
|
||||
SecOffset += EndOffset;
|
||||
}
|
||||
}
|
||||
@ -1905,19 +1905,19 @@ void DwarfDebug::emitSectionLabels() {
|
||||
}
|
||||
|
||||
// Recursively emits a debug information entry.
|
||||
void DwarfDebug::emitDIE(DIE *Die) {
|
||||
void DwarfDebug::emitDIE(DIE &Die) {
|
||||
// Get the abbreviation for this DIE.
|
||||
const DIEAbbrev &Abbrev = Die->getAbbrev();
|
||||
const DIEAbbrev &Abbrev = Die.getAbbrev();
|
||||
|
||||
// Emit the code (index) for the abbreviation.
|
||||
if (Asm->isVerbose())
|
||||
Asm->OutStreamer.AddComment("Abbrev [" + Twine(Abbrev.getNumber()) +
|
||||
"] 0x" + Twine::utohexstr(Die->getOffset()) +
|
||||
":0x" + Twine::utohexstr(Die->getSize()) + " " +
|
||||
"] 0x" + Twine::utohexstr(Die.getOffset()) +
|
||||
":0x" + Twine::utohexstr(Die.getSize()) + " " +
|
||||
dwarf::TagString(Abbrev.getTag()));
|
||||
Asm->EmitULEB128(Abbrev.getNumber());
|
||||
|
||||
const SmallVectorImpl<DIEValue *> &Values = Die->getValues();
|
||||
const SmallVectorImpl<DIEValue *> &Values = Die.getValues();
|
||||
const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
|
||||
|
||||
// Emit the DIE attribute values.
|
||||
@ -1939,10 +1939,8 @@ void DwarfDebug::emitDIE(DIE *Die) {
|
||||
|
||||
// Emit the DIE children if any.
|
||||
if (Abbrev.hasChildren()) {
|
||||
const std::vector<DIE *> &Children = Die->getChildren();
|
||||
|
||||
for (DIE *Child : Children)
|
||||
emitDIE(Child);
|
||||
for (auto &Child : Die.getChildren())
|
||||
emitDIE(*Child);
|
||||
|
||||
Asm->OutStreamer.AddComment("End Of Children Mark");
|
||||
Asm->EmitInt8(0);
|
||||
@ -1966,7 +1964,7 @@ void DwarfFile::emitUnits(DwarfDebug *DD, const MCSymbol *ASectionSym) {
|
||||
|
||||
TheU->emitHeader(ASectionSym);
|
||||
|
||||
DD->emitDIE(Die);
|
||||
DD->emitDIE(*Die);
|
||||
Asm->OutStreamer.EmitLabel(TheU->getLabelEnd());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user