[cfe-commits] r108974 - /cfe/trunk/lib/Frontend/PCHReader.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Tue Jul 20 17:46:22 PDT 2010


Author: cornedbee
Date: Tue Jul 20 19:46:22 2010
New Revision: 108974

URL: http://llvm.org/viewvc/llvm-project?rev=108974&view=rev
Log:
Allow loading identifiers from any file in the chain. WIP

Modified:
    cfe/trunk/lib/Frontend/PCHReader.cpp

Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=108974&r1=108973&r2=108974&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Tue Jul 20 19:46:22 2010
@@ -3176,15 +3176,26 @@
   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 @@
     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) {





More information about the cfe-commits mailing list