[clang] Fix 2 bugs with parenthesized aggregate initialization
authorAlan Zhao <ayzhao@google.com>
Mon, 20 Mar 2023 21:53:53 +0000 (14:53 -0700)
committerAlan Zhao <ayzhao@google.com>
Thu, 30 Mar 2023 22:06:37 +0000 (15:06 -0700)
commit7df3c71b508b65284483225685f1ba19777f2bbb
tree2202e30cc3b0264deec615a4c247778bb27c7250
parent3b11e4097f3ab3fbc44f91e6599d890add0c387e
[clang] Fix 2 bugs with parenthesized aggregate initialization

* Fix an issue where temporaries initialized via parenthesized aggregate
  initialization don't get destroyed.
* Fix an issue where aggregate initialization omits calls to class
  members' move constructors after a TreeTransform. This occurs because
  the CXXConstructExpr wrapping the call to the move constructor gets
  unboxed during a TreeTransform of the wrapping FunctionalCastExpr (as with a
  InitListExpr), but unlike InitListExpr, we dont reperform the
  InitializationSequence for the list's expressions to regenerate the
  CXXConstructExpr. This patch fixes this bug by treating
  CXXParenListInitExpr identically to InitListExpr in this regard.

Fixes #61145

Reviewed By: rsmith

Differential Revision: https://reviews.llvm.org/D146465
clang/lib/AST/Expr.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/TreeTransform.h
clang/test/CodeGen/paren-list-agg-init.cpp
clang/test/SemaCXX/paren-list-agg-init.cpp