]> granicus.if.org Git - clang/commitdiff
Simplified SourceManager::translateLineCol a bit.
authorAlexander Kornienko <alexfh@google.com>
Mon, 29 Jul 2013 22:26:10 +0000 (22:26 +0000)
committerAlexander Kornienko <alexfh@google.com>
Mon, 29 Jul 2013 22:26:10 +0000 (22:26 +0000)
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

lib/Basic/SourceManager.cpp

index 755675ff1d23557b064615f72bbd8c0098d307d0..fca0dba9906861f8a366863827efc1437f2e8c79 100644 (file)
@@ -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<ContentCache *>(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