[llvm] r194401 - Unify the adding of enumerators with the construction of the enumeration.
Eric Christopher
echristo at gmail.com
Mon Nov 11 10:52:40 PST 2013
Author: echristo
Date: Mon Nov 11 12:52:39 2013
New Revision: 194401
URL: http://llvm.org/viewvc/llvm-project?rev=194401&view=rev
Log:
Unify the adding of enumerators with the construction of the enumeration.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=194401&r1=194400&r2=194401&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Mon Nov 11 12:52:39 2013
@@ -1137,21 +1137,9 @@ void CompileUnit::constructTypeDIE(DIE &
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(
}
}
-/// 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
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=194401&r1=194400&r2=194401&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Mon Nov 11 12:52:39 2013
@@ -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);
More information about the llvm-commits
mailing list