1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

Unify the adding of enumerators with the construction of the enumeration.

llvm-svn: 194401
This commit is contained in:
Eric Christopher 2013-11-11 18:52:39 +00:00
parent bbbbc2a7b7
commit 67515d7632
2 changed files with 25 additions and 23 deletions

View File

@ -1137,21 +1137,9 @@ void CompileUnit::constructTypeDIE(DIE &Buffer, DICompositeType CTy) {
case dwarf::DW_TAG_array_type:
constructArrayTypeDIE(Buffer, CTy);
break;
case dwarf::DW_TAG_enumeration_type: {
DIArray Elements = CTy.getTypeArray();
// Add enumerators to enumeration type.
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
DIDescriptor Enum(Elements.getElement(i));
if (Enum.isEnumerator())
constructEnumTypeDIE(Buffer, DIEnumerator(Enum));
}
DIType DTy = resolve(CTy.getTypeDerivedFrom());
if (DTy) {
addType(&Buffer, DTy);
addFlag(&Buffer, dwarf::DW_AT_enum_class);
}
} break;
case dwarf::DW_TAG_enumeration_type:
constructEnumTypeDIE(Buffer, CTy);
break;
case dwarf::DW_TAG_subroutine_type: {
// Add return type. A void return won't have a type.
DIArray Elements = CTy.getTypeArray();
@ -1720,13 +1708,27 @@ void CompileUnit::constructArrayTypeDIE(DIE &Buffer, DICompositeType CTy) {
}
}
/// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
void CompileUnit::constructEnumTypeDIE(DIE &Buffer, DIEnumerator ETy) {
DIE *Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
StringRef Name = ETy.getName();
addString(Enumerator, dwarf::DW_AT_name, Name);
int64_t Value = ETy.getEnumValue();
addSInt(Enumerator, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, Value);
/// constructEnumTypeDIE - Construct an enum type DIE from DICompositeType.
void CompileUnit::constructEnumTypeDIE(DIE &Buffer, DICompositeType CTy) {
DIArray Elements = CTy.getTypeArray();
// Add enumerators to enumeration type.
for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) {
DIDescriptor Enum(Elements.getElement(i));
DIEnumerator ETy = DIEnumerator(Enum);
if (Enum.isEnumerator()) {
DIE *Enumerator = createAndAddDIE(dwarf::DW_TAG_enumerator, Buffer);
StringRef Name = ETy.getName();
addString(Enumerator, dwarf::DW_AT_name, Name);
int64_t Value = ETy.getEnumValue();
addSInt(Enumerator, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, Value);
}
}
DIType DTy = resolve(CTy.getTypeDerivedFrom());
if (DTy) {
addType(&Buffer, DTy);
addFlag(&Buffer, dwarf::DW_AT_enum_class);
}
}
/// constructContainingTypeDIEs - Construct DIEs for types that contain

View File

@ -351,7 +351,7 @@ private:
void constructArrayTypeDIE(DIE &Buffer, DICompositeType CTy);
/// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator.
void constructEnumTypeDIE(DIE &Buffer, DIEnumerator ETy);
void constructEnumTypeDIE(DIE &Buffer, DICompositeType CTy);
/// constructMemberDIE - Construct member DIE from DIDerivedType.
void constructMemberDIE(DIE &Buffer, DIDerivedType DT);