aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Driver/CacheTokens.cpp30
-rw-r--r--include/clang/Lex/PTHManager.h2
-rw-r--r--lib/Lex/PTHLexer.cpp8
3 files changed, 15 insertions, 25 deletions
diff --git a/Driver/CacheTokens.cpp b/Driver/CacheTokens.cpp
index 23400e67c0..58f1d21c37 100644
--- a/Driver/CacheTokens.cpp
+++ b/Driver/CacheTokens.cpp
@@ -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);
-}
diff --git a/include/clang/Lex/PTHManager.h b/include/clang/Lex/PTHManager.h
index 7fd8aac637..c9554939f5 100644
--- a/include/clang/Lex/PTHManager.h
+++ b/include/clang/Lex/PTHManager.h
@@ -96,7 +96,7 @@ class PTHManager : public IdentifierInfoLookup {
public:
// The current PTH version.
- enum { Version = 2 };
+ enum { Version = 3 };
~PTHManager();
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index 2f4ac986e4..4231f2a915 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -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);