[PATCH] Fix bug in clang-format while merging short function (PR19461)

Manuel Klimek klimek at google.com
Thu Apr 24 03:40:00 PDT 2014


On Thu, Apr 24, 2014 at 12:34 PM, Dinesh Dwivedi <dinesh.d at samsung.com>wrote:

> *** updated comment for typos
>
> Hi Klimek,
>
> Thanks for review.
>
> With this change, I am trying to figure out whether there is a "gap" in
> the line.
> If this gap is just white spaces, that is not an issue and we can still
> merge
> function. But if there are other constructs such as preprocessor
> directives, we
> should not merge this function to single line.
>

With "gap" I mean that the UnwrappedLine has a sequence of tokens that are
not also subsequent in the original token stream. The correct fix is to
figure out whether that has happened.
Architecturally, we put the #ifdef directives into different
UnwrappedLines, and the UnwrappedLine with the code then has non-continuous
tokens in it.

Now that I think about it - those tokens also need to have MustBreakBefore
set - can we just check that we never merge lines when one of the tokens
has MustBreakBefore set?


>
> During debugging, I have observed that if there are other constructs,
> block before
> and after the construct (inclusive) are handled separately [Basically, I
> am trying
> to say is I found TheLine->MustBeDeclaration to be false for 'after' block
> in such
> cases]. I assumed, just checking for this case is good enough, as asserted
> from
> test cases too.
>
> If you think this is not correct, I will look in to code and try to find
> better fix.
>
> Regards
>
> http://reviews.llvm.org/D3439
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140424/2617a8fc/attachment.html>


More information about the cfe-commits mailing list