[cfe-commits] r63710 - /cfe/trunk/lib/Basic/SourceManager.cpp

Chris Lattner sabre at nondot.org
Tue Feb 3 18:00:59 PST 2009


Author: lattner
Date: Tue Feb  3 20:00:59 2009
New Revision: 63710

URL: http://llvm.org/viewvc/llvm-project?rev=63710&view=rev
Log:
add the difference in the line marker phys line number and the
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!


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=63710&r1=63709&r2=63710&view=diff

==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Tue Feb  3 20:00:59 2009
@@ -697,10 +697,18 @@
     // 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);
+      
+
     }
   }
 





More information about the cfe-commits mailing list