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