[LifetimeSafety] Add fix-its for misplaced lifetimebound diagnostics
After #197753, we now warn when lifetimebound is written on the wrong declaration. This diagnostic would ideally have a fix-it that adds the attribute to the declaration that should carry it.
Currently we only warn that the user should add a lifetimebound attribute:
int* get(int &x); // warning: 'lifetimebound' attribute on this definition is not visible to callers before the definition; add it to the declaration instead
int* get(int &x [[clang::lifetimebound]]) {
return &x;
}
It would be more user-friendly if we could also create a suggestion with a lifetimebound attribute:
int* get(int &x); // fix-it: add [[clang::lifetimebound]] here
int* get(int &x [[clang::lifetimebound]]) {
return &x;
}
After applying the fix-it:
int* get(int &x [[clang::lifetimebound]]);
int* get(int &x [[clang::lifetimebound]]) {
return &x;
}
@llvm/issue-subscribers-clang-temporal-safety
Author: NeKon69
int* get(int &x); // should suggest adding lifetimebound here
int* get(int &x [[clang::lifetimebound]]) {
return &x;
}
Can you please add a more elaborate example of what is the current vs the expected behaviour
Done
I will give this a try