[cfe-commits] r59498 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Basic/SourceManager.cpp

Chris Lattner sabre at nondot.org
Mon Nov 17 22:51:16 PST 2008


Author: lattner
Date: Tue Nov 18 00:51:15 2008
New Revision: 59498

URL: http://llvm.org/viewvc/llvm-project?rev=59498&view=rev
Log:
SourceManager::getLineNumber is logically const except for caching.
Use mutable to make it so.

Modified:
    cfe/trunk/include/clang/Basic/SourceManager.h
    cfe/trunk/lib/Basic/SourceManager.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=59498&r1=59497&r2=59498&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Nov 18 00:51:15 2008
@@ -237,10 +237,10 @@
   
   /// LastLineNo - These ivars serve as a cache used in the getLineNumber
   /// method which is used to speedup getLineNumber calls to nearby locations.
-  unsigned LastLineNoFileIDQuery;
-  SrcMgr::ContentCache *LastLineNoContentCache;
-  unsigned LastLineNoFilePos;
-  unsigned LastLineNoResult;
+  mutable unsigned LastLineNoFileIDQuery;
+  mutable SrcMgr::ContentCache *LastLineNoContentCache;
+  mutable unsigned LastLineNoFilePos;
+  mutable unsigned LastLineNoResult;
   
   /// MainFileID - The file ID for the main source file of the translation unit.
   unsigned MainFileID;
@@ -344,12 +344,12 @@
   /// for the position indicated.  This requires building and caching a table of
   /// line offsets for the MemoryBuffer, so this is not cheap: use only when
   /// about to emit a diagnostic.
-  unsigned getLineNumber(SourceLocation Loc);
+  unsigned getLineNumber(SourceLocation Loc) const;
 
-  unsigned getLogicalLineNumber(SourceLocation Loc) {
+  unsigned getLogicalLineNumber(SourceLocation Loc) const {
     return getLineNumber(getLogicalLoc(Loc));
   }
-  unsigned getPhysicalLineNumber(SourceLocation Loc) {
+  unsigned getPhysicalLineNumber(SourceLocation Loc) const {
     return getLineNumber(getPhysicalLoc(Loc));
   }
   

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=59498&r1=59497&r2=59498&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Tue Nov 18 00:51:15 2008
@@ -238,7 +238,7 @@
 /// for the position indicated.  This requires building and caching a table of
 /// line offsets for the MemoryBuffer, so this is not cheap: use only when
 /// about to emit a diagnostic.
-unsigned SourceManager::getLineNumber(SourceLocation Loc) {
+unsigned SourceManager::getLineNumber(SourceLocation Loc) const {
   unsigned FileID = Loc.getFileID();
   if (FileID == 0) return 0;
 





More information about the cfe-commits mailing list