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 namespace clang { 20 /// \brief Specifies the width of a type, e.g., short, long, or long long. 21 enum TypeSpecifierWidth { 22 TSW_unspecified, 23 TSW_short, 24 TSW_long, 25 TSW_longlong 26 }; 27 28 /// \brief Specifies the signedness of a type, e.g., signed or unsigned. 29 enum TypeSpecifierSign { 30 TSS_unspecified, 31 TSS_signed, 32 TSS_unsigned 33 }; 34 35 /// \brief Specifies the kind of type. 36 enum TypeSpecifierType { 37 TST_unspecified, 38 TST_void, 39 TST_char, 40 TST_wchar, // C++ wchar_t 41 TST_char16, // C++11 char16_t 42 TST_char32, // C++11 char32_t 43 TST_int, 44 TST_int128, 45 TST_half, // OpenCL half, ARM NEON __fp16 46 TST_float, 47 TST_double, 48 TST_bool, // _Bool 49 TST_decimal32, // _Decimal32 50 TST_decimal64, // _Decimal64 51 TST_decimal128, // _Decimal128 52 TST_enum, 53 TST_union, 54 TST_struct, 55 TST_class, // C++ class type 56 TST_interface, // C++ (Microsoft-specific) __interface type 57 TST_typename, // Typedef, C++ class-name or enum name, etc. 58 TST_typeofType, 59 TST_typeofExpr, 60 TST_decltype, // C++11 decltype 61 TST_underlyingType, // __underlying_type for C++11 62 TST_auto, // C++11 auto 63 TST_decltype_auto, // C++1y decltype(auto) 64 TST_unknown_anytype, // __unknown_anytype extension 65 TST_atomic, // C11 _Atomic 66 TST_error // erroneous type 67 }; 68 69 /// \brief Structure that packs information about the type specifiers that 70 /// were written in a particular type specifier sequence. 71 struct WrittenBuiltinSpecs { 72 /*DeclSpec::TST*/ unsigned Type : 5; 73 /*DeclSpec::TSS*/ unsigned Sign : 2; 74 /*DeclSpec::TSW*/ unsigned Width : 2; 75 bool ModeAttr : 1; 76 }; 77 78 /// \brief A C++ access specifier (public, private, protected), plus the 79 /// special value "none" which means different things in different contexts. 80 enum AccessSpecifier { 81 AS_public, 82 AS_protected, 83 AS_private, 84 AS_none 85 }; 86 87 /// \brief The categorization of expression values, currently following the 88 /// C++11 scheme. 89 enum ExprValueKind { 90 /// \brief An r-value expression (a pr-value in the C++11 taxonomy) 91 /// produces a temporary value. 92 VK_RValue, 93 94 /// \brief An l-value expression is a reference to an object with 95 /// independent storage. 96 VK_LValue, 97 98 /// \brief An x-value expression is a reference to an object with 99 /// independent storage but which can be "moved", i.e. 100 /// efficiently cannibalized for its resources. 101 VK_XValue 102 }; 103 104 /// \brief A further classification of the kind of object referenced by an 105 /// l-value or x-value. 106 enum ExprObjectKind { 107 /// An ordinary object is located at an address in memory. 108 OK_Ordinary, 109 110 /// A bitfield object is a bitfield on a C or C++ record. 111 OK_BitField, 112 113 /// A vector component is an element or range of elements on a vector. 114 OK_VectorComponent, 115 116 /// An Objective-C property is a logical field of an Objective-C 117 /// object which is read and written via Objective-C method calls. 118 OK_ObjCProperty, 119 120 /// An Objective-C array/dictionary subscripting which reads an 121 /// object or writes at the subscripted array/dictionary element via 122 /// Objective-C method calls. 123 OK_ObjCSubscript 124 }; 125 126 /// \brief Describes the kind of template specialization that a 127 /// particular template specialization declaration represents. 128 enum TemplateSpecializationKind { 129 /// This template specialization was formed from a template-id but 130 /// has not yet been declared, defined, or instantiated. 131 TSK_Undeclared = 0, 132 /// This template specialization was implicitly instantiated from a 133 /// template. (C++ [temp.inst]). 134 TSK_ImplicitInstantiation, 135 /// This template specialization was declared or defined by an 136 /// explicit specialization (C++ [temp.expl.spec]) or partial 137 /// specialization (C++ [temp.class.spec]). 138 TSK_ExplicitSpecialization, 139 /// This template specialization was instantiated from a template 140 /// due to an explicit instantiation declaration request 141 /// (C++11 [temp.explicit]). 142 TSK_ExplicitInstantiationDeclaration, 143 /// This template specialization was instantiated from a template 144 /// due to an explicit instantiation definition request 145 /// (C++ [temp.explicit]). 146 TSK_ExplicitInstantiationDefinition 147 }; 148 149 /// \brief Determine whether this template specialization kind refers 150 /// to an instantiation of an entity (as opposed to a non-template or 151 /// an explicit specialization). isTemplateInstantiation(TemplateSpecializationKind Kind)152 inline bool isTemplateInstantiation(TemplateSpecializationKind Kind) { 153 return Kind != TSK_Undeclared && Kind != TSK_ExplicitSpecialization; 154 } 155 156 /// \brief Thread storage-class-specifier. 157 enum ThreadStorageClassSpecifier { 158 TSCS_unspecified, 159 /// GNU __thread. 160 TSCS___thread, 161 /// C++11 thread_local. Implies 'static' at block scope, but not at 162 /// class scope. 163 TSCS_thread_local, 164 /// C11 _Thread_local. Must be combined with either 'static' or 'extern' 165 /// if used at block scope. 166 TSCS__Thread_local 167 }; 168 169 /// \brief Storage classes. 170 enum StorageClass { 171 // These are legal on both functions and variables. 172 SC_None, 173 SC_Extern, 174 SC_Static, 175 SC_PrivateExtern, 176 177 // These are only legal on variables. 178 SC_OpenCLWorkGroupLocal, 179 SC_Auto, 180 SC_Register 181 }; 182 183 /// \brief Checks whether the given storage class is legal for functions. isLegalForFunction(StorageClass SC)184 inline bool isLegalForFunction(StorageClass SC) { 185 return SC <= SC_PrivateExtern; 186 } 187 188 /// \brief Checks whether the given storage class is legal for variables. isLegalForVariable(StorageClass SC)189 inline bool isLegalForVariable(StorageClass SC) { 190 return true; 191 } 192 193 /// \brief In-class initialization styles for non-static data members. 194 enum InClassInitStyle { 195 ICIS_NoInit, ///< No in-class initializer. 196 ICIS_CopyInit, ///< Copy initialization. 197 ICIS_ListInit ///< Direct list-initialization. 198 }; 199 200 /// \brief CallingConv - Specifies the calling convention that a function uses. 201 enum CallingConv { 202 CC_C, // __attribute__((cdecl)) 203 CC_X86StdCall, // __attribute__((stdcall)) 204 CC_X86FastCall, // __attribute__((fastcall)) 205 CC_X86ThisCall, // __attribute__((thiscall)) 206 CC_X86Pascal, // __attribute__((pascal)) 207 CC_X86_64Win64, // __attribute__((ms_abi)) 208 CC_X86_64SysV, // __attribute__((sysv_abi)) 209 CC_AAPCS, // __attribute__((pcs("aapcs"))) 210 CC_AAPCS_VFP, // __attribute__((pcs("aapcs-vfp"))) 211 CC_PnaclCall, // __attribute__((pnaclcall)) 212 CC_IntelOclBicc // __attribute__((intel_ocl_bicc)) 213 }; 214 215 /// \brief Checks whether the given calling convention is callee-cleanup. isCalleeCleanup(CallingConv CC)216 inline bool isCalleeCleanup(CallingConv CC) { 217 switch (CC) { 218 case CC_X86StdCall: 219 case CC_X86FastCall: 220 case CC_X86ThisCall: 221 case CC_X86Pascal: 222 return true; 223 default: 224 return false; 225 } 226 } 227 228 /// \brief The storage duration for an object (per C++ [basic.stc]). 229 enum StorageDuration { 230 SD_FullExpression, ///< Full-expression storage duration (for temporaries). 231 SD_Automatic, ///< Automatic storage duration (most local variables). 232 SD_Thread, ///< Thread storage duration. 233 SD_Static, ///< Static storage duration. 234 SD_Dynamic ///< Dynamic storage duration. 235 }; 236 } // end namespace clang 237 238 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H 239