Skip to content

Update version of clang format in CODING_STANDARDs #4196

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions CODING_STANDARD.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ To avoid waiting until you've made a PR to find formatting issues, you can
install clang-format locally and run it against your code as you are working.

Different versions of clang-format have slightly different behaviors. CBMC uses
clang-format-3.8 as it is available the repositories for Ubuntu 16.04 and
clang-format-7 as it is available the repositories for Ubuntu 18.04 and
Homebrew.
To install on a Unix-like system, try installing using the system package
manager:
```
apt-get install clang-format-3.8 # Run this on Ubuntu, Debian etc.
brew install clang-format@3.8 # Run this on a Mac with Homebrew installed
apt-get install clang-format-7 # Run this on Ubuntu, Debian etc.
brew install clang-format@7 # Run this on a Mac with Homebrew installed
```

If your platform doesn't have a package for clang-format, you can download a
Expand All @@ -333,18 +333,23 @@ the [LLVM Snapshot Builds page](http://llvm.org/builds/).

### FORMATTING A RANGE OF COMMITS

Clang-format is distributed with a driver script called git-clang-format-3.8.
Clang-format is distributed with a driver script called git-clang-format-7.
This script can be used to format git diffs (rather than entire files).

After committing some code, it is recommended to run:
```
git-clang-format-3.8 upstream/develop
git-clang-format-7 upstream/develop
```
*Important:* If your branch is based on a branch other than `upstream/develop`,
use the name or checksum of that branch instead. It is strongly recommended to
rebase your work onto the tip of the branch it's based on before running
`git-clang-format` in this way.

Note: By default, git-clang-format uses the git config variable
`clangformat.binary`. If you have multiple versions of clang-format installed,
you might need to update this, or explicitly specify the binary to use via
`--binary clang-format-7`.

### RETROACTIVELY FORMATTING INDIVIDUAL COMMITS

If your works spans several commits and you'd like to keep the formatting
Expand All @@ -355,7 +360,7 @@ The following command will stop at each commit in the range and run
clang-format on the diff at that point. This rewrites git history, so it's
*unsafe*, and you should back up your branch before running this command:
```
git filter-branch --tree-filter 'git-clang-format-3.8 upstream/develop' \
git filter-branch --tree-filter 'git-clang-format-7 upstream/develop' \
-- upstream/develop..HEAD
```
*Important*: `upstream/develop` should be changed in *both* places in the
Expand Down