diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 19ea18c4cbc6..2fdd7a3e568b 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2660,8 +2660,9 @@ void CGDebugInfo::EmitGlobalVariable(const ValueDecl *VD, StringRef Name = VD->getName(); llvm::DIType Ty = getOrCreateType(VD->getType(), Unit); if (const EnumConstantDecl *ECD = dyn_cast(VD)) { - if (const EnumDecl *ED = dyn_cast(ECD->getDeclContext())) - Ty = CreateEnumType(ED); + const EnumDecl *ED = cast(ECD->getDeclContext()); + assert(isa(ED->getTypeForDecl()) && "Enum without EnumType?"); + Ty = getOrCreateType(QualType(ED->getTypeForDecl(), 0), Unit); } // Do not use DIGlobalVariable for enums. if (Ty.getTag() == llvm::dwarf::DW_TAG_enumeration_type)