[clang] [clang-tools-extra] [codegen] Emit missing cleanups when an expression contains a branch (PR #80698)

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 13 06:00:45 PST 2024


================
@@ -627,9 +627,11 @@ CodeGenFunction::getJumpDestForLabel(const LabelDecl *D) {
   if (Dest.isValid()) return Dest;
 
   // Create, but don't insert, the new block.
+  // FIXME: We do not know `BranchInExprDepth` for the destination and currently
+  // emit *all* the BranchInExpr cleanups.
----------------
usx95 wrote:

I think we should remember/copy the entire `BranchInExpr` stack in a branch-fix-up and then emit the cleanups from this stored `BranchInExpr` stack up until the now-known destination depth.
This is because we simply pop the `BranchInExpr` stack on leaving an expression, but in this case, we need to remember which cleanups were popped earlier.

(This would not work if the goto destination is inside a different stmt-expr. In this case, the code is invalid anyways.)

https://github.com/llvm/llvm-project/pull/80698


More information about the cfe-commits mailing list