LLVM has a relatively large number of proprietary replacements for standard C++ functions and classes. One of these is dyn_cast to replace dynamic_cast. The two calls appear to be semantically equivalent; the only difference that I can see is that dyn_cast reportedly works on classes that have no v-table [1]. Could someone please explain why I should use dyn_cast instead of dynamic_cast? (I thought all classes have v-tables...) Thanks, Trevor [1] http://llvm.org/docs/ProgrammersManual.html#isa
Trevor Harmon <Trevor.W.Harmon at nasa.gov> writes: [snip]> Could someone > please explain why I should use dyn_cast instead of dynamic_cast? (I > thought all classes have v-tables...) Thanks,For reducing executable size, LLVM builds with RTTI disabled where possible.
On Nov 12, 2010, at 5:57 PM, Óscar Fuentes wrote:> Trevor Harmon <Trevor.W.Harmon at nasa.gov> writes: > > [snip] >> Could someone >> please explain why I should use dyn_cast instead of dynamic_cast? (I >> thought all classes have v-tables...) Thanks, > > For reducing executable size, LLVM builds with RTTI disabled where > possible.dyn_cast is also much much faster than dynamic_cast, which is really important because llvm uses dyn_cast all over the place. -Chris
On Nov 12, 2010, at 5:57 PM, Óscar Fuentes wrote:>> Could someone >> please explain why I should use dyn_cast instead of dynamic_cast? (I >> thought all classes have v-tables...) Thanks, > > For reducing executable size, LLVM builds with RTTI disabled where > possible.Right, but how does that relate to dyn_cast? I thought v-tables were present even when RTTI is not (because otherwise polymorphism would be impossible). Trevor