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