clang-format: features, questions and contributions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

clang-format: features, questions and contributions

Yvan Roux via cfe-dev
Hi everyone,

I'm on a new team with a new style guide and I'm trying to make everyone happy with clang-format. Two issues that have been raised are:

- We have different formatting guidelines for C vs C++ code.
- Function declarations should have bin packed parameters but function definitions should have parameters on each line.

I got downloaded and build clang this evening and played with modifying formatting. I'm happy making these changes, if they are possible. Do these sound like features that would be welcome upstream?

I'm thinking about changing BinPackParameters from a boolean to an enum with values something like {Always, DeclarationsOnly, DefinitionsOnly, Never}. 

Does that sound possible? 
Does clang-format know when it is formatting a declaration vs a definition? 

I see a few flags that seem to indicate that it does but it also seemed like it might be a heuristic. 

Having different rules for C and C++... I have no idea how I'd distinguish that programmatically. 

Can clang-format tell if a file is C or C++? If so, adding a new FormatStyle so I can have different configs in my .clang-format file doesn't seem too difficult on the surface.

Does this sound like something that would be welcome upstream?

Also, are there any standard scripts to use clang-format with Mercurial? I've written my own but it is far from ideal.

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: clang-format: features, questions and contributions

Yvan Roux via cfe-dev
Hi Alan,

On Thu, Sep 27, 2018 at 9:36 AM, Alan Oursland via cfe-dev
<[hidden email]> wrote:
(snip)
> Having different rules for C and C++... I have no idea how I'd distinguish
> that programmatically.
>
> Can clang-format tell if a file is C or C++? If so, adding a new FormatStyle
> so I can have different configs in my .clang-format file doesn't seem too
> difficult on the surface.

It seems easier to filter the list of files, and invoke clang-format
once for C files with one config and again for C++ files with a
different config file.


Csaba
--
You can get very substantial performance improvements
by not doing the right thing. - Scott Meyers, An Effective C++11/14 Sampler
So if you're looking for a completely portable, 100% standards-conformat way
to get the wrong information: this is what you want. - Scott Meyers (C++TDaWYK)
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev