DebugInfo: Refactor index type DIE initialization by rolling it into the accessor

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221080 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie 2014-11-02 03:09:13 +00:00
parent 91ff6ebef0
commit 7f0ed39af9
2 changed files with 13 additions and 10 deletions

View File

@ -1525,6 +1525,18 @@ void DwarfUnit::constructSubrangeDIE(DIE &Buffer, DISubrange SR, DIE *IndexTy) {
addUInt(DW_Subrange, dwarf::DW_AT_count, None, Count);
}
DIE *DwarfUnit::getIndexTyDie() {
if (IndexTyDie)
return IndexTyDie;
// Construct an integer type to use for indexes.
IndexTyDie = &createAndAddDIE(dwarf::DW_TAG_base_type, UnitDie);
addString(*IndexTyDie, dwarf::DW_AT_name, "sizetype");
addUInt(*IndexTyDie, dwarf::DW_AT_byte_size, None, sizeof(int64_t));
addUInt(*IndexTyDie, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
dwarf::DW_ATE_unsigned);
return IndexTyDie;
}
/// constructArrayTypeDIE - Construct array type DIE from DICompositeType.
void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, DICompositeType CTy) {
if (CTy.isVector())
@ -1537,15 +1549,6 @@ void DwarfUnit::constructArrayTypeDIE(DIE &Buffer, DICompositeType CTy) {
// FIXME: This type should be passed down from the front end
// as different languages may have different sizes for indexes.
DIE *IdxTy = getIndexTyDie();
if (!IdxTy) {
// Construct an integer type to use for indexes.
IdxTy = &createAndAddDIE(dwarf::DW_TAG_base_type, UnitDie);
addString(*IdxTy, dwarf::DW_AT_name, "sizetype");
addUInt(*IdxTy, dwarf::DW_AT_byte_size, None, sizeof(int64_t));
addUInt(*IdxTy, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1,
dwarf::DW_ATE_unsigned);
setIndexTyDie(IdxTy);
}
// Add subranges to array type.
DIArray Elements = CTy.getElements();

View File

@ -430,7 +430,7 @@ private:
}
// getIndexTyDie - Get an anonymous type for index type.
DIE *getIndexTyDie() { return IndexTyDie; }
DIE *getIndexTyDie();
// setIndexTyDie - Set D as anonymous type for index which can be reused
// later.