[cfe-commits] r114575 - in /cfe/trunk: include/clang/Serialization/ASTReader.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Wed Sep 22 13:19:08 PDT 2010
Author: cornedbee
Date: Wed Sep 22 15:19:08 2010
New Revision: 114575
URL: http://llvm.org/viewvc/llvm-project?rev=114575&view=rev
Log:
Change source manager serialization to be less tied to the PCH model.
Modified:
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=114575&r1=114574&r2=114575&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Sep 22 15:19:08 2010
@@ -228,8 +228,8 @@
/// 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 @@
// === 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 @@
// === 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 @@
/// \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 @@
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());
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=114575&r1=114574&r2=114575&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Sep 22 15:19:08 2010
@@ -1879,7 +1879,7 @@
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 @@
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 @@
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 @@
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 @@
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::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),
Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=114575&r1=114574&r2=114575&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Sep 22 15:19:08 2010
@@ -1228,7 +1228,8 @@
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]));
More information about the cfe-commits
mailing list