Could you avoid creating the FinalBB unless it's needed rather than
creating it and then adding it so it can be removed? (or, if the creation
can't be avoided, maybe it's OK to 'delete FinalBB' here, rather than
adding it for it to be removed later?)

(also bracing seems off - could you run your changes through clang-format?
I'd expect '} else {' on the same line.

On Tue, May 23, 2017 at 6:54 PM Gor Nishanov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: gornishanov
> Date: Tue May 23 20:54:37 2017
> New Revision: 303714
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303714&view=rev
> Log:
> [coroutines] Fix leak in CGCoroutine.cpp
>
> FinalBB need to be emitted even when unused to make sure it is deleted
>
> Modified:
>     cfe/trunk/lib/CodeGen/CGCoroutine.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGCoroutine.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCoroutine.cpp?rev=303714&r1=303713&r2=303714&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGCoroutine.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGCoroutine.cpp Tue May 23 20:54:37 2017
> @@ -430,6 +430,10 @@ void CodeGenFunction::EmitCoroutineBody(
>        CurCoro.Data->CurrentAwaitKind = AwaitKind::Final;
>        EmitStmt(S.getFinalSuspendStmt());
>      }
> +    else {
> +      // We don't need FinalBB. Emit it to make sure the block is deleted.
> +      EmitBlock(FinalBB, /*IsFinished=*/true);
> +    }
>    }
>
>    EmitBlock(RetBB);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to