Project

General

Profile

Task #3895

Updated by Davide Pesavento almost 7 years ago

Clang-format is a tool that reformats C++ code (among other languages) according to a configuration file. The program is expressive and useful, and it would be a good extension to the toolchain. 

 Currently, the system has some limitations. According to Davide Pesavento: 

 * "break-after-return-type" doesn't work on overloaded operators, they are not considered functions, thus the rule isn't applied. 
 * `constexpr`/`explicit`/`virtual` "`explicit`" and "`virtual`" are not considered return types (and rightly so), but this means that constexpr/explicit explicit constructors and virtual destructors are reformatted written all on in one line. This is minor and I think we can adapt our code style. 
 * In lambda expressions, clang-format always removes the space between capture list and param list. This is very minor and we can adapt our style. 
 * clang-format The tool gets *very* confused by macros such as `PUBLIC_WITH_TESTS_ELSE_PRIVATE` (I guess it doesn't expand them) and it makes a terrible mess with the lines that follow, until it encounters another access specifier or the end of the class declaration. 
 * The alignment of "`<<`" after a line break within a logging macro is not what you would expect. 
 * Enums containing 

 At least a few short enumerators that of these could fit in one line are reformatted to be all on the same line (but fixed with clever use of a lexer or similar, perhaps a Perl or Python script. However, unless there is a [workaround](https://stackoverflow.com/a/24009906)) someone who wants to manage the extra parts, it could be unmaintainable.

Back