[llvm] r174113 - Give the MCStreamer class hierarchy LLVM RTTI facilities for use with

Sean Silva silvas at purdue.edu
Thu Jan 31 20:23:53 PST 2013


> See: http://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html
>
> Actually, I think we might want to move all of the middle class checks to be
> based on a covered switch so we get compiler warnings to ensure everywhere
> gets updated.

If you haven't already considered it, one quite fault-tolerant way to
approach this is that for each interior node Foo of the inheritance
hierarchy you have a FirstFoo and LastFoo in the Kind enum, and then
your check in the classof for any interior node Foo is always
`X->getKind() >= FirstFoo && X->getKind() <= LastFoo()`.

I'm not sure why I didn't mention that in HowToSetUpLLVMStyleRTTI
since that's exactly what I did for the TableGen's Init hierarchy and
IIRC that was in the same patch set that spurred me to write this
document.

I'd like to have some pattern (either FirstFoo/LastFoo, or whatever
you come up with using covered-switch) documented as the preferred
"fault-tolerant" pattern for this, so keep me in the loop with what
you settle on.

-- Sean Silva



More information about the llvm-commits mailing list