clang API Documentation

Specifiers.h
Go to the documentation of this file.
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 // This file defines various enumerations that describe declaration and
00011 // type specifiers.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_CLANG_BASIC_SPECIFIERS_H
00016 #define LLVM_CLANG_BASIC_SPECIFIERS_H
00017 
00018 namespace clang {
00019   /// \brief Specifies the width of a type, e.g., short, long, or long long.
00020   enum TypeSpecifierWidth {
00021     TSW_unspecified,
00022     TSW_short,
00023     TSW_long,
00024     TSW_longlong
00025   };
00026   
00027   /// \brief Specifies the signedness of a type, e.g., signed or unsigned.
00028   enum TypeSpecifierSign {
00029     TSS_unspecified,
00030     TSS_signed,
00031     TSS_unsigned
00032   };
00033   
00034   /// \brief Specifies the kind of type.
00035   enum TypeSpecifierType {
00036     TST_unspecified,
00037     TST_void,
00038     TST_char,
00039     TST_wchar,        // C++ wchar_t
00040     TST_char16,       // C++0x char16_t
00041     TST_char32,       // C++0x char32_t
00042     TST_int,
00043     TST_int128,
00044     TST_half,         // OpenCL half, ARM NEON __fp16
00045     TST_float,
00046     TST_double,
00047     TST_bool,         // _Bool
00048     TST_decimal32,    // _Decimal32
00049     TST_decimal64,    // _Decimal64
00050     TST_decimal128,   // _Decimal128
00051     TST_enum,
00052     TST_union,
00053     TST_struct,
00054     TST_class,        // C++ class type
00055     TST_typename,     // Typedef, C++ class-name or enum name, etc.
00056     TST_typeofType,
00057     TST_typeofExpr,
00058     TST_decltype,     // C++0x decltype
00059     TST_underlyingType, // __underlying_type for C++0x
00060     TST_auto,         // C++0x auto
00061     TST_unknown_anytype, // __unknown_anytype extension
00062     TST_atomic,       // C11 _Atomic
00063     TST_error         // erroneous type
00064   };
00065   
00066   /// WrittenBuiltinSpecs - Structure that packs information about the 
00067   /// type specifiers that were written in a particular type specifier
00068   /// sequence.
00069   struct WrittenBuiltinSpecs {
00070     /*DeclSpec::TST*/ unsigned Type  : 5;
00071     /*DeclSpec::TSS*/ unsigned Sign  : 2;
00072     /*DeclSpec::TSW*/ unsigned Width : 2;
00073     bool ModeAttr : 1;
00074   };  
00075 
00076   /// AccessSpecifier - A C++ access specifier (public, private,
00077   /// protected), plus the special value "none" which means
00078   /// different things in different contexts.
00079   enum AccessSpecifier {
00080     AS_public,
00081     AS_protected,
00082     AS_private,
00083     AS_none
00084   };
00085 
00086   /// ExprValueKind - The categorization of expression values,
00087   /// currently following the C++0x scheme.
00088   enum ExprValueKind {
00089     /// An r-value expression (a pr-value in the C++0x taxonomy)
00090     /// produces a temporary value.
00091     VK_RValue,
00092 
00093     /// An l-value expression is a reference to an object with
00094     /// independent storage.
00095     VK_LValue,
00096 
00097     /// An x-value expression is a reference to an object with
00098     /// independent storage but which can be "moved", i.e.
00099     /// efficiently cannibalized for its resources.
00100     VK_XValue
00101   };
00102 
00103   /// A further classification of the kind of object referenced by an
00104   /// l-value or x-value.
00105   enum ExprObjectKind {
00106     /// An ordinary object is located at an address in memory.
00107     OK_Ordinary,
00108 
00109     /// A bitfield object is a bitfield on a C or C++ record.
00110     OK_BitField,
00111 
00112     /// A vector component is an element or range of elements on a vector.
00113     OK_VectorComponent,
00114 
00115     /// An Objective C property is a logical field of an Objective-C
00116     /// object which is read and written via Objective C method calls.
00117     OK_ObjCProperty,
00118     
00119     /// An Objective C array/dictionary subscripting which reads an object
00120     /// or writes at the subscripted array/dictionary element via
00121     /// Objective C method calls.
00122     OK_ObjCSubscript
00123   };
00124 
00125   // \brief Describes the kind of template specialization that a
00126   // particular template specialization declaration represents.
00127   enum TemplateSpecializationKind {
00128     /// This template specialization was formed from a template-id but
00129     /// has not yet been declared, defined, or instantiated.
00130     TSK_Undeclared = 0,
00131     /// This template specialization was implicitly instantiated from a
00132     /// template. (C++ [temp.inst]).
00133     TSK_ImplicitInstantiation,
00134     /// This template specialization was declared or defined by an
00135     /// explicit specialization (C++ [temp.expl.spec]) or partial
00136     /// specialization (C++ [temp.class.spec]).
00137     TSK_ExplicitSpecialization,
00138     /// This template specialization was instantiated from a template
00139     /// due to an explicit instantiation declaration request
00140     /// (C++0x [temp.explicit]).
00141     TSK_ExplicitInstantiationDeclaration,
00142     /// This template specialization was instantiated from a template
00143     /// due to an explicit instantiation definition request
00144     /// (C++ [temp.explicit]).
00145     TSK_ExplicitInstantiationDefinition
00146   };
00147 
00148   /// \brief Storage classes.
00149   enum StorageClass {
00150     // These are legal on both functions and variables.
00151     SC_None,
00152     SC_Extern,
00153     SC_Static,
00154     SC_PrivateExtern,
00155 
00156     // These are only legal on variables.
00157     SC_OpenCLWorkGroupLocal,
00158     SC_Auto,
00159     SC_Register
00160   };
00161 
00162   /// Checks whether the given storage class is legal for functions.
00163   inline bool isLegalForFunction(StorageClass SC) {
00164     return SC <= SC_PrivateExtern;
00165   }
00166 
00167   /// Checks whether the given storage class is legal for variables.
00168   inline bool isLegalForVariable(StorageClass SC) {
00169     return true;
00170   }
00171 } // end namespace clang
00172 
00173 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H