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 | 69c2e0635a74b2a7c5ef5e31788ab89d90606d67 (patch) | |
tree | e1bf669bf6b62f578b6a45bd8759e0c866019410 /clang/lib/Basic/SourceManager.cpp | |
parent | 3a08ec1662dbf2438b93fedc4e828977212c6b66 (diff) | |
download | llvm-69c2e0635a74b2a7c5ef5e31788ab89d90606d67.zip llvm-69c2e0635a74b2a7c5ef5e31788ab89d90606d67.tar.gz llvm-69c2e0635a74b2a7c5ef5e31788ab89d90606d67.tar.bz2 |
Slight modification to column checking inside SourceManager::getLocation().
llvm-svn: 73826
Diffstat (limited to 'clang/lib/Basic/SourceManager.cpp')
-rw-r--r-- | clang/lib/Basic/SourceManager.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index 867e1bd..8dfc5d1 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/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). |