r260002 - Add a missing call to MDNode::deleteTemporary().

Duncan P. N. Exon Smith via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 6 12:38:17 PST 2016


> On 2016-Feb-06, at 10:39, Adrian Prantl via cfe-commits <cfe-commits at lists.llvm.org> wrote:
> 
> Author: adrian
> Date: Sat Feb  6 12:39:34 2016
> New Revision: 260002
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=260002&view=rev
> Log:
> Add a missing call to MDNode::deleteTemporary().
> Follow-up to r259975. Kudos to the ASAN bots!
> 
> <rdar://problem/24493203>
> 
> Modified:
>    cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> 
> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=260002&r1=260001&r2=260002&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Sat Feb  6 12:39:34 2016
> @@ -2056,19 +2056,20 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp
>     // 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 *EDContext = DBuilder.createReplaceableCompositeType(
> +    llvm::DIScope *TmpContext = DBuilder.createReplaceableCompositeType(

If you change this to:
```
llvm::TempDIScope TmpContext(DBuilder.create...())
```
then the lifetime of `TmpContext` will get managed for you (it's a
`std::unique_ptr<DIScope*, deleteTemporary()>`).

Really, `DIBuilder` should return this instead of a `DIScope*`, so
that it's clear what the lifetime is.

>       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, EDContext, DefUnit, Line,
> +        llvm::dwarf::DW_TAG_enumeration_type, EDName, TmpContext, 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);
> -    EDContext->replaceAllUsesWith(getDeclContextDescriptor(ED));
> +    TmpContext->replaceAllUsesWith(getDeclContextDescriptor(ED));
> +    llvm::MDNode::deleteTemporary(TmpContext);
> 
>     ReplaceMap.emplace_back(
>         std::piecewise_construct, std::make_tuple(Ty),
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list