[clang-tools-extra] [clang-tidy] Add bugprone-move-shared-pointer-contents check. (PR #67467)
Denis Mikhailov via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 3 14:59:48 PST 2025
denzor200 wrote:
> Wouldn't that be a runtime check, and thus not something clang-tidy can do without significant data flow analysis effort?
I'm not experienced enough in clang-tidy internals, but I believe it will not be a serious challenge to check for having `assert(sp.use_count() == 1)` one line before `*sp` being moved.
I suppose everybody agree that this snippet
```
assert(sp.use_count() == 1);
auto y = std::move(*sp);
```
..is better than that one:
```
// NOLINTNEXTLINE(clang-tidy-bugprone-move-shared-pointer-contents)
auto y = std::move(*sp);
```
https://github.com/llvm/llvm-project/pull/67467
More information about the cfe-commits
mailing list