[clang] [analyzer] Implement BugReporterVisitor for UseAfterLifetimeEnd to trace lifetime source binding (PR #207052)
Balázs Benics via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 12 10:36:48 PDT 2026
================
@@ -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 at -1 {{Returning value bound to 'x' that will go out of scope}}
+ // expected-note at -2 {{Value bound to 'x' here}}
----------------
steakhal wrote:
Have you checked in your console that this highlights the source range of the expression that you refer to `x`? If not, then you probably miss a `addRange` call on the report object passing the expression's range.
unfortunately, the `-verify` is only line sensitive and you can not test if it underlines parts with `~~~~` in the console output.
https://github.com/llvm/llvm-project/pull/207052
More information about the cfe-commits
mailing list