clang API Documentation
00001 //===--- Specifiers.h - Declaration and Type Specifiers ---------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 /// 00010 /// \file 00011 /// \brief Defines various enumerations that describe declaration and 00012 /// type specifiers. 00013 /// 00014 //===----------------------------------------------------------------------===// 00015 00016 #ifndef LLVM_CLANG_BASIC_SPECIFIERS_H 00017 #define LLVM_CLANG_BASIC_SPECIFIERS_H 00018 00019 namespace clang { 00020 /// \brief Specifies the width of a type, e.g., short, long, or long long. 00021 enum TypeSpecifierWidth { 00022 TSW_unspecified, 00023 TSW_short, 00024 TSW_long, 00025 TSW_longlong 00026 }; 00027 00028 /// \brief Specifies the signedness of a type, e.g., signed or unsigned. 00029 enum TypeSpecifierSign { 00030 TSS_unspecified, 00031 TSS_signed, 00032 TSS_unsigned 00033 }; 00034 00035 /// \brief Specifies the kind of type. 00036 enum TypeSpecifierType { 00037 TST_unspecified, 00038 TST_void, 00039 TST_char, 00040 TST_wchar, // C++ wchar_t 00041 TST_char16, // C++11 char16_t 00042 TST_char32, // C++11 char32_t 00043 TST_int, 00044 TST_int128, 00045 TST_half, // OpenCL half, ARM NEON __fp16 00046 TST_float, 00047 TST_double, 00048 TST_bool, // _Bool 00049 TST_decimal32, // _Decimal32 00050 TST_decimal64, // _Decimal64 00051 TST_decimal128, // _Decimal128 00052 TST_enum, 00053 TST_union, 00054 TST_struct, 00055 TST_class, // C++ class type 00056 TST_interface, // C++ (Microsoft-specific) __interface type 00057 TST_typename, // Typedef, C++ class-name or enum name, etc. 00058 TST_typeofType, 00059 TST_typeofExpr, 00060 TST_decltype, // C++11 decltype 00061 TST_underlyingType, // __underlying_type for C++11 00062 TST_auto, // C++11 auto 00063 TST_decltype_auto, // C++1y decltype(auto) 00064 TST_unknown_anytype, // __unknown_anytype extension 00065 TST_atomic, // C11 _Atomic 00066 TST_error // erroneous type 00067 }; 00068 00069 /// \brief Structure that packs information about the type specifiers that 00070 /// were written in a particular type specifier sequence. 00071 struct WrittenBuiltinSpecs { 00072 /*DeclSpec::TST*/ unsigned Type : 5; 00073 /*DeclSpec::TSS*/ unsigned Sign : 2; 00074 /*DeclSpec::TSW*/ unsigned Width : 2; 00075 bool ModeAttr : 1; 00076 }; 00077 00078 /// \brief A C++ access specifier (public, private, protected), plus the 00079 /// special value "none" which means different things in different contexts. 00080 enum AccessSpecifier { 00081 AS_public, 00082 AS_protected, 00083 AS_private, 00084 AS_none 00085 }; 00086 00087 /// \brief The categorization of expression values, currently following the 00088 /// C++11 scheme. 00089 enum ExprValueKind { 00090 /// \brief An r-value expression (a pr-value in the C++11 taxonomy) 00091 /// produces a temporary value. 00092 VK_RValue, 00093 00094 /// \brief An l-value expression is a reference to an object with 00095 /// independent storage. 00096 VK_LValue, 00097 00098 /// \brief An x-value expression is a reference to an object with 00099 /// independent storage but which can be "moved", i.e. 00100 /// efficiently cannibalized for its resources. 00101 VK_XValue 00102 }; 00103 00104 /// \brief A further classification of the kind of object referenced by an 00105 /// l-value or x-value. 00106 enum ExprObjectKind { 00107 /// An ordinary object is located at an address in memory. 00108 OK_Ordinary, 00109 00110 /// A bitfield object is a bitfield on a C or C++ record. 00111 OK_BitField, 00112 00113 /// A vector component is an element or range of elements on a vector. 00114 OK_VectorComponent, 00115 00116 /// An Objective-C property is a logical field of an Objective-C 00117 /// object which is read and written via Objective-C method calls. 00118 OK_ObjCProperty, 00119 00120 /// An Objective-C array/dictionary subscripting which reads an 00121 /// object or writes at the subscripted array/dictionary element via 00122 /// Objective-C method calls. 00123 OK_ObjCSubscript 00124 }; 00125 00126 /// \brief Describes the kind of template specialization that a 00127 /// particular template specialization declaration represents. 00128 enum TemplateSpecializationKind { 00129 /// This template specialization was formed from a template-id but 00130 /// has not yet been declared, defined, or instantiated. 00131 TSK_Undeclared = 0, 00132 /// This template specialization was implicitly instantiated from a 00133 /// template. (C++ [temp.inst]). 00134 TSK_ImplicitInstantiation, 00135 /// This template specialization was declared or defined by an 00136 /// explicit specialization (C++ [temp.expl.spec]) or partial 00137 /// specialization (C++ [temp.class.spec]). 00138 TSK_ExplicitSpecialization, 00139 /// This template specialization was instantiated from a template 00140 /// due to an explicit instantiation declaration request 00141 /// (C++11 [temp.explicit]). 00142 TSK_ExplicitInstantiationDeclaration, 00143 /// This template specialization was instantiated from a template 00144 /// due to an explicit instantiation definition request 00145 /// (C++ [temp.explicit]). 00146 TSK_ExplicitInstantiationDefinition 00147 }; 00148 00149 /// \brief Determine whether this template specialization kind refers 00150 /// to an instantiation of an entity (as opposed to a non-template or 00151 /// an explicit specialization). 00152 inline bool isTemplateInstantiation(TemplateSpecializationKind Kind) { 00153 return Kind != TSK_Undeclared && Kind != TSK_ExplicitSpecialization; 00154 } 00155 00156 /// \brief Thread storage-class-specifier. 00157 enum ThreadStorageClassSpecifier { 00158 TSCS_unspecified, 00159 /// GNU __thread. 00160 TSCS___thread, 00161 /// C++11 thread_local. Implies 'static' at block scope, but not at 00162 /// class scope. 00163 TSCS_thread_local, 00164 /// C11 _Thread_local. Must be combined with either 'static' or 'extern' 00165 /// if used at block scope. 00166 TSCS__Thread_local 00167 }; 00168 00169 /// \brief Storage classes. 00170 enum StorageClass { 00171 // These are legal on both functions and variables. 00172 SC_None, 00173 SC_Extern, 00174 SC_Static, 00175 SC_PrivateExtern, 00176 00177 // These are only legal on variables. 00178 SC_OpenCLWorkGroupLocal, 00179 SC_Auto, 00180 SC_Register 00181 }; 00182 00183 /// \brief Checks whether the given storage class is legal for functions. 00184 inline bool isLegalForFunction(StorageClass SC) { 00185 return SC <= SC_PrivateExtern; 00186 } 00187 00188 /// \brief Checks whether the given storage class is legal for variables. 00189 inline bool isLegalForVariable(StorageClass SC) { 00190 return true; 00191 } 00192 00193 /// \brief In-class initialization styles for non-static data members. 00194 enum InClassInitStyle { 00195 ICIS_NoInit, ///< No in-class initializer. 00196 ICIS_CopyInit, ///< Copy initialization. 00197 ICIS_ListInit ///< Direct list-initialization. 00198 }; 00199 00200 /// \brief CallingConv - Specifies the calling convention that a function uses. 00201 enum CallingConv { 00202 CC_C, // __attribute__((cdecl)) 00203 CC_X86StdCall, // __attribute__((stdcall)) 00204 CC_X86FastCall, // __attribute__((fastcall)) 00205 CC_X86ThisCall, // __attribute__((thiscall)) 00206 CC_X86VectorCall, // __attribute__((vectorcall)) 00207 CC_X86Pascal, // __attribute__((pascal)) 00208 CC_X86_64Win64, // __attribute__((ms_abi)) 00209 CC_X86_64SysV, // __attribute__((sysv_abi)) 00210 CC_AAPCS, // __attribute__((pcs("aapcs"))) 00211 CC_AAPCS_VFP, // __attribute__((pcs("aapcs-vfp"))) 00212 CC_PnaclCall, // __attribute__((pnaclcall)) 00213 CC_IntelOclBicc // __attribute__((intel_ocl_bicc)) 00214 }; 00215 00216 /// \brief Checks whether the given calling convention supports variadic 00217 /// calls. Unprototyped calls also use the variadic call rules. 00218 inline bool supportsVariadicCall(CallingConv CC) { 00219 switch (CC) { 00220 case CC_X86StdCall: 00221 case CC_X86FastCall: 00222 case CC_X86ThisCall: 00223 case CC_X86Pascal: 00224 case CC_X86VectorCall: 00225 return false; 00226 default: 00227 return true; 00228 } 00229 } 00230 00231 /// \brief The storage duration for an object (per C++ [basic.stc]). 00232 enum StorageDuration { 00233 SD_FullExpression, ///< Full-expression storage duration (for temporaries). 00234 SD_Automatic, ///< Automatic storage duration (most local variables). 00235 SD_Thread, ///< Thread storage duration. 00236 SD_Static, ///< Static storage duration. 00237 SD_Dynamic ///< Dynamic storage duration. 00238 }; 00239 } // end namespace clang 00240 00241 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H