[cfe-commits] r70066 - in /cfe/trunk/lib/Frontend: PCHReader.cpp PCHWriter.cpp
Douglas Gregor
dgregor at apple.com
Sat Apr 25 12:25:49 PDT 2009
Author: dgregor
Date: Sat Apr 25 14:25:49 2009
New Revision: 70066
URL: http://llvm.org/viewvc/llvm-project?rev=70066&view=rev
Log:
Tweak the data layout for the on-disk hash table of identifiers in the PCH file so that the key layout matches that of the PTH key layout
Modified:
cfe/trunk/lib/Frontend/PCHReader.cpp
cfe/trunk/lib/Frontend/PCHWriter.cpp
Modified: cfe/trunk/lib/Frontend/PCHReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHReader.cpp?rev=70066&r1=70065&r2=70066&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHReader.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHReader.cpp Sat Apr 25 14:25:49 2009
@@ -1245,8 +1245,8 @@
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);
}
Modified: cfe/trunk/lib/Frontend/PCHWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PCHWriter.cpp?rev=70066&r1=70065&r2=70066&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PCHWriter.cpp (original)
+++ cfe/trunk/lib/Frontend/PCHWriter.cpp Sat Apr 25 14:25:49 2009
@@ -2013,7 +2013,6 @@
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 @@
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);
}
More information about the cfe-commits
mailing list