[llvm-dev] RTTI with smart pointers
Vedant Kumar via llvm-dev
llvm-dev at lists.llvm.org
Mon Jul 31 13:55:24 PDT 2017
> On Jul 31, 2017, at 5:43 AM, Victor Campos via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> I would like to use std::shared_ptr in my pass. However I'm facing a problem wrt RTTI. If I have a code like:
> std::shared_ptr<BaseClass> x(new DerivedClass());
> std::shared_ptr<DerivedClass> p = std::dynamic_pointer_cast<DerivedClass>(x);
> It does not compile since the default RTTI infrastructure is not used by LLVM. Also, it's not clear to me if the 'classof' approach works in this case (I did try it with no success).
> Is it possible to have a dynamic_cast using std smart pointers in LLVM?
I don't know of an off-the-shelf way to do this but you could look to r300098 for inspiration (it introduced unique_dyn_cast).
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev