Patch for clang-format to allow references and pointers to bind differently

Ben Longbons brlongbons at
Wed Nov 27 21:43:20 PST 2013

On Wed, Nov 27, 2013 at 6:15 PM, Alp Toker <alp at> wrote:
> On 28/11/2013 01:50, Ben Longbons wrote:
>> I'm trying to go from manually-enforced style to automatically
> Would an option to not touch the existing pointer/reference style be
> satisfactory?
Well, there already is an option DerivePointerBinding, which my patch
changes to do separate deduction for references.

Changing that to keep the existing style at each individual site would
solve the problem of the initial diff when applying it to my repo, but
not the main problem that a code formatter is supposed to solve.

> I can see a wider appeal for controlling what gets formatted and what
> doesn't, as opposed to just trying to support every personal taste here.
I admit, when I first started messing with the GNU indent program as a
novice, I asked "why doesn't this program ONLY change indentation?" At
the time I didn't even know about expand(1).

But what I want *now*, as a maintainer, is to be able to say to my
contributors: "if you run 'make format', your code will comply to all
style guidelines".

I actually think it's a bad idea for a formatter to *ever* preserve
anything, except in an initial "clang-format --detect-style >
.clang-format" run.
The only hard cases I can think of are:
1. if it decides to break a comment (which is irreversible, so should
never be done by default ... I'm not sure what exactly clang-format
does with PenaltyBreakComment)
2. when preserving multiple blank lines between logically distinct
parts of a source file (but what you really want in that case is
probably either a documentation section or a namespace or something,
so I could live without that).


More information about the cfe-commits mailing list