diff options
author | Aaron Smith <aaron.smith@microsoft.com> | 2018-03-06 18:20:22 +0000 |
---|---|---|
committer | Aaron Smith <aaron.smith@microsoft.com> | 2018-03-06 18:20:22 +0000 |
commit | 122d9e79ae0fcc41be6066c3928dd59e5cc59ca6 (patch) | |
tree | df65145069f986316bff30cf0ec601cc96de3705 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | |
parent | ed2211d50fec431b40d77f4573434fecf3923660 (diff) | |
download | llvm-122d9e79ae0fcc41be6066c3928dd59e5cc59ca6.zip llvm-122d9e79ae0fcc41be6066c3928dd59e5cc59ca6.tar.gz llvm-122d9e79ae0fcc41be6066c3928dd59e5cc59ca6.tar.bz2 |
[CodeView] Emit UdtSourceLine information for enums
Summary:
- Emit UdtSourceLine information for enums to match MSVC
- Add a method to add UDTSrcLine and call it for all Class/Struct/Union/Enum
- Update test cases to verify the changes
Reviewers: zturner, llvm-commits, rnk
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D44116
llvm-svn: 326824
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 058a0e8..3fac722 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -1769,6 +1769,26 @@ static ClassOptions getCommonClassOptions(const DICompositeType *Ty) { return CO; } +void CodeViewDebug::addUDTSrcLine(const DIType *Ty, TypeIndex TI) { + switch (Ty->getTag()) { + case dwarf::DW_TAG_class_type: + case dwarf::DW_TAG_structure_type: + case dwarf::DW_TAG_union_type: + case dwarf::DW_TAG_enumeration_type: + break; + default: + return; + } + + if (const auto *File = Ty->getFile()) { + StringIdRecord SIDR(TypeIndex(0x0), getFullFilepath(File)); + TypeIndex SIDI = TypeTable.writeLeafType(SIDR); + + UdtSourceLineRecord USLR(TI, SIDI, Ty->getLine()); + TypeTable.writeLeafType(USLR); + } +} + TypeIndex CodeViewDebug::lowerTypeEnum(const DICompositeType *Ty) { ClassOptions CO = getCommonClassOptions(Ty); TypeIndex FTI; @@ -1797,7 +1817,11 @@ TypeIndex CodeViewDebug::lowerTypeEnum(const DICompositeType *Ty) { EnumRecord ER(EnumeratorCount, CO, FTI, FullName, Ty->getIdentifier(), getTypeIndex(Ty->getBaseType())); - return TypeTable.writeLeafType(ER); + TypeIndex EnumTI = TypeTable.writeLeafType(ER); + + addUDTSrcLine(Ty, EnumTI); + + return EnumTI; } //===----------------------------------------------------------------------===// @@ -1949,13 +1973,7 @@ TypeIndex CodeViewDebug::lowerCompleteTypeClass(const DICompositeType *Ty) { SizeInBytes, FullName, Ty->getIdentifier()); TypeIndex ClassTI = TypeTable.writeLeafType(CR); - if (const auto *File = Ty->getFile()) { - StringIdRecord SIDR(TypeIndex(0x0), getFullFilepath(File)); - TypeIndex SIDI = TypeTable.writeLeafType(SIDR); - - UdtSourceLineRecord USLR(ClassTI, SIDI, Ty->getLine()); - TypeTable.writeLeafType(USLR); - } + addUDTSrcLine(Ty, ClassTI); addToUDTs(Ty); @@ -1991,11 +2009,7 @@ TypeIndex CodeViewDebug::lowerCompleteTypeUnion(const DICompositeType *Ty) { Ty->getIdentifier()); TypeIndex UnionTI = TypeTable.writeLeafType(UR); - StringIdRecord SIR(TypeIndex(0x0), getFullFilepath(Ty->getFile())); - TypeIndex SIRI = TypeTable.writeLeafType(SIR); - - UdtSourceLineRecord USLR(UnionTI, SIRI, Ty->getLine()); - TypeTable.writeLeafType(USLR); + addUDTSrcLine(Ty, UnionTI); addToUDTs(Ty); |