[clang] [LifetimeSafety] Fix 'clang::lifetimebound' ignored on template method definition (PR #178000)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 26 11:53:11 PST 2026


================
@@ -1260,13 +1278,17 @@ void test() {
 
     // Templated tests (generic templates)
     const auto ptrTA = StringTemplateA<char>().data();  // Declaration-only attribute // expected-warning {{temporary whose address is used}}
-    // FIXME: Definition is not instantiated until the end of TU. The attribute is not merged when this call is processed.
-    const auto ptrTB = StringTemplateB<char>().data();  // Definition-only attribute
+    const auto ptrTB = StringTemplateB<char>().data();  // Definition-only attribute  // expected-warning {{temporary whose address is used}}
     const auto ptrTC = StringTemplateC<char>().data();  // Both have attribute        // expected-warning {{temporary whose address is used}}
 
     // Template specialization tests
     const auto ptrTSA = StringTemplateSpecA<char>().data();  // Declaration-only attribute  // expected-warning {{temporary whose address is used}}
     const auto ptrTSB = StringTemplateSpecB<char>().data();  // Definition-only attribute   // expected-warning {{temporary whose address is used}}
     const auto ptrTSC = StringTemplateSpecC<char>().data();  // Both have attribute         // expected-warning {{temporary whose address is used}}
+
+    MemberFuncsTpl<int> mtf;
+    const int* pTMA = mtf.memberA(1);  // Declaration-only attribute  // expected-warning {{temporary whose address is used}}
+    const int* pTMB = mtf.memberB(2);  // Definition-only attribute   // FIXME: Definition-only attribute
----------------
vbvictor wrote:

Added the case, thank you!

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


More information about the cfe-commits mailing list