[cfe-dev] Clang-format configuration files

Sean Silva silvas at purdue.edu
Mon May 6 16:50:19 PDT 2013


On Mon, May 6, 2013 at 12:54 PM, 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?
>
>
In case you weren't aware of it, we have a great YAML library
http://llvm.org/docs/YamlIO.html which you should use if you go the YAML
route (or JSON, which is a subset of YAML).

-- Sean Silva
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130506/187d6f4d/attachment.html>


More information about the cfe-dev mailing list