[Openmp-commits] [PATCH] D38837: Add explicit values to .clang-format

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Oct 16 15:59:34 PDT 2017


jlpeyton added a comment.

Ok, I've done some more research on this and here is what I've found and suggest as the solution:

1. It appears we didn't clang-format our codebase to completion or somehow these changes in https://reviews.llvm.org/D38920 slipped through the cracks.  I don't know.  Whatever the case, it is a good idea to commit these remaining format changes.
2. The current non-commented part of .clang-format is fine and does not need changes to it.  Not even the MaxEmptyLinesToKeep change.  The changes that occur when MaxEmptyLinesToKeep=1 is tidying up around the LLVM license inclusion parts in the comment headers in each file.  Those changes are fine and would be consistent with our internal code base.  That being said, the commented parts are confusing and should be removed as they are not consistent with the defaults for clang-format.
3. Different versions of clang-format can produce different results when you clang-format an entire file and there is no great solution.  I've tried 3.7.1, 3.8.1, 3.9.1, 4.0 and all have given slightly different formatting for different parts of the code.  If you try to include a new Attribute: Value pair in the .clang-format file and use an old clang-format executable, then the .clang-format file is ignored and the "fallback-style" is used (defaults to LLVM).  For example, if you use an attribute added in v3.9, then you can only use v3.9+.  Also, from what I've seen, the defaults do not change from 3.7.1 to 4.0.

A compromise to 3) is to use `git clang-format` which I've described above which only formats the changes in your commit and does not format the entire file.  This way formatting is restricted to your changes and will not affect unrelated code.  If all users tried to do the `clang-format *.cpp *.h` lines for every commit, and they are using differing clang-format versions, we would get oscillating formatting changes to unrelated parts of the code.

So the next steps I would suggest are this:

1. Remove all changes to non-commented part of .clang-format, Remove all comments in .clang-format.
2. Run clang-format 3.8.1 on the current codebase to incorporate the missing formatting changes in https://reviews.llvm.org/D38920 and also new changes removing double newlines.
3. Do something like I've described above on the OMPT change.  It still needs to be run through clang-format and upload that to Phabricator.

Joachim, if you are ok with this I can do 1) and 2) and commit.  Is this ok?


https://reviews.llvm.org/D38837





More information about the Openmp-commits mailing list