[LifetimeSafety] Diagnose redeclarations in a different file whose lifetimebound annotations differ from the canonical declaration
After #197753, we decided that users should be asked to annotate the canonical declaration.
However, if a redeclaration is in a different file from the canonical declaration, and that redeclaration does not have a lifetimebound attribute that is present on the canonical declaration, we should diagnose that redeclaration as well.
// header.h
int* foo(int& x); // warning: redeclaration of function 'foo' does not have a 'lifetimebound' attribute on parameter 'x'
// source.cpp
int* foo(int& x [[clang::lifetimebound]]);
#include "header.h"
int* foo(int& x [[clang::lifetimebound]]) {
return &x;
}
@llvm/issue-subscribers-clang-temporal-safety
Author: NeKon69
int* foo(int& x); // redeclaration of a function 'foo' does not have a 'lifetimebound' attribute on parameter 'x'
int* foo(int& x [[clang::lifetimebound]]) { return &x; }
</details>
I am not in favour of this. I think we decided that we should ask users to annotate the canonical declaration.
But if we see a redecl in a header file which is not the canonical decl and is not in the same file as the canonical decl then we should ask users to annotate this redecl as well. Did you want to capture this part of the discussion ?
Yeah that makes more sense to me, thanks for the correction.
I would like to work on this.