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

Ben Longbons brlongbons at gmail.com
Sat Dec 7 18:01:46 PST 2013


On Wed, Dec 4, 2013 at 2:45 PM, Daniel Jasper <djasper at google.com> wrote:
> However, it might be my ignorance because I might not have
> worked on enough projects to see that this is actually a common style. Get
> me any kind of numbers. How many projects are there that use this style?
I did a quick-and-dirty search of C++ projects on Github and Google
Code, and found:
- Most don't have a consistent style at all, even within one file.
- About 15% use my style consistently in multiple files.
- Most projects that use a lot of references ("C++-ish") use type& val
- Most projects that use a lot of pointers ("C-ish") use type *val
- Very few projects have references and pointers in the same file.
- None of the projects I looked at consistently used type * val, but
did appeared in the inconsistent files.

> Is
> there a publicly accessible coding style that says that this is a good idea?
I'm not aware of one.

> If it just your codebase and
> you absolutely need clang-format to support this, fix the harder problems
> first.
I could, but at this point I just don't think it's worth my time to
try to get things into clang-format. I can't say anything when you say
"options are bad".

Instead, I'm working on a serious of pipe programs, each of which does
only one specific transformation. I've already found the advantage
that earlier tasks can deliberately introduce things that will be
fixed up later, it works on lex and yacc inputs, and it's really
obvious where the relevant code bits are.

-Ben



More information about the cfe-commits mailing list