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 удалений

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

@ -273,8 +273,12 @@ class VISIBILITY_HIDDEN PTHWriter {
for ( ; I != E ; ++I) Out << *I; for ( ; I != E ; ++I) Out << *I;
} }
std::pair<Offset,std::pair<Offset, Offset> > EmitIdentifierTable(); std::pair<Offset, Offset> EmitIdentifierTable();
Offset EmitFileTable();
/// EmitFileTable - Emit a table mapping from file name strings to PTH
/// token data.
Offset EmitFileTable() { return PM.Emit(Out); }
PCHEntry LexTokens(Lexer& L); PCHEntry LexTokens(Lexer& L);
Offset EmitCachedSpellings(); Offset EmitCachedSpellings();
@ -361,8 +365,7 @@ public:
}; };
} }
std::pair<Offset,std::pair<Offset,Offset> > std::pair<Offset,Offset> PTHWriter::EmitIdentifierTable() {
PTHWriter::EmitIdentifierTable() {
llvm::BumpPtrAllocator Alloc; llvm::BumpPtrAllocator Alloc;
// Build an inverse map from persistent IDs -> IdentifierInfo*. // Build an inverse map from persistent IDs -> IdentifierInfo*.
@ -388,9 +391,6 @@ PTHWriter::EmitIdentifierTable() {
Offset LexicalOff = Out.tell(); Offset LexicalOff = Out.tell();
for (unsigned i = 0; i < idcount ; ++i) Emit32(LexicalOrder[i]); 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) { for (unsigned i = 0; i < idcount; ++i) {
IDData& d = IIDMap[i]; IDData& d = IIDMap[i];
d.FileOffset = Out.tell(); // Record the location for this data. d.FileOffset = Out.tell(); // Record the location for this data.
@ -408,7 +408,7 @@ PTHWriter::EmitIdentifierTable() {
Emit32(idcount); // Emit the number of identifiers. Emit32(idcount); // Emit the number of identifiers.
for (unsigned i = 0 ; i < idcount; ++i) Emit32(IIDMap[i].FileOffset); 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. // Write out the identifier table.
const std::pair<Offset, std::pair<Offset,Offset> >& IdTableOff const std::pair<Offset,Offset>& IdTableOff = EmitIdentifierTable();
= EmitIdentifierTable();
// Write out the cached strings table. // Write out the cached strings table.
Offset SpellingOff = EmitCachedSpellings(); Offset SpellingOff = EmitCachedSpellings();
@ -628,8 +627,7 @@ void PTHWriter::GeneratePTH() {
// Finally, write out the offset table at the end. // Finally, write out the offset table at the end.
Offset JumpTargetOffset = Out.tell(); Offset JumpTargetOffset = Out.tell();
Emit32(IdTableOff.first); Emit32(IdTableOff.first);
Emit32(IdTableOff.second.first); Emit32(IdTableOff.second);
Emit32(IdTableOff.second.second);
Emit32(FileTableOff); Emit32(FileTableOff);
Emit32(SpellingOff); Emit32(SpellingOff);
@ -659,11 +657,3 @@ void clang::CacheTokens(Preprocessor& PP, const std::string& OutFile) {
PW.GeneratePTH(); 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: public:
// The current PTH version. // The current PTH version.
enum { Version = 2 }; enum { Version = 3 };
~PTHManager(); ~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 // Construct the file lookup table. This will be used for mapping from
// FileEntry*'s to cached tokens. // 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); const unsigned char* FileTable = BufBeg + ReadLE32(FileTableOffset);
if (!(FileTable > BufBeg && FileTable < BufEnd)) { 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 // Get the location of the table mapping from persistent ids to the
// data needed to reconstruct identifiers. // 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); const unsigned char* IData = BufBeg + ReadLE32(IDTableOffset);
if (!(IData >= BufBeg && IData < BufEnd)) { 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. // 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); const unsigned char* SortedIdTable = BufBeg + ReadLE32(SortedIdTableOffset);
if (!(SortedIdTable >= BufBeg && SortedIdTable < BufEnd)) { if (!(SortedIdTable >= BufBeg && SortedIdTable < BufEnd)) {
InvalidPTH(Diags); InvalidPTH(Diags);
@ -584,7 +584,7 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags) {
} }
// Get the location of the spelling cache. // 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); const unsigned char* spellingBase = BufBeg + ReadLE32(spellingBaseOffset);
if (!(spellingBase >= BufBeg && spellingBase < BufEnd)) { if (!(spellingBase >= BufBeg && spellingBase < BufEnd)) {
InvalidPTH(Diags); InvalidPTH(Diags);