clang  14.0.0git
TypeTraits.cpp
Go to the documentation of this file.
1 //===--- TypeTraits.cpp - Type Traits Support -----------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the type traits support functions.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "clang/Basic/TypeTraits.h"
14 #include "llvm/Support/ErrorHandling.h"
15 #include <cassert>
16 using namespace clang;
17 
18 static constexpr const char *TypeTraitNames[] = {
19 #define TYPE_TRAIT_1(Spelling, Name, Key) #Name,
20 #include "clang/Basic/TokenKinds.def"
21 #define TYPE_TRAIT_2(Spelling, Name, Key) #Name,
22 #include "clang/Basic/TokenKinds.def"
23 #define TYPE_TRAIT_N(Spelling, Name, Key) #Name,
24 #include "clang/Basic/TokenKinds.def"
25 };
26 
27 static constexpr const char *TypeTraitSpellings[] = {
28 #define TYPE_TRAIT_1(Spelling, Name, Key) #Spelling,
29 #include "clang/Basic/TokenKinds.def"
30 #define TYPE_TRAIT_2(Spelling, Name, Key) #Spelling,
31 #include "clang/Basic/TokenKinds.def"
32 #define TYPE_TRAIT_N(Spelling, Name, Key) #Spelling,
33 #include "clang/Basic/TokenKinds.def"
34 };
35 
36 static constexpr const char *ArrayTypeTraitNames[] = {
37 #define ARRAY_TYPE_TRAIT(Spelling, Name, Key) #Name,
38 #include "clang/Basic/TokenKinds.def"
39 };
40 
41 static constexpr const char *ArrayTypeTraitSpellings[] = {
42 #define ARRAY_TYPE_TRAIT(Spelling, Name, Key) #Spelling,
43 #include "clang/Basic/TokenKinds.def"
44 };
45 
46 static constexpr const char *UnaryExprOrTypeTraitNames[] = {
47 #define UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) #Name,
48 #define CXX11_UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) #Name,
49 #include "clang/Basic/TokenKinds.def"
50 };
51 
52 static constexpr const char *UnaryExprOrTypeTraitSpellings[] = {
53 #define UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) #Spelling,
54 #define CXX11_UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) #Spelling,
55 #include "clang/Basic/TokenKinds.def"
56 };
57 
59  assert(T <= TT_Last && "invalid enum value!");
60  return TypeTraitNames[T];
61 }
62 
64  assert(T <= ATT_Last && "invalid enum value!");
65  return ArrayTypeTraitNames[T];
66 }
67 
69  assert(T <= UETT_Last && "invalid enum value!");
70  return UnaryExprOrTypeTraitNames[T];
71 }
72 
74  assert(T <= TT_Last && "invalid enum value!");
75  return TypeTraitSpellings[T];
76 }
77 
79  assert(T <= ATT_Last && "invalid enum value!");
80  return ArrayTypeTraitSpellings[T];
81 }
82 
84  assert(T <= UETT_Last && "invalid enum value!");
86 }
clang::ArrayTypeTrait
ArrayTypeTrait
Names for the array type traits.
Definition: TypeTraits.h:42
clang::getTraitName
const char * getTraitName(ExpressionTrait T) LLVM_READONLY
Return the internal name of type trait T. Never null.
Definition: ExpressionTraits.cpp:28
UnaryExprOrTypeTraitNames
static constexpr const char * UnaryExprOrTypeTraitNames[]
Definition: TypeTraits.cpp:46
clang::TypeTrait
TypeTrait
Names for traits that operate specifically on types.
Definition: TypeTraits.h:21
clang::getTraitSpelling
const char * getTraitSpelling(ExpressionTrait T) LLVM_READONLY
Return the spelling of the type trait TT. Never null.
Definition: ExpressionTraits.cpp:33
TypeTraitSpellings
static constexpr const char * TypeTraitSpellings[]
Definition: TypeTraits.cpp:27
clang::ATT_Last
@ ATT_Last
Definition: TypeTraits.h:45
clang::UETT_Last
@ UETT_Last
Definition: TypeTraits.h:55
TypeTraits.h
TypeTraitNames
static constexpr const char * TypeTraitNames[]
Definition: TypeTraits.cpp:18
clang
Definition: CalledOnceCheck.h:17
UnaryExprOrTypeTraitSpellings
static constexpr const char * UnaryExprOrTypeTraitSpellings[]
Definition: TypeTraits.cpp:52
ArrayTypeTraitSpellings
static constexpr const char * ArrayTypeTraitSpellings[]
Definition: TypeTraits.cpp:41
clang::TT_Last
@ TT_Last
Definition: TypeTraits.h:36
clang::UnaryExprOrTypeTrait
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:51
ArrayTypeTraitNames
static constexpr const char * ArrayTypeTraitNames[]
Definition: TypeTraits.cpp:36