Home | History | Annotate | Download | only in Basic
      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++0x char16_t
     42     TST_char32,       // C++0x 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++0x decltype
     61     TST_underlyingType, // __underlying_type for C++0x
     62     TST_auto,         // C++0x auto
     63     TST_unknown_anytype, // __unknown_anytype extension
     64     TST_atomic,       // C11 _Atomic
     65     TST_image1d_t,        // OpenCL image1d_t
     66     TST_image1d_array_t,  // OpenCL image1d_array_t
     67     TST_image1d_buffer_t, // OpenCL image1d_buffer_t
     68     TST_image2d_t,        // OpenCL image2d_t
     69     TST_image2d_array_t,  // OpenCL image2d_array_t
     70     TST_image3d_t,        // OpenCL image3d_t
     71     TST_sampler_t,        // OpenCL sampler_t
     72     TST_event_t,          // OpenCL event_t
     73     TST_error         // erroneous type
     74   };
     75 
     76   /// \brief Structure that packs information about the type specifiers that
     77   /// were written in a particular type specifier sequence.
     78   struct WrittenBuiltinSpecs {
     79     /*DeclSpec::TST*/ unsigned Type  : 6;
     80     /*DeclSpec::TSS*/ unsigned Sign  : 2;
     81     /*DeclSpec::TSW*/ unsigned Width : 2;
     82     bool ModeAttr : 1;
     83   };
     84 
     85   /// \brief A C++ access specifier (public, private, protected), plus the
     86   /// special value "none" which means different things in different contexts.
     87   enum AccessSpecifier {
     88     AS_public,
     89     AS_protected,
     90     AS_private,
     91     AS_none
     92   };
     93 
     94   /// \brief The categorization of expression values, currently following the
     95   /// C++11 scheme.
     96   enum ExprValueKind {
     97     /// \brief An r-value expression (a pr-value in the C++11 taxonomy)
     98     /// produces a temporary value.
     99     VK_RValue,
    100 
    101     /// \brief An l-value expression is a reference to an object with
    102     /// independent storage.
    103     VK_LValue,
    104 
    105     /// \brief An x-value expression is a reference to an object with
    106     /// independent storage but which can be "moved", i.e.
    107     /// efficiently cannibalized for its resources.
    108     VK_XValue
    109   };
    110 
    111   /// \brief A further classification of the kind of object referenced by an
    112   /// l-value or x-value.
    113   enum ExprObjectKind {
    114     /// An ordinary object is located at an address in memory.
    115     OK_Ordinary,
    116 
    117     /// A bitfield object is a bitfield on a C or C++ record.
    118     OK_BitField,
    119 
    120     /// A vector component is an element or range of elements on a vector.
    121     OK_VectorComponent,
    122 
    123     /// An Objective-C property is a logical field of an Objective-C
    124     /// object which is read and written via Objective-C method calls.
    125     OK_ObjCProperty,
    126 
    127     /// An Objective-C array/dictionary subscripting which reads an
    128     /// object or writes at the subscripted array/dictionary element via
    129     /// Objective-C method calls.
    130     OK_ObjCSubscript
    131   };
    132 
    133   // \brief Describes the kind of template specialization that a
    134   // particular template specialization declaration represents.
    135   enum TemplateSpecializationKind {
    136     /// This template specialization was formed from a template-id but
    137     /// has not yet been declared, defined, or instantiated.
    138     TSK_Undeclared = 0,
    139     /// This template specialization was implicitly instantiated from a
    140     /// template. (C++ [temp.inst]).
    141     TSK_ImplicitInstantiation,
    142     /// This template specialization was declared or defined by an
    143     /// explicit specialization (C++ [temp.expl.spec]) or partial
    144     /// specialization (C++ [temp.class.spec]).
    145     TSK_ExplicitSpecialization,
    146     /// This template specialization was instantiated from a template
    147     /// due to an explicit instantiation declaration request
    148     /// (C++0x [temp.explicit]).
    149     TSK_ExplicitInstantiationDeclaration,
    150     /// This template specialization was instantiated from a template
    151     /// due to an explicit instantiation definition request
    152     /// (C++ [temp.explicit]).
    153     TSK_ExplicitInstantiationDefinition
    154   };
    155 
    156   /// \brief Storage classes.
    157   enum StorageClass {
    158     // These are legal on both functions and variables.
    159     SC_None,
    160     SC_Extern,
    161     SC_Static,
    162     SC_PrivateExtern,
    163 
    164     // These are only legal on variables.
    165     SC_OpenCLWorkGroupLocal,
    166     SC_Auto,
    167     SC_Register
    168   };
    169 
    170   /// \brief Checks whether the given storage class is legal for functions.
    171   inline bool isLegalForFunction(StorageClass SC) {
    172     return SC <= SC_PrivateExtern;
    173   }
    174 
    175   /// \brief Checks whether the given storage class is legal for variables.
    176   inline bool isLegalForVariable(StorageClass SC) {
    177     return true;
    178   }
    179 
    180   /// \brief In-class initialization styles for non-static data members.
    181   enum InClassInitStyle {
    182     ICIS_NoInit,   ///< No in-class initializer.
    183     ICIS_CopyInit, ///< Copy initialization.
    184     ICIS_ListInit  ///< Direct list-initialization.
    185   };
    186 
    187   /// \brief CallingConv - Specifies the calling convention that a function uses.
    188   enum CallingConv {
    189     CC_Default,
    190     CC_C,           // __attribute__((cdecl))
    191     CC_X86StdCall,  // __attribute__((stdcall))
    192     CC_X86FastCall, // __attribute__((fastcall))
    193     CC_X86ThisCall, // __attribute__((thiscall))
    194     CC_X86Pascal,   // __attribute__((pascal))
    195     CC_AAPCS,       // __attribute__((pcs("aapcs")))
    196     CC_AAPCS_VFP,   // __attribute__((pcs("aapcs-vfp")))
    197     CC_PnaclCall,   // __attribute__((pnaclcall))
    198     CC_IntelOclBicc // __attribute__((intel_ocl_bicc))
    199   };
    200 
    201 } // end namespace clang
    202 
    203 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H
    204