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

Alp Toker alp at nuanti.com
Wed Nov 27 18:15:47 PST 2013


On 28/11/2013 01:50, Ben Longbons wrote:
> On Wed, Nov 27, 2013 at 2:26 PM, Daniel Jasper <djasper at google.com> wrote:
>> This does not make any sense to me and I'd vote against putting it into
>> clang-format. Can you explain the rationale behind this formatting decision?
> It's certainly not the most *popular* formatting style, but it's the
> one I learned. Some other formatting tools, such as astyle, support
> this style.
> I'm guessing the reason I learned this style was because my background
> was C before C++, and most C code uses "int *var" but a lot of C++
> code uses "int& var" and avoids pointers.
> Note that the ambiguity doesn't usually happen in practice with
> references because references must be initialized so only one is
> declared on each line.
>
> I'm trying to go from manually-enforced style to automatically

Hi Ben,

Would an option to not touch the existing pointer/reference style be 
satisfactory?

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.

PS. I like the 'attach' terminology in your patch, maybe that's 
something libFormat could adopt -- reference 'binding' always meant 
something other that where the & token goes during code formatting in my 
mind(!)

Alp.



> , and I
> don't want the first formatting run to introduce a huge diff. I think
> that is the *single* *biggest* *thing* people want out of a formatting
> tool. It's not your job try to force one particular style on anyone
> (unless you're writing a new language - Go did this well).
>
> There are other things I need that clang-format doesn't support yet
> (such as forcing a newline after constexpr/static/inline and indenting
> preprocessor directives), but this patch was the easiest to make.
>
> -o11c
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

-- 
http://www.nuanti.com
the browser experts




More information about the cfe-commits mailing list