PTH: Don't emit the PTH offset of the IdentifierInfo string data as that data is

referenced by other tables.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64304 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ted Kremenek 2009-02-11 16:06:55 +00:00
Родитель d25c623a59
Коммит f1de4649e9
3 изменённых файлов: 15 добавлений и 25 удалений
Driver
include/clang/Lex
lib/Lex

Просмотреть файл

@ -273,8 +273,12 @@ class VISIBILITY_HIDDEN PTHWriter {
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();
@ -361,8 +365,7 @@ public:
};
}
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*.
@ -388,9 +391,6 @@ PTHWriter::EmitIdentifierTable() {
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.
@ -408,7 +408,7 @@ PTHWriter::EmitIdentifierTable() {
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);
}
@ -616,8 +616,7 @@ void PTHWriter::GeneratePTH() {
}
// 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();
@ -628,8 +627,7 @@ void PTHWriter::GeneratePTH() {
// 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);
@ -659,11 +657,3 @@ void clang::CacheTokens(Preprocessor& PP, const std::string& OutFile) {
PW.GeneratePTH();
}
//===----------------------------------------------------------------------===//
// Client code of on-disk hashtable logic.
//===----------------------------------------------------------------------===//
Offset PTHWriter::EmitFileTable() {
return PM.Emit(Out);
}

Просмотреть файл

@ -96,7 +96,7 @@ class PTHManager : public IdentifierInfoLookup {
public:
// The current PTH version.
enum { Version = 2 };
enum { Version = 3 };
~PTHManager();

Просмотреть файл

@ -551,7 +551,7 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags) {
// 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)) {
@ -567,7 +567,7 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags) {
// 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)) {
@ -576,7 +576,7 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags) {
}
// 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);
@ -584,7 +584,7 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* 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);