[PATCH] D17565: [Support] Add a fancy helper function to get a static name for a type.

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 24 13:50:02 PST 2016


majnemer added a subscriber: majnemer.
majnemer added a comment.

How hot is this code?
Your typeid trickery will not melt away at compile time, it will get demangled by the runtime...
IIRC, they have some mechanism to cache the demangled names which means that `typeid(T).name()` also acquires a lock.

If this is moderately hot, I'd suggest using `__FUNCSIG__` for MSVC.
Using `__FUNCSIG__` in `llvm::getTypeName<int>()` would give you:
`class llvm::StringRef __cdecl llvm::getTypeName<int>(void)`
The type's pretty name can be dug out by looking inside `__FUNCSIG__` for `llvm::getTypeName<` and looking backwards for `>`.


http://reviews.llvm.org/D17565





More information about the llvm-commits mailing list