This patch extracts the RTTI part of llvm::ErrorInfo into its own class (RTTIExtends) so that it can be used in other non-error hierarchies, and makes it compatible with the existing LLVM RTTI function templates (isa, cast, dyn_cast, dyn_cast_or_null) by adding the classof method.
This system makes different trade-offs to the existing LLVM RTTI approach (described in https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html) and would be complementary to the existing system rather than replacing it. Specifically: the extensible scheme is slower than the existing scheme (requiring a virtual call per isa check), but it leaves hierarchies open for extension and is slightly easier to use (since it eliminates the enumeration and switch boilerplate).
I believe that extensible RTTI makes sense for the Error hierarchy (which is why it was originally developed there) and I speculate that it may be useful in other hierarchies (e.g. Object) where casting is expected to be rare and not performance sensitive. I don't have a use-case in tree yet and am in no rush for this to go in, but thought I would throw it up for discussion, and in case it is useful to anyone else.