]> sourceware.org Git - glibc.git/commit
Add .clang-format style file
authorNoah Goldstein <goldstein.w.n@gmail.com>
Mon, 4 Apr 2022 16:56:46 +0000 (11:56 -0500)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Mon, 11 Apr 2022 15:51:03 +0000 (10:51 -0500)
commitac5f5a92edd9df5a6994e41309ef4a3580a2aeb1
tree5213d7d51e8a9c9a092140a71cf54ed47b0b36fa
parentd2265570a7694b5b01d5a0a2d56d3482ac1a5d97
Add .clang-format style file

Went with version >= 11.0 since it covers most of the major features
and should be pretty universally accessibly.

There are some issues:

1.  indention of preprocessor directives:
    Unfortunately there doesn't appear to be a switch for a seperate
    'IndentWidth' for preprocessor directives vs. normal code so we
    are stuck either not indenting the directives or over-indenting
    them. i.e:
    Desired:
    ```
    #ifndef A
    # define B
    #endif
    ```
    Options:
    ```
    #ifndef A
    #  define B /* Two spaces instead of one.  */
    #endif

    #ifndef C
    #define D   /* No spaces.  */
    #endif
    ```
    Chose to over-indent as it generally seems easier to script
    halving all pre-processor indentations than counting the nested
    depth and indenting from scratch.

2.  concatenation of lines missing semi-colons:
    Throughout glibc there are macros used to setup aliasing that are
    outside of functions and don't end in semi-colons i.e:
    ```
    libc_hidden_def (__pthread_self)
    weak_alias (__pthread_self, pthread_self)
    ```

    clang-format reformats lines like these to:
    ```
    libc_hidden_def (__pthread_self) weak_alias (__pthread_self, pthread_self)
    ```

    which is generally undesirable.

Other than those two big concerns there are certainly some questions
diffs but for the most part it creates a easy to read and consistent
style.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
.clang-format [new file with mode: 0644]
This page took 0.038571 seconds and 5 git commands to generate.