1//===--- TypeTraits.h - C++ Type Traits Support Enumerations ----*- C++ -*-===//
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/// \file
10/// Defines enumerations for the type traits support.
11///
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CLANG_BASIC_TYPETRAITS_H
15#define LLVM_CLANG_BASIC_TYPETRAITS_H
16
17#include "llvm/Support/Compiler.h"
18
19namespace clang {
20/// Names for traits that operate specifically on types.
21enum TypeTrait {
22#define TYPE_TRAIT_1(Spelling, Name, Key) UTT_##Name,
23#include "clang/Basic/TokenKinds.def"
24 UTT_Last = -1 // UTT_Last == last UTT_XX in the enum.
25#define TYPE_TRAIT_1(Spelling, Name, Key) +1
26#include "clang/Basic/TokenKinds.def"
27 ,
28#define TYPE_TRAIT_2(Spelling, Name, Key) BTT_##Name,
29#include "clang/Basic/TokenKinds.def"
30 BTT_Last = UTT_Last // BTT_Last == last BTT_XX in the enum.
31#define TYPE_TRAIT_2(Spelling, Name, Key) +1
32#include "clang/Basic/TokenKinds.def"
33 ,
34#define TYPE_TRAIT_N(Spelling, Name, Key) TT_##Name,
35#include "clang/Basic/TokenKinds.def"
36 TT_Last = BTT_Last // TT_Last == last TT_XX in the enum.
37#define TYPE_TRAIT_N(Spelling, Name, Key) +1
38#include "clang/Basic/TokenKinds.def"
39};
40
41/// Names for the array type traits.
42enum ArrayTypeTrait {
43#define ARRAY_TYPE_TRAIT(Spelling, Name, Key) ATT_##Name,
44#include "clang/Basic/TokenKinds.def"
45 ATT_Last = -1 // ATT_Last == last ATT_XX in the enum.
46#define ARRAY_TYPE_TRAIT(Spelling, Name, Key) +1
47#include "clang/Basic/TokenKinds.def"
48};
49
50/// Names for the "expression or type" traits.
51enum UnaryExprOrTypeTrait {
52#define UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) UETT_##Name,
53#define CXX11_UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) UETT_##Name,
54#include "clang/Basic/TokenKinds.def"
55 UETT_Last = -1 // UETT_Last == last UETT_XX in the enum.
56#define UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) +1
57#define CXX11_UNARY_EXPR_OR_TYPE_TRAIT(Spelling, Name, Key) +1
58#include "clang/Basic/TokenKinds.def"
59};
60
61/// Return the internal name of type trait \p T. Never null.
62const char *getTraitName(TypeTrait T) LLVM_READONLY;
63const char *getTraitName(ArrayTypeTrait T) LLVM_READONLY;
64const char *getTraitName(UnaryExprOrTypeTrait T) LLVM_READONLY;
65
66/// Return the spelling of the type trait \p TT. Never null.
67const char *getTraitSpelling(TypeTrait T) LLVM_READONLY;
68const char *getTraitSpelling(ArrayTypeTrait T) LLVM_READONLY;
69const char *getTraitSpelling(UnaryExprOrTypeTrait T) LLVM_READONLY;
70
71/// Return the arity of the type trait \p T.
72unsigned getTypeTraitArity(TypeTrait T) LLVM_READONLY;
73
74} // namespace clang
75
76#endif
77

source code of clang/include/clang/Basic/TypeTraits.h