[all-commits] [llvm/llvm-project] c22bb6: [clang] Implement lifetime analysis for lifetime_c...

Utkarsh Saxena via All-commits all-commits at lists.llvm.org
Wed Nov 20 06:17:22 PST 2024


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

  Changed paths:
    M clang/include/clang/Basic/AttrDocs.td
    M clang/include/clang/Basic/DiagnosticGroups.td
    M clang/include/clang/Basic/DiagnosticSemaKinds.td
    M clang/include/clang/Sema/Sema.h
    M clang/lib/Sema/CheckExprLifetime.cpp
    M clang/lib/Sema/CheckExprLifetime.h
    M clang/lib/Sema/SemaChecking.cpp
    M clang/lib/Sema/SemaExpr.cpp
    M clang/lib/Sema/SemaInit.cpp
    M clang/lib/Sema/SemaOverload.cpp
    A clang/test/Sema/Inputs/lifetime-analysis.h
    A clang/test/Sema/warn-lifetime-analysis-capture-by.cpp
    M clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
    M clang/test/SemaCXX/attr-lifetimebound.cpp

  Log Message:
  -----------
  [clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)

This PR uses the existing lifetime analysis for the `capture_by`
attribute.

The analysis is behind `-Wdangling-capture` warning and is disabled by
default for now. Once it is found to be stable, it will be default
enabled.

Planned followup:
- add implicit inference of this attribute on STL container methods like
`std::vector::push_back`.
- (consider) warning if capturing `X` cannot capture anything. It should
be a reference, pointer or a view type.
- refactoring temporary visitors and other related handlers.
- start discussing `__global` vs `global` in the annotation in a
separate PR.

---------

Co-authored-by: Boaz Brickner <brickner at google.com>



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