const unsigned char* d,
unsigned DataLen) {
using namespace clang::io;
+ pch::IdentID ID = ReadUnalignedLE32(d);
+ bool IsInteresting = ID & 0x01;
+
+ // Wipe out the "is interesting" bit.
+ ID = ID >> 1;
+
+ if (!IsInteresting) {
+ // For unintersting identifiers, just build the IdentifierInfo
+ // and associate it with the persistent ID.
+ IdentifierInfo *II = KnownII;
+ if (!II)
+ II = &Reader.getIdentifierTable().CreateIdentifierInfo(
+ k.first, k.first + k.second);
+ Reader.SetIdentifierInfo(ID, II);
+ return II;
+ }
+
uint32_t Bits = ReadUnalignedLE32(d);
bool CPlusPlusOperatorKeyword = Bits & 0x01;
Bits >>= 1;
Bits >>= 10;
unsigned TokenID = Bits & 0xFF;
Bits >>= 8;
-
- pch::IdentID ID = ReadUnalignedLE32(d);
+
assert(Bits == 0 && "Extra bits in the identifier?");
DataLen -= 8;
PCHWriter &Writer;
Preprocessor &PP;
+ /// \brief Determines whether this is an "interesting" identifier
+ /// that needs a full IdentifierInfo structure written into the hash
+ /// table.
+ static bool isInterestingIdentifier(const IdentifierInfo *II) {
+ return II->isPoisoned() ||
+ II->isExtensionToken() ||
+ II->hasMacroDefinition() ||
+ II->getObjCOrBuiltinID() ||
+ II->getFETokenInfo<void>();
+ }
+
public:
typedef const IdentifierInfo* key_type;
typedef key_type key_type_ref;
EmitKeyDataLength(llvm::raw_ostream& Out, const IdentifierInfo* II,
pch::IdentID ID) {
unsigned KeyLen = strlen(II->getName()) + 1;
- unsigned DataLen = 4 + 4; // 4 bytes for token ID, builtin, flags
- // 4 bytes for the persistent ID
- if (II->hasMacroDefinition() &&
- !PP.getMacroInfo(const_cast<IdentifierInfo *>(II))->isBuiltinMacro())
- DataLen += 8;
- for (IdentifierResolver::iterator D = IdentifierResolver::begin(II),
- DEnd = IdentifierResolver::end();
- D != DEnd; ++D)
- DataLen += sizeof(pch::DeclID);
+ unsigned DataLen = 4; // 4 bytes for the persistent ID << 1
+ if (isInterestingIdentifier(II)) {
+ DataLen += 4; // 4 bytes for token ID, builtin, flags
+ if (II->hasMacroDefinition() &&
+ !PP.getMacroInfo(const_cast<IdentifierInfo *>(II))->isBuiltinMacro())
+ DataLen += 8;
+ for (IdentifierResolver::iterator D = IdentifierResolver::begin(II),
+ DEnd = IdentifierResolver::end();
+ D != DEnd; ++D)
+ DataLen += sizeof(pch::DeclID);
+ }
clang::io::Emit16(Out, DataLen);
// We emit the key length after the data length so that every
// string is preceded by a 16-bit length. This matches the PTH
void EmitData(llvm::raw_ostream& Out, const IdentifierInfo* II,
pch::IdentID ID, unsigned) {
+ if (!isInterestingIdentifier(II)) {
+ clang::io::Emit32(Out, ID << 1);
+ return;
+ }
+ clang::io::Emit32(Out, (ID << 1) | 0x01);
uint32_t Bits = 0;
bool hasMacroDefinition =
II->hasMacroDefinition() &&
Bits = (Bits << 1) | II->isPoisoned();
Bits = (Bits << 1) | II->isCPlusPlusOperatorKeyword();
clang::io::Emit32(Out, Bits);
- clang::io::Emit32(Out, ID);
if (hasMacroDefinition)
clang::io::Emit64(Out, Writer.getMacroOffset(II));