Issue 164259
Summary Add implicit lifetimebound annotations to std::make_unique
Labels clang:temporal-safety
Assignees
Reporter usx95
    Consider this definition of `std::make_unique`:

```cpp
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
```

Add implicit annotations to the template instantiations of `make_unqiue` where the constructed type has `lifetimebound` arguments.

```cpp
struct A {
 std::string_view view;
    std::string owner
    A(const std::string& a [[clang::lifetimebound]], const std::string& b) : view(a), owner(b) {}
};
```
`std::make_unique<A>` function template should have its first arg to `a` as `lifetimebound` but not the other other arg to `b`.
This can be done by looking at the corresponding constructor of the type being constructed. [example](https://github.com/google/crubit/blob/29690a31672dbc54108ee70cb65fe22570eb1356/nullability/pointer_nullability_diagnosis.cc#L683)
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to