[llvm-branch-commits] [clang] [analyzer] Correctly highlight the variables' range in UseAfterLifetimeEnd reports (PR #215905)

Balázs Benics via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Aug 13 00:32:57 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:     ~
----------------
steakhal wrote:

FWIW filecheck accepts arbitrary whitespace indentations without strict whitespace matching.

https://github.com/llvm/llvm-project/pull/215905


More information about the llvm-branch-commits mailing list