summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PCHWriter.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-07-27 00:17:23 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-07-27 00:17:23 +0000
commit66c5eef182dc5adab30d50a2e73de3b31109d305 (patch)
treee4ae02e5b0defae7061eae9c2eae1e01e48b2da7 /clang/lib/Frontend/PCHWriter.cpp
parent761b8bf13045b7c41f2bbcd1e9e8884ea5f19ad4 (diff)
downloadbcm5719-llvm-66c5eef182dc5adab30d50a2e73de3b31109d305.tar.gz
bcm5719-llvm-66c5eef182dc5adab30d50a2e73de3b31109d305.zip
- Fix recording of offsets of types in dependent PCHs.
- Stop reading in (and thus deserializing) every declaration in the TU when creating a dependent PCH. - Switch the storage of a decl context's lexical declarations to a blob containing the IDs instead of a record. This is the only sane way of supporting update records later on. llvm-svn: 109474
Diffstat (limited to 'clang/lib/Frontend/PCHWriter.cpp')
-rw-r--r--clang/lib/Frontend/PCHWriter.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/clang/lib/Frontend/PCHWriter.cpp b/clang/lib/Frontend/PCHWriter.cpp
index 83e042120ec..0ade10f7f86 100644
--- a/clang/lib/Frontend/PCHWriter.cpp
+++ b/clang/lib/Frontend/PCHWriter.cpp
@@ -1391,11 +1391,12 @@ void PCHWriter::WriteType(QualType T) {
ID = NextTypeID++;
// Record the offset for this type.
- if (TypeOffsets.size() == ID - pch::NUM_PREDEF_TYPE_IDS)
+ unsigned Index = ID - FirstTypeID;
+ if (TypeOffsets.size() == Index)
TypeOffsets.push_back(Stream.GetCurrentBitNo());
- else if (TypeOffsets.size() < ID - pch::NUM_PREDEF_TYPE_IDS) {
- TypeOffsets.resize(ID + 1 - pch::NUM_PREDEF_TYPE_IDS);
- TypeOffsets[ID - pch::NUM_PREDEF_TYPE_IDS] = Stream.GetCurrentBitNo();
+ else if (TypeOffsets.size() < Index) {
+ TypeOffsets.resize(Index + 1);
+ TypeOffsets[Index] = Stream.GetCurrentBitNo();
}
RecordData Record;
@@ -1442,12 +1443,15 @@ uint64_t PCHWriter::WriteDeclContextLexicalBlock(ASTContext &Context,
uint64_t Offset = Stream.GetCurrentBitNo();
RecordData Record;
+ Record.push_back(pch::DECL_CONTEXT_LEXICAL);
+ llvm::SmallVector<pch::DeclID, 64> Decls;
for (DeclContext::decl_iterator D = DC->decls_begin(), DEnd = DC->decls_end();
D != DEnd; ++D)
- AddDeclRef(*D, Record);
+ Decls.push_back(GetDeclRef(*D));
++NumLexicalDeclContexts;
- Stream.EmitRecord(pch::DECL_CONTEXT_LEXICAL, Record);
+ Stream.EmitRecordWithBlob(DeclContextLexicalAbbrev, Record,
+ reinterpret_cast<char*>(Decls.data()), Decls.size() * sizeof(pch::DeclID));
return Offset;
}
@@ -2332,7 +2336,6 @@ void PCHWriter::WritePCHChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
ASTContext &Context = SemaRef.Context;
Preprocessor &PP = SemaRef.PP;
- (void)PP;
RecordData Record;
Stream.EnterSubblock(pch::PCH_BLOCK_ID, 5);
@@ -2351,16 +2354,15 @@ void PCHWriter::WritePCHChain(Sema &SemaRef, MemorizeStatCalls *StatCalls,
// The TU was loaded before we managed to register ourselves as a listener.
// Thus we need to add it manually.
DeclIDs[TU] = 1;
- // FIXME: We don't want to iterate over everything here, because it needlessly
- // deserializes the entire original PCH. Instead we only want to iterate over
- // the stuff that's already there.
- // All in good time, though.
- for (DeclContext::decl_iterator I = TU->decls_begin(), E = TU->decls_end();
+ Record.clear();
+ for (DeclContext::decl_iterator I = TU->noload_decls_begin(),
+ E = TU->noload_decls_end();
I != E; ++I) {
if ((*I)->getPCHLevel() == 0) {
- DeclTypesToEmit.push(*I);
+ AddDeclRef(*I, Record);
}
}
+ // We also need to write a lexical updates block for the TU.
Stream.EnterSubblock(pch::DECLTYPES_BLOCK_ID, 3);
WriteDeclsBlockAbbrevs();
@@ -2584,9 +2586,12 @@ void PCHWriter::AddTypeRef(QualType T, RecordData &Record) {
}
void PCHWriter::AddDeclRef(const Decl *D, RecordData &Record) {
+ Record.push_back(GetDeclRef(D));
+}
+
+pch::DeclID PCHWriter::GetDeclRef(const Decl *D) {
if (D == 0) {
- Record.push_back(0);
- return;
+ return 0;
}
pch::DeclID &ID = DeclIDs[D];
@@ -2597,7 +2602,7 @@ void PCHWriter::AddDeclRef(const Decl *D, RecordData &Record) {
DeclTypesToEmit.push(const_cast<Decl *>(D));
}
- Record.push_back(ID);
+ return ID;
}
pch::DeclID PCHWriter::getDeclID(const Decl *D) {
OpenPOWER on IntegriCloud