[all-commits] [llvm/llvm-project] cb0ff1: [clang] Use uniform lifetime bounds under exceptions

Paul Kirth via All-commits all-commits at lists.llvm.org
Wed Feb 11 17:53:08 PST 2026


  Branch: refs/heads/users/ilovepi/clang-lifetime-exceptions
  Home:   https://github.com/llvm/llvm-project
  Commit: cb0ff14a8c50570ac497689cdee123d40a1e9937
      https://github.com/llvm/llvm-project/commit/cb0ff14a8c50570ac497689cdee123d40a1e9937
  Author: Paul Kirth <paulkirth at google.com>
  Date:   2026-02-11 (Wed, 11 Feb 2026)

  Changed paths:
    M clang/lib/CodeGen/CGCall.cpp
    M clang/lib/Sema/SemaExprCXX.cpp
    M clang/test/CodeGenCXX/aggregate-lifetime-invoke.cpp

  Log Message:
  -----------
  [clang] Use uniform lifetime bounds under exceptions

To do this we have to slightly modify how some expressions are handled
in Sema. Principally, we need to ensure that calls to new for
non-trivial types still have their destructors run. Generally this isn't
an issue, since these just get sunk into the surrounding scope. With
more lifetime annotations being produced for the expressions, we found
that some calls to `new` in an unreachable switch arm would not be
wrapped in ExprWithCleanups. As a result, they remain on the EhStack
when processing the default label, and since the dead arm doesn't
dominate the default label, we can end up with a case where the def-use
chain is broken (e.g. the def doesn't dominate all uses). Technically
this path would be impossible to reach due to the active bit, but it
still failed to satisfy a dominance relationship.

With that in place, we can remove the constraint on only using tighter
lifetimes when exceptions are disabled.


  Commit: efdc085a562ce1a2a8354b4c39e519eebbe479d3
      https://github.com/llvm/llvm-project/commit/efdc085a562ce1a2a8354b4c39e519eebbe479d3
  Author: Paul Kirth <paulkirth at google.com>
  Date:   2026-02-11 (Wed, 11 Feb 2026)

  Changed paths:
    M clang/lib/AST/ExprConstant.cpp
    M clang/lib/Sema/SemaExprCXX.cpp

  Log Message:
  -----------
  Use setExprNeedsCleanups in BuildCXXNew and avoid breaking c++98

This approach is much cleaner, but broke checkICE reporting in c++98.
Stepping through a debugger shows that this happend because the
static_assert test didn not recognize ExprWithCleanups as transparent to
constant evaluation. To addresse this, we update CheckICE to recurse
into the sub-expression, and keep the old behavior.


  Commit: a99d52325aaeea3b42d93ee6e9f260ee86533f7f
      https://github.com/llvm/llvm-project/commit/a99d52325aaeea3b42d93ee6e9f260ee86533f7f
  Author: Paul Kirth <paulkirth at google.com>
  Date:   2026-02-11 (Wed, 11 Feb 2026)

  Changed paths:
    M clang/lib/AST/ExprConstant.cpp

  Log Message:
  -----------
  Use more restrictive condition for adding ExprWithCleanups


Compare: https://github.com/llvm/llvm-project/compare/57e19dd151c5...a99d52325aae

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