[PATCH] PR14795 : -frewrite-includes sometimes results in incorrect line number

Lubos Lunak l.lunak at suse.cz
Tue Jul 23 00:15:33 PDT 2013


On Tuesday 16 of July 2013, Eli Friedman wrote:
> On Sun, Jul 14, 2013 at 2:16 PM, Lubos Lunak <l.lunak at suse.cz> wrote:
> > On Monday 01 of July 2013, Eli Friedman wrote:
> >> On Sat, Jun 29, 2013 at 11:35 PM, Lubos Lunak <l.lunak at suse.cz> wrote:
> >> >  Hello,
> >> >
> >> >  could somebody please review and commit the atached patch for
> >> > pr14795? Thank
> >> > you.
> >>
> >> --- 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:

#3  0x00007f19e5e1e392 in __assert_fail () from /lib64/libc.so.6
#4  0x0000000001fc8e46 in clang::Lexer::resetExtendedTokenMode 
(this=0x7fff35cc4b00) 
at /home/llunak/build/src/llvm/tools/clang/lib/Lex/Lexer.cpp:129
#5  0x0000000001fd11f8 in clang::Lexer::LexEndOfFile (this=0x7fff35cc4b00, 
Result=..., CurPtr=0x75a4c94 "") 
at /home/llunak/build/src/llvm/tools/clang/lib/Lex/Lexer.cpp:2375
#6  0x0000000001fd1743 in clang::Lexer::LexTokenInternal (this=0x7fff35cc4b00, 
Result=...) at /home/llunak/build/src/llvm/tools/clang/lib/Lex/Lexer.cpp:2763
#7  0x0000000001f0c148 in clang::Lexer::Lex (this=0x7fff35cc4b00, Result=...) 
at /home/llunak/build/src/llvm/tools/clang/include/clang/Lex/Lexer.h:145
#8  0x0000000001f0b6a3 in clang::Lexer::LexFromRawLexer (this=0x7fff35cc4b00, 
Result=...) 
at /home/llunak/build/src/llvm/tools/clang/include/clang/Lex/Lexer.h:160
#9  0x0000000002f82cdd in (anonymous namespace)::InclusionRewriter::Process 
(this=0x5be11a0, FileId=..., FileType=clang::SrcMgr::C_ExternCSystem) 
at /home/llunak/build/src/llvm/tools/clang/lib/Rewrite/Frontend/InclusionRewriter.cpp:477

 So I will include that change too, unless somebody sees a better way of 
avoiding this.

-- 
 Lubos Lunak
 l.lunak at suse.cz



More information about the cfe-commits mailing list