[PATCH] D17565: [Support] Add a fancy helper function to get a static name for a type.
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 24 01:23:41 PST 2016
chandlerc created this revision.
chandlerc added reviewers: bogner, joker.eph, rsmith.
chandlerc added a subscriber: llvm-commits.
Herald added a subscriber: mcrosier.
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 4155 bytes
Desc: not available
More information about the llvm-commits