llvm-project
llvm-project copied to clipboard
-Wlifetime-safety-suggestions fixit misplaced to default argument
Input:
int* f(int* x = nullptr) {
return x;
}
Command:
$ clang++ -Wlifetime-safety -Wlifetime-safety-suggestions -Xclang -fixit main.cc
main.cc:1:8: warning: parameter in intra-TU function should be marked [[clang::lifetimebound]] [-Wlifetime-safety-intra-tu-suggestions]
1 | int* f(int* x = nullptr) {
| ^~~~~~~~~~~~~~~~
| [[clang::lifetimebound]]
main.cc:1:8: note: FIX-IT applied suggested code changes
Result:
int* f(int* x = nullptr [[clang::lifetimebound]]) {
return x;
}
Double-checking:
$ clang++ main.cc
main.cc:1:25: error: an attribute list cannot appear here
1 | int* f(int* x = nullptr [[clang::lifetimebound]]) {
| ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
@llvm/issue-subscribers-clang-temporal-safety
Author: Maksim Ivanov (emaxx-google)
Input:
int* f(int* x = nullptr) {
return x;
}
Command:
$ clang++ -Wlifetime-safety -Wlifetime-safety-suggestions -Xclang -fixit main.cc
main.cc:1:8: warning: parameter in intra-TU function should be marked [[clang::lifetimebound]] [-Wlifetime-safety-intra-tu-suggestions]
1 | int* f(int* x = nullptr) {
| ^~~~~~~~~~~~~~~~
| [[clang::lifetimebound]]
main.cc:1:8: note: FIX-IT applied suggested code changes
Result:
int* f(int* x = nullptr [[clang::lifetimebound]]) {
return x;
}
Double-checking:
$ clang++ main.cc
main.cc:1:25: error: an attribute list cannot appear here
1 | int* f(int* x = nullptr [[clang::lifetimebound]]) {
| ^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
I will work on this.
thanks a lot!