aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PCHReaderDecl.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
commit681d7237e1014bf64dd5ead6bf74ae55cdd19e61 (patch)
treeea54ca8f9269e79c717882fd7aef9d6473a71894 /lib/Frontend/PCHReaderDecl.cpp
parent3e15e0a7b4da6d906357b00b1bd2bba5ec3195ed (diff)
- 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109474 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReaderDecl.cpp')
-rw-r--r--lib/Frontend/PCHReaderDecl.cpp40
1 files changed, 35 insertions, 5 deletions
diff --git a/lib/Frontend/PCHReaderDecl.cpp b/lib/Frontend/PCHReaderDecl.cpp
index ef8a78ae05..6f6ed84df7 100644
--- a/lib/Frontend/PCHReaderDecl.cpp
+++ b/lib/Frontend/PCHReaderDecl.cpp
@@ -1517,11 +1517,9 @@ Decl *PCHReader::ReadDeclRecord(unsigned Index) {
if (Offsets.first || Offsets.second) {
DC->setHasExternalLexicalStorage(Offsets.first != 0);
DC->setHasExternalVisibleStorage(Offsets.second != 0);
- PCHReader::DeclContextInfo Info = {
- Loc.first,
- Offsets.first,
- Offsets.second
- };
+ DeclContextInfo Info;
+ if (ReadDeclContextStorage(DeclsCursor, Offsets, Info))
+ return 0;
DeclContextOffsets[DC].push_back(Info);
}
}
@@ -1536,3 +1534,35 @@ Decl *PCHReader::ReadDeclRecord(unsigned Index) {
return D;
}
+
+bool PCHReader::ReadDeclContextStorage(llvm::BitstreamCursor &Cursor,
+ const std::pair<uint64_t, uint64_t> &Offsets,
+ DeclContextInfo &Info) {
+ SavedStreamPosition SavedPosition(Cursor);
+ // First the lexical decls.
+ if (Offsets.first != 0) {
+ Cursor.JumpToBit(Offsets.first);
+
+ RecordData Record;
+ const char *Blob;
+ unsigned BlobLen;
+ unsigned Code = Cursor.ReadCode();
+ unsigned RecCode = Cursor.ReadRecord(Code, Record, &Blob, &BlobLen);
+ if (RecCode != pch::DECL_CONTEXT_LEXICAL) {
+ Error("Expected lexical block");
+ return true;
+ }
+
+ Info.LexicalDecls = reinterpret_cast<const pch::DeclID*>(Blob);
+ Info.NumLexicalDecls = BlobLen / sizeof(pch::DeclID);
+ } else {
+ Info.LexicalDecls = 0;
+ Info.NumLexicalDecls = 0;
+ }
+
+ // Now the visible decls.
+ Info.Stream = &Cursor;
+ Info.OffsetToVisibleDecls = Offsets.second;
+
+ return false;
+}