summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/PCHReaderDecl.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-07-20 22:46:15 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-07-20 22:46:15 +0000
commit3462779369380e32e68cbf35b7490a2f61475c78 (patch)
treeae51165698e0e9bbf945ea5b3a7f6624918af7d1 /clang/lib/Frontend/PCHReaderDecl.cpp
parent41ff5d4d916a6b7c031d2ebd9655c512c88348e6 (diff)
downloadbcm5719-llvm-3462779369380e32e68cbf35b7490a2f61475c78.tar.gz
bcm5719-llvm-3462779369380e32e68cbf35b7490a2f61475c78.zip
Allow loading declarations from any file in the chain. WIP
llvm-svn: 108956
Diffstat (limited to 'clang/lib/Frontend/PCHReaderDecl.cpp')
-rw-r--r--clang/lib/Frontend/PCHReaderDecl.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/clang/lib/Frontend/PCHReaderDecl.cpp b/clang/lib/Frontend/PCHReaderDecl.cpp
index e021d3cabab..a4c0d8df9a3 100644
--- a/clang/lib/Frontend/PCHReaderDecl.cpp
+++ b/clang/lib/Frontend/PCHReaderDecl.cpp
@@ -1254,9 +1254,23 @@ static bool isConsumerInterestedIn(Decl *D) {
return isa<ObjCProtocolDecl>(D);
}
+/// \brief Get the correct cursor and offset for loading a type.
+PCHReader::RecordLocation PCHReader::DeclCursorForIndex(unsigned Index) {
+ PerFileData *F = 0;
+ for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
+ F = Chain[N - I - 1];
+ if (Index < F->LocalNumDecls)
+ break;
+ Index -= F->LocalNumDecls;
+ }
+ assert(F && F->LocalNumDecls > Index && "Broken chain");
+ return RecordLocation(F->DeclsCursor, F->DeclOffsets[Index]);
+}
+
/// \brief Read the declaration at the given offset from the PCH file.
-Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) {
- llvm::BitstreamCursor &DeclsCursor = Chain[0]->DeclsCursor;
+Decl *PCHReader::ReadDeclRecord(unsigned Index) {
+ RecordLocation Loc = DeclCursorForIndex(Index);
+ llvm::BitstreamCursor &DeclsCursor = Loc.first;
// Keep track of where we are in the stream, then jump back there
// after reading this declaration.
SavedStreamPosition SavedPosition(DeclsCursor);
@@ -1266,7 +1280,7 @@ Decl *PCHReader::ReadDeclRecord(uint64_t Offset, unsigned Index) {
// Note that we are loading a declaration record.
LoadingTypeOrDecl Loading(*this);
- DeclsCursor.JumpToBit(Offset);
+ DeclsCursor.JumpToBit(Loc.second);
RecordData Record;
unsigned Code = DeclsCursor.ReadCode();
unsigned Idx = 0;
OpenPOWER on IntegriCloud