From: Alp Toker Date: Thu, 5 Dec 2013 03:41:20 +0000 (+0000) Subject: Add an assert to make it clear we're on the first line X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a2671931cbcf245390281162037628776a5ecfb9;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196461 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Rewrite/Frontend/InclusionRewriter.cpp b/lib/Rewrite/Frontend/InclusionRewriter.cpp index 176ea3f79d..16c6d86f73 100644 --- a/lib/Rewrite/Frontend/InclusionRewriter.cpp +++ b/lib/Rewrite/Frontend/InclusionRewriter.cpp @@ -363,9 +363,11 @@ bool InclusionRewriter::Process(FileID FileId, 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;