llvm / llvm/llvm-project

[LifetimeSafety] Infer missing lifetime_capture_by annotations

Open
#213,005 1 comment 0 reactions 0 assignees View on GitHub
clang:temporal-safety
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```c++
struct T { int x; };

struct Holder {
void set(const T& v [[clang::lifetime_capture_by_this]]) { p = &v; }
const T* p = nullptr;
};

void outerSet(Holder& h, const T& v) { h.set(v); }
```

We should suggest `[[clang::lifetime_capture_by(h)]]` on `v`.

Contributor guide

Open the contributing guide

Research direction

Start by compiling the C++ reproducer in the issue and inspect how lifetime_capture_by_this and lifetime_capture_by annotations are handled. Trace the lifetime-safety analysis entry point that processes outerSet and determine where the missing capture annotation should be suggested. Done means the example produces a suggestion for lifetime_capture_by(h) on v, with regression coverage for the shown case.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.