[cfe-commits] TableGen: Goodbye RTTI!

Jakob Stoklund Olesen stoklund at 2pi.dk
Wed Oct 10 11:02:47 PDT 2012


On Oct 10, 2012, at 10:40 AM, Sean Silva <silvas at purdue.edu> wrote:

>> - The 'kind' enums should be protected, not public.
> 
> My reasoning here was that it might be convenient to allow clients to
> switch over the enum. This is also what I have documented in
> docs/HowToSetUpLLVMStyleRTTI.rst for precisely this reason. Is there a
> particular reason you would prefer it to be protected? I'm mostly
> interested for the sake of updating the documentation.

Only that it's bad OO style to switch on the leaves of a class hierarchy.

It's bad enough that the LLVM-style RTTI requires the hierarchy to be enumerated in the base class, but at least the damage is centralized.

A good compiler should be able to turn a chain of 'else if (isa<…>)' tests into a switch, and then you can subclass without updating all clients.

/jakob





More information about the cfe-commits mailing list