• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_error         // erroneous type
66   };
67 
68   /// \brief Structure that packs information about the type specifiers that
69   /// were written in a particular type specifier sequence.
70   struct WrittenBuiltinSpecs {
71     /*DeclSpec::TST*/ unsigned Type  : 5;
72     /*DeclSpec::TSS*/ unsigned Sign  : 2;
73     /*DeclSpec::TSW*/ unsigned Width : 2;
74     bool ModeAttr : 1;
75   };
76 
77   /// \brief A C++ access specifier (public, private, protected), plus the
78   /// special value "none" which means different things in different contexts.
79   enum AccessSpecifier {
80     AS_public,
81     AS_protected,
82     AS_private,
83     AS_none
84   };
85 
86   /// \brief The categorization of expression values, currently following the
87   /// C++11 scheme.
88   enum ExprValueKind {
89     /// \brief An r-value expression (a pr-value in the C++11 taxonomy)
90     /// produces a temporary value.
91     VK_RValue,
92 
93     /// \brief An l-value expression is a reference to an object with
94     /// independent storage.
95     VK_LValue,
96 
97     /// \brief 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   /// \brief 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
120     /// object 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   /// \brief 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   /// \brief Checks whether the given storage class is legal for variables.
isLegalForVariable(StorageClass SC)168   inline bool isLegalForVariable(StorageClass SC) {
169     return true;
170   }
171 
172   /// \brief In-class initialization styles for non-static data members.
173   enum InClassInitStyle {
174     ICIS_NoInit,   ///< No in-class initializer.
175     ICIS_CopyInit, ///< Copy initialization.
176     ICIS_ListInit  ///< Direct list-initialization.
177   };
178 } // end namespace clang
179 
180 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H
181