/// ComputeSize - calculate the size of the location expression.
///
unsigned DIELoc::ComputeSize(AsmPrinter *AP) const {
- if (Size)
- return Size;
-
- unsigned Sz = 0;
- const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
- for (unsigned i = 0, N = Values.size(); i < N; ++i)
- Sz += Values[i]->SizeOf(AP, AbbrevData[i].getForm());
+ if (!Size) {
+ const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
+ for (unsigned i = 0, N = Values.size(); i < N; ++i)
+ Size += Values[i]->SizeOf(AP, AbbrevData[i].getForm());
+ }
- return Sz;
+ return Size;
}
/// EmitValue - Emit location data.
/// ComputeSize - calculate the size of the block.
///
unsigned DIEBlock::ComputeSize(AsmPrinter *AP) const {
- if (Size)
- return Size;
-
- unsigned Sz = 0;
- const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
- for (unsigned i = 0, N = Values.size(); i < N; ++i)
- Sz += Values[i]->SizeOf(AP, AbbrevData[i].getForm());
+ if (!Size) {
+ const SmallVectorImpl<DIEAbbrevData> &AbbrevData = Abbrev.getData();
+ for (unsigned i = 0, N = Values.size(); i < N; ++i)
+ Size += Values[i]->SizeOf(AP, AbbrevData[i].getForm());
+ }
- return Sz;
+ return Size;
}
/// EmitValue - Emit block data.
/// DIELoc - Represents an expression location.
//
class DIELoc : public DIEValue, public DIE {
- unsigned Size; // Size in bytes excluding size header.
+ mutable unsigned Size; // Size in bytes excluding size header.
public:
DIELoc() : DIEValue(isLoc), DIE(0), Size(0) {}
///
unsigned ComputeSize(AsmPrinter *AP) const;
- /// setSize - Set the size of the location entry.
- ///
- void setSize(unsigned Sz) { Size = Sz; }
-
/// BestForm - Choose the best form for data.
///
dwarf::Form BestForm(unsigned DwarfVersion) const {
/// DIEBlock - Represents a block of values.
//
class DIEBlock : public DIEValue, public DIE {
- unsigned Size; // Size in bytes excluding size header.
+ mutable unsigned Size; // Size in bytes excluding size header.
public:
DIEBlock() : DIEValue(isBlock), DIE(0), Size(0) {}
///
unsigned ComputeSize(AsmPrinter *AP) const;
- /// setSize - Set the size of the block.
- ///
- void setSize(unsigned Sz) { Size = Sz; }
-
/// BestForm - Choose the best form for data.
///
dwarf::Form BestForm() const {
/// addBlock - Add block data.
///
void DwarfUnit::addBlock(DIE *Die, dwarf::Attribute Attribute, DIELoc *Loc) {
- Loc->setSize(Loc->ComputeSize(Asm));
+ Loc->ComputeSize(Asm);
DIELocs.push_back(Loc); // Memoize so we can call the destructor later on.
Die->addValue(Attribute, Loc->BestForm(DD->getDwarfVersion()), Loc);
}
void DwarfUnit::addBlock(DIE *Die, dwarf::Attribute Attribute,
DIEBlock *Block) {
- Block->setSize(Block->ComputeSize(Asm));
+ Block->ComputeSize(Asm);
DIEBlocks.push_back(Block); // Memoize so we can call the destructor later on.
Die->addValue(Attribute, Block->BestForm(), Block);
}