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 // This file defines various enumerations that describe declaration and 11 // type specifiers. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_CLANG_BASIC_SPECIFIERS_H 16 #define LLVM_CLANG_BASIC_SPECIFIERS_H 17 18 namespace clang { 19 /// \brief Specifies the width of a type, e.g., short, long, or long long. 20 enum TypeSpecifierWidth { 21 TSW_unspecified, 22 TSW_short, 23 TSW_long, 24 TSW_longlong 25 }; 26 27 /// \brief Specifies the signedness of a type, e.g., signed or unsigned. 28 enum TypeSpecifierSign { 29 TSS_unspecified, 30 TSS_signed, 31 TSS_unsigned 32 }; 33 34 /// \brief Specifies the kind of type. 35 enum TypeSpecifierType { 36 TST_unspecified, 37 TST_void, 38 TST_char, 39 TST_wchar, // C++ wchar_t 40 TST_char16, // C++0x char16_t 41 TST_char32, // C++0x char32_t 42 TST_int, 43 TST_int128, 44 TST_half, // OpenCL half, ARM NEON __fp16 45 TST_float, 46 TST_double, 47 TST_bool, // _Bool 48 TST_decimal32, // _Decimal32 49 TST_decimal64, // _Decimal64 50 TST_decimal128, // _Decimal128 51 TST_enum, 52 TST_union, 53 TST_struct, 54 TST_class, // C++ class type 55 TST_typename, // Typedef, C++ class-name or enum name, etc. 56 TST_typeofType, 57 TST_typeofExpr, 58 TST_decltype, // C++0x decltype 59 TST_underlyingType, // __underlying_type for C++0x 60 TST_auto, // C++0x auto 61 TST_unknown_anytype, // __unknown_anytype extension 62 TST_atomic, // C11 _Atomic 63 TST_error // erroneous type 64 }; 65 66 /// WrittenBuiltinSpecs - Structure that packs information about the 67 /// type specifiers that were written in a particular type specifier 68 /// sequence. 69 struct WrittenBuiltinSpecs { 70 /*DeclSpec::TST*/ unsigned Type : 5; 71 /*DeclSpec::TSS*/ unsigned Sign : 2; 72 /*DeclSpec::TSW*/ unsigned Width : 2; 73 bool ModeAttr : 1; 74 }; 75 76 /// AccessSpecifier - A C++ access specifier (public, private, 77 /// protected), plus the special value "none" which means 78 /// different things in different contexts. 79 enum AccessSpecifier { 80 AS_public, 81 AS_protected, 82 AS_private, 83 AS_none 84 }; 85 86 /// ExprValueKind - The categorization of expression values, 87 /// currently following the C++0x scheme. 88 enum ExprValueKind { 89 /// An r-value expression (a pr-value in the C++0x taxonomy) 90 /// produces a temporary value. 91 VK_RValue, 92 93 /// An l-value expression is a reference to an object with 94 /// independent storage. 95 VK_LValue, 96 97 /// An x-value expression is a reference to an object with 98 /// independent storage but which can be "moved", i.e. 99 /// efficiently cannibalized for its resources. 100 VK_XValue 101 }; 102 103 /// A further classification of the kind of object referenced by an 104 /// l-value or x-value. 105 enum ExprObjectKind { 106 /// An ordinary object is located at an address in memory. 107 OK_Ordinary, 108 109 /// A bitfield object is a bitfield on a C or C++ record. 110 OK_BitField, 111 112 /// A vector component is an element or range of elements on a vector. 113 OK_VectorComponent, 114 115 /// An Objective C property is a logical field of an Objective-C 116 /// object which is read and written via Objective C method calls. 117 OK_ObjCProperty, 118 119 /// An Objective C array/dictionary subscripting which reads an object 120 /// or writes at the subscripted array/dictionary element via 121 /// Objective C method calls. 122 OK_ObjCSubscript 123 }; 124 125 // \brief Describes the kind of template specialization that a 126 // particular template specialization declaration represents. 127 enum TemplateSpecializationKind { 128 /// This template specialization was formed from a template-id but 129 /// has not yet been declared, defined, or instantiated. 130 TSK_Undeclared = 0, 131 /// This template specialization was implicitly instantiated from a 132 /// template. (C++ [temp.inst]). 133 TSK_ImplicitInstantiation, 134 /// This template specialization was declared or defined by an 135 /// explicit specialization (C++ [temp.expl.spec]) or partial 136 /// specialization (C++ [temp.class.spec]). 137 TSK_ExplicitSpecialization, 138 /// This template specialization was instantiated from a template 139 /// due to an explicit instantiation declaration request 140 /// (C++0x [temp.explicit]). 141 TSK_ExplicitInstantiationDeclaration, 142 /// This template specialization was instantiated from a template 143 /// due to an explicit instantiation definition request 144 /// (C++ [temp.explicit]). 145 TSK_ExplicitInstantiationDefinition 146 }; 147 148 /// \brief Storage classes. 149 enum StorageClass { 150 // These are legal on both functions and variables. 151 SC_None, 152 SC_Extern, 153 SC_Static, 154 SC_PrivateExtern, 155 156 // These are only legal on variables. 157 SC_OpenCLWorkGroupLocal, 158 SC_Auto, 159 SC_Register 160 }; 161 162 /// Checks whether the given storage class is legal for functions. isLegalForFunction(StorageClass SC)163 inline bool isLegalForFunction(StorageClass SC) { 164 return SC <= SC_PrivateExtern; 165 } 166 167 /// Checks whether the given storage class is legal for variables. isLegalForVariable(StorageClass SC)168 inline bool isLegalForVariable(StorageClass SC) { 169 return true; 170 } 171 } // end namespace clang 172 173 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H 174