llvm / llvm/llvm-project

Diagnose [[clang::lifetimebound]] on functions whose return value cannot refer to any object

Open
#188,655 2 comments 0 reactions 1 assignee Claimed by @NeKon69 View on GitHub
clang:temporal-safety
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

`[[clang::lifetimebound]]` on a parameter is meaningful only when the function's return value can refer to another object. When the return type is something like `int` or an enum, the returned value cannot carry a borrow, and the attribute has no effect:

```cpp
int getInt(const std::string &s [[clang::lifetimebound]]);
```

We should emit a diagnostic for this case.

cc @usx95

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.