forked from OSchip/llvm-project
Change source manager serialization to be less tied to the PCH model.
llvm-svn: 114575
This commit is contained in:
parent
ba28207dcd
commit
c1d035f6a3
|
@ -228,8 +228,8 @@ private:
|
|||
/// AST file.
|
||||
const uint32_t *SLocOffsets;
|
||||
|
||||
/// \brief The next SourceLocation offset after reading this file.
|
||||
unsigned NextOffset;
|
||||
/// \brief The entire size of this module's source location offset range.
|
||||
unsigned LocalSLocSize;
|
||||
|
||||
// === Identifiers ===
|
||||
|
||||
|
@ -255,6 +255,10 @@ private:
|
|||
|
||||
// === Macros ===
|
||||
|
||||
/// \brief The cursor to the start of the preprocessor block, which stores
|
||||
/// all of the macro definitions.
|
||||
llvm::BitstreamCursor MacroCursor;
|
||||
|
||||
/// \brief The number of macro definitions in this file.
|
||||
unsigned LocalNumMacroDefinitions;
|
||||
|
||||
|
@ -264,10 +268,6 @@ private:
|
|||
|
||||
// === Selectors ===
|
||||
|
||||
/// \brief The cursor to the start of the preprocessor block, which stores
|
||||
/// all of the macro definitions.
|
||||
llvm::BitstreamCursor MacroCursor;
|
||||
|
||||
/// \brief The number of selectors new to this file.
|
||||
///
|
||||
/// This is the number of entries in SelectorOffsets.
|
||||
|
@ -568,6 +568,9 @@ private:
|
|||
/// \brief The number of source location entries in the chain.
|
||||
unsigned TotalNumSLocEntries;
|
||||
|
||||
/// \brief The next offset for a SLocEntry after everything in this reader.
|
||||
unsigned NextSLocOffset;
|
||||
|
||||
/// \brief The number of statements (and expressions) de-serialized
|
||||
/// from the chain.
|
||||
unsigned NumStatementsRead;
|
||||
|
@ -788,6 +791,11 @@ public:
|
|||
return TotalNumSLocEntries;
|
||||
}
|
||||
|
||||
/// \brief Returns the next SLocEntry offset after the chain.
|
||||
unsigned getNextSLocOffset() const {
|
||||
return NextSLocOffset;
|
||||
}
|
||||
|
||||
/// \brief Returns the number of identifiers found in the chain.
|
||||
unsigned getTotalNumIdentifiers() const {
|
||||
return static_cast<unsigned>(IdentifiersLoaded.size());
|
||||
|
|
|
@ -1879,7 +1879,7 @@ ASTReader::ReadASTBlock(PerFileData &F) {
|
|||
case SOURCE_LOCATION_OFFSETS:
|
||||
F.SLocOffsets = (const uint32_t *)BlobStart;
|
||||
F.LocalNumSLocEntries = Record[0];
|
||||
F.NextOffset = Record[1];
|
||||
F.LocalSLocSize = Record[1];
|
||||
break;
|
||||
|
||||
case SOURCE_LOCATION_PRELOADS:
|
||||
|
@ -2000,6 +2000,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName) {
|
|||
TotalNumSelectors = 0;
|
||||
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
|
||||
TotalNumSLocEntries += Chain[I]->LocalNumSLocEntries;
|
||||
NextSLocOffset += Chain[I]->LocalSLocSize;
|
||||
TotalNumIdentifiers += Chain[I]->LocalNumIdentifiers;
|
||||
TotalNumTypes += Chain[I]->LocalNumTypes;
|
||||
TotalNumDecls += Chain[I]->LocalNumDecls;
|
||||
|
@ -2008,8 +2009,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName) {
|
|||
TotalNumMacroDefs += Chain[I]->LocalNumMacroDefinitions;
|
||||
TotalNumSelectors += Chain[I]->LocalNumSelectors;
|
||||
}
|
||||
SourceMgr.PreallocateSLocEntries(this, TotalNumSLocEntries,
|
||||
Chain.front()->NextOffset);
|
||||
SourceMgr.PreallocateSLocEntries(this, TotalNumSLocEntries, NextSLocOffset);
|
||||
IdentifiersLoaded.resize(TotalNumIdentifiers);
|
||||
TypesLoaded.resize(TotalNumTypes);
|
||||
DeclsLoaded.resize(TotalNumDecls);
|
||||
|
@ -4089,9 +4089,9 @@ ASTReader::ASTReader(Preprocessor &PP, ASTContext *Context,
|
|||
Diags(PP.getDiagnostics()), SemaObj(0), PP(&PP), Context(Context),
|
||||
Consumer(0), isysroot(isysroot), DisableValidation(DisableValidation),
|
||||
NumStatHits(0), NumStatMisses(0), NumSLocEntriesRead(0),
|
||||
TotalNumSLocEntries(0), NumStatementsRead(0), TotalNumStatements(0),
|
||||
NumMacrosRead(0), TotalNumMacros(0), NumSelectorsRead(0),
|
||||
NumMethodPoolEntriesRead(0), NumMethodPoolMisses(0),
|
||||
TotalNumSLocEntries(0), NextSLocOffset(0), NumStatementsRead(0),
|
||||
TotalNumStatements(0), NumMacrosRead(0), TotalNumMacros(0),
|
||||
NumSelectorsRead(0), NumMethodPoolEntriesRead(0), NumMethodPoolMisses(0),
|
||||
TotalNumMethodPoolEntries(0), NumLexicalDeclContextsRead(0),
|
||||
TotalLexicalDeclContexts(0), NumVisibleDeclContextsRead(0),
|
||||
TotalVisibleDeclContexts(0), NumCurrentElementsDeserializing(0) {
|
||||
|
@ -4105,12 +4105,12 @@ ASTReader::ASTReader(SourceManager &SourceMgr, FileManager &FileMgr,
|
|||
Diags(Diags), SemaObj(0), PP(0), Context(0), Consumer(0),
|
||||
isysroot(isysroot), DisableValidation(DisableValidation), NumStatHits(0),
|
||||
NumStatMisses(0), NumSLocEntriesRead(0), TotalNumSLocEntries(0),
|
||||
NumStatementsRead(0), TotalNumStatements(0), NumMacrosRead(0),
|
||||
TotalNumMacros(0), NumSelectorsRead(0), NumMethodPoolEntriesRead(0),
|
||||
NumMethodPoolMisses(0), TotalNumMethodPoolEntries(0),
|
||||
NumLexicalDeclContextsRead(0), TotalLexicalDeclContexts(0),
|
||||
NumVisibleDeclContextsRead(0), TotalVisibleDeclContexts(0),
|
||||
NumCurrentElementsDeserializing(0) {
|
||||
NextSLocOffset(0), NumStatementsRead(0), TotalNumStatements(0),
|
||||
NumMacrosRead(0), TotalNumMacros(0), NumSelectorsRead(0),
|
||||
NumMethodPoolEntriesRead(0), NumMethodPoolMisses(0),
|
||||
TotalNumMethodPoolEntries(0), NumLexicalDeclContextsRead(0),
|
||||
TotalLexicalDeclContexts(0), NumVisibleDeclContextsRead(0),
|
||||
TotalVisibleDeclContexts(0), NumCurrentElementsDeserializing(0) {
|
||||
RelocatablePCH = false;
|
||||
}
|
||||
|
||||
|
@ -4140,7 +4140,7 @@ ASTReader::~ASTReader() {
|
|||
}
|
||||
|
||||
ASTReader::PerFileData::PerFileData()
|
||||
: SizeInBits(0), LocalNumSLocEntries(0), SLocOffsets(0),
|
||||
: SizeInBits(0), LocalNumSLocEntries(0), SLocOffsets(0), LocalSLocSize(0),
|
||||
LocalNumIdentifiers(0), IdentifierOffsets(0), IdentifierTableData(0),
|
||||
IdentifierLookupTable(0), LocalNumMacroDefinitions(0),
|
||||
MacroDefinitionOffsets(0), LocalNumSelectors(0), SelectorOffsets(0),
|
||||
|
|
|
@ -1228,7 +1228,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
|
|||
Record.clear();
|
||||
Record.push_back(SOURCE_LOCATION_OFFSETS);
|
||||
Record.push_back(SLocEntryOffsets.size());
|
||||
Record.push_back(SourceMgr.getNextOffset());
|
||||
unsigned BaseOffset = Chain ? Chain->getNextSLocOffset() : 0;
|
||||
Record.push_back(SourceMgr.getNextOffset() - BaseOffset);
|
||||
Stream.EmitRecordWithBlob(SLocOffsetsAbbrev, Record,
|
||||
(const char *)data(SLocEntryOffsets),
|
||||
SLocEntryOffsets.size()*sizeof(SLocEntryOffsets[0]));
|
||||
|
|
Loading…
Reference in New Issue