Lines Matching +full:clang +full:- +full:format

7 (.editorconfig) and/or Emacs (.dir-locals.el) file. Alternatively the
9 try following the format of existing, neighboring code.
11 ``clang-format``
12 ----------------
14 A growing number of drivers and components are adopting ``clang-format``
17 You can re-format the code for the components that have opted-in to the
18 formatting enforcement (listed in ``.clang-format-include``) by simply
19 running ``ninja -C build/ clang-format``.
21 Since mass-reformatting commits can be an annoying extra jump to go
25 git config blame.ignoreRevsFile .git-blame-ignore-revs
28 write it; check your editor or its plug-ins to see how to enable this.
33 Add this to your ``.vimrc`` to automatically format any C & C++ file
34 (that has a .clang-format config) when you save it:
42 " Only format files that have a .clang-format in a parent folder
43 if !empty(findfile('.clang-format', '.;'))
44 let l:formatdiff = 1 " Only format lines that have changed
45 py3f /usr/share/clang/clang-format.py
52 If ``/usr/share/clang/clang-format.py`` doesn't exist, try
53 ``/usr/share/clang/clang-format-$CLANG_VERSION/clang-format.py``
54 (replacing ``$CLANG_VERSION`` with your clang version). If your distro
56 providing ``clang-format``.
61 Add this to your ``.emacs`` to automatically format any C & C++ file
62 (that has a .clang-format config) when you save it:
66 (load "/usr/share/clang/clang-format.el")
68 (defun clang-format-save-hook-for-this-buffer ()
70 (add-hook 'before-save-hook
72 (when (locate-dominating-file "." ".clang-format")
73 (clang-format-buffer))
81 (add-hook 'c-mode-hook (lambda () (clang-format-save-hook-for-this-buffer)))
82 (add-hook 'c++-mode-hook (lambda () (clang-format-save-hook-for-this-buffer)))
84 If ``/usr/share/clang/clang-format.el`` doesn't exist, look through the
85 files in the package providing ``clang-format`` in your distro. If you
87 answer <https://stackoverflow.com/questions/59690583/how-do-you-use-clang-format-on-emacs-ubuntu/59…
88 to install clang-format through Emacs instead.
90 git ``pre-commit`` hook
94 can always just run ``ninja clang-format`` to format everything, or add
95 a ``pre-commit`` hook that runs this automatically whenever you ``git
96 commit`` by adding the following in your ``.git/hooks/pre-commit``:
100 shopt -s globstar
101 git clang-format $upstream -- $(grep -E '^[^#]' .clang-format-include)
107 ---------------------------
109 - 3-space indentation, no tabs.
110 - Limit lines to 78 or fewer characters. The idea is to prevent line
111 wrapping in 80-column editors and terminals. There are exceptions,
113 - Opening braces go on the same line as the if/for/while statement. For
116 .. code-block:: c
124 - Put a space before/after operators. For example, ``a = b + c;`` and
126 - This GNU indent command generally does the right thing for
129 .. code-block:: sh
131 indent -br -i3 -npcs --no-tabs infile.c -o outfile.c
133 - Use comments wherever you think it would be helpful for other
138 Single-line comments:
140 .. code-block:: c
142 /* null-out pointer to prevent dangling reference below */
147 .. code-block:: c
151 Multi-line comment:
153 .. code-block:: c
161 .. code-block:: c
177 .. code-block:: c
181 * ctx->Driver.CreateObject() driver callback function.
192 - Put the function return type and qualifiers on one line and the
197 - Function names follow various conventions depending on the type of
200 +---------------------+------------------------------------------+
205 +---------------------+------------------------------------------+
207 +---------------------+------------------------------------------+
210 +---------------------+------------------------------------------+
212 +---------------------+------------------------------------------+
213 | ``_mesa_foo_bar()`` | an internal non-static Mesa function |
214 +---------------------+------------------------------------------+
216 - Constants, macros and enum names are ``ALL_UPPERCASE``, with \_
218 - Mesa usually uses camel case for local variables (Ex:
221 - Global variables are almost never used because Mesa should be
222 thread-safe.
223 - Booleans. Places that are not directly visible to the GL API should