[all-commits] [llvm/llvm-project] 8c4331: [clang] Introduce [[clang::lifetime_capture_by(X)]...

Utkarsh Saxena via All-commits all-commits at lists.llvm.org
Mon Nov 11 08:18:51 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8c4331c1abeb33eabf3cdbefa7f2b6e0540e7f4f
      https://github.com/llvm/llvm-project/commit/8c4331c1abeb33eabf3cdbefa7f2b6e0540e7f4f
  Author: Utkarsh Saxena <usx at google.com>
  Date:   2024-11-11 (Mon, 11 Nov 2024)

  Changed paths:
    M clang/docs/ReleaseNotes.rst
    M clang/include/clang/Basic/Attr.td
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/AST/TypePrinter.cpp
    M clang/lib/Sema/SemaDecl.cpp
    M clang/lib/Sema/SemaDeclAttr.cpp
    M clang/lib/Sema/SemaType.cpp
    A clang/test/AST/attr-lifetime-capture-by.cpp
    A clang/test/SemaCXX/attr-lifetime-capture-by.cpp

  Log Message:
  -----------
  [clang] Introduce [[clang::lifetime_capture_by(X)]] (#111499)

This implements the RFC
https://discourse.llvm.org/t/rfc-introduce-clang-lifetime-capture-by-x/81371

In this PR, we introduce `[[clang::lifetime_capture_by(X)]]` attribute
as discussed in the RFC.

As an implementation detail of this attribute, we store and use param
indices instead of raw param expressions. The parameter indices are
computed lazily at the end of function declaration since the function
decl (and therefore the subsequent parameters) are not visible yet while
parsing a parameter annotation.

In subsequent PR, we will infer this attribute for STL containers and
perform lifetime analysis to detect dangling cases.



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