€•n|Œsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ*/translations/zh_CN/dev-tools/clang-format”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/zh_TW/dev-tools/clang-format”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/it_IT/dev-tools/clang-format”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/ja_JP/dev-tools/clang-format”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/ko_KR/dev-tools/clang-format”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒPortuguese (Brazilian)”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/pt_BR/dev-tools/clang-format”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ*/translations/sp_SP/dev-tools/clang-format”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒtarget”“”)”}”(hŒ.. _clangformat:”h]”h}”(h]”h ]”h"]”h$]”h&]”Œrefid”Œ clangformat”uh1hµh´Khhh²hh³ŒD/var/lib/git/docbuild/linux/Documentation/dev-tools/clang-format.rst”ubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ clang-format”h]”hŒ clang-format”…””}”(hhËh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhhÆh²hh³hÃh´KubhŒ paragraph”“”)”}”(hŒÅ``clang-format`` is a tool to format C/C++/... code according to a set of rules and heuristics. Like most tools, it is not perfect nor covers every single case, but it is good enough to be helpful.”h]”(hŒliteral”“”)”}”(hŒ``clang-format``”h]”hŒ clang-format”…””}”(hháh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhhÛubhŒµ is a tool to format C/C++/... code according to a set of rules and heuristics. Like most tools, it is not perfect nor covers every single case, but it is good enough to be helpful.”…””}”(hhÛh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KhhÆh²hubhÚ)”}”(hŒ2``clang-format`` can be used for several purposes:”h]”(hà)”}”(hŒ``clang-format``”h]”hŒ clang-format”…””}”(hhýh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhhùubhŒ" can be used for several purposes:”…””}”(hhùh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K hhÆh²hubhŒ block_quote”“”)”}”(hXÎ- Quickly reformat a block of code to the kernel style. Specially useful when moving code around and aligning/sorting. See clangformatreformat_. - Spot style mistakes, typos and possible improvements in files you maintain, patches you review, diffs, etc. See clangformatreview_. - Help you follow the coding style rules, specially useful for those new to kernel development or working at the same time in several projects with different coding styles. ”h]”hŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒQuickly reformat a block of code to the kernel style. Specially useful when moving code around and aligning/sorting. See clangformatreformat_. ”h]”hÚ)”}”(hŒŽQuickly reformat a block of code to the kernel style. Specially useful when moving code around and aligning/sorting. See clangformatreformat_.”h]”(hŒyQuickly reformat a block of code to the kernel style. Specially useful when moving code around and aligning/sorting. See ”…””}”(hj&h²hh³Nh´NubhŒ reference”“”)”}”(hŒclangformatreformat_”h]”hŒclangformatreformat”…””}”(hj0h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œclangformatreformat”hÁŒclangformatreformat”uh1j.hj&Œresolved”KubhŒ.”…””}”(hj&h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K hj"ubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjubj!)”}”(hŒ„Spot style mistakes, typos and possible improvements in files you maintain, patches you review, diffs, etc. See clangformatreview_. ”h]”hÚ)”}”(hŒƒSpot style mistakes, typos and possible improvements in files you maintain, patches you review, diffs, etc. See clangformatreview_.”h]”(hŒpSpot style mistakes, typos and possible improvements in files you maintain, patches you review, diffs, etc. See ”…””}”(hjVh²hh³Nh´Nubj/)”}”(hŒclangformatreview_”h]”hŒclangformatreview”…””}”(hj^h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œclangformatreview”hÁŒclangformatreview”uh1j.hjVjAKubhŒ.”…””}”(hjVh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KhjRubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjubj!)”}”(hŒ«Help you follow the coding style rules, specially useful for those new to kernel development or working at the same time in several projects with different coding styles. ”h]”hÚ)”}”(hŒªHelp you follow the coding style rules, specially useful for those new to kernel development or working at the same time in several projects with different coding styles.”h]”hŒªHelp you follow the coding style rules, specially useful for those new to kernel development or working at the same time in several projects with different coding styles.”…””}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Khjubah}”(h]”h ]”h"]”h$]”h&]”uh1j hjubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1jh³hÃh´K hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÃh´K hhÆh²hubhÚ)”}”(hXöIts configuration file is ``.clang-format`` in the root of the kernel tree. The rules contained there try to approximate the most common kernel coding style. They also try to follow :ref:`Documentation/process/coding-style.rst ` as much as possible. Since not all the kernel follows the same style, it is possible that you may want to tweak the defaults for a particular subsystem or folder. To do so, you can override the defaults by writing another ``.clang-format`` file in a subfolder.”h]”(hŒIts configuration file is ”…””}”(hj¥h²hh³Nh´Nubhà)”}”(hŒ``.clang-format``”h]”hŒ .clang-format”…””}”(hj­h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhj¥ubhŒ‹ in the root of the kernel tree. The rules contained there try to approximate the most common kernel coding style. They also try to follow ”…””}”(hj¥h²hh³Nh´Nubh)”}”(hŒ;:ref:`Documentation/process/coding-style.rst `”h]”hŒinline”“”)”}”(hjÁh]”hŒ&Documentation/process/coding-style.rst”…””}”(hjÅh²hh³Nh´Nubah}”(h]”h ]”(Œxref”Œstd”Œstd-ref”eh"]”h$]”h&]”uh1jÃhj¿ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”Œdev-tools/clang-format”Œ refdomain”jÐŒreftype”Œref”Œ refexplicit”ˆŒrefwarn”ˆŒ reftarget”Œ codingstyle”uh1hh³hÃh´Khj¥ubhŒß as much as possible. Since not all the kernel follows the same style, it is possible that you may want to tweak the defaults for a particular subsystem or folder. To do so, you can override the defaults by writing another ”…””}”(hj¥h²hh³Nh´Nubhà)”}”(hŒ``.clang-format``”h]”hŒ .clang-format”…””}”(hjèh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhj¥ubhŒ file in a subfolder.”…””}”(hj¥h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KhhÆh²hubhÚ)”}”(hŒÿThe tool itself has already been included in the repositories of popular Linux distributions for a long time. Search for ``clang-format`` in your repositories. Otherwise, you can either download pre-built LLVM/clang binaries or build the source code from:”h]”(hŒyThe tool itself has already been included in the repositories of popular Linux distributions for a long time. Search for ”…””}”(hjh²hh³Nh´Nubhà)”}”(hŒ``clang-format``”h]”hŒ clang-format”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhjubhŒv in your repositories. Otherwise, you can either download pre-built LLVM/clang binaries or build the source code from:”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KhhÆh²hubj)”}”(hŒ(https://releases.llvm.org/download.html ”h]”hÚ)”}”(hŒ'https://releases.llvm.org/download.html”h]”j/)”}”(hj&h]”hŒ'https://releases.llvm.org/download.html”…””}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”j&uh1j.hj$ubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K#hj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÃh´K#hhÆh²hubhÚ)”}”(hŒ'See more information about the tool at:”h]”hŒ'See more information about the tool at:”…””}”(hjBh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K%hhÆh²hubj)”}”(hŒhhttps://clang.llvm.org/docs/ClangFormat.html https://clang.llvm.org/docs/ClangFormatStyleOptions.html ”h]”(hÚ)”}”(hŒ,https://clang.llvm.org/docs/ClangFormat.html”h]”j/)”}”(hjVh]”hŒ,https://clang.llvm.org/docs/ClangFormat.html”…””}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”jVuh1j.hjTubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K'hjPubhÚ)”}”(hŒ8https://clang.llvm.org/docs/ClangFormatStyleOptions.html”h]”j/)”}”(hjnh]”hŒ8https://clang.llvm.org/docs/ClangFormatStyleOptions.html”…””}”(hjph²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”jnuh1j.hjlubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K)hjPubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÃh´K'hhÆh²hubh¶)”}”(hŒ.. _clangformatreview:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÁjnuh1hµh´K,hhÆh²hh³hÃŒ referenced”KubhÅ)”}”(hhh]”(hÊ)”}”(hŒ)Review files and patches for coding style”h]”hŒ)Review files and patches for coding style”…””}”(hj˜h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhj•h²hh³hÃh´K/ubhÚ)”}”(hŒ“By running the tool in its inline mode, you can review full subsystems, folders or individual files for code style mistakes, typos or improvements.”h]”hŒ“By running the tool in its inline mode, you can review full subsystems, folders or individual files for code style mistakes, typos or improvements.”…””}”(hj¦h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K1hj•h²hubhÚ)”}”(hŒ&To do so, you can run something like::”h]”hŒ%To do so, you can run something like:”…””}”(hj´h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K4hj•h²hubhŒ literal_block”“”)”}”(hŒJ# Make sure your working directory is clean! clang-format -i kernel/*.[ch]”h]”hŒJ# Make sure your working directory is clean! clang-format -i kernel/*.[ch]”…””}”hjÄsbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1jÂh³hÃh´K6hj•h²hubhÚ)”}”(hŒ%And then take a look at the git diff.”h]”hŒ%And then take a look at the git diff.”…””}”(hjÔh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K9hj•h²hubhÚ)”}”(hŒ¯Counting the lines of such a diff is also useful for improving/tweaking the style options in the configuration file; as well as testing new ``clang-format`` features/versions.”h]”(hŒŒCounting the lines of such a diff is also useful for improving/tweaking the style options in the configuration file; as well as testing new ”…””}”(hjâh²hh³Nh´Nubhà)”}”(hŒ``clang-format``”h]”hŒ clang-format”…””}”(hjêh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhjâubhŒ features/versions.”…””}”(hjâh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K;hj•h²hubhÚ)”}”(hŒ``clang-format`` also supports reading unified diffs, so you can review patches and git diffs easily. See the documentation at:”h]”(hà)”}”(hŒ``clang-format``”h]”hŒ clang-format”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhjubhŒo also supports reading unified diffs, so you can review patches and git diffs easily. See the documentation at:”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K?hj•h²hubj)”}”(hŒKhttps://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting ”h]”hÚ)”}”(hŒJhttps://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting”h]”j/)”}”(hj$h]”hŒJhttps://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting”…””}”(hj&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”j$uh1j.hj"ubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KBhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÃh´KBhj•h²hubhÚ)”}”(hŒITo avoid ``clang-format`` formatting some portion of a file, you can do::”h]”(hŒ To avoid ”…””}”(hj@h²hh³Nh´Nubhà)”}”(hŒ``clang-format``”h]”hŒ clang-format”…””}”(hjHh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhj@ubhŒ/ formatting some portion of a file, you can do:”…””}”(hj@h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KDhj•h²hubjÃ)”}”(hŒuint formatted_code; // clang-format off void unformatted_code ; // clang-format on void formatted_code_again;”h]”hŒuint formatted_code; // clang-format off void unformatted_code ; // clang-format on void formatted_code_again;”…””}”hj`sbah}”(h]”h ]”h"]”h$]”h&]”jÒjÓuh1jÂh³hÃh´KFhj•h²hubhÚ)”}”(hXžWhile it might be tempting to use this to keep a file always in sync with ``clang-format``, specially if you are writing new files or if you are a maintainer, please note that people might be running different ``clang-format`` versions or not have it available at all. Therefore, you should probably refrain yourself from using this in kernel sources; at least until we see if ``clang-format`` becomes commonplace.”h]”(hŒJWhile it might be tempting to use this to keep a file always in sync with ”…””}”(hjnh²hh³Nh´Nubhà)”}”(hŒ``clang-format``”h]”hŒ clang-format”…””}”(hjvh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhjnubhŒx, specially if you are writing new files or if you are a maintainer, please note that people might be running different ”…””}”(hjnh²hh³Nh´Nubhà)”}”(hŒ``clang-format``”h]”hŒ clang-format”…””}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhjnubhŒ— versions or not have it available at all. Therefore, you should probably refrain yourself from using this in kernel sources; at least until we see if ”…””}”(hjnh²hh³Nh´Nubhà)”}”(hŒ``clang-format``”h]”hŒ clang-format”…””}”(hjšh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhjnubhŒ becomes commonplace.”…””}”(hjnh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KLhj•h²hubh¶)”}”(hŒ.. _clangformatreformat:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÁj@uh1hµh´KThj•h²hh³hÃj”Kubeh}”(h]”(Œ)review-files-and-patches-for-coding-style”jneh ]”h"]”(Œ)review files and patches for coding style”Œclangformatreview”eh$]”h&]”uh1hÄhhÆh²hh³hÃh´K/Œexpect_referenced_by_name”}”jÂjŠsŒexpect_referenced_by_id”}”jnjŠsj”KubhÅ)”}”(hhh]”(hÊ)”}”(hŒReformatting blocks of code”h]”hŒReformatting blocks of code”…””}”(hjÌh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhjÉh²hh³hÃh´KWubhÚ)”}”(hXBy using an integration with your text editor, you can reformat arbitrary blocks (selections) of code with a single keystroke. This is specially useful when moving code around, for complex code that is deeply indented, for multi-line macros (and aligning their backslashes), etc.”h]”hXBy using an integration with your text editor, you can reformat arbitrary blocks (selections) of code with a single keystroke. This is specially useful when moving code around, for complex code that is deeply indented, for multi-line macros (and aligning their backslashes), etc.”…””}”(hjÚh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KYhjÉh²hubhÚ)”}”(hŒ§Remember that you can always tweak the changes afterwards in those cases where the tool did not do an optimal job. But as a first approximation, it can be very useful.”h]”hŒ§Remember that you can always tweak the changes afterwards in those cases where the tool did not do an optimal job. But as a first approximation, it can be very useful.”…””}”(hjèh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K^hjÉh²hubhÚ)”}”(hŒÃThere are integrations for many popular text editors. For some of them, like vim, emacs, BBEdit and Visual Studio you can find support built-in. For instructions, read the appropriate section at:”h]”hŒÃThere are integrations for many popular text editors. For some of them, like vim, emacs, BBEdit and Visual Studio you can find support built-in. For instructions, read the appropriate section at:”…””}”(hjöh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KbhjÉh²hubj)”}”(hŒ-https://clang.llvm.org/docs/ClangFormat.html ”h]”hÚ)”}”(hŒ,https://clang.llvm.org/docs/ClangFormat.html”h]”j/)”}”(hj h]”hŒ,https://clang.llvm.org/docs/ClangFormat.html”…””}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”j uh1j.hjubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Kfhjubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÃh´KfhjÉh²hubhÚ)”}”(hŒ†For Atom, Eclipse, Sublime Text, Visual Studio Code, XCode and other editors and IDEs you should be able to find ready-to-use plugins.”h]”hŒ†For Atom, Eclipse, Sublime Text, Visual Studio Code, XCode and other editors and IDEs you should be able to find ready-to-use plugins.”…””}”(hj&h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KhhjÉh²hubhÚ)”}”(hŒ{For this use case, consider using a secondary ``.clang-format`` so that you can tweak a few options. See clangformatextra_.”h]”(hŒ.For this use case, consider using a secondary ”…””}”(hj4h²hh³Nh´Nubhà)”}”(hŒ``.clang-format``”h]”hŒ .clang-format”…””}”(hj<h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhj4ubhŒ* so that you can tweak a few options. See ”…””}”(hj4h²hh³Nh´Nubj/)”}”(hŒclangformatextra_”h]”hŒclangformatextra”…””}”(hjNh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œname”Œclangformatextra”hÁŒclangformatextra”uh1j.hj4jAKubhŒ.”…””}”(hj4h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KkhjÉh²hubh¶)”}”(hŒ.. _clangformatmissing:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÁŒclangformatmissing”uh1hµh´KohjÉh²hh³hÃubeh}”(h]”(Œreformatting-blocks-of-code”j@eh ]”h"]”(Œreformatting blocks of code”Œclangformatreformat”eh$]”h&]”uh1hÄhhÆh²hh³hÃh´KWjÅ}”jzj²sjÇ}”j@j²sj”KubhÅ)”}”(hhh]”(hÊ)”}”(hŒMissing support”h]”hŒMissing support”…””}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhjh²hh³hÃh´KrubhÚ)”}”(hŒ¾``clang-format`` is missing support for some things that are common in kernel code. They are easy to remember, so if you use the tool regularly, you will quickly learn to avoid/ignore those.”h]”(hà)”}”(hŒ``clang-format``”h]”hŒ clang-format”…””}”(hj”h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhjubhŒ® is missing support for some things that are common in kernel code. They are easy to remember, so if you use the tool regularly, you will quickly learn to avoid/ignore those.”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Kthjh²hubhÚ)”}”(hŒ9In particular, some very common ones you will notice are:”h]”hŒ9In particular, some very common ones you will notice are:”…””}”(hj¬h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´Kxhjh²hubj)”}”(hXé- Aligned blocks of one-line ``#defines``, e.g.:: #define TRACING_MAP_BITS_DEFAULT 11 #define TRACING_MAP_BITS_MAX 17 #define TRACING_MAP_BITS_MIN 7 vs.:: #define TRACING_MAP_BITS_DEFAULT 11 #define TRACING_MAP_BITS_MAX 17 #define TRACING_MAP_BITS_MIN 7 - Aligned designated initializers, e.g.:: static const struct file_operations uprobe_events_ops = { .owner = THIS_MODULE, .open = probes_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, .write = probes_write, }; vs.:: static const struct file_operations uprobe_events_ops = { .owner = THIS_MODULE, .open = probes_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, .write = probes_write, }; ”h]”j)”}”(hhh]”(j!)”}”(hX1Aligned blocks of one-line ``#defines``, e.g.:: #define TRACING_MAP_BITS_DEFAULT 11 #define TRACING_MAP_BITS_MAX 17 #define TRACING_MAP_BITS_MIN 7 vs.:: #define TRACING_MAP_BITS_DEFAULT 11 #define TRACING_MAP_BITS_MAX 17 #define TRACING_MAP_BITS_MIN 7 ”h]”(hÚ)”}”(hŒ/Aligned blocks of one-line ``#defines``, e.g.::”h]”(hŒAligned blocks of one-line ”…””}”(hjÅh²hh³Nh´Nubhà)”}”(hŒ ``#defines``”h]”hŒ#defines”…””}”(hjÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhjÅubhŒ, e.g.:”…””}”(hjÅh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´KzhjÁubjÃ)”}”(hŒ|#define TRACING_MAP_BITS_DEFAULT 11 #define TRACING_MAP_BITS_MAX 17 #define TRACING_MAP_BITS_MIN 7”h]”hŒ|#define TRACING_MAP_BITS_DEFAULT 11 #define TRACING_MAP_BITS_MAX 17 #define TRACING_MAP_BITS_MIN 7”…””}”hjåsbah}”(h]”h ]”h"]”h$]”h&]”jÒjÓuh1jÂh³hÃh´K|hjÁubhÚ)”}”(hŒvs.::”h]”hŒvs.:”…””}”(hjóh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K€hjÁubjÃ)”}”(hŒb#define TRACING_MAP_BITS_DEFAULT 11 #define TRACING_MAP_BITS_MAX 17 #define TRACING_MAP_BITS_MIN 7”h]”hŒb#define TRACING_MAP_BITS_DEFAULT 11 #define TRACING_MAP_BITS_MAX 17 #define TRACING_MAP_BITS_MIN 7”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”jÒjÓuh1jÂh³hÃh´K‚hjÁubeh}”(h]”h ]”h"]”h$]”h&]”uh1j hj¾ubj!)”}”(hXƒAligned designated initializers, e.g.:: static const struct file_operations uprobe_events_ops = { .owner = THIS_MODULE, .open = probes_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, .write = probes_write, }; vs.:: static const struct file_operations uprobe_events_ops = { .owner = THIS_MODULE, .open = probes_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, .write = probes_write, }; ”h]”(hÚ)”}”(hŒ'Aligned designated initializers, e.g.::”h]”hŒ&Aligned designated initializers, e.g.:”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K†hjubjÃ)”}”(hX"static const struct file_operations uprobe_events_ops = { .owner = THIS_MODULE, .open = probes_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, .write = probes_write, };”h]”hX"static const struct file_operations uprobe_events_ops = { .owner = THIS_MODULE, .open = probes_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, .write = probes_write, };”…””}”hj'sbah}”(h]”h ]”h"]”h$]”h&]”jÒjÓuh1jÂh³hÃh´KˆhjubhÚ)”}”(hŒvs.::”h]”hŒvs.:”…””}”(hj5h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K‘hjubjÃ)”}”(hŒístatic const struct file_operations uprobe_events_ops = { .owner = THIS_MODULE, .open = probes_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, .write = probes_write, };”h]”hŒístatic const struct file_operations uprobe_events_ops = { .owner = THIS_MODULE, .open = probes_open, .read = seq_read, .llseek = seq_lseek, .release = seq_release, .write = probes_write, };”…””}”hjCsbah}”(h]”h ]”h"]”h$]”h&]”jÒjÓuh1jÂh³hÃh´K“hjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j hj¾ubeh}”(h]”h ]”h"]”h$]”h&]”jjžuh1jh³hÃh´Kzhjºubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÃh´Kzhjh²hubh¶)”}”(hŒ.. _clangformatextra:”h]”h}”(h]”h ]”h"]”h$]”h&]”hÁj^uh1hµh´Khjh²hh³hÃj”Kubeh}”(h]”(Œmissing-support”jseh ]”h"]”(Œmissing support”Œclangformatmissing”eh$]”h&]”uh1hÄhhÆh²hh³hÃh´KrjÅ}”jsjisjÇ}”jsjisubhÅ)”}”(hhh]”(hÊ)”}”(hŒExtra features/options”h]”hŒExtra features/options”…””}”(hj{h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhjxh²hh³hÃh´K ubhÚ)”}”(hX1Some features/style options are not enabled by default in the configuration file in order to minimize the differences between the output and the current code. In other words, to make the difference as small as possible, which makes reviewing full-file style, as well diffs and patches as easy as possible.”h]”hX1Some features/style options are not enabled by default in the configuration file in order to minimize the differences between the output and the current code. In other words, to make the difference as small as possible, which makes reviewing full-file style, as well diffs and patches as easy as possible.”…””}”(hj‰h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K¢hjxh²hubhÚ)”}”(hŒ©In other cases (e.g. particular subsystems/folders/files), the kernel style might be different and enabling some of these options may approximate better the style there.”h]”hŒ©In other cases (e.g. particular subsystems/folders/files), the kernel style might be different and enabling some of these options may approximate better the style there.”…””}”(hj—h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K¨hjxh²hubhÚ)”}”(hŒ For instance:”h]”hŒ For instance:”…””}”(hj¥h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K¬hjxh²hubj)”}”(hŒØ- Aligning assignments (``AlignConsecutiveAssignments``). - Aligning declarations (``AlignConsecutiveDeclarations``). - Reflowing text in comments (``ReflowComments``). - Sorting ``#includes`` (``SortIncludes``). ”h]”j)”}”(hhh]”(j!)”}”(hŒ8Aligning assignments (``AlignConsecutiveAssignments``). ”h]”hÚ)”}”(hŒ7Aligning assignments (``AlignConsecutiveAssignments``).”h]”(hŒAligning assignments (”…””}”(hj¾h²hh³Nh´Nubhà)”}”(hŒ``AlignConsecutiveAssignments``”h]”hŒAlignConsecutiveAssignments”…””}”(hjÆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhj¾ubhŒ).”…””}”(hj¾h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K®hjºubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj·ubj!)”}”(hŒ:Aligning declarations (``AlignConsecutiveDeclarations``). ”h]”hÚ)”}”(hŒ9Aligning declarations (``AlignConsecutiveDeclarations``).”h]”(hŒAligning declarations (”…””}”(hjèh²hh³Nh´Nubhà)”}”(hŒ ``AlignConsecutiveDeclarations``”h]”hŒAlignConsecutiveDeclarations”…””}”(hjðh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhjèubhŒ).”…””}”(hjèh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K°hjäubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj·ubj!)”}”(hŒ1Reflowing text in comments (``ReflowComments``). ”h]”hÚ)”}”(hŒ0Reflowing text in comments (``ReflowComments``).”h]”(hŒReflowing text in comments (”…””}”(hjh²hh³Nh´Nubhà)”}”(hŒ``ReflowComments``”h]”hŒReflowComments”…””}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhjubhŒ).”…””}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K²hjubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj·ubj!)”}”(hŒ*Sorting ``#includes`` (``SortIncludes``). ”h]”hÚ)”}”(hŒ)Sorting ``#includes`` (``SortIncludes``).”h]”(hŒSorting ”…””}”(hj<h²hh³Nh´Nubhà)”}”(hŒ ``#includes``”h]”hŒ #includes”…””}”(hjDh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhj<ubhŒ (”…””}”(hj<h²hh³Nh´Nubhà)”}”(hŒ``SortIncludes``”h]”hŒ SortIncludes”…””}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhj<ubhŒ).”…””}”(hj<h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K´hj8ubah}”(h]”h ]”h"]”h$]”h&]”uh1j hj·ubeh}”(h]”h ]”h"]”h$]”h&]”jjžuh1jh³hÃh´K®hj³ubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÃh´K®hjxh²hubhÚ)”}”(hŒ°They are typically useful for block re-formatting, rather than full-file. You might want to create another ``.clang-format`` file and use that one from your editor/IDE instead.”h]”(hŒkThey are typically useful for block re-formatting, rather than full-file. You might want to create another ”…””}”(hj€h²hh³Nh´Nubhà)”}”(hŒ``.clang-format``”h]”hŒ .clang-format”…””}”(hjˆh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hßhj€ubhŒ4 file and use that one from your editor/IDE instead.”…””}”(hj€h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÙh³hÃh´K¶hjxh²hubeh}”(h]”(Œextra-features-options”j^eh ]”h"]”(Œextra features/options”Œclangformatextra”eh$]”h&]”uh1hÄhhÆh²hh³hÃh´K jÅ}”j¦jcsjÇ}”j^jcsj”Kubeh}”(h]”(Œ clang-format”hÂeh ]”h"]”(Œ clang-format”Œ clangformat”eh$]”h&]”uh1hÄhhh²hh³hÃh´KjÅ}”j±h·sjÇ}”hÂh·subeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÃuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(hÉNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jÙŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÃŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”(Œclangformatreformat”]”j0aŒclangformatreview”]”j^aŒclangformatextra”]”jNauŒrefids”}”(hÂ]”h·ajn]”jŠaj@]”j²ajs]”jiaj^]”jcauŒnameids”}”(j±hÂj°j­jÂjnjÁj¾jzj@jyjvjsjsjrjoj¦j^j¥j¢uŒ nametypes”}”(j±ˆj°‰jˆjÁ‰jzˆjy‰jsˆjr‰j¦ˆj¥‰uh}”(hÂhÆj­hÆjnj•j¾j•j@jÉjvjÉjsjjojj^jxj¢jxuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”(hŒsystem_message”“”)”}”(hhh]”hÚ)”}”(hhh]”hŒ1Hyperlink target "clangformat" is not referenced.”…””}”hjMsbah}”(h]”h ]”h"]”h$]”h&]”uh1hÙhjJubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œsource”hÃŒline”Kuh1jHubjI)”}”(hhh]”hÚ)”}”(hhh]”hŒ8Hyperlink target "clangformatmissing" is not referenced.”…””}”hjhsbah}”(h]”h ]”h"]”h$]”h&]”uh1hÙhjeubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”jbŒsource”hÃŒline”Kouh1jHubeŒ transformer”NŒ include_log”]”Œ decoration”Nh²hub.