Rename ASTReader::PerFileData to serialization::Module, pulling it out

of ASTReader so it can become its own full-fledged class
(eventually). No functionality change.

llvm-svn: 135767
This commit is contained in:
Douglas Gregor 2011-07-22 16:00:58 +00:00
parent 7f1e2a5c03
commit a6895d8a8f
8 changed files with 383 additions and 366 deletions

View File

@ -158,6 +158,238 @@ private:
void Error(const char *Msg);
};
namespace serialization {
/// \brief Specifies the kind of module that has been loaded.
enum ModuleKind {
MK_Module, ///< File is a module proper.
MK_PCH, ///< File is a PCH file treated as such.
MK_Preamble, ///< File is a PCH file treated as the preamble.
MK_MainFile ///< File is a PCH file treated as the actual main file.
};
/// \brief Information about a module that has been loaded by the ASTReader.
///
/// Each instance of the Module class corresponds to a single AST file, which
/// may be a precompiled header, precompiled preamble, or an AST file of some
/// sort loaded as the main file, all of which are specific formulations of
/// the general notion of a "module". A module may depend on another module
/// (FIXME: or a set of other modules).
class Module {
public:
Module(ModuleKind Kind);
~Module();
// === General information ===
/// \brief The type of this module.
ModuleKind Kind;
/// \brief The file name of the module file.
std::string FileName;
/// \brief The memory buffer that stores the data associated with
/// this AST file.
llvm::OwningPtr<llvm::MemoryBuffer> Buffer;
/// \brief The size of this file, in bits.
uint64_t SizeInBits;
/// \brief The global bit offset (or base) of this module
uint64_t GlobalBitOffset;
/// \brief The bitstream reader from which we'll read the AST file.
llvm::BitstreamReader StreamFile;
/// \brief The main bitstream cursor for the main block.
llvm::BitstreamCursor Stream;
/// \brief The source location where this module was first imported.
SourceLocation ImportLoc;
/// \brief The first source location in this module.
SourceLocation FirstLoc;
// === Source Locations ===
/// \brief Cursor used to read source location entries.
llvm::BitstreamCursor SLocEntryCursor;
/// \brief The number of source location entries in this AST file.
unsigned LocalNumSLocEntries;
/// \brief The base ID in the source manager's view of this module.
int SLocEntryBaseID;
/// \brief The base offset in the source manager's view of this module.
unsigned SLocEntryBaseOffset;
/// \brief Offsets for all of the source location entries in the
/// AST file.
const uint32_t *SLocEntryOffsets;
/// \brief The number of source location file entries in this AST file.
unsigned LocalNumSLocFileEntries;
/// \brief Offsets for all of the source location file entries in the
/// AST file.
const uint32_t *SLocFileOffsets;
/// \brief Remapping table for source locations in this module.
ContinuousRangeMap<uint32_t, int, 2> SLocRemap;
// === Identifiers ===
/// \brief The number of identifiers in this AST file.
unsigned LocalNumIdentifiers;
/// \brief Offsets into the identifier table data.
///
/// This array is indexed by the identifier ID (-1), and provides
/// the offset into IdentifierTableData where the string data is
/// stored.
const uint32_t *IdentifierOffsets;
/// \brief Actual data for the on-disk hash table of identifiers.
///
/// This pointer points into a memory buffer, where the on-disk hash
/// table for identifiers actually lives.
const char *IdentifierTableData;
/// \brief A pointer to an on-disk hash table of opaque type
/// IdentifierHashTable.
void *IdentifierLookupTable;
// === Macros ===
/// \brief The cursor to the start of the preprocessor block, which stores
/// all of the macro definitions.
llvm::BitstreamCursor MacroCursor;
/// \brief The offset of the start of the set of defined macros.
uint64_t MacroStartOffset;
// === Detailed PreprocessingRecord ===
/// \brief The cursor to the start of the (optional) detailed preprocessing
/// record block.
llvm::BitstreamCursor PreprocessorDetailCursor;
/// \brief The offset of the start of the preprocessor detail cursor.
uint64_t PreprocessorDetailStartOffset;
/// \brief The number of macro definitions in this file.
unsigned LocalNumMacroDefinitions;
/// \brief Offsets of all of the macro definitions in the preprocessing
/// record in the AST file.
const uint32_t *MacroDefinitionOffsets;
// === Header search information ===
/// \brief The number of local HeaderFileInfo structures.
unsigned LocalNumHeaderFileInfos;
/// \brief Actual data for the on-disk hash table of header file
/// information.
///
/// This pointer points into a memory buffer, where the on-disk hash
/// table for header file information actually lives.
const char *HeaderFileInfoTableData;
/// \brief The on-disk hash table that contains information about each of
/// the header files.
void *HeaderFileInfoTable;
// === Selectors ===
/// \brief The number of selectors new to this file.
///
/// This is the number of entries in SelectorOffsets.
unsigned LocalNumSelectors;
/// \brief Offsets into the selector lookup table's data array
/// where each selector resides.
const uint32_t *SelectorOffsets;
/// \brief A pointer to the character data that comprises the selector table
///
/// The SelectorOffsets table refers into this memory.
const unsigned char *SelectorLookupTableData;
/// \brief A pointer to an on-disk hash table of opaque type
/// ASTSelectorLookupTable.
///
/// This hash table provides the IDs of all selectors, and the associated
/// instance and factory methods.
void *SelectorLookupTable;
/// \brief Method selectors used in a @selector expression. Used for
/// implementation of -Wselector.
SmallVector<uint64_t, 64> ReferencedSelectorsData;
// === Declarations ===
/// DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block. It
/// has read all the abbreviations at the start of the block and is ready to
/// jump around with these in context.
llvm::BitstreamCursor DeclsCursor;
/// \brief The number of declarations in this AST file.
unsigned LocalNumDecls;
/// \brief Offset of each declaration within the bitstream, indexed
/// by the declaration ID (-1).
const uint32_t *DeclOffsets;
/// \brief A snapshot of the pending instantiations in the chain.
///
/// This record tracks the instantiations that Sema has to perform at the
/// end of the TU. It consists of a pair of values for every pending
/// instantiation where the first value is the ID of the decl and the second
/// is the instantiation location.
SmallVector<uint64_t, 64> PendingInstantiations;
/// \brief The number of C++ base specifier sets in this AST file.
unsigned LocalNumCXXBaseSpecifiers;
/// \brief Offset of each C++ base specifier set within the bitstream,
/// indexed by the C++ base specifier set ID (-1).
const uint32_t *CXXBaseSpecifiersOffsets;
// === Types ===
/// \brief The number of types in this AST file.
unsigned LocalNumTypes;
/// \brief Offset of each type within the bitstream, indexed by the
/// type ID, or the representation of a Type*.
const uint32_t *TypeOffsets;
// === Miscellaneous ===
/// \brief Diagnostic IDs and their mappings that the user changed.
SmallVector<uint64_t, 8> PragmaDiagMappings;
/// \brief The AST stat cache installed for this file, if any.
///
/// The dynamic type of this stat cache is always ASTStatCache
void *StatCache;
/// \brief The number of preallocated preprocessing entities in the
/// preprocessing record.
unsigned NumPreallocatedPreprocessingEntities;
/// \brief The next module in source order.
Module *NextInSource;
/// \brief All the modules that loaded this one. Can contain NULL for
/// directly loaded modules.
SmallVector<Module *, 1> Loaders;
};
} // end namespace serialization
/// \brief Reads an AST files chain containing the contents of a translation
/// unit.
///
@ -182,12 +414,6 @@ class ASTReader
public:
enum ASTReadResult { Success, Failure, IgnorePCH };
/// \brief Types of AST files.
enum ASTFileType {
Module, ///< File is a module proper.
PCH, ///< File is a PCH file treated as such.
Preamble, ///< File is a PCH file treated as the preamble.
MainFile ///< File is a PCH file treated as the actual main file.
};
friend class PCHValidator;
friend class ASTDeclReader;
friend class ASTStmtReader;
@ -196,6 +422,10 @@ public:
friend class TypeLocReader;
friend class ASTWriter;
friend class ASTUnit; // ASTUnit needs to remap source locations.
typedef serialization::Module Module;
typedef serialization::ModuleKind ModuleKind;
private:
/// \brief The receiver of some callbacks invoked by ASTReader.
llvm::OwningPtr<ASTReaderListener> Listener;
@ -223,242 +453,27 @@ private:
/// \brief AST buffers for chained PCHs created and stored in memory.
/// First (not depending on another) PCH in chain is in front.
std::vector<llvm::MemoryBuffer *> ASTBuffers;
public:
/// \brief Information that is needed for every module.
struct PerFileData {
PerFileData(ASTFileType Ty);
~PerFileData();
// === General information ===
/// \brief The type of this AST file.
ASTFileType Type;
/// \brief The file name of the AST file.
std::string FileName;
/// \brief The memory buffer that stores the data associated with
/// this AST file.
llvm::OwningPtr<llvm::MemoryBuffer> Buffer;
/// \brief The size of this file, in bits.
uint64_t SizeInBits;
/// \brief The global bit offset (or base) of this module
uint64_t GlobalBitOffset;
/// \brief The bitstream reader from which we'll read the AST file.
llvm::BitstreamReader StreamFile;
/// \brief The main bitstream cursor for the main block.
llvm::BitstreamCursor Stream;
/// \brief The source location where this module was first imported.
SourceLocation ImportLoc;
/// \brief The first source location in this module.
SourceLocation FirstLoc;
// === Source Locations ===
/// \brief Cursor used to read source location entries.
llvm::BitstreamCursor SLocEntryCursor;
/// \brief The number of source location entries in this AST file.
unsigned LocalNumSLocEntries;
/// \brief The base ID in the source manager's view of this module.
int SLocEntryBaseID;
/// \brief The base offset in the source manager's view of this module.
unsigned SLocEntryBaseOffset;
/// \brief Offsets for all of the source location entries in the
/// AST file.
const uint32_t *SLocEntryOffsets;
/// \brief The number of source location file entries in this AST file.
unsigned LocalNumSLocFileEntries;
/// \brief Offsets for all of the source location file entries in the
/// AST file.
const uint32_t *SLocFileOffsets;
/// \brief Remapping table for source locations in this module.
ContinuousRangeMap<uint32_t, int, 2> SLocRemap;
// === Identifiers ===
/// \brief The number of identifiers in this AST file.
unsigned LocalNumIdentifiers;
/// \brief Offsets into the identifier table data.
///
/// This array is indexed by the identifier ID (-1), and provides
/// the offset into IdentifierTableData where the string data is
/// stored.
const uint32_t *IdentifierOffsets;
/// \brief Actual data for the on-disk hash table of identifiers.
///
/// This pointer points into a memory buffer, where the on-disk hash
/// table for identifiers actually lives.
const char *IdentifierTableData;
/// \brief A pointer to an on-disk hash table of opaque type
/// IdentifierHashTable.
void *IdentifierLookupTable;
// === Macros ===
/// \brief The cursor to the start of the preprocessor block, which stores
/// all of the macro definitions.
llvm::BitstreamCursor MacroCursor;
/// \brief The offset of the start of the set of defined macros.
uint64_t MacroStartOffset;
// === Detailed PreprocessingRecord ===
/// \brief The cursor to the start of the (optional) detailed preprocessing
/// record block.
llvm::BitstreamCursor PreprocessorDetailCursor;
/// \brief The offset of the start of the preprocessor detail cursor.
uint64_t PreprocessorDetailStartOffset;
/// \brief The number of macro definitions in this file.
unsigned LocalNumMacroDefinitions;
/// \brief Offsets of all of the macro definitions in the preprocessing
/// record in the AST file.
const uint32_t *MacroDefinitionOffsets;
// === Header search information ===
/// \brief The number of local HeaderFileInfo structures.
unsigned LocalNumHeaderFileInfos;
/// \brief Actual data for the on-disk hash table of header file
/// information.
///
/// This pointer points into a memory buffer, where the on-disk hash
/// table for header file information actually lives.
const char *HeaderFileInfoTableData;
/// \brief The on-disk hash table that contains information about each of
/// the header files.
void *HeaderFileInfoTable;
// === Selectors ===
/// \brief The number of selectors new to this file.
///
/// This is the number of entries in SelectorOffsets.
unsigned LocalNumSelectors;
/// \brief Offsets into the selector lookup table's data array
/// where each selector resides.
const uint32_t *SelectorOffsets;
/// \brief A pointer to the character data that comprises the selector table
///
/// The SelectorOffsets table refers into this memory.
const unsigned char *SelectorLookupTableData;
/// \brief A pointer to an on-disk hash table of opaque type
/// ASTSelectorLookupTable.
///
/// This hash table provides the IDs of all selectors, and the associated
/// instance and factory methods.
void *SelectorLookupTable;
/// \brief Method selectors used in a @selector expression. Used for
/// implementation of -Wselector.
SmallVector<uint64_t, 64> ReferencedSelectorsData;
// === Declarations ===
/// DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block. It
/// has read all the abbreviations at the start of the block and is ready to
/// jump around with these in context.
llvm::BitstreamCursor DeclsCursor;
/// \brief The number of declarations in this AST file.
unsigned LocalNumDecls;
/// \brief Offset of each declaration within the bitstream, indexed
/// by the declaration ID (-1).
const uint32_t *DeclOffsets;
/// \brief A snapshot of the pending instantiations in the chain.
///
/// This record tracks the instantiations that Sema has to perform at the
/// end of the TU. It consists of a pair of values for every pending
/// instantiation where the first value is the ID of the decl and the second
/// is the instantiation location.
SmallVector<uint64_t, 64> PendingInstantiations;
/// \brief The number of C++ base specifier sets in this AST file.
unsigned LocalNumCXXBaseSpecifiers;
/// \brief Offset of each C++ base specifier set within the bitstream,
/// indexed by the C++ base specifier set ID (-1).
const uint32_t *CXXBaseSpecifiersOffsets;
// === Types ===
/// \brief The number of types in this AST file.
unsigned LocalNumTypes;
/// \brief Offset of each type within the bitstream, indexed by the
/// type ID, or the representation of a Type*.
const uint32_t *TypeOffsets;
// === Miscellaneous ===
/// \brief Diagnostic IDs and their mappings that the user changed.
SmallVector<uint64_t, 8> PragmaDiagMappings;
/// \brief The AST stat cache installed for this file, if any.
///
/// The dynamic type of this stat cache is always ASTStatCache
void *StatCache;
/// \brief The number of preallocated preprocessing entities in the
/// preprocessing record.
unsigned NumPreallocatedPreprocessingEntities;
/// \brief The next module in source order.
PerFileData *NextInSource;
/// \brief All the modules that loaded this one. Can contain NULL for
/// directly loaded modules.
SmallVector<PerFileData *, 1> Loaders;
};
private:
/// \brief All loaded modules, indexed by name.
llvm::StringMap<PerFileData*> Modules;
llvm::StringMap<Module*> Modules;
/// \brief The first module in source order.
PerFileData *FirstInSource;
Module *FirstInSource;
/// \brief The chain of AST files. The first entry is the one named by the
/// user, the last one is the one that doesn't depend on anything further.
/// That is, the entry I was created with -include-pch I+1.
SmallVector<PerFileData*, 2> Chain;
SmallVector<Module*, 2> Chain;
/// \brief A map of global bit offsets to the module that stores entities
/// at those bit offsets.
ContinuousRangeMap<uint64_t, PerFileData*, 4> GlobalBitOffsetsMap;
ContinuousRangeMap<uint64_t, Module*, 4> GlobalBitOffsetsMap;
/// \brief SLocEntries that we're going to preload.
SmallVector<int, 64> PreloadSLocEntries;
/// \brief A map of negated SLocEntryIDs to the modules containing them.
ContinuousRangeMap<unsigned, PerFileData*, 64> GlobalSLocEntryMap;
ContinuousRangeMap<unsigned, Module*, 64> GlobalSLocEntryMap;
/// \brief Types that have already been loaded from the chain.
///
@ -467,7 +482,7 @@ private:
std::vector<QualType> TypesLoaded;
typedef ContinuousRangeMap<serialization::TypeID,
std::pair<PerFileData *, int32_t>, 4>
std::pair<Module *, int32_t>, 4>
GlobalTypeMapType;
/// \brief Mapping from global type IDs to the module in which the
@ -493,7 +508,7 @@ private:
std::vector<Decl *> DeclsLoaded;
typedef ContinuousRangeMap<serialization::DeclID,
std::pair<PerFileData *, int32_t>, 4>
std::pair<Module *, int32_t>, 4>
GlobalDeclMapType;
/// \brief Mapping from global declaration IDs to the module in which the
@ -501,7 +516,7 @@ private:
/// global declaration ID to produce a local ID.
GlobalDeclMapType GlobalDeclMap;
typedef std::pair<PerFileData *, uint64_t> FileOffset;
typedef std::pair<Module *, uint64_t> FileOffset;
typedef SmallVector<FileOffset, 2> FileOffsetsTy;
typedef llvm::DenseMap<serialization::DeclID, FileOffsetsTy>
DeclUpdateOffsetsMap;
@ -511,14 +526,14 @@ private:
DeclUpdateOffsetsMap DeclUpdateOffsets;
typedef llvm::DenseMap<serialization::DeclID,
std::pair<PerFileData *, uint64_t> >
std::pair<Module *, uint64_t> >
DeclReplacementMap;
/// \brief Declarations that have been replaced in a later file in the chain.
DeclReplacementMap ReplacedDecls;
/// \brief Information about the contents of a DeclContext.
struct DeclContextInfo {
PerFileData *F;
Module *F;
void *NameLookupTableData; // a ASTDeclContextNameLookupTable.
const serialization::KindDeclIDPair *LexicalDecls;
unsigned NumLexicalDecls;
@ -574,7 +589,7 @@ private:
std::vector<IdentifierInfo *> IdentifiersLoaded;
typedef ContinuousRangeMap<serialization::IdentID,
std::pair<PerFileData *, int32_t>, 4>
std::pair<Module *, int32_t>, 4>
GlobalIdentifierMapType;
/// \brief Mapping from global identifer IDs to the module in which the
@ -590,7 +605,7 @@ private:
SmallVector<Selector, 16> SelectorsLoaded;
typedef ContinuousRangeMap<serialization::SelectorID,
std::pair<PerFileData *, int32_t>, 4>
std::pair<Module *, int32_t>, 4>
GlobalSelectorMapType;
/// \brief Mapping from global selector IDs to the module in which the
@ -602,7 +617,7 @@ private:
SmallVector<MacroDefinition *, 16> MacroDefinitionsLoaded;
typedef ContinuousRangeMap<serialization::MacroID,
std::pair<PerFileData *, int32_t>, 4>
std::pair<Module *, int32_t>, 4>
GlobalMacroDefinitionMapType;
/// \brief Mapping from global macro definition IDs to the module in which the
@ -615,7 +630,7 @@ private:
/// record resides.
llvm::DenseMap<IdentifierInfo *, uint64_t> UnreadMacroRecordOffsets;
typedef ContinuousRangeMap<unsigned, std::pair<PerFileData *, int>, 4>
typedef ContinuousRangeMap<unsigned, std::pair<Module *, int>, 4>
GlobalPreprocessedEntityMapType;
/// \brief Mapping from global preprocessing entity IDs to the module in
@ -624,7 +639,7 @@ private:
GlobalPreprocessedEntityMapType GlobalPreprocessedEntityMap;
typedef ContinuousRangeMap<serialization::CXXBaseSpecifiersID,
std::pair<PerFileData *, int32_t>, 4>
std::pair<Module *, int32_t>, 4>
GlobalCXXBaseSpecifiersMapType;
/// \brief Mapping from global CXX base specifier IDs to the module in which the
@ -893,7 +908,7 @@ private:
std::string SuggestedPredefines;
/// \brief Reads a statement from the specified cursor.
Stmt *ReadStmtFromStream(PerFileData &F);
Stmt *ReadStmtFromStream(Module &F);
/// \brief Get a FileEntry out of stored-in-PCH filename, making sure we take
/// into account all the necessary relocations.
@ -901,20 +916,20 @@ private:
void MaybeAddSystemRootToFilename(std::string &Filename);
ASTReadResult ReadASTCore(StringRef FileName, ASTFileType Type);
ASTReadResult ReadASTBlock(PerFileData &F);
ASTReadResult ReadASTCore(StringRef FileName, ModuleKind Type);
ASTReadResult ReadASTBlock(Module &F);
bool CheckPredefinesBuffers();
bool ParseLineTable(PerFileData &F, SmallVectorImpl<uint64_t> &Record);
ASTReadResult ReadSourceManagerBlock(PerFileData &F);
bool ParseLineTable(Module &F, SmallVectorImpl<uint64_t> &Record);
ASTReadResult ReadSourceManagerBlock(Module &F);
ASTReadResult ReadSLocEntryRecord(int ID);
llvm::BitstreamCursor &SLocCursorForID(int ID);
SourceLocation getImportLocation(PerFileData *F);
SourceLocation getImportLocation(Module *F);
bool ParseLanguageOptions(const SmallVectorImpl<uint64_t> &Record);
struct RecordLocation {
RecordLocation(PerFileData *M, uint64_t O)
RecordLocation(Module *M, uint64_t O)
: F(M), Offset(O) {}
PerFileData *F;
Module *F;
uint64_t Offset;
};
@ -997,7 +1012,7 @@ public:
/// \brief Load the precompiled header designated by the given file
/// name.
ASTReadResult ReadAST(const std::string &FileName, ASTFileType Type);
ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type);
/// \brief Checks that no file that is stored in PCH is out-of-sync with
/// the actual file in the file system.
@ -1100,16 +1115,16 @@ public:
/// \brief Reads a TemplateArgumentLocInfo appropriate for the
/// given TemplateArgument kind.
TemplateArgumentLocInfo
GetTemplateArgumentLocInfo(PerFileData &F, TemplateArgument::ArgKind Kind,
GetTemplateArgumentLocInfo(Module &F, TemplateArgument::ArgKind Kind,
const RecordData &Record, unsigned &Idx);
/// \brief Reads a TemplateArgumentLoc.
TemplateArgumentLoc
ReadTemplateArgumentLoc(PerFileData &F,
ReadTemplateArgumentLoc(Module &F,
const RecordData &Record, unsigned &Idx);
/// \brief Reads a declarator info from the given record.
TypeSourceInfo *GetTypeSourceInfo(PerFileData &F,
TypeSourceInfo *GetTypeSourceInfo(Module &F,
const RecordData &Record, unsigned &Idx);
/// \brief Resolve and return the translation unit declaration.
@ -1120,14 +1135,14 @@ public:
QualType GetType(serialization::TypeID ID);
/// \brief Resolve a local type ID within a given AST file into a type.
QualType getLocalType(PerFileData &F, unsigned LocalID);
QualType getLocalType(Module &F, unsigned LocalID);
/// \brief Map a local type ID within a given AST file into a global type ID.
serialization::TypeID getGlobalTypeID(PerFileData &F, unsigned LocalID) const;
serialization::TypeID getGlobalTypeID(Module &F, unsigned LocalID) const;
/// \brief Read a type from the current position in the given record, which
/// was read from the given AST file.
QualType readType(PerFileData &F, const RecordData &Record, unsigned &Idx) {
QualType readType(Module &F, const RecordData &Record, unsigned &Idx) {
if (Idx >= Record.size())
return QualType();
@ -1146,7 +1161,7 @@ public:
/// \brief Map from a local declaration ID within a given module to a
/// global declaration ID.
serialization::DeclID getGlobalDeclID(PerFileData &F, unsigned LocalID) const;
serialization::DeclID getGlobalDeclID(Module &F, unsigned LocalID) const;
/// \brief Resolve a declaration ID into a declaration, potentially
/// building a new declaration.
@ -1154,7 +1169,7 @@ public:
virtual Decl *GetExternalDecl(uint32_t ID);
/// \brief Reads a declaration with the given local ID in the give module.
Decl *GetLocalDecl(PerFileData &F, uint32_t LocalID) {
Decl *GetLocalDecl(Module &F, uint32_t LocalID) {
return GetDecl(getGlobalDeclID(F, LocalID));
}
@ -1162,7 +1177,7 @@ public:
///
/// \returns The requested declaration, casted to the given return type.
template<typename T>
T *GetLocalDeclAs(PerFileData &F, uint32_t LocalID) {
T *GetLocalDeclAs(Module &F, uint32_t LocalID) {
return cast_or_null<T>(GetLocalDecl(F, LocalID));
}
@ -1170,12 +1185,12 @@ public:
/// given module.
///
/// \returns The declaration ID read from the record, adjusted to a global ID.
serialization::DeclID ReadDeclID(PerFileData &F, const RecordData &Record,
serialization::DeclID ReadDeclID(Module &F, const RecordData &Record,
unsigned &Idx);
/// \brief Reads a declaration from the given position in a record in the
/// given module.
Decl *ReadDecl(PerFileData &F, const RecordData &R, unsigned &I) {
Decl *ReadDecl(Module &F, const RecordData &R, unsigned &I) {
return GetDecl(ReadDeclID(F, R, I));
}
@ -1185,7 +1200,7 @@ public:
/// \returns The declaration read from this location, casted to the given
/// result type.
template<typename T>
T *ReadDeclAs(PerFileData &F, const RecordData &R, unsigned &I) {
T *ReadDeclAs(Module &F, const RecordData &R, unsigned &I) {
return cast_or_null<T>(GetDecl(ReadDeclID(F, R, I)));
}
@ -1332,59 +1347,59 @@ public:
}
/// \brief Read a declaration name.
DeclarationName ReadDeclarationName(PerFileData &F,
DeclarationName ReadDeclarationName(Module &F,
const RecordData &Record, unsigned &Idx);
void ReadDeclarationNameLoc(PerFileData &F,
void ReadDeclarationNameLoc(Module &F,
DeclarationNameLoc &DNLoc, DeclarationName Name,
const RecordData &Record, unsigned &Idx);
void ReadDeclarationNameInfo(PerFileData &F, DeclarationNameInfo &NameInfo,
void ReadDeclarationNameInfo(Module &F, DeclarationNameInfo &NameInfo,
const RecordData &Record, unsigned &Idx);
void ReadQualifierInfo(PerFileData &F, QualifierInfo &Info,
void ReadQualifierInfo(Module &F, QualifierInfo &Info,
const RecordData &Record, unsigned &Idx);
NestedNameSpecifier *ReadNestedNameSpecifier(PerFileData &F,
NestedNameSpecifier *ReadNestedNameSpecifier(Module &F,
const RecordData &Record,
unsigned &Idx);
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(PerFileData &F,
NestedNameSpecifierLoc ReadNestedNameSpecifierLoc(Module &F,
const RecordData &Record,
unsigned &Idx);
/// \brief Read a template name.
TemplateName ReadTemplateName(PerFileData &F, const RecordData &Record,
TemplateName ReadTemplateName(Module &F, const RecordData &Record,
unsigned &Idx);
/// \brief Read a template argument.
TemplateArgument ReadTemplateArgument(PerFileData &F,
TemplateArgument ReadTemplateArgument(Module &F,
const RecordData &Record,unsigned &Idx);
/// \brief Read a template parameter list.
TemplateParameterList *ReadTemplateParameterList(PerFileData &F,
TemplateParameterList *ReadTemplateParameterList(Module &F,
const RecordData &Record,
unsigned &Idx);
/// \brief Read a template argument array.
void
ReadTemplateArgumentList(SmallVector<TemplateArgument, 8> &TemplArgs,
PerFileData &F, const RecordData &Record,
Module &F, const RecordData &Record,
unsigned &Idx);
/// \brief Read a UnresolvedSet structure.
void ReadUnresolvedSet(PerFileData &F, UnresolvedSetImpl &Set,
void ReadUnresolvedSet(Module &F, UnresolvedSetImpl &Set,
const RecordData &Record, unsigned &Idx);
/// \brief Read a C++ base specifier.
CXXBaseSpecifier ReadCXXBaseSpecifier(PerFileData &F,
CXXBaseSpecifier ReadCXXBaseSpecifier(Module &F,
const RecordData &Record,unsigned &Idx);
/// \brief Read a CXXCtorInitializer array.
std::pair<CXXCtorInitializer **, unsigned>
ReadCXXCtorInitializers(PerFileData &F, const RecordData &Record,
ReadCXXCtorInitializers(Module &F, const RecordData &Record,
unsigned &Idx);
/// \brief Read a source location from raw form.
SourceLocation ReadSourceLocation(PerFileData &Module, unsigned Raw) {
SourceLocation ReadSourceLocation(Module &Module, unsigned Raw) {
unsigned Flag = Raw & (1U << 31);
unsigned Offset = Raw & ~(1U << 31);
assert(Module.SLocRemap.find(Offset) != Module.SLocRemap.end() &&
@ -1397,13 +1412,13 @@ public:
}
/// \brief Read a source location.
SourceLocation ReadSourceLocation(PerFileData &Module,
SourceLocation ReadSourceLocation(Module &Module,
const RecordData &Record, unsigned& Idx) {
return ReadSourceLocation(Module, Record[Idx++]);
}
/// \brief Read a source range.
SourceRange ReadSourceRange(PerFileData &F,
SourceRange ReadSourceRange(Module &F,
const RecordData &Record, unsigned& Idx);
/// \brief Read an integral value
@ -1421,18 +1436,18 @@ public:
/// \brief Read a version tuple.
VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx);
CXXTemporary *ReadCXXTemporary(PerFileData &F, const RecordData &Record,
CXXTemporary *ReadCXXTemporary(Module &F, const RecordData &Record,
unsigned &Idx);
/// \brief Reads attributes from the current stream position.
void ReadAttributes(PerFileData &F, AttrVec &Attrs,
void ReadAttributes(Module &F, AttrVec &Attrs,
const RecordData &Record, unsigned &Idx);
/// \brief Reads a statement.
Stmt *ReadStmt(PerFileData &F);
Stmt *ReadStmt(Module &F);
/// \brief Reads an expression.
Expr *ReadExpr(PerFileData &F);
Expr *ReadExpr(Module &F);
/// \brief Reads a sub-statement operand during statement reading.
Stmt *ReadSubStmt() {
@ -1448,15 +1463,15 @@ public:
Expr *ReadSubExpr();
/// \brief Reads the macro record located at the given offset.
PreprocessedEntity *ReadMacroRecord(PerFileData &F, uint64_t Offset);
PreprocessedEntity *ReadMacroRecord(Module &F, uint64_t Offset);
/// \brief Reads the preprocessed entity located at the current stream
/// position.
PreprocessedEntity *LoadPreprocessedEntity(PerFileData &F);
PreprocessedEntity *LoadPreprocessedEntity(Module &F);
/// \brief Note that the identifier is a macro whose record will be loaded
/// from the given AST file at the given (file-local) offset.
void SetIdentifierIsMacro(IdentifierInfo *II, PerFileData &F,
void SetIdentifierIsMacro(IdentifierInfo *II, Module &F,
uint64_t Offset);
/// \brief Read the set of macros defined by this external macro source.

View File

@ -595,7 +595,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
Reader->setListener(new ASTInfoCollector(LangInfo, HeaderInfo, TargetTriple,
Predefines, Counter));
switch (Reader->ReadAST(Filename, ASTReader::MainFile)) {
switch (Reader->ReadAST(Filename, serialization::MK_MainFile)) {
case ASTReader::Success:
break;
@ -2380,7 +2380,7 @@ void ASTUnit::TranslateStoredDiagnostics(
llvm::SmallVector<StoredDiagnostic, 4> Result;
Result.reserve(Diags.size());
assert(MMan && "Don't have a module manager");
ASTReader::PerFileData *Mod = MMan->Modules.lookup(ModName);
serialization::Module *Mod = MMan->Modules.lookup(ModName);
assert(Mod && "Don't have preamble module");
SLocRemap &Remap = Mod->SLocRemap;
for (unsigned I = 0, N = Diags.size(); I != N; ++I) {

View File

@ -295,8 +295,9 @@ CompilerInstance::createPCHExternalASTSource(llvm::StringRef Path,
Reader->setDeserializationListener(
static_cast<ASTDeserializationListener *>(DeserializationListener));
switch (Reader->ReadAST(Path,
Preamble ? ASTReader::Preamble : ASTReader::PCH)) {
switch (Reader->ReadAST(Path,
Preamble ? serialization::MK_Preamble
: serialization::MK_PCH)) {
case ASTReader::Success:
// Set the predefines buffer as suggested by the PCH reader. Typically, the
// predefines buffer will be empty.

View File

@ -483,7 +483,7 @@ ASTReader::setDeserializationListener(ASTDeserializationListener *Listener) {
namespace {
class ASTSelectorLookupTrait {
ASTReader &Reader;
ASTReader::PerFileData &F;
Module &F;
public:
struct data_type {
@ -494,7 +494,7 @@ public:
typedef Selector external_key_type;
typedef external_key_type internal_key_type;
ASTSelectorLookupTrait(ASTReader &Reader, ASTReader::PerFileData &F)
ASTSelectorLookupTrait(ASTReader &Reader, Module &F)
: Reader(Reader), F(F) { }
static bool EqualKey(const internal_key_type& a,
@ -595,7 +595,7 @@ typedef OnDiskChainedHashTable<ASTSelectorLookupTrait>
namespace clang {
class ASTIdentifierLookupTrait {
ASTReader &Reader;
ASTReader::PerFileData &F;
Module &F;
// If we know the IdentifierInfo in advance, it is here and we will
// not build a new one. Used when deserializing information about an
@ -609,7 +609,7 @@ public:
typedef external_key_type internal_key_type;
ASTIdentifierLookupTrait(ASTReader &Reader, ASTReader::PerFileData &F,
ASTIdentifierLookupTrait(ASTReader &Reader, Module &F,
IdentifierInfo *II = 0)
: Reader(Reader), F(F), KnownII(II) { }
@ -738,7 +738,7 @@ typedef OnDiskChainedHashTable<ASTIdentifierLookupTrait>
namespace {
class ASTDeclContextNameLookupTrait {
ASTReader &Reader;
ASTReader::PerFileData &F;
Module &F;
public:
/// \brief Pair of begin/end iterators for DeclIDs.
@ -757,7 +757,7 @@ public:
typedef DeclNameKey internal_key_type;
explicit ASTDeclContextNameLookupTrait(ASTReader &Reader,
ASTReader::PerFileData &F)
Module &F)
: Reader(Reader), F(F) { }
static bool EqualKey(const internal_key_type& a,
@ -996,7 +996,7 @@ bool ASTReader::CheckPredefinesBuffers() {
/// \brief Read the line table in the source manager block.
/// \returns true if there was an error.
bool ASTReader::ParseLineTable(PerFileData &F,
bool ASTReader::ParseLineTable(Module &F,
llvm::SmallVectorImpl<uint64_t> &Record) {
unsigned Idx = 0;
LineTableInfo &LineTable = SourceMgr.getLineTable();
@ -1140,7 +1140,7 @@ public:
/// \brief Read a source manager block
ASTReader::ASTReadResult ASTReader::ReadSourceManagerBlock(PerFileData &F) {
ASTReader::ASTReadResult ASTReader::ReadSourceManagerBlock(Module &F) {
using namespace SrcMgr;
llvm::BitstreamCursor &SLocEntryCursor = F.SLocEntryCursor;
@ -1249,7 +1249,7 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(int ID) {
return Failure;
}
PerFileData *F = GlobalSLocEntryMap.find(-ID)->second;
Module *F = GlobalSLocEntryMap.find(-ID)->second;
F->SLocEntryCursor.JumpToBit(F->SLocEntryOffsets[ID - F->SLocEntryBaseID]);
llvm::BitstreamCursor &SLocEntryCursor = F->SLocEntryCursor;
unsigned BaseOffset = F->SLocEntryBaseOffset;
@ -1313,7 +1313,7 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(int ID) {
}
SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]);
if (IncludeLoc.isInvalid() && F->Type != MainFile) {
if (IncludeLoc.isInvalid() && F->Kind != MK_MainFile) {
// This is the module's main file.
IncludeLoc = getImportLocation(F);
}
@ -1373,7 +1373,7 @@ ASTReader::ASTReadResult ASTReader::ReadSLocEntryRecord(int ID) {
}
/// \brief Find the location where the module F is imported.
SourceLocation ASTReader::getImportLocation(PerFileData *F) {
SourceLocation ASTReader::getImportLocation(Module *F) {
if (F->ImportLoc.isValid())
return F->ImportLoc;
// Otherwise we have a PCH. It's considered to be "imported" at the first
@ -1412,7 +1412,7 @@ bool ASTReader::ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor,
}
}
PreprocessedEntity *ASTReader::ReadMacroRecord(PerFileData &F, uint64_t Offset) {
PreprocessedEntity *ASTReader::ReadMacroRecord(Module &F, uint64_t Offset) {
assert(PP && "Forgot to set Preprocessor ?");
llvm::BitstreamCursor &Stream = F.MacroCursor;
@ -1532,7 +1532,7 @@ PreprocessedEntity *ASTReader::ReadMacroRecord(PerFileData &F, uint64_t Offset)
return 0;
}
PreprocessedEntity *ASTReader::LoadPreprocessedEntity(PerFileData &F) {
PreprocessedEntity *ASTReader::LoadPreprocessedEntity(Module &F) {
assert(PP && "Forgot to set Preprocessor ?");
unsigned Code = F.PreprocessorDetailCursor.ReadCode();
switch (Code) {
@ -1730,7 +1730,7 @@ namespace {
typedef OnDiskChainedHashTable<HeaderFileInfoTrait>
HeaderFileInfoLookupTable;
void ASTReader::SetIdentifierIsMacro(IdentifierInfo *II, PerFileData &F,
void ASTReader::SetIdentifierIsMacro(IdentifierInfo *II, Module &F,
uint64_t Offset) {
// Note that this identifier has a macro definition.
II->setHasMacroDefinition(true);
@ -1741,7 +1741,7 @@ void ASTReader::SetIdentifierIsMacro(IdentifierInfo *II, PerFileData &F,
void ASTReader::ReadDefinedMacros() {
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
PerFileData &F = *Chain[N - I - 1];
Module &F = *Chain[N - I - 1];
llvm::BitstreamCursor &MacroCursor = F.MacroCursor;
// If there was no preprocessor block, skip this file.
@ -1821,7 +1821,7 @@ MacroDefinition *ASTReader::getMacroDefinition(MacroID ID) {
GlobalMacroDefinitionMapType::iterator I =GlobalMacroDefinitionMap.find(ID);
assert(I != GlobalMacroDefinitionMap.end() &&
"Corrupted global macro definition map");
PerFileData &F = *I->second.first;
Module &F = *I->second.first;
unsigned Index = ID - 1 + I->second.second;
SavedStreamPosition SavedPosition(F.PreprocessorDetailCursor);
F.PreprocessorDetailCursor.JumpToBit(F.MacroDefinitionOffsets[Index]);
@ -1872,7 +1872,7 @@ void ASTReader::MaybeAddSystemRootToFilename(std::string &Filename) {
}
ASTReader::ASTReadResult
ASTReader::ReadASTBlock(PerFileData &F) {
ASTReader::ReadASTBlock(Module &F) {
llvm::BitstreamCursor &Stream = F.Stream;
if (Stream.EnterSubBlock(AST_BLOCK_ID)) {
@ -2002,7 +2002,8 @@ ASTReader::ReadASTBlock(PerFileData &F) {
}
// Load the chained file, which is always a PCH file.
switch(ReadASTCore(llvm::StringRef(BlobStart, BlobLen), PCH)) {
// FIXME: This could end up being a module.
switch(ReadASTCore(llvm::StringRef(BlobStart, BlobLen), MK_PCH)) {
case Failure: return Failure;
// If we have to ignore the dependency, we'll have to ignore this too.
case IgnorePCH: return IgnorePCH;
@ -2222,7 +2223,7 @@ ASTReader::ReadASTBlock(PerFileData &F) {
uint32_t Offset = io::ReadUnalignedLE32(Data);
uint16_t Len = io::ReadUnalignedLE16(Data);
llvm::StringRef Name = llvm::StringRef((const char*)Data, Len);
PerFileData *OM = Modules.lookup(Name);
Module *OM = Modules.lookup(Name);
if (!OM) {
Error("SourceLocation remap refers to unknown module");
return Failure;
@ -2465,7 +2466,7 @@ ASTReader::ReadASTBlock(PerFileData &F) {
ASTReader::ASTReadResult ASTReader::validateFileEntries() {
for (unsigned CI = 0, CN = Chain.size(); CI != CN; ++CI) {
PerFileData *F = Chain[CI];
Module *F = Chain[CI];
llvm::BitstreamCursor &SLocEntryCursor = F->SLocEntryCursor;
for (unsigned i = 0, e = F->LocalNumSLocFileEntries; i != e; ++i) {
@ -2533,7 +2534,7 @@ ASTReader::ASTReadResult ASTReader::validateFileEntries() {
}
ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
ASTFileType Type) {
ModuleKind Type) {
switch(ReadASTCore(FileName, Type)) {
case Failure: return Failure;
case IgnorePCH: return IgnorePCH;
@ -2613,7 +2614,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
// If this AST file is a precompiled preamble, then set the main file ID of
// the source manager to the file source file from which the preamble was
// built. This is the only valid way to use a precompiled preamble.
if (Type == Preamble) {
if (Type == MK_Preamble) {
if (OriginalFileID.isInvalid()) {
SourceLocation Loc
= SourceMgr.getLocation(FileMgr.getFile(getOriginalSourceFile()), 1, 1);
@ -2633,10 +2634,10 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
}
ASTReader::ASTReadResult ASTReader::ReadASTCore(llvm::StringRef FileName,
ASTFileType Type) {
PerFileData *Prev = Chain.empty() ? 0 : Chain.back();
Chain.push_back(new PerFileData(Type));
PerFileData &F = *Chain.back();
ModuleKind Type) {
Module *Prev = Chain.empty() ? 0 : Chain.back();
Chain.push_back(new Module(Type));
Module &F = *Chain.back();
if (Prev)
Prev->NextInSource = &F;
else
@ -2741,7 +2742,7 @@ ASTReader::ASTReadResult ASTReader::ReadASTCore(llvm::StringRef FileName,
}
}
// Once read, set the PerFileData bit base offset and update the size in
// Once read, set the Module bit base offset and update the size in
// bits of all files we've seen.
F.GlobalBitOffset = TotalModulesSizeInBits;
TotalModulesSizeInBits += F.SizeInBits;
@ -3060,7 +3061,7 @@ bool ASTReader::ParseLanguageOptions(
void ASTReader::ReadPreprocessedEntities() {
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
PerFileData &F = *Chain[I];
Module &F = *Chain[I];
if (!F.PreprocessorDetailCursor.getBitStreamReader())
continue;
@ -3083,7 +3084,7 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntityAtOffset(uint64_t Offset) {
HeaderFileInfo ASTReader::GetHeaderFileInfo(const FileEntry *FE) {
HeaderFileInfoTrait Trait(FE->getName());
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
PerFileData &F = *Chain[I];
Module &F = *Chain[I];
HeaderFileInfoLookupTable *Table
= static_cast<HeaderFileInfoLookupTable *>(F.HeaderFileInfoTable);
if (!Table)
@ -3107,7 +3108,7 @@ HeaderFileInfo ASTReader::GetHeaderFileInfo(const FileEntry *FE) {
void ASTReader::ReadPragmaDiagnosticMappings(Diagnostic &Diag) {
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
PerFileData &F = *Chain[I];
Module &F = *Chain[I];
unsigned Idx = 0;
while (Idx < F.PragmaDiagMappings.size()) {
SourceLocation Loc = ReadSourceLocation(F, F.PragmaDiagMappings[Idx++]);
@ -3565,7 +3566,7 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
class clang::TypeLocReader : public TypeLocVisitor<TypeLocReader> {
ASTReader &Reader;
ASTReader::PerFileData &F;
Module &F;
llvm::BitstreamCursor &DeclsCursor;
const ASTReader::RecordData &Record;
unsigned &Idx;
@ -3581,7 +3582,7 @@ class clang::TypeLocReader : public TypeLocVisitor<TypeLocReader> {
}
public:
TypeLocReader(ASTReader &Reader, ASTReader::PerFileData &F,
TypeLocReader(ASTReader &Reader, Module &F,
const ASTReader::RecordData &Record, unsigned &Idx)
: Reader(Reader), F(F), DeclsCursor(F.DeclsCursor), Record(Record), Idx(Idx)
{ }
@ -3793,7 +3794,7 @@ void TypeLocReader::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
TL.setStarLoc(ReadSourceLocation(Record, Idx));
}
TypeSourceInfo *ASTReader::GetTypeSourceInfo(PerFileData &F,
TypeSourceInfo *ASTReader::GetTypeSourceInfo(Module &F,
const RecordData &Record,
unsigned &Idx) {
QualType InfoTy = readType(F, Record, Idx);
@ -3873,12 +3874,12 @@ QualType ASTReader::GetType(TypeID ID) {
return TypesLoaded[Index].withFastQualifiers(FastQuals);
}
QualType ASTReader::getLocalType(PerFileData &F, unsigned LocalID) {
QualType ASTReader::getLocalType(Module &F, unsigned LocalID) {
return GetType(getGlobalTypeID(F, LocalID));
}
serialization::TypeID
ASTReader::getGlobalTypeID(PerFileData &F, unsigned LocalID) const {
ASTReader::getGlobalTypeID(Module &F, unsigned LocalID) const {
// FIXME: Map from local type ID to global type ID.
return LocalID;
}
@ -3905,7 +3906,7 @@ TypeIdx ASTReader::GetTypeIdx(QualType T) const {
}
TemplateArgumentLocInfo
ASTReader::GetTemplateArgumentLocInfo(PerFileData &F,
ASTReader::GetTemplateArgumentLocInfo(Module &F,
TemplateArgument::ArgKind Kind,
const RecordData &Record,
unsigned &Index) {
@ -3940,7 +3941,7 @@ ASTReader::GetTemplateArgumentLocInfo(PerFileData &F,
}
TemplateArgumentLoc
ASTReader::ReadTemplateArgumentLoc(PerFileData &F,
ASTReader::ReadTemplateArgumentLoc(Module &F,
const RecordData &Record, unsigned &Index) {
TemplateArgument Arg = ReadTemplateArgument(F, Record, Index);
@ -4007,7 +4008,7 @@ TranslationUnitDecl *ASTReader::GetTranslationUnitDecl() {
}
serialization::DeclID
ASTReader::getGlobalDeclID(PerFileData &F, unsigned LocalID) const {
ASTReader::getGlobalDeclID(Module &F, unsigned LocalID) const {
// FIXME: Perform local -> global remapping for declarations.
return LocalID;
}
@ -4031,7 +4032,7 @@ Decl *ASTReader::GetDecl(DeclID ID) {
return DeclsLoaded[Index];
}
serialization::DeclID ASTReader::ReadDeclID(PerFileData &F,
serialization::DeclID ASTReader::ReadDeclID(Module &F,
const RecordData &Record,
unsigned &Idx) {
if (Idx >= Record.size()) {
@ -4247,15 +4248,15 @@ void ASTReader::PrintStats() {
std::fprintf(stderr, "\n");
}
template<typename Key, typename PerFileData, unsigned InitialCapacity>
template<typename Key, typename Module, unsigned InitialCapacity>
static void
dumpModuleIDMap(llvm::StringRef Name,
const ContinuousRangeMap<Key, PerFileData *,
const ContinuousRangeMap<Key, Module *,
InitialCapacity> &Map) {
if (Map.begin() == Map.end())
return;
typedef ContinuousRangeMap<Key, PerFileData *, InitialCapacity> MapType;
typedef ContinuousRangeMap<Key, Module *, InitialCapacity> MapType;
llvm::errs() << Name << ":\n";
for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
I != IEnd; ++I) {
@ -4264,18 +4265,18 @@ dumpModuleIDMap(llvm::StringRef Name,
}
}
template<typename Key, typename PerFileData, typename Adjustment,
template<typename Key, typename Module, typename Adjustment,
unsigned InitialCapacity>
static void
dumpModuleIDOffsetMap(llvm::StringRef Name,
const ContinuousRangeMap<Key,
std::pair<PerFileData *,
std::pair<Module *,
Adjustment>,
InitialCapacity> &Map) {
if (Map.begin() == Map.end())
return;
typedef ContinuousRangeMap<Key, std::pair<PerFileData *, Adjustment>,
typedef ContinuousRangeMap<Key, std::pair<Module *, Adjustment>,
InitialCapacity> MapType;
llvm::errs() << Name << ":\n";
for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
@ -4383,7 +4384,7 @@ void ASTReader::InitializeSema(Sema &S) {
SemaObj->StdBadAlloc = SemaDeclRefs[1];
}
for (PerFileData *F = FirstInSource; F; F = F->NextInSource) {
for (Module *F = FirstInSource; F; F = F->NextInSource) {
// If there are @selector references added them to its pool. This is for
// implementation of -Wselector.
@ -4401,7 +4402,7 @@ void ASTReader::InitializeSema(Sema &S) {
// The special data sets below always come from the most recent PCH,
// which is at the front of the chain.
PerFileData &F = *Chain.front();
Module &F = *Chain.front();
// If there were any pending implicit instantiations, deserialize them
// and add them to Sema's queue of such instantiations.
@ -4538,7 +4539,7 @@ std::pair<ObjCMethodList, ObjCMethodList>
ASTReader::ReadMethodPool(Selector Sel) {
// Find this selector in a hash table. We want to find the most recent entry.
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
PerFileData &F = *Chain[I];
Module &F = *Chain[I];
if (!F.SelectorLookupTable)
continue;
@ -4685,7 +4686,7 @@ Selector ASTReader::DecodeSelector(unsigned ID) {
// Load this selector from the selector table.
GlobalSelectorMapType::iterator I = GlobalSelectorMap.find(ID);
assert(I != GlobalSelectorMap.end() && "Corrupted global selector map");
PerFileData &F = *I->second.first;
Module &F = *I->second.first;
ASTSelectorLookupTrait Trait(*this, F);
unsigned Idx = ID - 1 + I->second.second;
SelectorsLoaded[ID - 1] =
@ -4707,7 +4708,7 @@ uint32_t ASTReader::GetNumExternalSelectors() {
}
DeclarationName
ASTReader::ReadDeclarationName(PerFileData &F,
ASTReader::ReadDeclarationName(Module &F,
const RecordData &Record, unsigned &Idx) {
DeclarationName::NameKind Kind = (DeclarationName::NameKind)Record[Idx++];
switch (Kind) {
@ -4747,7 +4748,7 @@ ASTReader::ReadDeclarationName(PerFileData &F,
return DeclarationName();
}
void ASTReader::ReadDeclarationNameLoc(PerFileData &F,
void ASTReader::ReadDeclarationNameLoc(Module &F,
DeclarationNameLoc &DNLoc,
DeclarationName Name,
const RecordData &Record, unsigned &Idx) {
@ -4779,7 +4780,7 @@ void ASTReader::ReadDeclarationNameLoc(PerFileData &F,
}
}
void ASTReader::ReadDeclarationNameInfo(PerFileData &F,
void ASTReader::ReadDeclarationNameInfo(Module &F,
DeclarationNameInfo &NameInfo,
const RecordData &Record, unsigned &Idx) {
NameInfo.setName(ReadDeclarationName(F, Record, Idx));
@ -4789,7 +4790,7 @@ void ASTReader::ReadDeclarationNameInfo(PerFileData &F,
NameInfo.setInfo(DNLoc);
}
void ASTReader::ReadQualifierInfo(PerFileData &F, QualifierInfo &Info,
void ASTReader::ReadQualifierInfo(Module &F, QualifierInfo &Info,
const RecordData &Record, unsigned &Idx) {
Info.QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
unsigned NumTPLists = Record[Idx++];
@ -4802,7 +4803,7 @@ void ASTReader::ReadQualifierInfo(PerFileData &F, QualifierInfo &Info,
}
TemplateName
ASTReader::ReadTemplateName(PerFileData &F, const RecordData &Record,
ASTReader::ReadTemplateName(Module &F, const RecordData &Record,
unsigned &Idx) {
TemplateName::NameKind Kind = (TemplateName::NameKind)Record[Idx++];
switch (Kind) {
@ -4861,7 +4862,7 @@ ASTReader::ReadTemplateName(PerFileData &F, const RecordData &Record,
}
TemplateArgument
ASTReader::ReadTemplateArgument(PerFileData &F,
ASTReader::ReadTemplateArgument(Module &F,
const RecordData &Record, unsigned &Idx) {
TemplateArgument::ArgKind Kind = (TemplateArgument::ArgKind)Record[Idx++];
switch (Kind) {
@ -4901,7 +4902,7 @@ ASTReader::ReadTemplateArgument(PerFileData &F,
}
TemplateParameterList *
ASTReader::ReadTemplateParameterList(PerFileData &F,
ASTReader::ReadTemplateParameterList(Module &F,
const RecordData &Record, unsigned &Idx) {
SourceLocation TemplateLoc = ReadSourceLocation(F, Record, Idx);
SourceLocation LAngleLoc = ReadSourceLocation(F, Record, Idx);
@ -4922,7 +4923,7 @@ ASTReader::ReadTemplateParameterList(PerFileData &F,
void
ASTReader::
ReadTemplateArgumentList(llvm::SmallVector<TemplateArgument, 8> &TemplArgs,
PerFileData &F, const RecordData &Record,
Module &F, const RecordData &Record,
unsigned &Idx) {
unsigned NumTemplateArgs = Record[Idx++];
TemplArgs.reserve(NumTemplateArgs);
@ -4931,7 +4932,7 @@ ReadTemplateArgumentList(llvm::SmallVector<TemplateArgument, 8> &TemplArgs,
}
/// \brief Read a UnresolvedSet structure.
void ASTReader::ReadUnresolvedSet(PerFileData &F, UnresolvedSetImpl &Set,
void ASTReader::ReadUnresolvedSet(Module &F, UnresolvedSetImpl &Set,
const RecordData &Record, unsigned &Idx) {
unsigned NumDecls = Record[Idx++];
while (NumDecls--) {
@ -4942,7 +4943,7 @@ void ASTReader::ReadUnresolvedSet(PerFileData &F, UnresolvedSetImpl &Set,
}
CXXBaseSpecifier
ASTReader::ReadCXXBaseSpecifier(PerFileData &F,
ASTReader::ReadCXXBaseSpecifier(Module &F,
const RecordData &Record, unsigned &Idx) {
bool isVirtual = static_cast<bool>(Record[Idx++]);
bool isBaseOfClass = static_cast<bool>(Record[Idx++]);
@ -4958,7 +4959,7 @@ ASTReader::ReadCXXBaseSpecifier(PerFileData &F,
}
std::pair<CXXCtorInitializer **, unsigned>
ASTReader::ReadCXXCtorInitializers(PerFileData &F, const RecordData &Record,
ASTReader::ReadCXXCtorInitializers(Module &F, const RecordData &Record,
unsigned &Idx) {
CXXCtorInitializer **CtorInitializers = 0;
unsigned NumInitializers = Record[Idx++];
@ -5042,7 +5043,7 @@ ASTReader::ReadCXXCtorInitializers(PerFileData &F, const RecordData &Record,
}
NestedNameSpecifier *
ASTReader::ReadNestedNameSpecifier(PerFileData &F,
ASTReader::ReadNestedNameSpecifier(Module &F,
const RecordData &Record, unsigned &Idx) {
unsigned N = Record[Idx++];
NestedNameSpecifier *NNS = 0, *Prev = 0;
@ -5091,7 +5092,7 @@ ASTReader::ReadNestedNameSpecifier(PerFileData &F,
}
NestedNameSpecifierLoc
ASTReader::ReadNestedNameSpecifierLoc(PerFileData &F, const RecordData &Record,
ASTReader::ReadNestedNameSpecifierLoc(Module &F, const RecordData &Record,
unsigned &Idx) {
unsigned N = Record[Idx++];
NestedNameSpecifierLocBuilder Builder;
@ -5147,7 +5148,7 @@ ASTReader::ReadNestedNameSpecifierLoc(PerFileData &F, const RecordData &Record,
}
SourceRange
ASTReader::ReadSourceRange(PerFileData &F, const RecordData &Record,
ASTReader::ReadSourceRange(Module &F, const RecordData &Record,
unsigned &Idx) {
SourceLocation beg = ReadSourceLocation(F, Record, Idx);
SourceLocation end = ReadSourceLocation(F, Record, Idx);
@ -5194,7 +5195,7 @@ VersionTuple ASTReader::ReadVersionTuple(const RecordData &Record,
return VersionTuple(Major, Minor - 1, Subminor - 1);
}
CXXTemporary *ASTReader::ReadCXXTemporary(PerFileData &F,
CXXTemporary *ASTReader::ReadCXXTemporary(Module &F,
const RecordData &Record,
unsigned &Idx) {
CXXDestructorDecl *Decl = ReadDeclAs<CXXDestructorDecl>(F, Record, Idx);
@ -5328,8 +5329,8 @@ ASTReader::~ASTReader() {
}
}
ASTReader::PerFileData::PerFileData(ASTFileType Ty)
: Type(Ty), SizeInBits(0), LocalNumSLocEntries(0), SLocEntryBaseID(0),
Module::Module(ModuleKind Kind)
: Kind(Kind), SizeInBits(0), LocalNumSLocEntries(0), SLocEntryBaseID(0),
SLocEntryBaseOffset(0), SLocEntryOffsets(0),
SLocFileOffsets(0), LocalNumIdentifiers(0),
IdentifierOffsets(0), IdentifierTableData(0),
@ -5343,7 +5344,7 @@ ASTReader::PerFileData::PerFileData(ASTFileType Ty)
NumPreallocatedPreprocessingEntities(0), NextInSource(0)
{}
ASTReader::PerFileData::~PerFileData() {
Module::~Module() {
delete static_cast<ASTIdentifierLookupTable *>(IdentifierLookupTable);
delete static_cast<HeaderFileInfoLookupTable *>(HeaderFileInfoTable);
delete static_cast<ASTSelectorLookupTable *>(SelectorLookupTable);

View File

@ -31,7 +31,7 @@ using namespace clang::serialization;
namespace clang {
class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> {
ASTReader &Reader;
ASTReader::PerFileData &F;
Module &F;
llvm::BitstreamCursor &Cursor;
const DeclID ThisDeclID;
typedef ASTReader::RecordData RecordData;
@ -91,7 +91,7 @@ namespace clang {
CXXRecordDecl *DefinitionDecl,
const RecordData &Record, unsigned &Idx);
public:
ASTDeclReader(ASTReader &Reader, ASTReader::PerFileData &F,
ASTDeclReader(ASTReader &Reader, Module &F,
llvm::BitstreamCursor &Cursor, DeclID thisDeclID,
const RecordData &Record, unsigned &Idx)
: Reader(Reader), F(F), Cursor(Cursor), ThisDeclID(thisDeclID),
@ -101,7 +101,7 @@ namespace clang {
void Visit(Decl *D);
void UpdateDecl(Decl *D, ASTReader::PerFileData &Module,
void UpdateDecl(Decl *D, Module &Module,
const RecordData &Record);
void VisitDecl(Decl *D);
@ -239,7 +239,7 @@ void ASTDeclReader::VisitDecl(Decl *D) {
D->setUsed(Record[Idx++]);
D->setReferenced(Record[Idx++]);
D->setAccess((AccessSpecifier)Record[Idx++]);
D->setPCHLevel(Record[Idx++] + (F.Type <= ASTReader::PCH));
D->setPCHLevel(Record[Idx++] + (F.Kind <= MK_PCH));
}
void ASTDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
@ -1349,7 +1349,7 @@ void ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
//===----------------------------------------------------------------------===//
/// \brief Reads attributes from the current stream position.
void ASTReader::ReadAttributes(PerFileData &F, AttrVec &Attrs,
void ASTReader::ReadAttributes(Module &F, AttrVec &Attrs,
const RecordData &Record, unsigned &Idx) {
for (unsigned i = 0, e = Record[Idx++]; i != e; ++i) {
Attr *New = 0;
@ -1411,7 +1411,7 @@ ASTReader::DeclCursorForIndex(unsigned Index, DeclID ID) {
}
ASTReader::RecordLocation ASTReader::getLocalBitOffset(uint64_t GlobalOffset) {
ContinuousRangeMap<uint64_t, PerFileData*, 4>::iterator I
ContinuousRangeMap<uint64_t, Module*, 4>::iterator I
= GlobalBitOffsetsMap.find(GlobalOffset);
assert(I != GlobalBitOffsetsMap.end() && "Corrupted global bit offsets map");
@ -1728,7 +1728,7 @@ Decl *ASTReader::ReadDeclRecord(unsigned Index, DeclID ID) {
FileOffsetsTy &UpdateOffsets = UpdI->second;
for (FileOffsetsTy::iterator
I = UpdateOffsets.begin(), E = UpdateOffsets.end(); I != E; ++I) {
PerFileData *F = I->first;
Module *F = I->first;
uint64_t Offset = I->second;
llvm::BitstreamCursor &Cursor = F->DeclsCursor;
SavedStreamPosition SavedPosition(Cursor);
@ -1752,7 +1752,7 @@ Decl *ASTReader::ReadDeclRecord(unsigned Index, DeclID ID) {
return D;
}
void ASTDeclReader::UpdateDecl(Decl *D, ASTReader::PerFileData &Module,
void ASTDeclReader::UpdateDecl(Decl *D, Module &Module,
const RecordData &Record) {
unsigned Idx = 0;
while (Idx < Record.size()) {

View File

@ -25,7 +25,7 @@ namespace clang {
typedef ASTReader::RecordData RecordData;
ASTReader &Reader;
ASTReader::PerFileData &F;
Module &F;
llvm::BitstreamCursor &DeclsCursor;
const ASTReader::RecordData &Record;
unsigned &Idx;
@ -66,7 +66,7 @@ namespace clang {
}
public:
ASTStmtReader(ASTReader &Reader, ASTReader::PerFileData &F,
ASTStmtReader(ASTReader &Reader, Module &F,
llvm::BitstreamCursor &Cursor,
const ASTReader::RecordData &Record, unsigned &Idx)
: Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
@ -1382,7 +1382,7 @@ void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
// ASTReader Implementation
//===----------------------------------------------------------------------===//
Stmt *ASTReader::ReadStmt(PerFileData &F) {
Stmt *ASTReader::ReadStmt(Module &F) {
switch (ReadingKind) {
case Read_Decl:
case Read_Type:
@ -1395,7 +1395,7 @@ Stmt *ASTReader::ReadStmt(PerFileData &F) {
return 0;
}
Expr *ASTReader::ReadExpr(PerFileData &F) {
Expr *ASTReader::ReadExpr(Module &F) {
return cast_or_null<Expr>(ReadStmt(F));
}
@ -1410,7 +1410,7 @@ Expr *ASTReader::ReadSubExpr() {
// the stack, with expressions having operands removing those operands from the
// stack. Evaluation terminates when we see a STMT_STOP record, and
// the single remaining expression on the stack is our result.
Stmt *ASTReader::ReadStmtFromStream(PerFileData &F) {
Stmt *ASTReader::ReadStmtFromStream(Module &F) {
ReadingKindTracker ReadingKind(Read_Stmt, *this);
llvm::BitstreamCursor &Cursor = F.DeclsCursor;

View File

@ -1549,7 +1549,7 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
typedef std::pair<uint32_t, llvm::StringRef> ModuleOffset;
llvm::SmallVector<ModuleOffset, 16> Modules;
Modules.reserve(Chain->Modules.size());
for (llvm::StringMap<ASTReader::PerFileData*>::const_iterator
for (llvm::StringMap<Module*>::const_iterator
I = Chain->Modules.begin(), E = Chain->Modules.end();
I != E; ++I) {
Modules.push_back(ModuleOffset(I->getValue()->SLocEntryBaseOffset,

View File

@ -36,7 +36,7 @@ static ASTReader *createASTReader(CompilerInstance &CI,
/*DisableValidation=*/true));
Reader->setASTMemoryBuffers(memBufs, numBufs);
Reader->setDeserializationListener(deserialListener);
switch (Reader->ReadAST(pchFile, ASTReader::PCH)) {
switch (Reader->ReadAST(pchFile, serialization::MK_PCH)) {
case ASTReader::Success:
// Set the predefines buffer as suggested by the PCH reader.
PP.setPredefines(Reader->getSuggestedPredefines());