diff --git a/include/clang/Lex/Preprocessor.h b/include/clang/Lex/Preprocessor.h index e453fd04d6..3956725ffa 100644 --- a/include/clang/Lex/Preprocessor.h +++ b/include/clang/Lex/Preprocessor.h @@ -455,7 +455,6 @@ public: /// location in the appropriate MemoryBuffer. char getSpelledCharacterAt(SourceLocation SL) const { if (PTH) { - SL = SourceMgr.getSpellingLoc(SL); const char *Data; if (PTH->getSpelling(SL, Data)) return *Data; diff --git a/lib/Lex/PTHLexer.cpp b/lib/Lex/PTHLexer.cpp index b2870f46fd..fd7c367c70 100644 --- a/lib/Lex/PTHLexer.cpp +++ b/lib/Lex/PTHLexer.cpp @@ -311,8 +311,9 @@ unsigned PTHManager::getSpelling(FileID FID, unsigned FPos, } unsigned PTHManager::getSpelling(SourceLocation Loc, const char *&Buffer) { - std::pair LocInfo = - PP->getSourceManager().getDecomposedFileLoc(Loc); + SourceManager &SM = PP->getSourceManager(); + Loc = SM.getSpellingLoc(Loc); + std::pair LocInfo = SM.getDecomposedFileLoc(Loc); return getSpelling(LocInfo.first, LocInfo.second, Buffer); } diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index 976e1a2f7a..ff84b0abf3 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -199,8 +199,7 @@ std::string Preprocessor::getSpelling(const Token &Tok) const { const char* TokStart; if (PTH) { - SourceLocation SLoc = SourceMgr.getSpellingLoc(Tok.getLocation()); - if (unsigned Len = PTH->getSpelling(SLoc, TokStart)) { + if (unsigned Len = PTH->getSpelling(Tok.getLocation(), TokStart)) { assert(!Tok.needsCleaning()); return std::string(TokStart, TokStart+Len); } @@ -254,8 +253,7 @@ unsigned Preprocessor::getSpelling(const Token &Tok, if (CurPTHLexer) { Len = CurPTHLexer.get()->getSpelling(Tok.getLocation(), Buffer); } else { - Len = PTH->getSpelling(SourceMgr.getSpellingLoc(Tok.getLocation()), - Buffer); + Len = PTH->getSpelling(Tok.getLocation(), Buffer); } // Did we find a spelling? If so return its length. Otherwise fall