[LifetimeSafety] Infer missing lifetime_capture_by annotations
- 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
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