Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: c++/clang-format/README.md

Issue 29537634: Noissue - clang-format configuration file for C++
Left Patch Set: Created Sept. 6, 2017, 1:44 p.m.
Right Patch Set: new version Created Sept. 15, 2017, 12:31 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | c++/clang-format/clang-format-eyeo » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 clang-format-eyeo 1 clang-format-eyeo
2 ================= 2 =================
3 3
4 A file containing style configuration for [`clang-format`](http://clang.llvm.org /docs/ClangFormat.html) 4 A file containing style configuration for [`clang-format`][clang-format-docs]
5 that formats according to the [Adblock Plus coding style guide](https://adblockp lus.org/coding-style#cpp) 5 that formats according to the
6 for C++. 6 [Adblock Plus coding style guide][abp-coding-style-cpp] for C++.
7 7
8 Installation 8 Installation
9 ------------ 9 ------------
10 10
11 When `clang-format` receives its style configuration from a file, it searches 11 When `clang-format` receives its style configuration from a file, it searches
12 for style configuration in the directory of each input file and then each parent 12 for style configuration in the directory of each input file and then each parent
13 directory. Copy the format file to the parent directory of the working 13 directory. Copy the format file to the parent directory of the working
14 directory. In this way it will `clang-format` will find the format file and 14 directory. In this way it will `clang-format` will find the format file and
15 the version control system will not. 15 the version control system will not.
16 16
17 The configuration file must be named either "`.clang-format`" or "`_clang-format `". 17 The configuration file must be named either "`.clang-format`" or
18 At the present time there's no command line option to specify the file name. 18 "`_clang-format`". At the present time there's no command line option to specify
19 the file name.
19 20
20 Usage 21 Usage
21 ----- 22 -----
22 23
23 clang-format -style=file [...] 24 clang-format -style=file [...]
24 25
25 The option "-style=file" (note that this is the word "file", not a file name) 26 The option "-style=file" (note that this is the word "file", not a file name)
26 says to perform a directory search for the configuration. For the rest of the 27 says to perform a directory search for the configuration. For the rest of the
27 command line, see the `clang-format` documentation link above. 28 command line, see the `clang-format` documentation link above.
29
30 Notes
31 -----
32
33 `clang-format` is a complete reformatter; it largely ignores whitespace within
34 the input and reformats code according to its specified rules. Its treatment of
35 whitespace within comments, however, is different, within which it preserves
36 whitespace by default. If the automatically-formatted code is not acceptable,
37 interventions are available.
38
39 * Formatting can be turned on and off with explicit special comments.
40
41 ```
42 // clang-format off
43 // clang-format on
44 /* clang-format off */
45 /* clang-format on */
46 ```
47
48 * Line-end comments contain an embedded newline that `clang-format` will retain.
49 To prevent a manually-split line from unwrapping, add a `//`-comment at the end
50 of the line; it can be empty.
51
52 For more information, see the answer to this Stack Overflow question:
53 [Clang-format line breaks][SO-1]
54
55 Clang Version Support
56 ---------------------
57 The present version is for Clang 4. One option (`BreakConstructorInitializers`)
58 we're using has changed in Clang 5. If you want to use Clang 5, edit the file as
59 part of installation. Uncomment the new version and comment out the old one.
60
61
62 [clang-format-docs]: http://clang.llvm.org/docs/ClangFormat.html
63 [abp-coding-style-cpp]: https://adblockplus.org/coding-style#cpp
64 [SO-1]: https://stackoverflow.com/questions/33656800/clang-format-line-breaks#an swer-34362422
LEFTRIGHT

Powered by Google App Engine
This is Rietveld