From: Argyrios Kyrtzidis Date: Sat, 20 Jun 2009 08:40:15 +0000 (+0000) Subject: Slight modification to column checking inside SourceManager::getLocation(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=93edc3c874257077aac59db7f897cee984113db2;p=clang 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 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).