[cfe-dev] Clang-format configuration files

Mehmet Erol Sanliturk m.e.sanliturk at gmail.com
Mon May 6 12:25:05 PDT 2013


On Mon, May 6, 2013 at 11:54 AM, Alexander Kornienko <alexfh at google.com>wrote:

> It's time for clang-format to support more flexible style configuration.
> We're starting to work on configuration files support for clang-format.
>
> Some thoughts on desired features and overall design:
>
>    - *contents*: fields of the FormatStyle struct, which currently has <
>    20 fields of primitive types;
>    - *format*: a set of key-value pairs, most probably JSON or YAML with
>    flat structure, e.g.:
>      ColumnLimit: 80
>      ConstructorInitializerAllOnOneLineOrOnePerLine: true
>      ...
>    - *file location*: in a longer term we'd like to support local
>    per-project hierarchical model, so that style can be configured for a
>    project and then partially or fully overridden in its various subprojects.
>    E.g. for this directory structure:
>      dir:
>        .clang-format
>        a.cpp
>        subdir:
>          .clang-format
>          b.cpp
>
>    *clang-format dir/a.cpp* should read only dir/.clang-format (assuming
>    that there are no .clang-format files in parent directories), *clang-format
>    dir/subdir/b.cpp* should use configuration values from
>    dir/subdir/.clang-format, and for the values not defined there try to
>    get them from dir/.clang-format
>    - *command-line interface*: there's currently -style option which
>    takes a name of a predefined style, we can use "-style config" or "-style
>    file" to turn on configuration file parsing, or turn it on by default.
>
> Any comments/suggestions?
>
>

(1)

Instead of writing :

ConstructorInitializerAllOnOneLineOrOnePerLine


Use of underscores makes reading more easier :

Constructor_Initializer_All_On_One_Line_Or_One_Per_Line


(2)

Instead of using - ( dash ) , use of underscore as a separator between
words allows use of variable parsing procedures to be used for parsing
lines :

"clang-format" as three tokens
versus
"clang_format"  as one token .



Thank you very much .


Mehmet Erol Sanliturk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130506/64af24f6/attachment.html>


More information about the cfe-dev mailing list