clang-format Style for RTEMS

Joel Sherrill joel at rtems.org
Fri Dec 14 13:16:01 UTC 2018


On Fri, Dec 14, 2018, 7:08 AM Mikail Yayla <myayla1245 at gmail.com wrote:

> Hello,
>
> we are trying to describe the rtems formatting style using clang-format (
> http://clang.llvm.org/docs/ClangFormatStyleOptions.html).
> To see whether it can be done, we used ratemonperiod.c as an example and
> tried to set up a .clang-format file to describe the formatting.
> In the mail added the .clang configuration file and a
> ratemonperiodWKCustom_Commented.c, which is ratemonperiod.c with the
> configuration in .clang-format applied.
>
> With the .clang-format file in the folder with the source files, it can be
> tried out with:
> clang-format -style=file original_source.c > formatted_source.c
>
> There are several problems in ratemonperiodWKCustom_Commented.c using
> clang-format:
>
> 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.
>
> We have also asked the clang community how much effort it would take to
> implement these points.
>

This is awesome! Other than tracking this effort, what can the community do?

Have you seen the written description of the Coding Conventions? It is in
the wiki right now but recently converted to Sphinx/Rest to be paid of the
RTEMS Software Engineering Handbook. I intend to post a patch of a first
draft of the document next week but it is now in my personal rtems-docs
repo on git.rtems.org.

If you see discrepancies between the code and written guides, we'd like to
resolve that one way or the other.

>
> Best,
> Mikail
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20181214/c9137edd/attachment-0002.html>


More information about the devel mailing list