From d065e23dac4ccf233dee643594c0ec35dba7da03 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Thu, 2 Jun 2016 06:21:37 +0000 Subject: [codeview] Return type indices for typedefs Use the type index of the underlying type unless we have a typedef from long to HRESULT; HRESULT typedefs are translated to T_HRESULT. llvm-svn: 271494 --- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp') diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index dec6770537eb..7c167ba0c43c 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -731,6 +731,8 @@ void CodeViewDebug::beginFunction(const MachineFunction *MF) { TypeIndex CodeViewDebug::lowerType(const DIType *Ty) { // Generic dispatch for lowering an unknown type. switch (Ty->getTag()) { + case dwarf::DW_TAG_typedef: + return lowerTypeAlias(cast(Ty)); case dwarf::DW_TAG_base_type: return lowerTypeBasic(cast(Ty)); case dwarf::DW_TAG_pointer_type: @@ -748,6 +750,16 @@ TypeIndex CodeViewDebug::lowerType(const DIType *Ty) { } } +TypeIndex CodeViewDebug::lowerTypeAlias(const DIDerivedType *Ty) { + // TODO: MSVC emits a S_UDT record. + DITypeRef UnderlyingTypeRef = Ty->getBaseType(); + TypeIndex UnderlyingTypeIndex = getTypeIndex(UnderlyingTypeRef); + if (UnderlyingTypeIndex == TypeIndex(SimpleTypeKind::Int32Long) && + Ty->getName() == "HRESULT") + return TypeIndex(SimpleTypeKind::HResult); + return UnderlyingTypeIndex; +} + TypeIndex CodeViewDebug::lowerTypeBasic(const DIBasicType *Ty) { TypeIndex Index; dwarf::TypeKind Kind; -- cgit v1.2.3