From 277faca30c9f8f72b79f55695cbe3395ec246e7c Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 27 Jan 2009 00:01:05 +0000 Subject: 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%. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63072 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Lex/Preprocessor.cpp | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) (limited to 'lib/Lex/Preprocessor.cpp') diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index cb0c850e7e..e6bf1777a8 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/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; -- cgit v1.2.3-18-g5258