• 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 // 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_float,
44     TST_double,
45     TST_bool,         // _Bool
46     TST_decimal32,    // _Decimal32
47     TST_decimal64,    // _Decimal64
48     TST_decimal128,   // _Decimal128
49     TST_enum,
50     TST_union,
51     TST_struct,
52     TST_class,        // C++ class type
53     TST_typename,     // Typedef, C++ class-name or enum name, etc.
54     TST_typeofType,
55     TST_typeofExpr,
56     TST_decltype,     // C++0x decltype
57     TST_underlyingType, // __underlying_type for C++0x
58     TST_auto,         // C++0x auto
59     TST_unknown_anytype, // __unknown_anytype extension
60     TST_error         // erroneous type
61   };
62 
63   /// WrittenBuiltinSpecs - Structure that packs information about the
64   /// type specifiers that were written in a particular type specifier
65   /// sequence.
66   struct WrittenBuiltinSpecs {
67     /*DeclSpec::TST*/ unsigned Type  : 5;
68     /*DeclSpec::TSS*/ unsigned Sign  : 2;
69     /*DeclSpec::TSW*/ unsigned Width : 2;
70     bool ModeAttr : 1;
71   };
72 
73   /// AccessSpecifier - A C++ access specifier (public, private,
74   /// protected), plus the special value "none" which means
75   /// different things in different contexts.
76   enum AccessSpecifier {
77     AS_public,
78     AS_protected,
79     AS_private,
80     AS_none
81   };
82 
83   /// ExprValueKind - The categorization of expression values,
84   /// currently following the C++0x scheme.
85   enum ExprValueKind {
86     /// An r-value expression (a pr-value in the C++0x taxonomy)
87     /// produces a temporary value.
88     VK_RValue,
89 
90     /// An l-value expression is a reference to an object with
91     /// independent storage.
92     VK_LValue,
93 
94     /// An x-value expression is a reference to an object with
95     /// independent storage but which can be "moved", i.e.
96     /// efficiently cannibalized for its resources.
97     VK_XValue
98   };
99 
100   /// A further classification of the kind of object referenced by an
101   /// l-value or x-value.
102   enum ExprObjectKind {
103     /// An ordinary object is located at an address in memory.
104     OK_Ordinary,
105 
106     /// A bitfield object is a bitfield on a C or C++ record.
107     OK_BitField,
108 
109     /// A vector component is an element or range of elements on a vector.
110     OK_VectorComponent,
111 
112     /// An Objective C property is a logical field of an Objective-C
113     /// object which is read and written via Objective C method calls.
114     OK_ObjCProperty
115   };
116 
117   // \brief Describes the kind of template specialization that a
118   // particular template specialization declaration represents.
119   enum TemplateSpecializationKind {
120     /// This template specialization was formed from a template-id but
121     /// has not yet been declared, defined, or instantiated.
122     TSK_Undeclared = 0,
123     /// This template specialization was implicitly instantiated from a
124     /// template. (C++ [temp.inst]).
125     TSK_ImplicitInstantiation,
126     /// This template specialization was declared or defined by an
127     /// explicit specialization (C++ [temp.expl.spec]) or partial
128     /// specialization (C++ [temp.class.spec]).
129     TSK_ExplicitSpecialization,
130     /// This template specialization was instantiated from a template
131     /// due to an explicit instantiation declaration request
132     /// (C++0x [temp.explicit]).
133     TSK_ExplicitInstantiationDeclaration,
134     /// This template specialization was instantiated from a template
135     /// due to an explicit instantiation definition request
136     /// (C++ [temp.explicit]).
137     TSK_ExplicitInstantiationDefinition
138   };
139 
140   /// \brief Storage classes.
141   enum StorageClass {
142     // These are legal on both functions and variables.
143     SC_None,
144     SC_Extern,
145     SC_Static,
146     SC_PrivateExtern,
147 
148     // These are only legal on variables.
149     SC_Auto,
150     SC_Register
151   };
152 
153   /// Checks whether the given storage class is legal for functions.
isLegalForFunction(StorageClass SC)154   inline bool isLegalForFunction(StorageClass SC) {
155     return SC <= SC_PrivateExtern;
156   }
157 
158   /// Checks whether the given storage class is legal for variables.
isLegalForVariable(StorageClass SC)159   inline bool isLegalForVariable(StorageClass SC) {
160     return true;
161   }
162 } // end namespace clang
163 
164 #endif // LLVM_CLANG_BASIC_SPECIFIERS_H
165