[clang-format] Typedef declaration alignment

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[clang-format] Typedef declaration alignment

Neil Nelson via cfe-dev
Hi everybody,

I was wondering why clang-format does not align consecutive typedef as one might expect.
As an example, what i except from the following code:
   
    typedef hash_table_iterator<T, key_type, hash_type> iterator;
    typedef hash_table_iterator<T, key_type, hash_type, true> const_iterator;
    typedef std::pair<key_type, T> value_type;

is an alignment like (when the option AlignConsecutiveDeclarations is true):
   
    typedef hash_table_iterator<T, key_type, hash_type>         iterator;
    typedef hash_table_iterator<T, key_type, hash_type, true> const_iterator;
    typedef std::pair<key_type, T>                                             value_type;

but no change is applied by clan-format.

Looking at the code, what prevents the formatting is the number of commas found before the “declaration name”, i.e. iterator, const_iterator and value_type. If the number of commas changes from one declaration to the next one, the sequence of declaration to align is interrupted.

Is this behavior intentional?

Valentino Picotti
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: [clang-format] Typedef declaration alignment

Neil Nelson via cfe-dev
Ping.

> On 11 May 2016, at 20:41, Valentino Picotti <[hidden email]> wrote:
>
> Hi everybody,
>
> I was wondering why clang-format does not align consecutive typedef as one might expect.
> As an example, what i except from the following code:
>
>    typedef hash_table_iterator<T, key_type, hash_type> iterator;
>    typedef hash_table_iterator<T, key_type, hash_type, true> const_iterator;
>    typedef std::pair<key_type, T> value_type;
>
> is an alignment like (when the option AlignConsecutiveDeclarations is true):
>
>    typedef hash_table_iterator<T, key_type, hash_type>         iterator;
>    typedef hash_table_iterator<T, key_type, hash_type, true> const_iterator;
>    typedef std::pair<key_type, T>                                             value_type;
>
> but no change is applied by clan-format.
>
> Looking at the code, what prevents the formatting is the number of commas found before the “declaration name”, i.e. iterator, const_iterator and value_type. If the number of commas changes from one declaration to the next one, the sequence of declaration to align is interrupted.
>
> Is this behavior intentional?
>
> Valentino Picotti

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev