]> granicus.if.org Git - clang/commitdiff
Don't circumvent the debug info type cache when emitting info for EnumConstantDecl.
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 20 Jun 2012 18:11:18 +0000 (18:11 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 20 Jun 2012 18:11:18 +0000 (18:11 +0000)
CreateEnumType doesn't participate in caching so the descriptor for the enum
gets recomputed for every reference of an element of an enum, only to get
discarded when it gets turned into an MDNode.

No functionality change except performance.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158832 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp

index 19ea18c4cbc6a28370a6c3a878cce5c4b7dde03f..2fdd7a3e568bb9d8e0a0dae603c22feb7eeb4c79 100644 (file)
@@ -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<EnumConstantDecl>(VD)) {
-    if (const EnumDecl *ED = dyn_cast<EnumDecl>(ECD->getDeclContext()))
-      Ty = CreateEnumType(ED);
+    const EnumDecl *ED = cast<EnumDecl>(ECD->getDeclContext());
+    assert(isa<EnumType>(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)