[PATCH] D147991: [LLVM][Casting.h] Fix dyn_cast for std::unique_ptr.

Aman LaChapelle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 23:01:31 PDT 2023


bzcheeseman added a comment.

The test looks fine to me, but I'm now realizing some tricky behavior. If you std::move a unique pointer into a dyn_cast, and casting fails, you now have no pointer anymore (it's been moved already). In the unit test, if BP couldn't be cast to `foo` I believe you'd see this behavior. I vaguely recall hitting some of this in the past, does it make sense to have UniquePtrCast take `unique_ptr<> &` rather than `unique_ptr<> &&` and use `.release()/.reset()`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147991/new/

https://reviews.llvm.org/D147991



More information about the llvm-commits mailing list