From 9c1349047edb660095eba11ae8444970e97f375d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Wed, 14 Sep 2022 14:09:25 +0200 Subject: [PATCH] clang-format: codify some of our conventions 1. We tend to use 2 spaces for indenting pre-processor directives, when we do it. Unfortunately clang-format also counts header-guards so not really recommended to use blindly on a header... 2. Add comments to namespaces, since the closing brace is simply a brace with no further decoration. 3. Attach escaped new-lines on the left (instead of current: right). Where 'right' will add the '\' characters on the far-right of our column limit, 'left' will put them as far left as it can while having them vertically aligned. Change-Id: Ib5a836c76f7761d743e0100c83e7db609b959249 Reviewed-by: Thiago Macieira Reviewed-by: Kai Koehne --- _clang-format | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/_clang-format b/_clang-format index 19d2e364..085320ad 100644 --- a/_clang-format +++ b/_clang-format @@ -62,6 +62,8 @@ NamespaceIndentation: None # Allow indentation for preprocessing directives (if/ifdef/endif). https://reviews.llvm.org/rL312125 IndentPPDirectives: AfterHash +# We only indent with 2 spaces for preprocessor directives +PPIndentWidth: 2 # Horizontally align arguments after an open bracket. # The coding style does not specify the following, but this is what gives @@ -85,6 +87,21 @@ ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCH # Break constructor initializers before the colon and after the commas. BreakConstructorInitializers: BeforeColon +# Add "// namespace " comments on closing brace for a namespace +# Ignored for namespaces that qualify as a short namespace, +# see 'ShortNamespaceLines' +FixNamespaceComments: true + +# Definition of how short a short namespace is, default 1 +ShortNamespaceLines: 1 + +# When escaping newlines in a macro attach the '\' as far left as possible, e.g. +##define a \ +# something; \ +# other; \ +# thelastlineislong; +AlignEscapedNewlines: Left + # Avoids the addition of a space between an identifier and the # initializer list in list-initialization. SpaceBeforeCpp11BracedList: false