Slight modification to column checking inside SourceManager::getLocation().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73826 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp
index 867e1bd..8dfc5d1 100644
--- a/lib/Basic/SourceManager.cpp
+++ b/lib/Basic/SourceManager.cpp
@@ -940,14 +940,14 @@
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).