clang  5.0.0
Specifiers.h
Go to the documentation of this file.
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 #include "llvm/Support/ErrorHandling.h"
22 
23 namespace clang {
24  /// \brief Specifies the width of a type, e.g., short, long, or long long.
30  };
31 
32  /// \brief Specifies the signedness of a type, e.g., signed or unsigned.
37  };
38 
42  };
43 
44  /// \brief Specifies the kind of type.
49  TST_wchar, // C++ wchar_t
50  TST_char16, // C++11 char16_t
51  TST_char32, // C++11 char32_t
54  TST_half, // OpenCL half, ARM NEON __fp16
58  TST_bool, // _Bool
59  TST_decimal32, // _Decimal32
60  TST_decimal64, // _Decimal64
61  TST_decimal128, // _Decimal128
65  TST_class, // C++ class type
66  TST_interface, // C++ (Microsoft-specific) __interface type
67  TST_typename, // Typedef, C++ class-name or enum name, etc.
70  TST_decltype, // C++11 decltype
71  TST_underlyingType, // __underlying_type for C++11
72  TST_auto, // C++11 auto
73  TST_decltype_auto, // C++1y decltype(auto)
74  TST_auto_type, // __auto_type extension
75  TST_unknown_anytype, // __unknown_anytype extension
76  TST_atomic, // C11 _Atomic
77 #define GENERIC_IMAGE_TYPE(ImgType, Id) TST_##ImgType##_t, // OpenCL image types
78 #include "clang/Basic/OpenCLImageTypes.def"
79  TST_error // erroneous type
80  };
81 
82  /// \brief Structure that packs information about the type specifiers that
83  /// were written in a particular type specifier sequence.
85  static_assert(TST_error < 1 << 6, "Type bitfield not wide enough for TST");
86  /*DeclSpec::TST*/ unsigned Type : 6;
87  /*DeclSpec::TSS*/ unsigned Sign : 2;
88  /*DeclSpec::TSW*/ unsigned Width : 2;
89  unsigned ModeAttr : 1;
90  };
91 
92  /// \brief A C++ access specifier (public, private, protected), plus the
93  /// special value "none" which means different things in different contexts.
99  };
100 
101  /// \brief The categorization of expression values, currently following the
102  /// C++11 scheme.
104  /// \brief An r-value expression (a pr-value in the C++11 taxonomy)
105  /// produces a temporary value.
107 
108  /// \brief An l-value expression is a reference to an object with
109  /// independent storage.
111 
112  /// \brief An x-value expression is a reference to an object with
113  /// independent storage but which can be "moved", i.e.
114  /// efficiently cannibalized for its resources.
116  };
117 
118  /// \brief A further classification of the kind of object referenced by an
119  /// l-value or x-value.
121  /// An ordinary object is located at an address in memory.
123 
124  /// A bitfield object is a bitfield on a C or C++ record.
126 
127  /// A vector component is an element or range of elements on a vector.
129 
130  /// An Objective-C property is a logical field of an Objective-C
131  /// object which is read and written via Objective-C method calls.
133 
134  /// An Objective-C array/dictionary subscripting which reads an
135  /// object or writes at the subscripted array/dictionary element via
136  /// Objective-C method calls.
138  };
139 
140  /// \brief Describes the kind of template specialization that a
141  /// particular template specialization declaration represents.
143  /// This template specialization was formed from a template-id but
144  /// has not yet been declared, defined, or instantiated.
146  /// This template specialization was implicitly instantiated from a
147  /// template. (C++ [temp.inst]).
149  /// This template specialization was declared or defined by an
150  /// explicit specialization (C++ [temp.expl.spec]) or partial
151  /// specialization (C++ [temp.class.spec]).
153  /// This template specialization was instantiated from a template
154  /// due to an explicit instantiation declaration request
155  /// (C++11 [temp.explicit]).
157  /// This template specialization was instantiated from a template
158  /// due to an explicit instantiation definition request
159  /// (C++ [temp.explicit]).
161  };
162 
163  /// \brief Determine whether this template specialization kind refers
164  /// to an instantiation of an entity (as opposed to a non-template or
165  /// an explicit specialization).
167  return Kind != TSK_Undeclared && Kind != TSK_ExplicitSpecialization;
168  }
169 
170  /// \brief True if this template specialization kind is an explicit
171  /// specialization, explicit instantiation declaration, or explicit
172  /// instantiation definition.
175  switch (Kind) {
179  return true;
180 
181  case TSK_Undeclared:
183  return false;
184  }
185  llvm_unreachable("bad template specialization kind");
186  }
187 
188  /// \brief Thread storage-class-specifier.
191  /// GNU __thread.
193  /// C++11 thread_local. Implies 'static' at block scope, but not at
194  /// class scope.
196  /// C11 _Thread_local. Must be combined with either 'static' or 'extern'
197  /// if used at block scope.
199  };
200 
201  /// \brief Storage classes.
203  // These are legal on both functions and variables.
208 
209  // These are only legal on variables.
212  };
213 
214  /// \brief Checks whether the given storage class is legal for functions.
216  return SC <= SC_PrivateExtern;
217  }
218 
219  /// \brief Checks whether the given storage class is legal for variables.
221  return true;
222  }
223 
224  /// \brief In-class initialization styles for non-static data members.
226  ICIS_NoInit, ///< No in-class initializer.
227  ICIS_CopyInit, ///< Copy initialization.
228  ICIS_ListInit ///< Direct list-initialization.
229  };
230 
231  /// \brief CallingConv - Specifies the calling convention that a function uses.
232  enum CallingConv {
233  CC_C, // __attribute__((cdecl))
234  CC_X86StdCall, // __attribute__((stdcall))
235  CC_X86FastCall, // __attribute__((fastcall))
236  CC_X86ThisCall, // __attribute__((thiscall))
237  CC_X86VectorCall, // __attribute__((vectorcall))
238  CC_X86Pascal, // __attribute__((pascal))
239  CC_Win64, // __attribute__((ms_abi))
240  CC_X86_64SysV, // __attribute__((sysv_abi))
241  CC_X86RegCall, // __attribute__((regcall))
242  CC_AAPCS, // __attribute__((pcs("aapcs")))
243  CC_AAPCS_VFP, // __attribute__((pcs("aapcs-vfp")))
244  CC_IntelOclBicc, // __attribute__((intel_ocl_bicc))
245  CC_SpirFunction, // default for OpenCL functions on SPIR target
246  CC_OpenCLKernel, // inferred for OpenCL kernels
247  CC_Swift, // __attribute__((swiftcall))
248  CC_PreserveMost, // __attribute__((preserve_most))
249  CC_PreserveAll, // __attribute__((preserve_all))
250  };
251 
252  /// \brief Checks whether the given calling convention supports variadic
253  /// calls. Unprototyped calls also use the variadic call rules.
255  switch (CC) {
256  case CC_X86StdCall:
257  case CC_X86FastCall:
258  case CC_X86ThisCall:
259  case CC_X86RegCall:
260  case CC_X86Pascal:
261  case CC_X86VectorCall:
262  case CC_SpirFunction:
263  case CC_OpenCLKernel:
264  case CC_Swift:
265  return false;
266  default:
267  return true;
268  }
269  }
270 
271  /// \brief The storage duration for an object (per C++ [basic.stc]).
273  SD_FullExpression, ///< Full-expression storage duration (for temporaries).
274  SD_Automatic, ///< Automatic storage duration (most local variables).
275  SD_Thread, ///< Thread storage duration.
276  SD_Static, ///< Static storage duration.
277  SD_Dynamic ///< Dynamic storage duration.
278  };
279 
280  /// Describes the nullability of a particular type.
281  enum class NullabilityKind : uint8_t {
282  /// Values of this type can never be null.
283  NonNull = 0,
284  /// Values of this type can be null.
285  Nullable,
286  /// Whether values of this type can be null is (explicitly)
287  /// unspecified. This captures a (fairly rare) case where we
288  /// can't conclude anything about the nullability of the type even
289  /// though it has been considered.
291  };
292 
293  /// Retrieve the spelling of the given nullability kind.
295  bool isContextSensitive = false);
296 
297  /// \brief Kinds of parameter ABI.
298  enum class ParameterABI {
299  /// This parameter uses ordinary ABI rules for its type.
300  Ordinary,
301 
302  /// This parameter (which must have pointer type) is a Swift
303  /// indirect result parameter.
305 
306  /// This parameter (which must have pointer-to-pointer type) uses
307  /// the special Swift error-result ABI treatment. There can be at
308  /// most one parameter on a given function that uses this treatment.
310 
311  /// This parameter (which must have pointer type) uses the special
312  /// Swift context-pointer ABI treatment. There can be at
313  /// most one parameter on a given function that uses this treatment.
315  };
316 
317  llvm::StringRef getParameterABISpelling(ParameterABI kind);
318 } // end namespace clang
319 
320 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H
Static storage duration.
Definition: Specifiers.h:276
NullabilityKind
Describes the nullability of a particular type.
Definition: Specifiers.h:281
The base class of the type hierarchy.
Definition: Type.h:1303
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:94
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
Definition: Specifiers.h:272
An Objective-C array/dictionary subscripting which reads an object or writes at the subscripted array...
Definition: Specifiers.h:137
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:45
bool isTemplateExplicitInstantiationOrSpecialization(TemplateSpecializationKind Kind)
True if this template specialization kind is an explicit specialization, explicit instantiation decla...
Definition: Specifiers.h:173
C11 _Thread_local.
Definition: Specifiers.h:198
A vector component is an element or range of elements on a vector.
Definition: Specifiers.h:128
Copy initialization.
Definition: Specifiers.h:227
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
Definition: Specifiers.h:33
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:106
Values of this type can be null.
This parameter (which must have pointer type) uses the special Swift context-pointer ABI treatment...
Whether values of this type can be null is (explicitly) unspecified.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
Definition: Specifiers.h:115
Values of this type can never be null.
An ordinary object is located at an address in memory.
Definition: Specifiers.h:122
This parameter (which must have pointer-to-pointer type) uses the special Swift error-result ABI trea...
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
Definition: Specifiers.h:132
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:103
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls.
Definition: Specifiers.h:254
StorageClass
Storage classes.
Definition: Specifiers.h:202
bool isLegalForFunction(StorageClass SC)
Checks whether the given storage class is legal for functions.
Definition: Specifiers.h:215
InClassInitStyle
In-class initialization styles for non-static data members.
Definition: Specifiers.h:225
This template specialization was implicitly instantiated from a template.
Definition: Specifiers.h:148
TypeSpecifiersPipe
Definition: Specifiers.h:39
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
Definition: Specifiers.h:166
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:232
Dynamic storage duration.
Definition: Specifiers.h:277
Thread storage duration.
Definition: Specifiers.h:275
Kind
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:120
bool isLegalForVariable(StorageClass SC)
Checks whether the given storage class is legal for variables.
Definition: Specifiers.h:220
GNU __thread.
Definition: Specifiers.h:192
Direct list-initialization.
Definition: Specifiers.h:228
This template specialization was instantiated from a template due to an explicit instantiation defini...
Definition: Specifiers.h:160
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
Definition: Specifiers.h:145
ParameterABI
Kinds of parameter ABI.
Definition: Specifiers.h:298
C++11 thread_local.
Definition: Specifiers.h:195
This template specialization was instantiated from a template due to an explicit instantiation declar...
Definition: Specifiers.h:156
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:142
This template specialization was declared or defined by an explicit specialization (C++ [temp...
Definition: Specifiers.h:152
llvm::StringRef getParameterABISpelling(ParameterABI kind)
A bitfield object is a bitfield on a C or C++ record.
Definition: Specifiers.h:125
Structure that packs information about the type specifiers that were written in a particular type spe...
Definition: Specifiers.h:84
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Definition: Specifiers.h:189
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
Definition: Specifiers.h:25
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:44
Full-expression storage duration (for temporaries).
Definition: Specifiers.h:273
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:110
Automatic storage duration (most local variables).
Definition: Specifiers.h:274
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
No in-class initializer.
Definition: Specifiers.h:226
This parameter (which must have pointer type) is a Swift indirect result parameter.