]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/clang/include/clang/Basic/Specifiers.h
Merge OpenSSL 1.0.2g.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / clang / include / clang / Basic / Specifiers.h
1 //===--- Specifiers.h - Declaration and Type Specifiers ---------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 ///
10 /// \file
11 /// \brief Defines various enumerations that describe declaration and
12 /// type specifiers.
13 ///
14 //===----------------------------------------------------------------------===//
15
16 #ifndef LLVM_CLANG_BASIC_SPECIFIERS_H
17 #define LLVM_CLANG_BASIC_SPECIFIERS_H
18
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/DataTypes.h"
21
22 namespace clang {
23   /// \brief Specifies the width of a type, e.g., short, long, or long long.
24   enum TypeSpecifierWidth {
25     TSW_unspecified,
26     TSW_short,
27     TSW_long,
28     TSW_longlong
29   };
30   
31   /// \brief Specifies the signedness of a type, e.g., signed or unsigned.
32   enum TypeSpecifierSign {
33     TSS_unspecified,
34     TSS_signed,
35     TSS_unsigned
36   };
37   
38   /// \brief Specifies the kind of type.
39   enum TypeSpecifierType {
40     TST_unspecified,
41     TST_void,
42     TST_char,
43     TST_wchar,        // C++ wchar_t
44     TST_char16,       // C++11 char16_t
45     TST_char32,       // C++11 char32_t
46     TST_int,
47     TST_int128,
48     TST_half,         // OpenCL half, ARM NEON __fp16
49     TST_float,
50     TST_double,
51     TST_bool,         // _Bool
52     TST_decimal32,    // _Decimal32
53     TST_decimal64,    // _Decimal64
54     TST_decimal128,   // _Decimal128
55     TST_enum,
56     TST_union,
57     TST_struct,
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.
61     TST_typeofType,
62     TST_typeofExpr,
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
70   };
71   
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;
78     bool ModeAttr : 1;
79   };  
80
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 {
84     AS_public,
85     AS_protected,
86     AS_private,
87     AS_none
88   };
89
90   /// \brief The categorization of expression values, currently following the
91   /// C++11 scheme.
92   enum ExprValueKind {
93     /// \brief An r-value expression (a pr-value in the C++11 taxonomy)
94     /// produces a temporary value.
95     VK_RValue,
96
97     /// \brief An l-value expression is a reference to an object with
98     /// independent storage.
99     VK_LValue,
100
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.
104     VK_XValue
105   };
106
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.
111     OK_Ordinary,
112
113     /// A bitfield object is a bitfield on a C or C++ record.
114     OK_BitField,
115
116     /// A vector component is an element or range of elements on a vector.
117     OK_VectorComponent,
118
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.
121     OK_ObjCProperty,
122     
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.
126     OK_ObjCSubscript
127   };
128
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.
134     TSK_Undeclared = 0,
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
150   };
151
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;
157   }
158
159   /// \brief Thread storage-class-specifier.
160   enum ThreadStorageClassSpecifier {
161     TSCS_unspecified,
162     /// GNU __thread.
163     TSCS___thread,
164     /// C++11 thread_local. Implies 'static' at block scope, but not at
165     /// class scope.
166     TSCS_thread_local,
167     /// C11 _Thread_local. Must be combined with either 'static' or 'extern'
168     /// if used at block scope.
169     TSCS__Thread_local
170   };
171
172   /// \brief Storage classes.
173   enum StorageClass {
174     // These are legal on both functions and variables.
175     SC_None,
176     SC_Extern,
177     SC_Static,
178     SC_PrivateExtern,
179
180     // These are only legal on variables.
181     SC_OpenCLWorkGroupLocal,
182     SC_Auto,
183     SC_Register
184   };
185
186   /// \brief Checks whether the given storage class is legal for functions.
187   inline bool isLegalForFunction(StorageClass SC) {
188     return SC <= SC_PrivateExtern;
189   }
190
191   /// \brief Checks whether the given storage class is legal for variables.
192   inline bool isLegalForVariable(StorageClass SC) {
193     return true;
194   }
195
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.
201   };
202
203   /// \brief CallingConv - Specifies the calling convention that a function uses.
204   enum CallingConv {
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
218   };
219
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) {
223     switch (CC) {
224     case CC_X86StdCall:
225     case CC_X86FastCall:
226     case CC_X86ThisCall:
227     case CC_X86Pascal:
228     case CC_X86VectorCall:
229     case CC_SpirFunction:
230     case CC_SpirKernel:
231       return false;
232     default:
233       return true;
234     }
235   }
236
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.
244   };
245
246   /// Describes the nullability of a particular type.
247   enum class NullabilityKind : uint8_t {
248     /// Values of this type can never be null.
249     NonNull = 0,
250     /// Values of this type can be null.
251     Nullable,
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.
256     Unspecified
257   };
258
259   /// Retrieve the spelling of the given nullability kind.
260   llvm::StringRef getNullabilitySpelling(NullabilityKind kind,
261                                          bool isContextSensitive = false);
262 } // end namespace clang
263
264 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H