From: Alexander Kornienko Date: Mon, 29 Jul 2013 22:26:10 +0000 (+0000) Subject: Simplified SourceManager::translateLineCol a bit. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c8051e6d276b916f4a4244ad353c5a9c1d2c58e4;p=clang Simplified SourceManager::translateLineCol a bit. Reviewers: rsmith Reviewed By: rsmith CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1183 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187386 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 755675ff1d..fca0dba990 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -1734,7 +1734,7 @@ SourceLocation SourceManager::translateLineCol(FileID FID, const SLocEntry &Entry = getSLocEntry(FID, &Invalid); if (Invalid) return SourceLocation(); - + if (!Entry.isFile()) return SourceLocation(); @@ -1747,7 +1747,7 @@ SourceLocation SourceManager::translateLineCol(FileID FID, = const_cast(Entry.getFile().getContentCache()); if (!Content) return SourceLocation(); - + // If this is the first use of line information for this buffer, compute the // SourceLineCache for it on demand. if (Content->SourceLineCache == 0) { @@ -1776,10 +1776,7 @@ SourceLocation SourceManager::translateLineCol(FileID FID, // Check that the given column is valid. while (i < BufLength-1 && i < Col-1 && Buf[i] != '\n' && Buf[i] != '\r') ++i; - if (i < Col-1) - return FileLoc.getLocWithOffset(FilePos + i); - - return FileLoc.getLocWithOffset(FilePos + Col - 1); + return FileLoc.getLocWithOffset(FilePos + i); } /// \brief Compute a map of macro argument chunks to their expanded source