]> granicus.if.org Git - clang/commitdiff
SourceManager::getLineNumber is logically const except for caching.
authorChris Lattner <sabre@nondot.org>
Tue, 18 Nov 2008 06:51:15 +0000 (06:51 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 18 Nov 2008 06:51:15 +0000 (06:51 +0000)
Use mutable to make it so.

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

include/clang/Basic/SourceManager.h
lib/Basic/SourceManager.cpp

index 4f58334f2e8152de0c83596d4a0f2723f61a8741..70237ff1155ac8508480ead782ef535e1db5c595 100644 (file)
@@ -237,10 +237,10 @@ class SourceManager {
   
   /// 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 @@ public:
   /// 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));
   }
   
index b8b72878f525476e7365a8865f74df2498e1211b..44a6d66c1a6a44253517c4a46be999b6d25590ea 100644 (file)
@@ -238,7 +238,7 @@ static void ComputeLineNumbers(ContentCache* FI) {
 /// 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;