1f4a2713aSLionel Sambuc //===--- Module.h - Module description --------------------------*- C++ -*-===//
2f4a2713aSLionel Sambuc //
3f4a2713aSLionel Sambuc //                     The LLVM Compiler Infrastructure
4f4a2713aSLionel Sambuc //
5f4a2713aSLionel Sambuc // This file is distributed under the University of Illinois Open Source
6f4a2713aSLionel Sambuc // License. See LICENSE.TXT for details.
7f4a2713aSLionel Sambuc //
8f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
9f4a2713aSLionel Sambuc //
10f4a2713aSLionel Sambuc //  This file defines the Module class, which describes a module that has
11f4a2713aSLionel Sambuc //  been loaded from an AST file.
12f4a2713aSLionel Sambuc //
13f4a2713aSLionel Sambuc //===----------------------------------------------------------------------===//
14f4a2713aSLionel Sambuc 
15f4a2713aSLionel Sambuc #ifndef LLVM_CLANG_SERIALIZATION_MODULE_H
16f4a2713aSLionel Sambuc #define LLVM_CLANG_SERIALIZATION_MODULE_H
17f4a2713aSLionel Sambuc 
18f4a2713aSLionel Sambuc #include "clang/Basic/SourceLocation.h"
19f4a2713aSLionel Sambuc #include "clang/Serialization/ASTBitCodes.h"
20f4a2713aSLionel Sambuc #include "clang/Serialization/ContinuousRangeMap.h"
21f4a2713aSLionel Sambuc #include "llvm/ADT/SetVector.h"
22f4a2713aSLionel Sambuc #include "llvm/Bitcode/BitstreamReader.h"
23*0a6a1f1dSLionel Sambuc #include <memory>
24f4a2713aSLionel Sambuc #include <string>
25f4a2713aSLionel Sambuc 
26*0a6a1f1dSLionel Sambuc namespace llvm {
27*0a6a1f1dSLionel Sambuc template <typename Info> class OnDiskChainedHashTable;
28*0a6a1f1dSLionel Sambuc template <typename Info> class OnDiskIterableChainedHashTable;
29*0a6a1f1dSLionel Sambuc }
30*0a6a1f1dSLionel Sambuc 
31f4a2713aSLionel Sambuc namespace clang {
32f4a2713aSLionel Sambuc 
33f4a2713aSLionel Sambuc class FileEntry;
34f4a2713aSLionel Sambuc class DeclContext;
35f4a2713aSLionel Sambuc class Module;
36f4a2713aSLionel Sambuc 
37f4a2713aSLionel Sambuc namespace serialization {
38f4a2713aSLionel Sambuc 
39f4a2713aSLionel Sambuc namespace reader {
40f4a2713aSLionel Sambuc   class ASTDeclContextNameLookupTrait;
41f4a2713aSLionel Sambuc }
42f4a2713aSLionel Sambuc 
43f4a2713aSLionel Sambuc /// \brief Specifies the kind of module that has been loaded.
44f4a2713aSLionel Sambuc enum ModuleKind {
45*0a6a1f1dSLionel Sambuc   MK_ImplicitModule, ///< File is an implicitly-loaded module.
46*0a6a1f1dSLionel Sambuc   MK_ExplicitModule, ///< File is an explicitly-loaded module.
47f4a2713aSLionel Sambuc   MK_PCH,            ///< File is a PCH file treated as such.
48f4a2713aSLionel Sambuc   MK_Preamble,       ///< File is a PCH file treated as the preamble.
49f4a2713aSLionel Sambuc   MK_MainFile        ///< File is a PCH file treated as the actual main file.
50f4a2713aSLionel Sambuc };
51f4a2713aSLionel Sambuc 
52f4a2713aSLionel Sambuc /// \brief Information about the contents of a DeclContext.
53f4a2713aSLionel Sambuc struct DeclContextInfo {
DeclContextInfoDeclContextInfo54f4a2713aSLionel Sambuc   DeclContextInfo()
55f4a2713aSLionel Sambuc     : NameLookupTableData(), LexicalDecls(), NumLexicalDecls() {}
56f4a2713aSLionel Sambuc 
57*0a6a1f1dSLionel Sambuc   llvm::OnDiskIterableChainedHashTable<reader::ASTDeclContextNameLookupTrait>
58f4a2713aSLionel Sambuc     *NameLookupTableData; // an ASTDeclContextNameLookupTable.
59f4a2713aSLionel Sambuc   const KindDeclIDPair *LexicalDecls;
60f4a2713aSLionel Sambuc   unsigned NumLexicalDecls;
61f4a2713aSLionel Sambuc };
62f4a2713aSLionel Sambuc 
63f4a2713aSLionel Sambuc /// \brief The input file that has been loaded from this AST file, along with
64f4a2713aSLionel Sambuc /// bools indicating whether this was an overridden buffer or if it was
65*0a6a1f1dSLionel Sambuc /// out-of-date or not-found.
66f4a2713aSLionel Sambuc class InputFile {
67f4a2713aSLionel Sambuc   enum {
68f4a2713aSLionel Sambuc     Overridden = 1,
69*0a6a1f1dSLionel Sambuc     OutOfDate = 2,
70*0a6a1f1dSLionel Sambuc     NotFound = 3
71f4a2713aSLionel Sambuc   };
72f4a2713aSLionel Sambuc   llvm::PointerIntPair<const FileEntry *, 2, unsigned> Val;
73f4a2713aSLionel Sambuc 
74f4a2713aSLionel Sambuc public:
InputFile()75f4a2713aSLionel Sambuc   InputFile() {}
76f4a2713aSLionel Sambuc   InputFile(const FileEntry *File,
77f4a2713aSLionel Sambuc             bool isOverridden = false, bool isOutOfDate = false) {
78f4a2713aSLionel Sambuc     assert(!(isOverridden && isOutOfDate) &&
79f4a2713aSLionel Sambuc            "an overridden cannot be out-of-date");
80f4a2713aSLionel Sambuc     unsigned intVal = 0;
81f4a2713aSLionel Sambuc     if (isOverridden)
82f4a2713aSLionel Sambuc       intVal = Overridden;
83f4a2713aSLionel Sambuc     else if (isOutOfDate)
84f4a2713aSLionel Sambuc       intVal = OutOfDate;
85f4a2713aSLionel Sambuc     Val.setPointerAndInt(File, intVal);
86f4a2713aSLionel Sambuc   }
87f4a2713aSLionel Sambuc 
getNotFound()88*0a6a1f1dSLionel Sambuc   static InputFile getNotFound() {
89*0a6a1f1dSLionel Sambuc     InputFile File;
90*0a6a1f1dSLionel Sambuc     File.Val.setInt(NotFound);
91*0a6a1f1dSLionel Sambuc     return File;
92*0a6a1f1dSLionel Sambuc   }
93*0a6a1f1dSLionel Sambuc 
getFile()94f4a2713aSLionel Sambuc   const FileEntry *getFile() const { return Val.getPointer(); }
isOverridden()95f4a2713aSLionel Sambuc   bool isOverridden() const { return Val.getInt() == Overridden; }
isOutOfDate()96f4a2713aSLionel Sambuc   bool isOutOfDate() const { return Val.getInt() == OutOfDate; }
isNotFound()97*0a6a1f1dSLionel Sambuc   bool isNotFound() const { return Val.getInt() == NotFound; }
98f4a2713aSLionel Sambuc };
99f4a2713aSLionel Sambuc 
100*0a6a1f1dSLionel Sambuc typedef unsigned ASTFileSignature;
101*0a6a1f1dSLionel Sambuc 
102f4a2713aSLionel Sambuc /// \brief Information about a module that has been loaded by the ASTReader.
103f4a2713aSLionel Sambuc ///
104f4a2713aSLionel Sambuc /// Each instance of the Module class corresponds to a single AST file, which
105f4a2713aSLionel Sambuc /// may be a precompiled header, precompiled preamble, a module, or an AST file
106f4a2713aSLionel Sambuc /// of some sort loaded as the main file, all of which are specific formulations
107f4a2713aSLionel Sambuc /// of the general notion of a "module". A module may depend on any number of
108f4a2713aSLionel Sambuc /// other modules.
109f4a2713aSLionel Sambuc class ModuleFile {
110f4a2713aSLionel Sambuc public:
111f4a2713aSLionel Sambuc   ModuleFile(ModuleKind Kind, unsigned Generation);
112f4a2713aSLionel Sambuc   ~ModuleFile();
113f4a2713aSLionel Sambuc 
114f4a2713aSLionel Sambuc   // === General information ===
115f4a2713aSLionel Sambuc 
116f4a2713aSLionel Sambuc   /// \brief The index of this module in the list of modules.
117f4a2713aSLionel Sambuc   unsigned Index;
118f4a2713aSLionel Sambuc 
119f4a2713aSLionel Sambuc   /// \brief The type of this module.
120f4a2713aSLionel Sambuc   ModuleKind Kind;
121f4a2713aSLionel Sambuc 
122f4a2713aSLionel Sambuc   /// \brief The file name of the module file.
123f4a2713aSLionel Sambuc   std::string FileName;
124f4a2713aSLionel Sambuc 
125*0a6a1f1dSLionel Sambuc   /// \brief The name of the module.
126*0a6a1f1dSLionel Sambuc   std::string ModuleName;
127*0a6a1f1dSLionel Sambuc 
128*0a6a1f1dSLionel Sambuc   /// \brief The base directory of the module.
129*0a6a1f1dSLionel Sambuc   std::string BaseDirectory;
130*0a6a1f1dSLionel Sambuc 
getTimestampFilename()131*0a6a1f1dSLionel Sambuc   std::string getTimestampFilename() const {
132*0a6a1f1dSLionel Sambuc     return FileName + ".timestamp";
133*0a6a1f1dSLionel Sambuc   }
134*0a6a1f1dSLionel Sambuc 
135f4a2713aSLionel Sambuc   /// \brief The original source file name that was used to build the
136f4a2713aSLionel Sambuc   /// primary AST file, which may have been modified for
137f4a2713aSLionel Sambuc   /// relocatable-pch support.
138f4a2713aSLionel Sambuc   std::string OriginalSourceFileName;
139f4a2713aSLionel Sambuc 
140f4a2713aSLionel Sambuc   /// \brief The actual original source file name that was used to
141f4a2713aSLionel Sambuc   /// build this AST file.
142f4a2713aSLionel Sambuc   std::string ActualOriginalSourceFileName;
143f4a2713aSLionel Sambuc 
144f4a2713aSLionel Sambuc   /// \brief The file ID for the original source file that was used to
145f4a2713aSLionel Sambuc   /// build this AST file.
146f4a2713aSLionel Sambuc   FileID OriginalSourceFileID;
147f4a2713aSLionel Sambuc 
148f4a2713aSLionel Sambuc   /// \brief The directory that the PCH was originally created in. Used to
149f4a2713aSLionel Sambuc   /// allow resolving headers even after headers+PCH was moved to a new path.
150f4a2713aSLionel Sambuc   std::string OriginalDir;
151f4a2713aSLionel Sambuc 
152*0a6a1f1dSLionel Sambuc   std::string ModuleMapPath;
153*0a6a1f1dSLionel Sambuc 
154f4a2713aSLionel Sambuc   /// \brief Whether this precompiled header is a relocatable PCH file.
155f4a2713aSLionel Sambuc   bool RelocatablePCH;
156f4a2713aSLionel Sambuc 
157f4a2713aSLionel Sambuc   /// \brief The file entry for the module file.
158f4a2713aSLionel Sambuc   const FileEntry *File;
159f4a2713aSLionel Sambuc 
160*0a6a1f1dSLionel Sambuc   /// \brief The signature of the module file, which may be used along with size
161*0a6a1f1dSLionel Sambuc   /// and modification time to identify this particular file.
162*0a6a1f1dSLionel Sambuc   ASTFileSignature Signature;
163*0a6a1f1dSLionel Sambuc 
164f4a2713aSLionel Sambuc   /// \brief Whether this module has been directly imported by the
165f4a2713aSLionel Sambuc   /// user.
166f4a2713aSLionel Sambuc   bool DirectlyImported;
167f4a2713aSLionel Sambuc 
168f4a2713aSLionel Sambuc   /// \brief The generation of which this module file is a part.
169f4a2713aSLionel Sambuc   unsigned Generation;
170f4a2713aSLionel Sambuc 
171f4a2713aSLionel Sambuc   /// \brief The memory buffer that stores the data associated with
172f4a2713aSLionel Sambuc   /// this AST file.
173*0a6a1f1dSLionel Sambuc   std::unique_ptr<llvm::MemoryBuffer> Buffer;
174f4a2713aSLionel Sambuc 
175f4a2713aSLionel Sambuc   /// \brief The size of this file, in bits.
176f4a2713aSLionel Sambuc   uint64_t SizeInBits;
177f4a2713aSLionel Sambuc 
178f4a2713aSLionel Sambuc   /// \brief The global bit offset (or base) of this module
179f4a2713aSLionel Sambuc   uint64_t GlobalBitOffset;
180f4a2713aSLionel Sambuc 
181f4a2713aSLionel Sambuc   /// \brief The bitstream reader from which we'll read the AST file.
182f4a2713aSLionel Sambuc   llvm::BitstreamReader StreamFile;
183f4a2713aSLionel Sambuc 
184f4a2713aSLionel Sambuc   /// \brief The main bitstream cursor for the main block.
185f4a2713aSLionel Sambuc   llvm::BitstreamCursor Stream;
186f4a2713aSLionel Sambuc 
187f4a2713aSLionel Sambuc   /// \brief The source location where the module was explicitly or implicitly
188f4a2713aSLionel Sambuc   /// imported in the local translation unit.
189f4a2713aSLionel Sambuc   ///
190f4a2713aSLionel Sambuc   /// If module A depends on and imports module B, both modules will have the
191f4a2713aSLionel Sambuc   /// same DirectImportLoc, but different ImportLoc (B's ImportLoc will be a
192f4a2713aSLionel Sambuc   /// source location inside module A).
193*0a6a1f1dSLionel Sambuc   ///
194*0a6a1f1dSLionel Sambuc   /// WARNING: This is largely useless. It doesn't tell you when a module was
195*0a6a1f1dSLionel Sambuc   /// made visible, just when the first submodule of that module was imported.
196f4a2713aSLionel Sambuc   SourceLocation DirectImportLoc;
197f4a2713aSLionel Sambuc 
198f4a2713aSLionel Sambuc   /// \brief The source location where this module was first imported.
199f4a2713aSLionel Sambuc   SourceLocation ImportLoc;
200f4a2713aSLionel Sambuc 
201f4a2713aSLionel Sambuc   /// \brief The first source location in this module.
202f4a2713aSLionel Sambuc   SourceLocation FirstLoc;
203f4a2713aSLionel Sambuc 
204f4a2713aSLionel Sambuc   // === Input Files ===
205f4a2713aSLionel Sambuc   /// \brief The cursor to the start of the input-files block.
206f4a2713aSLionel Sambuc   llvm::BitstreamCursor InputFilesCursor;
207f4a2713aSLionel Sambuc 
208f4a2713aSLionel Sambuc   /// \brief Offsets for all of the input file entries in the AST file.
209f4a2713aSLionel Sambuc   const uint32_t *InputFileOffsets;
210f4a2713aSLionel Sambuc 
211f4a2713aSLionel Sambuc   /// \brief The input files that have been loaded from this AST file.
212f4a2713aSLionel Sambuc   std::vector<InputFile> InputFilesLoaded;
213f4a2713aSLionel Sambuc 
214*0a6a1f1dSLionel Sambuc   /// \brief If non-zero, specifies the time when we last validated input
215*0a6a1f1dSLionel Sambuc   /// files.  Zero means we never validated them.
216*0a6a1f1dSLionel Sambuc   ///
217*0a6a1f1dSLionel Sambuc   /// The time is specified in seconds since the start of the Epoch.
218*0a6a1f1dSLionel Sambuc   uint64_t InputFilesValidationTimestamp;
219*0a6a1f1dSLionel Sambuc 
220f4a2713aSLionel Sambuc   // === Source Locations ===
221f4a2713aSLionel Sambuc 
222f4a2713aSLionel Sambuc   /// \brief Cursor used to read source location entries.
223f4a2713aSLionel Sambuc   llvm::BitstreamCursor SLocEntryCursor;
224f4a2713aSLionel Sambuc 
225f4a2713aSLionel Sambuc   /// \brief The number of source location entries in this AST file.
226f4a2713aSLionel Sambuc   unsigned LocalNumSLocEntries;
227f4a2713aSLionel Sambuc 
228f4a2713aSLionel Sambuc   /// \brief The base ID in the source manager's view of this module.
229f4a2713aSLionel Sambuc   int SLocEntryBaseID;
230f4a2713aSLionel Sambuc 
231f4a2713aSLionel Sambuc   /// \brief The base offset in the source manager's view of this module.
232f4a2713aSLionel Sambuc   unsigned SLocEntryBaseOffset;
233f4a2713aSLionel Sambuc 
234f4a2713aSLionel Sambuc   /// \brief Offsets for all of the source location entries in the
235f4a2713aSLionel Sambuc   /// AST file.
236f4a2713aSLionel Sambuc   const uint32_t *SLocEntryOffsets;
237f4a2713aSLionel Sambuc 
238f4a2713aSLionel Sambuc   /// \brief SLocEntries that we're going to preload.
239f4a2713aSLionel Sambuc   SmallVector<uint64_t, 4> PreloadSLocEntries;
240f4a2713aSLionel Sambuc 
241f4a2713aSLionel Sambuc   /// \brief Remapping table for source locations in this module.
242f4a2713aSLionel Sambuc   ContinuousRangeMap<uint32_t, int, 2> SLocRemap;
243f4a2713aSLionel Sambuc 
244f4a2713aSLionel Sambuc   // === Identifiers ===
245f4a2713aSLionel Sambuc 
246f4a2713aSLionel Sambuc   /// \brief The number of identifiers in this AST file.
247f4a2713aSLionel Sambuc   unsigned LocalNumIdentifiers;
248f4a2713aSLionel Sambuc 
249f4a2713aSLionel Sambuc   /// \brief Offsets into the identifier table data.
250f4a2713aSLionel Sambuc   ///
251f4a2713aSLionel Sambuc   /// This array is indexed by the identifier ID (-1), and provides
252f4a2713aSLionel Sambuc   /// the offset into IdentifierTableData where the string data is
253f4a2713aSLionel Sambuc   /// stored.
254f4a2713aSLionel Sambuc   const uint32_t *IdentifierOffsets;
255f4a2713aSLionel Sambuc 
256f4a2713aSLionel Sambuc   /// \brief Base identifier ID for identifiers local to this module.
257f4a2713aSLionel Sambuc   serialization::IdentID BaseIdentifierID;
258f4a2713aSLionel Sambuc 
259f4a2713aSLionel Sambuc   /// \brief Remapping table for identifier IDs in this module.
260f4a2713aSLionel Sambuc   ContinuousRangeMap<uint32_t, int, 2> IdentifierRemap;
261f4a2713aSLionel Sambuc 
262f4a2713aSLionel Sambuc   /// \brief Actual data for the on-disk hash table of identifiers.
263f4a2713aSLionel Sambuc   ///
264f4a2713aSLionel Sambuc   /// This pointer points into a memory buffer, where the on-disk hash
265f4a2713aSLionel Sambuc   /// table for identifiers actually lives.
266f4a2713aSLionel Sambuc   const char *IdentifierTableData;
267f4a2713aSLionel Sambuc 
268f4a2713aSLionel Sambuc   /// \brief A pointer to an on-disk hash table of opaque type
269f4a2713aSLionel Sambuc   /// IdentifierHashTable.
270f4a2713aSLionel Sambuc   void *IdentifierLookupTable;
271f4a2713aSLionel Sambuc 
272f4a2713aSLionel Sambuc   // === Macros ===
273f4a2713aSLionel Sambuc 
274f4a2713aSLionel Sambuc   /// \brief The cursor to the start of the preprocessor block, which stores
275f4a2713aSLionel Sambuc   /// all of the macro definitions.
276f4a2713aSLionel Sambuc   llvm::BitstreamCursor MacroCursor;
277f4a2713aSLionel Sambuc 
278f4a2713aSLionel Sambuc   /// \brief The number of macros in this AST file.
279f4a2713aSLionel Sambuc   unsigned LocalNumMacros;
280f4a2713aSLionel Sambuc 
281f4a2713aSLionel Sambuc   /// \brief Offsets of macros in the preprocessor block.
282f4a2713aSLionel Sambuc   ///
283f4a2713aSLionel Sambuc   /// This array is indexed by the macro ID (-1), and provides
284f4a2713aSLionel Sambuc   /// the offset into the preprocessor block where macro definitions are
285f4a2713aSLionel Sambuc   /// stored.
286f4a2713aSLionel Sambuc   const uint32_t *MacroOffsets;
287f4a2713aSLionel Sambuc 
288f4a2713aSLionel Sambuc   /// \brief Base macro ID for macros local to this module.
289f4a2713aSLionel Sambuc   serialization::MacroID BaseMacroID;
290f4a2713aSLionel Sambuc 
291f4a2713aSLionel Sambuc   /// \brief Remapping table for macro IDs in this module.
292f4a2713aSLionel Sambuc   ContinuousRangeMap<uint32_t, int, 2> MacroRemap;
293f4a2713aSLionel Sambuc 
294f4a2713aSLionel Sambuc   /// \brief The offset of the start of the set of defined macros.
295f4a2713aSLionel Sambuc   uint64_t MacroStartOffset;
296f4a2713aSLionel Sambuc 
297f4a2713aSLionel Sambuc   // === Detailed PreprocessingRecord ===
298f4a2713aSLionel Sambuc 
299f4a2713aSLionel Sambuc   /// \brief The cursor to the start of the (optional) detailed preprocessing
300f4a2713aSLionel Sambuc   /// record block.
301f4a2713aSLionel Sambuc   llvm::BitstreamCursor PreprocessorDetailCursor;
302f4a2713aSLionel Sambuc 
303f4a2713aSLionel Sambuc   /// \brief The offset of the start of the preprocessor detail cursor.
304f4a2713aSLionel Sambuc   uint64_t PreprocessorDetailStartOffset;
305f4a2713aSLionel Sambuc 
306f4a2713aSLionel Sambuc   /// \brief Base preprocessed entity ID for preprocessed entities local to
307f4a2713aSLionel Sambuc   /// this module.
308f4a2713aSLionel Sambuc   serialization::PreprocessedEntityID BasePreprocessedEntityID;
309f4a2713aSLionel Sambuc 
310f4a2713aSLionel Sambuc   /// \brief Remapping table for preprocessed entity IDs in this module.
311f4a2713aSLionel Sambuc   ContinuousRangeMap<uint32_t, int, 2> PreprocessedEntityRemap;
312f4a2713aSLionel Sambuc 
313f4a2713aSLionel Sambuc   const PPEntityOffset *PreprocessedEntityOffsets;
314f4a2713aSLionel Sambuc   unsigned NumPreprocessedEntities;
315f4a2713aSLionel Sambuc 
316f4a2713aSLionel Sambuc   // === Header search information ===
317f4a2713aSLionel Sambuc 
318f4a2713aSLionel Sambuc   /// \brief The number of local HeaderFileInfo structures.
319f4a2713aSLionel Sambuc   unsigned LocalNumHeaderFileInfos;
320f4a2713aSLionel Sambuc 
321f4a2713aSLionel Sambuc   /// \brief Actual data for the on-disk hash table of header file
322f4a2713aSLionel Sambuc   /// information.
323f4a2713aSLionel Sambuc   ///
324f4a2713aSLionel Sambuc   /// This pointer points into a memory buffer, where the on-disk hash
325f4a2713aSLionel Sambuc   /// table for header file information actually lives.
326f4a2713aSLionel Sambuc   const char *HeaderFileInfoTableData;
327f4a2713aSLionel Sambuc 
328f4a2713aSLionel Sambuc   /// \brief The on-disk hash table that contains information about each of
329f4a2713aSLionel Sambuc   /// the header files.
330f4a2713aSLionel Sambuc   void *HeaderFileInfoTable;
331f4a2713aSLionel Sambuc 
332f4a2713aSLionel Sambuc   // === Submodule information ===
333f4a2713aSLionel Sambuc   /// \brief The number of submodules in this module.
334f4a2713aSLionel Sambuc   unsigned LocalNumSubmodules;
335f4a2713aSLionel Sambuc 
336f4a2713aSLionel Sambuc   /// \brief Base submodule ID for submodules local to this module.
337f4a2713aSLionel Sambuc   serialization::SubmoduleID BaseSubmoduleID;
338f4a2713aSLionel Sambuc 
339f4a2713aSLionel Sambuc   /// \brief Remapping table for submodule IDs in this module.
340f4a2713aSLionel Sambuc   ContinuousRangeMap<uint32_t, int, 2> SubmoduleRemap;
341f4a2713aSLionel Sambuc 
342f4a2713aSLionel Sambuc   // === Selectors ===
343f4a2713aSLionel Sambuc 
344f4a2713aSLionel Sambuc   /// \brief The number of selectors new to this file.
345f4a2713aSLionel Sambuc   ///
346f4a2713aSLionel Sambuc   /// This is the number of entries in SelectorOffsets.
347f4a2713aSLionel Sambuc   unsigned LocalNumSelectors;
348f4a2713aSLionel Sambuc 
349f4a2713aSLionel Sambuc   /// \brief Offsets into the selector lookup table's data array
350f4a2713aSLionel Sambuc   /// where each selector resides.
351f4a2713aSLionel Sambuc   const uint32_t *SelectorOffsets;
352f4a2713aSLionel Sambuc 
353f4a2713aSLionel Sambuc   /// \brief Base selector ID for selectors local to this module.
354f4a2713aSLionel Sambuc   serialization::SelectorID BaseSelectorID;
355f4a2713aSLionel Sambuc 
356f4a2713aSLionel Sambuc   /// \brief Remapping table for selector IDs in this module.
357f4a2713aSLionel Sambuc   ContinuousRangeMap<uint32_t, int, 2> SelectorRemap;
358f4a2713aSLionel Sambuc 
359f4a2713aSLionel Sambuc   /// \brief A pointer to the character data that comprises the selector table
360f4a2713aSLionel Sambuc   ///
361f4a2713aSLionel Sambuc   /// The SelectorOffsets table refers into this memory.
362f4a2713aSLionel Sambuc   const unsigned char *SelectorLookupTableData;
363f4a2713aSLionel Sambuc 
364f4a2713aSLionel Sambuc   /// \brief A pointer to an on-disk hash table of opaque type
365f4a2713aSLionel Sambuc   /// ASTSelectorLookupTable.
366f4a2713aSLionel Sambuc   ///
367f4a2713aSLionel Sambuc   /// This hash table provides the IDs of all selectors, and the associated
368f4a2713aSLionel Sambuc   /// instance and factory methods.
369f4a2713aSLionel Sambuc   void *SelectorLookupTable;
370f4a2713aSLionel Sambuc 
371f4a2713aSLionel Sambuc   // === Declarations ===
372f4a2713aSLionel Sambuc 
373f4a2713aSLionel Sambuc   /// DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block. It
374f4a2713aSLionel Sambuc   /// has read all the abbreviations at the start of the block and is ready to
375f4a2713aSLionel Sambuc   /// jump around with these in context.
376f4a2713aSLionel Sambuc   llvm::BitstreamCursor DeclsCursor;
377f4a2713aSLionel Sambuc 
378f4a2713aSLionel Sambuc   /// \brief The number of declarations in this AST file.
379f4a2713aSLionel Sambuc   unsigned LocalNumDecls;
380f4a2713aSLionel Sambuc 
381f4a2713aSLionel Sambuc   /// \brief Offset of each declaration within the bitstream, indexed
382f4a2713aSLionel Sambuc   /// by the declaration ID (-1).
383f4a2713aSLionel Sambuc   const DeclOffset *DeclOffsets;
384f4a2713aSLionel Sambuc 
385f4a2713aSLionel Sambuc   /// \brief Base declaration ID for declarations local to this module.
386f4a2713aSLionel Sambuc   serialization::DeclID BaseDeclID;
387f4a2713aSLionel Sambuc 
388f4a2713aSLionel Sambuc   /// \brief Remapping table for declaration IDs in this module.
389f4a2713aSLionel Sambuc   ContinuousRangeMap<uint32_t, int, 2> DeclRemap;
390f4a2713aSLionel Sambuc 
391f4a2713aSLionel Sambuc   /// \brief Mapping from the module files that this module file depends on
392f4a2713aSLionel Sambuc   /// to the base declaration ID for that module as it is understood within this
393f4a2713aSLionel Sambuc   /// module.
394f4a2713aSLionel Sambuc   ///
395f4a2713aSLionel Sambuc   /// This is effectively a reverse global-to-local mapping for declaration
396f4a2713aSLionel Sambuc   /// IDs, so that we can interpret a true global ID (for this translation unit)
397f4a2713aSLionel Sambuc   /// as a local ID (for this module file).
398f4a2713aSLionel Sambuc   llvm::DenseMap<ModuleFile *, serialization::DeclID> GlobalToLocalDeclIDs;
399f4a2713aSLionel Sambuc 
400f4a2713aSLionel Sambuc   /// \brief The number of C++ base specifier sets in this AST file.
401f4a2713aSLionel Sambuc   unsigned LocalNumCXXBaseSpecifiers;
402f4a2713aSLionel Sambuc 
403f4a2713aSLionel Sambuc   /// \brief Offset of each C++ base specifier set within the bitstream,
404f4a2713aSLionel Sambuc   /// indexed by the C++ base specifier set ID (-1).
405f4a2713aSLionel Sambuc   const uint32_t *CXXBaseSpecifiersOffsets;
406f4a2713aSLionel Sambuc 
407f4a2713aSLionel Sambuc   typedef llvm::DenseMap<const DeclContext *, DeclContextInfo>
408f4a2713aSLionel Sambuc   DeclContextInfosMap;
409f4a2713aSLionel Sambuc 
410f4a2713aSLionel Sambuc   /// \brief Information about the lexical and visible declarations
411f4a2713aSLionel Sambuc   /// for each DeclContext.
412f4a2713aSLionel Sambuc   DeclContextInfosMap DeclContextInfos;
413f4a2713aSLionel Sambuc 
414f4a2713aSLionel Sambuc   /// \brief Array of file-level DeclIDs sorted by file.
415f4a2713aSLionel Sambuc   const serialization::DeclID *FileSortedDecls;
416f4a2713aSLionel Sambuc   unsigned NumFileSortedDecls;
417f4a2713aSLionel Sambuc 
418f4a2713aSLionel Sambuc   /// \brief Array of redeclaration chain location information within this
419f4a2713aSLionel Sambuc   /// module file, sorted by the first declaration ID.
420f4a2713aSLionel Sambuc   const serialization::LocalRedeclarationsInfo *RedeclarationsMap;
421f4a2713aSLionel Sambuc 
422f4a2713aSLionel Sambuc   /// \brief The number of redeclaration info entries in RedeclarationsMap.
423f4a2713aSLionel Sambuc   unsigned LocalNumRedeclarationsInMap;
424f4a2713aSLionel Sambuc 
425f4a2713aSLionel Sambuc   /// \brief The redeclaration chains for declarations local to this
426f4a2713aSLionel Sambuc   /// module file.
427f4a2713aSLionel Sambuc   SmallVector<uint64_t, 1> RedeclarationChains;
428f4a2713aSLionel Sambuc 
429f4a2713aSLionel Sambuc   /// \brief Array of category list location information within this
430f4a2713aSLionel Sambuc   /// module file, sorted by the definition ID.
431f4a2713aSLionel Sambuc   const serialization::ObjCCategoriesInfo *ObjCCategoriesMap;
432f4a2713aSLionel Sambuc 
433f4a2713aSLionel Sambuc   /// \brief The number of redeclaration info entries in ObjCCategoriesMap.
434f4a2713aSLionel Sambuc   unsigned LocalNumObjCCategoriesInMap;
435f4a2713aSLionel Sambuc 
436f4a2713aSLionel Sambuc   /// \brief The Objective-C category lists for categories known to this
437f4a2713aSLionel Sambuc   /// module.
438f4a2713aSLionel Sambuc   SmallVector<uint64_t, 1> ObjCCategories;
439f4a2713aSLionel Sambuc 
440f4a2713aSLionel Sambuc   // === Types ===
441f4a2713aSLionel Sambuc 
442f4a2713aSLionel Sambuc   /// \brief The number of types in this AST file.
443f4a2713aSLionel Sambuc   unsigned LocalNumTypes;
444f4a2713aSLionel Sambuc 
445f4a2713aSLionel Sambuc   /// \brief Offset of each type within the bitstream, indexed by the
446f4a2713aSLionel Sambuc   /// type ID, or the representation of a Type*.
447f4a2713aSLionel Sambuc   const uint32_t *TypeOffsets;
448f4a2713aSLionel Sambuc 
449f4a2713aSLionel Sambuc   /// \brief Base type ID for types local to this module as represented in
450f4a2713aSLionel Sambuc   /// the global type ID space.
451f4a2713aSLionel Sambuc   serialization::TypeID BaseTypeIndex;
452f4a2713aSLionel Sambuc 
453f4a2713aSLionel Sambuc   /// \brief Remapping table for type IDs in this module.
454f4a2713aSLionel Sambuc   ContinuousRangeMap<uint32_t, int, 2> TypeRemap;
455f4a2713aSLionel Sambuc 
456f4a2713aSLionel Sambuc   // === Miscellaneous ===
457f4a2713aSLionel Sambuc 
458f4a2713aSLionel Sambuc   /// \brief Diagnostic IDs and their mappings that the user changed.
459f4a2713aSLionel Sambuc   SmallVector<uint64_t, 8> PragmaDiagMappings;
460f4a2713aSLionel Sambuc 
461f4a2713aSLionel Sambuc   /// \brief List of modules which depend on this module
462f4a2713aSLionel Sambuc   llvm::SetVector<ModuleFile *> ImportedBy;
463f4a2713aSLionel Sambuc 
464f4a2713aSLionel Sambuc   /// \brief List of modules which this module depends on
465f4a2713aSLionel Sambuc   llvm::SetVector<ModuleFile *> Imports;
466f4a2713aSLionel Sambuc 
467f4a2713aSLionel Sambuc   /// \brief Determine whether this module was directly imported at
468f4a2713aSLionel Sambuc   /// any point during translation.
isDirectlyImported()469f4a2713aSLionel Sambuc   bool isDirectlyImported() const { return DirectlyImported; }
470f4a2713aSLionel Sambuc 
471f4a2713aSLionel Sambuc   /// \brief Dump debugging output for this module.
472f4a2713aSLionel Sambuc   void dump();
473f4a2713aSLionel Sambuc };
474f4a2713aSLionel Sambuc 
475f4a2713aSLionel Sambuc } // end namespace serialization
476f4a2713aSLionel Sambuc 
477f4a2713aSLionel Sambuc } // end namespace clang
478f4a2713aSLionel Sambuc 
479f4a2713aSLionel Sambuc #endif
480