[cfe-commits] r64338 - in /cfe/trunk: Driver/CacheTokens.cpp include/clang/Lex/PTHManager.h lib/Lex/PTHLexer.cpp

Ted Kremenek kremenek at apple.com
Wed Feb 11 15:34:33 PST 2009


Author: kremenek
Date: Wed Feb 11 17:34:32 2009
New Revision: 64338

URL: http://llvm.org/viewvc/llvm-project?rev=64338&view=rev
Log:
PTH: Have meta data be at the beginning of the PTH file, not the end.

Modified:
    cfe/trunk/Driver/CacheTokens.cpp
    cfe/trunk/include/clang/Lex/PTHManager.h
    cfe/trunk/lib/Lex/PTHLexer.cpp

Modified: cfe/trunk/Driver/CacheTokens.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/CacheTokens.cpp?rev=64338&r1=64337&r2=64338&view=diff

==============================================================================
--- cfe/trunk/Driver/CacheTokens.cpp (original)
+++ cfe/trunk/Driver/CacheTokens.cpp Wed Feb 11 17:34:32 2009
@@ -517,8 +517,10 @@
   // Generate the prologue.
   Out << "cfe-pth";
   Emit32(PTHManager::Version);
-  Offset JumpOffset = Out.tell();
-  Emit32(0);
+  
+  // Leave 4 words for the prologue.
+  Offset PrologueOffset = Out.tell();
+  for (unsigned i = 0; i < 4 * sizeof(uint32_t); ++i) Emit8(0);
   
   // Iterate over all the files in SourceManager.  Create a lexer
   // for each file and cache the tokens.
@@ -554,16 +556,12 @@
   // Write out the file table.
   Offset FileTableOff = EmitFileTable();  
   
-  // Finally, write out the offset table at the end.
-  Offset JumpTargetOffset = Out.tell();    
+  // Finally, write the prologue.
+  Out.seek(PrologueOffset);
   Emit32(IdTableOff.first);
   Emit32(IdTableOff.second);
   Emit32(FileTableOff);
   Emit32(SpellingOff);
-  
-  // Now write the offset in the prologue.
-  Out.seek(JumpOffset);
-  Emit32(JumpTargetOffset);
 }
 
 void clang::CacheTokens(Preprocessor& PP, const std::string& OutFile) {

Modified: cfe/trunk/include/clang/Lex/PTHManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PTHManager.h?rev=64338&r1=64337&r2=64338&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/PTHManager.h (original)
+++ cfe/trunk/include/clang/Lex/PTHManager.h Wed Feb 11 17:34:32 2009
@@ -95,7 +95,7 @@
   
 public:
   // The current PTH version.
-  enum { Version = 5 };
+  enum { Version = 6 };
 
   ~PTHManager();
   

Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=64338&r1=64337&r2=64338&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Wed Feb 11 17:34:32 2009
@@ -597,16 +597,16 @@
   }
 
   // Compute the address of the index table at the end of the PTH file.  
-  const unsigned char *EndTable = BufBeg + ReadLE32(p);
+  const unsigned char *PrologueOffset = p;
   
-  if (EndTable >= BufEnd) {
+  if (PrologueOffset >= BufEnd) {
     InvalidPTH(Diags);
     return 0;
   }
   
   // Construct the file lookup table.  This will be used for mapping from
   // FileEntry*'s to cached tokens.
-  const unsigned char* FileTableOffset = EndTable + sizeof(uint32_t)*2;
+  const unsigned char* FileTableOffset = PrologueOffset + sizeof(uint32_t)*2;
   const unsigned char* FileTable = BufBeg + ReadLE32(FileTableOffset);
   
   if (!(FileTable > BufBeg && FileTable < BufEnd)) {
@@ -622,7 +622,7 @@
   
   // Get the location of the table mapping from persistent ids to the
   // data needed to reconstruct identifiers.
-  const unsigned char* IDTableOffset = EndTable + sizeof(uint32_t)*0;
+  const unsigned char* IDTableOffset = PrologueOffset + sizeof(uint32_t)*0;
   const unsigned char* IData = BufBeg + ReadLE32(IDTableOffset);
   
   if (!(IData >= BufBeg && IData < BufEnd)) {
@@ -632,7 +632,7 @@
   
   // Get the location of the hashtable mapping between strings and
   // persistent IDs.
-  const unsigned char* StringIdTableOffset = EndTable + sizeof(uint32_t)*1;
+  const unsigned char* StringIdTableOffset = PrologueOffset + sizeof(uint32_t)*1;
   const unsigned char* StringIdTable = BufBeg + ReadLE32(StringIdTableOffset);
   if (!(StringIdTable >= BufBeg && StringIdTable < BufEnd)) {
     InvalidPTH(Diags);
@@ -647,7 +647,7 @@
   }
   
   // Get the location of the spelling cache.
-  const unsigned char* spellingBaseOffset = EndTable + sizeof(uint32_t)*3;
+  const unsigned char* spellingBaseOffset = PrologueOffset + sizeof(uint32_t)*3;
   const unsigned char* spellingBase = BufBeg + ReadLE32(spellingBaseOffset);
   if (!(spellingBase >= BufBeg && spellingBase < BufEnd)) {
     InvalidPTH(Diags);





More information about the cfe-commits mailing list