[cfe-dev] clang-format: features, questions and contributions

Alan Oursland via cfe-dev cfe-dev at lists.llvm.org
Thu Sep 27 00:36:12 PDT 2018


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180927/fd6c1ff3/attachment.html>


More information about the cfe-dev mailing list