[clang] [WIP][clang]: Implement a conditional lifetimebound_if builtin. (PR #125520)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 20 13:16:42 PST 2025
hokein wrote:
It feels like the current direction & discussion is expanding into a broader problem space beyond the specific issue this PR aims to address. We have two major problems which seem to be orthogonal:
1. **avoiding code duplication** – specifically, reducing the number of function overloads required due to `IsViewType<T>`.
2. **supporting variadic templates** – handling cases like `emplace_back(Args...)`.
The prototype here primarily targets problem (1). While `lifetimebound_like` seems like a reasonable solution, if I understand correctly, it mainly addresses problem (2).
As the name indicates, `lifetimebound_like` is a variant of `lifetimebound`, there are some inconsistencies:
- `lifetimebound` applies to the `*this` object when placed after the function type. However, `lifetimebound_like` does not follow the same rule;
- `lifetimebound` cannot be placed after standalone function (since there is no `*this` object), whereas `lifetimebound_like` can;
These differences might cause confusion for users. While they may not be a major issue, perhaps a more precise name could help clarify the intended behavior.
I'm starting to feel that we’re introducing more and more builtins to address a specific issue, which doesn’t seem ideal or scalable. That said, I don’t have a better alternative at the moment. Problem (2) is a known limitation of the current `lifetimebound` annotation -- supporting it would be great, but if we don’t have a solid and simple solution, we can always choose to do nothing and accept the limitation.
https://github.com/llvm/llvm-project/pull/125520
More information about the cfe-commits
mailing list