summaryrefslogtreecommitdiffstats
path: root/clang/lib/Lex/Preprocessor.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-01-27 00:01:05 +0000
committerTed Kremenek <kremenek@apple.com>2009-01-27 00:01:05 +0000
commit8d178f435720f7180a7594ddd10109d61ee392e5 (patch)
treef4492baf085c9049af5720825b2dcc10958a8286 /clang/lib/Lex/Preprocessor.cpp
parentd0e8e85afc43f36280b0b7e860dec808c413b724 (diff)
downloadbcm5719-llvm-8d178f435720f7180a7594ddd10109d61ee392e5.tar.gz
bcm5719-llvm-8d178f435720f7180a7594ddd10109d61ee392e5.zip
PTH: Use Token::setLiteralData() to directly store a pointer to cached spelling data in the PTH file. This removes a ton of code for looking up spellings using sourcelocations in the PTH file. This simplifies both PTH-generation and reading.
Performance impact for -fsyntax-only on Cocoa.h (with Cocoa.h in the PTH file): - PTH generation time improves by 5% - PTH reading improves by 0.3%. llvm-svn: 63072
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r--clang/lib/Lex/Preprocessor.cpp29
1 files changed, 2 insertions, 27 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index cb0c850e7ea..e6bf1777a89 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -198,17 +198,9 @@ void Preprocessor::PrintStats() {
/// UCNs, etc.
std::string Preprocessor::getSpelling(const Token &Tok) const {
assert((int)Tok.getLength() >= 0 && "Token character range is bogus!");
- const char* TokStart;
-
- if (PTH) {
- if (unsigned Len = PTH->getSpelling(Tok.getLocation(), TokStart)) {
- assert(!Tok.needsCleaning());
- return std::string(TokStart, TokStart+Len);
- }
- }
-
+
// If this token contains nothing interesting, return it directly.
- TokStart = SourceMgr.getCharacterData(Tok.getLocation());
+ const char* TokStart = SourceMgr.getCharacterData(Tok.getLocation());
if (!Tok.needsCleaning())
return std::string(TokStart, TokStart+Tok.getLength());
@@ -248,23 +240,6 @@ unsigned Preprocessor::getSpelling(const Token &Tok,
return II->getLength();
}
- // If using PTH, try and get the spelling from the PTH file.
- if (PTH) {
- unsigned Len;
-
- if (CurPTHLexer) {
- Len = CurPTHLexer.get()->getSpelling(Tok.getLocation(), Buffer);
- } else {
- Len = PTH->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 = 0;
OpenPOWER on IntegriCloud