diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-07-21 00:46:22 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2010-07-21 00:46:22 +0000 |
commit | 11f5ccf2d88c2ea600ed950831f100ed96d89fed (patch) | |
tree | 912fc4d455eebb7b81c450a94875176f1409f71c /lib/Frontend/PCHReader.cpp | |
parent | 740e807eee153348f50a86f4a6eac49f324467ab (diff) |
Allow loading identifiers from any file in the chain. WIP
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108974 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReader.cpp')
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 008f58eaea..86f1091a05 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -3176,15 +3176,26 @@ IdentifierInfo *PCHReader::DecodeIdentifierInfo(unsigned ID) { if (ID == 0) return 0; - if (!Chain[0]->IdentifierTableData || IdentifiersLoaded.empty()) { + if (IdentifiersLoaded.empty()) { Error("no identifier table in PCH file"); return 0; } assert(PP && "Forgot to set Preprocessor ?"); - if (!IdentifiersLoaded[ID - 1]) { - uint32_t Offset = Chain[0]->IdentifierOffsets[ID - 1]; - const char *Str = Chain[0]->IdentifierTableData + Offset; + ID -= 1; + if (!IdentifiersLoaded[ID]) { + unsigned Index = ID; + const char *Str = 0; + for (unsigned I = 0, N = Chain.size(); I != N; ++I) { + PerFileData *F = Chain[N - I - 1]; + if (Index < F->LocalNumIdentifiers) { + uint32_t Offset = F->IdentifierOffsets[Index]; + Str = F->IdentifierTableData + Offset; + break; + } + Index -= F->LocalNumIdentifiers; + } + assert(Str && "Broken Chain"); // All of the strings in the PCH file are preceded by a 16-bit // length. Extract that 16-bit length to avoid having to execute @@ -3195,11 +3206,11 @@ IdentifierInfo *PCHReader::DecodeIdentifierInfo(unsigned ID) { const unsigned char *StrLenPtr = (const unsigned char*) Str - 2; unsigned StrLen = (((unsigned) StrLenPtr[0]) | (((unsigned) StrLenPtr[1]) << 8)) - 1; - IdentifiersLoaded[ID - 1] + IdentifiersLoaded[ID] = &PP->getIdentifierTable().get(Str, StrLen); } - return IdentifiersLoaded[ID - 1]; + return IdentifiersLoaded[ID]; } void PCHReader::ReadSLocEntry(unsigned ID) { |