[clang] [llvm] [analyzer] Implemented a base of detecing lifetimebound annotation (PR #200145)

Benedek Kaibas via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 23 03:02:43 PDT 2026


================
@@ -122,36 +102,30 @@ void caller_seven() {
 // This does not apply to the test cases above this test case.
 }
 
-
 // Function returns a reference and has an annotated parameter
 int& func(int& some_number [[clang::lifetimebound]]);
 
-void clang_analyzer_lifetime_bound(int&);
-
 void caller_eight() {
   int f = 15;
   auto& bind = func(f);
 
-  clang_analyzer_lifetime_bound(bind);
-                                       // expected-warning at -1 {{Origin bound to some_number}}
-                                       // expected-warning at -1 {{Origin contains loan some_number}}
-  clang_analyzer_dump(bind);
-
+  clang_analyzer_lifetime_bound(bind); // expected-warning {{bound to f}}
+                                       // expected-warning at -1 {{contains loan f}}
 // The FIXME about the full warning applies to this text case as well.
 }
 
 // Function returns a reference and has two annotated parameters.
 int& f(int& a [[clang::lifetimebound]], int& b [[clang::lifetimebound]]);
 
-void clang_analyzer_lifetime_bound(int&);
-
 void caller_nine() {
   int first_num = 1;
   int second_num = 2;
-  auto numbers = f(first_num, second_num);
+  int& numbers = f(first_num, second_num);
+
+  clang_analyzer_lifetime_bound(numbers); // expected-warning {{bound to first_num}}
----------------
benedekaibas wrote:

Resolved here: 674c40e

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


More information about the cfe-commits mailing list