r200787 - Fix whitespace handling in empty macro expansions

Richard Smith richard at metafoo.co.uk
Mon Feb 24 12:51:48 PST 2014


On Wed, Feb 5, 2014 at 1:08 PM, Harald van Dijk <harald at gigawatt.nl> wrote:

> On 05/02/14 00:42, Richard Smith wrote:
> > Here's an easy test:
> >
> > #define foo() bar() b
> > #define bar()
> > a
> > foo()
> > c
> >
> > This should produce:
> >
> > # 1 "..."
> >
> >
> > a
> >  b
> > c
> >
> > ... but currently produces:
> >
> > #1 "..."
> >
> >
> > a b
> >
> > c
>
> Thanks Richard, I don't know how I managed to miss that.
>
> Setting Token::StartOfLine as mentioned gets this right in the lexer.
> However, even though the b token in the output has both
> Token::StartOfLine and Token::LeadingSpace set,
> PrintPPOutputPPCallbacks::HandleFirstTokOnLine uses the column number to
> determine whether to print spaces, not the flag. As a result, the output
> becomes not
>
> a
>  b
> c
>
> but
>
> a
> b
> c
>
> Given that the lexer behaviour is now right, would it be okay to leave
> this as it is, and only add a test to check that b is on a separate
> line, like attached?


Yes, this is fine. Committed as r202068. Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140224/739b0d91/attachment.html>


More information about the cfe-commits mailing list