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

Balázs Benics via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 18 01:10:36 PDT 2026


================
@@ -523,25 +532,29 @@ inline Twine Twine::concat(const Twine &Suffix) const {
   return Twine(NewLHS, NewLHSKind, NewRHS, NewRHSKind);
 }
 
-inline Twine operator+(const Twine &LHS, const Twine &RHS) {
+inline Twine operator+(const Twine &LHS LLVM_LIFETIME_BOUND,
+                       const Twine &RHS LLVM_LIFETIME_BOUND) {
   return LHS.concat(RHS);
 }
 
 /// Additional overload to guarantee simplified codegen; this is equivalent to
 /// concat().
 
-inline Twine operator+(const char *LHS, StringRef RHS) {
+inline Twine operator+(const char *LHS LLVM_LIFETIME_BOUND,
+                       StringRef RHS LLVM_LIFETIME_BOUND) {
   return Twine(LHS, RHS);
 }
 
 /// Additional overload to guarantee simplified codegen; this is equivalent to
 /// concat().
 
-inline Twine operator+(StringRef LHS, const char *RHS) {
+inline Twine operator+(StringRef LHS LLVM_LIFETIME_BOUND,
+                       const char *RHS LLVM_LIFETIME_BOUND) {
   return Twine(LHS, RHS);
 }
 
-inline raw_ostream &operator<<(raw_ostream &OS, const Twine &RHS) {
+inline raw_ostream &operator<<(raw_ostream &OS LLVM_LIFETIME_BOUND,
----------------
steakhal wrote:

This fn only takes OS and uses it within thid call. Its never stored, thus shouldnt be annotated.

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


More information about the llvm-commits mailing list