blob: bac81ece23a197757d2dc487f668713ab4727dd0 [file] [log] [blame]
Douglas Gregor2cf26342009-04-09 22:27:44 +00001//===- PCHBitCodes.h - Enum values for the PCH bitcode format ---*- 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 header defines Bitcode enum values for Clang precompiled header files.
11//
12// The enum values defined in this file should be considered permanent. If
13// new features are added, they should have values added at the end of the
14// respective lists.
15//
16//===----------------------------------------------------------------------===//
17#ifndef LLVM_CLANG_FRONTEND_PCHBITCODES_H
18#define LLVM_CLANG_FRONTEND_PCHBITCODES_H
19
20#include "llvm/Bitcode/BitCodes.h"
21#include "llvm/Support/DataTypes.h"
22
23namespace clang {
24 namespace pch {
Douglas Gregor8038d512009-04-10 17:25:41 +000025 /// \brief An ID number that refers to a declaration in a PCH file.
26 ///
27 /// The ID numbers of types are consecutive (in order of
28 /// discovery) and start at 2. 0 is reserved for NULL, and 1 is
29 /// reserved for the translation unit declaration.
30 typedef uint32_t DeclID;
31
32 /// \brief An ID number that refers to a type in a PCH file.
33 ///
34 /// The ID of a type is partitioned into two parts: the lower
35 /// three bits are used to store the const/volatile/restrict
36 /// qualifiers (as with QualType) and the upper bits provide a
37 /// type index. The type index values are partitioned into two
38 /// sets. The values below NUM_PREDEF_TYPE_IDs are predefined type
39 /// IDs (based on the PREDEF_TYPE_*_ID constants), with 0 as a
40 /// placeholder for "no type". Values from NUM_PREDEF_TYPE_IDs are
41 /// other types that have serialized representations.
42 typedef uint32_t TypeID;
Douglas Gregor2cf26342009-04-09 22:27:44 +000043
Douglas Gregorafaf3082009-04-11 00:14:32 +000044 /// \brief An ID number that refers to an identifier in a PCH
45 /// file.
46 typedef uint32_t IdentID;
47
Douglas Gregor2cf26342009-04-09 22:27:44 +000048 /// \brief Describes the various kinds of blocks that occur within
49 /// a PCH file.
50 enum BlockIDs {
51 /// \brief The PCH block, which acts as a container around the
52 /// full PCH block.
53 PCH_BLOCK_ID = llvm::bitc::FIRST_APPLICATION_BLOCKID,
Douglas Gregor14f79002009-04-10 03:52:48 +000054
Douglas Gregor14f79002009-04-10 03:52:48 +000055 /// \brief The block containing information about the source
56 /// manager.
57 SOURCE_MANAGER_BLOCK_ID,
58
59 /// \brief The block containing information about the
60 /// preprocessor.
61 PREPROCESSOR_BLOCK_ID,
62
Douglas Gregor2cf26342009-04-09 22:27:44 +000063 /// \brief The block containing the definitions of all of the
64 /// types used within the PCH file.
65 TYPES_BLOCK_ID,
66
Douglas Gregor2cf26342009-04-09 22:27:44 +000067 /// \brief The block containing the definitions of all of the
68 /// declarations stored in the PCH file.
Douglas Gregor8038d512009-04-10 17:25:41 +000069 DECLS_BLOCK_ID
70 };
Douglas Gregor2cf26342009-04-09 22:27:44 +000071
Douglas Gregor8038d512009-04-10 17:25:41 +000072 /// \brief Record types that occur within the PCH block itself.
73 enum PCHRecordTypes {
74 /// \brief Offset of each type within the types block.
Douglas Gregor2cf26342009-04-09 22:27:44 +000075 ///
Douglas Gregor8038d512009-04-10 17:25:41 +000076 /// The TYPE_OFFSET constant describes the record that occurs
77 /// within the block identified by TYPE_OFFSETS_BLOCK_ID within
78 /// the PCH file. The record itself is an array of offsets that
79 /// point into the types block (identified by TYPES_BLOCK_ID in
80 /// the PCH file). The index into the array is based on the ID
81 /// of a type. For a given type ID @c T, the lower three bits of
82 /// @c T are its qualifiers (const, volatile, restrict), as in
83 /// the QualType class. The upper bits, after being shifted and
84 /// subtracting NUM_PREDEF_TYPE_IDS, are used to index into the
85 /// TYPE_OFFSET block to determine the offset of that type's
86 /// corresponding record within the TYPES_BLOCK_ID block.
87 TYPE_OFFSET = 1,
88
89 /// \brief Record code for the offsets of each decl.
90 ///
91 /// The DECL_OFFSET constant describes the record that occurs
92 /// within the block identifier by DECL_OFFSETS_BLOCK_ID within
93 /// the PCH file. The record itself is an array of offsets that
94 /// point into the declarations block (identified by
95 /// DECLS_BLOCK_ID). The declaration ID is an index into this
96 /// record, after subtracting one to account for the use of
97 /// declaration ID 0 for a NULL declaration pointer. Index 0 is
98 /// reserved for the translation unit declaration.
Douglas Gregor0a0428e2009-04-10 20:39:37 +000099 DECL_OFFSET = 2,
100
101 /// \brief Record code for the language options table.
102 ///
103 /// The record with this code contains the contents of the
104 /// LangOptions structure. We serialize the entire contents of
105 /// the structure, and let the reader decide which options are
106 /// actually important to check.
Douglas Gregor2bec0412009-04-10 21:16:55 +0000107 LANGUAGE_OPTIONS = 3,
108
109 /// \brief Record code for the target triple used to build the
110 /// PCH file.
Douglas Gregorafaf3082009-04-11 00:14:32 +0000111 TARGET_TRIPLE = 4,
112
113 /// \brief Record code for the table of offsets of each
114 /// identifier ID.
115 ///
116 /// The offset table contains offsets into the blob stored in
117 /// the IDENTIFIER_TABLE record. Each offset points to the
118 /// NULL-terminated string that corresponds to that identifier.
119 IDENTIFIER_OFFSET = 5,
120
121 /// \brief Record code for the identifier table.
122 ///
123 /// The identifier table is a simple blob that contains
124 /// NULL-terminated strings for all of the identifiers
125 /// referenced by the PCH file. The IDENTIFIER_OFFSET table
126 /// contains the mapping from identifier IDs to the characters
127 /// in this blob. Note that the starting offsets of all of the
128 /// identifiers are odd, so that, when the identifier offset
129 /// table is loaded in, we can use the low bit to distinguish
130 /// between offsets (for unresolved identifier IDs) and
131 /// IdentifierInfo pointers (for already-resolved identifier
132 /// IDs).
Douglas Gregorfdd01722009-04-14 00:24:19 +0000133 IDENTIFIER_TABLE = 6,
134
135 /// \brief Record code for the array of external definitions.
136 ///
137 /// The PCH file contains a list of all of the external
138 /// definitions present within the parsed headers, stored as an
139 /// array of declaration IDs. These external definitions will be
140 /// reported to the AST consumer after the PCH file has been
141 /// read, since their presence can affect the semantics of the
142 /// program (e.g., for code generation).
143 EXTERNAL_DEFINITIONS = 7
Douglas Gregor2cf26342009-04-09 22:27:44 +0000144 };
145
Douglas Gregor14f79002009-04-10 03:52:48 +0000146 /// \brief Record types used within a source manager block.
147 enum SourceManagerRecordTypes {
148 /// \brief Describes a source location entry (SLocEntry) for a
149 /// file.
150 SM_SLOC_FILE_ENTRY = 1,
151 /// \brief Describes a source location entry (SLocEntry) for a
152 /// buffer.
153 SM_SLOC_BUFFER_ENTRY = 2,
154 /// \brief Describes a blob that contains the data for a buffer
155 /// entry. This kind of record always directly follows a
156 /// SM_SLOC_BUFFER_ENTRY record.
157 SM_SLOC_BUFFER_BLOB = 3,
158 /// \brief Describes a source location entry (SLocEntry) for a
159 /// macro instantiation.
Douglas Gregorbd945002009-04-13 16:31:14 +0000160 SM_SLOC_INSTANTIATION_ENTRY = 4,
161 /// \brief Describes the SourceManager's line table, with
162 /// information about #line directives.
163 SM_LINE_TABLE = 5
Douglas Gregor14f79002009-04-10 03:52:48 +0000164 };
Chris Lattner7c5d24e2009-04-10 18:00:12 +0000165
166 /// \brief Record types used within a preprocessor block.
167 enum PreprocessorRecordTypes {
168 // The macros in the PP section are a PP_MACRO_* instance followed by a
169 // list of PP_TOKEN instances for each token in the definition.
170
171 /// \brief An object-like macro definition.
172 /// [PP_MACRO_OBJECT_LIKE, IdentInfoID, SLoc, IsUsed]
173 PP_MACRO_OBJECT_LIKE = 1,
174
175 /// \brief A function-like macro definition.
176 /// [PP_MACRO_FUNCTION_LIKE, <ObjectLikeStuff>, IsC99Varargs, IsGNUVarars,
177 /// NumArgs, ArgIdentInfoID* ]
178 PP_MACRO_FUNCTION_LIKE = 2,
179
180 /// \brief Describes one token.
Chris Lattnerc1f9d822009-04-13 01:29:17 +0000181 /// [PP_TOKEN, SLoc, Length, IdentInfoID, Kind, Flags]
182 PP_TOKEN = 3,
183
184 /// \brief The value of the next __COUNTER__ to dispense.
185 /// [PP_COUNTER_VALUE, Val]
186 PP_COUNTER_VALUE = 4
Chris Lattner7c5d24e2009-04-10 18:00:12 +0000187 };
188
Douglas Gregor14f79002009-04-10 03:52:48 +0000189
190 /// \defgroup PCHAST Precompiled header AST constants
191 ///
192 /// The constants in this group describe various components of the
193 /// abstract syntax tree within a precompiled header.
194 ///
195 /// @{
196
Douglas Gregor2cf26342009-04-09 22:27:44 +0000197 /// \brief Predefined type IDs.
198 ///
199 /// These type IDs correspond to predefined types in the AST
200 /// context, such as built-in types (int) and special place-holder
201 /// types (the <overload> and <dependent> type markers). Such
202 /// types are never actually serialized, since they will be built
203 /// by the AST context when it is created.
204 enum PredefinedTypeIDs {
205 /// \brief The NULL type.
206 PREDEF_TYPE_NULL_ID = 0,
207 /// \brief The void type.
208 PREDEF_TYPE_VOID_ID = 1,
209 /// \brief The 'bool' or '_Bool' type.
210 PREDEF_TYPE_BOOL_ID = 2,
211 /// \brief The 'char' type, when it is unsigned.
212 PREDEF_TYPE_CHAR_U_ID = 3,
213 /// \brief The 'unsigned char' type.
214 PREDEF_TYPE_UCHAR_ID = 4,
215 /// \brief The 'unsigned short' type.
216 PREDEF_TYPE_USHORT_ID = 5,
217 /// \brief The 'unsigned int' type.
218 PREDEF_TYPE_UINT_ID = 6,
219 /// \brief The 'unsigned long' type.
220 PREDEF_TYPE_ULONG_ID = 7,
221 /// \brief The 'unsigned long long' type.
222 PREDEF_TYPE_ULONGLONG_ID = 8,
223 /// \brief The 'char' type, when it is signed.
224 PREDEF_TYPE_CHAR_S_ID = 9,
225 /// \brief The 'signed char' type.
226 PREDEF_TYPE_SCHAR_ID = 10,
227 /// \brief The C++ 'wchar_t' type.
228 PREDEF_TYPE_WCHAR_ID = 11,
229 /// \brief The (signed) 'short' type.
230 PREDEF_TYPE_SHORT_ID = 12,
231 /// \brief The (signed) 'int' type.
232 PREDEF_TYPE_INT_ID = 13,
233 /// \brief The (signed) 'long' type.
234 PREDEF_TYPE_LONG_ID = 14,
235 /// \brief The (signed) 'long long' type.
236 PREDEF_TYPE_LONGLONG_ID = 15,
237 /// \brief The 'float' type.
238 PREDEF_TYPE_FLOAT_ID = 16,
239 /// \brief The 'double' type.
240 PREDEF_TYPE_DOUBLE_ID = 17,
241 /// \brief The 'long double' type.
242 PREDEF_TYPE_LONGDOUBLE_ID = 18,
243 /// \brief The placeholder type for overloaded function sets.
244 PREDEF_TYPE_OVERLOAD_ID = 19,
245 /// \brief The placeholder type for dependent types.
246 PREDEF_TYPE_DEPENDENT_ID = 20
247 };
248
249 /// \brief The number of predefined type IDs that are reserved for
250 /// the PREDEF_TYPE_* constants.
251 ///
252 /// Type IDs for non-predefined types will start at
253 /// NUM_PREDEF_TYPE_IDs.
254 const unsigned NUM_PREDEF_TYPE_IDS = 100;
255
256 /// \brief Record codes for each kind of type.
257 ///
258 /// These constants describe the records that can occur within a
259 /// block identified by TYPES_BLOCK_ID in the PCH file. Each
260 /// constant describes a record for a specific type class in the
261 /// AST.
262 enum TypeCode {
263 /// \brief An ExtQualType record.
264 TYPE_EXT_QUAL = 1,
265 /// \brief A FixedWidthIntType record.
266 TYPE_FIXED_WIDTH_INT = 2,
267 /// \brief A ComplexType record.
268 TYPE_COMPLEX = 3,
269 /// \brief A PointerType record.
270 TYPE_POINTER = 4,
271 /// \brief A BlockPointerType record.
272 TYPE_BLOCK_POINTER = 5,
273 /// \brief An LValueReferenceType record.
274 TYPE_LVALUE_REFERENCE = 6,
275 /// \brief An RValueReferenceType record.
276 TYPE_RVALUE_REFERENCE = 7,
277 /// \brief A MemberPointerType record.
278 TYPE_MEMBER_POINTER = 8,
279 /// \brief A ConstantArrayType record.
280 TYPE_CONSTANT_ARRAY = 9,
281 /// \brief An IncompleteArrayType record.
282 TYPE_INCOMPLETE_ARRAY = 10,
283 /// \brief A VariableArrayType record.
284 TYPE_VARIABLE_ARRAY = 11,
285 /// \brief A VectorType record.
286 TYPE_VECTOR = 12,
287 /// \brief An ExtVectorType record.
288 TYPE_EXT_VECTOR = 13,
289 /// \brief A FunctionNoProtoType record.
290 TYPE_FUNCTION_NO_PROTO = 14,
291 /// \brief A FunctionProtoType record.
292 TYPE_FUNCTION_PROTO = 15,
293 /// \brief A TypedefType record.
294 TYPE_TYPEDEF = 16,
295 /// \brief A TypeOfExprType record.
296 TYPE_TYPEOF_EXPR = 17,
297 /// \brief A TypeOfType record.
298 TYPE_TYPEOF = 18,
299 /// \brief A RecordType record.
300 TYPE_RECORD = 19,
301 /// \brief An EnumType record.
302 TYPE_ENUM = 20,
303 /// \brief An ObjCInterfaceType record.
304 TYPE_OBJC_INTERFACE = 21,
305 /// \brief An ObjCQualifiedInterfaceType record.
306 TYPE_OBJC_QUALIFIED_INTERFACE = 22,
307 /// \brief An ObjCQualifiedIdType record.
308 TYPE_OBJC_QUALIFIED_ID = 23,
309 /// \brief An ObjCQualifiedClassType record.
310 TYPE_OBJC_QUALIFIED_CLASS = 24
311 };
312
Douglas Gregor2cf26342009-04-09 22:27:44 +0000313 /// \brief Record codes for each kind of declaration.
314 ///
315 /// These constants describe the records that can occur within a
316 /// declarations block (identified by DECLS_BLOCK_ID). Each
317 /// constant describes a record for a specific declaration class
318 /// in the AST.
319 enum DeclCode {
320 /// \brief A TranslationUnitDecl record.
321 DECL_TRANSLATION_UNIT = 1,
322 /// \brief A TypedefDecl record.
323 DECL_TYPEDEF,
Douglas Gregor0a2b45e2009-04-13 18:14:40 +0000324 /// \brief An EnumDecl record.
325 DECL_ENUM,
Douglas Gregor8c700062009-04-13 21:20:57 +0000326 /// \brief A RecordDecl record.
327 DECL_RECORD,
Douglas Gregor0a2b45e2009-04-13 18:14:40 +0000328 /// \brief An EnumConstantDecl record.
329 DECL_ENUM_CONSTANT,
Douglas Gregor3a2f7e42009-04-13 22:18:37 +0000330 /// \brief A FunctionDecl record.
331 DECL_FUNCTION,
Douglas Gregor8c700062009-04-13 21:20:57 +0000332 /// \brief A FieldDecl record.
333 DECL_FIELD,
Douglas Gregor2cf26342009-04-09 22:27:44 +0000334 /// \brief A VarDecl record.
335 DECL_VAR,
Douglas Gregor3a2f7e42009-04-13 22:18:37 +0000336 /// \brief A ParmVarDecl record.
337 DECL_PARM_VAR,
338 /// \brief An OriginalParmVarDecl record.
339 DECL_ORIGINAL_PARM_VAR,
Douglas Gregor1028bc62009-04-13 22:49:25 +0000340 /// \brief A FileScopeAsmDecl record.
341 DECL_FILE_SCOPE_ASM,
342 /// \brief A BlockDecl record.
343 DECL_BLOCK,
Douglas Gregor2cf26342009-04-09 22:27:44 +0000344 /// \brief A record that stores the set of declarations that are
345 /// lexically stored within a given DeclContext.
346 ///
347 /// The record itself is an array of declaration IDs, in the
348 /// order in which those declarations were added to the
349 /// declaration context. This data is used when iterating over
350 /// the contents of a DeclContext, e.g., via
351 /// DeclContext::decls_begin()/DeclContext::decls_end().
352 DECL_CONTEXT_LEXICAL,
353 /// \brief A record that stores the set of declarations that are
354 /// visible from a given DeclContext.
355 ///
356 /// The record itself stores a set of mappings, each of which
357 /// associates a declaration name with one or more declaration
358 /// IDs. This data is used when performing qualified name lookup
359 /// into a DeclContext via DeclContext::lookup.
360 DECL_CONTEXT_VISIBLE
361 };
Douglas Gregor0b748912009-04-14 21:18:50 +0000362
363 /// \brief Record codes for each kind of statement or expression.
364 ///
365 /// These constants describe the records that describe statements
366 /// or expressions. These records can occur within either the type
367 /// or declaration blocks, so they begin with record values of
368 /// 100. Each constant describes a record for a specific
369 /// statement or expression class in the AST.
370 enum StmtCode {
Douglas Gregor087fd532009-04-14 23:32:43 +0000371 /// \brief A marker record that indicates that we are at the end
372 /// of an expression.
373 EXPR_STOP,
Douglas Gregor0b748912009-04-14 21:18:50 +0000374 /// \brief A NULL expression.
Douglas Gregor087fd532009-04-14 23:32:43 +0000375 EXPR_NULL,
Douglas Gregor17fc2232009-04-14 21:55:33 +0000376 /// \brief A PredefinedExpr record.
377 EXPR_PREDEFINED,
Douglas Gregor0b748912009-04-14 21:18:50 +0000378 /// \brief A DeclRefExpr record.
379 EXPR_DECL_REF,
380 /// \brief An IntegerLiteral record.
381 EXPR_INTEGER_LITERAL,
Douglas Gregor17fc2232009-04-14 21:55:33 +0000382 /// \brief A FloatingLiteral record.
383 EXPR_FLOATING_LITERAL,
Douglas Gregor0b748912009-04-14 21:18:50 +0000384 /// \brief A CharacterLiteral record.
Douglas Gregor087fd532009-04-14 23:32:43 +0000385 EXPR_CHARACTER_LITERAL,
Douglas Gregorc04db4f2009-04-14 23:59:37 +0000386 /// \brief A ParenExpr record.
387 EXPR_PAREN,
Douglas Gregordb600c32009-04-15 00:25:59 +0000388 /// \brief A BinaryOperator record.
389 EXPR_BINARY_OPERATOR,
Douglas Gregor087fd532009-04-14 23:32:43 +0000390 /// \brief An ImplicitCastExpr record.
Douglas Gregordb600c32009-04-15 00:25:59 +0000391 EXPR_IMPLICIT_CAST,
392 /// \brief A CStyleCastExpr record.
393 EXPR_CSTYLE_CAST
Douglas Gregor0b748912009-04-14 21:18:50 +0000394 };
Douglas Gregor14f79002009-04-10 03:52:48 +0000395 /// @}
Douglas Gregor2cf26342009-04-09 22:27:44 +0000396 }
397} // end namespace clang
398
399#endif