for ( ; I != E ; ++I) Out << *I;
}
- std::pair<Offset,std::pair<Offset, Offset> > EmitIdentifierTable();
- Offset EmitFileTable();
+ std::pair<Offset, Offset> EmitIdentifierTable();
+
+ /// EmitFileTable - Emit a table mapping from file name strings to PTH
+ /// token data.
+ Offset EmitFileTable() { return PM.Emit(Out); }
+
PCHEntry LexTokens(Lexer& L);
Offset EmitCachedSpellings();
};
}
-std::pair<Offset,std::pair<Offset,Offset> >
-PTHWriter::EmitIdentifierTable() {
+std::pair<Offset,Offset> PTHWriter::EmitIdentifierTable() {
llvm::BumpPtrAllocator Alloc;
// Build an inverse map from persistent IDs -> IdentifierInfo*.
Offset LexicalOff = Out.tell();
for (unsigned i = 0; i < idcount ; ++i) Emit32(LexicalOrder[i]);
- // Write out the string data itself.
- Offset DataOff = Out.tell();
-
for (unsigned i = 0; i < idcount; ++i) {
IDData& d = IIDMap[i];
d.FileOffset = Out.tell(); // Record the location for this data.
Emit32(idcount); // Emit the number of identifiers.
for (unsigned i = 0 ; i < idcount; ++i) Emit32(IIDMap[i].FileOffset);
- return std::make_pair(DataOff, std::make_pair(IDOff, LexicalOff));
+ return std::make_pair(IDOff, LexicalOff);
}
}
// Write out the identifier table.
- const std::pair<Offset, std::pair<Offset,Offset> >& IdTableOff
- = EmitIdentifierTable();
+ const std::pair<Offset,Offset>& IdTableOff = EmitIdentifierTable();
// Write out the cached strings table.
Offset SpellingOff = EmitCachedSpellings();
// Finally, write out the offset table at the end.
Offset JumpTargetOffset = Out.tell();
Emit32(IdTableOff.first);
- Emit32(IdTableOff.second.first);
- Emit32(IdTableOff.second.second);
+ Emit32(IdTableOff.second);
Emit32(FileTableOff);
Emit32(SpellingOff);
PW.GeneratePTH();
}
-
-//===----------------------------------------------------------------------===//
-// Client code of on-disk hashtable logic.
-//===----------------------------------------------------------------------===//
-
-Offset PTHWriter::EmitFileTable() {
- return PM.Emit(Out);
-}
// 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)*3;
+ const unsigned char* FileTableOffset = EndTable + sizeof(uint32_t)*2;
const unsigned char* FileTable = BufBeg + ReadLE32(FileTableOffset);
if (!(FileTable > BufBeg && FileTable < BufEnd)) {
// 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)*1;
+ const unsigned char* IDTableOffset = EndTable + sizeof(uint32_t)*0;
const unsigned char* IData = BufBeg + ReadLE32(IDTableOffset);
if (!(IData >= BufBeg && IData < BufEnd)) {
}
// Get the location of the lexigraphically-sorted table of persistent IDs.
- const unsigned char* SortedIdTableOffset = EndTable + sizeof(uint32_t)*2;
+ const unsigned char* SortedIdTableOffset = EndTable + sizeof(uint32_t)*1;
const unsigned char* SortedIdTable = BufBeg + ReadLE32(SortedIdTableOffset);
if (!(SortedIdTable >= BufBeg && SortedIdTable < BufEnd)) {
InvalidPTH(Diags);
}
// Get the location of the spelling cache.
- const unsigned char* spellingBaseOffset = EndTable + sizeof(uint32_t)*4;
+ const unsigned char* spellingBaseOffset = EndTable + sizeof(uint32_t)*3;
const unsigned char* spellingBase = BufBeg + ReadLE32(spellingBaseOffset);
if (!(spellingBase >= BufBeg && spellingBase < BufEnd)) {
InvalidPTH(Diags);