From 42e3b31d698dfe492c1c33adbbc6b98be9918fd2 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sun, 11 May 2014 17:04:05 +0000 Subject: [PATCH] DwarfUnit: Make explicit a limitation/bug in enumeration constant emission. Filed as PR19712, LLVM fails to detect the right type of an enum constant when a frontend does not provide an underlying type for the enumeration type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208502 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 7e1a9879c67..7797ff4273a 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -748,12 +748,17 @@ void DwarfUnit::addBlockByrefAddress(const DbgVariable &DV, DIE &Die, /// Return true if type encoding is unsigned. static bool isUnsignedDIType(DwarfDebug *DD, DIType Ty) { DIDerivedType DTy(Ty); - if (DTy.isDerivedType()) - return isUnsignedDIType(DD, DD->resolve(DTy.getTypeDerivedFrom())); + if (DTy.isDerivedType()) { + if (DIType Deriv = DD->resolve(DTy.getTypeDerivedFrom())) + return isUnsignedDIType(DD, Deriv); + // FIXME: Enums without a fixed underlying type have unknown signedness + // here, leading to incorrectly emitted constants. + assert(DTy.getTag() == dwarf::DW_TAG_enumeration_type); + return false; + } DIBasicType BTy(Ty); - if (!BTy.isBasicType()) - return false; + assert(BTy.isBasicType()); unsigned Encoding = BTy.getEncoding(); assert(Encoding == dwarf::DW_ATE_unsigned || Encoding == dwarf::DW_ATE_unsigned_char || -- 2.11.0