[all-commits] [llvm/llvm-project] 840788: [clang] Fix overly aggressive lifetime checks for ...

Alan Zhao via All-commits all-commits at lists.llvm.org
Tue May 30 22:11:02 PDT 2023


  Branch: refs/heads/release/16.x
  Home:   https://github.com/llvm/llvm-project
  Commit: 84078877549b6b1b62a1dbe232108d67266de4bf
      https://github.com/llvm/llvm-project/commit/84078877549b6b1b62a1dbe232108d67266de4bf
  Author: Alan Zhao <ayzhao at google.com>
  Date:   2023-05-30 (Tue, 30 May 2023)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Initialization.h
    M clang/lib/Sema/SemaAccess.cpp
    M clang/lib/Sema/SemaInit.cpp
    M clang/test/CodeGen/paren-list-agg-init.cpp
    M clang/test/SemaCXX/paren-list-agg-init.cpp

  Log Message:
  -----------
  [clang] Fix overly aggressive lifetime checks for parenthesized aggregate initialization

Before this patch, initialized class members would have the LifetimeKind
LK_MemInitializer, which does not allow for binding a temporary to a
reference. Binding to a temporary however is allowed in parenthesized
aggregate initialization, even if it leads to a dangling reference. To
fix this, we create a new EntityKind, EK_ParenAggInitMember, which has
LifetimeKind LK_FullExpression.

This patch does *not* attempt to diagnose dangling references as a
result of using this feature.

This patch also refactors TryOrBuildParenListInitialization(...) to
accomodate creating different InitializedEntity objects.

Fixes #61567

[0]: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0960r3.html

Reviewed By: shafik

Differential Revision: https://reviews.llvm.org/D148274




More information about the All-commits mailing list