[all-commits] [llvm/llvm-project] 6a2a99: [Clang] Track temporary cleanups in rebuilt defaul...

Yuxuan Chen via All-commits all-commits at lists.llvm.org
Fri May 29 12:44:16 PDT 2026


  Branch: refs/heads/users/yuxuanchen1997/fix-cwg1815-lambda-capture-cleanup
  Home:   https://github.com/llvm/llvm-project
  Commit: 6a2a99dd482af118f2c0e33fb60ae28d79cb8dda
      https://github.com/llvm/llvm-project/commit/6a2a99dd482af118f2c0e33fb60ae28d79cb8dda
  Author: Yuxuan Chen <ych at meta.com>
  Date:   2026-05-29 (Fri, 29 May 2026)

  Changed paths:
    M clang/lib/Sema/SemaExpr.cpp
    A clang/test/CodeGenCXX/gh196469-default-member-init-lambda-cleanup.cpp

  Log Message:
  -----------
  [Clang] Track temporary cleanups in rebuilt default member initializers

Fixes https://github.com/llvm/llvm-project/issues/196469

When Clang rebuilds a default member initializer for CWG1815 lifetime
extension, TreeTransform's initializer path strips CXXBindTemporaryExpr
cleanup information. That loses destructor cleanup for ordinary
temporaries inside the initializer; for a DMI-local lambda with an
init-capture, the closure temporary is not destroyed at the end of the
full-expression.

In EnsureImmediateInvocationInDefaultArgs, after the base
TransformInitializer runs, re-bind the result with MaybeBindToTemporary
to restore the cleanup edge. Skip re-binding when the original
expression is a lifetime-extended MaterializeTemporaryExpr (CWG1815) or
when the rebuild already re-bound on its own (e.g. via BuildCallExpr).
Track whether any rebuilt temporary still needs end-of-full-expression
destruction; after DiscardCleanupsInEvaluationContext discards the
cleanups collected for lifetime extension, re-arm
Cleanup.setExprNeedsCleanups so ActOnFinishFullExpr wraps the result in
ExprWithCleanups when warranted.

Add a CodeGenCXX regression test for a lambda init-capture in a default
member initializer.

Assisted By: OpenAI Codex



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list