9#ifndef LLVM_SUPPORT_TYPENAME_H
10#define LLVM_SUPPORT_TYPENAME_H
17#if defined(__clang__) || defined(_MSC_VER) || \
18 (defined(__GNUC__) && __GNUC__ >= 9)
19#define LLVM_GET_TYPE_NAME_CONSTEXPR constexpr
20#define LLVM_GET_TYPE_NAME_STATIC_ASSERT 1
22#define LLVM_GET_TYPE_NAME_CONSTEXPR
23#define LLVM_GET_TYPE_NAME_STATIC_ASSERT 0
39template <
typename DesiredTypeName>
41#if defined(__clang__) || defined(__GNUC__)
47#if LLVM_GET_TYPE_NAME_STATIC_ASSERT
48 static_assert(!TemplateParamsStart.empty(),
49 "Unable to find the template parameter!");
51 assert(!TemplateParamsStart.empty() &&
52 "Unable to find the template parameter!");
56 TemplateParamsStart.substr(Key.size());
58#if LLVM_GET_TYPE_NAME_STATIC_ASSERT
60 static_assert(!SubstitutionKey.empty() && SubstitutionKey.back() ==
']',
61 "Name doesn't end in the substitution key!");
63 assert(!SubstitutionKey.empty() && SubstitutionKey.back() ==
']' &&
64 "Name doesn't end in the substitution key!");
67 return SubstitutionKey.substr(0, SubstitutionKey.size() - 1);
68#elif defined(_MSC_VER)
74 static_assert(!GetTypeNameStart.empty(),
75 "Unable to find the template parameter!");
77 GetTypeNameStart.substr(Key.size());
81 SubstitutionKey.find(
"class ") == 0
82 ? SubstitutionKey.substr(
sizeof(
"class ") - 1)
85 RmPrefixClass.find(
"struct ") == 0
86 ? RmPrefixClass.substr(
sizeof(
"struct ") - 1)
89 RmPrefixStruct.find(
"union ") == 0
90 ? RmPrefixStruct.substr(
sizeof(
"union ") - 1)
93 RmPrefixUnion.find(
"enum ") == 0
94 ? RmPrefixUnion.substr(
sizeof(
"enum ") - 1)
98 static_assert(AnglePos != std::string_view::npos,
99 "Unable to find the closing '>'!");
100 return RmPrefixEnum.substr(0, AnglePos);
104 return "UNKNOWN_TYPE";
111#undef LLVM_GET_TYPE_NAME_CONSTEXPR
112#undef LLVM_GET_TYPE_NAME_STATIC_ASSERT
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_GET_TYPE_NAME_CONSTEXPR
StringRef - Represent a constant reference to a string, i.e.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_GET_TYPE_NAME_CONSTEXPR StringRef getTypeName()
We provide a function which tries to compute the (demangled) name of a type statically.