]> granicus.if.org Git - clang/commitdiff
Slight modification to column checking inside SourceManager::getLocation().
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 20 Jun 2009 08:40:15 +0000 (08:40 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 20 Jun 2009 08:40:15 +0000 (08:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73826 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/SourceManager.cpp

index 867e1bdf553189b43a20a02c18c2562a6cf48397..8dfc5d100e8590674b45e26c779ab6ba09791152 100644 (file)
@@ -940,14 +940,14 @@ SourceLocation SourceManager::getLocation(const FileEntry *SourceFile,
     return SourceLocation();
   
   unsigned FilePos = Content->SourceLineCache[Line - 1];
-  const char *BufStart = Content->getBuffer()->getBufferStart();
-  const char *BufEnd = Content->getBuffer()->getBufferEnd();
-  const char *p = BufStart;
+  const char *Buf = Content->getBuffer()->getBufferStart();
+  unsigned BufLength = Content->getBuffer()->getBufferEnd() - Buf;
+  unsigned i = 0;
 
   // Check that the given column is valid.
-  while (p < BufEnd && *p != '\n' && *p != '\r')
-    ++p;
-  if (Col > p-BufStart)
+  while (i < BufLength-1 && i < Col-1 && Buf[i] != '\n' && Buf[i] != '\r')
+    ++i;
+  if (i < Col-1)
     return SourceLocation();
   
   return getLocForStartOfFile(Content->FirstFID).