Enforcing Coding Conventions
July 31, 2015 ยท View on GitHub
The LLILC project is structured as a subproject of LLVM so we are using the same coding conventions as LLVM. See the coding convention document for more details. To maintain these conventions, we require all contributors to run our code formatting script over their changes before submitting a pull request. The code formatting script is found at LLILC\utils\ccformat.py.
Prerequisites
- Binaries for clang-format and clang-tidy are required to run ccformat.py.
- clang-format is available in the clang repository. It can either be downloaded from LLVM, or built from clang source tree.
- clang-tidy is available in the clang-tools-extra repository. It should be built from the MS branch of the clang-tools-extra repository.
Setup
- Set the INCLUDE=
. On Windows, this can be done by executing
"%VS120COMNTOOLS%\..\..\VC\vcvarsall.bat" x64
- Provide a full path to the following locations via the corresponding environment settings or command line arguments.
| Description | Environment Variable | Argument to ccFormat.py |
|---|---|---|
| LLVM source directory | LLVMSOURCE | --llvm-source <path> |
| LLVM build directory | LLVMBUILD | --llvm-build <path> |
| CoreClr build directory | CORECLRBUILD | --coreclr-build <path> |
| clang-format binary | /< on path/> | --clang-format <path> |
| clang-tidy binary | /< on path/> | --clang-tidy <path> |
Running ccformat
To check if a submission conforms to coding conventions, contributors should run from their main LLILC enlistment directory:
utils\ccformat.py
Choosing Checks
By default, ccFormat will run both clang-format and clang-tidy checks. To disable clang-format checks, run:
utils\ccformat.py --noformat
To disable clang-tidy checks, run:
utils\ccformat.py --untidy
Hiding Formatting Diffs
If you do not want to see the diffs generated by clang-format (but only want to check if there are any formatting errors), run:
utils\ccformat.py --hide-diffs
Fixing Formatting Errors
If ccformat.py informs you that there are diffs between your code and the formatted version returned by clang-format, contributors need to run with --fix to automatically fix formatting errors:
utils\ccformat.py --fix
Further Information
For further information, please run:
utils\ccformat.py --help