[llvm-branch-commits] [clang] [analyzer] Correctly highlight the variables' range in UseAfterLifetimeEnd reports (PR #215905)
Benedek Kaibas via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Aug 13 01:46:46 PDT 2026
================
@@ -435,3 +435,31 @@ int test_multi_param_highlight() {
// CHECK: return multi_params_annotated(&local_one, &local_two);
// CHECK-NEXT: ^~~~~~~~~~
}
+
+int test_multi_local_bound_to_param_highlight() {
+ int j = 4, k = 5;
+ // expected-note at -1 {{'j' initialized here}}
+ // expected-note at -2 {{'k' initialized here}}
+ return multi_params_annotated(&j, &k);
+ // expected-warning at -1 {{address of stack memory associated with local variable 'j' returned}}
+ // expected-warning at -2 {{address of stack memory associated with local variable 'k' returned}}
+ // expected-warning at -3 {{Returning value bound to 'j' that will go out of scope}}
+ // expected-note at -4 {{Value's lifetime bound to the lifetime of 'j' here}}
+ // expected-note at -5 {{Lifetime of 'j' ended here}}
+ // expected-warning at -6 {{Returning value bound to 'k' that will go out of scope}}
+ // expected-note at -7 {{Value's lifetime bound to the lifetime of 'k' here}}
+ // expected-note at -8 {{Lifetime of 'k' ended here}}
+
+ // CHECK: note: Value's lifetime bound to the lifetime of 'j' here
+ // CHECK-NEXT: int j = 4, k = 5;
+ // CHECK-NEXT: ~
+ // CHECK: note: Lifetime of 'j' ended here
+ // CHECK-NEXT: int j = 4, k = 5;
+ // CHECK-NEXT: ~
----------------
benedekaibas wrote:
I agree that the change in [40660e2](https://github.com/llvm/llvm-project/pull/215905/commits/40660e25ed980beaded53f99b654b50d7d212bec) saves time on writing the tests, but also 1) not good for visibility 2) can be confusing on where the indentations actually opposed to point.
https://github.com/llvm/llvm-project/pull/215905
More information about the llvm-branch-commits
mailing list