[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:59:28 PDT 2026
================
@@ -470,8 +479,8 @@ class Twine {
/// given SmallVector and a StringRef to the SmallVector's data is returned.
///
/// The returned StringRef's size does not include the null terminator.
- LLVM_ABI StringRef
- toNullTerminatedStringRef(SmallVectorImpl<char> &Out) const;
+ LLVM_ABI StringRef toNullTerminatedStringRef(
+ SmallVectorImpl<char> &Out LLVM_LIFETIME_BOUND) const;
----------------
benedekaibas wrote:
> Thinking about this a bit, I think `this` should be annotated for `toNullTerminatedStringRef` , right? That's the whole point of this function that if it's a stringref, it just returns that instead.
Yes, you are right based on the comment:
```text
/// This returns the twine as a single null terminated StringRef if it
/// can be represented as such. Otherwise the twine is written into the
/// given SmallVector and a StringRef to the SmallVector's data is returned.
///
/// The returned StringRef's size does not include the null terminator.
```
I think the same also applies to the `toStringRef` function.
https://github.com/llvm/llvm-project/pull/210474
More information about the llvm-commits
mailing list