[llvm] r273010 - [CodeView] Refactor enumerator emission
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 17 09:13:21 PDT 2016
Author: majnemer
Date: Fri Jun 17 11:13:21 2016
New Revision: 273010
URL: http://llvm.org/viewvc/llvm-project?rev=273010&view=rev
Log:
[CodeView] Refactor enumerator emission
This addresses Amjad's review comments on D21442.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
llvm/trunk/test/DebugInfo/COFF/enum.ll
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=273010&r1=273009&r2=273010&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Fri Jun 17 11:13:21 2016
@@ -1095,14 +1095,26 @@ static ClassOptions getRecordUniqueNameO
TypeIndex CodeViewDebug::lowerTypeEnum(const DICompositeType *Ty) {
ClassOptions CO = ClassOptions::None | getRecordUniqueNameOption(Ty);
TypeIndex FTI;
- unsigned FieldCount = 0;
+ unsigned EnumeratorCount = 0;
- if (Ty->isForwardDecl())
+ if (Ty->isForwardDecl()) {
CO |= ClassOptions::ForwardReference;
- else
- std::tie(FTI, FieldCount) = lowerRecordFieldList(Ty);
+ } else {
+ FieldListRecordBuilder Fields;
+ for (const DINode *Element : Ty->getElements()) {
+ // We assume that the frontend provides all members in source declaration
+ // order, which is what MSVC does.
+ if (auto *Enumerator = dyn_cast_or_null<DIEnumerator>(Element)) {
+ Fields.writeEnumerator(EnumeratorRecord(
+ MemberAccess::Public, APSInt::getUnsigned(Enumerator->getValue()),
+ Enumerator->getName()));
+ EnumeratorCount++;
+ }
+ }
+ FTI = TypeTable.writeFieldList(Fields);
+ }
- return TypeTable.writeEnum(EnumRecord(FieldCount, CO, FTI, Ty->getName(),
+ return TypeTable.writeEnum(EnumRecord(EnumeratorCount, CO, FTI, Ty->getName(),
Ty->getIdentifier(),
getTypeIndex(Ty->getBaseType())));
}
@@ -1198,10 +1210,6 @@ CodeViewDebug::lowerRecordFieldList(cons
}
// FIXME: Get clang to emit nested types here and do something with
// them.
- } else if (auto *Enumerator = dyn_cast<DIEnumerator>(Element)) {
- Fields.writeEnumerator(EnumeratorRecord(
- MemberAccess::Public, APSInt::getUnsigned(Enumerator->getValue()),
- Enumerator->getName()));
}
// Skip other unrecognized kinds of elements.
}
Modified: llvm/trunk/test/DebugInfo/COFF/enum.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/enum.ll?rev=273010&r1=273009&r2=273010&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/enum.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/enum.ll Fri Jun 17 11:13:21 2016
@@ -15,7 +15,7 @@
; CHECK-NEXT: }
; CHECK-NEXT: Enum (0x1001) {
; CHECK-NEXT: TypeLeafKind: LF_ENUM (0x1507)
-; CHECK-NEXT: NumEnumerators: 0
+; CHECK-NEXT: NumEnumerators: 1
; CHECK-NEXT: Properties [ (0x0)
; CHECK-NEXT: ]
; CHECK-NEXT: UnderlyingType: int (0x74)
More information about the llvm-commits
mailing list