Clang format discussion on options to be considered

I did a first testing with clang-format tool.

I use whatever is defined by default, and the following manual settings.

"AccessModifierOffset" : -4
"ColumnLimit" : 110
"AllowShortIfStatementsOnASingleLine" : "true"
"AlwaysBreakTemplateDeclarations" : "false"
"Standard" : "C++11"

I just drop this to let discussion about what is the most appropriate style settings to be used with clang-format. An example result after using clang-format is in the present TRestAxionSolarModel.

1 Like

I have seen the recently added clang-format by @lobis.

Personally, I use 120 column wide terminal, and I find more convenient that most of the methods are defined in just 1-line.

Could we add to the actual clang-format the following two lines?

IndentWidth: 4
ColumnLimit : 110

It is anyone using a terminal with shorter length?

It is fine by me.

Maybe the increased width can be a problem when doing some side by side comparison (merge etc.) especially when using 3 files (I think that’s the idea behind such a short limit anyway) but personally I don’t do these frequently enough that this would be come a problem so I agree with your additions to the .clang-format file.

Ok, I just reformatted the full source directory and added also a script reformat-clang.sh to re-format a given directory.

Usage : ./reformat-clang.sh /path/to/source/

If someone finds inconvenient the new style he may complain here.

I also found out that clang gets a bit confused after ClassImp( TRestClassName )

This is because ClassImp does not end using ;. However, I believe I run in the past into troubles long long time ago because the ; was included. Perhaps this was a bug in ROOT5? I have added now the ; to few classes and I get no troubles…

1 Like