Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions llvm/include/llvm/Support/TypeName.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,8 @@

namespace llvm {

/// We provide a function which tries to compute the (demangled) name of a type
/// statically.
///
/// This routine may fail on some platforms or for particularly unusual types.
/// Do not use it for anything other than logging and debugging aids. It isn't
/// portable or dependendable in any real sense.
///
/// The returned StringRef will point into a static storage duration string.
/// However, it may not be null terminated and may be some strangely aligned
/// inner substring of a larger string.
template <typename DesiredTypeName>
inline StringRef getTypeName() {
namespace detail {
template <typename DesiredTypeName> inline StringRef getTypeNameImpl() {
#if defined(__clang__) || defined(__GNUC__)
StringRef Name = __PRETTY_FUNCTION__;

Expand Down Expand Up @@ -58,6 +48,22 @@ inline StringRef getTypeName() {
return "UNKNOWN_TYPE";
#endif
}
} // namespace detail

/// We provide a function which tries to compute the (demangled) name of a type
/// statically.
///
/// This routine may fail on some platforms or for particularly unusual types.
/// Do not use it for anything other than logging and debugging aids. It isn't
/// portable or dependendable in any real sense.
///
/// The returned StringRef will point into a static storage duration string.
/// However, it may not be null terminated and may be some strangely aligned
/// inner substring of a larger string.
template <typename DesiredTypeName> inline StringRef getTypeName() {
static StringRef Name = detail::getTypeNameImpl<DesiredTypeName>();
return Name;
}

} // namespace llvm

Expand Down
Loading