[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-06-30 23:35:04
Message-ID: CAJdarcFDqrQTjTwr5aVz7rLAG6N6WO8TprbXk9-YJq_FSHhukQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


On Sat, Jun 29, 2013 at 11:35 PM, Lubos Lunak <l.lunak@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?

+            // We surround every #include by #if 0 to comment it out, but
that
+            // changes line numbers. These are fixed up right after that,
but
+            // the whole #include could be inside a preprocessor
conditional
+            // that is not processed. So it is necessary to fix the line

This looks like it puts a line directive after every if/elif/else/endif.
 That not really a problem, I guess, but it would be nice to avoid if
possible.

Otherwise, looks fine.

-Eli

[Attachment #5 (text/html)]

<div dir="ltr">On Sat, Jun 29, 2013 at 11:35 PM, Lubos Lunak <span dir="ltr">&lt;<a \
href="mailto:l.lunak@suse.cz" target="_blank">l.lunak@suse.cz</a>&gt;</span> \
wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 <br>
 Hello,<br>
<br>
 could somebody please review and commit the atached patch for pr14795? Thank<br>
you.<br><br></blockquote><div><br></div><div>--- a/lib/Lex/Lexer.cpp</div><div>+++ \
b/lib/Lex/Lexer.cpp</div><div>@@ -2372,8 +2372,9 @@ bool Lexer::LexEndOfFile(Token \
&amp;Result, const char *CurPtr) {</div><div>     FormTokenWithChars(Result, CurPtr, \
tok::eod);</div> <div> </div><div>     // Restore comment saving mode, in case it was \
disabled for directive.</div><div>-    resetExtendedTokenMode();</div><div>-    \
return true;  // Have a token.</div><div>+    if (PP)</div><div>+      \
resetExtendedTokenMode();</div> <div>+    return true; // Have a token.</div><div>   \
}</div><div>  </div><div>   // If we are in raw mode, return this event as an EOF \
token.  Let the caller</div><div><br></div><div>How is this \
related?</div><div><br></div> <div>+            // We surround every #include by #if \
0 to comment it out, but that</div><div>+            // changes line numbers. These \
are fixed up right after that, but</div><div>+            // the whole #include could \
be inside a preprocessor conditional</div> <div>+            // that is not \
processed. So it is necessary to fix the line</div><div><br></div><div>This looks \
like it puts a line directive after every if/elif/else/endif.  That not really a \
problem, I guess, but it would be nice to avoid if possible.</div> \
<div><br></div><div>Otherwise, looks \
fine.</div><div><br></div><div>-Eli</div></div></div></div>



_______________________________________________
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