[cfe-dev] clang-format Style for RTEMS

Mikail Yayla via cfe-dev cfe-dev at lists.llvm.org
Fri Dec 14 03:53:48 PST 2018


Hello,

for the rtems (https://www.rtems.org/) source code we are trying to
describe the rtems formatting style (
https://devel.rtems.org/wiki/Developer/Coding/Conventions) using
clang-format.
To see whether it can be done, we used ratemonperiod.c as an example and
tried to set up a .clang-config file to describe the formatting.

In the mail I added the .clang configuration file and a
ratemonperiodWKCustom_Commented.c, which is ratemonperiodOriginal.c with
the configuration in .clang-config applied.

There are several problems in ratemonperiodWKCustom_Commented.c using
clang-format.
Our questions are whether these points can be resolved using different
configurations.
If they are not available with different configurations, we would like to
ask you how much effort would be needed to implement the functionality
which seems missing in clang-format:

The problems/needed functionality in ratemonperiodWKCustom_Commented.c:

1. In line 30-32, we can see that the "*" of the pointers are not aligned
to the right. This is not supported yet it clang-format (see
https://stackoverflow.com/questions/38392889/clang-format-align-asterisk-of-pointer-declaration-with-variable-name
).

2. In line 32, the ")" at the end of the parameter list needs to be in a
new row, but this doesn't seem to be supported in clang-format.

4. In line 44: If the function call is split into multiple rows, the ");"
should always be in a new row.

5. Also in line 44, when a function call is split into multiple rows. The
parameters can all be in separate rows, but clang-format always puts all
the parameters in one row when they fit.

6. In line 80, clang-format does not stick to the column limit of 80. The
line is 81 long. I have tried to configure a strict 80 column rule with the
penalties, but there are still lines with 81 characters.

7. In line 127, I can't turn off the break after the function return type
in this case.

8. In line 127, the parameter is not in a new line, but in rtems we would
need every parameter of a function definition to always be in seperate
line. Line 182, 279 have the same problem.

8. Lines 323, 330, 335, 348: It should be possible to specify that the
functions arguments can be in seperate rows.

Best,
Mikail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181214/ec8351cc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ratemonperiodWKCustom_Commented.c
Type: text/x-csrc
Size: 11050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181214/ec8351cc/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ratemonperiodOriginal.c
Type: text/x-csrc
Size: 10540 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181214/ec8351cc/attachment-0001.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .clang-format
Type: application/octet-stream
Size: 3275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181214/ec8351cc/attachment.obj>


More information about the cfe-dev mailing list