[llvm] [ADT] Add `[[clang::lifetimebound]]` annotations to Twine.h (PR #210474)

via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 18 12:30:32 PDT 2026


================
@@ -174,15 +174,17 @@ class Twine {
   }
 
   /// Construct a binary twine.
-  explicit Twine(const Twine &LHS, const Twine &RHS)
+  explicit Twine(const Twine &LHS LLVM_LIFETIME_BOUND,
+                 const Twine &RHS LLVM_LIFETIME_BOUND)
       : LHSKind(TwineKind), RHSKind(TwineKind) {
     this->LHS.twine = &LHS;
     this->RHS.twine = &RHS;
     assert(isValid() && "Invalid twine!");
   }
 
   /// Construct a twine from explicit values.
-  explicit Twine(Child LHS, NodeKind LHSKind, Child RHS, NodeKind RHSKind)
+  explicit Twine(Child LHS LLVM_LIFETIME_BOUND, NodeKind LHSKind,
----------------
NeKon69 wrote:

I think the idea is that you mark a parameter as 'lifetimebound' if the return value's lifetime can be bound by that parameter's lifetime at least in one of the control paths. I see where you're coming from, though I still think it's good to keep this. (Unless you want to redesign the API that is, which certainly is out of scope of this PR)

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


More information about the llvm-commits mailing list