[cfe-commits] r108956 - in /cfe/trunk: include/clang/Frontend/PCHReader.h lib/Frontend/PCHReader.cpp lib/Frontend/PCHReaderDecl.cpp
Sebastian Redl
sebastian.redl at getdesigned.at
Tue Jul 20 15:46:15 PDT 2010
Author: cornedbee
Date: Tue Jul 20 17:46:15 2010
New Revision: 108956
URL: http://llvm.org/viewvc/llvm-project?rev=108956&view=rev
Log:
Allow loading declarations from any file in the chain. WIP
Modified:
cfe/trunk/include/clang/Frontend/PCHReader.h
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
Modified: cfe/trunk/include/clang/Frontend/PCHReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PCHReader.h?rev=108956&r1=108955&r2=108956&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/PCHReader.h (original)
+++ cfe/trunk/include/clang/Frontend/PCHReader.h Tue Jul 20 17:46:15 2010
@@ -548,7 +548,8 @@
QualType ReadTypeRecord(unsigned Index);
RecordLocation TypeCursorForIndex(unsigned Index);
void LoadedDecl(unsigned Index, Decl *D);
- Decl *ReadDeclRecord(uint64_t Offset, unsigned Index);
+ Decl *ReadDeclRecord(unsigned Index);
+ RecordLocation DeclCursorForIndex(unsigned Index);
void PassInterestingDeclsToConsumer();
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=108956&r1=108955&r2=108956&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Tue Jul 20 17:46:15 2010
@@ -2805,7 +2805,7 @@
TranslationUnitDecl *PCHReader::GetTranslationUnitDecl() {
if (!DeclsLoaded[0]) {
- ReadDeclRecord(Chain[0]->DeclOffsets[0], 0);
+ ReadDeclRecord(0);
if (DeserializationListener)
DeserializationListener->DeclRead(1, DeclsLoaded[0]);
}
@@ -2824,7 +2824,7 @@
unsigned Index = ID - 1;
if (!DeclsLoaded[Index]) {
- ReadDeclRecord(Chain[0]->DeclOffsets[Index], Index);
+ ReadDeclRecord(Index);
if (DeserializationListener)
DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
}
Modified: cfe/trunk/lib/Frontend/PCHReaderDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReaderDecl.cpp?rev=108956&r1=108955&r2=108956&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReaderDecl.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReaderDecl.cpp Tue Jul 20 17:46:15 2010
@@ -1254,9 +1254,23 @@
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 @@
// 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;
More information about the cfe-commits
mailing list