r196461 - Add an assert to make it clear we're on the first line

Alp Toker alp at nuanti.com
Thu Dec 5 09:33:54 PST 2013


On 05/12/2013 16:50, Alp Toker wrote:
>
> On 05/12/2013 16:43, Jordan Rose wrote:
>> Should this be using the presumed loc? That gets reset by #line and 
>> such.
>
> Well, a raw lexer in its initial state won't have done any 
> preprocessing yet so the presumed loc line is guaranteed to be 1.
>
> But yes, it'd be nice to check the physical line to make the assertion 
> stronger.

r196511.

Alp.


>
> Alp.
>
>
>>
>> Jordan
>>
>> On Dec 4, 2013, at 19:41 , Alp Toker <alp at nuanti.com> wrote:
>>
>>> 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;
>>>
>>>
>>> _______________________________________________
>>> cfe-commits mailing list
>>> cfe-commits at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>

-- 
http://www.nuanti.com
the browser experts




More information about the cfe-commits mailing list