1 //===--- Specifiers.h - Declaration and Type Specifiers ---------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief Defines various enumerations that describe declaration and
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_CLANG_BASIC_SPECIFIERS_H
17 #define LLVM_CLANG_BASIC_SPECIFIERS_H
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/DataTypes.h"
23 /// \brief Specifies the width of a type, e.g., short, long, or long long.
24 enum TypeSpecifierWidth {
31 /// \brief Specifies the signedness of a type, e.g., signed or unsigned.
32 enum TypeSpecifierSign {
38 /// \brief Specifies the kind of type.
39 enum TypeSpecifierType {
43 TST_wchar, // C++ wchar_t
44 TST_char16, // C++11 char16_t
45 TST_char32, // C++11 char32_t
48 TST_half, // OpenCL half, ARM NEON __fp16
52 TST_decimal32, // _Decimal32
53 TST_decimal64, // _Decimal64
54 TST_decimal128, // _Decimal128
58 TST_class, // C++ class type
59 TST_interface, // C++ (Microsoft-specific) __interface type
60 TST_typename, // Typedef, C++ class-name or enum name, etc.
63 TST_decltype, // C++11 decltype
64 TST_underlyingType, // __underlying_type for C++11
65 TST_auto, // C++11 auto
66 TST_decltype_auto, // C++1y decltype(auto)
67 TST_unknown_anytype, // __unknown_anytype extension
68 TST_atomic, // C11 _Atomic
69 TST_error // erroneous type
72 /// \brief Structure that packs information about the type specifiers that
73 /// were written in a particular type specifier sequence.
74 struct WrittenBuiltinSpecs {
75 /*DeclSpec::TST*/ unsigned Type : 5;
76 /*DeclSpec::TSS*/ unsigned Sign : 2;
77 /*DeclSpec::TSW*/ unsigned Width : 2;
81 /// \brief A C++ access specifier (public, private, protected), plus the
82 /// special value "none" which means different things in different contexts.
83 enum AccessSpecifier {
90 /// \brief The categorization of expression values, currently following the
93 /// \brief An r-value expression (a pr-value in the C++11 taxonomy)
94 /// produces a temporary value.
97 /// \brief An l-value expression is a reference to an object with
98 /// independent storage.
101 /// \brief An x-value expression is a reference to an object with
102 /// independent storage but which can be "moved", i.e.
103 /// efficiently cannibalized for its resources.
107 /// \brief A further classification of the kind of object referenced by an
108 /// l-value or x-value.
109 enum ExprObjectKind {
110 /// An ordinary object is located at an address in memory.
113 /// A bitfield object is a bitfield on a C or C++ record.
116 /// A vector component is an element or range of elements on a vector.
119 /// An Objective-C property is a logical field of an Objective-C
120 /// object which is read and written via Objective-C method calls.
123 /// An Objective-C array/dictionary subscripting which reads an
124 /// object or writes at the subscripted array/dictionary element via
125 /// Objective-C method calls.
129 /// \brief Describes the kind of template specialization that a
130 /// particular template specialization declaration represents.
131 enum TemplateSpecializationKind {
132 /// This template specialization was formed from a template-id but
133 /// has not yet been declared, defined, or instantiated.
135 /// This template specialization was implicitly instantiated from a
136 /// template. (C++ [temp.inst]).
137 TSK_ImplicitInstantiation,
138 /// This template specialization was declared or defined by an
139 /// explicit specialization (C++ [temp.expl.spec]) or partial
140 /// specialization (C++ [temp.class.spec]).
141 TSK_ExplicitSpecialization,
142 /// This template specialization was instantiated from a template
143 /// due to an explicit instantiation declaration request
144 /// (C++11 [temp.explicit]).
145 TSK_ExplicitInstantiationDeclaration,
146 /// This template specialization was instantiated from a template
147 /// due to an explicit instantiation definition request
148 /// (C++ [temp.explicit]).
149 TSK_ExplicitInstantiationDefinition
152 /// \brief Determine whether this template specialization kind refers
153 /// to an instantiation of an entity (as opposed to a non-template or
154 /// an explicit specialization).
155 inline bool isTemplateInstantiation(TemplateSpecializationKind Kind) {
156 return Kind != TSK_Undeclared && Kind != TSK_ExplicitSpecialization;
159 /// \brief Thread storage-class-specifier.
160 enum ThreadStorageClassSpecifier {
164 /// C++11 thread_local. Implies 'static' at block scope, but not at
167 /// C11 _Thread_local. Must be combined with either 'static' or 'extern'
168 /// if used at block scope.
172 /// \brief Storage classes.
174 // These are legal on both functions and variables.
180 // These are only legal on variables.
181 SC_OpenCLWorkGroupLocal,
186 /// \brief Checks whether the given storage class is legal for functions.
187 inline bool isLegalForFunction(StorageClass SC) {
188 return SC <= SC_PrivateExtern;
191 /// \brief Checks whether the given storage class is legal for variables.
192 inline bool isLegalForVariable(StorageClass SC) {
196 /// \brief In-class initialization styles for non-static data members.
197 enum InClassInitStyle {
198 ICIS_NoInit, ///< No in-class initializer.
199 ICIS_CopyInit, ///< Copy initialization.
200 ICIS_ListInit ///< Direct list-initialization.
203 /// \brief CallingConv - Specifies the calling convention that a function uses.
205 CC_C, // __attribute__((cdecl))
206 CC_X86StdCall, // __attribute__((stdcall))
207 CC_X86FastCall, // __attribute__((fastcall))
208 CC_X86ThisCall, // __attribute__((thiscall))
209 CC_X86VectorCall, // __attribute__((vectorcall))
210 CC_X86Pascal, // __attribute__((pascal))
211 CC_X86_64Win64, // __attribute__((ms_abi))
212 CC_X86_64SysV, // __attribute__((sysv_abi))
213 CC_AAPCS, // __attribute__((pcs("aapcs")))
214 CC_AAPCS_VFP, // __attribute__((pcs("aapcs-vfp")))
215 CC_IntelOclBicc, // __attribute__((intel_ocl_bicc))
216 CC_SpirFunction, // default for OpenCL functions on SPIR target
217 CC_SpirKernel // inferred for OpenCL kernels on SPIR target
220 /// \brief Checks whether the given calling convention supports variadic
221 /// calls. Unprototyped calls also use the variadic call rules.
222 inline bool supportsVariadicCall(CallingConv CC) {
228 case CC_X86VectorCall:
229 case CC_SpirFunction:
237 /// \brief The storage duration for an object (per C++ [basic.stc]).
238 enum StorageDuration {
239 SD_FullExpression, ///< Full-expression storage duration (for temporaries).
240 SD_Automatic, ///< Automatic storage duration (most local variables).
241 SD_Thread, ///< Thread storage duration.
242 SD_Static, ///< Static storage duration.
243 SD_Dynamic ///< Dynamic storage duration.
246 /// Describes the nullability of a particular type.
247 enum class NullabilityKind : uint8_t {
248 /// Values of this type can never be null.
250 /// Values of this type can be null.
252 /// Whether values of this type can be null is (explicitly)
253 /// unspecified. This captures a (fairly rare) case where we
254 /// can't conclude anything about the nullability of the type even
255 /// though it has been considered.
259 /// Retrieve the spelling of the given nullability kind.
260 llvm::StringRef getNullabilitySpelling(NullabilityKind kind,
261 bool isContextSensitive = false);
262 } // end namespace clang
264 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H