Commit Graph

1 Commits

Author SHA1 Message Date
Noah Goldstein ac5f5a92ed 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>
2022-04-11 10:51:03 -05:00