[prev in list] [next in list] [prev in thread] [next in thread]
List: cfe-commits
Subject: Re: [PATCH] PR14795 : -frewrite-includes sometimes results in incorrect line number
From: Eli Friedman <eli.friedman () gmail ! com>
Date: 2013-07-29 23:26:26
Message-ID: CAJdarcEzmampzEgX_qv3BOMWFSEcoMyL+fVHbpm23SAVf5MR8A () mail ! gmail ! com
[Download RAW message or body]
On Sun, Jul 28, 2013 at 2:22 AM, Lubos Lunak <l.lunak@suse.cz> wrote:
> On Thursday 25 of July 2013, Eli Friedman wrote:
>> On Tue, Jul 23, 2013 at 12:15 AM, Lubos Lunak <l.lunak@suse.cz> wrote:
>> > On Tuesday 16 of July 2013, Eli Friedman wrote:
>> >> On Sun, Jul 14, 2013 at 2:16 PM, Lubos Lunak <l.lunak@suse.cz> wrote:
>> >> > On Monday 01 of July 2013, Eli Friedman wrote:
>> >> >> --- a/lib/Lex/Lexer.cpp
>> >> >> +++ b/lib/Lex/Lexer.cpp
>> >> >> @@ -2372,8 +2372,9 @@ bool Lexer::LexEndOfFile(Token &Result, const
>> >> >> char *CurPtr) {
>> >> >> FormTokenWithChars(Result, CurPtr, tok::eod);
>> >> >>
>> >> >> // Restore comment saving mode, in case it was disabled for
>> >> >> directive. - resetExtendedTokenMode();
>> >> >> - return true; // Have a token.
>> >> >> + if (PP)
>> >> >> + resetExtendedTokenMode();
>> >> >> + return true; // Have a token.
>> >> >> }
>> >> >>
>> >> >> // If we are in raw mode, return this event as an EOF token. Let
>> >> >> the caller
>> >> >>
>> >> >> How is this related?
>> >> >
>> >> > I had a crash there without this when I wrote the patch. I don't
>> >> > remember the circumstances though and the random testcase I tried
>> >> > doesn't trigger it.
>> >>
>> >> Okay.
>> >>
>> >> Please commit without this change.
>> >
>> > Actually, LibreOffice is always a good testcase, so I can reproduce the
>> > crash after all:
> ...
>> > So I will include that change too, unless somebody sees a better way of
>> > avoiding this.
>>
>> Can you reduce a testcase?
>
> $ echo -ne '#if 0\n#endif' >a.cpp
> $ clang++ -frewrite-includes -E a.cpp
>
> (note the lack of the trailing \n)
Thanks.
Isn't the right fix here to rearrange the checks in Lexer::LexEndOfFile?
Please submit this as a separate patch, with a test.
-Eli
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic