Hi all, Re: misc: Add .clang-format for C++ autoformat tools https://gem5-review.googlesource.com/#/c/3382/
Gabe uploaded this change set which is an internal version of .clang-format configuration which IMO formats closest to gem5 style guide definitions. I have happily used clang-format for ~2 years now (still learning) and it has saved me time developing C++ code and humiliating code reviews. So I start this discussion, hopefully we can mutually agree if and how we can adopt clang-format for gem5 project. It seems folks agree that there is considerable advantage of using clang-format for C++ code auto-formatting but there exist some specific C++ code in gem5 that is incompatible. I list a few known issues and possible remedy. 1) BitUnion or any other macros: The ideal solution is to implement support for macro in clang-format but IMO this is quite complicated and unlikely to happen without significantly changing clang-format tool itself. A simple work around for this issue is to use: https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code 2) switch case label indentation: Since switch case indentation has many observed rules depending on different SW project, we can define the gem5 style guide to either keep case label indentation same as switch statement or 4 spaces indented. Both these are programmable in clang-format configuration via IndentCaseLabels parameter. 3) clang-format doesn't check "naming" convention: This is out of scope of clang-format Internally at Google we use cpplint <https://google.github.io/styleguide/cppguide.html#cpplint> and gem5 style checker can incorporate checking naming convention. 4) Accepting on a certain .clang-format configuration for gem5 and then revising the gem5 code base: e.g. following a specific rule on how constructor initialization list is formatted and revising existing code base to comply with agreed upon .clang-format configuration Thanks, Rahul. _______________________________________________ gem5-dev mailing list [email protected] http://m5sim.org/mailman/listinfo/gem5-dev
