This extracts the type name from PRETTY_FUNCTION for compilers that
support it (I've opted Clang, GCC, and ICC into this as I've tested that
they work) and it uses typeid and typeinfo in a pattern that work with
MSVC even without RTTI. The routine falls back gracefully on a stub
"UNKNOWN_TYPE" string with compilers or formats it doesn't understand.
This should be enough for a lot of common cases in LLVM where the real
goal is just to log or print a type name as a debugging aid, and save
a ton of boilerplate in the process.
The design and implementation is based on a bunch of advice and
discussion with Richard Smith and experimenting with most versions of
Clang, GCC, and MSVC 2015. We've also checked that ICC does something
reasonable and I'll watch the build bots for other compilers. It'd be
great if someone could contribute logic for xlC and/or other toolchains.
Comments or suggestions about how to make this better welcome. Hoping to
land this when the bots aren't too busy (which is not tonight with the
llvm.org hiccups) so tossing it out for review.