]> granicus.if.org Git - clang/commitdiff
add the difference in the line marker phys line number and the
authorChris Lattner <sabre@nondot.org>
Wed, 4 Feb 2009 02:00:59 +0000 (02:00 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 4 Feb 2009 02:00:59 +0000 (02:00 +0000)
query point to the returned presumed location.  We now produce:

foo.h:92:2: warning: #warning blarg!
#warning blarg!
 ^
foo.h:93:2: warning: #warning blarg!
#warning blarg!
 ^
foo.h:94:2: warning: #warning blarg!
#warning blarg!
 ^

for:

#line 92 "foo.h"
#warning blarg!
#warning blarg!
#warning blarg!

blarg indeed!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63710 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Basic/SourceManager.cpp

index 34e7049894e7326f7ac7bb723f221cc1ce3c9e5b..998374104019d695bef01713dd09354b41cfb0fd 100644 (file)
@@ -697,10 +697,18 @@ PresumedLoc SourceManager::getPresumedLoc(SourceLocation Loc) const {
     // See if there is a #line directive before this.  If so, get it.
     if (const LineEntry *Entry =
           LineTable->FindNearestLineEntry(LocInfo.first.ID, LocInfo.second)) {
-      LineNo = Entry->LineNo;
-      
+      // If the LineEntry indicates a filename, use it.
       if (Entry->FilenameID != -1)
         Filename = LineTable->getFilename(Entry->FilenameID);
+
+      // Use the line number specified by the LineEntry.  This line number may
+      // be multiple lines down from the line entry.  Add the difference in
+      // physical line numbers from the query point and the line marker to the
+      // total.
+      unsigned MarkerLineNo = getLineNumber(LocInfo.first, Entry->FileOffset);
+      LineNo = Entry->LineNo + (LineNo-MarkerLineNo-1);
+      
+
     }
   }