[Mlir-commits] [mlir] [mlir] Make single value `ValueRange`s memory safer (PR #121996)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Fri Jan 10 04:22:20 PST 2025
Markus =?utf-8?q?Böck?= <markus.boeck02 at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/121996 at github.com>
ftynse wrote:
> On the other hand, I already think about `ValueRange` and friends like `ArrayRef<Value>`, and it's not valid to do
>
> ```c++
> ArrayRef<Value> stuff = getTemporary();
> ```
If we can guard against that too somehow, I'd say let's have that as well! I have been bitten by this before. Maybe a clang-tidy check?
It's even worse because some functions intentionally return ArrayRef or ValueRange pointing to an object already owned by the caller, so we can't just disable copy-initialization for ValueRange or document that one should not create variables of this type.
https://github.com/llvm/llvm-project/pull/121996
More information about the Mlir-commits
mailing list