From 11f5ccf2d88c2ea600ed950831f100ed96d89fed Mon Sep 17 00:00:00 2001 From: Sebastian Redl Date: Wed, 21 Jul 2010 00:46:22 +0000 Subject: [PATCH] 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 --- lib/Frontend/PCHReader.cpp | 23 +++++++++++++++++------ 1 file 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) { -- 2.40.0