[cfe-commits] r108762 - in /cfe/trunk: include/clang/Frontend/PCHReader.h lib/Frontend/PCHReader.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Mon Jul 19 15:28:42 PDT 2010
Author: cornedbee
Date: Mon Jul 19 17:28:42 2010
New Revision: 108762
URL: http://llvm.org/viewvc/llvm-project?rev=108762&view=rev
Log:
Promote IdentifierOffsets to per-file data.
Modified:
cfe/trunk/include/clang/Frontend/PCHReader.h
cfe/trunk/lib/Frontend/PCHReader.cpp
Modified: cfe/trunk/include/clang/Frontend/PCHReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHReader.h?rev=108762&r1=108761&r2=108762&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Mon Jul 19 17:28:42 2010
@@ -238,9 +238,19 @@
/// \brief The number of declarations in this PCH file.
unsigned LocalNumDecls;
- /// \brief Offset of each declaration within the bitstream, indexed
- /// by the declaration ID (-1).
- const uint32_t *DeclOffsets;
+ /// \brief Offset of each declaration within the bitstream, indexed
+ /// by the declaration ID (-1).
+ const uint32_t *DeclOffsets;
+
+ /// \brief The number of identifiers in this PCH 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.
///
@@ -284,13 +294,6 @@
/// DeclContext.
DeclContextOffsetsMap DeclContextOffsets;
- /// \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 A vector containing identifiers that have already been
/// loaded.
///
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=108762&r1=108761&r2=108762&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Mon Jul 19 17:28:42 2010
@@ -418,8 +418,7 @@
: Listener(new PCHValidator(PP, *this)), DeserializationListener(0),
SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()),
Diags(PP.getDiagnostics()), SemaObj(0), PP(&PP), Context(Context),
- Consumer(0), IdentifierOffsets(0),
- MethodPoolLookupTable(0), MethodPoolLookupTableData(0),
+ Consumer(0), MethodPoolLookupTable(0), MethodPoolLookupTableData(0),
TotalSelectorsInMethodPool(0), SelectorOffsets(0),
TotalNumSelectors(0), MacroDefinitionOffsets(0),
NumPreallocatedPreprocessingEntities(0),
@@ -435,7 +434,6 @@
Diagnostic &Diags, const char *isysroot)
: DeserializationListener(0), SourceMgr(SourceMgr), FileMgr(FileMgr),
Diags(Diags), SemaObj(0), PP(0), Context(0), Consumer(0),
- IdentifierOffsets(0),
MethodPoolLookupTable(0), MethodPoolLookupTableData(0),
TotalSelectorsInMethodPool(0), SelectorOffsets(0),
TotalNumSelectors(0), MacroDefinitionOffsets(0),
@@ -455,8 +453,8 @@
PCHReader::PerFileData::PerFileData()
: StatCache(0), LocalNumSLocEntries(0), LocalNumTypes(0), TypeOffsets(0),
- LocalNumDecls(0), DeclOffsets(0), IdentifierTableData(0),
- IdentifierLookupTable(0)
+ LocalNumDecls(0), DeclOffsets(0), LocalNumIdentifiers(0),
+ IdentifierOffsets(0), IdentifierTableData(0), IdentifierLookupTable(0)
{}
@@ -1527,14 +1525,12 @@
break;
case pch::IDENTIFIER_OFFSET:
- if (!IdentifiersLoaded.empty()) {
+ if (F.LocalNumIdentifiers != 0) {
Error("duplicate IDENTIFIER_OFFSET record in PCH file");
return Failure;
}
- IdentifierOffsets = (const uint32_t *)BlobStart;
- IdentifiersLoaded.resize(Record[0]);
- if (PP)
- PP->getHeaderSearchInfo().SetExternalLookup(this);
+ F.IdentifierOffsets = (const uint32_t *)BlobStart;
+ F.LocalNumIdentifiers = Record[0];
break;
case pch::EXTERNAL_DEFINITIONS:
@@ -1695,13 +1691,17 @@
// Here comes stuff that we only do once the entire chain is loaded.
// Allocate space for loaded decls and types.
- unsigned TotalNumTypes = 0, TotalNumDecls = 0;
+ unsigned TotalNumIdentifiers = 0, TotalNumTypes = 0, TotalNumDecls = 0;
for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
+ TotalNumIdentifiers += Chain[I]->LocalNumIdentifiers;
TotalNumTypes += Chain[I]->LocalNumTypes;
TotalNumDecls += Chain[I]->LocalNumDecls;
}
+ IdentifiersLoaded.resize(TotalNumIdentifiers);
TypesLoaded.resize(TotalNumTypes);
DeclsLoaded.resize(TotalNumDecls);
+ if (PP && TotalNumIdentifiers > 0)
+ PP->getHeaderSearchInfo().SetExternalLookup(this);
// Check the predefines buffers.
if (CheckPredefinesBuffers())
@@ -3131,7 +3131,7 @@
assert(PP && "Forgot to set Preprocessor ?");
if (!IdentifiersLoaded[ID - 1]) {
- uint32_t Offset = IdentifierOffsets[ID - 1];
+ uint32_t Offset = Chain[0]->IdentifierOffsets[ID - 1];
const char *Str = Chain[0]->IdentifierTableData + Offset;
// All of the strings in the PCH file are preceded by a 16-bit
More information about the cfe-commits
mailing list