r187386 - Simplified SourceManager::translateLineCol a bit.

Alexander Kornienko alexfh at google.com
Mon Jul 29 15:26:10 PDT 2013


Author: alexfh
Date: Mon Jul 29 17:26:10 2013
New Revision: 187386

URL: http://llvm.org/viewvc/llvm-project?rev=187386&view=rev
Log:
Simplified SourceManager::translateLineCol a bit.

Reviewers: rsmith

Reviewed By: rsmith

CC: cfe-commits

Differential Revision: http://llvm-reviews.chandlerc.com/D1183

Modified:
    cfe/trunk/lib/Basic/SourceManager.cpp

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=187386&r1=187385&r2=187386&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Mon Jul 29 17:26:10 2013
@@ -1734,7 +1734,7 @@ SourceLocation SourceManager::translateL
   const SLocEntry &Entry = getSLocEntry(FID, &Invalid);
   if (Invalid)
     return SourceLocation();
-  
+
   if (!Entry.isFile())
     return SourceLocation();
 
@@ -1747,7 +1747,7 @@ SourceLocation SourceManager::translateL
     = 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::translateL
   // 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





More information about the cfe-commits mailing list