[cfe-commits] r101099 - /cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp

Chris Lattner sabre at nondot.org
Mon Apr 12 17:06:42 PDT 2010


Author: lattner
Date: Mon Apr 12 19:06:42 2010
New Revision: 101099

URL: http://llvm.org/viewvc/llvm-project?rev=101099&view=rev
Log:
cache the PP's SourceManager.

Modified:
    cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp

Modified: cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp?rev=101099&r1=101098&r2=101099&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp (original)
+++ cfe/trunk/lib/Frontend/PrintPreprocessedOutput.cpp Mon Apr 12 19:06:42 2010
@@ -78,6 +78,7 @@
 namespace {
 class PrintPPOutputPPCallbacks : public PPCallbacks {
   Preprocessor &PP;
+  SourceManager &SM;
   TokenConcatenation ConcatInfo;
 public:
   llvm::raw_ostream &OS;
@@ -94,7 +95,8 @@
 public:
   PrintPPOutputPPCallbacks(Preprocessor &pp, llvm::raw_ostream &os,
                            bool lineMarkers, bool defines)
-     : PP(pp), ConcatInfo(PP), OS(os), DisableLineMarkers(lineMarkers),
+     : PP(pp), SM(PP.getSourceManager()),
+       ConcatInfo(PP), OS(os), DisableLineMarkers(lineMarkers),
        DumpDefines(defines) {
     CurLine = 0;
     CurFilename += "<uninit>";
@@ -119,7 +121,7 @@
 
   bool HandleFirstTokOnLine(Token &Tok);
   bool MoveToLine(SourceLocation Loc) {
-    return MoveToLine(PP.getSourceManager().getPresumedLoc(Loc).getLine());
+    return MoveToLine(SM.getPresumedLoc(Loc).getLine());
   }
   bool MoveToLine(unsigned LineNo);
 
@@ -213,7 +215,7 @@
                                        SrcMgr::CharacteristicKind NewFileType) {
   // Unless we are exiting a #include, make sure to skip ahead to the line the
   // #include directive was at.
-  SourceManager &SourceMgr = PP.getSourceManager();
+  SourceManager &SourceMgr = SM;
   
   PresumedLoc UserLoc = SourceMgr.getPresumedLoc(Loc);
   unsigned NewLine = UserLoc.getLine()+1;
@@ -322,8 +324,7 @@
 
   // Print out space characters so that the first token on a line is
   // indented for easy reading.
-  const SourceManager &SourceMgr = PP.getSourceManager();
-  unsigned ColNo = SourceMgr.getInstantiationColumnNumber(Tok.getLocation());
+  unsigned ColNo = SM.getInstantiationColumnNumber(Tok.getLocation());
 
   // This hack prevents stuff like:
   // #define HASH #





More information about the cfe-commits mailing list