================
@@ -214,6 +248,27 @@ int *no_dangling_sources_ptr(int *a
[[clang::lifetimebound]], int *b [[clang::li
int *one_dangling_source_ptr(int *a [[clang::lifetimebound]]) {
int x = 1;
int *x_ptr = &x;
- return multi_param_test_ptr(a, x_ptr); // expected-warning {{Returning value
bound to 'x' that will go out of scope}}
+ return multi_param_test_ptr(a, x_ptr);
+ // expected-warning@-1 {{Returning value bound to 'x' that will go out of
scope}}
+ // expected-note@-2 {{Value bound to 'x' here}}
----------------
steakhal wrote:
@benedekaibas I think you are missing my point. Pointing at the declaration is
easy. That's not interesting because most often they only declare a single
variable - thus there is no confusion for the user.
However, where could be confusion is this, and read closely:
```
return multi_param_test_ptr(a, x_ptr);
// expected-warning@-1 {{Returning value bound to 'x' that will go out of
scope}} <-- what is 'x'?
// expected-note@-2 {{Value bound to 'x' here}} <-- what is 'here'? (does it
have a line:col range)
```
What does 'x' refer to in the call expr `multi_param_test_ptr(a, x_ptr)`. The
problem is that `x` is not spelled there at all. It's super confusing. While in
this case you intentionally correlated the name `x_ptr` which makes sense for
the test but you should assume it has some unrelated name. So what is `x`?
One way to help with this is by underlining the part of the call expr that has
`x` - but I'll let you speculate of how to improve this diag message because
right now it's not going to cut it for the users.
https://github.com/llvm/llvm-project/pull/207052
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits