diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-01-08 02:47:16 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-01-08 02:47:16 +0000 |
commit | b70e3dafb9618f34017061400dc19ac5e3539a6d (patch) | |
tree | b99741b597b3bb15aaaf9fb76bcfca9d962d0e70 /lib/Lex/PTHLexer.cpp | |
parent | 500bab244c7f50779ba9dcf7cf0a5537854dd73f (diff) |
PTH:
- Added stub PTHLexer::getSpelling() that will be used for fetching cached
spellings from the PTH file. This doesn't do anything yet.
- Added a hook in Preprocessor::getSpelling() to call PTHLexer::getSpelling()
when using a PTHLexer.
- Updated PTHLexer to read the offsets of spelling tables in the PTH file.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61911 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PTHLexer.cpp')
-rw-r--r-- | lib/Lex/PTHLexer.cpp | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp index 3924c9cd2d..ef7cfb18d6 100644 --- a/lib/Lex/PTHLexer.cpp +++ b/lib/Lex/PTHLexer.cpp @@ -285,6 +285,10 @@ SourceLocation PTHLexer::getSourceLocation() { return SourceLocation::getFileLoc(FileID, offset); } +unsigned PTHLexer::getSpelling(SourceLocation sloc, const char *&Buffer) { + return 0; +} + //===----------------------------------------------------------------------===// // Internal Data Structures for PTH file lookup and resolving identifiers. //===----------------------------------------------------------------------===// @@ -299,21 +303,28 @@ public: class Val { uint32_t TokenOff; uint32_t PPCondOff; + uint32_t SpellingOff; public: Val() : TokenOff(~0) {} - Val(uint32_t toff, uint32_t poff) : TokenOff(toff), PPCondOff(poff) {} + Val(uint32_t toff, uint32_t poff, uint32_t soff) + : TokenOff(toff), PPCondOff(poff), SpellingOff(soff) {} uint32_t getTokenOffset() const { assert(TokenOff != ~((uint32_t)0) && "PTHFileLookup entry initialized."); return TokenOff; } - uint32_t gettPPCondOffset() const { + uint32_t getPPCondOffset() const { assert(TokenOff != ~((uint32_t)0) && "PTHFileLookup entry initialized."); return PPCondOff; } + uint32_t getSpellingOffset() const { + assert(TokenOff != ~((uint32_t)0) && "PTHFileLookup entry initialized."); + return SpellingOff; + } + bool isValid() const { return TokenOff != ~((uint32_t)0); } }; @@ -336,8 +347,13 @@ public: uint32_t len = Read32(D); const char* s = D; D += len; + uint32_t TokenOff = Read32(D); - FileMap.GetOrCreateValue(s, s+len).getValue() = Val(TokenOff, Read32(D)); + uint32_t PPCondOff = Read32(D); + uint32_t SpellingOff = Read32(D); + + FileMap.GetOrCreateValue(s, s+len).getValue() = + Val(TokenOff, PPCondOff, SpellingOff); } } }; @@ -459,10 +475,10 @@ PTHLexer* PTHManager::CreateLexer(unsigned FileID, const FileEntry* FE) { const char* data = Buf->getBufferStart() + FileData.getTokenOffset(); // Get the location of pp-conditional table. - const char* ppcond = Buf->getBufferStart() + FileData.gettPPCondOffset(); - uint32_t len = Read32(ppcond); + const char* ppcond = Buf->getBufferStart() + FileData.getPPCondOffset(); + uint32_t len = Read32(ppcond); if (len == 0) ppcond = 0; - + assert(data < Buf->getBufferEnd()); return new PTHLexer(PP, SourceLocation::getFileLoc(FileID, 0), data, ppcond, *this); |