diff options
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 2 | ||||
-rw-r--r-- | lib/Frontend/PCHWriter.cpp | 8 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 005436dccf..2d894774a1 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -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); } diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp index 4ac836419e..7eb398c166 100644 --- a/lib/Frontend/PCHWriter.cpp +++ b/lib/Frontend/PCHWriter.cpp @@ -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); } |