13
13
#include " clang/Basic/TypeTraits.h"
14
14
#include " llvm/Support/ErrorHandling.h"
15
15
#include < cassert>
16
+ #include < cstring>
16
17
using namespace clang ;
17
18
18
19
static constexpr const char *TypeTraitNames[] = {
19
20
#define TYPE_TRAIT_1 (Spelling, Name, Key ) #Name,
20
21
#include " clang/Basic/TokenKinds.def"
21
22
#define TYPE_TRAIT_2 (Spelling, Name, Key ) #Name,
22
- // IsDeducible is only used internally by clang for CTAD implementation and
23
- // is not exposed to users.
24
- TYPE_TRAIT_2 (/* */ , IsDeducible, KEYCXX)
25
23
#include " clang/Basic/TokenKinds.def"
26
24
#define TYPE_TRAIT_N (Spelling, Name, Key ) #Name,
27
25
#include " clang/Basic/TokenKinds.def"
@@ -31,9 +29,6 @@ static constexpr const char *TypeTraitSpellings[] = {
31
29
#define TYPE_TRAIT_1 (Spelling, Name, Key ) #Spelling,
32
30
#include " clang/Basic/TokenKinds.def"
33
31
#define TYPE_TRAIT_2 (Spelling, Name, Key ) #Spelling,
34
- // __is_deducible is only used internally by clang for CTAD implementation
35
- // and is not exposed to users.
36
- TYPE_TRAIT_2 (__is_deducible, /* */ , KEYCXX)
37
32
#include " clang/Basic/TokenKinds.def"
38
33
#define TYPE_TRAIT_N (Spelling, Name, Key ) #Spelling,
39
34
#include " clang/Basic/TokenKinds.def"
@@ -65,9 +60,6 @@ static constexpr const unsigned TypeTraitArities[] = {
65
60
#define TYPE_TRAIT_1 (Spelling, Name, Key ) 1 ,
66
61
#include " clang/Basic/TokenKinds.def"
67
62
#define TYPE_TRAIT_2 (Spelling, Name, Key ) 2 ,
68
- // IsDeducible is only used internally by clang for CTAD implementation and
69
- // is not exposed to users.
70
- TYPE_TRAIT_2 (/* */ , IsDeducible, KEYCXX)
71
63
#include " clang/Basic/TokenKinds.def"
72
64
#define TYPE_TRAIT_N (Spelling, Name, Key ) 0 ,
73
65
#include " clang/Basic/TokenKinds.def"
@@ -90,6 +82,15 @@ const char *clang::getTraitName(UnaryExprOrTypeTrait T) {
90
82
91
83
const char *clang::getTraitSpelling (TypeTrait T) {
92
84
assert (T <= TT_Last && " invalid enum value!" );
85
+ if (T == BTT_IsDeducible) {
86
+ // The __is_deducible is an internal-only type trait. To hide it from
87
+ // external users, we define it with an empty spelling name, preventing the
88
+ // clang parser from recognizing its token kind.
89
+ // However, other components such as the AST dump still require the real
90
+ // type trait name. Therefore, we return the real name when needed.
91
+ assert (std::strlen (TypeTraitSpellings[T]) == 0 );
92
+ return " __is_deducible" ;
93
+ }
93
94
return TypeTraitSpellings[T];
94
95
}
95
96
0 commit comments