r196461 - Add an assert to make it clear we're on the first line
Alp Toker
alp at nuanti.com
Wed Dec 4 19:41:20 PST 2013
Author: alp
Date: Wed Dec 4 21:41:20 2013
New Revision: 196461
URL: http://llvm.org/viewvc/llvm-project?rev=196461&view=rev
Log:
Add an assert to make it clear we're on the first line
A raw lexer in its initial state is guaranteed to be on line number one.
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=196461&r1=196460&r2=196461&view=diff
==============================================================================
--- cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp (original)
+++ cfe/trunk/lib/Rewrite/Frontend/InclusionRewriter.cpp Wed Dec 4 21:41:20 2013
@@ -363,9 +363,11 @@ 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(RawLex.getSourceLocation());
+ unsigned NextToWrite = SM.getFileOffset(StartLoc);
+ assert(SM.getPresumedLoc(StartLoc).getLine() == 1);
int Line = 1; // The current input file line number.
Token RawToken;
More information about the cfe-commits
mailing list