r196511 - Check the initial line number without going through PresumedLoc

Alp Toker alp at nuanti.com
Thu Dec 5 09:28:43 PST 2013


Author: alp
Date: Thu Dec  5 11:28:42 2013
New Revision: 196511

URL: http://llvm.org/viewvc/llvm-project?rev=196511&view=rev
Log:
Check the initial line number without going through PresumedLoc

No practical difference in this case and would return 1 either way, but this is
more self-explanatory.

Modified:
    cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp

Modified: cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp?rev=196511&r1=196510&r2=196511&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp Thu Dec  5 11:28:42 2013
@@ -363,11 +363,10 @@ bool InclusionRewriter::Process(FileID F
   if (SM.getFileIDSize(FileId) == 0)
     return false;
 
-  SourceLocation StartLoc = RawLex.getSourceLocation();
   // The next byte to be copied from the source file, which may be non-zero if
   // the lexer handled a BOM.
-  unsigned NextToWrite = SM.getFileOffset(StartLoc);
-  assert(SM.getPresumedLoc(StartLoc).getLine() == 1);
+  unsigned NextToWrite = SM.getFileOffset(RawLex.getSourceLocation());
+  assert(SM.getLineNumber(FileId, NextToWrite) == 1);
   int Line = 1; // The current input file line number.
 
   Token RawToken;





More information about the cfe-commits mailing list