[cfe-commits] r62408 - in /cfe/trunk: include/clang/Lex/Preprocessor.h lib/Lex/PTHLexer.cpp lib/Lex/Preprocessor.cpp

Chris Lattner sabre at nondot.org
Fri Jan 16 22:29:33 PST 2009


Author: lattner
Date: Sat Jan 17 00:29:33 2009
New Revision: 62408

URL: http://llvm.org/viewvc/llvm-project?rev=62408&view=rev
Log:
suck the call to "getSpellingLoc" that all clients do into
the implementation of PTHManager::getSpelling.

Modified:
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/Lex/PTHLexer.cpp
    cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=62408&r1=62407&r2=62408&view=diff

==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Sat Jan 17 00:29:33 2009
@@ -455,7 +455,6 @@
   /// 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;

Modified: cfe/trunk/lib/Lex/PTHLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PTHLexer.cpp?rev=62408&r1=62407&r2=62408&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PTHLexer.cpp (original)
+++ cfe/trunk/lib/Lex/PTHLexer.cpp Sat Jan 17 00:29:33 2009
@@ -311,8 +311,9 @@
 }
 
 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);
 }
 

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=62408&r1=62407&r2=62408&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Sat Jan 17 00:29:33 2009
@@ -199,8 +199,7 @@
   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 @@
     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





More information about the cfe-commits mailing list