clang-format.rst (1059B)
1 clang-format 2 ============ 3 4 `clang-format <https://clang.llvm.org/docs/ClangFormat.html>`__ is a tool to reformat C/C++ to the right coding style. 5 6 Run Locally 7 ----------- 8 9 The mozlint integration of clang-format can be run using mach: 10 11 .. parsed-literal:: 12 13 $ mach lint --linter clang-format <file paths> 14 15 16 Configuration 17 ------------- 18 19 To enable clang-format on new directory, add the path to the include 20 section in the :searchfox:`clang-format.yml <tools/lint/clang-format.yml>` file. 21 22 While excludes: will work, this linter will read the ignore list from :searchfox:`.clang-format-ignore file <.clang-format-ignore>` 23 at the root directory. This because it is also used by the ./mach clang-format -p command. 24 25 Autofix 26 ------- 27 28 clang-format can reformat the code with the option `--fix` (based on the upstream option `-i`). 29 To highlight the results, we are using the ``--dry-run`` option (from clang-format 10). 30 31 Sources 32 ------- 33 34 * :searchfox:`Configuration (YAML) <tools/lint/clang-format.yml>` 35 * :searchfox:`Source <tools/lint/clang-format/__init__.py>`