]> granicus.if.org Git - clang/commitdiff
suck the call to "getSpellingLoc" that all clients do into
authorChris Lattner <sabre@nondot.org>
Sat, 17 Jan 2009 06:29:33 +0000 (06:29 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 17 Jan 2009 06:29:33 +0000 (06:29 +0000)
the implementation of PTHManager::getSpelling.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62408 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/Preprocessor.h
lib/Lex/PTHLexer.cpp
lib/Lex/Preprocessor.cpp

index e453fd04d6c5841cc28293b55f3d44e0a39d8846..3956725ffa69916e20c342e5edf3f4e590ca9301 100644 (file)
@@ -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;
index b2870f46fdbfcb59f6ac8a47763311aee7261021..fd7c367c70ae3310ed10a2040d13e8c693f4619e 100644 (file)
@@ -311,8 +311,9 @@ unsigned PTHManager::getSpelling(FileID FID, unsigned FPos,
 }
 
 unsigned PTHManager::getSpelling(SourceLocation Loc, const char *&Buffer) {
-  std::pair<FileID, unsigned> LocInfo =
-    PP->getSourceManager().getDecomposedFileLoc(Loc);
+  SourceManager &SM = PP->getSourceManager();
+  Loc = SM.getSpellingLoc(Loc);
+  std::pair<FileID, unsigned> LocInfo = SM.getDecomposedFileLoc(Loc);
   return getSpelling(LocInfo.first, LocInfo.second, Buffer);
 }
 
index 976e1a2f7ab6b36db1e1f8e35dba643579519f4f..ff84b0abf36f75bb046605ba77b8326d71809dbf 100644 (file)
@@ -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