aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/PTHLexer.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-03-19 22:19:30 +0000
committerTed Kremenek <kremenek@apple.com>2009-03-19 22:19:30 +0000
commit68228634016f644a1164fa1f024a9ce2093656bf (patch)
tree51e1396ed31fbd34d6b477faaab3ef76c3facd2b /lib/Lex/PTHLexer.cpp
parentd5cded40432da737ef85a29a1b9de3a6dcf08793 (diff)
Add PTHManager::getOriginalSourceFile(), a method that returns the name of the
original source file (if any) that was used to generate the PTH cache. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67343 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PTHLexer.cpp')
-rw-r--r--lib/Lex/PTHLexer.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp
index a5423d08f8..0a810ceaa6 100644
--- a/lib/Lex/PTHLexer.cpp
+++ b/lib/Lex/PTHLexer.cpp
@@ -569,10 +569,12 @@ PTHManager::PTHManager(const llvm::MemoryBuffer* buf, void* fileLookup,
const unsigned char* idDataTable,
IdentifierInfo** perIDCache,
void* stringIdLookup, unsigned numIds,
- const unsigned char* spellingBase)
+ const unsigned char* spellingBase,
+ const char* originalSourceFile)
: Buf(buf), PerIDCache(perIDCache), FileLookup(fileLookup),
IdDataTable(idDataTable), StringIdLookup(stringIdLookup),
- NumIds(numIds), PP(0), SpellingBase(spellingBase) {}
+ NumIds(numIds), PP(0), SpellingBase(spellingBase),
+ OriginalSourceFile(originalSourceFile) {}
PTHManager::~PTHManager() {
delete Buf;
@@ -701,10 +703,17 @@ PTHManager* PTHManager::Create(const std::string& file, Diagnostic* Diags) {
}
}
+ // Compute the address of the original source file.
+ const unsigned char* originalSourceBase = PrologueOffset + sizeof(uint32_t)*4;
+ unsigned len = ReadUnalignedLE16(originalSourceBase);
+ if (!len) originalSourceBase = 0;
+
// Create the new PTHManager.
return new PTHManager(File.take(), FL.take(), IData, PerIDCache,
- SL.take(), NumIds, spellingBase);
+ SL.take(), NumIds, spellingBase,
+ (const char*) originalSourceBase);
}
+
IdentifierInfo* PTHManager::LazilyCreateIdentifierInfo(unsigned PersistentID) {
// Look in the PTH file for the string data for the IdentifierInfo object.
const unsigned char* TableEntry = IdDataTable + sizeof(uint32_t)*PersistentID;