[cfe-dev] [clang-format] Typedef declaration alignment

Valentino Picotti via cfe-dev cfe-dev at lists.llvm.org
Mon May 16 05:11:07 PDT 2016


Ping.

> On 11 May 2016, at 20:41, Valentino Picotti <valentino.picotti at gmail.com> 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




More information about the cfe-dev mailing list