clang  3.7.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 
22 namespace clang {
23  /// \brief Specifies the width of a type, e.g., short, long, or long long.
29  };
30 
31  /// \brief Specifies the signedness of a type, e.g., signed or unsigned.
36  };
37 
38  /// \brief Specifies the kind of type.
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
51  TST_bool, // _Bool
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
70  };
71 
72  /// \brief Structure that packs information about the type specifiers that
73  /// were written in a particular type specifier sequence.
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.
88  };
89 
90  /// \brief The categorization of expression values, currently following the
91  /// C++11 scheme.
93  /// \brief An r-value expression (a pr-value in the C++11 taxonomy)
94  /// produces a temporary value.
96 
97  /// \brief An l-value expression is a reference to an object with
98  /// independent storage.
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.
105  };
106 
107  /// \brief A further classification of the kind of object referenced by an
108  /// l-value or x-value.
110  /// An ordinary object is located at an address in memory.
112 
113  /// A bitfield object is a bitfield on a C or C++ record.
115 
116  /// A vector component is an element or range of elements on a vector.
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.
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.
127  };
128 
129  /// \brief Describes the kind of template specialization that a
130  /// particular template specialization declaration represents.
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]).
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]).
142  /// This template specialization was instantiated from a template
143  /// due to an explicit instantiation declaration request
144  /// (C++11 [temp.explicit]).
146  /// This template specialization was instantiated from a template
147  /// due to an explicit instantiation definition request
148  /// (C++ [temp.explicit]).
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).
156  return Kind != TSK_Undeclared && Kind != TSK_ExplicitSpecialization;
157  }
158 
159  /// \brief Thread storage-class-specifier.
162  /// GNU __thread.
164  /// C++11 thread_local. Implies 'static' at block scope, but not at
165  /// class scope.
167  /// C11 _Thread_local. Must be combined with either 'static' or 'extern'
168  /// if used at block scope.
170  };
171 
172  /// \brief Storage classes.
174  // These are legal on both functions and variables.
179 
180  // These are only legal on variables.
184  };
185 
186  /// \brief Checks whether the given storage class is legal for functions.
188  return SC <= SC_PrivateExtern;
189  }
190 
191  /// \brief Checks whether the given storage class is legal for variables.
193  return true;
194  }
195 
196  /// \brief In-class initialization styles for non-static data members.
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.
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]).
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.
257  };
258 
259  /// Retrieve the spelling of the given nullability kind.
261  bool isContextSensitive = false);
262 } // end namespace clang
263 
264 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H
Static storage duration.
Definition: Specifiers.h:242
NullabilityKind
Describes the nullability of a particular type.
Definition: Specifiers.h:247
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:83
StorageDuration
The storage duration for an object (per C++ [basic.stc]).
Definition: Specifiers.h:238
TypeSpecifierType
Specifies the kind of type.
Definition: Specifiers.h:39
A vector component is an element or range of elements on a vector.
Definition: Specifiers.h:117
Copy initialization.
Definition: Specifiers.h:199
TypeSpecifierSign
Specifies the signedness of a type, e.g., signed or unsigned.
Definition: Specifiers.h:32
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:95
Values of this type can be null.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
Definition: Specifiers.h:104
Values of this type can never be null.
An ordinary object is located at an address in memory.
Definition: Specifiers.h:111
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:92
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls. Unprototyped calls also use the ...
Definition: Specifiers.h:222
StorageClass
Storage classes.
Definition: Specifiers.h:173
bool isLegalForFunction(StorageClass SC)
Checks whether the given storage class is legal for functions.
Definition: Specifiers.h:187
InClassInitStyle
In-class initialization styles for non-static data members.
Definition: Specifiers.h:197
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
Definition: Specifiers.h:155
CallingConv
CallingConv - Specifies the calling convention that a function uses.
Definition: Specifiers.h:204
Dynamic storage duration.
Definition: Specifiers.h:243
Thread storage duration.
Definition: Specifiers.h:241
Kind
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
Definition: Specifiers.h:109
bool isLegalForVariable(StorageClass SC)
Checks whether the given storage class is legal for variables.
Definition: Specifiers.h:192
GNU __thread.
Definition: Specifiers.h:163
Direct list-initialization.
Definition: Specifiers.h:200
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
Definition: Specifiers.h:131
A bitfield object is a bitfield on a C or C++ record.
Definition: Specifiers.h:114
Structure that packs information about the type specifiers that were written in a particular type spe...
Definition: Specifiers.h:74
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Definition: Specifiers.h:160
TypeSpecifierWidth
Specifies the width of a type, e.g., short, long, or long long.
Definition: Specifiers.h:24
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:239
An l-value expression is a reference to an object with independent storage.
Definition: Specifiers.h:99
Automatic storage duration (most local variables).
Definition: Specifiers.h:240
llvm::StringRef getNullabilitySpelling(NullabilityKind kind, bool isContextSensitive=false)
Retrieve the spelling of the given nullability kind.
No in-class initializer.
Definition: Specifiers.h:198