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

via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 18 07:39:02 PDT 2026


================

----------------
isuckatcs wrote:

Isn't this lifetime bound as well?

```c++
class StringLiteral : public StringRef {
  ...
public:
  template <size_t N>
  constexpr StringLiteral(const char (&Str)[N])
  ...
}
```
This allows snippets like this one:
```c++
  StringLiteral err() {
    const char Arr[] = "Hehehe";
    StringLiteral Dangling(Arr);

    return Dangling;
  }
```

In case of `Twine` it is more like this one:
```c++
  Twine err() {
    const char Arr[] = "Hehehe";
    StringLiteral Dangling(Arr);

    return Dangling;
  }
```

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


More information about the llvm-commits mailing list