[cfe-dev] clang-format inconsistent behavior

FIXED-TERM Kammel Fabian (ETAS-PSC/EPE) via cfe-dev cfe-dev at lists.llvm.org
Wed Feb 15 01:02:35 PST 2017


No sorry the error is on my side. I accidentally copied the same file twice. Find the correct files attached to this mail.

I do agree that the interface to the function calls can be improved, but (as you probably know) that is not always possible. I do have two weeks of spare time. Do you think it’s reasonable to implement a switch to specify this behavior as well?

Also do you think it’s possible to achieve this in two weeks? Sounds like this change/adding this option might be complex or even impossible?

Regards,
Fabian


From: Manuel Klimek [mailto:klimek at google.com]
Sent: Dienstag, 14. Februar 2017 12:24
To: FIXED-TERM Kammel Fabian (ETAS-PSC/EPE) <fixed-term.Fabian.Kammel at escrypt.com>; cfe-dev at lists.llvm.org
Subject: Re: [cfe-dev] clang-format inconsistent behavior

Not sure whether I'm unable to use my mail program correctly, but I don't get a diff between desired.c and format_me.c.

Generally, we've thought about trying to make clang-format be more consistent across subsequent statements, but
a) that's a lot of effort, as clang-format fundamentally works on each statement separately
b) basically all instances (outside of braced lists, which have special support) we've seen have been due to code duplication, where the right answer is to refactor the code so the structure is simpler

For example, in your code, I would pull out a wrapper function that takes all the common parameters in a struct, and potentially the other parameters as structs, too. That way, the calls would become reasonably short.

On Mon, Feb 13, 2017 at 5:35 PM FIXED-TERM Kammel Fabian (ETAS-PSC/EPE) via cfe-dev <cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>> wrote:
Hi All,

I have found an inconsistent behavior in clang-format. When I format the attached desired.c with the attached .clang-format file (using Clang 4.0 on Windows) I get format_me.c.

I think that the assignment should be consistent, either break the line for all assignments or none of them. Is there an option I have missed or is this behavior intended/not configurable? And if not configurable would we be interested in such a switch?

Regards,
Fabian
_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org<mailto:cfe-dev at lists.llvm.org>
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170215/91a0e825/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: format_me.c
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170215/91a0e825/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: desired.c
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170215/91a0e825/attachment-0001.c>


More information about the cfe-dev mailing list