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 | 884a5584416dc66c7663d8529b6f9c7e1e205a8b (patch) | |
tree | 26e48585c991d0ef598822260ae0b19051136fa7 /clang/lib/Lex/Preprocessor.cpp | |
parent | 5423c53b59d8e8b96bfed5260a8d1738571c08b7 (diff) | |
download | bcm5719-llvm-884a5584416dc66c7663d8529b6f9c7e1e205a8b.tar.gz bcm5719-llvm-884a5584416dc66c7663d8529b6f9c7e1e205a8b.zip |
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.
llvm-svn: 61911
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index 1fe23216e71..ee6b0f888cf 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -236,7 +236,25 @@ unsigned Preprocessor::getSpelling(const Token &Tok, Buffer = II->getName(); return II->getLength(); } - + + // If using PTH, try and get the spelling from the PTH file. + if (CurPTHLexer) { + // We perform the const_cast<> here because we will only have a PTHLexer + // when grabbing a stream of tokens from the PTH file (and thus the + // Preprocessor state is allowed to change). The PTHLexer can assume we are + // getting token spellings in the order of tokens, and thus can update + // its internal state so that it can quickly fetch spellings from the PTH + // file. + unsigned len = + const_cast<PTHLexer*>(CurPTHLexer.get())->getSpelling(Tok.getLocation(), + Buffer); + + // Did we find a spelling? If so return its length. Otherwise fall + // back to the default behavior for getting the spelling by looking at + // at the source code. + if (len) return len; + } + // Otherwise, compute the start of the token in the input lexer buffer. const char *TokStart = SourceMgr.getCharacterData(Tok.getLocation()); |