]> granicus.if.org Git - clang/commitdiff
Tweak the data layout for the on-disk hash table of identifiers in the PCH file so...
authorDouglas Gregor <dgregor@apple.com>
Sat, 25 Apr 2009 19:25:49 +0000 (19:25 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sat, 25 Apr 2009 19:25:49 +0000 (19:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70066 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/PCHReader.cpp
lib/Frontend/PCHWriter.cpp

index 005436dccf2eacfdc619d5214e5606612310d707..2d894774a165a8fab1ed605d9680e7829dae8324 100644 (file)
@@ -1245,8 +1245,8 @@ public:
   static std::pair<unsigned, unsigned>
   ReadKeyDataLength(const unsigned char*& d) {
     using namespace clang::io;
-    unsigned KeyLen = ReadUnalignedLE16(d);
     unsigned DataLen = ReadUnalignedLE16(d);
+    unsigned KeyLen = ReadUnalignedLE16(d);
     return std::make_pair(KeyLen, DataLen);
   }
     
index 4ac836419eb836d307fe84d5b96d0cfe72b840dd..7eb398c1663fd973a1f8093aa54d3551bb900c01 100644 (file)
@@ -2013,7 +2013,6 @@ public:
     EmitKeyDataLength(llvm::raw_ostream& Out, const IdentifierInfo* II, 
                       pch::IdentID ID) {
     unsigned KeyLen = strlen(II->getName()) + 1;
-    clang::io::Emit16(Out, KeyLen);
     unsigned DataLen = 4 + 4; // 4 bytes for token ID, builtin, flags
                               // 4 bytes for the persistent ID
     if (II->hasMacroDefinition() && 
@@ -2023,7 +2022,14 @@ public:
                                    DEnd = IdentifierResolver::end();
          D != DEnd; ++D)
       DataLen += sizeof(pch::DeclID);
+
+    // We emit the data length before the key length, because we want
+    // the key length to immediately precede the actual string
+    // data. This is so that our identifier length + key layout
+    // matches that of the identifier hash table for pretokenized
+    // headers.
     clang::io::Emit16(Out, DataLen);
+    clang::io::Emit16(Out, KeyLen);
     return std::make_pair(KeyLen, DataLen);
   }