]> granicus.if.org Git - clang/commitdiff
Use llvm::TempDIScope instead of manually deleting a temporary MDNode.
authorAdrian Prantl <aprantl@apple.com>
Mon, 8 Feb 2016 17:03:28 +0000 (17:03 +0000)
committerAdrian Prantl <aprantl@apple.com>
Mon, 8 Feb 2016 17:03:28 +0000 (17:03 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@260113 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGDebugInfo.cpp

index 3da0765d375aee62c080ba32d9f23911930a79da..52bd805b81ce63e8911c001c62621bac2acb494c 100644 (file)
@@ -2056,20 +2056,19 @@ llvm::DIType *CGDebugInfo::CreateEnumType(const EnumType *Ty) {
     // It is possible for enums to be created as part of their own
     // declcontext. We need to cache a placeholder to avoid the type being
     // created twice before hitting the cache.
-    llvm::DIScope *TmpContext = DBuilder.createReplaceableCompositeType(
-      llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0);
+    llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(
+        llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));
 
     unsigned Line = getLineNumber(ED->getLocation());
     StringRef EDName = ED->getName();
     llvm::DIType *RetTy = DBuilder.createReplaceableCompositeType(
-        llvm::dwarf::DW_TAG_enumeration_type, EDName, TmpContext, DefUnit, Line,
-        0, Size, Align, llvm::DINode::FlagFwdDecl, FullName);
+        llvm::dwarf::DW_TAG_enumeration_type, EDName, TmpContext.get(), DefUnit,
+        Line, 0, Size, Align, llvm::DINode::FlagFwdDecl, FullName);
 
     // Cache the enum type so it is available when building the declcontext
     // and replace the declcontect with the real thing.
     TypeCache[Ty].reset(RetTy);
     TmpContext->replaceAllUsesWith(getDeclContextDescriptor(ED));
-    llvm::MDNode::deleteTemporary(TmpContext);
 
     ReplaceMap.emplace_back(
         std::piecewise_construct, std::make_tuple(Ty),