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

Benedek Kaibas via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 18 01:37:38 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,
----------------
benedekaibas wrote:

Applied changes here: [ea5a904](https://github.com/llvm/llvm-project/pull/210474/commits/ea5a904db2f7a81cb80536f1f11e30c5b23ce5a3)

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


More information about the llvm-commits mailing list