Issue799

Title use clang-format instead of uncrustify
Priority wish Status resolved
Superseder Nosy List jendrik, malte, silvan, thomas
Assigned To jendrik Keywords
Optional summary

Created on 2018-06-08.12:20:19 by jendrik, last changed by jendrik.

Files
File name Uploaded Type Edit Remove
.clang-format jendrik, 2018-06-08.12:20:19 application/octet-stream
Messages
msg7259 (view) Author: jendrik Date: 2018-06-16.09:50:11
During a Fast Downward meeting we came to the conclusion that switching to clang-
format has more disadvantages than advantages. 

clang-format bases its format on the token stream and ignores the existing format 
of the code. As a result, it only allows one way of formatting a given logical 
line of code. We think that this often results in less readable code. Also, this 
leads to lots of (rather unpredictable) changes whenever a logical line grows 
beyond or shrinks below the maximum line length.

Taken together with the advantages of clang-format over uncrustify listed in 
msg7242 and the disadvantages of clang-format in msg7250, we think it's better to 
consider upgrading to a newer uncrustify version.
msg7256 (view) Author: jendrik Date: 2018-06-08.18:35:13
I agree with all of your points. Let's discuss this issue during the next 
meeting.
msg7250 (view) Author: malte Date: 2018-06-08.16:50:32
Sounds good in principle. I tried it on the whole search code (not just the
top-level directory as in your example) and it produces an 18999 line diff, so
it looks like this would rather drastically reformat the code. This will make
merges very hard, so we would

1) Need to verify that we are happy with the new formatting conventions that
this change entails, and

2) Decide at which point we want to apply this change as it will likely
introduce conflicts in more or less all outstanding merges.

Changes like this need buy-in from everybody, so I think the next step going
forward would be to build consensus.
msg7242 (view) Author: jendrik Date: 2018-06-08.12:20:19
Our current version of uncrustify (0.61) has several drawbacks:

* It doesn't handle C++11 constructs well (e.g., lambda functions, initializer lists).
* It has a myriad of options, but they are poorly documented.
* It's not available in the Ubuntu repos.

Therefore, I propose switching to clang-format-5.0, which doesn't share these problems. It is available 
in Ubuntu 16.04, 17.10, 18.04 (and will be in 18.10).

I propose using the attached .clang-format file. For anyone interested in this issue, you can put the 
file into the root directory of your repository and run

sudo apt install clang-format-5.0
clang-format-5.0 -i src/search/*.h src/search/*.cc  # Modifies files in-place (be sure to backup first)
hg diff  # or "hg meld"

to see the effects on a subset of the source files. The format options are documented at 
https://releases.llvm.org/5.0.0/tools/clang/docs/ClangFormatStyleOptions.html .
History
Date User Action Args
2018-06-16 09:50:11jendriksetstatus: in-progress -> resolved
messages: + msg7259
2018-06-08 18:35:13jendriksetmessages: + msg7256
2018-06-08 16:50:32maltesetmessages: + msg7250
2018-06-08 15:21:22thomassetnosy: + thomas
2018-06-08 14:35:30silvansetnosy: + silvan
2018-06-08 12:20:19jendrikcreate