[LifetimeSafety] Avoid suggesting lifetimebound on primary templates
Open
clang:temporal-safety
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
After #197753, we suggest adding `lifetimebound` to a primary template when the annotation appears on an explicit specialization.
This can be misleading because adding the attribute to the primary template affects all instantiations/specializations, even if only one specialization needs the annotation.
We should either avoid making this suggestion in these cases, or add a more specific diagnostic/suggestion for explicit specializations.
```cpp
template
MyObj &spec_func(T &obj); // suggests adding lifetimbound attribute here!
template <>
MyObj &spec_func(MyObj &obj [[clang::lifetimebound]]);
template <>
MyObj &spec_func(MyObj &obj) { return obj; }
```
Contributor guide
Assessment
This issue has not been assessed yet.