diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-06-20 08:40:15 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-06-20 08:40:15 +0000 |
commit | 93edc3c874257077aac59db7f897cee984113db2 (patch) | |
tree | bdf86e139b63819e0c00b887e9d86dc7a3e36e7e /lib/Basic/SourceManager.cpp | |
parent | 4b562cf889bc59e1914dd2c5d9fbd7e7bfa1ad77 (diff) |
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
Diffstat (limited to 'lib/Basic/SourceManager.cpp')
-rw-r--r-- | lib/Basic/SourceManager.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 867e1bdf55..8dfc5d100e 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -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). |