forked from OSchip/llvm-project
While calculating original type size for a derived type, handle type variants encoded as DIDerivedType appropriately.
This improves bitfield support. llvm-svn: 86073
This commit is contained in:
parent
a5beced60e
commit
f05d57283e
|
@ -401,12 +401,18 @@ bool DIVariable::Verify() const {
|
||||||
/// getOriginalTypeSize - If this type is derived from a base type then
|
/// getOriginalTypeSize - If this type is derived from a base type then
|
||||||
/// return base type size.
|
/// return base type size.
|
||||||
uint64_t DIDerivedType::getOriginalTypeSize() const {
|
uint64_t DIDerivedType::getOriginalTypeSize() const {
|
||||||
DIType BT = getTypeDerivedFrom();
|
unsigned Tag = getTag();
|
||||||
if (!BT.isNull() && BT.isDerivedType())
|
if (Tag == dwarf::DW_TAG_member || Tag == dwarf::DW_TAG_typedef ||
|
||||||
return DIDerivedType(BT.getNode()).getOriginalTypeSize();
|
Tag == dwarf::DW_TAG_const_type || Tag == dwarf::DW_TAG_volatile_type ||
|
||||||
if (BT.isNull())
|
Tag == dwarf::DW_TAG_restrict_type) {
|
||||||
return getSizeInBits();
|
DIType BaseType = getTypeDerivedFrom();
|
||||||
return BT.getSizeInBits();
|
if (BaseType.isDerivedType())
|
||||||
|
return DIDerivedType(BaseType.getNode()).getOriginalTypeSize();
|
||||||
|
else
|
||||||
|
return BaseType.getSizeInBits();
|
||||||
|
}
|
||||||
|
|
||||||
|
return getSizeInBits();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// describes - Return true if this subprogram provides debugging
|
/// describes - Return true if this subprogram provides debugging
|
||||||
|
|
|
@ -1141,9 +1141,7 @@ DIE *DwarfDebug::CreateMemberDIE(CompileUnit *DW_Unit, const DIDerivedType &DT){
|
||||||
AddUInt(MemLocationDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
|
AddUInt(MemLocationDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
|
||||||
|
|
||||||
uint64_t Size = DT.getSizeInBits();
|
uint64_t Size = DT.getSizeInBits();
|
||||||
uint64_t FieldSize = Size;
|
uint64_t FieldSize = DT.getOriginalTypeSize();
|
||||||
if (DT.getTypeDerivedFrom().getTag() != dwarf::DW_TAG_array_type)
|
|
||||||
FieldSize = DT.getOriginalTypeSize();
|
|
||||||
|
|
||||||
if (Size != FieldSize) {
|
if (Size != FieldSize) {
|
||||||
// Handle bitfield.
|
// Handle bitfield.
|
||||||
|
|
Loading…
Reference in New Issue